parent
a3901b0251
commit
e611734396
@ -1,41 +1,51 @@
|
||||
panel#mainMenu:
|
||||
skin: roundedGridPanel
|
||||
size: [117, 171]
|
||||
panel#background:
|
||||
skin:
|
||||
image: background.png
|
||||
antialised: true
|
||||
size: [500, 500]
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
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
|
||||
onClick: MainMenu_enterGameClicked()
|
||||
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
|
||||
onClick: MainMenu_enterGameClicked()
|
||||
|
||||
button#accessAccountButton:
|
||||
text: Access Account
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 46
|
||||
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
|
||||
onClick: MainMenu_optionsClicked()
|
||||
button#optionsButton:
|
||||
text: Options
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 76
|
||||
onClick: MainMenu_optionsClicked()
|
||||
|
||||
button#infoButton:
|
||||
text: Info
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 106
|
||||
onClick: MainMenu_infoClicked()
|
||||
button#infoButton:
|
||||
text: Info
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 106
|
||||
onClick: MainMenu_infoClicked()
|
||||
|
||||
button#exitGameButton:
|
||||
text: Exit
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 136
|
||||
onClick: MainMenu_exitClicked()
|
||||
button#exitGameButton:
|
||||
text: Exit
|
||||
anchors.top: parent.top
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
margin.top: 136
|
||||
onClick: MainMenu_exitClicked()
|
@ -0,0 +1,20 @@
|
||||
-- menu state
|
||||
function onEnterMenuState()
|
||||
MainMenu_create()
|
||||
end
|
||||
|
||||
function onLeaveMenuState()
|
||||
MainMenu_destroy()
|
||||
end
|
||||
|
||||
function onApplicationClose()
|
||||
onLeaveMenuState()
|
||||
exitGame()
|
||||
end
|
||||
|
||||
-- here is where everything starts
|
||||
if not initialStateLoaded then
|
||||
onEnterMenuState()
|
||||
setOnApplicationClose(onApplicationClose)
|
||||
initialStateLoaded = true
|
||||
end
|
@ -0,0 +1,10 @@
|
||||
title: Main menu
|
||||
notes: Used to create the main menu
|
||||
enabled: true
|
||||
#dependencies
|
||||
interface: 020
|
||||
author: edubart
|
||||
version: 0.2
|
||||
scripts:
|
||||
- menustate.lua
|
||||
- mainmenu.lua
|
@ -1,55 +0,0 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef GAMESTATE_H
|
||||
#define GAMESTATE_H
|
||||
|
||||
#include <prerequisites.h>
|
||||
#include <core/input.h>
|
||||
|
||||
struct InputEvent;
|
||||
|
||||
class GameState
|
||||
{
|
||||
public:
|
||||
GameState() { }
|
||||
virtual ~GameState() { }
|
||||
|
||||
/// Fired when enter the state
|
||||
virtual void onEnter() = 0;
|
||||
/// Fired when leaves the state
|
||||
virtual void onLeave() = 0;
|
||||
|
||||
/// 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;
|
||||
/// Fired when main window is resized
|
||||
virtual void onResize(const Size& size) = 0;
|
||||
|
||||
/// Fired before redering the UI
|
||||
virtual void render() = 0;
|
||||
};
|
||||
|
||||
#endif // GAMESTATE_H
|
@ -1,79 +0,0 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#include <prerequisites.h>
|
||||
#include <core/engine.h>
|
||||
#include <core/dispatcher.h>
|
||||
#include <graphics/framebuffer.h>
|
||||
#include <graphics/graphics.h>
|
||||
#include <graphics/textures.h>
|
||||
#include <graphics/borderedimage.h>
|
||||
#include <graphics/fonts.h>
|
||||
#include <ui/ui.h>
|
||||
#include "menustate.h"
|
||||
#include <script/luascript.h>
|
||||
|
||||
void MenuState::onEnter()
|
||||
{
|
||||
m_background = g_textures.get("background.png");
|
||||
m_background->enableBilinearFilter();
|
||||
|
||||
g_lua.loadFile("modules/mainmenu/mainmenu.lua");
|
||||
}
|
||||
|
||||
void MenuState::onLeave()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MenuState::onClose()
|
||||
{
|
||||
g_engine.stop();
|
||||
}
|
||||
|
||||
bool MenuState::onInputEvent(const InputEvent& event)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void MenuState::onResize(const Size& size)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MenuState::render()
|
||||
{
|
||||
// render background
|
||||
static Size minTexCoordsSize(1240, 880);
|
||||
const Size& screenSize = g_graphics.getScreenSize();
|
||||
const Size& texSize = m_background->getSize();
|
||||
Size texCoordsSize = screenSize;
|
||||
if(texCoordsSize < minTexCoordsSize)
|
||||
texCoordsSize.scale(minTexCoordsSize, KEEP_ASPECT_RATIO_BY_EXPANDING);
|
||||
texCoordsSize = texCoordsSize.boundedTo(texSize);
|
||||
Rect texCoords(0, 0, texCoordsSize);
|
||||
texCoords.moveBottomRight(texSize.toPoint());
|
||||
g_graphics.drawTexturedRect(Rect(0, 0, screenSize), m_background, texCoords);
|
||||
}
|
||||
|
@ -1,59 +0,0 @@
|
||||
/* The MIT License
|
||||
*
|
||||
* Copyright (c) 2010 OTClient, https://github.com/edubart/otclient
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef MENUSTATE_H
|
||||
#define MENUSTATE_H
|
||||
|
||||
#include <prerequisites.h>
|
||||
#include <core/gamestate.h>
|
||||
#include <graphics/texture.h>
|
||||
#include "protocollogin.h"
|
||||
|
||||
class MenuState : public GameState
|
||||
{
|
||||
|
||||
public:
|
||||
MenuState() { }
|
||||
|
||||
void onEnter();
|
||||
void onLeave();
|
||||
|
||||
void onClose();
|
||||
bool onInputEvent(const InputEvent& event);
|
||||
void onResize(const Size& size);
|
||||
|
||||
void render();
|
||||
|
||||
private:
|
||||
void enterGameButton_clicked();
|
||||
void infoButton_clicked();
|
||||
void optionsButton_clicked();
|
||||
|
||||
void enterGameWindowOkButton_clicked();
|
||||
|
||||
TexturePtr m_background;
|
||||
ProtocolLoginPtr m_protocolLogin;
|
||||
};
|
||||
|
||||
#endif // MENUSTATE_H
|
Loading…
Reference in new issue