OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4MCPoint Class Reference

#include <C4MapCreatorS2.h>

Inheritance diagram for C4MCPoint:
[legend]
Collaboration diagram for C4MCPoint:
[legend]

Public Member Functions

 C4MCPoint (C4MCNode *pOwner=nullptr)
 
 C4MCPoint (C4MCParser *pParser, C4MCNode *pOwner, C4MCPoint &rTemplate, bool fClone)
 
C4MCNodeclone (C4MCParser *pParser, C4MCNode *pToNode)
 
virtual void Evaluate ()
 
bool SetField (C4MCParser *pParser, const char *szField, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
C4MCNodeType Type ()
 
void Clear ()
 
void Reg2Owner (C4MCNode *pOwner)
 
virtual C4MCOverlayOverlay ()
 
C4MCOverlayOwnerOverlay ()
 

Public Attributes

int32_t X
 
int32_t Y
 
int_bool RX
 
int_bool RY
 
C4MCNodeOwner
 
C4MCNodeChild0
 
C4MCNodeChildL
 
C4MCNodePrev
 
C4MCNodeNext
 
C4MapCreatorS2MapCreator
 
char Name [C4MaxName]
 

Protected Member Functions

void Default ()
 
virtual bool GlobalScope ()
 
virtual bool SetOp (C4MCTokenType eOp)
 
C4MCNodeGetNodeByName (const char *szName)
 
int32_t IntPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
const char * StrPar (C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
 
void ReEvaluate ()
 

Friends

class C4MapCreatorS2
 
class C4MCParser
 

Detailed Description

Definition at line 248 of file C4MapCreatorS2.h.

Constructor & Destructor Documentation

C4MCPoint::C4MCPoint ( C4MCNode pOwner = nullptr)

Definition at line 641 of file C4MapCreatorS2.cpp.

References X, and Y.

Referenced by clone().

641  : C4MCNode(pOwner)
642 {
643  // zero members
644  X=Y=0;
645 }
C4MCNode(C4MCNode *pOwner=nullptr)

Here is the caller graph for this function:

C4MCPoint::C4MCPoint ( C4MCParser pParser,
C4MCNode pOwner,
C4MCPoint rTemplate,
bool  fClone 
)

Definition at line 647 of file C4MapCreatorS2.cpp.

References RX, RY, X, and Y.

647  : C4MCNode(pParser, pOwner, rTemplate, fClone)
648 {
649  // copy fields
650  X=rTemplate.X; Y=rTemplate.Y;
651  RX=rTemplate.RX; RY=rTemplate.RY;
652 }
C4MCNode(C4MCNode *pOwner=nullptr)
int_bool RY
int_bool RX

Member Function Documentation

void C4MCNode::Clear ( )
inherited

Definition at line 239 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0.

Referenced by C4MapCreatorS2::Clear(), and C4MCNode::~C4MCNode().

240 {
241  // delete all children; they'll unreg themselves
242  while (Child0) delete Child0;
243 }
C4MCNode * Child0

Here is the caller graph for this function:

C4MCNode* C4MCPoint::clone ( C4MCParser pParser,
C4MCNode pToNode 
)
inlinevirtual

Reimplemented from C4MCNode.

Definition at line 254 of file C4MapCreatorS2.h.

References C4MCPoint().

254 { return new C4MCPoint(pParser, pToNode, *this, true); }
C4MCPoint(C4MCNode *pOwner=nullptr)

Here is the call graph for this function:

void C4MCPoint::Default ( )
protected

Definition at line 654 of file C4MapCreatorS2.cpp.

References X, and Y.

Referenced by C4MapCreatorS2::Default().

655 {
656  X=Y=0;
657 }

Here is the caller graph for this function:

void C4MCPoint::Evaluate ( )
virtual

Reimplemented from C4MCNode.

Definition at line 676 of file C4MapCreatorS2.cpp.

References C4MCNode::Evaluate(), C4MCNode::int_bool::Evaluate(), C4MCOverlay::Hgt, C4MCNode::Owner, C4MCNode::OwnerOverlay(), RX, RY, C4MCOverlay::Wdt, C4MCOverlay::X, X, C4MCOverlay::Y, and Y.

677 {
678  // inherited
680  // get mat color
681  // calc size
682  if (Owner)
683  {
684  C4MCOverlay *pOwnrOvrl;
685  if ((pOwnrOvrl=OwnerOverlay()))
686  {
687  X = RX.Evaluate(pOwnrOvrl->Wdt) + pOwnrOvrl->X;
688  Y = RY.Evaluate(pOwnrOvrl->Hgt) + pOwnrOvrl->Y;
689  }
690  }
691 }
C4MCOverlay * OwnerOverlay()
virtual void Evaluate()
C4MCNode * Owner
int_bool RY
int32_t Evaluate(int32_t relative_to)
int_bool RX

Here is the call graph for this function:

C4MCNode * C4MCNode::GetNodeByName ( const char *  szName)
protectedinherited

Definition at line 254 of file C4MapCreatorS2.cpp.

References C4MCNode::ChildL, C4MCNode::GetNodeByName(), C4MCNode::Owner, C4MCNode::Prev, and SEqual().

Referenced by C4MapCreatorS2::GetMap(), and C4MCNode::GetNodeByName().

255 {
256  // search local list (backwards: last node has highest priority)
257  for (C4MCNode *pChild=ChildL; pChild; pChild=pChild->Prev)
258  // name match?
259  if (SEqual(pChild->Name, szName))
260  // yeah, success!
261  return pChild;
262  // search owner, if present
263  if (Owner) return Owner->GetNodeByName(szName);
264  // nothing found
265  return nullptr;
266 }
C4MCNode * GetNodeByName(const char *szName)
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Prev

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4MCNode::GlobalScope ( )
inlineprotectedvirtualinherited

Reimplemented in C4MapCreatorS2.

Definition at line 162 of file C4MapCreatorS2.h.

162 { return false; } // whether node is a global scope
int32_t C4MCNode::IntPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 274 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, MCT_INT, MCT_PERCENT, and MCT_PX.

Referenced by C4MCOverlay::SetField(), and SetField().

275 {
276  // check if int32_t
277  if (ValType == MCT_INT || ValType == MCT_PERCENT || ValType == MCT_PX)
278  return iVal;
279  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
280 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

virtual C4MCOverlay* C4MCNode::Overlay ( )
inlinevirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 187 of file C4MapCreatorS2.h.

Referenced by C4MCOverlay::FirstOfChain(), and C4MCOverlay::PeekPix().

187 { return nullptr; } // return overlay, if this is one

Here is the caller graph for this function:

C4MCOverlay * C4MCNode::OwnerOverlay ( )
inherited

Definition at line 245 of file C4MapCreatorS2.cpp.

References C4MCOverlay::Overlay(), and C4MCNode::Owner.

Referenced by C4MCOverlay::Evaluate(), Evaluate(), and PreparePeek().

246 {
247  for (C4MCNode *pOwnr=Owner; pOwnr; pOwnr=pOwnr->Owner)
248  if (C4MCOverlay *pOwnrOvrl=pOwnr->Overlay())
249  return pOwnrOvrl;
250  // no overlay-owner
251  return nullptr;
252 }
C4MCOverlay * Overlay()
C4MCNode * Owner

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::ReEvaluate ( )
protectedinherited

Definition at line 293 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0, C4MCNode::Evaluate(), and C4MCNode::Next.

Referenced by C4MCMap::SetSize().

294 {
295  // evaluate ourselves
296  Evaluate();
297  // evaluate children
298  for (C4MCNode *pChild=Child0; pChild; pChild=pChild->Next)
299  pChild->ReEvaluate();
300 }
virtual void Evaluate()
C4MCNode * Child0
C4MCNode * Next

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MCNode::Reg2Owner ( C4MCNode pOwner)
inherited

Definition at line 215 of file C4MapCreatorS2.cpp.

References C4MCNode::Child0, C4MCNode::ChildL, C4MCNode::MapCreator, C4MCNode::Next, C4MCNode::Owner, and C4MCNode::Prev.

Referenced by C4MCNode::C4MCNode().

216 {
217  // init list
218  Child0=ChildL=nullptr;
219  // owner?
220  if ((Owner=pOwner))
221  {
222  // link into it
223  if ((Prev = Owner->ChildL))
224  Prev->Next = this;
225  else
226  Owner->Child0 = this;
227  Owner->ChildL = this;
228  MapCreator=pOwner->MapCreator;
229  }
230  else
231  {
232  Prev=nullptr;
233  MapCreator=nullptr;
234  }
235  // we're always last entry
236  Next=nullptr;
237 }
C4MCNode * Child0
C4MCNode * ChildL
C4MCNode * Owner
C4MCNode * Next
C4MCNode * Prev
C4MapCreatorS2 * MapCreator

Here is the caller graph for this function:

bool C4MCPoint::SetField ( C4MCParser pParser,
const char *  szField,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
virtual

Reimplemented from C4MCNode.

Definition at line 659 of file C4MapCreatorS2.cpp.

References C4MCNode::IntPar(), MCT_INT, MCT_PERCENT, RX, RY, SEqual(), and C4MCNode::int_bool::Set().

660 {
661  // only explicit %/px
662  if (ValType == MCT_INT) return false;
663  if (SEqual (szField, "x"))
664  {
665  RX.Set(IntPar, ValType == MCT_PERCENT);
666  return true;
667  }
668  else if (SEqual (szField, "y"))
669  {
670  RY.Set(IntPar, ValType == MCT_PERCENT);
671  return true;
672  }
673  return false;
674 }
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97
int_bool RY
int32_t IntPar(C4MCParser *pParser, const char *szSVal, int32_t iVal, C4MCTokenType ValType)
void Set(int32_t value, bool percent)
int_bool RX

Here is the call graph for this function:

virtual bool C4MCNode::SetOp ( C4MCTokenType  eOp)
inlineprotectedvirtualinherited

Reimplemented in C4MCOverlay.

Definition at line 163 of file C4MapCreatorS2.h.

163 { return false; } // set following operator
const char * C4MCNode::StrPar ( C4MCParser pParser,
const char *  szSVal,
int32_t  iVal,
C4MCTokenType  ValType 
)
protectedinherited

Definition at line 282 of file C4MapCreatorS2.cpp.

References C4MCErr_FieldValInvalid, and MCT_IDTF.

Referenced by C4MCOverlay::SetField().

283 {
284  // check if identifier
285  if (ValType != MCT_IDTF)
286  throw C4MCParserErr(pParser, C4MCErr_FieldValInvalid, szSVal);
287  return szSVal;
288 }
#define C4MCErr_FieldValInvalid

Here is the caller graph for this function:

C4MCNodeType C4MCPoint::Type ( )
inlinevirtual

Reimplemented from C4MCNode.

Definition at line 267 of file C4MapCreatorS2.h.

References MCN_Point.

267 { return MCN_Point; } // get node type

Friends And Related Function Documentation

friend class C4MapCreatorS2
friend

Definition at line 269 of file C4MapCreatorS2.h.

friend class C4MCParser
friend

Definition at line 270 of file C4MapCreatorS2.h.

Member Data Documentation

C4MCNode * C4MCNode::ChildL
inherited
char C4MCNode::Name[C4MaxName]
inherited

Definition at line 149 of file C4MapCreatorS2.h.

Referenced by AlgoScript(), and C4MCNode::C4MCNode().

int_bool C4MCPoint::RX

Definition at line 261 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Evaluate(), and SetField().

int_bool C4MCPoint::RY

Definition at line 261 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Evaluate(), and SetField().

int32_t C4MCPoint::X

Definition at line 260 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Default(), and Evaluate().

int32_t C4MCPoint::Y

Definition at line 260 of file C4MapCreatorS2.h.

Referenced by C4MCPoint(), Default(), and Evaluate().


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