OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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)
 
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 C4ScenarioParametersGetAchievements () const
 

Detailed Description

Definition at line 45 of file C4StartupScenSelDlg.h.

Constructor & Destructor Documentation

C4ScenarioListLoader::C4ScenarioListLoader ( const C4ScenarioParameters Achievements)

Definition at line 1163 of file C4StartupScenSelDlg.cpp.

1163  : Achievements(Achievements), pRootFolder(nullptr), pCurrFolder(nullptr),
1164  iLoading(0), iProgress(0), iMaxProgress(0), fAbortThis(false), fAbortPrevious(false)
1165 {
1166 }
C4ScenarioListLoader::~C4ScenarioListLoader ( )

Definition at line 1168 of file C4StartupScenSelDlg.cpp.

1169 {
1170  if (pRootFolder) delete pRootFolder;
1171 }

Member Function Documentation

bool C4ScenarioListLoader::DoProcessCallback ( int32_t  iProgress,
int32_t  iMaxProgress 
)

Definition at line 1203 of file C4StartupScenSelDlg.cpp.

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

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

1204 {
1205  this->iProgress = iProgress;
1206  this->iMaxProgress = iMaxProgress;
1207  // callback to dialog
1209  // process callback - abort at a few ugly circumstances...
1210  if (!Application.ScheduleProcs() // WM_QUIT message?
1211  || !C4StartupScenSelDlg::pInstance // host dialog removed?
1212  || !C4StartupScenSelDlg::pInstance->IsShown() // host dialog closed?
1213  ) return false;
1214  // and also abort if flagged
1215  return !fAbortThis;
1216 }
bool IsShown()
Definition: C4Gui.h:2147
bool ScheduleProcs(int iTimeout=1000/36)
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:

bool C4ScenarioListLoader::FolderBack ( )

Definition at line 1256 of file C4StartupScenSelDlg.cpp.

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

Referenced by C4StartupScenSelDlg::DoBack().

1257 {
1258  // call safety
1259  if (!pRootFolder || !pCurrFolder) return false;
1260  // already in root: Can't go up
1261  if (pCurrFolder == pRootFolder) return false;
1262  // otherwise, up one level
1263  return Load(pCurrFolder->GetParent(), false);
1264 }
bool Load(const StdStrBuf &sRootFolder)
class Folder * GetParent() const

Here is the call graph for this function:

Here is the caller graph for this function:

const C4ScenarioParameters& C4ScenarioListLoader::GetAchievements ( ) const
inline

Definition at line 269 of file C4StartupScenSelDlg.h.

269 { return Achievements; }
Folder* C4ScenarioListLoader::GetCurrFolder ( ) const
inline

Definition at line 262 of file C4StartupScenSelDlg.h.

262 { return pCurrFolder; }
Entry* C4ScenarioListLoader::GetFirstEntry ( ) const
inline

Definition at line 260 of file C4StartupScenSelDlg.h.

References C4ScenarioListLoader::Folder::GetFirstEntry().

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

Here is the call graph for this function:

int32_t C4ScenarioListLoader::GetMaxProgress ( ) const
inline

Definition at line 266 of file C4StartupScenSelDlg.h.

266 { return iMaxProgress; }
int32_t C4ScenarioListLoader::GetProgress ( ) const
inline

Definition at line 265 of file C4StartupScenSelDlg.h.

265 { return iProgress; }
int32_t C4ScenarioListLoader::GetProgressPercent ( ) const
inline

Definition at line 267 of file C4StartupScenSelDlg.h.

267 { return iProgress * 100 / std::max<int32_t>(iMaxProgress, 1); }
Folder* C4ScenarioListLoader::GetRootFolder ( ) const
inline

Definition at line 263 of file C4StartupScenSelDlg.h.

263 { return pRootFolder; }
bool C4ScenarioListLoader::IsLoading ( ) const
inline

Definition at line 259 of file C4StartupScenSelDlg.h.

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

259 { return !!iLoading; }

Here is the caller graph for this function:

bool C4ScenarioListLoader::Load ( const StdStrBuf sRootFolder)

Definition at line 1218 of file C4StartupScenSelDlg.cpp.

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

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

1219 {
1220  // (unthreaded) loading of all entries in root folder
1221  if (!BeginActivity(true)) return false;
1222  if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; }
1223  pCurrFolder = pRootFolder = new RegularFolder(this, nullptr);
1224  // Load regular game data if no explicit path specified
1225  if(!sRootFolder.getData())
1226  for(C4Reloc::iterator iter = Reloc.begin(); iter != Reloc.end(); ++iter)
1227  pRootFolder->Merge(iter->strBuf.getData());
1228  bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false);
1229  EndActivity();
1230  return fSuccess;
1231 }
const char * getData() const
Definition: StdBuf.h:450
PathList::const_iterator iterator
Definition: C4Reloc.h:38
iterator begin() const
Definition: C4Reloc.cpp:59
C4Reloc Reloc
Definition: C4Reloc.cpp:22
bool LoadContents(C4ScenarioListLoader *pLoader, C4Group *pFromGrp, const StdStrBuf *psFilename, bool fLoadEx, bool fReload)
iterator end() const
Definition: C4Reloc.cpp:64

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1233 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Folder::LoadContents().

1234 {
1235  // call safety
1236  if (!pRootFolder || !pSpecifiedFolder) return false;
1237  // set new current and load it
1238  if (!BeginActivity(true)) return false;
1239  pCurrFolder = pSpecifiedFolder;
1240  bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload);
1241  EndActivity();
1242  return fSuccess;
1243 }
bool LoadContents(C4ScenarioListLoader *pLoader, C4Group *pFromGrp, const StdStrBuf *psFilename, bool fLoadEx, bool fReload)

Here is the call graph for this function:

bool C4ScenarioListLoader::LoadExtended ( Entry pEntry)

Definition at line 1245 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Entry::Load().

1246 {
1247  // call safety
1248  if (!pRootFolder || !pEntry) return false;
1249  // load info of selection
1250  if (!BeginActivity(false)) return false;
1251  bool fSuccess = pEntry->Load(nullptr, nullptr, true);
1252  EndActivity();
1253  return fSuccess;
1254 }

Here is the call graph for this function:

bool C4ScenarioListLoader::ReloadCurrent ( )

Definition at line 1266 of file C4StartupScenSelDlg.cpp.

References Load().

Referenced by C4StartupScenSelDlg::DoRefresh().

1267 {
1268  // call safety
1269  if (!pRootFolder || !pCurrFolder) return false;
1270  // reload current
1271  return Load(pCurrFolder, true);
1272 }
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: