OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ObjectMenu.h
Go to the documentation of this file.
1 /*
2  * OpenClonk, http://www.openclonk.org
3  *
4  * Copyright (c) 1998-2000, Matthes Bender
5  * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de/
6  * Copyright (c) 2009-2016, The OpenClonk Team and contributors
7  *
8  * Distributed under the terms of the ISC license; see accompanying file
9  * "COPYING" for details.
10  *
11  * "Clonk" is a registered trademark of Matthes Bender, used with permission.
12  * See accompanying file "TRADEMARK" for details.
13  *
14  * To redistribute this file separately, substitute the full license texts
15  * for the above references.
16  */
17 // Menus attached to objects; script created or internal
18 // These menus are shown to players if the target object is the current cursor
19 
20 #ifndef INC_C4ObjectMenu
21 #define INC_C4ObjectMenu
22 
23 #include "gui/C4Menu.h"
24 
25 enum
26 {
27  C4MN_None = 0,
28  /*C4MN_Construction = 1, obsolete, now reserved */
29  /*C4MN_Bridge = 2, obsolete, now reserved */
30  C4MN_Take = 3,
31  C4MN_Buy = 4,
32  C4MN_Sell = 5,
34  /*C4MN_Hostility = 7, now defined in C4MainMenu*/
35  /*C4MN_Surrender = 8, obsolete, now reserved*/
36  /*C4MN_Put = 9, obsolete, now reserved*/
37  /*C4MN_Magic = 10, obsolete, now reserved*/
38  /*C4MN_Main = 12, now defined in C4MainMenu*/
39  C4MN_Get = 13,
40  /*C4MN_Context = 14, obsolete, now reserved*/
41  C4MN_Info = 15,
42  /*C4MN_TeamSelection= 16, now defined in C4MainMenu */
43  /*C4MN_TeamSwitch = 17, now defined in C4MainMenu */
45 };
46 
47 class C4ObjectMenu : public C4Menu
48 {
49 public:
50  C4ObjectMenu();
51 
52  virtual void Default();
53 
55 protected:
61  bool UserMenu; // set for script created menus; user menus do CloseQuery and MenuSelection callbacks
62  bool CloseQuerying; // recursion check for close query callback
63 
64  void LocalInit(C4Object *pObject, bool fUserMenu);
65 
66 public:
67  void SetRefillObject(C4Object *pObj);
68  void ClearPointers(C4Object *pObj);
69  bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false);
70  bool InitRefSym(const C4TargetFacet &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false);
71  void Execute();
72 
73  virtual C4Object* GetParentObject();
74  bool IsCloseQuerying() const { return !!CloseQuerying; }
75 
76 protected:
77  virtual bool MenuCommand(const char *szCommand, bool fIsCloseCommand);
78 
79  virtual bool DoRefillInternal(bool &rfRefilled);
80  virtual void OnSelectionChanged(int32_t iNewSelection); // do object callbacks if selection changed in user menus
81  virtual bool IsCloseDenied(); // do MenuQueryCancel-callbacks for user menus
82  virtual bool IsReadOnly(); // determine whether the menu is just viewed by an observer, and should not issue any calls
83  virtual void OnUserSelectItem(int32_t Player, int32_t iIndex);
84  virtual void OnUserEnter(int32_t Player, int32_t iIndex, bool fRight);
85  virtual void OnUserClose();
86  virtual int32_t GetControllingPlayer();
87 };
88 
89 #endif
bool CloseQuerying
Definition: C4ObjectMenu.h:62
virtual bool IsCloseDenied()
virtual bool IsReadOnly()
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false)
virtual void OnUserSelectItem(int32_t Player, int32_t iIndex)
Definition: C4Menu.h:122
virtual void Default()
bool InitRefSym(const C4TargetFacet &fctSymbol, const char *szEmpty, C4Object *pObject, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal, bool fUserMenu=false)
void ClearPointers(C4Object *pObj)
CallbackType eCallbackType
Definition: C4ObjectMenu.h:60
virtual void OnUserEnter(int32_t Player, int32_t iIndex, bool fRight)
virtual void OnUserClose()
virtual bool MenuCommand(const char *szCommand, bool fIsCloseCommand)
virtual void OnSelectionChanged(int32_t iNewSelection)
C4Object * Object
Definition: C4ObjectMenu.h:56
void SetRefillObject(C4Object *pObj)
int32_t RefillObjectContentsCount
Definition: C4ObjectMenu.h:59
C4Object * RefillObject
Definition: C4ObjectMenu.h:58
bool IsCloseQuerying() const
Definition: C4ObjectMenu.h:74
void LocalInit(C4Object *pObject, bool fUserMenu)
virtual int32_t GetControllingPlayer()
virtual bool DoRefillInternal(bool &rfRefilled)
virtual C4Object * GetParentObject()
C4Object * ParentObject
Definition: C4ObjectMenu.h:57