1
1
forked from 0ad/0ad
This was SVN commit r709.
This commit is contained in:
Ykkrosh 2004-07-11 18:32:33 +00:00
parent 2537d1bc6e
commit 4c1d96341e
2 changed files with 185 additions and 158 deletions

View File

@ -3,80 +3,102 @@
<!DOCTYPE objects SYSTEM "../gui.dtd">
<objects>
<object
type="button"
name="arena"
sprite="sprite1"
size="0 0 600 400"
z="100"
hidden="true"
>
<action on="Load"><![CDATA[
g_ballx = 300;
g_bally = 200;
g_balldx = 0;
g_balldy = 0;
]]></action>
<action on="MouseOver"><![CDATA[
g_ballx += g_balldx;
g_bally += g_balldy;
if (g_ballx > 600) {
g_balldx *= -0.9;
g_ballx = 600-(g_ballx-600);
}
else if (g_ballx < 0) {
g_balldx *= -0.9;
g_ballx = -g_ballx;
}
if (g_bally > 400) {
g_balldy *= -0.9;
g_bally = 400-(g_bally-400);
}
else if (g_bally < 0) {
g_balldy *= -0.9;
g_bally = -g_bally;
<script file="gui/test/test.js"><![CDATA[
writeConsole("GUI file loading");
function MakeDude(x, y, z) {
DudeSpawnPoint = new Vector3D(x, y, z);
new Entity(getEntityTemplate("Prometheus Dude"), DudeSpawnPoint, 1.0);
writeConsole("Dude created at " + DudeSpawnPoint);
}
// Gravitate towards the mouse
var vect_x = g_ballx-mouse.x;
var vect_y = g_bally-mouse.y;
var dsquared = vect_x*vect_x + vect_y*vect_y;
if (dsquared < 1000) dsquared = 1000;
var force = 10000.0 / dsquared;
var mag = Math.sqrt(vect_x*vect_x + vect_y*vect_y);
vect_x /= mag; vect_y /= mag;
g_balldx -= force * vect_x;
g_balldy -= force * vect_y;
writeConsole("Made MakeDude " + MakeDude);
]]></script>
var ball = getGUIObjectByName('ball');
var r=5;
ball.size = new GUISize(g_ballx-r, g_bally-r, g_ballx+r, g_bally+r);
]]></action>
</object>
<object type="button" name="exit_button" sprite="exit_sprite" size="100%-18 2 100%-2 18" z="100" hidden="false">
<action on="Load"><![CDATA[
writeConsole("(GUI) Exit button successfully loaded.");
]]></action>
<action on="Press"><![CDATA[
exit();
]]></action>
</object>
<object type="button" name="Dude_Production_Button" sprite="sprite1" sprite-over="sprite1-over" sprite-pressed="sprite1-pressed" size="10% 80% 10%+32 80%+32" z="100" hidden="false">
<action on="Press">
MakeDude(15, 0, 15);
</action>
</object>
<object
type="button"
name="ball"
sprite="sprite1"
size="0 0 1 1"
z="120"
>*
<action on="Press"><![CDATA[
writeConsole(mouse);
]]></action>
</object>
<object type="button" name="Dude_Production_Button_random" sprite="sprite1" sprite-over="sprite1-over" sprite-pressed="sprite1-pressed" size="10%+34 80% 10%+66 80%+32" z="100" hidden="false">
<action on="Press"><![CDATA[
// Generate random numbers
rand_x = Math.round(Math.random()*100);
rand_y = Math.round(Math.random()*100);
rand_z = Math.round(Math.random()*100);
<object
type="button"
sprite="sprite1"
size="592 2 608 18"
z="200"
>*
<action on="Press"><![CDATA[
var arena = getGUIObjectByName('arena');
arena.hidden = !arena.hidden;
]]></action>
</object>
MakeDude(rand_x, rand_y, rand_z);
]]></action>
</object>
<object type="button" name="arena" sprite="sprite1" sprite-over="sprite1-over" size="0 0 600 400" z="100" hidden="true">
<action on="Load"><![CDATA[
g_ballx = 300;
g_bally = 200;
g_balldx = 0;
g_balldy = 0;
]]></action>
<action on="MouseOver"><![CDATA[
g_ballx += g_balldx;
g_bally += g_balldy;
if (g_ballx > 600) {
g_balldx *= -0.9;
g_ballx = 600-(g_ballx-600);
}
else if (g_ballx < 0) {
g_balldx *= -0.9;
g_ballx = -g_ballx;
}
if (g_bally > 400) {
g_balldy *= -0.9;
g_bally = 400-(g_bally-400);
}
else if (g_bally < 0) {
g_balldy *= -0.9;
g_bally = -g_bally;
}
// Gravitate towards the mouse
var vect_x = g_ballx-mouse.x;
var vect_y = g_bally-mouse.y;
var dsquared = vect_x*vect_x + vect_y*vect_y;
if (dsquared < 1000) dsquared = 1000;
var force = 10000.0 / dsquared;
var mag = Math.sqrt(dsquared);
vect_x /= mag; vect_y /= mag;
g_balldx -= force * vect_x;
g_balldy -= force * vect_y;
var ball = getGUIObjectByName('ball');
var r=5;
ball.size = new GUISize(g_ballx-r, g_bally-r, g_ballx+r, g_bally+r);
]]></action>
</object>
<object type="button" name="ball" sprite="sprite1" size="0 0 1 1" z="120">*
<action on="Press"><![CDATA[
writeConsole(mouse);
]]></action>
</object>
<object type="button" sprite="sprite1" size="592 2 608 18" z="200">*
<action on="Press"><![CDATA[
var arena = getGUIObjectByName('arena');
arena.hidden = !arena.hidden;
]]></action>
</object>
</objects>

View File

@ -3,103 +3,108 @@
<!DOCTYPE sprites SYSTEM "..\gui.dtd">
<sprites>
<sprite name="sprite1">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="1 1 100%-2 100%-2" />
</sprite>
<sprite name="exit_sprite">
<image backcolor="255 255 255" size="0 0 100% 100%" />
<image backcolor="0 0 0" size="50% 2 50%+2 100%-1" />
<image backcolor="0 0 0" size="2 50% 100%-1 50%+2" />
</sprite>
<sprite name="sprite1">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="1 1 100%-2 100%-2" />
</sprite>
<sprite name="sprite4">
<image backcolor="50 50 50" size="0 0 100% 100%" />
</sprite>
<sprite name="sprite4">
<image backcolor="50 50 50" size="0 0 100% 100%" />
</sprite>
<sprite name="sprite1-over">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="200 0 0" size="1 1 100%-2 100%-2" />
<image backcolor="212 208 200" size="2 2 100%-3 100%-3" />
</sprite>
<sprite name="sprite1-over">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="200 0 0" size="1 1 100%-2 100%-2" />
<image backcolor="212 208 200" size="2 2 100%-3 100%-3" />
</sprite>
<sprite name="sprite1-ch">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="4 4 100%-5 100%-5" z-level="1" />
<image backcolor="128 0 0" size="4 4 100%-5 100%-5" z-level="1" />
</sprite>
<sprite name="sprite1-ch">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="4 4 100%-5 100%-5" z-level="1" />
<image backcolor="128 0 0" size="4 4 100%-5 100%-5" z-level="1" />
</sprite>
<sprite name="sprite1-pressed">
<image backcolor="64 64 64" size="0 0 100% 100%" />
<image backcolor="128 128 128" size="1 1 100%-1 100%-1" z-level="1" />
<image backcolor="212 208 200" size="2 2 100%-2 100%-2" z-level="2" />
</sprite>
<sprite name="sprite1-pressed">
<image backcolor="64 64 64" size="0 0 100% 100%" />
<image backcolor="128 128 128" size="1 1 100%-1 100%-1" z-level="1" />
<image backcolor="212 208 200" size="2 2 100%-2 100%-2" z-level="2" />
</sprite>
<sprite name="sprite2">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="212 208 200" size="0 1 1 100%-1" />
<image backcolor="212 208 200" size="0 0 100%-1 1" />
<image backcolor="255 255 255" size="1 2 1 100%-2" />
<image backcolor="255 255 255" size="1 1 100%-2 2" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="2 2 100%-2 100%-2" />
</sprite>
<sprite name="sprite2">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="212 208 200" size="0 1 1 100%-1" />
<image backcolor="212 208 200" size="0 0 100%-1 1" />
<image backcolor="255 255 255" size="1 2 1 100%-2" />
<image backcolor="255 255 255" size="1 1 100%-2 2" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="2 2 100%-2 100%-2" />
</sprite>
<sprite name="sprite2-pressed">
<image backcolor="128 128 128" size="0 0 100% 100%" />
<image backcolor="212 208 200" size="1 1 100%-1 100%-1" z-level="1" />
</sprite>
<sprite name="sprite2-pressed">
<image backcolor="128 128 128" size="0 0 100% 100%" />
<image backcolor="212 208 200" size="1 1 100%-1 100%-1" z-level="1" />
</sprite>
<sprite name="sprite1">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="1 1 100%-2 100%-2" />
</sprite>
<sprite name="sprite1">
<!-- Starting with top left corner continuing in a clockwise manner -->
<image backcolor="255 255 255" size="0 1 1 100%-1" />
<image backcolor="255 255 255" size="0 0 100%-1 1" />
<image backcolor="64 64 64" size="100%-1 0 100% 100%" />
<image backcolor="64 64 64" size="0 100%-1 100%-1 100%" />
<image backcolor="128 128 128" size="100%-2 1 100%-1 100%-1" />
<image backcolor="128 128 128" size="1 100%-2 100%-1 100%-1" />
<!-- middle -->
<image backcolor="212 208 200" size="1 1 100%-2 100%-2" />
</sprite>
<sprite name="grey">
<image backcolor="243 242 240" size="0 0 100% 100%" />
</sprite>
<sprite name="grey">
<image backcolor="243 242 240" size="0 0 100% 100%" />
</sprite>
<sprite name="white-border">
<image backcolor="100 70 120" size="0 0 100% 100%" />
<image backcolor="255 255 255" size="-1 -1 100%+1 0" />
<image backcolor="255 255 255" size="-1 100% 100%+1 100%+1" />
<image backcolor="255 255 255" size="-1 0 0 100%" />
<image backcolor="255 255 255" size="100% 0 100%+1 100%" />
</sprite>
<sprite name="white-border">
<image backcolor="100 70 120" size="0 0 100% 100%" />
<image backcolor="255 255 255" size="-1 -1 100%+1 0" />
<image backcolor="255 255 255" size="-1 100% 100%+1 100%+1" />
<image backcolor="255 255 255" size="-1 0 0 100%" />
<image backcolor="255 255 255" size="100% 0 100%+1 100%" />
</sprite>
<sprite name="scroll">
<!--<image backcolor="128 128 128" size="0 0 100% 100%" />-->
<image backcolor="150 105 180" size="2 2 100%-2 100%-2" z-level="1" />
</sprite>
<sprite name="scroll-bar">
<!--<image backcolor="128 128 128" size="0 0 100% 100%" />-->
<image backcolor="150 105 180" size="2 0 100%-2 100%" z-level="1" />
</sprite>
<sprite name="scroll">
<!--<image backcolor="128 128 128" size="0 0 100% 100%" />-->
<image backcolor="150 105 180" size="2 2 100%-2 100%-2" z-level="1" />
</sprite>
<sprite name="scroll-bar">
<!--<image backcolor="128 128 128" size="0 0 100% 100%" />-->
<image backcolor="150 105 180" size="2 0 100%-2 100%" z-level="1" />
</sprite>
</sprites>