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 529 of file C4StartupScenSelDlg.cpp.

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

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

530 {
531  // create iterator on free store to avoid stack overflow with deeply recursed folders
532  DirectoryIterator *pIter = new DirectoryIterator(szDir);
533  const char *szChildFilename;
534  for (; (szChildFilename = **pIter); ++*pIter)
535  {
536  // Ignore directory navigation entries and CVS folders
537  if (C4Group_TestIgnore(szChildFilename)) continue;
538  if (WildcardMatch(C4CFN_ScenarioFiles, szChildFilename) || WildcardMatch(C4CFN_FolderFiles, szChildFilename)) break;
539  if (DirectoryExists(szChildFilename))
540  if (DirContainsScenarios(szChildFilename))
541  break;
542  }
543  delete pIter;
544  // return true if loop was broken, in which case a matching entry was found
545  return !!szChildFilename;
546 }
#define C4CFN_FolderFiles
Definition: C4Components.h:175
bool DirContainsScenarios(const char *szDir)
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:694
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:384
#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 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:450
int32_t AlphabeticalSorting
Definition: C4Config.h:190
C4Config Config
Definition: C4Config.cpp:837
C4ConfigStartup Startup
Definition: C4Config.h:261
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:45
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 1284 of file C4StartupScenSelDlg.cpp.

Referenced by C4StartupScenSelDlg::C4StartupScenSelDlg().

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

Definition at line 1285 of file C4StartupScenSelDlg.cpp.