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, 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 ( const C4ScenarioParameters Achievements)

Definition at line 1164 of file C4StartupScenSelDlg.cpp.

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

Definition at line 1169 of file C4StartupScenSelDlg.cpp.

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

Member Function Documentation

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

Definition at line 1206 of file C4StartupScenSelDlg.cpp.

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

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

1207 {
1208  this->iProgress = iProgress;
1209  this->iMaxProgress = iMaxProgress;
1210  this->current_load_info.Copy(current_load_info);
1211  // callback to dialog
1213  // process callback - abort at a few ugly circumstances...
1214  // schedule with 1ms delay to force event processing
1215  // (delay 0 would be nice, but isn't supported properly by our Windows implementation of ScheduleProcs)
1216  if (!Application.ScheduleProcs(1) // WM_QUIT message?
1217  || !C4StartupScenSelDlg::pInstance // host dialog removed?
1218  || !C4StartupScenSelDlg::pInstance->IsShown() // host dialog closed?
1219  ) return false;
1220  // and also abort if flagged
1221  return !fAbortThis;
1222 }
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:

bool C4ScenarioListLoader::FolderBack ( )

Definition at line 1262 of file C4StartupScenSelDlg.cpp.

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

Referenced by C4StartupScenSelDlg::DoBack().

1263 {
1264  // call safety
1265  if (!pRootFolder || !pCurrFolder) return false;
1266  // already in root: Can't go up
1267  if (pCurrFolder == pRootFolder) return false;
1268  // otherwise, up one level
1269  return Load(pCurrFolder->GetParent(), false);
1270 }
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 268 of file C4StartupScenSelDlg.h.

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

Definition at line 260 of file C4StartupScenSelDlg.h.

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

Definition at line 258 of file C4StartupScenSelDlg.h.

References C4ScenarioListLoader::Folder::GetFirstEntry().

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

Here is the call graph for this function:

int32_t C4ScenarioListLoader::GetMaxProgress ( ) const
inline

Definition at line 264 of file C4StartupScenSelDlg.h.

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

Definition at line 263 of file C4StartupScenSelDlg.h.

263 { return iProgress; }
const char* C4ScenarioListLoader::GetProgressInfo ( ) const
inline

Definition at line 266 of file C4StartupScenSelDlg.h.

References StdStrBuf::getData().

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

Here is the call graph for this function:

int32_t C4ScenarioListLoader::GetProgressPercent ( ) const
inline

Definition at line 265 of file C4StartupScenSelDlg.h.

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

Definition at line 261 of file C4StartupScenSelDlg.h.

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

Definition at line 257 of file C4StartupScenSelDlg.h.

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

257 { return !!iLoading; }

Here is the caller graph for this function:

bool C4ScenarioListLoader::Load ( const StdStrBuf sRootFolder)

Definition at line 1224 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().

1225 {
1226  // (unthreaded) loading of all entries in root folder
1227  if (!BeginActivity(true)) return false;
1228  if (pRootFolder) { delete pRootFolder; pRootFolder = nullptr; }
1229  pCurrFolder = pRootFolder = new RegularFolder(this, nullptr);
1230  // Load regular game data if no explicit path specified
1231  if(!sRootFolder.getData())
1232  for(const auto & iter : Reloc)
1233  pRootFolder->Merge(iter.strBuf.getData());
1234  bool fSuccess = pRootFolder->LoadContents(this, nullptr, &sRootFolder, false, false);
1235  EndActivity();
1236  return fSuccess;
1237 }
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 1239 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Folder::LoadContents().

1240 {
1241  // call safety
1242  if (!pRootFolder || !pSpecifiedFolder) return false;
1243  // set new current and load it
1244  if (!BeginActivity(true)) return false;
1245  pCurrFolder = pSpecifiedFolder;
1246  bool fSuccess = pCurrFolder->LoadContents(this, nullptr, nullptr, false, fReload);
1247  EndActivity();
1248  return fSuccess;
1249 }
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 1251 of file C4StartupScenSelDlg.cpp.

References C4ScenarioListLoader::Entry::Load().

1252 {
1253  // call safety
1254  if (!pRootFolder || !pEntry) return false;
1255  // load info of selection
1256  if (!BeginActivity(false)) return false;
1257  bool fSuccess = pEntry->Load(nullptr, nullptr, true);
1258  EndActivity();
1259  return fSuccess;
1260 }

Here is the call graph for this function:

bool C4ScenarioListLoader::ReloadCurrent ( )

Definition at line 1272 of file C4StartupScenSelDlg.cpp.

References Load().

Referenced by C4StartupScenSelDlg::DoRefresh().

1273 {
1274  // call safety
1275  if (!pRootFolder || !pCurrFolder) return false;
1276  // reload current
1277  return Load(pCurrFolder, true);
1278 }
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: