From bb0533819062c11d8fe32cbdb0845abd86bc7b8b Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Mon, 18 Apr 2011 23:10:08 -0300 Subject: [PATCH] first script stuff (still ugly and under experiments) --- CMakeLists.txt | 8 +++++-- Doxyfile | 2 +- data/lib/init.lua | 0 data/menustate.lua | 22 ++++++++++++++++++ data/modules/mainmenu/init.lua | 1 + data/modules/mainmenu/mainmenu.lua | 1 + data/modules/mainmenu/mainmenu.yml | 37 ++++++++++++++++++++++++++++++ src/framework/core/gamestate.h | 2 +- src/framework/graphics/font.cpp | 2 +- src/main.cpp | 3 +++ src/menustate.cpp | 4 ++++ 11 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 data/lib/init.lua create mode 100644 data/menustate.lua create mode 100644 data/modules/mainmenu/init.lua create mode 100644 data/modules/mainmenu/mainmenu.lua create mode 100644 data/modules/mainmenu/mainmenu.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d937222..7a8bb5a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ IF(CMAKE_BUILD_TYPE STREQUAL "Debug") ADD_DEFINITIONS(-D_DEBUG) ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug") -SET(SOURCES +SET(SOURCES src/framework/script/script.cpp # game sources src/main.cpp src/menustate.cpp @@ -67,6 +67,10 @@ SET(SOURCES src/framework/core/resources.cpp src/framework/core/engine.cpp +# framework script + src/framework/script/script.cpp + src/framework/script/scriptfunctions.cpp + # framework utilities src/framework/util/color.cpp src/framework/util/util.cpp @@ -125,7 +129,7 @@ ADD_EXECUTABLE(otclient ${SOURCES}) TARGET_LINK_LIBRARIES(otclient ${Boost_LIBRARIES} ${OPENGL_LIBRARY} - ${LUA51_LIBRARY} + ${LUA_LIBRARIES} ${YAMLCPP_LIBRARY} ${PHYSFS_LIBRARY} ${PNG_LIBRARY} diff --git a/Doxyfile b/Doxyfile index 2f1dd241..0963c314 100644 --- a/Doxyfile +++ b/Doxyfile @@ -516,7 +516,7 @@ SHOW_USED_FILES = YES # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. -SHOW_DIRECTORIES = NO +SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the diff --git a/data/lib/init.lua b/data/lib/init.lua new file mode 100644 index 00000000..e69de29b diff --git a/data/menustate.lua b/data/menustate.lua new file mode 100644 index 00000000..eb26f26a --- /dev/null +++ b/data/menustate.lua @@ -0,0 +1,22 @@ +MainMenuController = {} +enterGameController = {} + +function enterGameController.enterGameButton_clicked() + createEnterGameWindow() +end + +function mainMenuController.createMainMenu() + mainMenuPanel = loadUI("ui/mainMenuPanel.yml") + enterGameButton = mainMenuPanel:getElementById("enterGameButton") + enterGameButton.setOnClick(enterGameController.enterGameButton_clicked) + exitButton = mainMenuPanel:getElementById("exitButton") + exitButton:setOnClick(function() exitGame() end) +end + +function onEnter() + mainMenuController:createMainMenu() +end + +function onLeave() + +end diff --git a/data/modules/mainmenu/init.lua b/data/modules/mainmenu/init.lua new file mode 100644 index 00000000..296b7928 --- /dev/null +++ b/data/modules/mainmenu/init.lua @@ -0,0 +1 @@ +require("modules/mainmenu/mainmenu") \ No newline at end of file diff --git a/data/modules/mainmenu/mainmenu.lua b/data/modules/mainmenu/mainmenu.lua new file mode 100644 index 00000000..22150b0a --- /dev/null +++ b/data/modules/mainmenu/mainmenu.lua @@ -0,0 +1 @@ +loadUI("modules/mainmenu/mainmenu.yml") \ No newline at end of file diff --git a/data/modules/mainmenu/mainmenu.yml b/data/modules/mainmenu/mainmenu.yml new file mode 100644 index 00000000..1438a708 --- /dev/null +++ b/data/modules/mainmenu/mainmenu.yml @@ -0,0 +1,37 @@ +panel#mainMenu: + skin: roundedGridPanel + size: [117, 171] + anchors.left: parent.left + anchors.bottom: parent.bottom + margin.left: 60 + margin.bottom: 70 + + button#enterGameButton: + text: Enter Game + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 16 + + button#accessAccountButton: + text: Access Account + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 46 + + button#optionsButton: + text: Options + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 76 + + button#infoButton: + text: Info + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 106 + + button#exitGameButton: + text: Exit + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + margin.top: 136 \ No newline at end of file diff --git a/src/framework/core/gamestate.h b/src/framework/core/gamestate.h index dde082e2..199e64a4 100644 --- a/src/framework/core/gamestate.h +++ b/src/framework/core/gamestate.h @@ -41,7 +41,7 @@ public: /// Fired when leaves the state virtual void onLeave() = 0; - /// Fired when user tryes to close the window + /// Fired when user tries to close the window virtual void onClose() = 0; /// Fired for every user input event, this is called before processing UI input and if it returns false the input is not passed to the UI virtual bool onInputEvent(const InputEvent& event) = 0; diff --git a/src/framework/graphics/font.cpp b/src/framework/graphics/font.cpp index e12da001..6e2aa06e 100644 --- a/src/framework/graphics/font.cpp +++ b/src/framework/graphics/font.cpp @@ -279,7 +279,7 @@ const std::vector& Font::calculateGlyphsPositions(const std::string& text if(textBoxSize) { textBoxSize->setWidth(maxLineWidth); - textBoxSize->setHeight(virtualPos.y + m_glyphHeight + m_glyphSpacing.height()); + textBoxSize->setHeight(virtualPos.y + m_glyphHeight); } return glyphsPositions; diff --git a/src/main.cpp b/src/main.cpp index 16eb0ba5..c17666f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,6 +31,7 @@ #include #include "menustate.h" #include "teststate.h" +#include