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:
@@ -171,7 +171,7 @@ void ClientApplication::Proc() {
|
||||
//simulate game time
|
||||
while (simTime < realTime) {
|
||||
//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;
|
||||
}
|
||||
|
||||
|
||||
+37
-23
@@ -29,25 +29,43 @@
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
CleanUp::CleanUp(
|
||||
ConfigUtility* const argConfig,
|
||||
UDPNetworkUtility* const argNetwork,
|
||||
int* const argClientIndex,
|
||||
int* const argAccountIndex,
|
||||
int* const argCharacterIndex,
|
||||
CharacterMap* argCharacterMap
|
||||
):
|
||||
config(*argConfig),
|
||||
network(*argNetwork),
|
||||
clientIndex(*argClientIndex),
|
||||
accountIndex(*argAccountIndex),
|
||||
characterIndex(*argCharacterIndex),
|
||||
characterMap(*argCharacterMap)
|
||||
CleanUp::CleanUp(lua_State* L, UDPNetworkUtility& aNetwork, CharacterMap& aCharacterMap):
|
||||
lua(L),
|
||||
network(aNetwork),
|
||||
characterMap(aCharacterMap)
|
||||
{
|
||||
//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
|
||||
image.LoadSurface(config["dir.interface"] + "button_menu.bmp");
|
||||
image.LoadSurface(interfaceDir + "button_menu.bmp");
|
||||
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
|
||||
backButton.SetImage(&image);
|
||||
@@ -62,12 +80,7 @@ CleanUp::CleanUp(
|
||||
|
||||
//full reset
|
||||
network.Unbind(Channels::SERVER);
|
||||
clientIndex = -1;
|
||||
accountIndex = -1;
|
||||
characterIndex = -1;
|
||||
// combatMap.clear();
|
||||
characterMap.clear();
|
||||
// enemyMap.clear();
|
||||
|
||||
//auto return
|
||||
startTick = std::chrono::steady_clock::now();
|
||||
@@ -83,7 +96,7 @@ CleanUp::~CleanUp() {
|
||||
|
||||
void CleanUp::Update(double delta) {
|
||||
if (std::chrono::steady_clock::now() - startTick > std::chrono::duration<int>(10)) {
|
||||
QuitEvent();
|
||||
SetNextScene(SceneList::MAINMENU);
|
||||
}
|
||||
|
||||
//BUGFIX: Eat incoming packets
|
||||
@@ -119,7 +132,8 @@ void CleanUp::MouseButtonDown(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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,19 +25,18 @@
|
||||
//network
|
||||
#include "udp_network_utility.hpp"
|
||||
|
||||
//graphics
|
||||
//graphics & ui
|
||||
#include "image.hpp"
|
||||
#include "raster_font.hpp"
|
||||
#include "button.hpp"
|
||||
|
||||
//common
|
||||
#include "config_utility.hpp"
|
||||
#include "frame_rate.hpp"
|
||||
|
||||
#include "character.hpp"
|
||||
|
||||
//client
|
||||
#include "base_scene.hpp"
|
||||
#include "character.hpp"
|
||||
|
||||
//APIs
|
||||
#include "lua/lua.hpp"
|
||||
|
||||
//std namespace
|
||||
#include <chrono>
|
||||
@@ -45,14 +44,7 @@
|
||||
class CleanUp : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
CleanUp(
|
||||
ConfigUtility* const argConfig,
|
||||
UDPNetworkUtility* const argNetwork,
|
||||
int* const argClientIndex,
|
||||
int* const argAccountIndex,
|
||||
int* const argCharacterIndex,
|
||||
CharacterMap* argCharacterMap
|
||||
);
|
||||
CleanUp(lua_State*, UDPNetworkUtility&, CharacterMap&);
|
||||
~CleanUp();
|
||||
|
||||
protected:
|
||||
@@ -70,18 +62,13 @@ protected:
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//shared parameters
|
||||
ConfigUtility& config;
|
||||
lua_State* lua = nullptr;
|
||||
UDPNetworkUtility& network;
|
||||
int& clientIndex;
|
||||
int& accountIndex;
|
||||
int& characterIndex;
|
||||
CharacterMap& characterMap;
|
||||
|
||||
//graphics
|
||||
//graphics & ui
|
||||
Image image;
|
||||
RasterFont font;
|
||||
|
||||
//UI
|
||||
Button backButton;
|
||||
FrameRate fps;
|
||||
|
||||
|
||||
@@ -30,15 +30,17 @@ MainMenu::MainMenu(lua_State* L): lua(L) {
|
||||
lua_getglobal(lua, "config");
|
||||
lua_getfield(lua, -1, "dir");
|
||||
lua_getfield(lua, -1, "interface");
|
||||
std::string interface = lua_tostring(lua, -1);
|
||||
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);
|
||||
|
||||
//setup the utility objects
|
||||
image.LoadSurface(interface + "button_menu.bmp");
|
||||
image.LoadSurface(interfaceDir + "button_menu.bmp");
|
||||
image.SetClipH(image.GetClipH()/3);
|
||||
font.LoadSurface(fonts + "pk_white_8.bmp");
|
||||
font.LoadSurface(fontsDir + "pk_white_8.bmp");
|
||||
|
||||
//pass the utility objects
|
||||
startButton.SetImage(&image);
|
||||
@@ -114,7 +116,8 @@ void MainMenu::MouseButtonUp(SDL_MouseButtonEvent const& button) {
|
||||
if (optionsButton.MouseButtonUp(button) == Button::State::HOVER) {
|
||||
SetNextScene(SceneList::OPTIONSMENU);
|
||||
}
|
||||
if (quitButton.MouseButtonUp(button) == Button::State::HOVER) {
|
||||
if (quitButton.MouseButtonUp(button) == Button::State::HOVER &&
|
||||
button.button & SDL_BUTTON_LMASK) {
|
||||
QuitEvent();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,15 +30,17 @@ OptionsMenu::OptionsMenu(lua_State* L): lua(L) {
|
||||
lua_getglobal(lua, "config");
|
||||
lua_getfield(lua, -1, "dir");
|
||||
lua_getfield(lua, -1, "interface");
|
||||
std::string interface = lua_tostring(lua, -1);
|
||||
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);
|
||||
|
||||
//setup the utility objects
|
||||
image.LoadSurface(interface + "button_menu.bmp");
|
||||
image.LoadSurface(interfaceDir + "button_menu.bmp");
|
||||
image.SetClipH(image.GetClipH()/3);
|
||||
font.LoadSurface(fonts + "pk_white_8.bmp");
|
||||
font.LoadSurface(fontsDir + "pk_white_8.bmp");
|
||||
|
||||
//pass the utility objects
|
||||
backButton.SetImage(&image);
|
||||
@@ -91,7 +93,8 @@ void OptionsMenu::MouseButtonDown(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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user