Update of /cvsroot/csp/APPLICATIONS/CSPSim/Source In directory sc8-pr-cvs1:/tmp/cvs-serv32359/Source Modified Files: CSPSim.cpp LogoScreen.cpp Platform.cpp TerrainObject.cpp VirtualBattlefield.cpp main.cpp Log Message: moved hard-coded data paths to ini file Index: CSPSim.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/CSPSim.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CSPSim.cpp 2 Feb 2003 20:53:28 -0000 1.3 --- CSPSim.cpp 16 Feb 2003 09:48:59 -0000 1.4 *************** *** 172,178 **** CSP_LOG(CSP_APP, CSP_INFO, "Starting CSPSim..."); ! std::string archive_file; ! // TODO get the path prefix from config.... ! archive_file = ospath::filter("../Data/Sim.dar"); // open the primary data archive --- 172,177 ---- CSP_LOG(CSP_APP, CSP_INFO, "Starting CSPSim..."); ! std::string data_path = g_Config.getPath("Paths", "DataPath", ".", true); ! std::string archive_file = ospath::join(data_path, "Sim.dar"); // open the primary data archive *************** *** 575,581 **** Con_rect.w = Con_rect.h = 300; ! m_ConsoleFont = DT_LoadFont("../Data/Fonts/ConsoleFont.bmp", 0); ! m_pConsole = CON_Init("../Data/Fonts/ConsoleFont.bmp", m_SDLScreen, 100, Con_rect); CON_Alpha(m_pConsole, 50); --- 574,582 ---- Con_rect.w = Con_rect.h = 300; ! std::string font_path = g_Config.getPath("Paths", "FontPath", ".", true); ! std::string console_font = ospath::join(font_path, "ConsoleFont.bmp"); ! m_ConsoleFont = DT_LoadFont(console_font.c_str(), 0); ! m_pConsole = CON_Init(console_font.c_str(), m_SDLScreen, 100, Con_rect); CON_Alpha(m_pConsole, 50); Index: LogoScreen.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/LogoScreen.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** LogoScreen.cpp 2 Feb 2003 20:53:28 -0000 1.3 --- LogoScreen.cpp 16 Feb 2003 09:48:59 -0000 1.4 *************** *** 54,65 **** void LogoScreen::OnInit() { ! std::string path = ospath::filter("../Data/Images/CSPLogo.bmp"); ! m_image = SDL_LoadBMP(path.c_str()); ! if (m_image == NULL) ! { std::cout << "Unable to load bitmap " << path << std::endl; ! } ! ! } --- 54,64 ---- void LogoScreen::OnInit() { ! std::string image_path = g_Config.getPath("Paths", "ImagePath", ".", true); ! std::string path = ospath.join(image_path, "CSPLogo.bmp"); ! m_image = SDL_LoadBMP(path.c_str()); ! if (m_image == NULL) ! { std::cout << "Unable to load bitmap " << path << std::endl; ! } } Index: Platform.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/Platform.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Platform.cpp 26 Jan 2003 23:33:38 -0000 1.2 --- Platform.cpp 16 Feb 2003 09:48:59 -0000 1.3 *************** *** 53,56 **** --- 53,65 ---- #endif + #ifdef _WIN32 + const char ospath::DIR_SEPARATOR = '\\'; + const char ospath::PATH_SEPARATOR = ';'; + #else + const char ospath::DIR_SEPARATOR = '/'; + const char ospath::PATH_SEPARATOR = ':'; + #endif + + std::string ospath::basename(const std::string &path) { *************** *** 147,150 **** --- 156,165 ---- free(str); return result; + } + + std::string const &ospath::addpath(std::string &pathlist, const std::string &path) { + if (pathlist.size() > 0) pathlist = pathlist + PATH_SEPARATOR; + pathlist = pathlist + path; + return pathlist; } Index: TerrainObject.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/TerrainObject.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** TerrainObject.cpp 2 Feb 2003 20:53:28 -0000 1.3 --- TerrainObject.cpp 16 Feb 2003 09:48:59 -0000 1.4 *************** *** 144,151 **** void TerrainObject::load() { if (m_Loaded) return; if (m_Lattice) { // create lattice ! Demeter::Settings::GetInstance()->SetMediaPath("../Data/Terrain"); createTerrainLattice(); m_TerrainNode = createTerrainLatticeNode(m_pTerrainLattice); --- 144,152 ---- void TerrainObject::load() { if (m_Loaded) return; + std::string terrain_path = g_Config.getPath("Paths", "TerrainPath", ".", true); if (m_Lattice) { // create lattice ! Demeter::Settings::GetInstance()->SetMediaPath(terrain_path.c_str()); createTerrainLattice(); m_TerrainNode = createTerrainLatticeNode(m_pTerrainLattice); *************** *** 157,161 **** { // create single terrain node ! Demeter::Settings::GetInstance()->SetMediaPath("../Data/Terrain"); createTerrain(); m_TerrainNode = createTerrainNode(m_pTerrain); --- 158,162 ---- { // create single terrain node ! Demeter::Settings::GetInstance()->SetMediaPath(terrain_path.c_str()); createTerrain(); m_TerrainNode = createTerrainNode(m_pTerrain); *************** *** 391,396 **** void TerrainObject::updateDemeterSettings() { ! std::string mediaPath = ospath::filter("../Data/Terrain/"); ! Demeter::Settings::GetInstance()->SetMediaPath(mediaPath.c_str()); Demeter::Settings::GetInstance()->SetVerbose(false); Demeter::Settings::GetInstance()->SetScreenWidth(g_ScreenWidth); --- 392,397 ---- void TerrainObject::updateDemeterSettings() { ! std::string terrain_path = g_Config.getPath("Paths", "TerrainPath", ".", true); ! Demeter::Settings::GetInstance()->SetMediaPath(terrain_path.c_str()); Demeter::Settings::GetInstance()->SetVerbose(false); Demeter::Settings::GetInstance()->SetScreenWidth(g_ScreenWidth); Index: VirtualBattlefield.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/VirtualBattlefield.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VirtualBattlefield.cpp 2 Feb 2003 20:53:29 -0000 1.3 --- VirtualBattlefield.cpp 16 Feb 2003 09:48:59 -0000 1.4 *************** *** 36,39 **** --- 36,40 ---- #include "LogStream.h" #include "VirtualBattlefield.h" + #include "Platform.h" #include <SimData/Types.h> *************** *** 255,259 **** #endif ! osgDB::setDataFilePathList("../Data" + sep + "../Data/Images" + sep + "../Data/Models" + sep + "../Data/Fonts"); // we don't need this on Linux since libs are usually --- 256,267 ---- #endif ! std::string image_path = g_Config.getPath("Paths", "ImagePath", ".", true); ! std::string model_path = g_Config.getPath("Paths", "ModelPath", ".", true); ! std::string font_path = g_Config.getPath("Paths", "FontPath", ".", true); ! std::string search_path; ! ospath::addpath(search_path, image_path); ! ospath::addpath(search_path, model_path); ! ospath::addpath(search_path, font_path); ! osgDB::setDataFilePathList(searchpath); // we don't need this on Linux since libs are usually Index: main.cpp =================================================================== RCS file: /cvsroot/csp/APPLICATIONS/CSPSim/Source/main.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.cpp 2 Feb 2003 20:53:30 -0000 1.3 --- main.cpp 16 Feb 2003 09:48:59 -0000 1.4 *************** *** 5,9 **** int main(int argc, char *argv[]) { ! if (!openConfig("../Data/CSPSim.ini")) return 0; CSPSim app; --- 5,9 ---- int main(int argc, char *argv[]) { ! if (!openConfig("CSPSim.ini")) return 0; CSPSim app; |