From ae0cecdce60daa6f7ccd4f377472a8e36a4f2104 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sun, 6 Jun 2010 19:04:08 +0100 Subject: [PATCH] Re-enable UI demo mode and add Lua script --- scripts/uidemo.lua | 1 + src/Main.cpp | 2 +- src/UIDemo.cpp | 5 ++++- 3 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 scripts/uidemo.lua diff --git a/scripts/uidemo.lua b/scripts/uidemo.lua new file mode 100644 index 0000000..c8abd5f --- /dev/null +++ b/scripts/uidemo.lua @@ -0,0 +1 @@ +debug("Lua UI demo!") \ No newline at end of file diff --git a/src/Main.cpp b/src/Main.cpp index 1834019..022587c 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -96,7 +96,7 @@ int main(int argc, char** argv) log() << "Program started"; try { - if (::action == "" || ::mapFile == "") + if (::action == "" || (::mapFile == "" && ::action != "uidemo")) throw runtime_error("Usage: TrainGame (edit|play) [map]"); initResources(); diff --git a/src/UIDemo.cpp b/src/UIDemo.cpp index b8cfd1a..b52494f 100644 --- a/src/UIDemo.cpp +++ b/src/UIDemo.cpp @@ -1,5 +1,5 @@ // -// Copyright (C) 2009 Nick Gasson +// Copyright (C) 2009-2010 Nick Gasson // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -19,6 +19,7 @@ #include "gui/ILayout.hpp" #include "gui/Label.hpp" #include "ILogger.hpp" +#include "ILua.hpp" #include @@ -53,6 +54,8 @@ UIDemo::UIDemo() layout->get("/wnd1/btn1").connect(gui::Widget::SIG_CLICK, bind(&UIDemo::btn1Click, this, _1)); + + getLua()->loadFile("scripts/uidemo.lua"); } void UIDemo::btn1Click(gui::Widget& w) -- 2.39.2