Updated ClientApplication

This commit is contained in:
Kayne Ruse
2014-07-31 13:57:46 +10:00
parent 67c8bb6f11
commit a8eb67d619
3 changed files with 51 additions and 35 deletions
+1
View File
@@ -15,6 +15,7 @@ Out/
*.o *.o
*.a *.a
*.exe *.exe
*.diff
#Shell files #Shell files
*.bat *.bat
+44 -34
View File
@@ -72,62 +72,72 @@ void ClientApplication::Init(int argc, char** argv) {
luaL_openlibs(lua); luaL_openlibs(lua);
std::cout << "Initialized lua" << std::endl; std::cout << "Initialized lua" << std::endl;
//run the setup script
if (luaL_dofile(lua, "rsc\\setup.lua")) { if (luaL_dofile(lua, "rsc\\setup.lua")) {
throw(std::runtime_error("Failed to initialize lua's startup script")); throw(std::runtime_error("Failed to initialize lua's startup script"));
} }
std::cout << "Initialized lua's setup script" << std::endl; std::cout << "Initialized lua's setup script" << std::endl;
//place the config table onto the stack
lua_getglobal(lua, "config");
//------------------------- //-------------------------
//Setup the screen //Setup the screen
//------------------------- //-------------------------
lua_getglobal(lua, "config"); //get each field
lua_getfield(lua, 1, "screen"); lua_getfield(lua, -1, "client");
lua_getfield(lua, 2, "width"); lua_getfield(lua, -1, "screen");
lua_getfield(lua, 2, "height"); lua_getfield(lua, -1, "width");
lua_getfield(lua, 2, "fullscreen"); lua_getfield(lua, -2, "height");
lua_getfield(lua, -3, "fullscreen");
int w = lua_tointeger(lua, 3); int w = lua_tointeger(lua, -3);
int h = lua_tointeger(lua, 4); int h = lua_tointeger(lua, -2);
int f = lua_toboolean(lua, 5); int f = lua_toboolean(lua, -1);
//pop the screen members
lua_pop(lua, 5); lua_pop(lua, 5);
BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF); BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f ?
std::cout << "Initialized the screen" << std::endl; SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN :
SDL_HWSURFACE|SDL_DOUBLEBUF);
int w = config.Int("client.screen.w");
int h = config.Int("client.screen.h");
int f = config.Bool("client.screen.f") ? SDL_HWSURFACE|SDL_DOUBLEBUF|SDL_FULLSCREEN : SDL_HWSURFACE|SDL_DOUBLEBUF;
BaseScene::SetScreen(w ? w : 800, h ? h : 600, 0, f);
std::cout << "Initialized the screen" << std::endl; std::cout << "Initialized the screen" << std::endl;
//------------------------- //-------------------------
//debug output //debug output
//------------------------- //-------------------------
//TODO: enable/disable these with a switch lua_getfield(lua, -1, "debug");
if (lua_toboolean(lua, -1)) {
#define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl; #define DEBUG_OUTPUT_VAR(x) std::cout << "\t" << #x << ": " << x << std::endl;
std::cout << "Internal sizes:" << std::endl; std::cout << "Internal sizes:" << std::endl;
DEBUG_OUTPUT_VAR(sizeof(Region::type_t)); DEBUG_OUTPUT_VAR(sizeof(Region::type_t));
DEBUG_OUTPUT_VAR(sizeof(Region)); DEBUG_OUTPUT_VAR(sizeof(Region));
DEBUG_OUTPUT_VAR(REGION_WIDTH); DEBUG_OUTPUT_VAR(REGION_WIDTH);
DEBUG_OUTPUT_VAR(REGION_HEIGHT); DEBUG_OUTPUT_VAR(REGION_HEIGHT);
DEBUG_OUTPUT_VAR(REGION_DEPTH); DEBUG_OUTPUT_VAR(REGION_DEPTH);
DEBUG_OUTPUT_VAR(REGION_SOLID_FOOTPRINT); DEBUG_OUTPUT_VAR(REGION_SOLID_FOOTPRINT);
DEBUG_OUTPUT_VAR(REGION_FOOTPRINT); DEBUG_OUTPUT_VAR(REGION_FOOTPRINT);
DEBUG_OUTPUT_VAR(PACKET_BUFFER_SIZE); DEBUG_OUTPUT_VAR(PACKET_BUFFER_SIZE);
DEBUG_OUTPUT_VAR(MAX_PACKET_SIZE); DEBUG_OUTPUT_VAR(MAX_PACKET_SIZE);
#undef DEBUG_OUTPUT_VAR #undef DEBUG_OUTPUT_VAR
}
//pop the debug value
lua_pop(lua, 1);
//------------------------- //-------------------------
//finalize the startup //finalize the startup
//------------------------- //-------------------------
//pop the config table
lua_pop(lua, 1);
std::cout << "Startup completed successfully" << std::endl; std::cout << "Startup completed successfully" << std::endl;
//------------------------- //-------------------------
@@ -191,25 +201,25 @@ void ClientApplication::LoadScene(SceneList sceneIndex) {
//add scene creation calls here //add scene creation calls here
case SceneList::FIRST: case SceneList::FIRST:
case SceneList::SPLASHSCREEN: case SceneList::SPLASHSCREEN:
activeScene = new SplashScreen(&config); activeScene = new SplashScreen(lua);
break; break;
case SceneList::MAINMENU: case SceneList::MAINMENU:
activeScene = new MainMenu(&config); activeScene = new MainMenu(lua);
break; break;
case SceneList::OPTIONSMENU: case SceneList::OPTIONSMENU:
activeScene = new OptionsMenu(&config); activeScene = new OptionsMenu(lua);
break; break;
case SceneList::LOBBYMENU: case SceneList::LOBBYMENU:
activeScene = new LobbyMenu(&config, &network, &clientIndex, &accountIndex); activeScene = new LobbyMenu(lua, network, characterMap);
break; break;
case SceneList::INWORLD: case SceneList::INWORLD:
activeScene = new InWorld(&config, &network, &clientIndex, &accountIndex, &characterIndex, &characterMap); activeScene = new InWorld(lua, network, characterMap);
break; break;
case SceneList::INCOMBAT: case SceneList::INCOMBAT:
activeScene = new InCombat(&config, &network, &clientIndex, &accountIndex, &characterIndex, &characterMap); activeScene = new InCombat(lua, network, characterMap);
break; break;
case SceneList::CLEANUP: case SceneList::CLEANUP:
activeScene = new CleanUp(&config, &network, &clientIndex, &accountIndex, &characterIndex, &characterMap); activeScene = new CleanUp(lua, network, characterMap);
break; break;
default: default:
throw(std::logic_error("Failed to recognize the scene index")); throw(std::logic_error("Failed to recognize the scene index"));
+6 -1
View File
@@ -33,7 +33,12 @@ config = {
}, },
username = "Kayne", username = "Kayne",
handle = "Ratstail91", handle = "Ratstail91",
avatar = "elliot2.bmp" avatar = "elliot2.bmp",
--NOTE: these generally go here
-- clientIndex
-- accountIndex
-- characterIndex
}, },
--server specific stuff --server specific stuff