void CScreenIO::IOReadName() { CWindow* pw; CEdit* pe; std::string resume; char line[100]; char name[100]; time_t now; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == nullptr ) return; pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_IONAME)); if ( pe == nullptr ) return; resume = GetLevelCategoryDir(m_main->GetLevelCategory()) + " " + StrUtils::ToString<int>(m_main->GetLevelChap()); CLevelParser levelParser(m_main->GetLevelCategory(), m_main->GetLevelChap(), 0); try { levelParser.Load(); resume = levelParser.Get("Title")->GetParam("resume")->AsString(); } catch (CLevelParserException& e) { GetLogger()->Warn("%s\n", e.what()); } time(&now); TimeToAsciiClean(now, line); sprintf(name, "%s - %s %d", line, resume.c_str(), m_main->GetLevelRank()); pe->SetText(name); pe->SetCursor(strlen(name), 0); m_interface->SetFocus(pe); }
void CScreenLevelList::UpdateSceneResume(int chap, int rank) { CWindow* pw; CEdit* pe; CCheck* pc; std::string fileName; int numTry; bool bPassed, bVisible; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == nullptr ) return; pe = static_cast<CEdit*>(pw->SearchControl(EVENT_INTERFACE_RESUME)); if ( pe == nullptr ) return; pc = static_cast<CCheck*>(pw->SearchControl(EVENT_INTERFACE_SOLUCE)); if ( pc == nullptr ) { m_sceneSoluce = false; } else { numTry = m_main->GetPlayerProfile()->GetLevelTryCount(m_category, chap, rank); bPassed = m_main->GetPlayerProfile()->GetLevelPassed(m_category, chap, rank); bVisible = ( numTry > 2 || bPassed || m_main->GetShowSoluce() ); if ( !CSettings::GetInstancePointer()->GetSoluce4() ) bVisible = false; pc->SetState(STATE_VISIBLE, bVisible); if ( !bVisible ) { pc->ClearState(STATE_CHECK); m_sceneSoluce = false; } } if(chap == 0 || rank == 0) return; try { CLevelParser levelParser(m_category, chap, rank); levelParser.Load(); pe->SetText(levelParser.Get("Resume")->GetParam("text")->AsString().c_str()); } catch (CLevelParserException& e) { pe->SetText((std::string("[ERROR]: ")+e.what()).c_str()); } }
void CScreenLevelList::UpdateSceneList(int chap, int &sel) { CWindow* pw; CList* pl; std::string fileName; char line[500] = {0}; int j; bool bPassed; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == nullptr ) return; pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_LIST)); if ( pl == nullptr ) return; pl->Flush(); bool readAll = true; for ( j=0 ; j<MAXSCENE ; j++ ) { CLevelParser levelParser(m_category, chap+1, j+1); if (!levelParser.Exists()) { readAll = true; break; } else { if (!readAll) break; } try { levelParser.Load(); sprintf(line, "%d: %s", j+1, levelParser.Get("Title")->GetParam("text")->AsString().c_str()); } catch (CLevelParserException& e) { sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str()); } bPassed = m_main->GetPlayerProfile()->GetLevelPassed(m_category, chap+1, j+1); pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); if ( m_category == LevelCategory::Missions && !m_main->GetShowAll() && !bPassed ) { readAll = false; } } if (readAll) { m_maxList = j; } else { m_maxList = j+1; // this is not the last! } if ( sel > j-1 ) sel = j-1; pl->SetSelect(sel); pl->ShowSelect(false); // shows the selected columns }
void CScreenLevelList::UpdateSceneChap(int &chap) { CWindow* pw; CList* pl; std::string fileName; char line[500] = {0}; bool bPassed; pw = static_cast<CWindow*>(m_interface->SearchControl(EVENT_WINDOW5)); if ( pw == nullptr ) return; pl = static_cast<CList*>(pw->SearchControl(EVENT_INTERFACE_CHAP)); if ( pl == nullptr ) return; pl->Flush(); int j; if ( m_category == LevelCategory::CustomLevels ) { UpdateCustomLevelList(); for ( j=0 ; j < static_cast<int>(m_customLevelList.size()) ; j++ ) { try { CLevelParser levelParser("custom", j+1, 0); levelParser.Load(); pl->SetItemName(j, levelParser.Get("Title")->GetParam("text")->AsString()); pl->SetEnable(j, true); } catch (CLevelParserException& e) { pl->SetItemName(j, std::string("[ERROR]: ")+e.what()); pl->SetEnable(j, false); } } } else { for ( j=0 ; j<MAXSCENE ; j++ ) { CLevelParser levelParser(m_category, j+1, 0); if (!levelParser.Exists()) break; try { levelParser.Load(); sprintf(line, "%d: %s", j+1, levelParser.Get("Title")->GetParam("text")->AsString().c_str()); } catch (CLevelParserException& e) { sprintf(line, "%s", (std::string("[ERROR]: ")+e.what()).c_str()); } bPassed = m_main->GetPlayerProfile()->GetLevelPassed(m_category, j+1, 0); pl->SetItemName(j, line); pl->SetCheck(j, bPassed); pl->SetEnable(j, true); if ( m_category == LevelCategory::Missions && !m_main->GetShowAll() && !bPassed ) { j ++; break; } if ( m_category == LevelCategory::FreeGame && j == m_accessChap ) { j ++; break; } } } if ( chap > j-1 ) chap = j-1; pl->SetSelect(chap); pl->ShowSelect(false); // shows the selected columns }