Updated a number of simpler client scenes (read more)

Updated the ClientApplication class to help support the new design, but
it's not finished because of that module's dependence on the various
scenes.

Updated the following scenes:

* CleanUp
* MainMenu
* OptionsMenu

The following source files (in client/scenes/) compile correctly:

* base_scene.cpp
* splash_screen.cpp
* clean_up.cpp
* main_menu.cpp
* options_menu.cpp

The folling source files (in client/scenes/) do not compile:

* in_world.cpp
* in_combat.cpp
* lobby_menu.cpp
This commit is contained in:
Kayne Ruse
2014-07-31 14:48:04 +10:00
parent a8eb67d619
commit 35363c05c3
5 changed files with 62 additions and 55 deletions
+1 -1
View File
@@ -171,7 +171,7 @@ void ClientApplication::Proc() {
//simulate game time //simulate game time
while (simTime < realTime) { while (simTime < realTime) {
//call each user defined function //call each user defined function
activeScene->RunFrame(double(delta.count()) / std::chrono::duration<int, std::milli>::period::den); activeScene->RunFrame(constexpr(double(delta.count()) / std::chrono::duration<int, std::milli>::period::den));
simTime += delta; simTime += delta;
} }
+37 -23
View File
@@ -29,25 +29,43 @@
//Public access members //Public access members
//------------------------- //-------------------------
CleanUp::CleanUp( CleanUp::CleanUp(lua_State* L, UDPNetworkUtility& aNetwork, CharacterMap& aCharacterMap):
ConfigUtility* const argConfig, lua(L),
UDPNetworkUtility* const argNetwork, network(aNetwork),
int* const argClientIndex, characterMap(aCharacterMap)
int* const argAccountIndex,
int* const argCharacterIndex,
CharacterMap* argCharacterMap
):
config(*argConfig),
network(*argNetwork),
clientIndex(*argClientIndex),
accountIndex(*argAccountIndex),
characterIndex(*argCharacterIndex),
characterMap(*argCharacterMap)
{ {
//get the config table
lua_getglobal(lua, "config");
//TODO: I need to figure out an alternative to loading these over and over again
//get the directories
lua_getfield(lua, -1, "dir");
lua_getfield(lua, -1, "interface");
lua_getfield(lua, -2, "fonts");
std::string interfaceDir = lua_tostring(lua, -2);
std::string fontsDir = lua_tostring(lua, -1);
lua_pop(lua, 3);
//clear the indicies
lua_getfield(lua, -1, "client");
lua_pushnil(lua);
lua_pushnil(lua);
lua_pushnil(lua);
lua_setfield(lua, -4, "clientIndex");
lua_setfield(lua, -3, "accountIndex");
lua_setfield(lua, -2, "characterIndex");
//pop the remaining objects from the stack
lua_pop(lua, 2);
//setup the utility objects //setup the utility objects
image.LoadSurface(config["dir.interface"] + "button_menu.bmp"); image.LoadSurface(interfaceDir + "button_menu.bmp");
image.SetClipH(image.GetClipH()/3); image.SetClipH(image.GetClipH()/3);
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp"); font.LoadSurface(fontsDir + "pk_white_8.bmp");
//pass the utility objects //pass the utility objects
backButton.SetImage(&image); backButton.SetImage(&image);
@@ -62,12 +80,7 @@ CleanUp::CleanUp(
//full reset //full reset
network.Unbind(Channels::SERVER); network.Unbind(Channels::SERVER);
clientIndex = -1;
accountIndex = -1;
characterIndex = -1;
// combatMap.clear();
characterMap.clear(); characterMap.clear();
// enemyMap.clear();
//auto return //auto return
startTick = std::chrono::steady_clock::now(); startTick = std::chrono::steady_clock::now();
@@ -83,7 +96,7 @@ CleanUp::~CleanUp() {
void CleanUp::Update(double delta) { void CleanUp::Update(double delta) {
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) { if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) {
QuitEvent(); SetNextScene(SceneList::MAINMENU);
} }
//BUGFIX: Eat incoming packets //BUGFIX: Eat incoming packets
@@ -119,7 +132,8 @@ void CleanUp::MouseButtonDown(SDL_MouseButtonEvent const& button) {
} }
void CleanUp::MouseButtonUp(SDL_MouseButtonEvent const& button) { void CleanUp::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (backButton.MouseButtonUp(button) == Button::State::HOVER) { if (backButton.MouseButtonUp(button) == Button::State::HOVER &&
button.button & SDL_BUTTON_LMASK) {
SetNextScene(SceneList::MAINMENU); SetNextScene(SceneList::MAINMENU);
} }
} }
+8 -21
View File
@@ -25,19 +25,18 @@
//network //network
#include "udp_network_utility.hpp" #include "udp_network_utility.hpp"
//graphics //graphics & ui
#include "image.hpp" #include "image.hpp"
#include "raster_font.hpp" #include "raster_font.hpp"
#include "button.hpp" #include "button.hpp"
//common
#include "config_utility.hpp"
#include "frame_rate.hpp" #include "frame_rate.hpp"
#include "character.hpp"
//client //client
#include "base_scene.hpp" #include "base_scene.hpp"
#include "character.hpp"
//APIs
#include "lua/lua.hpp"
//std namespace //std namespace
#include <chrono> #include <chrono>
@@ -45,14 +44,7 @@
class CleanUp : public BaseScene { class CleanUp : public BaseScene {
public: public:
//Public access members //Public access members
CleanUp( CleanUp(lua_State*, UDPNetworkUtility&, CharacterMap&);
ConfigUtility* const argConfig,
UDPNetworkUtility* const argNetwork,
int* const argClientIndex,
int* const argAccountIndex,
int* const argCharacterIndex,
CharacterMap* argCharacterMap
);
~CleanUp(); ~CleanUp();
protected: protected:
@@ -70,18 +62,13 @@ protected:
void KeyUp(SDL_KeyboardEvent const&); void KeyUp(SDL_KeyboardEvent const&);
//shared parameters //shared parameters
ConfigUtility& config; lua_State* lua = nullptr;
UDPNetworkUtility& network; UDPNetworkUtility& network;
int& clientIndex;
int& accountIndex;
int& characterIndex;
CharacterMap& characterMap; CharacterMap& characterMap;
//graphics //graphics & ui
Image image; Image image;
RasterFont font; RasterFont font;
//UI
Button backButton; Button backButton;
FrameRate fps; FrameRate fps;
+8 -5
View File
@@ -30,15 +30,17 @@ MainMenu::MainMenu(lua_State* L): lua(L) {
lua_getglobal(lua, "config"); lua_getglobal(lua, "config");
lua_getfield(lua, -1, "dir"); lua_getfield(lua, -1, "dir");
lua_getfield(lua, -1, "interface"); lua_getfield(lua, -1, "interface");
std::string interface = lua_tostring(lua, -1);
lua_getfield(lua, -2, "fonts"); lua_getfield(lua, -2, "fonts");
std::string fonts = lua_tostring(lua, -1);
std::string interfaceDir = lua_tostring(lua, -2);
std::string fontsDir = lua_tostring(lua, -1);
lua_pop(lua, 4); lua_pop(lua, 4);
//setup the utility objects //setup the utility objects
image.LoadSurface(interface + "button_menu.bmp"); image.LoadSurface(interfaceDir + "button_menu.bmp");
image.SetClipH(image.GetClipH()/3); image.SetClipH(image.GetClipH()/3);
font.LoadSurface(fonts + "pk_white_8.bmp"); font.LoadSurface(fontsDir + "pk_white_8.bmp");
//pass the utility objects //pass the utility objects
startButton.SetImage(&image); startButton.SetImage(&image);
@@ -114,7 +116,8 @@ void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (optionsButton.MouseButtonUp(button) == Button::State::HOVER) { if (optionsButton.MouseButtonUp(button) == Button::State::HOVER) {
SetNextScene(SceneList::OPTIONSMENU); SetNextScene(SceneList::OPTIONSMENU);
} }
if (quitButton.MouseButtonUp(button) == Button::State::HOVER) { if (quitButton.MouseButtonUp(button) == Button::State::HOVER &&
button.button & SDL_BUTTON_LMASK) {
QuitEvent(); QuitEvent();
} }
} }
+8 -5
View File
@@ -30,15 +30,17 @@ OptionsMenu::OptionsMenu(lua_State* L): lua(L) {
lua_getglobal(lua, "config"); lua_getglobal(lua, "config");
lua_getfield(lua, -1, "dir"); lua_getfield(lua, -1, "dir");
lua_getfield(lua, -1, "interface"); lua_getfield(lua, -1, "interface");
std::string interface = lua_tostring(lua, -1);
lua_getfield(lua, -2, "fonts"); lua_getfield(lua, -2, "fonts");
std::string fonts = lua_tostring(lua, -1);
std::string interfaceDir = lua_tostring(lua, -2);
std::string fontsDir = lua_tostring(lua, -1);
lua_pop(lua, 4); lua_pop(lua, 4);
//setup the utility objects //setup the utility objects
image.LoadSurface(interface + "button_menu.bmp"); image.LoadSurface(interfaceDir + "button_menu.bmp");
image.SetClipH(image.GetClipH()/3); image.SetClipH(image.GetClipH()/3);
font.LoadSurface(fonts + "pk_white_8.bmp"); font.LoadSurface(fontsDir + "pk_white_8.bmp");
//pass the utility objects //pass the utility objects
backButton.SetImage(&image); backButton.SetImage(&image);
@@ -91,7 +93,8 @@ void OptionsMenu::MouseButtonDown(SDL_MouseButtonEvent const& button) {
} }
void OptionsMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) { void OptionsMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
if (backButton.MouseButtonUp(button) == Button::State::HOVER) { if (backButton.MouseButtonUp(button) == Button::State::HOVER &&
button.button & SDL_BUTTON_LMASK) {
SetNextScene(SceneList::MAINMENU); SetNextScene(SceneList::MAINMENU);
} }
} }