OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4StartupScenSelDlg.cpp File Reference
Include dependency graph for C4StartupScenSelDlg.cpp:

Go to the source code of this file.

Functions

bool DirContainsScenarios (const char *szDir)
 
int EntrySortFunc (const void *pEl1, const void *pEl2)
 

Variables

const uint32_t ClrScenarioItem = 0xff000000
 
const uint32_t ClrScenarioItemXtra = 0x7f000000
 
const uint32_t ClrScenarioItemDisabled = 0x7f000000
 

Function Documentation

bool DirContainsScenarios ( const char *  szDir)

Definition at line 525 of file C4StartupScenSelDlg.cpp.

References C4CFN_DefFiles, C4CFN_FolderFiles, C4CFN_GenericGroupFiles, C4CFN_ScenarioFiles, C4Group_TestIgnore(), DirectoryExists(), and WildcardMatch().

Referenced by C4ScenarioListLoader::Entry::CreateEntryForFile().

526 {
527  // Ignore object and group folders to avoid descending e.g. deep into unpacked Objects.ocd
529  {
530  return false;
531  }
532  // create iterator on free store to avoid stack overflow with deeply recursed folders
533  DirectoryIterator *pIter = new DirectoryIterator(szDir);
534  const char *szChildFilename;
535  for (; (szChildFilename = **pIter); ++*pIter)
536  {
537  // Ignore directory navigation entries and CVS folders
538  if (C4Group_TestIgnore(szChildFilename)) continue;
539  if (WildcardMatch(C4CFN_ScenarioFiles, szChildFilename) || WildcardMatch(C4CFN_FolderFiles, szChildFilename)) break;
540  if (DirectoryExists(szChildFilename))
541  if (DirContainsScenarios(szChildFilename))
542  break;
543  }
544  delete pIter;
545  // return true if loop was broken, in which case a matching entry was found
546  return !!szChildFilename;
547 }
#define C4CFN_FolderFiles
Definition: C4Components.h:176
#define C4CFN_GenericGroupFiles
Definition: C4Components.h:167
bool DirContainsScenarios(const char *szDir)
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:684
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:374
#define C4CFN_ScenarioFiles
Definition: C4Components.h:175
#define C4CFN_DefFiles
Definition: C4Components.h:166
bool C4Group_TestIgnore(const char *szFilename)
Definition: C4Group.cpp:85

Here is the call graph for this function:

Here is the caller graph for this function:

int EntrySortFunc ( const void *  pEl1,
const void *  pEl2 
)

Definition at line 855 of file C4StartupScenSelDlg.cpp.

References C4ConfigStartup::AlphabeticalSorting, Config, StdStrBuf::getData(), C4ScenarioListLoader::Entry::GetDifficulty(), C4ScenarioListLoader::Entry::GetFolderIndex(), C4ScenarioListLoader::Entry::GetIconIndex(), C4ScenarioListLoader::Entry::GetIsFolder(), C4ScenarioListLoader::Folder::GetIsFolder(), C4ScenarioListLoader::Entry::GetName(), Inside(), C4Config::Startup, and stricmp().

Referenced by C4ScenarioListLoader::Folder::Sort().

856 {
857  C4ScenarioListLoader::Entry *pEntry1 = *(C4ScenarioListLoader::Entry * const *) pEl1, *pEntry2 = *(C4ScenarioListLoader::Entry * const *) pEl2;
858  // sort folders before scenarios
859  bool fS1 = !pEntry1->GetIsFolder(), fS2 = !pEntry2->GetIsFolder();
860  if (fS1 != fS2) return fS1-fS2;
861  // sort by folder index (undefined index 0 goes to the end)
862  if (!Config.Startup.AlphabeticalSorting) if (pEntry1->GetFolderIndex() || pEntry2->GetFolderIndex())
863  {
864  if (!pEntry1->GetFolderIndex()) return +1;
865  if (!pEntry2->GetFolderIndex()) return -1;
866  int32_t iDiff = pEntry1->GetFolderIndex() - pEntry2->GetFolderIndex();
867  if (iDiff) return iDiff;
868  }
869  // sort by numbered standard scenario icons
870  if (Inside(pEntry1->GetIconIndex(), 2, 11))
871  {
872  int32_t iDiff = pEntry1->GetIconIndex() - pEntry2->GetIconIndex();
873  if (iDiff) return iDiff;
874  }
875  // sort by difficulty (undefined difficulty goes to the end)
876  if (!Config.Startup.AlphabeticalSorting) if (pEntry1->GetDifficulty() || pEntry2->GetDifficulty())
877  {
878  if (!pEntry1->GetDifficulty()) return +1;
879  if (!pEntry2->GetDifficulty()) return -1;
880  int32_t iDiff = pEntry1->GetDifficulty() - pEntry2->GetDifficulty();
881  if (iDiff) return iDiff;
882  }
883  // otherwise, sort by name
884  return stricmp(pEntry1->GetName().getData(), pEntry2->GetName().getData());
885 }
const char * getData() const
Definition: StdBuf.h:442
int32_t AlphabeticalSorting
Definition: C4Config.h:189
C4Config Config
Definition: C4Config.cpp:833
C4ConfigStartup Startup
Definition: C4Config.h:260
int stricmp(const char *s1, const char *s2)
int GetFolderIndex()
virtual Folder * GetIsFolder()
const StdStrBuf & GetName() const
int GetDifficulty()
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:43
int GetIconIndex()

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

const uint32_t ClrScenarioItem = 0xff000000

Definition at line 1290 of file C4StartupScenSelDlg.cpp.

Referenced by C4StartupScenSelDlg::C4StartupScenSelDlg().

const uint32_t ClrScenarioItemDisabled = 0x7f000000
const uint32_t ClrScenarioItemXtra = 0x7f000000

Definition at line 1291 of file C4StartupScenSelDlg.cpp.

Referenced by C4StartupScenSelDlg::C4StartupScenSelDlg().