OpenClonk
C4ScenarioListLoader Class Reference

#include <C4StartupScenSelDlg.h>

Classes

class  Entry
 
class  Folder
 
class  RegularFolder
 
class  Scenario
 
class  SubFolder
 

Public Member Functions

 C4ScenarioListLoader (const C4ScenarioParameters &Achievements)
 
 ~C4ScenarioListLoader ()
 
bool DoProcessCallback (int32_t iProgress, int32_t iMaxProgress, const char *current_load_info)
 
bool Load (const StdStrBuf &sRootFolder)
 
bool Load (Folder *pSpecifiedFolder, bool fReload)
 
bool LoadExtended (Entry *pEntry)
 
bool FolderBack ()
 
bool ReloadCurrent ()
 
bool IsLoading () const
 
EntryGetFirstEntry () const
 
FolderGetCurrFolder () const
 
FolderGetRootFolder () const
 
int32_t GetProgress () const
 
int32_t GetMaxProgress () const
 
int32_t GetProgressPercent () const
 
const char * GetProgressInfo () const
 
const C4ScenarioParametersGetAchievements () const
 

Detailed Description

Definition at line 42 of file C4StartupScenSelDlg.h.

Constructor & Destructor Documentation

◆ C4ScenarioListLoader()

C4ScenarioListLoader::C4ScenarioListLoader ( const C4ScenarioParameters Achievements)

Definition at line 1173 of file C4StartupScenSelDlg.cpp.

1173  : Achievements(Achievements), pRootFolder(nullptr), pCurrFolder(nullptr),
1174  iLoading(0), iProgress(0), iMaxProgress(0), fAbortThis(false), fAbortPrevious(false)
1175 {
1176 }

◆ ~C4ScenarioListLoader()

C4ScenarioListLoader::~C4ScenarioListLoader ( )

Definition at line 1178 of file C4StartupScenSelDlg.cpp.

References StdStrBuf::Clear().

1179 {
1180  if (pRootFolder) delete pRootFolder;
1181 }
Here is the call graph for this function:

Member Function Documentation

◆ DoProcessCallback()

bool C4ScenarioListLoader::DoProcessCallback ( int32_t  iProgress,
int32_t  iMaxProgress,
const char *  current_load_info 
)

Definition at line 1215 of file C4StartupScenSelDlg.cpp.

References Application, C4GUI::Dialog::IsShown(), C4StartupScenSelDlg::ProcessCallback(), and StdScheduler::ScheduleProcs().

Referenced by C4ScenarioListLoader::SubFolder::DoLoadContents(), and C4ScenarioListLoader::RegularFolder::DoLoadContents().

1216 {
1217  this->iProgress = iProgress;
1218  this->iMaxProgress = iMaxProgress;
1219  this->current_load_info.Copy(current_load_info);
1220  // callback to dialog
1222  // process callback - abort at a few ugly circumstances...
1223  // schedule with 1ms delay to force event processing
1224  // (delay 0 would be nice, but isn't supported properly by our Windows implementation of ScheduleProcs)
1225  if (!Application.ScheduleProcs(1) // WM_QUIT message?
1226  || !C4StartupScenSelDlg::pInstance // host dialog removed?
1227  || !C4StartupScenSelDlg::pInstance->IsShown() // host dialog closed?
1228  ) return false;
1229  // and also abort if flagged
1230  return !fAbortThis;
1231 }
bool IsShown()
Definition: C4Gui.h:2147
bool ScheduleProcs(int iTimeout=1000/36)
void Copy()
Definition: StdBuf.h:467
C4Application Application
Definition: C4Globals.cpp:44
static C4StartupScenSelDlg * pInstance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FolderBack()

bool C4ScenarioListLoader::FolderBack ( )

Definition at line 1271 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Entry::GetParent(), and Load().

Referenced by C4StartupScenSelDlg::DoBack().

1272 {
1273  // call safety
1274  if (!pRootFolder || !pCurrFolder) return false;
1275  // already in root: Can't go up
1276  if (pCurrFolder == pRootFolder) return false;
1277  // otherwise, up one level
1278  return Load(pCurrFolder->GetParent(), false);
1279 }
class Folder * GetParent() const
bool Load(const StdStrBuf &sRootFolder)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetAchievements()

const C4ScenarioParameters& C4ScenarioListLoader::GetAchievements ( ) const
inline

Definition at line 268 of file C4StartupScenSelDlg.h.

Referenced by C4ScenarioListLoader::Scenario::LoadCustomPre().

268 { return Achievements; }
Here is the caller graph for this function:

◆ GetCurrFolder()

Folder* C4ScenarioListLoader::GetCurrFolder ( ) const
inline

Definition at line 260 of file C4StartupScenSelDlg.h.

Referenced by C4StartupScenSelDlg::OnClosed().

260 { return pCurrFolder; }
Here is the caller graph for this function:

◆ GetFirstEntry()

Entry* C4ScenarioListLoader::GetFirstEntry ( ) const
inline

Definition at line 258 of file C4StartupScenSelDlg.h.

