forked from halo-battle/game
Version 1.12
This commit is contained in:
parent
2a066a7498
commit
de31cd3e9a
1373 changed files with 156282 additions and 45238 deletions
225
htdocs/n3p7bLn59Yco3d/js/animations.js
Normal file
225
htdocs/n3p7bLn59Yco3d/js/animations.js
Normal file
|
|
@ -0,0 +1,225 @@
|
|||
function create(type,parent,id,classe)
|
||||
{
|
||||
var element = document.createElement(type);
|
||||
if(id && !$(id)) element.setAttribute('id',id);
|
||||
if(classe) Element.addClassName(element,classe);
|
||||
if(parent) element = $(parent).appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
var Effect =
|
||||
{
|
||||
queue : [],
|
||||
|
||||
hide : function(element)
|
||||
{
|
||||
element.style.display = 'none';
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
show : function(element)
|
||||
{
|
||||
element.style.display = '';
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
opacity : function(element,opacity)
|
||||
{
|
||||
element.style.opacity = opacity / 100;
|
||||
element.style.MozOpacity = opacity / 100;
|
||||
element.style.KhtmlOpacity = opacity / 100;
|
||||
element.style.filter = "alpha(opacity="+ opacity +")";
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
style : function(element,style)
|
||||
{
|
||||
for(var property in style)
|
||||
{
|
||||
if(property == 'opacity') Effect.opacity(element,style[property]);
|
||||
else element.style[property] = style[property];
|
||||
}
|
||||
|
||||
return element;
|
||||
},
|
||||
|
||||
animate : function(element,style,speed) //usage : Effect.animate(element,{backgroundColor: [[0,0,0],[0,255,255]], fontSize: [12,14,'px']},500)
|
||||
{
|
||||
for(var i = 0; i < Effect.queue.length; i++) if(Effect.queue[i] == element) return false;
|
||||
Effect.queue.push(element);
|
||||
|
||||
var anim = {};
|
||||
var noanim = {};
|
||||
|
||||
var dif = 0;
|
||||
|
||||
for(var property in style)
|
||||
{
|
||||
if(typeof style[property] == 'string')
|
||||
noanim[property] = style[property];
|
||||
|
||||
else if(typeof style[property] == 'number')
|
||||
anim[property] = [!element.style.property ? 0 : element.style.property , style[property]];
|
||||
|
||||
else if(typeof style[property] == 'object')
|
||||
{
|
||||
if(style[property].length == 1)
|
||||
noanim[property] = style[property][0];
|
||||
|
||||
else if(style[property].length == 2 || style[property].length == 3)
|
||||
{
|
||||
if(typeof style[property][0] == 'number' && typeof style[property][1] == 'number')
|
||||
{
|
||||
anim[property] = style[property];
|
||||
}
|
||||
|
||||
else if(typeof style[property][0] == 'number' && typeof style[property][1] == 'string')
|
||||
{
|
||||
anim[property] = [!element.style[property] ? 0 : element.style[property].substr(0,element.style[property].length - style[property][1].length) , style[property][0], style[property][1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Effect.style(element,noanim);
|
||||
|
||||
for(var property in anim) dif = dif < Math.abs(anim[property][0] - anim[property][1]) ? Math.abs(anim[property][0] - anim[property][1]) : dif;
|
||||
|
||||
for(var i=1; i <= dif ;i++)
|
||||
{
|
||||
|
||||
for(var property in anim)
|
||||
{
|
||||
var from = Number(anim[property][0]);
|
||||
var to = Number(anim[property][1]);
|
||||
var ext = typeof anim[property][2] != 'undefined' ? anim[property][2] : 0;
|
||||
|
||||
var count = Math.floor(from + i*(to - from) / dif);
|
||||
|
||||
var funct = function()
|
||||
{
|
||||
var style = {};
|
||||
style[this.property] = this.count+this.ext;
|
||||
Effect.style(element,style);
|
||||
};
|
||||
|
||||
setTimeout(funct.bind({property: property,count: count,ext: ext}),Math.floor(i/dif*speed));
|
||||
}
|
||||
}
|
||||
setTimeout(function(){for(var i = 0; i < Effect.queue.length; i++) if(Effect.queue[i] == element) Effect.queue[i] = null},speed+10);
|
||||
return element;
|
||||
},
|
||||
|
||||
fadeIn: function(element,speed)
|
||||
{
|
||||
Effect.animate(element,{visibility: 'visible',opacity: [0,100]},speed);
|
||||
},
|
||||
|
||||
fadeOut: function(element,speed)
|
||||
{
|
||||
Effect.animate(element,{opacity: [100,0]},speed);
|
||||
setTimeout(function(){Effect.style(element,{visibility: 'hidden'})},speed);
|
||||
},
|
||||
|
||||
move : function(element,relative,from,to,speed)
|
||||
{
|
||||
switch(relative)
|
||||
{
|
||||
case 'top':
|
||||
case 'left':
|
||||
case 'bottom':
|
||||
case 'right':
|
||||
var anim = {};
|
||||
anim[relative] = [from,to,'px'];
|
||||
Effect.animate(element,anim,speed);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/*Element.prototype.effect.hide = function()
|
||||
{
|
||||
return Effect.hide(this);
|
||||
};
|
||||
|
||||
Element.prototype.effect.show = function()
|
||||
{
|
||||
return Effect.show(this);
|
||||
};*/
|
||||
|
||||
Object.extend(Element.prototype,{
|
||||
opacity : function(opacity)
|
||||
{
|
||||
return Effect.opacity(this,opacity);
|
||||
},
|
||||
|
||||
setStyle : function(style)
|
||||
{
|
||||
return Effect.style(this,style);
|
||||
},
|
||||
|
||||
animate : function(style,speed)
|
||||
{
|
||||
return Effect.animate(this,style,speed);
|
||||
},
|
||||
|
||||
fadeIn : function(speed)
|
||||
{
|
||||
return Effect.fadeIn(this,speed);
|
||||
},
|
||||
|
||||
fadeOut : function(speed)
|
||||
{
|
||||
return Effect.fadeOut(this,speed);
|
||||
},
|
||||
|
||||
move : function(relative,from,to,speed)
|
||||
{
|
||||
return Effect.move(this,relative,from,to,speed);
|
||||
}
|
||||
});
|
||||
|
||||
Element.addMethods();
|
||||
|
||||
/*Element.prototype.opacity = function(opacity)
|
||||
{
|
||||
return Effect.opacity(this,opacity);
|
||||
};
|
||||
|
||||
Element.prototype.setStyle = function(style)
|
||||
{
|
||||
return Effect.style(this,style);
|
||||
};
|
||||
|
||||
Element.prototype.animate = function(style,speed)
|
||||
{
|
||||
return Effect.animate(this,style,speed);
|
||||
};
|
||||
|
||||
Element.prototype.fadeIn = function(speed)
|
||||
{
|
||||
return Effect.fadeIn(this,speed);
|
||||
};
|
||||
|
||||
Element.prototype.fadeOut = function(speed)
|
||||
{
|
||||
return Effect.fadeOut(this,speed);
|
||||
};
|
||||
|
||||
Element.prototype.move = function(relative,from,to,speed)
|
||||
{
|
||||
return Effect.move(this,relative,from,to,speed);
|
||||
};*/
|
||||
|
||||
/*create('div',document.body,'test2');
|
||||
myfunct = function(){ $('test2').innerHTML += this.i };
|
||||
for(var i = 1; i < 20; i++)
|
||||
{
|
||||
setTimeout(myfunct.bind({i:i}),1000*i);
|
||||
}*/
|
||||
|
||||
/*var masque = [/#([0-9A-F]{6}|[0-9A-F]{3})/i,
|
||||
/rgb\((\d{1,3})%?,(\d{1,3})%?,(\d{1,3})%?\)/i,
|
||||
/\d+(px|pc|pt|ex|em|mm|cm|in|%)/i];*/
|
||||
534
htdocs/n3p7bLn59Yco3d/js/api.js
Normal file
534
htdocs/n3p7bLn59Yco3d/js/api.js
Normal file
|
|
@ -0,0 +1,534 @@
|
|||
|
||||
var Desktop =
|
||||
{
|
||||
|
||||
dom : {windows: {}},
|
||||
|
||||
ressources : {metal: 2000, cristal: 1500, ions: 1000, energie: [1000,1500]},
|
||||
|
||||
planete : 1, //Planete sélectionné
|
||||
|
||||
planetes : [[01,'Pegasi Alpha',8,31,4,1],[02,'Pegasi Beta',8,31,3,2],[03,'Pegasi Delta',8,31,2,3],[04,'Pegasi Zeta',8,31,1,4]], //id, nom , amas, syteme solaire, position, image.
|
||||
|
||||
menu : [['Fenêtre 1',fenetre1],['Fenêtre 2',fenetre2],['Batiments',batiments],['Dialog',dialog],['Notification',notification],['Double',doubler]],
|
||||
|
||||
descriptions : {
|
||||
batiments:
|
||||
{
|
||||
1:['Usine de Métal','metal.png','Le purificateur de métal vous fournit les matières premières pour la construction de vos infrastructures et de vos unités. Plus vous développerez vos purificateurs, plus ils produiront de ressources. Les purificateurs les plus développés ont aussi besoin de plus d\'énergie.'],
|
||||
2:['Purificateur de Cristal','cristal.png','Le purificateur de cristal vous fournit les ressources pour vos installations électroniques et pour les alliages. Le purificateur de cristal consomme deux fois plus d\'énergie que celui de métal. Tous les vaisseaux et bâtiments ont besoin de cristal pour leur bouclier ou encore leurs composants électroniques. La production augmente avec le développement de l\'usine.'],
|
||||
3:['Ionisateur','hydrogene.jpg','L\'ionisateur utilise des ions négatifs et positifs d\'hydrogène pour créer une source conventionnelle de courant stable, servant à alimenter les bâtiments covenants qui nécessitent une arrivée massive de cette "ressource" pour actionner les divers éléments matériels des contrôles. La centrale de fusion à besoin de beaucoup d\'ions pour fonctionner.']
|
||||
}},
|
||||
|
||||
|
||||
Start : function()
|
||||
{
|
||||
|
||||
/*new Ajax.Request('descriptions.xml',{method: 'get',onSuccess: function(xhr)
|
||||
{
|
||||
Desktop.dom.descriptions = xhr.responseXML;
|
||||
truc = xhr;
|
||||
bat = Desktop.dom.descriptions.documentElement.getElementsByTagName('*');
|
||||
//alert(bat[2].textContent);
|
||||
for(var i in bat)
|
||||
{
|
||||
//Desktop.descriptions['batiments'][bat[i].getAttribute('id')] = [bat[i].getAttribute('name'),bat[i].getAttribute('img'),bat[i].textContent];
|
||||
//Desktop.descriptions.batiments = bat[i];
|
||||
alert(i);
|
||||
}
|
||||
}});*/
|
||||
|
||||
this.dom.menu = create('ul',document.body,'menu');
|
||||
|
||||
this.dom.barre = create('div',document.body,'barre');
|
||||
|
||||
var barre = new Array();
|
||||
|
||||
for(var i=0; i < this.menu.length ; i++)
|
||||
{
|
||||
this.menu[i][2] = create('li',this.dom.menu);
|
||||
this.menu[i][2].innerHTML = this.menu[i][0];
|
||||
this.menu[i][2].onclick = this.menu[i][1];
|
||||
}
|
||||
|
||||
var ressources = create('div',document.body,'ressources');
|
||||
|
||||
var metal = create('div',ressources);
|
||||
metal.innerHTML = 'Métal : ';
|
||||
metal = create('span',metal);
|
||||
metal.innerHTML = this.ressources.metal;
|
||||
|
||||
var cristal = create('div',ressources);
|
||||
cristal.innerHTML = 'Cristal : ';
|
||||
cristal = create('span',cristal);
|
||||
cristal.innerHTML = this.ressources.cristal;
|
||||
|
||||
var ions = create('div',ressources);
|
||||
ions.innerHTML = 'Ions : ';
|
||||
ions = create('span',ions);
|
||||
ions.innerHTML = this.ressources.ions;
|
||||
|
||||
var energie = create('div',ressources);
|
||||
energie.innerHTML = 'Energie : ';
|
||||
var energie = create('span',energie);
|
||||
energie.innerHTML = this.ressources.energie[0] +'/'+ this.ressources.energie[1];
|
||||
|
||||
this.dom.ressources = {metal: metal,cristal: cristal, ions: ions,energie: energie};
|
||||
|
||||
var planetes = create('div',document.body,'planetes');
|
||||
var up = create('span',planetes,document.body,'up');
|
||||
up.onclick = function()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(var i = 0; i <= 2 && i < this.planetes[i].length; i++)
|
||||
{
|
||||
var p = create('img',planetes);
|
||||
p.src = 'planetes/'+this.planetes[i][5]+'.jpg';
|
||||
p.onclick = callback(function(i) { Desktop.ChangePlanete(i);},i);
|
||||
if(this.planetes[i][0] == this.planete) Element.addClassName(p,'selected');
|
||||
}
|
||||
|
||||
var down = create('span',planetes,0,'down');
|
||||
down.onclick = function()
|
||||
{
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
NewWin : function(id,t,c)
|
||||
{
|
||||
if(!this.dom.windows[id])
|
||||
{
|
||||
|
||||
var o = new Object();
|
||||
|
||||
o.win = create('div',document.body,'Window'+id,'window');
|
||||
|
||||
o.win.style.zIndex = 10;
|
||||
|
||||
o.top = create('div',o.win,0,'top');
|
||||
|
||||
o.topleft = create('span',o.top,0,'topleft');
|
||||
|
||||
o.topcenter = create('span',o.top,0,'topcenter');
|
||||
|
||||
o.topright = create('span',o.top,0,'topright');
|
||||
|
||||
o.barre = create('div',o.win,0,'barre');
|
||||
o.barre.onmousedown = function(event) { Desktop.WinMove(id,event,1); };
|
||||
o.barre.onmouseup = function(event) { Desktop.WinMove(id,event,3); };
|
||||
|
||||
o.titre = create('span',o.barre,0,'titre');
|
||||
o.titre.innerHTML = t;
|
||||
|
||||
o.button = create('div',o.barre,0,'button');
|
||||
o.button.onmousedown, o.button.onmouseup = function() { return false;};
|
||||
|
||||
o.hide = create('span',o.button,0,'hide');
|
||||
|
||||
o.full = create('span',o.button,0,'full');
|
||||
|
||||
o.close = create('span',o.button,0,'close');
|
||||
|
||||
o.hide.onclick = function() { Desktop.WinHide(id); };
|
||||
o.full.onclick = function() { Desktop.WinFull(id); };
|
||||
o.close.onclick = function() { Desktop.WinClose(id); };
|
||||
o.hide.onmousedown, o.full.onmousedown, o.close.onmousedown = function() { return false;};
|
||||
|
||||
o.content = create('div',o.win,0,'content');
|
||||
if(typeof(c) == 'object') o.content.appendChild(c);
|
||||
else o.content.innerHTML = c;
|
||||
|
||||
o.bottom = create('div',o.win,0,'bottom');
|
||||
|
||||
o.bottomleft = create('span',o.bottom,0,'bottomleft');
|
||||
|
||||
o.bottomcenter = create('span',o.bottom,0,'bottomcenter');
|
||||
|
||||
o.bottomright = create('span',o.bottom,0,'bottomright');
|
||||
|
||||
o.barre = create('div',this.dom.barre);
|
||||
o.barre.innerHTML = t;
|
||||
o.barre.onclick = function() { Desktop.WinFocus(id); } ;
|
||||
|
||||
o.id = id;
|
||||
|
||||
o.x = o.win.offsetLeft;
|
||||
|
||||
o.y = o.win.offsetTop;
|
||||
|
||||
o.h = o.win.offsetHeight;
|
||||
|
||||
o.w = o.win.offsetWidth;
|
||||
|
||||
o.full = false;
|
||||
|
||||
o.move = false;
|
||||
|
||||
o.moveX = 0;
|
||||
|
||||
o.moveY = 0;
|
||||
|
||||
this.dom.windows[id] = o;
|
||||
|
||||
var r = new Object();
|
||||
|
||||
r.id = id;
|
||||
|
||||
r.Close = function() { return Desktop.WinClose(id); } ;
|
||||
|
||||
r.Full = function() { return Desktop.WinFull(id); } ;
|
||||
|
||||
r.Hide = function() { return Desktop.WinHide(id); } ;
|
||||
|
||||
r.Focus = function() { return Desktop.WinFocus(id); } ;
|
||||
|
||||
r.Move = function(x,y) { return Desktop.WinMove(id,x,y); } ;
|
||||
|
||||
r.Resize = function(x,y) { return Desktop.WinResize(id,x,y); } ;
|
||||
|
||||
r.Content = function(t) { return Desktop.WinContent(id,t); } ;
|
||||
|
||||
this.WinFocus(id);
|
||||
|
||||
return r;
|
||||
}
|
||||
else this.WinFocus(id);
|
||||
|
||||
},
|
||||
|
||||
WinFull : function(id)
|
||||
{
|
||||
if(this.dom.windows[id].full)
|
||||
{
|
||||
this.dom.windows[id].win.style.left = this.dom.windows[id].full[0]+'px';
|
||||
this.dom.windows[id].win.style.top = this.dom.windows[id].full[1]+'px';
|
||||
this.dom.windows[id].win.style.width = this.dom.windows[id].full[2]+'px';
|
||||
this.dom.windows[id].win.style.height = this.dom.windows[id].full[3]+'px';
|
||||
|
||||
this.dom.windows[id].full = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.dom.windows[id].full = [this.dom.windows[id].win.offsetLeft, this.dom.windows[id].win.offsetTop, this.dom.windows[id].win.offsetWidth, this.dom.windows[id].win.offsetHeight];
|
||||
|
||||
this.dom.windows[id].win.style.top = '0';
|
||||
this.dom.windows[id].win.style.left = '0';
|
||||
this.dom.windows[id].win.style.width = '100%';
|
||||
this.dom.windows[id].win.style.height = (document.documentElement.offsetHeight - this.dom.barre.offsetHeight - 49) + 'px';
|
||||
}
|
||||
Desktop.WinFocus(id);
|
||||
},
|
||||
|
||||
WinHide : function(id)
|
||||
{
|
||||
this.dom.windows[id].win.style.display = 'none';
|
||||
},
|
||||
|
||||
WinFocus : function(id)
|
||||
{
|
||||
this.dom.windows[id].win.style.display = 'block';
|
||||
this.dom.windows[id].x = this.dom.windows[id].win.offsetLeft;
|
||||
this.dom.windows[id].y = this.dom.windows[id].win.offsetTop;
|
||||
this.dom.windows[id].w = this.dom.windows[id].win.offsetHeight;
|
||||
this.dom.windows[id].h = this.dom.windows[id].win.offsetWidth;
|
||||
|
||||
var z = this.dom.windows[id].win.style.zIndex * 1;
|
||||
|
||||
for(var i in this.dom.windows)
|
||||
{
|
||||
z = z >= this.dom.windows[i].win.style.zIndex ? z : this.dom.windows[i].win.style.zIndex * 1;
|
||||
}
|
||||
|
||||
this.dom.windows[id].win.style.zIndex = z+1;
|
||||
},
|
||||
|
||||
WinMove : function(id,event,action)
|
||||
{
|
||||
if(action == 1 && !this.dom.windows[id].full) // MouseDown
|
||||
{
|
||||
Desktop.WinFocus(id);
|
||||
this.dom.windows[id].moveX = Event.pointerX(event) - this.dom.windows[id].win.offsetLeft;
|
||||
this.dom.windows[id].moveY = Event.pointerY(event) - this.dom.windows[id].win.offsetTop;
|
||||
|
||||
document.body.onmousemove = function(event) { Desktop.dom.windows[id].move = event; Desktop.WinMove(id,event,2);};
|
||||
opacity(this.dom.windows[id].win,50);
|
||||
}
|
||||
else if(action == 2) //MouseMove
|
||||
{
|
||||
x = Event.pointerX(event) - this.dom.windows[id].moveX;
|
||||
y = Event.pointerY(event) - this.dom.windows[id].moveY;
|
||||
this.dom.windows[id].win.style.left = (x > 0 ? x : 0) + 'px';
|
||||
this.dom.windows[id].win.style.top = (y > 0 ? y : 0) + 'px';
|
||||
}
|
||||
|
||||
else if(action == 3) //MouseUp
|
||||
{
|
||||
this.dom.windows[id].x = this.dom.windows[id].win.offsetLeft;
|
||||
this.dom.windows[id].y = this.dom.windows[id].win.offsetTop;
|
||||
opacity(this.dom.windows[id].win,100);
|
||||
document.body.onmousemove = function() { return false;};
|
||||
}
|
||||
},
|
||||
|
||||
WinContent: function(id,c)
|
||||
{
|
||||
if(typeof(c) == 'object')
|
||||
{
|
||||
this.dom.windows[id].content.innerHTML = '';
|
||||
this.dom.windows[id].content.appendChild(c);
|
||||
}
|
||||
else this.dom.windows[id].content.innerHTML = c;
|
||||
},
|
||||
|
||||
WinClose : function(id)
|
||||
{
|
||||
Element.remove(this.dom.windows[id].win);
|
||||
Element.remove(this.dom.windows[id].barre);
|
||||
delete this.dom.windows[id];
|
||||
},
|
||||
|
||||
Dialog : function(text,callback)
|
||||
{
|
||||
if(!this.dom.dialog)
|
||||
{
|
||||
this.dom.darkness = create('div',document.body,'darkness');
|
||||
fade('darkness',0,80,400);
|
||||
|
||||
this.dom.dialog = create('div',document.body,'dialog');
|
||||
|
||||
var p = create('p',this.dom.dialog);
|
||||
p.innerHTML = text;
|
||||
|
||||
var ok = create('span',this.dom.dialog,0,'button');
|
||||
ok.innerHTML = 'ok';
|
||||
|
||||
var cancel = create('span',this.dom.dialog,0,'button');
|
||||
cancel.innerHTML = 'Annuler';
|
||||
|
||||
var quit = create('span',this.dom.dialog,0,'quit');
|
||||
var close = function()
|
||||
{
|
||||
Element.remove(Desktop.dom.dialog);
|
||||
Element.remove(Desktop.dom.darkness);
|
||||
|
||||
Desktop.dom.dialog = false;
|
||||
Desktop.dom.darkness = false;
|
||||
};
|
||||
|
||||
quit.onclick = close;
|
||||
cancel.onclick = close;
|
||||
ok.onclick = function()
|
||||
{
|
||||
close();
|
||||
callback();
|
||||
};
|
||||
}
|
||||
},
|
||||
|
||||
Notification: function(message)
|
||||
{
|
||||
if(!this.dom.notification)
|
||||
{
|
||||
this.dom.notification = create('p',document.body,'notification');
|
||||
this.dom.notification.innerHTML = message;
|
||||
|
||||
move('notification','bottom',-110,35,2000);
|
||||
setTimeout(function() {move('notification','bottom',35,-110,2000);},7000);
|
||||
setTimeout(function() {Element.remove(Desktop.dom.notification); Desktop.dom.notification = false;},10000);
|
||||
}
|
||||
},
|
||||
|
||||
Ressource: function(ressource,set)
|
||||
{
|
||||
switch(ressource)
|
||||
{
|
||||
case 'metal':
|
||||
case 'cristal':
|
||||
case 'ions':
|
||||
if(set)
|
||||
{
|
||||
this.dom.ressources[ressource].innerHTML = set;
|
||||
this.ressources[ressource] = set;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'energie':
|
||||
if(set)
|
||||
{
|
||||
this.dom.ressources[ressource].innerHTML = set+'/'+this.ressources[ressource][1];
|
||||
this.ressources[ressource][0] = set;
|
||||
}
|
||||
break;
|
||||
case 'energieAll':
|
||||
if(set)
|
||||
{
|
||||
this.dom.ressources[ressource].innerHTML = this.ressources[ressource][0]+'/'+set;
|
||||
this.ressources[ressource][1] = set;
|
||||
}
|
||||
break;
|
||||
|
||||
default: return false;
|
||||
}
|
||||
|
||||
return this.ressources[ressource];
|
||||
},
|
||||
|
||||
ChangePlanete: function(i)
|
||||
{
|
||||
if(this.planetes[i][0] != this.planete) alert('Changement de planete : '+this.planetes[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
function create(type,parent,id,classe)
|
||||
{
|
||||
var element = document.createElement(type);
|
||||
if(id && !$(id)) element.setAttribute('id',id);
|
||||
if(classe) Element.addClassName(element,classe);
|
||||
if(parent) element = $(parent).appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
function callback(funct,parameter)
|
||||
{
|
||||
return function() { funct(parameter); };
|
||||
}
|
||||
|
||||
function move(objet,relative,from,to,speed)
|
||||
{
|
||||
switch(relative)
|
||||
{
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
case 'left':
|
||||
case 'right':
|
||||
|
||||
for(var i=1; i <= (Math.floor(Math.abs(from - to))) ;i++)
|
||||
{
|
||||
setTimeout(callback(function(i) {$(objet).style[relative] = (from < to ? from + i : from -i)+'px';},i),Math.floor(speed / (Math.floor(Math.abs(from - to))) * i));
|
||||
}
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fade(objet,from,to,speed)
|
||||
{
|
||||
for(var i = 1; (Math.floor(Math.abs(from - to)) / 10) >= i; i++)
|
||||
{
|
||||
setTimeout(callback(function(i) {opacity(objet,(from < to ? from + i * 10 : from - i * 10));},i),Math.floor(speed / (Math.floor(Math.abs(from - to)) / 10)) * i);
|
||||
}
|
||||
}
|
||||
|
||||
function opacity(objet,opacity)
|
||||
{
|
||||
$(objet).style.opacity = opacity / 100;
|
||||
$(objet).style.MozOpacity = opacity /100;
|
||||
$(objet).style.KhtmlOpacity = opacity / 100;
|
||||
$(objet).style.filter = "alpha(opacity="+opacity+")";
|
||||
}
|
||||
|
||||
function bulle(objet,text)
|
||||
{
|
||||
if(!$('bulle'))
|
||||
{
|
||||
objet.onmouvehover = function()
|
||||
{
|
||||
bulle = $('body').appendChild(document.createElement('div'));
|
||||
bulle.setAttribute('id','bulle');
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function fenetre1()
|
||||
{
|
||||
var test1 = Desktop.NewWin('test1','Test','<i>Hello World</i>');
|
||||
}
|
||||
|
||||
function fenetre2()
|
||||
{
|
||||
var test2 = Desktop.NewWin('test2','Test 2','<p>Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br />Bla bla bla bla bla bla bla bla bla bla bla<br /></p>');
|
||||
}
|
||||
|
||||
function dialog()
|
||||
{
|
||||
Desktop.Dialog('Test',function() {alert('test');});
|
||||
}
|
||||
|
||||
function notification()
|
||||
{
|
||||
Desktop.Notification('test');
|
||||
}
|
||||
|
||||
function doubler()
|
||||
{
|
||||
Desktop.Ressource('metal',Desktop.ressources.metal*2);
|
||||
Desktop.Ressource('cristal',Desktop.ressources.cristal*2);
|
||||
Desktop.Ressource('ions',Desktop.ressources.ions*2);
|
||||
Desktop.Ressource('energie',Desktop.ressources.energie[0]*2);
|
||||
}
|
||||
|
||||
/*description = {
|
||||
bat01: 'Le purificateur de métal vous fournit les matières premières pour la construction de vos infrastructures et de vos unités. Plus vous développerez vos purificateurs, plus ils produiront de ressources. Les purificateurs les plus développés ont aussi besoin de plus d\'énergie.',
|
||||
bat02: 'Le purificateur de cristal vous fournit les ressources pour vos installations électroniques et pour les alliages. Le purificateur de cristal consomme deux fois plus d\'énergie que celui de métal. Tous les vaisseaux et bâtiments ont besoin de cristal pour leur bouclier ou encore leurs composants électroniques. La production augmente avec le développement de l\'usine.',
|
||||
bat03:'L\'ionisateur utilise des ions négatifs et positifs d\'hydrogène pour créer une source conventionnelle de courant stable, servant à alimenter les bâtiments covenants qui nécessitent une arrivée massive de cette "ressource" pour actionner les divers éléments matériels des contrôles. La centrale de fusion à besoin de beaucoup d\'ions pour fonctionner.'
|
||||
};
|
||||
|
||||
ajax = {bat01: ['Usine de Métal','metal.png',3,100,200,300,0],bat02: ['Usine de Cristal','cristal.png',3,100,200,300,0],bat03: ['Ionisateur','hydrogene.jpg',3,100,200,300,0]};*/
|
||||
|
||||
function batiments()
|
||||
{
|
||||
var batiments = Desktop.descriptions.batiments;
|
||||
|
||||
var all = create('div');
|
||||
all.style.height = '100%';
|
||||
var left = create('dl',all,0,'menu');
|
||||
var dt = create('dt',left);
|
||||
dt.innerHTML = 'Batiments';
|
||||
|
||||
var right = create('div',all,0,'description');
|
||||
var titre = create('h4',right);
|
||||
titre.innerHTML = batiments[1][0];
|
||||
var img = create('img',right);
|
||||
img.src = 'images/'+batiments[1][1];
|
||||
img.alt = batiments[1][0];
|
||||
var p = create('p',right);
|
||||
p.innerHTML = batiments[1][2];
|
||||
var button = create('button',right);
|
||||
button.innerHTML = 'Construire';
|
||||
button.onclick = function() { alert('Construction!') };
|
||||
|
||||
for(var i in batiments)
|
||||
{
|
||||
var dd = create('dd',left);
|
||||
dd.innerHTML = batiments[i][0];
|
||||
if(i == 1) Element.addClassName(dd,'selected');
|
||||
dd.onclick = callback(function(par)
|
||||
{
|
||||
var i = par[0];
|
||||
var dd = par[1];
|
||||
var dds = dd.parentNode.childNodes;
|
||||
|
||||
for(var j = 1; j < dds.length; j++)
|
||||
{
|
||||
Element.removeClassName(dds[j],'selected');
|
||||
}
|
||||
|
||||
Element.addClassName(dd,'selected');
|
||||
|
||||
titre.innerHTML = batiments[i][0];
|
||||
img.src = 'images/'+batiments[i][1];
|
||||
img.alt = batiments[i][0];
|
||||
p.innerHTML = batiments[i][2];
|
||||
},[i,dd]);
|
||||
}
|
||||
|
||||
Desktop.NewWin('batiments','Batiments',all);
|
||||
}
|
||||
|
||||
Desktop.Start();
|
||||
Element.remove($('start'));
|
||||
Desktop.Notification('Bienvenue sur Halo-Battle');
|
||||
52
htdocs/n3p7bLn59Yco3d/js/functions.js
Normal file
52
htdocs/n3p7bLn59Yco3d/js/functions.js
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
function create(type,parent,id,classe)
|
||||
{
|
||||
var element = document.createElement(type);
|
||||
if(id && !$(id)) element.setAttribute('id',id);
|
||||
if(classe) Element.addClassName(element,classe);
|
||||
if(parent) element = $(parent).appendChild(element);
|
||||
return element;
|
||||
}
|
||||
|
||||
function callback()
|
||||
{
|
||||
if(parameters.length == 0) return false;
|
||||
funct = prameters.shift();
|
||||
if(typeof funct != 'function') return false;
|
||||
|
||||
return function() { funct.apply(this,parameters); };
|
||||
}
|
||||
|
||||
function move(objet,relative,from,to,speed)
|
||||
{
|
||||
switch(relative)
|
||||
{
|
||||
case 'top':
|
||||
case 'bottom':
|
||||
case 'left':
|
||||
case 'right':
|
||||
|
||||
for(var i=1; i <= (Math.floor(Math.abs(from - to))) ;i++)
|
||||
{
|
||||
setTimeout(callback(function(i) {$(objet).style[relative] = (from < to ? from + i : from -i)+'px';},i),Math.floor(speed / (Math.floor(Math.abs(from - to))) * i));
|
||||
}
|
||||
break;
|
||||
default: return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function fade(objet,from,to,speed)
|
||||
{
|
||||
for(var i = 1; (Math.floor(Math.abs(from - to)) / 10) >= i; i++)
|
||||
{
|
||||
setTimeout(callback(function(i) {opacity(objet,(from < to ? from + i * 10 : from - i * 10));},i),Math.floor(speed / (Math.floor(Math.abs(from - to)) / 10)) * i);
|
||||
}
|
||||
}
|
||||
|
||||
function opacity(objet,opacity)
|
||||
{
|
||||
$(objet).style.opacity = opacity / 100;
|
||||
$(objet).style.MozOpacity = opacity /100;
|
||||
$(objet).style.KhtmlOpacity = opacity / 100;
|
||||
$(objet).style.filter = "alpha(opacity="+opacity+")";
|
||||
}
|
||||
646
htdocs/n3p7bLn59Yco3d/js/interface.js
Normal file
646
htdocs/n3p7bLn59Yco3d/js/interface.js
Normal file
|
|
@ -0,0 +1,646 @@
|
|||
var script = 'interface.xml';
|
||||
|
||||
var Interface=
|
||||
{
|
||||
mouseFocus : false,
|
||||
|
||||
dom: {windows:{}},
|
||||
|
||||
descriptions : {batiments : [], vaisseaux : [],defenses : [],technologies : []},
|
||||
|
||||
planetes : [{name: 'Pegasi Alpha',position: '01:30:05',img: '1'},{name: 'Pegasi Beta',position: '01:30:06',img: '2'},{name: 'Pegasi Gamma',position: '01:30:08',img: '3'}],
|
||||
|
||||
menuList: [],
|
||||
|
||||
menu :
|
||||
{
|
||||
objects : {},
|
||||
|
||||
add : function(text,funct)
|
||||
{
|
||||
Interface.menu.objects[text] = {};
|
||||
Interface.menu.objects[text]['object'] = create('li',Interface.dom.menu);
|
||||
Interface.menu.objects[text]['object'].innerHTML = text;
|
||||
Interface.menu.objects[text]['function'] = funct;
|
||||
Interface.menu.objects[text]['event'] = Event.observe(Interface.menu.objects[text]['object'], 'click', funct);
|
||||
|
||||
},
|
||||
|
||||
remove : function(text)
|
||||
{
|
||||
if(typeof Interface.menu.objects[text] != 'object') return false;
|
||||
Interface.menu.objects[text]['object'].remove();
|
||||
delete Interface.menu.objects[text];
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
/*barre :
|
||||
{
|
||||
objects : {},
|
||||
|
||||
add : function(text,funct)
|
||||
{
|
||||
Interface.menu.objects[text] = {};
|
||||
Interface.menu.objects[text].object = create('li',Interface.dom.menu);
|
||||
Interface.menu.objects[text].object.innerHTML = text;
|
||||
Interface.menu.objects[text].funct = funct;
|
||||
Interface.menu.objects[text].evt = Event.observe(Interface.menu.objects[text].object, 'click', funct);
|
||||
},
|
||||
|
||||
remove : function()
|
||||
{
|
||||
|
||||
}
|
||||
},*/
|
||||
|
||||
planete :
|
||||
{
|
||||
objects : {},
|
||||
|
||||
add : function(name,position,img)
|
||||
{
|
||||
Interface.planete.objects[position] = {};
|
||||
Interface.planete.objects[position].name = name;
|
||||
Interface.planete.objects[position].position = position;
|
||||
Interface.planete.objects[position].object = create('img',Interface.dom.planetes);
|
||||
Interface.planete.objects[position].object.src = 'planetes/' + img + '.jpg';
|
||||
Interface.planete.objects[position].object.alt = name+ ' [' + position + ']';
|
||||
Interface.planete.objects[position].event = Event.observe(Interface.planete.objects[position].object, 'click', Interface.planete.change);
|
||||
},
|
||||
|
||||
focus : function(position)
|
||||
{
|
||||
for(var i in Interface.planete.objects)
|
||||
if(i == position)
|
||||
{
|
||||
$(Interface.planete.objects[i].object).addClassName('selected');
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
change : function()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
remove : function()
|
||||
{
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
ressources :
|
||||
{
|
||||
metal : 10000,
|
||||
cristal : 5000,
|
||||
ions : 7500,
|
||||
energie : 300,
|
||||
allEnergie: 450,
|
||||
|
||||
set : function(type,number)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
default: return false;
|
||||
|
||||
case 'metal':
|
||||
case 'cristal':
|
||||
case 'ions':
|
||||
Interface.ressources[type] = number;
|
||||
Interface.dom.ressources[type].innerHTML = number;
|
||||
break;
|
||||
|
||||
case 'energie':
|
||||
Interface.ressources[type] = number;
|
||||
Interface.dom.ressources.energie.innerHTML = number + '/' + Interface.ressources.allEnergie;
|
||||
break;
|
||||
|
||||
case 'allEnergie':
|
||||
Interface.ressources[type] = number;
|
||||
Interface.dom.ressources.energie.innerHTML = Interface.ressources.energie + '/' + number;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
updater : function()
|
||||
{
|
||||
|
||||
},
|
||||
|
||||
init : function()
|
||||
{
|
||||
var oldNodes = $(document.body).childElements();
|
||||
for(var i =0; i < oldNodes.length; i++) if(oldNodes[i].tagName != 'script') oldNodes[i].remove();
|
||||
|
||||
Interface.dom.deskbar = create('div',document.body,'barre');
|
||||
|
||||
Interface.dom.menu = create('ul',document.body,'menu');
|
||||
|
||||
for(var i = 0; i < Interface.menuList.length; i++) Interface.menu.add(Interface.menuList[i][0],Interface.menuList[i][1]);
|
||||
|
||||
Interface.dom.planetes = create('div',document.body,'planetes');
|
||||
|
||||
create('span',Interface.dom.planetes,0,'up');
|
||||
for(var i = 0; i < Interface.planetes.length; i++) Interface.planete.add(Interface.planetes[i].name,Interface.planetes[i].position,Interface.planetes[i].img);
|
||||
create('span',Interface.dom.planetes,0,'down');
|
||||
Interface.planete.focus(Interface.planetes[0].position);
|
||||
|
||||
Interface.dom.ressources = {};
|
||||
Interface.dom.ressources.all = create('div',document.body,'ressources');
|
||||
|
||||
var metal = create('div',Interface.dom.ressources.all);
|
||||
metal.innerHTML = 'Métal : ';
|
||||
Interface.dom.ressources.metal = create('strong',metal,'metal');
|
||||
Interface.dom.ressources.metal.innerHTML = Interface.ressources.metal;
|
||||
|
||||
var cristal = create('div',Interface.dom.ressources.all);
|
||||
cristal.innerHTML = 'Cristal : ';
|
||||
Interface.dom.ressources.cristal = create('strong',cristal,'metal');
|
||||
Interface.dom.ressources.cristal.innerHTML = Interface.ressources.cristal;
|
||||
|
||||
var ions = create('div',Interface.dom.ressources.all);
|
||||
ions.innerHTML = 'Métal : ';
|
||||
Interface.dom.ressources.ions = create('strong',ions,'metal');
|
||||
Interface.dom.ressources.ions.innerHTML = Interface.ressources.ions;
|
||||
|
||||
var energie = create('div',Interface.dom.ressources.all);
|
||||
energie.innerHTML = 'Métal : ';
|
||||
Interface.dom.ressources.energie = create('strong',energie,'metal');
|
||||
Interface.dom.ressources.energie.innerHTML = Interface.ressources.energie + '/' + Interface.ressources.allEnergie;
|
||||
|
||||
|
||||
desc = new Ajax.Request('descriptions.xml',{onSuccess: function(xhr)
|
||||
{
|
||||
batiments = xhr.responseXML.getElementsByTagName('batiment');
|
||||
for(var i = 0; i < batiments.length; i++)
|
||||
{
|
||||
Interface.descriptions.batiments[batiments[i].getAttribute('id')] = {name: batiments[i].getAttribute('name'),value:batiments[i].text || batiments[i].textContent};
|
||||
var img = create('img');
|
||||
img.src = 'images/batiments/' + batiments[i].getAttribute('img');
|
||||
img.alt = batiments[i].getAttribute('name');
|
||||
Interface.descriptions.batiments[batiments[i].getAttribute('id')].img = img;
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/*console :
|
||||
{
|
||||
active : true,
|
||||
|
||||
print : function(message)
|
||||
{
|
||||
//if(!Interface.console.active) return false;
|
||||
Interface.dom.console.innerHTHML += message + '<br />';
|
||||
},
|
||||
|
||||
flush : function()
|
||||
{
|
||||
if(!Interface.console.active) return false;
|
||||
Interface.dom.console.innerHTHML = '';
|
||||
return true;
|
||||
}
|
||||
},*/
|
||||
|
||||
batiments :
|
||||
{
|
||||
initialized : false,
|
||||
|
||||
window : null,
|
||||
|
||||
init : function()
|
||||
{
|
||||
if(Interface.batiments.initialized) return false;
|
||||
|
||||
Interface.batiments.initialized = true;
|
||||
|
||||
var batiments = Interface.descriptions.batiments;
|
||||
|
||||
if(typeof Interface.dom.batiment == 'undefined') Interface.dom.batiment = {};
|
||||
var dom = Interface.dom.batiment;
|
||||
|
||||
dom.all = create('div');
|
||||
dom.all.style.height = '100%';
|
||||
dom.left = create('dl',dom.all,0,'menu');
|
||||
dom.dt = create('dt',dom.left);
|
||||
dom.dt.innerHTML = 'Batiments';
|
||||
|
||||
dom.right = create('div',dom.all,0,'description');
|
||||
dom.titre = create('h4',dom.right);
|
||||
dom.titre.innerHTML = batiments[1].name;
|
||||
dom.img = dom.right.appendChild(batiments[1].img.cloneNode(true));
|
||||
dom.p = create('p',dom.right);
|
||||
dom.p.innerHTML = batiments[1].value;
|
||||
dom.button = create('button',dom.right);
|
||||
dom.button.innerHTML = 'Construire';
|
||||
dom.button.onclick = function() { alert('Construction!') };
|
||||
|
||||
Event.observe(dom.img,'click',function(){Interface.info('batiments',1)});
|
||||
|
||||
var change = function()
|
||||
{
|
||||
var dom = Interface.dom.batiment;
|
||||
var dd = dom.dd[this.i];
|
||||
var dds = dd.parentNode.childNodes;
|
||||
|
||||
for(var j = 1; j < dds.length; j++)
|
||||
{
|
||||
Element.removeClassName(dds[j],'selected');
|
||||
}
|
||||
|
||||
Element.addClassName(dd,'selected');
|
||||
|
||||
dom.titre.innerHTML = batiments[this.i].name;
|
||||
|
||||
var newimg = batiments[this.i].img.cloneNode(true);
|
||||
dom.right.replaceChild(newimg,dom.img);
|
||||
dom.img = newimg;
|
||||
|
||||
var i = this.i;
|
||||
Event.observe(dom.img,'click',function(){Interface.info('batiments',i)});
|
||||
|
||||
dom.p.innerHTML = batiments[this.i].value;
|
||||
};
|
||||
|
||||
dom.dd = [];
|
||||
|
||||
for(var i = 1; i < batiments.length; i++)
|
||||
{
|
||||
dom.dd[i] = create('dd',dom.left);
|
||||
dom.dd[i].innerHTML = batiments[i].name;
|
||||
if(i == 1) Element.addClassName(dom.dd[i],'selected');
|
||||
|
||||
Event.observe(dom.dd[i],'click',change.bindAsEventListener({i:i}));
|
||||
}
|
||||
|
||||
Interface.batiments.window = new Interface.window('batiments','Batiments',dom.all);
|
||||
}
|
||||
},
|
||||
|
||||
info : function(groupe,id)
|
||||
{
|
||||
if(typeof Interface.descriptions[groupe][id] == 'undefined') return false;
|
||||
|
||||
var description = Interface.descriptions[groupe][id];
|
||||
|
||||
var container = create('div',0,0,'info');
|
||||
var title = create('h5',container);
|
||||
title.innerHTML = description.name;
|
||||
container.appendChild(description.img.cloneNode(true));
|
||||
var preview = create('p',container);
|
||||
preview.innerHTML = description.value;
|
||||
|
||||
if(typeof Interface.dom.info == 'object')
|
||||
{
|
||||
Interface.dom.info.title(description.name);
|
||||
Interface.dom.info.content(container);
|
||||
Interface.dom.info.focus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Interface.dom.info = new Interface.window('description',description.name,container);
|
||||
Interface.dom.info.closeCallback = function() {Interface.dom.info = false;};
|
||||
}
|
||||
},
|
||||
|
||||
notification : function(text)
|
||||
{
|
||||
if(typeof Interface.dom.notification == 'object') return false;
|
||||
|
||||
Interface.dom.notification = create('p',document.body,'notification');
|
||||
Interface.dom.notification.innerHTML = text;
|
||||
|
||||
Effect.move(Interface.dom.notification,'bottom',-110,35,2000);
|
||||
setTimeout(function() {Effect.move(Interface.dom.notification,'bottom',35,-110,2000);},7000);
|
||||
setTimeout(function() {Element.remove(Interface.dom.notification); Interface.dom.notification = false;},10010);
|
||||
},
|
||||
|
||||
dialog : function(text,callback)
|
||||
{
|
||||
if(typeof Interface.dom.dialog == 'object') return false;
|
||||
|
||||
Interface.dom.darkness = create('div',document.body,'darkness');
|
||||
Effect.animate(Interface.dom.darkness,{opacity: [0,80]},500);
|
||||
|
||||
Interface.dom.dialog = create('div',document.body,'dialog');
|
||||
|
||||
var p = create('p',Interface.dom.dialog);
|
||||
p.innerHTML = text;
|
||||
|
||||
var ok = create('button',Interface.dom.dialog);
|
||||
ok.innerHTML = 'ok';
|
||||
|
||||
var cancel = create('button',Interface.dom.dialog);
|
||||
cancel.innerHTML = 'Annuler';
|
||||
|
||||
var quit = create('span',Interface.dom.dialog,0,'quit');
|
||||
var close = function()
|
||||
{
|
||||
Element.remove(Interface.dom.dialog);
|
||||
Element.remove(Interface.dom.darkness);
|
||||
|
||||
Interface.dom.dialog = false;
|
||||
Interface.dom.darkness = false;
|
||||
};
|
||||
|
||||
Event.observe(quit,'click',close);
|
||||
Event.observe(cancel,'click',close);
|
||||
Event.observe(ok,'click',close);
|
||||
Event.observe(ok,'click',callback);
|
||||
}
|
||||
}
|
||||
|
||||
Interface.window = Class.create({
|
||||
initialize : function(id,title,content)
|
||||
{
|
||||
if(!(id && title && content)) return false;
|
||||
this.id = id;
|
||||
this.titre = title;
|
||||
this.dom = {};
|
||||
|
||||
this.load(title,content);
|
||||
this.focus();
|
||||
},
|
||||
|
||||
load : function(title,content)
|
||||
{
|
||||
if(this.dom.win || Interface.dom.windows[this.id]) return false;
|
||||
|
||||
var title = title || this.titre;
|
||||
var content = content || this.dom.content;
|
||||
|
||||
this.dom.deskbar = create('div',Interface.dom.deskbar);
|
||||
this.dom.deskbar.innerHTML = title;
|
||||
Event.observe(this.dom.deskbar,'click',this.focus.bindAsEventListener(this));
|
||||
|
||||
this.dom.win = create('div',document.body,'window_'+this.id,'window');
|
||||
|
||||
this.dom.win.style.top = (this.dom.win.offsetTop + Math.round(Math.random()*30 -10)) + 'px';
|
||||
this.dom.win.style.left = (this.dom.win.offsetLeft + Math.round(Math.random()*30 -10)) + 'px';
|
||||
|
||||
this.dom.win.style.zIndex = 10;
|
||||
|
||||
this.dom.top = create('div',this.dom.win,0,'top');
|
||||
|
||||
this.dom.topleft = create('span',this.dom.top,0,'topleft');
|
||||
|
||||
this.dom.topcenter = create('span',this.dom.top,0,'topcenter');
|
||||
|
||||
this.dom.topright = create('span',this.dom.top,0,'topright');
|
||||
|
||||
this.dom.barre = create('div',this.dom.win,0,'barre');
|
||||
Event.observe(this.dom.win, 'mousedown', this.focus.bindAsEventListener(this));
|
||||
Event.observe(this.dom.barre, 'mousedown', this.move.mouseDown.bindAsEventListener(this));
|
||||
|
||||
this.dom.titre = create('span',this.dom.barre,0,'titre');
|
||||
|
||||
this.dom.button = create('div',this.dom.barre,0,'button');
|
||||
|
||||
this.dom.hide = create('span',this.dom.button,0,'hide');
|
||||
Event.observe(this.dom.hide, 'click', this.hide.bindAsEventListener(this));
|
||||
|
||||
this.dom.full = create('span',this.dom.button,0,'full');
|
||||
Event.observe(this.dom.full, 'click', this.full.bindAsEventListener(this));
|
||||
|
||||
this.dom.close = create('span',this.dom.button,0,'close');
|
||||
Event.observe(this.dom.close, 'click', this.close.bindAsEventListener(this));
|
||||
|
||||
this.dom.content = create('div',this.dom.win,0,'content');
|
||||
|
||||
this.dom.bottom = create('div',this.dom.win,0,'bottom');
|
||||
|
||||
this.dom.bottomleft = create('span',this.dom.bottom,0,'bottomleft');
|
||||
|
||||
this.dom.bottomcenter = create('span',this.dom.bottom,0,'bottomcenter');
|
||||
|
||||
this.dom.bottomright = create('span',this.dom.bottom,0,'bottomright');
|
||||
|
||||
Event.observe(this.dom.bottomright, 'mousedown', this.resize.mouseDown.bindAsEventListener(this));
|
||||
|
||||
this.x = this.dom.win.offsetLeft;
|
||||
|
||||
this.y = this.dom.win.offsetTop;
|
||||
|
||||
this.h = this.dom.win.offsetHeight;
|
||||
|
||||
this.w = this.dom.win.offsetWidth;
|
||||
|
||||
this.position = false;
|
||||
|
||||
this.movePosition = false;
|
||||
|
||||
Interface.dom.windows[this.id] = this.dom;
|
||||
|
||||
//for(var i in this.dom) this.dom[i].windowId = this.id;
|
||||
|
||||
if(typeof(content) == 'object') this.dom.content.appendChild(content);
|
||||
else if(typeof(content) == 'string') this.dom.content.innerHTML = content;
|
||||
|
||||
this.dom.titre.innerHTML = title;
|
||||
},
|
||||
|
||||
focus : function()
|
||||
{
|
||||
this.dom.win.style.display = '';
|
||||
|
||||
var z = Number(this.dom.win.style.zIndex);
|
||||
|
||||
for(var i in Interface.dom.windows)
|
||||
{
|
||||
if(Interface.dom.windows[i]) z = z > Number(Interface.dom.windows[i].win.style.zIndex) ? z : Number(Interface.dom.windows[i].win.style.zIndex);
|
||||
}
|
||||
|
||||
this.dom.win.style.zIndex = z+1;
|
||||
},
|
||||
|
||||
hide : function()
|
||||
{
|
||||
this.dom.win.style.display = 'none';
|
||||
},
|
||||
|
||||
full : function()
|
||||
{
|
||||
if(this.position)
|
||||
{
|
||||
this.dom.win.style.left = this.position.left+'px';
|
||||
this.dom.win.style.top = this.position.top+'px';
|
||||
this.dom.win.style.width = this.position.width+'px';
|
||||
this.dom.win.style.height = this.position.height+'px';
|
||||
|
||||
this.position = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.position = {left : this.dom.win.offsetLeft, top: this.dom.win.offsetTop, width: this.dom.win.offsetWidth, height: this.dom.win.offsetHeight};
|
||||
|
||||
this.dom.win.style.top = '0';
|
||||
this.dom.win.style.left = '0';
|
||||
this.dom.win.style.width = '100%';
|
||||
this.dom.win.style.height = (document.documentElement.offsetHeight - this.dom.barre.offsetHeight - 49) + 'px';
|
||||
}
|
||||
this.focus();
|
||||
},
|
||||
|
||||
close : function()
|
||||
{
|
||||
if(typeof this.closeCallback == 'function') this.closeCallback();
|
||||
this.dom.deskbar.remove();
|
||||
this.dom.win.remove();
|
||||
delete this.dom;
|
||||
this.dom = false;
|
||||
Interface.dom.windows[this.id] = false;
|
||||
return true;
|
||||
},
|
||||
|
||||
resize :
|
||||
{
|
||||
mouseDown : function(event)
|
||||
{
|
||||
Interface.mouseFocus = this.dom;
|
||||
|
||||
Interface.mouseFocus.resizePosition = [Interface.mouseFocus.win.offsetLeft,
|
||||
Interface.mouseFocus.win.offsetTop];
|
||||
|
||||
Interface.dom.resize = create('div',document.body,'resize');
|
||||
|
||||
Interface.dom.resize.style.left = Interface.mouseFocus.win.offsetLeft + 'px';
|
||||
Interface.dom.resize.style.top = Interface.mouseFocus.win.offsetTop + 'px';
|
||||
Interface.dom.resize.style.width = (Event.pointerX(event) - Interface.mouseFocus.win.offsetLeft) + 'px';
|
||||
Interface.dom.resize.style.height = (Event.pointerY(event) - Interface.mouseFocus.win.offsetTop) + 'px';
|
||||
|
||||
Event.observe(document.body, 'mousemove',Interface.window.prototype.resize.mouseMove);
|
||||
Event.observe(document.body, 'mouseup', Interface.window.prototype.resize.mouseUp);
|
||||
},
|
||||
|
||||
mouseMove : function(event)
|
||||
{
|
||||
|
||||
var w = Event.pointerX(event) - Interface.mouseFocus.resizePosition[0];
|
||||
var h = Event.pointerY(event) - Interface.mouseFocus.resizePosition[1];
|
||||
Interface.dom.resize.style.width = (w > 0 ? w : 0) + 'px';
|
||||
Interface.dom.resize.style.height = (h > 0 ? h : 0) + 'px';
|
||||
},
|
||||
|
||||
mouseUp : function(event)
|
||||
{
|
||||
Interface.mouseFocus.win.style.width = (Event.pointerX(event) - Interface.mouseFocus.resizePosition[0] + 2) + 'px';
|
||||
Interface.mouseFocus.win.style.height = (Event.pointerY(event) - Interface.mouseFocus.resizePosition[1] - 51) + 'px';
|
||||
|
||||
Element.remove(Interface.dom.resize);
|
||||
|
||||
Interface.mouseFocus.resizePosition = false;
|
||||
Interface.mouseFocus = false;
|
||||
|
||||
Event.stopObserving(document.body,'mousemove',Interface.window.prototype.resize.mouseMove);
|
||||
Event.stopObserving(document.body,'mouseup',Interface.window.prototype.resize.mouseUp);
|
||||
}
|
||||
},
|
||||
|
||||
move :
|
||||
{
|
||||
mouseDown : function(event)
|
||||
{
|
||||
if(Event.element(event).parentNode == this.dom.button) return false;
|
||||
|
||||
Interface.mouseFocus = this.dom;
|
||||
|
||||
Effect.opacity(Interface.mouseFocus.win,60);
|
||||
|
||||
Interface.mouseFocus.movePosition = [Event.pointerX(event) - Interface.mouseFocus.win.offsetLeft,Event.pointerY(event) - Interface.mouseFocus.win.offsetTop];
|
||||
|
||||
Event.observe(document.body, 'mousemove',Interface.window.prototype.move.mouseMove);
|
||||
Event.observe(document.body, 'mouseup', Interface.window.prototype.move.mouseUp);
|
||||
},
|
||||
|
||||
mouseMove : function(event)
|
||||
{
|
||||
|
||||
var x = Event.pointerX(event) - Interface.mouseFocus.movePosition[0];
|
||||
var y = Event.pointerY(event) - Interface.mouseFocus.movePosition[1];
|
||||
Interface.mouseFocus.win.style.left = (x > 0 ? x : 0) + 'px';
|
||||
Interface.mouseFocus.win.style.top = (y > 0 ? y : 0) + 'px';
|
||||
},
|
||||
|
||||
mouseUp : function(event)
|
||||
{
|
||||
Effect.opacity(Interface.mouseFocus.win,100);
|
||||
Interface.mouseFocus.movePosition = false;
|
||||
Interface.mouseFocus = false;
|
||||
Event.stopObserving(document.body,'mousemove',Interface.window.prototype.move.mouseMove);
|
||||
Event.stopObserving(document.body,'mouseup',Interface.window.prototype.move.mouseUp);
|
||||
},
|
||||
|
||||
to : function(object,x,y)
|
||||
{
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
title : function(title)
|
||||
{
|
||||
if(typeof title != 'string') return this.titre;
|
||||
|
||||
var old = this.title;
|
||||
|
||||
this.titre = title;
|
||||
this.dom.titre.innerHTML = title;
|
||||
|
||||
return old;
|
||||
},
|
||||
|
||||
content : function(content)
|
||||
{
|
||||
var old = this.dom.content.cloneNode(true);
|
||||
|
||||
if(typeof(content) == 'object') { Element.remove(this.dom.content.firstChild); this.dom.content.appendChild(content); }
|
||||
else if(typeof(content) == 'string') this.dom.content.innerHTML = content ;
|
||||
else return this.dom.content;
|
||||
|
||||
return old;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Interface.menuList = [['Hello World',helloWorld],
|
||||
['Batiments',Interface.batiments.init],
|
||||
['Doubler',doubler],
|
||||
//['Background',background],
|
||||
['Notification',notif],
|
||||
['Dialog',dialog]];
|
||||
|
||||
|
||||
|
||||
function dialog()
|
||||
{
|
||||
Interface.dialog('WTF??',function(){alert(':P')});
|
||||
}
|
||||
|
||||
function background()
|
||||
{
|
||||
if($('background')) return false;
|
||||
bg = create('div',document.body,'background');
|
||||
bg2 = create('div',bg,0,'content');
|
||||
}
|
||||
|
||||
function doubler()
|
||||
{
|
||||
Interface.ressources.set('metal',Interface.ressources.metal*2);
|
||||
Interface.ressources.set('cristal',Interface.ressources.cristal*2);
|
||||
Interface.ressources.set('ions',Interface.ressources.ions*2);
|
||||
Interface.ressources.set('energie',Interface.ressources.energie*2);
|
||||
Interface.ressources.set('allEnergie',Interface.ressources.allEnergie*2);
|
||||
}
|
||||
|
||||
function notif()
|
||||
{
|
||||
Interface.notification('test! :P');
|
||||
}
|
||||
|
||||
function helloWorld()
|
||||
{
|
||||
hw = new Interface.window('helloWorld','Hello World','Hello World!');
|
||||
}
|
||||
|
||||
Interface.init();
|
||||
10
htdocs/n3p7bLn59Yco3d/js/load.js
Normal file
10
htdocs/n3p7bLn59Yco3d/js/load.js
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
function include(fichier)
|
||||
{
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('src',fichier);
|
||||
script.setAttribute('type','application/javascript');
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
include('js/prototype.js');
|
||||
include('js/api.js');
|
||||
4320
htdocs/n3p7bLn59Yco3d/js/prototype.js
vendored
Normal file
4320
htdocs/n3p7bLn59Yco3d/js/prototype.js
vendored
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue