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_FolderFiles, C4CFN_ScenarioFiles, C4Group_TestIgnore(), DirectoryExists(), and WildcardMatch().

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

526 {
527  // create iterator on free store to avoid stack overflow with deeply recursed folders
528  DirectoryIterator *pIter = new DirectoryIterator(szDir);
529  const char *szChildFilename;
530  for (; (szChildFilename = **pIter); ++*pIter)
531  {
532  // Ignore directory navigation entries and CVS folders
533  if (C4Group_TestIgnore(szChildFilename)) continue;
534  if (WildcardMatch(C4CFN_ScenarioFiles, szChildFilename) || WildcardMatch(C4CFN_FolderFiles, szChildFilename)) break;
535  if (DirectoryExists(szChildFilename))
536  if (DirContainsScenarios(szChildFilename))
537  break;
538  }
539  delete pIter;
540  // return true if loop was broken, in which case a matching entry was found
541  return !!szChildFilename;
542 }
#define C4CFN_FolderFiles
Definition: C4Components.h:175
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:174
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 850 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().

851 {
852  C4ScenarioListLoader::Entry *pEntry1 = *(C4ScenarioListLoader::Entry * const *) pEl1, *pEntry2 = *(C4ScenarioListLoader::Entry * const *) pEl2;
853  // sort folders before scenarios
854  bool fS1 = !pEntry1->GetIsFolder(), fS2 = !pEntry2->GetIsFolder();
855  if (fS1 != fS2) return fS1-fS2;
856  // sort by folder index (undefined index 0 goes to the end)
857  if (!Config.Startup.AlphabeticalSorting) if (pEntry1->GetFolderIndex() || pEntry2->GetFolderIndex())
858  {
859  if (!pEntry1->GetFolderIndex()) return +1;
860  if (!pEntry2->GetFolderIndex()) return -1;
861  int32_t iDiff = pEntry1->GetFolderIndex() - pEntry2->GetFolderIndex();
862  if (iDiff) return iDiff;
863  }
864  // sort by numbered standard scenario icons
865  if (Inside(pEntry1->GetIconIndex(), 2, 11))
866  {
867  int32_t iDiff = pEntry1->GetIconIndex() - pEntry2->GetIconIndex();
868  if (iDiff) return iDiff;
869  }
870  // sort by difficulty (undefined difficulty goes to the end)
871  if (!Config.Startup.AlphabeticalSorting) if (pEntry1->GetDifficulty() || pEntry2->GetDifficulty())
872  {
873  if (!pEntry1->GetDifficulty()) return +1;
874  if (!pEntry2->GetDifficulty()) return -1;
875  int32_t iDiff = pEntry1->GetDifficulty() - pEntry2->GetDifficulty();
876  if (iDiff) return iDiff;
877  }
878  // otherwise, sort by name
879  return stricmp(pEntry1->GetName().getData(), pEntry2->GetName().getData());
880 }
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 1278 of file C4StartupScenSelDlg.cpp.

Referenced by C4StartupScenSelDlg::C4StartupScenSelDlg().

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

Definition at line 1279 of file C4StartupScenSelDlg.cpp.