References C4ScenarioListLoader::Folder::GetFirstEntry().

Referenced by C4StartupScenSelDlg::OnClosed().

258 { return pCurrFolder ? pCurrFolder->GetFirstEntry() : nullptr; }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMaxProgress()

int32_t C4ScenarioListLoader::GetMaxProgress ( ) const
inline

Definition at line 264 of file C4StartupScenSelDlg.h.

264 { return iMaxProgress; }

◆ GetProgress()

int32_t C4ScenarioListLoader::GetProgress ( ) const
inline

Definition at line 263 of file C4StartupScenSelDlg.h.

263 { return iProgress; }

◆ GetProgressInfo()

const char* C4ScenarioListLoader::GetProgressInfo ( ) const
inline

Definition at line 266 of file C4StartupScenSelDlg.h.

References StdStrBuf::getData().

Referenced by C4StartupScenSelDlg::OnClosed().

266 { return current_load_info.getData(); }
const char * getData() const
Definition: StdBuf.h:442
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetProgressPercent()

int32_t C4ScenarioListLoader::GetProgressPercent ( ) const
inline

Definition at line 265 of file C4StartupScenSelDlg.h.

Referenced by C4StartupScenSelDlg::OnClosed().

265 { return iProgress * 100 / std::max<int32_t>(iMaxProgress, 1); }
Here is the caller graph for this function:

◆ GetRootFolder()

Folder* C4ScenarioListLoader::GetRootFolder ( ) const
inline

Definition at line 261 of file C4StartupScenSelDlg.h.

Referenced by C4StartupScenSelDlg::OnClosed().

261 { return pRootFolder; }
Here is the caller graph for this function:

◆ IsLoading()

bool C4ScenarioListLoader::IsLoading ( ) const
inline

Definition at line 257 of file C4StartupScenSelDlg.h.

Referenced by C4StartupScenSelDlg::DoBack(), C4StartupScenSelDlg::DoRefresh(), and C4StartupScenSelDlg::OnClosed().

257 { return !!iLoading; }
Here is the caller graph for this function:

◆ Load() [1/2]

bool C4ScenarioListLoader::Load ( const StdStrBuf sRootFolder)

Definition at line 1233 of file C4StartupScenSelDlg.cpp.

References StdStrBuf::getData(), C4ScenarioListLoader::Folder::LoadContents(), C4ScenarioListLoader::RegularFolder::Merge(), and Reloc.

Referenced by FolderBack(), C4StartupScenSelDlg::OnShown(), C4StartupScenSelDlg::OpenFolder(), and ReloadCurrent().

1234 {
1235  // (unthreaded) loading of all entries in root folder
1236  if (!BeginActivity(true)) return false;
1237  if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; }
1238  pCurrFolder = pRootFolder = new RegularFolder(this, nullptr);
1239  // Load regular game data if no explicit path specified
1240  if(!sRootFolder.getData())
1241  for(const auto & iter : Reloc)
1242  pRootFolder->Merge(iter.strBuf.getData());
1243  bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false);
1244  EndActivity();
1245  return fSuccess;
1246 }
const char * getData() const
Definition: StdBuf.h:442
C4Reloc Reloc
Definition: C4Reloc.cpp:21
bool LoadContents(C4ScenarioListLoader *pLoader, C4Group *pFromGrp, const StdStrBuf *psFilename, bool fLoadEx, bool fReload)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Load() [2/2]

bool C4ScenarioListLoader::Load ( Folder pSpecifiedFolder,
bool  fReload 
)

Definition at line 1248 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Folder::LoadContents().

1249 {
1250  // call safety
1251  if (!pRootFolder || !pSpecifiedFolder) return false;
1252  // set new current and load it
1253  if (!BeginActivity(true)) return false;
1254  pCurrFolder = pSpecifiedFolder;
1255  bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload);
1256  EndActivity();
1257  return fSuccess;
1258 }
bool LoadContents(C4ScenarioListLoader *pLoader, C4Group *pFromGrp, const StdStrBuf *psFilename, bool fLoadEx, bool fReload)
Here is the call graph for this function:

◆ LoadExtended()

bool C4ScenarioListLoader::LoadExtended ( Entry pEntry)

Definition at line 1260 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Entry::Load().

Referenced by C4StartupScenSelDlg::OnClosed().

1261 {
1262  // call safety
1263  if (!pRootFolder || !pEntry) return false;
1264  // load info of selection
1265  if (!BeginActivity(false)) return false;
1266  bool fSuccess = pEntry->Load(nullptr, nullptr, true);
1267  EndActivity();
1268  return fSuccess;
1269 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReloadCurrent()

bool C4ScenarioListLoader::ReloadCurrent ( )

Definition at line 1281 of file C4StartupScenSelDlg.cpp.

References Load().

Referenced by C4StartupScenSelDlg::DoRefresh().

1282 {
1283  // call safety
1284  if (!pRootFolder || !pCurrFolder) return false;
1285  // reload current
1286  return Load(pCurrFolder, true);
1287 }
bool Load(const StdStrBuf &sRootFolder)
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following files: