HiScore::HiScore(Resources *rsc): _rsc(rsc), _scores(NumScores), _lastSet(NumScores) //invalid pos { const std::string hiscoreDir = getPath(FolderConf); #ifndef GEKKO ensureFolder(hiscoreDir); #endif _hiscoreFile = hiscoreDir + hiscoreFName; std::ifstream fsScore(_hiscoreFile.c_str()); if (fsScore.fail()) //if it doesn't exist { populateEmptyFile(); fsScore.close(); fsScore.open(_hiscoreFile.c_str()); } //extract version int tmp; fsScore >> tmp; assert (tmp == hiscoreVersion); if (tmp == hiscoreVersion) { //check number of scores fsScore >> tmp; assert (tmp == NumScores); for (int i = 0; i < NumScores; ++i) fsScore >> _scores[i]; }
void GameStateStory::loadStoriesMenu(const char * root) { SAFE_DELETE(menu); stories.clear(); vector<string>subFolders = JFileSystem::GetInstance()->scanfolder(root); for (size_t i = 0; i < subFolders.size(); ++i) { string subfolder = ensureFolder(subFolders[i]); string filename = root + subfolder + "story.xml"; if (FileExists(filename)) { subfolder.resize(subfolder.length() - 1); //remove trailing slash stories.push_back(subfolder); } } switch (stories.size()) { case 0: mParent->DoTransition(TRANSITION_FADE, GAME_STATE_MENU); break; case 1: flow = NEW StoryFlow(stories[0]); break; default: menu = NEW SimpleMenu(JGE::GetInstance(), WResourceManager::Instance(), 103, this, Fonts::MENU_FONT, 150, 60); for (size_t i = 0; i < stories.size(); ++i) { menu->Add(i, stories[i].c_str()); } menu->Add(kCancelMenuID, "Cancel"); } }
static std::string getLogFolderPath(bool folder_timestamp) { std::string logfolder = folder_timestamp ? Utils::to_string(Utils::now()) : ""; std::string fullPath = combine(getAppDataFolder(), logfolder); ensureFolder(fullPath); return fullPath; }
static std::string getLogFileNamePath(const std::string& fullPath, const std::string& prefix, const std::string& suffix, const std::string& extension, bool file_timestamp) { //TODO: because this bug we are using alternative code with stringstream //https://answers.unrealengine.com/questions/664905/unreal-crashes-on-two-lines-of-extremely-simple-st.html std::string filename; filename.append(ensureFolder(fullPath)) .push_back(kPathSeparator); filename.append(prefix) .append(suffix) .append(file_timestamp ? Utils::to_string(Utils::now()) : "") .append(extension); return filename; //std::stringstream filename_ss; //filename_ss << ensureFolder(fullPath) << kPathSeparator << prefix << suffix << timestamp << extension; //return filename_ss.str(); }
static std::string getLogFileNamePath(std::string prefix, std::string suffix, std::string extension, bool add_timestamp) { std::string logfolder = Utils::to_string(Utils::now(), "%Y-%m-%d"); std::string fullPath = combine(getAppDataFolder(), logfolder); std::string timestamp = add_timestamp ? Utils::to_string(Utils::now()) : ""; //TODO: because this bug we are using alternative code with stringstream //https://answers.unrealengine.com/questions/664905/unreal-crashes-on-two-lines-of-extremely-simple-st.html std::string filename; filename.append(ensureFolder(fullPath)) .push_back(kPathSeparator); filename.append(prefix) .append(suffix) .append(timestamp) .append(extension); return filename; //std::stringstream filename_ss; //filename_ss << ensureFolder(fullPath) << kPathSeparator << prefix << suffix << timestamp << extension; //return filename_ss.str(); }
static std::string getAppDataFolder() { return ensureFolder(combine(getUserDocumentsFolder(), ProductFolderName)); }