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 493 of file C4Scenario.cpp.

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

494 {
495  pComp->Value(mkNamingAdapt(LocalOnly, "LocalOnly", false));
496  pComp->Value(mkNamingAdapt(AllowUserChange, "AllowUserChange", false));
497  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[0]), "Definition1", "Objects.ocd"));
498  for (int32_t i = 1; i < C4S_MaxDefinitions; i++)
499  pComp->Value(mkNamingAdapt(mkStringAdaptMA(Definition[i]), FormatString("Definition%i", i+1).getData(), ""));
500  pComp->Value(mkNamingAdapt(SkipDefs, "SkipDefs", C4IDList()));
501 }
StdNamingAdapt< T > mkNamingAdapt(T &&rValue, const char *szName)
Definition: StdAdaptors.h:93
C4IDList SkipDefs
Definition: C4Scenario.h:94
bool AllowUserChange
Definition: C4Scenario.h:93
void Value(const T &rStruct)
Definition: StdCompiler.h:170
#define mkStringAdaptMA(szString)
Definition: StdAdaptors.h:191
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277

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:63

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 413 of file C4Scenario.cpp.

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

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

414 {
415  // Local only
416  if (LocalOnly) { psOutModules->Copy(""); return true; }
417  // Scan for any valid entries
418  bool fSpecified = false;
419  int32_t cnt=0;
420  for (; cnt<C4S_MaxDefinitions; cnt++)
421  if (Definition[cnt][0])
422  fSpecified = true;
423  // No valid entries
424  if (!fSpecified) return false;
425  // Compose entry list
426  psOutModules->Copy("");
427  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++)
428  if (Definition[cnt][0])
429  {
430  if (psOutModules->getLength()) psOutModules->AppendChar(';');
431  psOutModules->Append(Definition[cnt]);
432  }
433  // Done
434  return true;
435 }
void AppendChar(char cChar)
Definition: StdBuf.h:596
void Append(const char *pnData, size_t iChars)
Definition: StdBuf.h:527
size_t getLength() const
Definition: StdBuf.h:453
void Copy()
Definition: StdBuf.h:475
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 437 of file C4Scenario.cpp.

References LocalOnly.

438 {
439  // get definitions as string pointers into this structure
440  std::list<const char *> result;
441  if (!LocalOnly)
442  {
443  for (const char *def : Definition)
444  {
445  if (*def)
446  {
447  result.push_back(def);
448  }
449  }
450  }
451  return result;
452 }
void C4SDefinitions::SetModules ( const char *  szList,
const char *  szRelativeToPath = nullptr,
const char *  szRelativeToPath2 = nullptr 
)

Definition at line 455 of file C4Scenario.cpp.

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

456 {
457  int32_t cnt;
458 
459  // Empty list: local only
460  if (!SModuleCount(szList))
461  {
462  LocalOnly=true;
463  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++) Definition[cnt][0]=0;
464  return;
465  }
466 
467  // Set list
468  LocalOnly=false;
469  for (cnt=0; cnt<C4S_MaxDefinitions; cnt++)
470  {
471  SGetModule(szList,cnt,Definition[cnt],_MAX_PATH);
472  // Make relative path
473  if (szRelativeToPath && *szRelativeToPath)
474  {
475  if (GetRelativePathS(Definition[cnt],szRelativeToPath) != Definition[cnt])
476  {
477  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath),Definition[cnt]);
478  continue;
479  }
480  }
481  if (szRelativeToPath2 && *szRelativeToPath2)
482  {
483  if (GetRelativePathS(Definition[cnt],szRelativeToPath2) != Definition[cnt])
484  {
485  SCopy(GetRelativePathS(Definition[cnt],szRelativeToPath2),Definition[cnt]);
486  continue;
487  }
488  }
489  }
490 
491 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:503
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
#define _MAX_PATH
int SModuleCount(const char *szList)
Definition: Standard.cpp:581
const int32_t C4S_MaxDefinitions
Definition: C4Scenario.h:87
const char * GetRelativePathS(const char *strPath, const char *strRelativeTo)
Definition: StdFile.cpp:221

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: