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 42 of file C4StartupScenSelDlg.h.

Constructor & Destructor Documentation

C4ScenarioListLoader::C4ScenarioListLoader ( const C4ScenarioParameters Achievements)

Definition at line 1157 of file C4StartupScenSelDlg.cpp.

1157  : Achievements(Achievements), pRootFolder(nullptr), pCurrFolder(nullptr),
1158  iLoading(0), iProgress(0), iMaxProgress(0), fAbortThis(false), fAbortPrevious(false)
1159 {
1160 }
C4ScenarioListLoader::~C4ScenarioListLoader ( )

Definition at line 1162 of file C4StartupScenSelDlg.cpp.

1163 {
1164  if (pRootFolder) delete pRootFolder;
1165 }

Member Function Documentation

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

Definition at line 1197 of file C4StartupScenSelDlg.cpp.

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

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

1198 {
1199  this->iProgress = iProgress;
1200  this->iMaxProgress = iMaxProgress;
1201  // callback to dialog
1203  // process callback - abort at a few ugly circumstances...
1204  if (!Application.ScheduleProcs() // WM_QUIT message?
1205  || !C4StartupScenSelDlg::pInstance // host dialog removed?
1206  || !C4StartupScenSelDlg::pInstance->IsShown() // host dialog closed?
1207  ) return false;
1208  // and also abort if flagged
1209  return !fAbortThis;
1210 }
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 1250 of file C4StartupScenSelDlg.cpp.

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

Referenced by C4StartupScenSelDlg::DoBack().

1251 {
1252  // call safety
1253  if (!pRootFolder || !pCurrFolder) return false;
1254  // already in root: Can't go up
1255  if (pCurrFolder == pRootFolder) return false;
1256  // otherwise, up one level
1257  return Load(pCurrFolder->GetParent(), false);
1258 }
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 266 of file C4StartupScenSelDlg.h.

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

Definition at line 259 of file C4StartupScenSelDlg.h.

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

Definition at line 257 of file C4StartupScenSelDlg.h.

References C4ScenarioListLoader::Folder::GetFirstEntry().

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

Here is the call graph for this function:

int32_t C4ScenarioListLoader::GetMaxProgress ( ) const
inline

Definition at line 263 of file C4StartupScenSelDlg.h.

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

Definition at line 262 of file C4StartupScenSelDlg.h.

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

Definition at line 264 of file C4StartupScenSelDlg.h.

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

Definition at line 260 of file C4StartupScenSelDlg.h.

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

Definition at line 256 of file C4StartupScenSelDlg.h.

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

256 { return !!iLoading; }

Here is the caller graph for this function:

bool C4ScenarioListLoader::Load ( const StdStrBuf sRootFolder)

Definition at line 1212 of file C4StartupScenSelDlg.cpp.

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

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

1213 {
1214  // (unthreaded) loading of all entries in root folder
1215  if (!BeginActivity(true)) return false;
1216  if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; }
1217  pCurrFolder = pRootFolder = new RegularFolder(this, nullptr);
1218  // Load regular game data if no explicit path specified
1219  if(!sRootFolder.getData())
1220  for(const auto & iter : Reloc)
1221  pRootFolder->Merge(iter.strBuf.getData());
1222  bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false);
1223  EndActivity();
1224  return fSuccess;
1225 }
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:

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

Definition at line 1227 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Folder::LoadContents().

1228 {
1229  // call safety
1230  if (!pRootFolder || !pSpecifiedFolder) return false;
1231  // set new current and load it
1232  if (!BeginActivity(true)) return false;
1233  pCurrFolder = pSpecifiedFolder;
1234  bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload);
1235  EndActivity();
1236  return fSuccess;
1237 }
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 1239 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Entry::Load().

1240 {
1241  // call safety
1242  if (!pRootFolder || !pEntry) return false;
1243  // load info of selection
1244  if (!BeginActivity(false)) return false;
1245  bool fSuccess = pEntry->Load(nullptr, nullptr, true);
1246  EndActivity();
1247  return fSuccess;
1248 }

Here is the call graph for this function:

bool C4ScenarioListLoader::ReloadCurrent ( )

Definition at line 1260 of file C4StartupScenSelDlg.cpp.

References Load().

Referenced by C4StartupScenSelDlg::DoRefresh().

1261 {
1262  // call safety
1263  if (!pRootFolder || !pCurrFolder) return false;
1264  // reload current
1265  return Load(pCurrFolder, true);
1266 }
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: