diff --git a/binaries/data/mods/_test.sim/simulation/components/addentity/test-addentity.js b/binaries/data/mods/_test.sim/simulation/components/addentity/test-addentity.js new file mode 100644 index 0000000000..2d17760034 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/addentity/test-addentity.js @@ -0,0 +1,11 @@ +function TestScript2A() {} + +TestScript2A.prototype.Init = function() { + this.x = eval(this.template.y); +}; + +TestScript2A.prototype.GetX = function() { + return this.x; +}; + +Engine.RegisterComponentType(IID_Test2, "TestScript2A", TestScript2A); \ No newline at end of file diff --git a/binaries/data/mods/_test.sim/simulation/components/error.js b/binaries/data/mods/_test.sim/simulation/components/error.js new file mode 100644 index 0000000000..e79e828e40 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/error.js @@ -0,0 +1,12 @@ +function TestScript1A() {} + +try { + Engine.RegisterComponentType(12345, "TestScript1A", TestScript1A); + Engine.TS_FAIL("Missed exception"); +} catch (e) { +// print("Caught exception: " + e + "\n"); +} + +var n = Engine.QueryInterface(12345, IID_Test1); +if (n !== null) + Engine.TS_FAIL("QueryInterface return "+n+", not null"); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-entityid.js b/binaries/data/mods/_test.sim/simulation/components/test-entityid.js new file mode 100644 index 0000000000..e0541699d9 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-entityid.js @@ -0,0 +1,12 @@ +function TestScript1A() {} + +TestScript1A.prototype.GetX = function() { + // Test that .entity is readonly + delete this.entity; + this.entity = -1; + + // and return the value + return this.entity; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1A", TestScript1A); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-helper.js b/binaries/data/mods/_test.sim/simulation/components/test-helper.js new file mode 100644 index 0000000000..ea491d4134 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-helper.js @@ -0,0 +1,7 @@ +function TestScript1_Helper() {} + +TestScript1_Helper.prototype.GetX = function() { + return AdditionHelper(1, 2); +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_Helper", TestScript1_Helper); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js b/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js new file mode 100644 index 0000000000..a94774fb7f --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-hotload1.js @@ -0,0 +1,23 @@ +function HotloadA() {} + +HotloadA.prototype.Init = function() { + this.x = +this.template.x; +}; + +HotloadA.prototype.GetX = function() { + return this.x; +}; + +Engine.RegisterComponentType(IID_Test1, "HotloadA", HotloadA); + +function HotloadB() {} + +HotloadB.prototype.Init = function() { + this.x = +this.template.x; +}; + +HotloadB.prototype.GetX = function() { + return this.x*2; +}; + +Engine.RegisterComponentType(IID_Test1, "HotloadB", HotloadB); \ No newline at end of file diff --git a/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js b/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js new file mode 100644 index 0000000000..8f4690093b --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-hotload2.js @@ -0,0 +1,11 @@ +function HotloadA() {} + +HotloadA.prototype.Init = function() { + this.x = +this.template.x; +}; + +HotloadA.prototype.GetX = function() { + return this.x*10; +}; + +Engine.RegisterComponentType(IID_Test1, "HotloadA", HotloadA); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-msg.js b/binaries/data/mods/_test.sim/simulation/components/test-msg.js new file mode 100644 index 0000000000..f00949c864 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-msg.js @@ -0,0 +1,32 @@ +function TestScript1A() {} + +TestScript1A.prototype.Init = function() { + this.x = 100; +}; + +TestScript1A.prototype.GetX = function() { + return this.x; +}; + +TestScript1A.prototype.OnUpdate = function(msg) { + this.x += msg.turnLength; +} + +Engine.RegisterComponentType(IID_Test1, "TestScript1A", TestScript1A); + +// -------- // + +function TestScript2A() {} + +TestScript2A.prototype.Init = function() { + this.x = 200; +}; + +TestScript2A.prototype.GetX = function() { + Engine.BroadcastMessage(MT_Update, { turnLength: 50 }); + Engine.PostMessage(1, MT_Update, { turnLength: 500 }); + Engine.PostMessage(2, MT_Update, { turnLength: 5000 }); + return this.x; +}; + +Engine.RegisterComponentType(IID_Test2, "TestScript2A", TestScript2A); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-param.js b/binaries/data/mods/_test.sim/simulation/components/test-param.js new file mode 100644 index 0000000000..de3bb1e2ca --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-param.js @@ -0,0 +1,31 @@ +function TestScript1_Init() {} + +TestScript1_Init.prototype.Init = function() { + var param = this.template; +// print("# ",uneval(param),"\n"); + if (param) + this.x = (+param.x) + (+param.y._string) + (+param.y.z['@w']) + (+param.y.z.a); + else + this.x = 100; +}; + +TestScript1_Init.prototype.GetX = function() { + return this.x; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_Init", TestScript1_Init); + +// -------- // + +function TestScript1_readonly() {} + +TestScript1_readonly.prototype.GetX = function() { + this.template = null; + delete this.template; + try { this.template.x += 1000; } catch(e) { } + try { delete this.template.x; } catch(e) { } + try { this.template.y = 2000; } catch(e) { } + return +(this.template.x || 1) + +(this.template.y || 2); +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_readonly", TestScript1_readonly); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-query.js b/binaries/data/mods/_test.sim/simulation/components/test-query.js new file mode 100644 index 0000000000..c33be54e67 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-query.js @@ -0,0 +1,26 @@ +function TestScript1A() {} + +TestScript1A.prototype.Init = function() { + this.x = 100; +}; + +TestScript1A.prototype.GetX = function() { + var test2 = Engine.QueryInterface(this.entity, IID_Test2); + return test2.GetX() + (test2.x || 0); +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1A", TestScript1A); + +// -------- // + +function TestScript2A() {} + +TestScript2A.prototype.Init = function() { + this.x = 200; +}; + +TestScript2A.prototype.GetX = function() { + return this.x; +}; + +Engine.RegisterComponentType(IID_Test2, "TestScript2A", TestScript2A); diff --git a/binaries/data/mods/_test.sim/simulation/components/test-serialize.js b/binaries/data/mods/_test.sim/simulation/components/test-serialize.js new file mode 100644 index 0000000000..64cbeb7ca6 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test-serialize.js @@ -0,0 +1,68 @@ +function TestScript1_values() {} + +TestScript1_values.prototype.Init = function() { + this.x = +this.template.x; + this.str = "this is a string"; + this.things = { a: 1, b: "2", c: [3, "4", [5, []]] }; +}; + +TestScript1_values.prototype.GetX = function() { +// print(uneval(this)); + return this.x; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_values", TestScript1_values); + +// -------- // + +function TestScript1_entity() {} + +TestScript1_entity.prototype.GetX = function() { + // Test that .entity is readonly + delete this.entity; + this.entity = -1; + + // and return the value + return this.entity; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_entity", TestScript1_entity); + +// -------- // + +function TestScript1_nontree() {} + +TestScript1_nontree.prototype.Init = function() { + var n = [1]; + this.x = [n, n, null, { y: n }]; + this.x[2] = this.x; +}; + +TestScript1_nontree.prototype.GetX = function() { +// print(uneval(this)+"\n"); + this.x[0][0] += 1; + return this.x[0][0] + this.x[1][0] + this.x[2][0][0] + this.x[3].y[0]; +} + +Engine.RegisterComponentType(IID_Test1, "TestScript1_nontree", TestScript1_nontree); + +// -------- // + +function TestScript1_getter() {} + +TestScript1_getter.prototype.Init = function() { + this.x = 100; + this.__defineGetter__('x', function () { return 200; }); +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_getter", TestScript1_getter); + +// -------- // + +function TestScript1_consts() {} + +TestScript1_consts.prototype.GetX = function() { + return (+this.entity) + (+this.template.x); +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1_consts", TestScript1_consts); diff --git a/binaries/data/mods/_test.sim/simulation/components/test.js b/binaries/data/mods/_test.sim/simulation/components/test.js new file mode 100644 index 0000000000..479427a5ba --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/components/test.js @@ -0,0 +1,45 @@ +function TestScript1A() {} + +TestScript1A.prototype.Init = function() { + this.x = 101000; +}; + +TestScript1A.prototype.GetX = function() { + return this.x; +}; + +TestScript1A.prototype.OnTurnStart = function(msg) { + this.x += 1; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1A", TestScript1A); + +// -------- // + +function TestScript1B() {} + +TestScript1B.prototype = new TestScript1A(); + +TestScript1B.prototype.Init = function() { + this.x = 102000; +}; + +Engine.RegisterComponentType(IID_Test1, "TestScript1B", TestScript1B); + +// -------- // + +function TestScript2A() {} + +TestScript2A.prototype.Init = function() { + this.x = 201000; +}; + +TestScript2A.prototype.GetX = function() { + return this.x; +}; + +TestScript2A.prototype.OnUpdate = function(msg) { + this.x += msg.turnLength; +}; + +Engine.RegisterComponentType(IID_Test2, "TestScript2A", TestScript2A); diff --git a/binaries/data/mods/_test.sim/simulation/helpers/test-helper.js b/binaries/data/mods/_test.sim/simulation/helpers/test-helper.js new file mode 100644 index 0000000000..2ce1940d13 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/helpers/test-helper.js @@ -0,0 +1,5 @@ +function AdditionHelper(a, b) { + return a+b; +} + +Engine.RegisterGlobal("AdditionHelper", AdditionHelper); diff --git a/binaries/data/mods/_test.sim/simulation/templates/basic.xml b/binaries/data/mods/_test.sim/simulation/templates/basic.xml new file mode 100644 index 0000000000..b876138c01 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/basic.xml @@ -0,0 +1,4 @@ + + + 12345 + diff --git a/binaries/data/mods/_test.sim/simulation/templates/hotload.xml b/binaries/data/mods/_test.sim/simulation/templates/hotload.xml new file mode 100644 index 0000000000..3be131ca8b --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/hotload.xml @@ -0,0 +1,6 @@ + + + + 100 + + diff --git a/binaries/data/mods/_test.sim/simulation/templates/inherit-broken.xml b/binaries/data/mods/_test.sim/simulation/templates/inherit-broken.xml new file mode 100644 index 0000000000..f3af209480 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/inherit-broken.xml @@ -0,0 +1,2 @@ + +broken diff --git a/binaries/data/mods/_test.sim/simulation/templates/inherit-loop-2.xml b/binaries/data/mods/_test.sim/simulation/templates/inherit-loop-2.xml new file mode 100644 index 0000000000..960984546a --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/inherit-loop-2.xml @@ -0,0 +1,2 @@ + +loop-2 diff --git a/binaries/data/mods/_test.sim/simulation/templates/inherit-loop.xml b/binaries/data/mods/_test.sim/simulation/templates/inherit-loop.xml new file mode 100644 index 0000000000..85fc6ecc62 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/inherit-loop.xml @@ -0,0 +1,2 @@ + +loop diff --git a/binaries/data/mods/_test.sim/simulation/templates/inherit1.xml b/binaries/data/mods/_test.sim/simulation/templates/inherit1.xml new file mode 100644 index 0000000000..c25d0b9a6a --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/inherit1.xml @@ -0,0 +1,8 @@ + + + + d1 + e1 + f1 + + diff --git a/binaries/data/mods/_test.sim/simulation/templates/inherit2.xml b/binaries/data/mods/_test.sim/simulation/templates/inherit2.xml new file mode 100644 index 0000000000..a9b1f8375e --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/inherit2.xml @@ -0,0 +1,7 @@ + + + + d2 + g2 + + diff --git a/binaries/data/mods/_test.sim/simulation/templates/template-serialize.xml b/binaries/data/mods/_test.sim/simulation/templates/template-serialize.xml new file mode 100644 index 0000000000..d0861e0d6d --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/template-serialize.xml @@ -0,0 +1,4 @@ + + + 12345 + diff --git a/binaries/data/mods/_test.sim/simulation/templates/test1-inherit.xml b/binaries/data/mods/_test.sim/simulation/templates/test1-inherit.xml new file mode 100644 index 0000000000..f2b142b171 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/test1-inherit.xml @@ -0,0 +1,6 @@ + + + + 1234 + + diff --git a/binaries/data/mods/_test.sim/simulation/templates/test1.xml b/binaries/data/mods/_test.sim/simulation/templates/test1.xml new file mode 100644 index 0000000000..43a8b846f1 --- /dev/null +++ b/binaries/data/mods/_test.sim/simulation/templates/test1.xml @@ -0,0 +1,9 @@ + + + + 999 + + + (600+17)*20+5 + + diff --git a/binaries/data/mods/public/gui/common/functions_global_object.js b/binaries/data/mods/public/gui/common/functions_global_object.js index 85dc99956c..e7a4194e44 100644 --- a/binaries/data/mods/public/gui/common/functions_global_object.js +++ b/binaries/data/mods/public/gui/common/functions_global_object.js @@ -14,7 +14,7 @@ function messageBox (mbWidth, mbHeight, mbMessage, mbTitle, mbMode, mbButtonCaptions, mbButtonsCode) { - pushGuiPage("page_msgbox.xml", { + Engine.PushGuiPage("page_msgbox.xml", { width: mbWidth, height: mbHeight, message: mbMessage, diff --git a/binaries/data/mods/public/gui/common/functions_page_pregame_load.js b/binaries/data/mods/public/gui/common/functions_page_pregame_load.js index f555ab93a7..0c069a5c86 100644 --- a/binaries/data/mods/public/gui/common/functions_page_pregame_load.js +++ b/binaries/data/mods/public/gui/common/functions_page_pregame_load.js @@ -39,7 +39,7 @@ function launchGame () closeMainMenuSubWindow ("pgSessionSetup"); // Display loading screen. - switchGuiPage("page_loading.xml"); + Engine.SwitchGuiPage("page_loading.xml"); console.write( "running startGame()" ); @@ -47,7 +47,7 @@ function launchGame () if (! startGame()) { // Failed to start the game; go back to the main menu. - switchGuiPage("page_pregame.xml"); + Engine.SwitchGuiPage("page_pregame.xml"); // Restore default cursor. setCursor ("arrow-default"); // Show an error message diff --git a/binaries/data/mods/public/gui/common/setup.xml b/binaries/data/mods/public/gui/common/setup.xml index 58b4af5b89..0371a13edb 100644 --- a/binaries/data/mods/public/gui/common/setup.xml +++ b/binaries/data/mods/public/gui/common/setup.xml @@ -146,43 +146,19 @@ ========================================== --> - 0 0 0 - + 0 0 0 + 255 255 255 + 255 0 0 + 0 0 255 + 255 255 0 - 237 227 167 - + 237 227 167 + 243 242 240 + 43 42 40 + 0 200 0 + 191 191 2 + 159 98 24 - 255 255 255 - - - 243 242 240 - - - 43 42 40 - - - 0 0 255 - - - 0 200 0 - - - 191 191 2 - - - 159 98 24 - - - +