OpenClonk
C4SDefinitions Class Reference

#include <C4Scenario.h>

Collaboration diagram for C4SDefinitions:
[legend]

Public Member Functions

void SetModules (const char *szList, const char *szRelativeToPath=nullptr, const char *szRelativeToPath2=nullptr)
 
bool GetModules (StdStrBuf *psOutModules) const
 
std::list< const char * > GetModulesAsList () const
 
void Default ()
 
void CompileFunc (StdCompiler *pComp)
 

Public Attributes

bool LocalOnly
 
bool AllowUserChange
 
C4IDList SkipDefs
 

Detailed Description

Definition at line 89 of file C4Scenario.h.

Member Function Documentation

◆ CompileFunc()

void C4SDefinitions::CompileFunc ( StdCompiler pComp)

Definition at line 502 of file C4Scenario.cpp.

References C4S_MaxDefinitions, FormatString(), mkNamingAdapt(), mkStringAdaptMA, and StdCompiler::Value().

503 {
504  pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
505  pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false));
506  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[0]), "Definition1", "Objects.ocd"));
507  for (int32_t i = 1; i < C4S_MaxDefinitions; i++)
508  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
509  pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
510 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:92
C4IDList SkipDefs
Definition: C4Scenario.h:94
bool AllowUserChange
Definition: C4Scenario.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:161
#define mkStringAdaptMA(szString)
Definition: StdAdaptors.h:190
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
Here is the call graph for this function:

◆ Default()

void C4SDefinitions::Default ( )

Definition at line 150 of file C4Scenario.cpp.

References ZeroMem().

151 {
153  ZeroMem(Definition,sizeof (Definition));
154  SkipDefs.Default();
155 }
C4IDList SkipDefs
Definition: C4Scenario.h:94
void Default()
Definition: stub-handle.cpp:63
bool AllowUserChange
Definition: C4Scenario.h:93
std::enable_if< std::is_pod< T >::value >::type ZeroMem(T *lpMem, size_t dwSize)
Definition: Standard.h:60
Here is the call graph for this function:

◆ GetModules()

bool C4SDefinitions::GetModules ( StdStrBuf psOutModules) const

Definition at line 422 of file C4Scenario.cpp.

References StdStrBuf::Append(), StdStrBuf::AppendChar(), C4S_MaxDefinitions, StdStrBuf::Copy(), and StdStrBuf::getLength().

Referenced by C4Game::OpenScenario(), and C4StartupScenSelDlg::StartScenario().

423 {
424  // Local only
425  if (LocalOnly) { psOutModules->Copy(""); return true; }
426  // Scan for any valid entries
427  bool fSpecified = false;
428  int32_t cnt=0;
429  for (; cnt<C4S_MaxDefinitions; cnt++)
430  if (Definition[cnt][0])
431  fSpecified = true;
432  // No valid entries
433  if (!fSpecified) return false;
434  // Compose entry list
435  psOutModules->Copy("");
436  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++)
437  if (Definition[cnt][0])
438  {
439  if (psOutModules->getLength()) psOutModules->AppendChar(';');
440  psOutModules->Append(Definition[cnt]);
441  }
442  // Done
443  return true;
444 }
void AppendChar(char cChar)
Definition: StdBuf.h:588
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:519
void Copy()
Definition: StdBuf.h:467
size_t getLength() const
Definition: StdBuf.h:445
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetModulesAsList()

std::list< const char * > C4SDefinitions::GetModulesAsList ( ) const

Definition at line 446 of file C4Scenario.cpp.

447 {
448  // get definitions as string pointers into this structure
449  std::list<const char *> result;
450  if (!LocalOnly)
451  {
452  for (const char *def : Definition)
453  {
454  if (*def)
455  {
456  result.push_back(def);
457  }
458  }
459  }
460  return result;
461 }

◆ SetModules()

void C4SDefinitions::SetModules ( const char *  szList,
const char *  szRelativeToPath = nullptr,
const char *  szRelativeToPath2 = nullptr 
)

Definition at line 464 of file C4Scenario.cpp.

References _MAX_PATH, C4S_MaxDefinitions, GetRelativePathS(), SCopy(), SGetModule(), and SModuleCount().

465 {
466  int32_t cnt;
467 
468  // Empty list: local only
469  if (!SModuleCount(szList))
470  {
471  LocalOnly=true;
472  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++) Definition[cnt][0]=0;
473  return;
474  }
475 
476  // Set list
477  LocalOnly=false;
478  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++)
479  {
480  SGetModule(szList,cnt,Definition[cnt],_MAX_PATH);
481  // Make relative path
482  if (szRelativeToPath && *szRelativeToPath)
483  {
484  if (GetRelativePathS(Definition[cnt],szRelativeToPath) != Definition[cnt])
485  {
486  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath),Definition[cnt]);
487  continue;
488  }
489  }
490  if (szRelativeToPath2 && *szRelativeToPath2)
491  {
492  if (GetRelativePathS(Definition[cnt],szRelativeToPath2) != Definition[cnt])
493  {
494  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath2),Definition[cnt]);
495  continue;
496  }
497  }
498  }
499 
500 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:533
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:152
#define _MAX_PATH
int SModuleCount(const char *szList)
Definition: Standard.cpp:611
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
const char * GetRelativePathS(const char *strPath, const char *strRelativeTo)
Definition: StdFile.cpp:211
Here is the call graph for this function:

Member Data Documentation

◆ AllowUserChange

bool C4SDefinitions::AllowUserChange

Definition at line 93 of file C4Scenario.h.

Referenced by C4Game::OpenScenario(), and C4StartupScenSelDlg::StartScenario().

◆ LocalOnly

bool C4SDefinitions::LocalOnly

Definition at line 92 of file C4Scenario.h.

◆ SkipDefs

C4IDList C4SDefinitions::SkipDefs

Definition at line 94 of file C4Scenario.h.

Referenced by C4Def::Clear().


The documentation for this class was generated from the following files: