bool CProject::Open(const char* filename) { Destroy(); // set the game directory m_Directory = filename; if (m_Directory.rfind('\\') != std::string::npos) m_Directory[m_Directory.rfind('\\')] = 0; // set the game filename m_Filename = filename; if (1) { char directory[MAX_PATH]; GetCurrentDirectory(MAX_PATH, directory); if (SetCurrentDirectory(m_Directory.c_str()) == 0) return false; FILE* file = fopen(m_Filename.c_str(), "a"); if (!file) return false; fclose(file); SetCurrentDirectory(directory); } // load the game.sgm CConfigFile config; if (!config.Load(m_Filename.c_str())) return false; m_GameTitle = config.ReadString("", "name", "Untitled"); m_Author = config.ReadString("", "author", "Unknown"); m_Description = config.ReadString("", "description", ""); m_GameScript = config.ReadString("", "script", ""); // screen dimensions m_ScreenWidth = config.ReadInt("", "screen_width", 320); m_ScreenHeight = config.ReadInt("", "screen_height", 240); RefreshItems(); return true; }
void LoadConfiguration(std::string sphere_dir) { CConfigFile file; file.Load((sphere_dir + "/system/video/sdl32.cfg").c_str()); Config.fullscreen = file.ReadBool("sdl32", "Fullscreen", false); Config.vsync = file.ReadBool("sdl32", "VSync", false); Config.scale = file.ReadBool("sdl32", "Scale", false); Config.filter = file.ReadInt ("sdl32", "Filter", 0); int vexpand = file.ReadInt ("sdl32", "VExpand", 0); int hexpand = file.ReadInt ("sdl32", "HExpand", 0); if (vexpand < 0 || vexpand > 1024) vexpand = 0; if (hexpand < 0 || hexpand > 1024) hexpand = 0; Config.border.top = (int)(vexpand / 2); Config.border.bottom = (int)(vexpand / 2) + (vexpand % 2); Config.border.left = (int)(hexpand / 2); Config.border.right = (int)(hexpand / 2) + (hexpand % 2); }