first script stuff (still ugly and under experiments)

This commit is contained in:
Eduardo Bart 2011-04-18 23:10:08 -03:00
parent 3de455fe7e
commit bb05338190
11 changed files with 77 additions and 5 deletions

View File

@ -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}

View File

@ -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

0
data/lib/init.lua Normal file
View File

22
data/menustate.lua Normal file
View File

@ -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

View File

@ -0,0 +1 @@
require("modules/mainmenu/mainmenu")

View File

@ -0,0 +1 @@
loadUI("modules/mainmenu/mainmenu.yml")

View File

@ -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

View File

@ -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;

View File

@ -279,7 +279,7 @@ const std::vector<Point>& 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;

View File

@ -31,6 +31,7 @@
#include <ui/uiskins.h>
#include "menustate.h"
#include "teststate.h"
#include <script/script.h>
/// Catches signals so we can exit nicely
void signal_handler(int sig)
@ -109,6 +110,8 @@ int main(int argc, const char *argv[])
// init engine
g_engine.init();
g_script.init();
g_script.loadFile("lib/init.lua");
g_uiSkins.load("skins/tibiaskin.yml");
// state scope

View File

@ -32,12 +32,15 @@
#include <graphics/fonts.h>
#include <ui/ui.h>
#include "menustate.h"
#include <script/script.h>
void MenuState::onEnter()
{
m_background = g_textures.get("background.png");
m_background->enableBilinearFilter();
g_script.loadFile("modules/mainmenu/init.lua");
/*
UIContainerPtr mainMenuPanel = UILoader::loadFile("ui/mainMenu.yml")->asUIContainer();
UIButtonPtr button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("exitGameButton"));
@ -51,6 +54,7 @@ void MenuState::onEnter()
button = boost::static_pointer_cast<UIButton>(mainMenuPanel->getChildById("optionsButton"));
button->setOnClick(boost::bind(&MenuState::optionsButton_clicked, this));
*/
}
void MenuState::onLeave()