OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
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

void C4SDefinitions::CompileFunc ( StdCompiler pComp)

Definition at line 500 of file C4Scenario.cpp.

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

501 {
502  pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
503  pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false));
504  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[0]), "Definition1", "Objects.ocd"));
505  for (int32_t i = 1; i < C4S_MaxDefinitions; i++)
506  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
507  pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
508 }
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:

void C4SDefinitions::Default ( )

Definition at line 150 of file C4Scenario.cpp.

References AllowUserChange, C4IDList::Default(), LocalOnly, SkipDefs, and ZeroMem().

Referenced by C4Scenario::Default().

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:

Here is the caller graph for this function:

bool C4SDefinitions::GetModules ( StdStrBuf psOutModules) const

Definition at line 420 of file C4Scenario.cpp.

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

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

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

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

Definition at line 444 of file C4Scenario.cpp.

References LocalOnly.

445 {
446  // get definitions as string pointers into this structure
447  std::list<const char *> result;
448  if (!LocalOnly)
449  {
450  for (const char *def : Definition)
451  {
452  if (*def)
453  {
454  result.push_back(def);
455  }
456  }
457  }
458  return result;
459 }
void C4SDefinitions::SetModules ( const char *  szList,
const char *  szRelativeToPath = nullptr,
const char *  szRelativeToPath2 = nullptr 
)

Definition at line 462 of file C4Scenario.cpp.

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

463 {
464  int32_t cnt;
465 
466  // Empty list: local only
467  if (!SModuleCount(szList))
468  {
469  LocalOnly=true;
470  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++) Definition[cnt][0]=0;
471  return;
472  }
473 
474  // Set list
475  LocalOnly=false;
476  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++)
477  {
478  SGetModule(szList,cnt,Definition[cnt],_MAX_PATH);
479  // Make relative path
480  if (szRelativeToPath && *szRelativeToPath)
481  {
482  if (GetRelativePathS(Definition[cnt],szRelativeToPath) != Definition[cnt])
483  {
484  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath),Definition[cnt]);
485  continue;
486  }
487  }
488  if (szRelativeToPath2 && *szRelativeToPath2)
489  {
490  if (GetRelativePathS(Definition[cnt],szRelativeToPath2) != Definition[cnt])
491  {
492  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath2),Definition[cnt]);
493  continue;
494  }
495  }
496  }
497 
498 }
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

bool C4SDefinitions::AllowUserChange
bool C4SDefinitions::LocalOnly

Definition at line 92 of file C4Scenario.h.

Referenced by CompileFunc(), Default(), GetModules(), GetModulesAsList(), and SetModules().

C4IDList C4SDefinitions::SkipDefs

Definition at line 94 of file C4Scenario.h.

Referenced by CompileFunc(), and Default().


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