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