first script stuff (still ugly and under experiments)

master
Eduardo Bart 13 years ago
parent 3de455fe7e
commit bb05338190

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

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

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

@ -0,0 +1 @@
loadUI("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

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

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

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

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

Loading…
Cancel
Save