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 1178 of file C4StartupScenSelDlg.cpp.

1178  : Achievements(Achievements), pRootFolder(nullptr), pCurrFolder(nullptr),
1179  iLoading(0), iProgress(0), iMaxProgress(0), fAbortThis(false), fAbortPrevious(false)
1180 {
1181 }

◆ ~C4ScenarioListLoader()

C4ScenarioListLoader::~C4ScenarioListLoader ( )

Definition at line 1183 of file C4StartupScenSelDlg.cpp.

1184 {
1185  if (pRootFolder) delete pRootFolder;
1186 }

Member Function Documentation

◆ DoProcessCallback()

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

Definition at line 1220 of file C4StartupScenSelDlg.cpp.

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

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FolderBack()

bool C4ScenarioListLoader::FolderBack ( )

Definition at line 1276 of file C4StartupScenSelDlg.cpp.

1277 {
1278  // call safety
1279  if (!pRootFolder || !pCurrFolder) return false;
1280  // already in root: Can't go up
1281  if (pCurrFolder == pRootFolder) return false;
1282  // otherwise, up one level
1283  return Load(pCurrFolder->GetParent(), false);
1284 }
class Folder * GetParent() const
bool Load(const StdStrBuf &sRootFolder)

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

Referenced by C4StartupScenSelDlg::DoBack().

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.

268 { return Achievements; }

◆ GetCurrFolder()

Folder* C4ScenarioListLoader::GetCurrFolder ( ) const
inline

Definition at line 260 of file C4StartupScenSelDlg.h.

260 { return pCurrFolder; }

◆ GetFirstEntry()

Entry* C4ScenarioListLoader::GetFirstEntry ( ) const
inline

Definition at line 258 of file C4StartupScenSelDlg.h.

258 { return pCurrFolder ? pCurrFolder->GetFirstEntry() : nullptr; }

References C4ScenarioListLoader::Folder::GetFirstEntry().

Here is the call 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.

266 { return current_load_info.getData(); }
const char * getData() const
Definition: StdBuf.h:442

References StdStrBuf::getData().

Here is the call graph for this function:

◆ GetProgressPercent()

int32_t C4ScenarioListLoader::GetProgressPercent ( ) const
inline

Definition at line 265 of file C4StartupScenSelDlg.h.

265 { return iProgress * 100 / std::max<int32_t>(iMaxProgress, 1); }

◆ GetRootFolder()

Folder* C4ScenarioListLoader::GetRootFolder ( ) const
inline

Definition at line 261 of file C4StartupScenSelDlg.h.

261 { return pRootFolder; }

◆ IsLoading()

bool C4ScenarioListLoader::IsLoading ( ) const
inline

Definition at line 257 of file C4StartupScenSelDlg.h.

257 { return !!iLoading; }

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

Here is the caller graph for this function:

◆ Load() [1/2]

bool C4ScenarioListLoader::Load ( const StdStrBuf sRootFolder)

Definition at line 1238 of file C4StartupScenSelDlg.cpp.

1239 {
1240  // (unthreaded) loading of all entries in root folder
1241  if (!BeginActivity(true)) return false;
1242  if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; }
1243  pCurrFolder = pRootFolder = new RegularFolder(this, nullptr);
1244  // Load regular game data if no explicit path specified
1245  if(!sRootFolder.getData())
1246  for(const auto & iter : Reloc)
1247  pRootFolder->Merge(iter.strBuf.getData());
1248  bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false);
1249  EndActivity();
1250  return fSuccess;
1251 }
C4Reloc Reloc
Definition: C4Reloc.cpp:21
bool LoadContents(C4ScenarioListLoader *pLoader, C4Group *pFromGrp, const StdStrBuf *psFilename, bool fLoadEx, bool fReload)

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

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

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 1253 of file C4StartupScenSelDlg.cpp.

1254 {
1255  // call safety
1256  if (!pRootFolder || !pSpecifiedFolder) return false;
1257  // set new current and load it
1258  if (!BeginActivity(true)) return false;
1259  pCurrFolder = pSpecifiedFolder;
1260  bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload);
1261  EndActivity();
1262  return fSuccess;
1263 }

References C4ScenarioListLoader::Folder::LoadContents().

Here is the call graph for this function:

◆ LoadExtended()

bool C4ScenarioListLoader::LoadExtended ( Entry pEntry)

Definition at line 1265 of file C4StartupScenSelDlg.cpp.

1266 {
1267  // call safety
1268  if (!pRootFolder || !pEntry) return false;
1269  // load info of selection
1270  if (!BeginActivity(false)) return false;
1271  bool fSuccess = pEntry->Load(nullptr, nullptr, true);
1272  EndActivity();
1273  return fSuccess;
1274 }

References C4ScenarioListLoader::Entry::Load().

Here is the call graph for this function:

◆ ReloadCurrent()

bool C4ScenarioListLoader::ReloadCurrent ( )

Definition at line 1286 of file C4StartupScenSelDlg.cpp.

1287 {
1288  // call safety
1289  if (!pRootFolder || !pCurrFolder) return false;
1290  // reload current
1291  return Load(pCurrFolder, true);
1292 }

References Load().

Referenced by C4StartupScenSelDlg::DoRefresh().

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: