Author: enetheru Date: Sun Jun 7 13:48:46 2009 New Revision: 347 Log: paths for menu now are relocatable, at the moment the data path is specified in the config file but thi config file is arbitrary so its a bit self defeatist at the moment. we need to find a mechanism to search some paths for the config file and then load it Modified: trunk/data/pvn.conf trunk/src/game.cpp trunk/src/game.h trunk/src/menu.cpp trunk/src/settings.cpp trunk/src/settings.h Modified: trunk/data/pvn.conf ============================================================================== --- trunk/data/pvn.conf Sun Jun 7 13:00:09 2009 (r346) +++ trunk/data/pvn.conf Sun Jun 7 13:48:46 2009 (r347) @@ -1 +1,2 @@ fullscreen N +datapath=../data/ Modified: trunk/src/game.cpp ============================================================================== --- trunk/src/game.cpp Sun Jun 7 13:00:09 2009 (r346) +++ trunk/src/game.cpp Sun Jun 7 13:48:46 2009 (r347) @@ -19,6 +19,7 @@ screen_bpp(0) { settings.Get("../data/pvn.conf"); + datapath = settings.datapath; //console stuff verbose = settings.console; Modified: trunk/src/game.h ============================================================================== --- trunk/src/game.h Sun Jun 7 13:00:09 2009 (r346) +++ trunk/src/game.h Sun Jun 7 13:48:46 2009 (r347) @@ -25,6 +25,8 @@ SDL_Surface *screen_surface; SDL_Rect screen_rect; + string datapath; + bool verbose; //Time stuffs Modified: trunk/src/menu.cpp ============================================================================== --- trunk/src/menu.cpp Sun Jun 7 13:00:09 2009 (r346) +++ trunk/src/menu.cpp Sun Jun 7 13:48:46 2009 (r347) @@ -8,7 +8,7 @@ PVN_menu::PVN_menu(PVN_game* game) : PVN_state(game) { /* Load the music file */ - menu_music = Mix_LoadMUS("../data/music/menu.ogg"); + menu_music = Mix_LoadMUS((game->datapath + "music/menu.ogg").c_str()); #if DEBUG > 0 if( menu_music == NULL ) { @@ -17,7 +17,7 @@ #endif /* load sound effects */ - menu_effect[0] = Mix_LoadWAV("../data/effects/yarr.ogg"); + menu_effect[0] = Mix_LoadWAV((game->datapath + "effects/yarr.ogg").c_str()); #if DEBUG > 0 if( menu_effect[0] == NULL ) { @@ -25,7 +25,7 @@ } #endif - menu_effect[1] = Mix_LoadWAV("../data/effects/pizza.ogg"); + menu_effect[1] = Mix_LoadWAV((game->datapath + "effects/pizza.ogg").c_str()); #if DEBUG > 0 if( menu_effect[1] == NULL ) { @@ -33,7 +33,7 @@ } #endif - menu_effect[2] = Mix_LoadWAV("../data/effects/laugh.ogg"); + menu_effect[2] = Mix_LoadWAV((game->datapath + "effects/laugh.ogg").c_str()); #if DEBUG > 0 if( menu_effect[2] == NULL ) { @@ -41,7 +41,7 @@ } #endif - menu_effect[3] = Mix_LoadWAV("../data/effects/bling.ogg"); + menu_effect[3] = Mix_LoadWAV((game->datapath + "effects/bling.ogg").c_str()); #if DEBUG > 0 if( menu_effect[3] == NULL ) { @@ -51,28 +51,28 @@ /* load Graphics */ resources[MENU_BACKGROUND] = new PVN_simple( - Image_Load("../data/images/background.png"), + Image_Load(game->datapath + "images/background.png"), 0, 0, 800, 600, 0, 0 ); resources[MENU_TITLE] = new PVN_simple( - Image_Load("../data/images/title.png"), + Image_Load(game->datapath + "images/title.png"), 0, 0, 800, 200, 0, 0 ); resources[MENU_K_GO_UP] = new PVN_simple( - Image_Load("../data/images/k_go_up.png"), + Image_Load(game->datapath + "images/k_go_up.png"), 0, 0, 400, 50, 200, 450 ); resources[MENU_K_GO_DOWN] = new PVN_simple( - Image_Load("../data/images/k_go_down.png"), + Image_Load(game->datapath + "images/k_go_down.png"), 0, 0, 400, 50, 200, 450 @@ -80,7 +80,7 @@ changing[2] = resources[MENU_K_GO_DOWN]; resources[MENU_CREDITS_UP] = new PVN_simple( - Image_Load("../data/images/respect_up.png"), + Image_Load(game->datapath + "images/respect_up.png"), 0, 0, 400, 50, 200, 500 @@ -88,28 +88,28 @@ changing[3] = resources[MENU_CREDITS_UP]; resources[MENU_CREDITS_DOWN] = new PVN_simple( - Image_Load("../data/images/respect_down.png"), + Image_Load(game->datapath + "images/respect_down.png"), 0, 0, 400, 50, 200, 500 ); resources[MENU_SWITCH] = new PVN_simple( - Image_Load("../data/images/switch.png"), + Image_Load(game->datapath + "images/switch.png"), 0, 0, 256, 256, 0, 0 ); resources[MENU_PIRATE_LEFT] = new PVN_simple( - Image_Load("../data/images/pirate_left.png"), + Image_Load(game->datapath + "images/pirate_left.png"), 0, 0, 256, 256, 494, 200 ); resources[MENU_PIRATE_RIGHT] = new PVN_simple( - Image_Load("../data/images/pirate_right.png"), + Image_Load(game->datapath + "images/pirate_right.png"), 0, 0, 256, 256, 50, 200 @@ -117,7 +117,7 @@ changing[0] = resources[MENU_PIRATE_RIGHT]; resources[MENU_NINJA_LEFT] = new PVN_simple( - Image_Load("../data/images/ninja_left.png"), + Image_Load(game->datapath + "images/ninja_left.png"), 0, 0, 256, 256, 494, 200 @@ -125,7 +125,7 @@ changing[1] = resources[MENU_NINJA_LEFT]; resources[MENU_NINJA_RIGHT] = new PVN_simple( - Image_Load("../data/images/ninja_right.png"), + Image_Load(game->datapath + "images/ninja_right.png"), 0, 0, 256, 256, 50, 200 Modified: trunk/src/settings.cpp ============================================================================== --- trunk/src/settings.cpp Sun Jun 7 13:00:09 2009 (r346) +++ trunk/src/settings.cpp Sun Jun 7 13:48:46 2009 (r347) @@ -32,6 +32,10 @@ if( !value.compare("Y") ) console = true; else console = false; } + else if( line.find("datapath") != string::npos ) + { + datapath = line.substr(9, line.npos); + } } myfile.close(); } Modified: trunk/src/settings.h ============================================================================== --- trunk/src/settings.h Sun Jun 7 13:00:09 2009 (r346) +++ trunk/src/settings.h Sun Jun 7 13:48:46 2009 (r347) @@ -1,12 +1,15 @@ #ifndef PVN_SETTINGS_H #define PVN_SETTINGS_H +#include "common.h" + struct PVN_settings { bool fullscreen; bool console; - bool player1; /* true = ninja */ + bool player1; /* true = ninja */ bool player2; /* false = pirate */ + string datapath; bool Get(const char*); };