Added config based directories
This commit is contained in:
@@ -62,7 +62,7 @@ void ClientApplication::Init() {
|
||||
if (SDL_Init(SDL_INIT_VIDEO)) {
|
||||
throw(std::runtime_error("Failed to initialize SDL"));
|
||||
}
|
||||
BaseScene::SetScreen(800, 600);
|
||||
BaseScene::SetScreen(config.Int("screen.w"), config.Int("screen.h"), 0, (config.Bool("screen.f")) ? SDL_HWSURFACE|SDL_DOUBLEBUF : SDL_HWSURFACE);
|
||||
|
||||
//initialize SDL_net
|
||||
if (SDLNet_Init()) {
|
||||
@@ -126,13 +126,13 @@ void ClientApplication::LoadScene(SceneList sceneIndex) {
|
||||
//add scene creation calls here
|
||||
case SceneList::FIRST:
|
||||
case SceneList::SPLASHSCREEN:
|
||||
activeScene = new SplashScreen();
|
||||
activeScene = new SplashScreen(&config);
|
||||
break;
|
||||
case SceneList::MAINMENU:
|
||||
activeScene = new MainMenu();
|
||||
activeScene = new MainMenu(&config);
|
||||
break;
|
||||
case SceneList::OPTIONSMENU:
|
||||
activeScene = new OptionsMenu();
|
||||
activeScene = new OptionsMenu(&config);
|
||||
break;
|
||||
case SceneList::LOBBYMENU:
|
||||
activeScene = new LobbyMenu(&config, &network);
|
||||
|
||||
@@ -30,9 +30,9 @@ LobbyMenu::LobbyMenu(ConfigUtility* const arg1, UDPNetworkUtility* const arg2):
|
||||
network(*arg2)
|
||||
{
|
||||
//setup the utility objects
|
||||
image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp");
|
||||
image.LoadSurface(config["dir.interface"] + "button_menu.bmp");
|
||||
image.SetClipH(image.GetClipH()/3);
|
||||
font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp");
|
||||
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp");
|
||||
|
||||
//pass the utility objects
|
||||
search.SetImage(&image);
|
||||
|
||||
@@ -37,7 +37,6 @@
|
||||
class LobbyMenu : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
LobbyMenu() = delete;
|
||||
LobbyMenu(ConfigUtility* const, UDPNetworkUtility* const);
|
||||
~LobbyMenu();
|
||||
|
||||
@@ -55,7 +54,7 @@ protected:
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//handles
|
||||
//global
|
||||
ConfigUtility& config;
|
||||
UDPNetworkUtility& network;
|
||||
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
MainMenu::MainMenu() {
|
||||
MainMenu::MainMenu(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
//setup the utility objects
|
||||
image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp");
|
||||
image.LoadSurface(config["dir.interface"] + "button_menu.bmp");
|
||||
image.SetClipH(image.GetClipH()/3);
|
||||
font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp");
|
||||
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp");
|
||||
|
||||
//pass the utility objects
|
||||
startButton.SetImage(&image);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "image.hpp"
|
||||
#include "raster_font.hpp"
|
||||
#include "button.hpp"
|
||||
@@ -31,7 +32,7 @@
|
||||
class MainMenu : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
MainMenu();
|
||||
MainMenu(ConfigUtility* const);
|
||||
~MainMenu();
|
||||
|
||||
protected:
|
||||
@@ -48,6 +49,9 @@ protected:
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//members
|
||||
Image image;
|
||||
RasterFont font;
|
||||
|
||||
@@ -25,11 +25,13 @@
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
OptionsMenu::OptionsMenu() {
|
||||
OptionsMenu::OptionsMenu(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
//setup the utility objects
|
||||
image.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp");
|
||||
image.LoadSurface(config["dir.interface"] + "button_menu.bmp");
|
||||
image.SetClipH(image.GetClipH()/3);
|
||||
font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp");
|
||||
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp");
|
||||
|
||||
//pass the utility objects
|
||||
backButton.SetImage(&image);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "image.hpp"
|
||||
#include "raster_font.hpp"
|
||||
#include "button.hpp"
|
||||
@@ -31,7 +32,7 @@
|
||||
class OptionsMenu : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
OptionsMenu();
|
||||
OptionsMenu(ConfigUtility* const);
|
||||
~OptionsMenu();
|
||||
|
||||
protected:
|
||||
@@ -48,6 +49,9 @@ protected:
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//members
|
||||
Image image;
|
||||
RasterFont font;
|
||||
|
||||
@@ -25,8 +25,10 @@
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
SplashScreen::SplashScreen() {
|
||||
logo.LoadSurface("rsc\\graphics\\logos\\krstudios.bmp");
|
||||
SplashScreen::SplashScreen(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
logo.LoadSurface(config["dir.logos"] + "krstudios.bmp");
|
||||
startTick = std::chrono::steady_clock::now();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "image.hpp"
|
||||
|
||||
#include <chrono>
|
||||
@@ -31,7 +32,7 @@
|
||||
class SplashScreen : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
SplashScreen();
|
||||
SplashScreen(ConfigUtility* const);
|
||||
~SplashScreen();
|
||||
|
||||
protected:
|
||||
@@ -39,6 +40,9 @@ protected:
|
||||
void Update(double delta);
|
||||
void Render(SDL_Surface* const);
|
||||
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//members
|
||||
std::chrono::steady_clock::time_point startTick;
|
||||
Image logo;
|
||||
|
||||
@@ -51,10 +51,11 @@ EditorApplication::~EditorApplication() {
|
||||
}
|
||||
|
||||
void EditorApplication::Init() {
|
||||
config.Load("rsc\\config.cfg");
|
||||
if (SDL_Init(SDL_INIT_VIDEO))
|
||||
throw(std::runtime_error("Failed to initialize SDL"));
|
||||
|
||||
BaseScene::SetScreen(800, 600);
|
||||
BaseScene::SetScreen(config.Int("screen.w"), config.Int("screen.h"));
|
||||
}
|
||||
|
||||
void EditorApplication::Proc() {
|
||||
@@ -110,11 +111,11 @@ void EditorApplication::LoadScene(SceneList sceneIndex) {
|
||||
//add scene creation calls here
|
||||
case SceneList::FIRST:
|
||||
case SceneList::EDITORSCENE:
|
||||
activeScene = new EditorScene();
|
||||
activeScene = new EditorScene(&config);
|
||||
break;
|
||||
|
||||
case SceneList::TESTIFICATESCENE:
|
||||
activeScene = new TestificateScene();
|
||||
activeScene = new TestificateScene(&config);
|
||||
break;
|
||||
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "scene_list.hpp"
|
||||
#include "base_scene.hpp"
|
||||
#include "config_utility.hpp"
|
||||
|
||||
class EditorApplication {
|
||||
private:
|
||||
@@ -43,6 +44,9 @@ private:
|
||||
void LoadScene(SceneList sceneIndex);
|
||||
void UnloadScene();
|
||||
|
||||
//globals
|
||||
ConfigUtility config;
|
||||
|
||||
BaseScene* activeScene = nullptr;
|
||||
};
|
||||
|
||||
|
||||
@@ -33,14 +33,16 @@ using namespace std;
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
EditorScene::EditorScene() {
|
||||
EditorScene::EditorScene(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
//create the debugging "window"
|
||||
debugInfo.CreateSurface(256, 256);
|
||||
|
||||
//setup the utility objects
|
||||
font.LoadSurface("rsc\\graphics\\fonts\\pk_white_8.bmp");
|
||||
font.LoadSurface(config["dir.fonts"] + "pk_white_8.bmp");
|
||||
|
||||
buttonImage.LoadSurface("rsc\\graphics\\interface\\button_menu.bmp");
|
||||
buttonImage.LoadSurface(config["dir.interface"] + "button_menu.bmp");
|
||||
buttonImage.SetClipH(buttonImage.GetClipH()/3);
|
||||
|
||||
//setup the menu bar
|
||||
@@ -66,7 +68,7 @@ EditorScene::EditorScene() {
|
||||
pager.SetWidth(32*4);
|
||||
pager.SetHeight(32*4);
|
||||
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\terrain.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "terrain.bmp", 32, 32);
|
||||
}
|
||||
|
||||
EditorScene::~EditorScene() {
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "region_pager.hpp"
|
||||
#include "tile_sheet_manager.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "image.hpp"
|
||||
#include "raster_font.hpp"
|
||||
#include "menu_bar.hpp"
|
||||
@@ -36,7 +37,7 @@
|
||||
class EditorScene : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
EditorScene();
|
||||
EditorScene(ConfigUtility* const);
|
||||
~EditorScene();
|
||||
|
||||
protected:
|
||||
@@ -53,7 +54,8 @@ protected:
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//members
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//debugging tools
|
||||
void DrawToDebugInfo(std::string, int line);
|
||||
|
||||
@@ -30,12 +30,14 @@ using std::endl;
|
||||
//Public access members
|
||||
//-------------------------
|
||||
|
||||
TestificateScene::TestificateScene() {
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\grass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\longgrass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\sand.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\dirt.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet("rsc\\graphics\\tilesets\\water.bmp", 32, 32);
|
||||
TestificateScene::TestificateScene(ConfigUtility* const arg1):
|
||||
config(*arg1)
|
||||
{
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "grass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "longgrass.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "sand.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "dirt.bmp", 32, 32);
|
||||
sheetMgr.LoadSheet(config["dir.tilesets"] + "water.bmp", 32, 32);
|
||||
|
||||
cout << "Range End: " << sheetMgr.GetRangeEnd() << endl;
|
||||
|
||||
|
||||
@@ -24,13 +24,14 @@
|
||||
|
||||
#include "base_scene.hpp"
|
||||
|
||||
#include "config_utility.hpp"
|
||||
#include "tile_Sheet_manager.hpp"
|
||||
#include "region_pager.hpp"
|
||||
|
||||
class TestificateScene : public BaseScene {
|
||||
public:
|
||||
//Public access members
|
||||
TestificateScene();
|
||||
TestificateScene(ConfigUtility* const);
|
||||
~TestificateScene();
|
||||
|
||||
protected:
|
||||
@@ -47,6 +48,9 @@ protected:
|
||||
void KeyDown(SDL_KeyboardEvent const&);
|
||||
void KeyUp(SDL_KeyboardEvent const&);
|
||||
|
||||
//globals
|
||||
ConfigUtility& config;
|
||||
|
||||
//members
|
||||
TileSheetManager sheetMgr;
|
||||
RegionPager pager;
|
||||
|
||||
+7
-7
@@ -3,18 +3,18 @@ server.host = 127.0.0.1
|
||||
server.port = 21795
|
||||
server.name = foobar
|
||||
|
||||
dbname = database.db
|
||||
server.dbname = database.db
|
||||
|
||||
screen.w = 800
|
||||
screen.h = 600
|
||||
screen.f = false
|
||||
|
||||
#directories
|
||||
fonts = rsc/graphics/fonts
|
||||
logos = rsc/graphics/logos
|
||||
sprites = rsc/graphics/sprites
|
||||
tilesets = rsc/graphics/tilesets
|
||||
interface = rsc/graphics/interface
|
||||
scripts = rsc/scripts
|
||||
dir.fonts = rsc/graphics/fonts/
|
||||
dir.logos = rsc/graphics/logos/
|
||||
dir.sprites = rsc/graphics/sprites/
|
||||
dir.tilesets = rsc/graphics/tilesets/
|
||||
dir.interface = rsc/graphics/interface/
|
||||
dir.scripts = rsc/scripts/
|
||||
|
||||
#debugging
|
||||
|
||||
@@ -95,7 +95,7 @@ void ServerApplication::Init(int argc, char** argv) {
|
||||
cout << "initialized SDL_net" << endl;
|
||||
|
||||
//Init SQL
|
||||
string dbname = (config["dbname"].size()) ? config["dbname"] : std::string(argv[0]) + ".db"; //fancy and unnecessary
|
||||
string dbname = (config["server.dbname"].size()) ? config["server.dbname"] : std::string(argv[0]) + ".db"; //fancy and unnecessary
|
||||
int ret = sqlite3_open_v2(dbname.c_str(), &database, SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE|SQLITE_OPEN_FULLMUTEX, nullptr);
|
||||
if (ret != SQLITE_OK || !database) {
|
||||
throw(runtime_error("Failed to open the server database"));
|
||||
|
||||
Reference in New Issue
Block a user