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

#include <C4MainMenu.h>

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

Public Member Functions

 C4MainMenu ()
 
virtual void Default ()
 
bool Init (C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
 
bool InitRefSym (const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
 
bool ActivateMain (int32_t iPlayer)
 
bool ActivateNewPlayer (int32_t iPlayer)
 
bool ActivateHostility (int32_t iPlayer)
 
bool ActivateGoals (int32_t iPlayer, bool fDoActivate)
 
bool ActivateRules (int32_t iPlayer)
 
bool ActivateSavegame (int32_t iPlayer)
 
bool ActivateHost (int32_t iPlayer)
 
bool ActivateClient (int32_t iPlayer)
 
bool ActivateOptions (int32_t iPlayer, int32_t selection=0)
 
bool ActivateDisplay (int32_t iPlayer, int32_t selection=0)
 
bool ActivateSurrender (int32_t iPlayer)
 
bool ActivateObserver ()
 
bool ActivateCommand (int32_t iPlayer, const char *szCommand)
 
void Clear ()
 
void ClearPointers (C4Object *pObj)
 
bool Refill ()
 
void Execute ()
 
void SetPermanent (bool fPermanent)
 
void SetAlignment (int32_t iAlignment)
 
int32_t GetIdentification ()
 
int32_t GetItemCount ()
 
int32_t GetPosition ()
 
int32_t GetSelection ()
 
bool IsContextMenu ()
 
int GetSymbolSize ()
 
int32_t GetItemHeight ()
 
C4MenuItemGetSelectedItem ()
 
C4MenuItemGetItem (int32_t iIndex)
 
virtual C4ObjectGetParentObject ()
 
bool MoveSelection (int32_t iBy, bool fAdjustPosition, bool fDoCalls)
 
bool SetSelection (int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
 
bool SetPosition (int32_t iPosition)
 
void SetSize (int32_t iToWdt, int32_t iToHgt)
 
bool Enter (bool fRight=false)
 
bool IsActive ()
 
bool IsActive (bool fForKeyboard)
 
bool Control (BYTE byCom, int32_t iData)
 
bool KeyControl (BYTE byCom)
 
bool AddRefSym (const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
 
bool Add (const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
 
bool Add (const char *szCaption, C4Object *pGfxObj, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
 
bool Add (const char *szCaption, C4DefGraphics *pGfx, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
 
void ClearItems ()
 
void ResetLocation ()
 
bool SetLocation (int32_t iX, int32_t iY)
 
bool SetTextProgress (int32_t iToProgress, bool fAdd)
 
void SetEqualItemHeight (bool fToVal)
 
bool TryClose (bool fOK, bool fControl)
 
void SetCloseCommand (const char *strCommand)
 
bool IsTextProgressing () const
 
void OnUserClose (C4GUI::Control *btn)
 
virtual void RemoveElement (Element *pChild)
 
virtual bool IsComponentOutsideClientArea ()
 
virtual void ApplyElementOffset (int32_t &riX, int32_t &riY)
 
virtual void ApplyInvElementOffset (int32_t &riX, int32_t &riY)
 
virtual bool IsFocused (Control *pCtrl)
 
void SetFocus (Control *pCtrl, bool fByMouse)
 
ControlGetFocus ()
 
virtual DialogGetDlg ()
 
virtual DialogWindow * GetDialogWindow ()
 
virtual bool CharIn (const char *c)
 
virtual void MouseInput (CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual class ControlGetDefaultControl ()
 
virtual bool OnEnter ()
 
bool KeyEnter ()
 
virtual bool OnEscape ()
 
bool KeyEscape ()
 
void AdvanceFocus (bool fBackwards)
 
bool KeyAdvanceFocus (bool fBackwards)
 
virtual int32_t GetMarginTop ()
 
bool IsShown ()
 
bool IsOK ()
 
bool IsAborted ()
 
bool IsFading ()
 
virtual bool IsFullscreenDialog ()
 
virtual bool HasBackground ()
 
virtual bool IsFreePlaceDialog ()
 
virtual bool IsBottomPlacementDialog ()
 
virtual bool IsExclusiveDialog ()
 
bool IsViewportDialog ()
 
virtual bool DoPlacement (Screen *pOnScreen, const C4Rect &rPreferredDlgRect)
 
bool Show (Screen *pOnScreen, bool fCB)
 
void Close (bool fOK)
 
bool FadeIn (Screen *pOnScreen)
 
void FadeOut (bool fCloseWithOK)
 
bool DoModal ()
 
bool Execute2 ()
 
void SetDelOnClose (bool fToVal=true)
 
void SetTitle (const char *szToTitle, bool fShowCloseButton=true)
 
void SetFrameDeco (FrameDecoration *pNewDeco)
 
void ClearFrameDeco ()
 
FrameDecoration * GetFrameDecoration () const
 
void SetClientSize (int32_t iToWdt, int32_t iToHgt)
 
virtual void OnClosed (bool fOK)
 
virtual void OnShown ()
 
virtual void OnIdle ()
 
virtual ContextHandler * GetContextHandler ()
 
void SetPos (int32_t iXPos, int32_t iYPos)
 
virtual C4RectGetClientRect ()
 
void ClearChildren ()
 
void MakeLastElement (Element *pChild)
 
void AddElement (Element *pChild)
 
void ReaddElement (Element *pChild)
 
void InsertElement (Element *pChild, Element *pInsertBefore)
 
ElementGetNextNestedElement (Element *pPrevElement, bool fBackwards)
 
virtual ElementGetFirstContained ()
 
virtual ElementGetLastContained ()
 
virtual ElementGetFirstNestedElement (bool fBackwards)
 
Iterator begin ()
 
Iterator end ()
 
ReverseIterator rbegin ()
 
ReverseIterator rend ()
 
ElementGetFirst ()
 
ElementGetLast ()
 
virtual ContainerGetContainer ()
 
ElementGetElementByIndex (int32_t i)
 
int32_t GetElementCount ()
 
virtual void SetVisibility (bool fToValue)
 
virtual bool IsSelectedChild (Element *pChild)
 
virtual bool IsParentOf (Element *pEl)
 
virtual void MouseEnter (CMouse &rMouse)
 
virtual void MouseLeave (CMouse &rMouse)
 
virtual void StartDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual void DoDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
virtual void StopDragging (CMouse &rMouse, int32_t iX, int32_t iY, DWORD dwKeyParam)
 
bool DoContext ()
 
ContainerGetParent ()
 
virtual ScreenGetScreen ()
 
virtual ControlIsFocusElement ()
 
void ScreenPos2ClientPos (int32_t &riX, int32_t &riY)
 
void ClientPos2ScreenPos (int32_t &riX, int32_t &riY)
 
void SetToolTip (const char *szNewTooltip, bool is_immediate=false)
 
const char * GetToolTip ()
 
const char * GetOwnToolTip ()
 
bool IsImmediateToolTip () const
 
int32_t GetWidth ()
 
int32_t GetHeight ()
 
C4RectGetBounds ()
 
void SetBounds (const C4Rect &rcNewBound)
 
C4Rect GetContainedClientRect ()
 
ElementGetNext () const
 
ElementGetPrev () const
 
bool IsInActiveDlg (bool fForKeyboard)
 
C4Rect GetToprightCornerRect (int32_t iWidth=16, int32_t iHeight=16, int32_t iHIndent=4, int32_t iVIndent=4, int32_t iIndexX=0)
 
bool IsVisible ()
 
virtual int32_t GetListItemTopSpacing ()
 
virtual bool GetListItemTopSpacingBar ()
 
void SetDragTarget (Window *pToWindow)
 
void SetContextHandler (ContextHandler *pNewHd)
 

Static Public Member Functions

static int32_t GetDefaultTitleHeight ()
 

Public Attributes

bool fVisible
 

Protected Member Functions

virtual bool MenuCommand (const char *szCommand, bool fIsCloseCommand)
 
virtual bool DoRefillInternal (bool &rfRefilled)
 
virtual void OnSelectionChanged (int32_t iNewSelection)
 
virtual void OnUserSelectItem (int32_t Player, int32_t iIndex)
 
virtual void OnUserEnter (int32_t Player, int32_t iIndex, bool fRight)
 
virtual void OnUserClose ()
 
virtual int32_t GetControllingPlayer ()
 
bool DoInitRefSym (const C4Facet &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
 
bool DoInit (C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
 
void DrawBuffer (C4Facet &cgo)
 
void AdjustSelection ()
 
void AdjustPosition ()
 
bool CheckBuffer ()
 
bool RefillInternal ()
 
void DrawButton (C4Facet &cgo)
 
void DrawScrollbar (C4Facet &cgo, int32_t iTotal, int32_t iVisible, int32_t iPosition)
 
void DrawFrame (C4Surface *sfcSurface, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt)
 
void InitLocation (C4Facet &cgo)
 
void InitSize ()
 
void UpdateScrollBar ()
 
void UserSelectItem (int32_t Player, C4MenuItem *pItem)
 
void UserEnter (int32_t Player, C4MenuItem *pItem, bool fRight)
 
bool HasMouse ()
 
virtual bool IsCloseDenied ()
 
virtual bool IsReadOnly ()
 
virtual const char * GetID ()
 
bool HasPortrait ()
 
virtual C4ViewportGetViewport ()
 
virtual bool IsExternalDrawDialog ()
 
virtual bool IsMouseControlled ()
 
virtual void UpdateOwnPos ()
 
void UpdateElementPositions ()
 
virtual int32_t GetZOrdering ()
 
virtual void Draw (C4TargetFacet &cgo)
 
virtual void DrawElement (C4TargetFacet &cgo)
 
virtual bool IsOwnPtrElement ()
 
virtual void UserClose (bool fOK)
 
virtual int32_t GetMarginBottom ()
 
virtual int32_t GetMarginLeft ()
 
virtual int32_t GetMarginRight ()
 
bool CreateConsoleWindow ()
 
void DestroyConsoleWindow ()
 
virtual void UpdateSize ()
 
virtual void UpdatePos ()
 
virtual void ElementSizeChanged (Element *pOfElement)
 
virtual void ElementPosChanged (Element *pOfElement)
 
virtual void AfterElementRemoval ()
 
virtual bool OnHotkey (uint32_t cHotkey)
 
void Draw3DFrame (C4TargetFacet &cgo, bool fUp=false, int32_t iIndent=1, BYTE byAlpha=C4GUI_BorderAlpha, bool fDrawTop=true, int32_t iTopOff=0, bool fDrawLeft=true, int32_t iLeftOff=0)
 
void DrawBar (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawVBar (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawHBarByVGfx (C4TargetFacet &cgo, DynBarFacet &rFacets)
 
void DrawHVBar (C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
 
virtual bool IsMenu ()
 
virtual bool CheckNameHotkey (const char *)
 

Protected Attributes

int32_t Player
 
bool LocationSet
 
bool Permanent
 
bool NeedRefill
 
int32_t Style
 
int32_t Selection
 
int32_t TimeOnSelection
 
int32_t ItemCount
 
int32_t ItemWidth
 
int32_t ItemHeight
 
int32_t Extra
 
int32_t ExtraData
 
int32_t Identification
 
int32_t Columns
 
int32_t Lines
 
int32_t Alignment
 
int32_t VisibleCount
 
StdStrBuf CloseCommand
 
char Caption [C4MaxTitle+1]
 
C4FacetSurface Symbol
 
C4GUI::ScrollWindowpClientWindow
 
bool fHasPortrait
 
bool fTextProgressing
 
bool fEqualIconItemHeight
 
bool fActive
 
WoodenLabel * pTitle
 
CallbackButton< Dialog,
C4GUI::IconButton > * 
pCloseBtn
 
ControlpActiveCtrl
 
bool fShow
 
bool fOK
 
int32_t iFade
 
Fade eFade
 
bool fDelOnClose
 
StdStrBuf TitleString
 
bool fViewportDlg
 
DialogWindow * pWindow
 
FrameDecoration * pFrameDeco
 
C4Rect rcClientRect
 
ElementpFirst
 
ElementpLast
 
ContainerpParent
 
ElementpPrev
 
ElementpNext
 
WindowpDragTarget
 
int32_t iDragX
 
int32_t iDragY
 
bool fDragging
 
ContextHandler * pContextHandler
 
C4Rect rcBounds
 

Detailed Description

Definition at line 33 of file C4MainMenu.h.

Constructor & Destructor Documentation

C4MainMenu::C4MainMenu ( )

Definition at line 39 of file C4MainMenu.cpp.

References C4Menu::Clear().

39  : C4Menu() // will be re-adjusted later
40 {
41  Clear();
42 }
C4Menu()
Definition: C4Menu.cpp:238
void Clear()
Definition: C4Menu.cpp:272

Here is the call graph for this function:

Member Function Documentation

bool C4MainMenu::ActivateClient ( int32_t  iPlayer)

Definition at line 491 of file C4MainMenu.cpp.

References C4Menu::Add(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Style_Context, C4SymbolSize, C4FacetSurface::Create(), C4GUI::Icon::GetIconFacet(), GfxR, C4GUI::Ico_Disconnect, InitRefSym(), LoadResStr(), C4Menu::SetAlignment(), and C4Menu::SetCloseCommand().

Referenced by MenuCommand().

492 {
493  // Menu symbol/init
494  C4FacetSurface fctSymbol;
495  InitRefSym(C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), LoadResStr("IDS_MENU_DISCONNECTFROMSERVER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
497  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
498  Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Part");
499  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
500  Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
501  SetCloseCommand("ActivateMenu:Main");
502  return true;
503 }
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
const int C4SymbolSize
Definition: C4Constants.h:58
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateCommand ( int32_t  iPlayer,
const char *  szCommand 
)

Definition at line 866 of file C4MainMenu.cpp.

References MenuCommand(), and Player.

Referenced by C4Game::ActivateMenu().

867 {
868  // init menu for player and activate with command
869  Player = iPlayer;
870  return MenuCommand(szCommand, false);
871 }
virtual bool MenuCommand(const char *szCommand, bool fIsCloseCommand)
Definition: C4MainMenu.cpp:654
int32_t Player
Definition: C4MainMenu.h:41

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateDisplay ( int32_t  iPlayer,
int32_t  selection = 0 
)

Definition at line 538 of file C4MainMenu.cpp.

References C4Menu::AddRefSym(), Application, C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Item_NoCount, C4MN_Style_Context, Config, C4ConfigGeneral::FPS, C4Config::General, GfxR, C4Config::Graphics, InitRefSym(), C4Application::isEditor, LoadResStr(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), C4Menu::SetPermanent(), C4Menu::SetSelection(), C4ConfigGraphics::ShowClock, C4ConfigGraphics::ShowCrewCNames, C4ConfigGraphics::ShowCrewNames, and C4ConfigGraphics::UpperBoard.

Referenced by MenuCommand().

539 {
540  // Menu symbol/init
541  InitRefSym(GfxR->fctMenu.GetPhase(8), LoadResStr("IDS_MENU_DISPLAY"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
543  SetPermanent(true);
544  // Crew player names
545  AddRefSym(LoadResStr("IDS_MNU_PLAYERNAMES"), GfxR->fctOptions.GetPhase(7 + Config.Graphics.ShowCrewNames), "Display:PlayerNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_PLAYERNAMES_DESC"));
546  // Crew clonk names
547  AddRefSym(LoadResStr("IDS_MNU_CLONKNAMES"), GfxR->fctOptions.GetPhase(9 + Config.Graphics.ShowCrewCNames), "Display:ClonkNames", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CLONKNAMES_DESC"));
548  // Upper Board
549  if (!Application.isEditor)
550  {
551  AddRefSym(LoadResStr("IDS_MNU_UPPERBOARD"),GfxR->fctOptions.GetPhase(3 + Config.Graphics.UpperBoard),"Display:UpperBoard",C4MN_Item_NoCount);
552  }
553  // FPS
554  if (!Application.isEditor)
555  AddRefSym(LoadResStr("IDS_MNU_FPS"), GfxR->fctOptions.GetPhase(5 + Config.General.FPS), "Display:FPS", C4MN_Item_NoCount);
556  // Clock
557  if (!Application.isEditor)
558  AddRefSym(LoadResStr("IDS_MNU_CLOCK"), GfxR->fctOptions.GetPhase(15 + Config.Graphics.ShowClock), "Display:Clock", C4MN_Item_NoCount);
559  // Restore selection
560  SetSelection(selection, false, true);
561  // Go back to options menu on close
562  SetCloseCommand("ActivateMenu:Options");
563  // Done
564  return true;
565 }
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
C4Config Config
Definition: C4Config.cpp:831
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
int32_t FPS
Definition: C4Config.h:47
C4ConfigGeneral General
Definition: C4Config.h:252
int32_t ShowCrewNames
Definition: C4Config.h:108
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
int32_t UpperBoard
Definition: C4Config.h:102
C4ConfigGraphics Graphics
Definition: C4Config.h:254
int32_t ShowCrewCNames
Definition: C4Config.h:109
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
C4Application Application
Definition: C4Globals.cpp:44
int32_t ShowClock
Definition: C4Config.h:103

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateGoals ( int32_t  iPlayer,
bool  fDoActivate 
)

Definition at line 305 of file C4MainMenu.cpp.

References C4Menu::Add(), C4Id2Def(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Item_NoCount, C4SymbolSize, C4FacetSurface::Create(), C4Facet::Draw(), C4Def::Draw(), C4RoundResults::EvaluateGoals(), C4GraphicsResource::fctCaptain, StdStrBuf::Format(), StdStrBuf::getData(), C4IDList::GetID(), C4IDList::GetIDCount(), C4PropListStatic::GetName(), C4IDList::GetNumberOfIDs(), GfxR, GraphicsResource, C4Facet::Hgt, InitRefSym(), LoadResStr(), C4Facet::Set(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), C4Menu::SetPermanent(), C4Facet::Surface, C4ID::ToString(), and C4Facet::Wdt.

306 {
307  C4FacetSurface fctSymbol;
308  C4Facet fctGF; // goal fulfilled facet
309 
310  if (fDoActivate)
311  {
312  // Menu symbol/init
313  InitRefSym(GfxR->fctMenu.GetPhase(4),LoadResStr("IDS_MENU_CPGOALS"),iPlayer);
315  SetPermanent(false);
317  }
318  // determine if the goals are fulfilled - do the calls even if the menu is not to be opened to ensure synchronization
319  C4IDList GoalList, FulfilledGoalList;
320  C4RoundResults::EvaluateGoals(GoalList, FulfilledGoalList, iPlayer);
321  // Add Items
322  if (fDoActivate)
323  {
324  int32_t iNumGoals = GoalList.GetNumberOfIDs(), cnt;
325  C4ID idGoal; C4Def *pDef;
326  for (int32_t i=0; i<iNumGoals; ++i)
327  if ((idGoal = GoalList.GetID(i, &cnt)))
328  if ((pDef = C4Id2Def(idGoal)))
329  {
330  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
331  // 2do: If an object instance is known, draw the object instead?
332  // this would allow us to do dynamic pictures and overlays; e.g. draw the actual, required settlement score
333  // for settlement score goals
334  // Same for pDef->GetName(), pDef->GetDesc()
335  pDef->Draw(fctSymbol);
336  if (FulfilledGoalList.GetIDCount(idGoal))
337  {
338  fctGF.Surface=fctSymbol.Surface;
340  }
341  StdStrBuf Command; Command.Format("Player:Goal:%s", idGoal.ToString());
342  Add(pDef->GetName(),fctSymbol,Command.getData(),C4MN_Item_NoCount,nullptr,"");
343  }
344  // Go back to options menu on close
345  SetCloseCommand("ActivateMenu:Main");
346  }
347  // Done
348  return true;
349 }
const char * getData() const
Definition: StdBuf.h:450
int32_t GetIDCount(C4ID c_id, int32_t iZeroDefVal=0) const
Definition: stub-handle.cpp:67
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
virtual const char * GetName() const
Definition: C4PropList.cpp:267
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
static void EvaluateGoals(C4IDList &GoalList, C4IDList &FulfilledGoalList, int32_t iPlayerNumber)
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
void Set(C4Surface &rSfc)
Definition: C4Facet.cpp:459
C4GraphicsResource GraphicsResource
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:601
Definition: C4Def.h:100
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
Definition: C4Id.h:28
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
const int C4SymbolSize
Definition: C4Constants.h:58
float Hgt
Definition: C4Facet.h:120
const char * ToString() const
Definition: C4Id.h:62
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
C4Surface * Surface
Definition: C4Facet.h:119
C4ID GetID(size_t index, int32_t *ipCount=nullptr) const
Definition: C4IDList.cpp:99
int32_t GetNumberOfIDs() const
Definition: C4IDList.cpp:197
float Wdt
Definition: C4Facet.h:120

Here is the call graph for this function:

bool C4MainMenu::ActivateHost ( int32_t  iPlayer)

Definition at line 470 of file C4MainMenu.cpp.

References C4Menu::AddRefSym(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Style_Context, C4Network2::Clients, fHost, StdStrBuf::Format(), StdStrBuf::getData(), C4GUI::Icon::GetIconFacet(), C4Network2ClientList::GetNextClient(), C4GUI::Ico_Client, C4GUI::Ico_Disconnect, C4GUI::Ico_Host, C4GUI::Ico_ObserverClient, InitRefSym(), LoadResStr(), Network, C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), and C4Menu::SetPermanent().

Referenced by MenuCommand().

471 {
472  // Menu symbol/init
475  SetPermanent(true);
476  // Clients
477  for (C4Network2Client *pClient=::Network.Clients.GetNextClient(nullptr); pClient; pClient=::Network.Clients.GetNextClient(pClient))
478  {
479  bool fHost = (pClient->getID() == 0);
480  StdStrBuf strText, strCommand;
481  strText.Format("%s (%s)", pClient->getName(), pClient->getCore().getNick());
482  strCommand.Format("Host:Kick:%d", pClient->getID());
483  C4GUI::Icons iIcon = fHost ? C4GUI::Ico_Host : (pClient->isActivated() ? C4GUI::Ico_Client : C4GUI::Ico_ObserverClient);
484  AddRefSym(strText.getData(), C4GUI::Icon::GetIconFacet(iIcon), strCommand.getData());
485  }
486  // Go back to options menu on close
487  SetCloseCommand("ActivateMenu:Main");
488  return true;
489 }
const char * getData() const
Definition: StdBuf.h:450
bool fHost
Definition: TstC4NetIO.cpp:34
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
C4Network2Client * GetNextClient(C4Network2Client *pClient)
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Network2 Network
Definition: C4Globals.cpp:53
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
Icons
Definition: C4Gui.h:637
C4Network2ClientList Clients
Definition: C4Network2.h:116
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateHostility ( int32_t  iPlayer)

Definition at line 639 of file C4MainMenu.cpp.

References C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Hostility, C4SymbolSize, C4FacetSurface::Create(), GfxR, Init(), LoadResStr(), C4Menu::Refill(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), and C4Menu::SetPermanent().

Referenced by MenuCommand().

640 {
641  // Init menu
642  C4FacetSurface fctSymbol;
643  fctSymbol.Create(C4SymbolSize, C4SymbolSize);
644  GfxR->fctMenu.GetPhase(7).Draw(fctSymbol);
645  Init(fctSymbol, LoadResStr("IDS_MENU_CPATTACK"), iPlayer, C4MN_Extra_None, 0, C4MN_Hostility);
647  SetPermanent(true);
648  Refill();
649  // Go back to options menu on close
650  SetCloseCommand("ActivateMenu:Main");
651  return true;
652 }
bool Refill()
Definition: C4Menu.cpp:918
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:50
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const int C4SymbolSize
Definition: C4Constants.h:58
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateMain ( int32_t  iPlayer)

Definition at line 567 of file C4MainMenu.cpp.

References C4Menu::AddRefSym(), Application, C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Item_NoCount, C4MN_Style_Context, C4SymbolSize, C4Game::Clients, C4GUI::Dialog::Close(), C4FacetSurface::Create(), Game, C4PlayerList::Get(), C4ClientList::getClient(), C4PlayerList::GetCount(), C4GUI::Icon::GetIconFacet(), C4Menu::GetItemCount(), GfxR, C4GUI::Ico_Disconnect, C4GUI::Ico_Exit, C4GUI::Ico_Surrender, C4GUI::Ico_Team, C4GUI::Ico_View, Init(), C4Application::isEditor, C4Network2::isEnabled(), C4Network2::isHost(), C4GameParameters::isLeague(), C4TeamList::IsTeamSwitchAllowed(), LoadResStr(), C4GameParameters::MaxPlayers, Network, C4Game::Parameters, Players, C4Menu::SetAlignment(), and C4Game::Teams.

Referenced by C4FullScreen::ActivateMenuMain(), C4Player::ActivateMenuMain(), and MenuCommand().

568 {
569  // Determine player
570  C4Player *pPlr = ::Players.Get(iPlayer);
571  // Menu symbol/init
572  C4FacetSurface fctSymbol;
573  fctSymbol.Create(C4SymbolSize, C4SymbolSize);
574  GfxR->fctOKCancel.Draw(fctSymbol, true, 1, 1);
575  Init(fctSymbol, LoadResStr(pPlr ? "IDS_MENU_CPMAIN" : "IDS_MENU_OBSERVER"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
577  // Goals+Rules (player menu only)
578  // Goal menu can't be shown because of script callbacks
579  // Rule menu could be shown, but rule activation would issue script callbacks and trigger client activation
580  // Showing rules but not showing goals would be strange anyway
581  if (pPlr)
582  {
583  // Goals
584  AddRefSym(LoadResStr("IDS_MENU_CPGOALS"),GfxR->fctMenu.GetPhase(4),"ActivateMenu:Goals",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPGOALSINFO"));
585  // Rules
586  AddRefSym(LoadResStr("IDS_MENU_CPRULES"),GfxR->fctMenu.GetPhase(5),"ActivateMenu:Rules",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPRULESINFO"));
587  }
588  // Observer menu in free viewport
589  if (!pPlr)
590  {
591  AddRefSym(LoadResStr("IDS_TEXT_VIEW"),C4GUI::Icon::GetIconFacet(C4GUI::Ico_View),"ActivateMenu:Observer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_TEXT_DETERMINEPLAYERVIEWTOFOLL"));
592  }
593  // Hostility (player menu only)
594  if (pPlr && (::Players.GetCount() > 1))
595  {
596  GfxR->fctFlagClr.Surface->SetClr(0xff0000);
597  AddRefSym(LoadResStr("IDS_MENU_CPATTACK"),GfxR->fctMenu.GetPhase(7),"ActivateMenu:Hostility",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPATTACKINFO"));
598  }
599  // Team change
600  if (pPlr && Game.Teams.IsTeamSwitchAllowed())
601  {
602  C4Facet fctTeams; fctTeams = C4GUI::Icon::GetIconFacet(C4GUI::Ico_Team);
603  AddRefSym(LoadResStr("IDS_MSG_SELTEAM"),fctTeams,"ActivateMenu:TeamSel",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MSG_ALLOWSYOUTOJOINADIFFERENT"));
604  }
605  // Player join
607  {
608  AddRefSym(LoadResStr("IDS_MENU_CPNEWPLAYER"),GfxR->fctPlayerClr.GetPhase(),"ActivateMenu:NewPlayer",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPNEWPLAYERINFO"));
609  }
610  // Save game (player menu only - should we allow saving games with no players in it?)
611  if (pPlr && (!::Network.isEnabled() || ::Network.isHost()))
612  {
613  AddRefSym(LoadResStr("IDS_MENU_CPSAVEGAME"),GfxR->fctMenu.GetPhase(0),"ActivateMenu:Save:Game",C4MN_Item_NoCount,nullptr,LoadResStr("IDS_MENU_CPSAVEGAMEINFO"));
614  }
615  // Options
616  AddRefSym(LoadResStr("IDS_MNU_OPTIONS"), GfxR->fctOptions.GetPhase(0), "ActivateMenu:Options",C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MNU_OPTIONSINFO"));
617  // Disconnect
618  if (::Network.isEnabled())
619  {
620  // Host
621  if (::Network.isHost() && Game.Clients.getClient(nullptr))
622  AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Host", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_KICKCERTAINCLIENTSFROMTHE"));
623  // Client
624  if (!::Network.isHost())
625  AddRefSym(LoadResStr("IDS_MENU_DISCONNECT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Disconnect), "ActivateMenu:Client", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_TEXT_DISCONNECTTHEGAMEFROMTHES"));
626  }
627  // Surrender (player menu only)
628  if (pPlr)
629  AddRefSym(LoadResStr("IDS_MENU_CPSURRENDER"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Surrender), "ActivateMenu:Surrender", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSURRENDERINFO"));
630  // Abort
631  if (!Application.isEditor)
632  AddRefSym(LoadResStr("IDS_MENU_ABORT"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Exit), "Abort", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_ABORT_DESC"));
633  // No empty menus
634  if (GetItemCount()==0) Close(false);
635  // Done
636  return true;
637 }
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
#define GfxR
bool isHost() const
Definition: C4Network2.h:209
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
C4Game Game
Definition: C4Globals.cpp:52
void Close(bool fOK)
int GetCount() const
C4GameParameters & Parameters
Definition: C4Game.h:69
bool Init(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:50
C4TeamList & Teams
Definition: C4Game.h:72
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4Player * Get(int iPlayer) const
bool IsTeamSwitchAllowed() const
Definition: C4Teams.h:166
C4Network2 Network
Definition: C4Globals.cpp:53
C4PlayerList Players
int32_t GetItemCount()
Definition: C4Menu.cpp:520
bool isEnabled() const
Definition: C4Network2.h:203
const int C4SymbolSize
Definition: C4Constants.h:58
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
C4ClientList & Clients
Definition: C4Game.h:71
bool isLeague() const
C4Client * getClient(const C4Client *pAfter=nullptr) const
Definition: C4Client.h:160
C4Application Application
Definition: C4Globals.cpp:44
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateNewPlayer ( int32_t  iPlayer)

Definition at line 64 of file C4MainMenu.cpp.

References _MAX_PATH, C4Menu::Add(), C4MN_Align_Bottom, C4MN_Align_Left, C4Game::C4S, C4Group::Close(), Config, C4FacetSurface::Default(), DirectoryExists(), C4PlayerList::FileInUse(), StdStrBuf::Format(), Game, C4Config::General, C4PlayerList::GetCount(), StdStrBuf::getData(), GfxR, C4Scenario::Head, InitRefSym(), C4GameParameters::isLeague(), C4PlayerInfoCore::Load(), LoadResStr(), C4GameParameters::MaxPlayers, C4Group::Open(), C4Game::Parameters, Players, C4PlayerInfoCore::PrefName, C4SHead::Replay, SCopy(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), sprintf, C4ConfigGeneral::UserDataPath, and WildcardMatch().

Referenced by MenuCommand().

65 {
66  // league or replay game
67  if (Game.Parameters.isLeague() || Game.C4S.Head.Replay) return false;
68  // Max player limit
69  if (::Players.GetCount() >= Game.Parameters.MaxPlayers) return false;
70 
71  // Menu symbol/init
72  if (GfxR->fctPlayerClr.Surface)
73  GfxR->fctPlayerClr.Surface->SetClr(0xff);
74  InitRefSym(GfxR->fctPlayerClr, LoadResStr("IDS_MENU_NOPLRFILES"), iPlayer);
75  for (DirectoryIterator iter(Config.General.UserDataPath); *iter; ++iter)
76  if (WildcardMatch("*.ocp", *iter))
77  {
78  char szFilename[_MAX_PATH+1], szCommand[_MAX_PATH+30+1];
79  SCopy(*iter, szFilename, _MAX_PATH);
80  if (DirectoryExists(szFilename)) continue;
81  if (::Players.FileInUse(szFilename)) continue;
82  // Open group
83  C4Group hGroup;
84  if (!hGroup.Open(szFilename)) continue;
85  // Load player info
86  C4PlayerInfoCore C4P;
87  if (!C4P.Load(hGroup)) { hGroup.Close(); continue; }
88  // Close group
89  hGroup.Close();
90  // Add player item
91  sprintf(szCommand, "JoinPlayer:%s", szFilename);
92  StdStrBuf sItemText;
93  sItemText.Format(LoadResStr("IDS_MENU_NEWPLAYER"), C4P.PrefName);
94  C4FacetSurface fctSymbol;
95  // Add menu item
96  Add(sItemText.getData(), fctSymbol, szCommand);
97  // Reset symbol facet (menu holds on to the surface)
98  fctSymbol.Default();
99  }
100 
101  // Alignment
103  // Go back to options menu on close
104  SetCloseCommand("ActivateMenu:Main");
105 
106  return true;
107 }
const char * getData() const
Definition: StdBuf.h:450
bool FileInUse(const char *szFilename) const
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
C4Config Config
Definition: C4Config.cpp:831
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
C4Game Game
Definition: C4Globals.cpp:52
C4Scenario C4S
Definition: C4Game.h:76
C4ConfigGeneral General
Definition: C4Config.h:252
#define sprintf
Definition: Standard.h:171
bool Replay
Definition: C4Scenario.h:72
char PrefName[C4MaxName+1]
Definition: C4InfoCore.h:86
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
#define _MAX_PATH
int GetCount() const
C4GameParameters & Parameters
Definition: C4Game.h:69
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Default()
Definition: C4FacetEx.h:43
bool Load(C4Group &hGroup)
Definition: C4InfoCore.cpp:81
char UserDataPath[CFG_MaxString+1]
Definition: C4Config.h:55
bool Open(const char *szGroupName, bool fCreate=false)
Definition: C4Group.cpp:514
C4PlayerList Players
bool Close()
Definition: C4Group.cpp:755
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
bool DirectoryExists(const char *szFilename)
Definition: StdFile.cpp:694
bool WildcardMatch(const char *szWildcard, const char *szString)
Definition: StdFile.cpp:384
bool isLeague() const
C4SHead Head
Definition: C4Scenario.h:230

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateObserver ( )

Definition at line 873 of file C4MainMenu.cpp.

References C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Observer, C4MN_Style_Context, C4GUI::Icon::GetIconFacet(), C4ViewportList::GetViewport(), C4GUI::Ico_View, InitRefSym(), LoadResStr(), NO_OWNER, C4Menu::Refill(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), and Viewports.

Referenced by MenuCommand().

874 {
875  // Safety: Viewport lost?
876  if (!::Viewports.GetViewport(NO_OWNER)) return false;
877  // Menu symbol/init
880  // Players added in Refill
881  Refill();
882  // Go back to main menu on close
883  SetCloseCommand("ActivateMenu:Main");
884  return true;
885 }
bool Refill()
Definition: C4Menu.cpp:918
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
const int NO_OWNER
Definition: C4Constants.h:138
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateOptions ( int32_t  iPlayer,
int32_t  selection = 0 
)

Definition at line 518 of file C4MainMenu.cpp.

References C4Menu::AddRefSym(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Item_NoCount, C4MN_Style_Context, Config, GfxR, InitRefSym(), LoadResStr(), C4ConfigSound::RXMusic, C4ConfigSound::RXSound, C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), C4Menu::SetPermanent(), C4Menu::SetSelection(), and C4Config::Sound.

Referenced by MenuCommand().

519 {
520  // Menu symbol/init
521  InitRefSym(GfxR->fctOptions.GetPhase(0), LoadResStr("IDS_MNU_OPTIONS"), iPlayer, C4MN_Extra_None, 0, 0, C4MN_Style_Context);
523  SetPermanent(true);
524  // Sound
525  AddRefSym(LoadResStr("IDS_DLG_SOUND"), GfxR->fctOptions.GetPhase(17 + Config.Sound.RXSound),"Options:Sound",C4MN_Item_NoCount);
526  // Music
527  AddRefSym(LoadResStr("IDS_MNU_MUSIC"), GfxR->fctOptions.GetPhase(1 + Config.Sound.RXMusic),"Options:Music",C4MN_Item_NoCount);
528  // Music
529  AddRefSym(LoadResStr("IDS_MENU_DISPLAY"), GfxR->fctMenu.GetPhase(8), "ActivateMenu:Display");
530  // Restore selection
531  SetSelection(selection, false, true);
532  // Go back to main menu on close
533  SetCloseCommand("ActivateMenu:Main");
534  // Done
535  return true;
536 }
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
C4Config Config
Definition: C4Config.cpp:831
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
int32_t RXSound
Definition: C4Config.h:127
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
C4ConfigSound Sound
Definition: C4Config.h:255
int32_t RXMusic
Definition: C4Config.h:128

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateRules ( int32_t  iPlayer)

Definition at line 351 of file C4MainMenu.cpp.

References C4Menu::Add(), C4D_Rule, C4Id2Def(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Item_NoCount, C4SymbolSize, C4FacetSurface::Create(), C4Def::Draw(), C4ObjectList::GetListID(), C4PropListStatic::GetName(), GfxR, InitRefSym(), LoadResStr(), Objects, C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), C4Menu::SetPermanent(), sprintf, and C4ID::ToString().

Referenced by MenuCommand().

352 {
353  // Menu symbol/init
354  char Command[256];
355  C4FacetSurface fctSymbol;
356  InitRefSym(GfxR->fctMenu.GetPhase(5),LoadResStr("IDS_MENU_CPRULES"),iPlayer);
358  SetPermanent(false);
359  // Items
360  int32_t cnt; C4ID idGoal; C4Def *pDef;
361  for (cnt=0; (idGoal=::Objects.GetListID(C4D_Rule,cnt)); cnt++)
362  if ((pDef=C4Id2Def(idGoal)))
363  {
364  fctSymbol.Create(C4SymbolSize,C4SymbolSize); pDef->Draw(fctSymbol);
365  sprintf(Command, "Player:Rule:%s", idGoal.ToString());
366  Add(pDef->GetName(),fctSymbol,Command,C4MN_Item_NoCount,nullptr,"");
367  }
368  // Go back to options menu on close
369  SetCloseCommand("ActivateMenu:Main");
370  // Done
371  return true;
372 }
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
virtual const char * GetName() const
Definition: C4PropList.cpp:267
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
#define sprintf
Definition: Standard.h:171
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Draw(C4Facet &cgo, bool fSelected=false, DWORD iColor=0, C4Object *pObj=nullptr, int32_t iPhaseX=0, int32_t iPhaseY=0, C4DrawTransform *trans=nullptr, const char *graphicsName=nullptr)
Definition: C4Def.cpp:601
Definition: C4Def.h:100
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
const int32_t C4D_Rule
Definition: C4Def.h:49
Definition: C4Id.h:28
C4ID GetListID(int32_t dwCategory, int Index) const
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
const int C4SymbolSize
Definition: C4Constants.h:58
const char * ToString() const
Definition: C4Id.h:62
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
C4GameObjects Objects
Definition: C4Globals.cpp:48

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateSavegame ( int32_t  iPlayer)

Definition at line 389 of file C4MainMenu.cpp.

References _MAX_PATH, C4Menu::AddRefSym(), C4Config::AtUserDataPath(), C4CFN_Savegames, C4Group_IsGroup(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Item_NoCount, C4Game::CanQuickSave(), Config, DirectorySeparator, StdStrBuf::Format(), Game, StdStrBuf::getData(), GetFilename(), GetFilenameOnly(), C4Group::GetName(), GfxR, InitRefSym(), LoadResStr(), LooksLikeInteger(), C4Game::pParentGroup, RemoveExtension(), C4Game::ScenarioFilename, C4Game::ScenarioTitle, SCopy(), C4Menu::SetAlignment(), C4Menu::SetCloseCommand(), C4Menu::SetPermanent(), and SLen().

Referenced by MenuCommand().

390 {
391  // Check if saving is possible
392  if (!Game.CanQuickSave()) return false;
393 
394  // Menu symbol/init
395  char DirPath[_MAX_PATH+1];
396  char ScenName[_MAX_PATH+1]; *ScenName=0;
397 
398  InitRefSym(GfxR->fctMenu.GetPhase(0), LoadResStr("IDS_MENU_CPSAVEGAME"), iPlayer);
400  SetPermanent(true);
401 
402  // target file name mask
403  // get folder & filename to store in
404  // some magic is needed to ensure savegames are stored properly into their folders
406  if (DirPath[strlen(DirPath) - 1] == '\\') DirPath[strlen(DirPath) - 1] = 0;
407  RemoveExtension(DirPath);
408  if (LooksLikeInteger(DirPath))
409  {
410  // ScenTitle.ocf\%d.ocs-names (old-style savegames)
411  // get owning folder
412  if (Game.pParentGroup)
413  {
414  // owning folder determines filename
416  }
417  else
418  {
419  // no owning folder known: too bad
420  // make a vague guess based on the scenario title
422  }
423  }
424  else
425  {
426  // DirPath is a valid filename for now...
427  SCopy(DirPath, ScenName);
428  // but remove trailing numbers to adjust new-style savegames
429  char *pScenNameEnd = ScenName+SLen(ScenName);
430  while (Inside<char>(*--pScenNameEnd, '0', '9'))
431  if (pScenNameEnd == ScenName)
432  {
433  // should not happen: digit-only-filenames should have been caught earlier
434  SCopy("dbg_error!", ScenName);
435  pScenNameEnd = ScenName+SLen(ScenName)-1;
436  }
437  pScenNameEnd[1]=0;
438  }
439 
440  // New Style 2007:
441  // * scenarios are saved into ScenName.ocf/ScenName123.ocs to keep umlauts out of filenames
442  // * language titles are stored in folders as title component
443  StdStrBuf strFilename, strTitle;
444  strFilename.Format("%s.ocf%c%s%%d.ocs", ScenName, DirectorySeparator, ScenName);
445  strTitle = Game.ScenarioTitle;
446 
447  // Create menu items
448  StdStrBuf strFilenameIndexed, strCommand, strCaption, strSavePath;
449  for (int32_t i = 1; i <= 10; i++)
450  {
451  // Index filename
452  strFilenameIndexed.Format(strFilename.getData(), i);
453  // Compose commmand
454  strCommand.Format("Save:Game:%s:%s", strFilenameIndexed.getData(), strTitle.getData()); // Notice: the language title might contain ':' and thus confuse the segment list - but C4Menu::MenuCommand will try to handle this...
455  // Check free slot
456  strSavePath.Format("%s%c%s", Config.AtUserDataPath(C4CFN_Savegames), DirectorySeparator, strFilenameIndexed.getData());
457  bool fFree = !C4Group_IsGroup(strSavePath.getData());
458  // Item caption
459  strCaption = LoadResStr("IDS_MENU_CPSAVEGAME");
460  // add menu item
461  AddRefSym(strCaption.getData(), GfxR->fctMenu.GetPhase(i - 1, fFree ? 2 : 1), strCommand.getData(), C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MENU_CPSAVEGAMEINFO"));
462  }
463 
464  // Go back to options menu on close
465  SetCloseCommand("ActivateMenu:Main");
466 
467  return true;
468 }
char * GetFilename(char *szPath)
Definition: StdFile.cpp:55
const char * getData() const
Definition: StdBuf.h:450
C4Group * pParentGroup
Definition: C4Game.h:90
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
char ScenarioFilename[_MAX_PATH+1]
Definition: C4Game.h:104
C4Config Config
Definition: C4Config.cpp:831
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
C4Game Game
Definition: C4Globals.cpp:52
StdCopyStrBuf ScenarioTitle
Definition: C4Game.h:105
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
#define _MAX_PATH
const char * GetFilenameOnly(const char *strFilename)
Definition: StdFile.cpp:70
size_t SLen(const char *sptr)
Definition: Standard.h:78
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool LooksLikeInteger(const char *szInt)
Definition: C4MainMenu.cpp:374
const char * GetName() const
Definition: C4Group.cpp:1845
bool C4Group_IsGroup(const char *szFilename)
Definition: C4Group.cpp:94
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
bool CanQuickSave()
Definition: C4Game.cpp:1934
void RemoveExtension(char *szFilename)
Definition: StdFile.cpp:316
const char * AtUserDataPath(const char *szFilename)
Definition: C4Config.cpp:524
void SetPermanent(bool fPermanent)
Definition: C4Menu.cpp:865
#define C4CFN_Savegames
Definition: C4Components.h:35
#define DirectorySeparator

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::ActivateSurrender ( int32_t  iPlayer)

Definition at line 505 of file C4MainMenu.cpp.

References C4Menu::Add(), C4MN_Align_Bottom, C4MN_Align_Left, C4MN_Extra_None, C4MN_Style_Context, C4SymbolSize, C4FacetSurface::Create(), C4GUI::Icon::GetIconFacet(), GfxR, C4GUI::Ico_Surrender, InitRefSym(), LoadResStr(), C4Menu::SetAlignment(), and C4Menu::SetCloseCommand().

Referenced by MenuCommand().

506 {
507  C4FacetSurface fctSymbol;
510  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,3,0);
511  Add(LoadResStr("IDS_BTN_YES"), fctSymbol, "Surrender");
512  fctSymbol.Create(C4SymbolSize, C4SymbolSize); GfxR->fctOKCancel.Draw(fctSymbol,true,1,0);
513  Add(LoadResStr("IDS_BTN_NO"), fctSymbol, "");
514  SetCloseCommand("ActivateMenu:Main");
515  return true;
516 }
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
#define GfxR
void SetCloseCommand(const char *strCommand)
Definition: C4Menu.cpp:1147
void SetAlignment(int32_t iAlignment)
Definition: C4Menu.cpp:860
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
bool InitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iPlayer, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4MainMenu.cpp:57
const int C4SymbolSize
Definition: C4Constants.h:58
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
static C4Facet GetIconFacet(Icons icoIconIndex)

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::Add ( const char *  szCaption,
C4FacetSurface fctSymbol,
const char *  szCommand,
int32_t  iCount = C4MN_Item_NoCount,
C4Object pObject = nullptr,
const char *  szInfoCaption = nullptr,
C4ID  idID = C4ID::None,
const char *  szCommand2 = nullptr,
bool  fOwnValue = false,
int32_t  iValue = 0,
bool  fIsSelectable = true 
)
inherited

Definition at line 351 of file C4Menu.cpp.

References C4Menu::C4MenuItem, C4MenuItem::GrabSymbol(), C4Menu::IsActive(), C4Menu::ItemCount, and C4Menu::Style.

Referenced by ActivateClient(), ActivateGoals(), C4Object::ActivateMenu(), ActivateNewPlayer(), ActivateRules(), ActivateSurrender(), DoRefillInternal(), and C4ObjectMenu::DoRefillInternal().

354 {
355  if (!IsActive()) return false;
356  // Create new menu item
357  C4MenuItem *pNew = new C4MenuItem(this, ItemCount, szCaption,szCommand,iCount,pObject,szInfoCaption,idID,szCommand2,fOwnValue,iValue,Style,fIsSelectable);
358  // Set Symbol
359  pNew->GrabSymbol(fctSymbol);
360  // Add
361  return AddItem(pNew, szCaption, szCommand, iCount, pObject, szInfoCaption, idID, szCommand2, fOwnValue, iValue, fIsSelectable);
362 }
friend class C4MenuItem
Definition: C4Menu.h:263
int32_t Style
Definition: C4Menu.h:136
int32_t ItemCount
Definition: C4Menu.h:138
bool IsActive()
Definition: C4Menu.cpp:483
void GrabSymbol(C4FacetSurface &fctSymbol)
Definition: C4Menu.h:102

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::Add ( const char *  szCaption,
C4Object pGfxObj,
const char *  szCommand,
int32_t  iCount = C4MN_Item_NoCount,
C4Object pObject = nullptr,
const char *  szInfoCaption = nullptr,
C4ID  idID = C4ID::None,
const char *  szCommand2 = nullptr,
bool  fOwnValue = false,
int32_t  iValue = 0,
bool  fIsSelectable = true 
)
inherited

Definition at line 364 of file C4Menu.cpp.

References C4Menu::C4MenuItem, C4Menu::IsActive(), C4Menu::ItemCount, C4MenuItem::SetGraphics(), and C4Menu::Style.

367 {
368  if (!IsActive()) return false;
369  // Create new menu item
370  C4MenuItem *pNew = new C4MenuItem(this, ItemCount, szCaption,szCommand,iCount,pObject,szInfoCaption,idID,szCommand2,fOwnValue,iValue,Style,fIsSelectable);
371  // Set Symbol
372  pNew->SetGraphics(pGfxObj);
373  // Add
374  return AddItem(pNew, szCaption, szCommand, iCount, pObject, szInfoCaption, idID, szCommand2, fOwnValue, iValue, fIsSelectable);
375 }
friend class C4MenuItem
Definition: C4Menu.h:263
int32_t Style
Definition: C4Menu.h:136
int32_t ItemCount
Definition: C4Menu.h:138
void SetGraphics(C4Object *pObj)
Definition: C4Menu.h:103
bool IsActive()
Definition: C4Menu.cpp:483

Here is the call graph for this function:

bool C4Menu::Add ( const char *  szCaption,
C4DefGraphics pGfx,
const char *  szCommand,
int32_t  iCount = C4MN_Item_NoCount,
C4Object pObject = nullptr,
const char *  szInfoCaption = nullptr,
C4ID  idID = C4ID::None,
const char *  szCommand2 = nullptr,
bool  fOwnValue = false,
int32_t  iValue = 0,
bool  fIsSelectable = true 
)
inherited

Definition at line 377 of file C4Menu.cpp.

References C4Menu::C4MenuItem, C4Menu::IsActive(), C4Menu::ItemCount, C4MenuItem::SetGraphics(), and C4Menu::Style.

380 {
381  if (!IsActive()) return false;
382  // Create new menu item
383  C4MenuItem *pNew = new C4MenuItem(this, ItemCount, szCaption,szCommand,iCount,pObject,szInfoCaption,idID,szCommand2,fOwnValue,iValue,Style,fIsSelectable);
384  // Set Symbol
385  pNew->SetGraphics(pGfx);
386  // Add
387  return AddItem(pNew, szCaption, szCommand, iCount, pObject, szInfoCaption, idID, szCommand2, fOwnValue, iValue, fIsSelectable);
388 }
friend class C4MenuItem
Definition: C4Menu.h:263
int32_t Style
Definition: C4Menu.h:136
int32_t ItemCount
Definition: C4Menu.h:138
void SetGraphics(C4Object *pObj)
Definition: C4Menu.h:103
bool IsActive()
Definition: C4Menu.cpp:483

Here is the call graph for this function:

void C4GUI::Container::AddElement ( Element pChild)
inherited

Definition at line 118 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, C4GUI::Element::pPrev, and C4GUI::Container::RemoveElement().

Referenced by C4GUI::Tabular::AddCustomSheet(), C4GUI::ListBox::AddElement(), C4ChartDialog::C4ChartDialog(), C4ChatControl::C4ChatControl(), C4ChatDlg::C4ChatDlg(), C4DownloadDlg::C4DownloadDlg(), C4GameOptionButtons::C4GameOptionButtons(), C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4Menu::C4Menu(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextButton::ContextButton(), C4MapFolderData::CreateGUIElements(), C4GUI::InfoDialog::CreateSubComponents(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4GUI::FullscreenDialog::FullscreenDialog(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), C4GUI::Container::InsertElement(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4ChatControl::ChatSheet::NickItem::NickItem(), C4GUI::ProgressDialog::ProgressDialog(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollWindow(), C4GUI::InputDialog::SetCustomEdit(), C4GoalDisplay::SetGoals(), C4GUI::Dialog::SetTitle(), C4GUI::FullscreenDialog::SetTitle(), and C4GUI::TextWindow::TextWindow().

119  {
120  // safety
121  if (!pChild) return;
122  // remove from any previous container
123  if (pChild->pParent) pChild->pParent->RemoveElement(pChild);
124  // add to end of list
125  if (pLast) pLast->pNext = pChild; else pFirst = pChild;
126  pChild->pPrev = pLast; pChild->pNext = nullptr; pLast = pChild;
127  pChild->pParent = this;
128 
129  assert(pChild->pNext != pChild);
130  assert(pChild->pPrev != pChild);
131  assert(pChild->pParent != pChild);
132  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Container * pParent
Definition: C4Gui.h:376
Element * pNext
Definition: C4Gui.h:377

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::AddRefSym ( const char *  szCaption,
const C4Facet fctSymbol,
const char *  szCommand,
int32_t  iCount = C4MN_Item_NoCount,
C4Object pObject = nullptr,
const char *  szInfoCaption = nullptr,
C4ID  idID = C4ID::None,
const char *  szCommand2 = nullptr,
bool  fOwnValue = false,
int32_t  iValue = 0,
bool  fIsSelectable = true 
)
inherited

Definition at line 338 of file C4Menu.cpp.

References C4Menu::C4MenuItem, C4Menu::IsActive(), C4Menu::ItemCount, C4MenuItem::RefSymbol(), and C4Menu::Style.

Referenced by ActivateDisplay(), ActivateHost(), ActivateMain(), ActivateOptions(), ActivateSavegame(), and DoRefillInternal().

341 {
342  if (!IsActive()) return false;
343  // Create new menu item
344  C4MenuItem *pNew = new C4MenuItem(this, ItemCount, szCaption,szCommand,iCount,pObject,szInfoCaption,idID,szCommand2,fOwnValue,iValue,Style,fIsSelectable);
345  // Ref Symbol
346  pNew->RefSymbol(fctSymbol);
347  // Add
348  return AddItem(pNew, szCaption, szCommand, iCount, pObject, szInfoCaption, idID, szCommand2, fOwnValue, iValue, fIsSelectable);
349 }
friend class C4MenuItem
Definition: C4Menu.h:263
int32_t Style
Definition: C4Menu.h:136
int32_t ItemCount
Definition: C4Menu.h:138
void RefSymbol(const C4Facet &fctSymbol)
Definition: C4Menu.h:105
bool IsActive()
Definition: C4Menu.cpp:483

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::AdjustPosition ( )
protectedinherited

Definition at line 591 of file C4Menu.cpp.

References C4Menu::Columns, C4GUI::Element::GetBounds(), C4Menu::GetSelectedItem(), C4Rect::Hgt, C4Menu::Lines, C4Menu::pClientWindow, C4GUI::ScrollWindow::ScrollRangeInView(), and C4Rect::y.

Referenced by C4Menu::InitLocation(), and C4Menu::SetSelection().

592 {
593  // Adjust position by selection (works only after InitLocation)
594  if ((Lines > 1) && Columns)
595  {
596  C4MenuItem *pSel = GetSelectedItem();
597  if (pSel)
599  }
600 }
C4GUI::ScrollWindow * pClientWindow
Definition: C4Menu.h:149
int32_t y
Definition: C4Rect.h:32
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
C4Rect & GetBounds()
Definition: C4Gui.h:445
int32_t Columns
Definition: C4Menu.h:142
int32_t Hgt
Definition: C4Rect.h:32
void ScrollRangeInView(int32_t iY, int32_t iHgt)
int32_t Lines
Definition: C4Menu.h:143

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::AdjustSelection ( )
protectedinherited

Definition at line 928 of file C4Menu.cpp.

References C4Menu::GetItem(), C4MenuItem::IsSelectable, C4Menu::Selection, and C4Menu::SetSelection().

Referenced by C4Menu::RefillInternal().

929 {
930  // selection valid?
931  C4MenuItem *pSelection = GetItem(Selection);
932  int iSel = Selection;
933  if (!pSelection || !pSelection->IsSelectable)
934  {
935  // set to new first valid selection: Downwards first
936  iSel = Selection;
937  while (--iSel>=0)
938  if ((pSelection = GetItem(iSel)))
939  if (pSelection->IsSelectable)
940  break;
941  // no success: upwards then
942  if (iSel<0)
943  for (iSel=Selection+1; (pSelection = GetItem(iSel)); ++iSel)
944  if (pSelection->IsSelectable)
945  break;
946  }
947  // set it then
948  if (!pSelection)
949  SetSelection(-1, Selection >= 0, false);
950  else
951  SetSelection(iSel, iSel != Selection, true);
952 }
int32_t Selection
Definition: C4Menu.h:137
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
bool IsSelectable
Definition: C4Menu.h:88
C4MenuItem * GetItem(int32_t iIndex)
Definition: C4Menu.cpp:515

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::AdvanceFocus ( bool  fBackwards)
inherited

Definition at line 581 of file C4GuiDialogs.cpp.

References C4GUI::Container::GetNextNestedElement(), C4GUI::Element::GetParent(), C4GUI::Element::IsFocusElement(), C4GUI::Container::IsSelectedChild(), C4GUI::Element::IsVisible(), C4GUI::Dialog::pActiveCtrl, and C4GUI::Dialog::SetFocus().

Referenced by C4GUI::Control::DisableFocus(), C4GUI::Dialog::KeyAdvanceFocus(), and C4ChatControl::OnLoginDataEnter().

582  {
583  // get element to start from
584  Element *pCurrElement = pActiveCtrl;
585  // find new control
586  for (;;)
587  {
588  // get next element
589  pCurrElement = GetNextNestedElement(pCurrElement, fBackwards);
590  // end reached: start from beginning
591  if (!pCurrElement && pActiveCtrl) if (!(pCurrElement = GetNextNestedElement(nullptr, fBackwards))) return;
592  // cycled?
593  if (pCurrElement == pActiveCtrl)
594  {
595  // but current is no longer a focus element? Then defocus it and return
596  if (pCurrElement && !pCurrElement->IsFocusElement())
597  SetFocus(nullptr, false);
598  return;
599  }
600  // for list elements, check whether the child can be selected
601  if (pCurrElement->GetParent() && !pCurrElement->GetParent()->IsSelectedChild(pCurrElement)) continue;
602  // check if this is a new control
603  Control *pFocusCtrl = pCurrElement->IsFocusElement();
604  if (pFocusCtrl && pFocusCtrl != pActiveCtrl && pFocusCtrl->IsVisible())
605  {
606  // set focus here...
607  SetFocus(pFocusCtrl, false);
608  // ...done!
609  return;
610  }
611  }
612  // never reached
613  }
bool IsVisible()
Definition: C4Gui.cpp:202
Control * pActiveCtrl
Definition: C4Gui.h:2080
C4GameControl Control
void SetFocus(Control *pCtrl, bool fByMouse)
Element * GetNextNestedElement(Element *pPrevElement, bool fBackwards)

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4GUI::Container::AfterElementRemoval ( )
inlineprotectedvirtualinherited

Reimplemented in C4GUI::ListBox.

Definition at line 756 of file C4Gui.h.

References C4GUI::Container::AfterElementRemoval(), and C4GUI::Element::pParent.

Referenced by C4GUI::Container::AfterElementRemoval(), C4GUI::ListBox::AfterElementRemoval(), and C4GUI::Container::RemoveElement().

757  { if (pParent) pParent->AfterElementRemoval(); } // called by ScrollWindow to parent after an element has been removed
virtual void AfterElementRemoval()
Definition: C4Gui.h:756
Container * pParent
Definition: C4Gui.h:376

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::ApplyElementOffset ( int32_t &  riX,
int32_t &  riY 
)
virtualinherited

Reimplemented from C4GUI::Window.

Definition at line 744 of file C4GuiDialogs.cpp.

References C4GUI::Window::ApplyElementOffset(), C4Viewport::GetOutputRect(), C4GUI::Dialog::GetViewport(), and C4Rect::x.

745  {
746  // inherited
747  Window::ApplyElementOffset(riX, riY);
748  // apply viewport offset, if a viewport is assigned
749  C4Viewport *pVP = GetViewport();
750  if (pVP)
751  {
752  C4Rect rcVP(pVP->GetOutputRect());
753  riX -= rcVP.x; riY -= rcVP.y;
754  }
755  }
Definition: C4Rect.h:29
virtual C4Viewport * GetViewport()
Definition: C4Gui.h:2171
virtual void ApplyElementOffset(int32_t &riX, int32_t &riY)
Definition: C4Gui.h:866
C4Rect GetOutputRect()
Definition: C4Viewport.h:64
int32_t x
Definition: C4Rect.h:32

Here is the call graph for this function:

void C4GUI::Dialog::ApplyInvElementOffset ( int32_t &  riX,
int32_t &  riY 
)
virtualinherited

Reimplemented from C4GUI::Window.

Definition at line 757 of file C4GuiDialogs.cpp.

References C4GUI::Window::ApplyInvElementOffset(), C4Viewport::GetOutputRect(), C4GUI::Dialog::GetViewport(), and C4Rect::x.

758  {
759  // inherited
761  // apply viewport offset, if a viewport is assigned
762  C4Viewport *pVP = GetViewport();
763  if (pVP)
764  {
765  C4Rect rcVP(pVP->GetOutputRect());
766  riX += rcVP.x; riY += rcVP.y;
767  }
768  }
Definition: C4Rect.h:29
virtual C4Viewport * GetViewport()
Definition: C4Gui.h:2171
C4Rect GetOutputRect()
Definition: C4Viewport.h:64
virtual void ApplyInvElementOffset(int32_t &riX, int32_t &riY)
Definition: C4Gui.h:868
int32_t x
Definition: C4Rect.h:32

Here is the call graph for this function:

Iterator C4GUI::Container::begin ( )
inlineinherited

Definition at line 824 of file C4Gui.h.

Referenced by C4ScriptGuiWindow::ClearPointers(), and C4ScriptGuiWindow::DrawChildren().

824 { return Iterator(pFirst); }
Element * pFirst
Definition: C4Gui.h:750

Here is the caller graph for this function:

bool C4GUI::Dialog::CharIn ( const char *  c)
virtualinherited

Definition at line 520 of file C4GuiDialogs.cpp.

References C4GUI::Control::CharIn(), C4GUI::Dialog::GetDefaultControl(), C4GUI::Dialog::pActiveCtrl, and C4GUI::Dialog::SetFocus().

Referenced by C4GUI::Screen::CharIn().

521  {
522  // reroute to active control
523  if (pActiveCtrl && pActiveCtrl->CharIn(c)) return true;
524  // unprocessed: Focus default control
525  // Except for space, which may have been processed as a key already
526  // (changing focus here would render buttons unusable, because they switch on KeyUp)
527  Control *pDefCtrl = GetDefaultControl();
528  if (pDefCtrl && pDefCtrl != pActiveCtrl && (!c || *c != 0x20))
529  {
530  SetFocus(pDefCtrl, false);
531  if (pActiveCtrl && pActiveCtrl->CharIn(c))
532  return true;
533  }
534  return false;
535  }
Control * pActiveCtrl
Definition: C4Gui.h:2080
C4GameControl Control
virtual bool CharIn(const char *)
Definition: C4Gui.h:1051
void SetFocus(Control *pCtrl, bool fByMouse)
virtual class Control * GetDefaultControl()
Definition: C4Gui.h:2129

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::CheckBuffer ( )
protectedinherited
virtual bool C4GUI::Element::CheckNameHotkey ( const char *  )
inlineprotectedvirtualinherited

Reimplemented in C4StartupScenSelDlg::ScenListItem.

Definition at line 407 of file C4Gui.h.

Referenced by C4GUI::ListBox::CharIn().

407 { return false; }

Here is the caller graph for this function:

void C4Menu::Clear ( )
inherited

Definition at line 272 of file C4Menu.cpp.

References C4FacetSurface::Clear(), C4GUI::Dialog::ClearFrameDeco(), C4Menu::ClearItems(), C4GUI::Dialog::Close(), C4Menu::fActive, and C4Menu::Symbol.

Referenced by C4MainMenu(), C4Menu::DoInit(), C4Menu::DoInitRefSym(), C4Menu::TryClose(), C4Menu::~C4Menu(), and C4Player::~C4Player().

273 {
274  Close(false);
275  Symbol.Clear();
276  ClearItems();
277  ClearFrameDeco();
278  fActive = false;
279 }
void Close(bool fOK)
void ClearItems()
Definition: C4Menu.cpp:898
bool fActive
Definition: C4Menu.h:153
C4FacetSurface Symbol
Definition: C4Menu.h:148
void ClearFrameDeco()
Definition: C4Gui.h:2199
void Clear()
Definition: C4FacetEx.h:44

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Container::ClearChildren ( )
inherited

Definition at line 68 of file C4GuiContainers.cpp.

References C4GUI::Element::IsOwnPtrElement(), C4GUI::Container::pFirst, C4GUI::Container::pLast, C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::Container::Clear(), C4ScriptGuiWindow::Close(), C4ScriptGuiWindow::RemoveChild(), C4GoalDisplay::SetGoals(), and C4ScriptGuiWindow::~C4ScriptGuiWindow().

69  {
70  // delete all items; dtor will update list
71  while (pFirst)
72  {
73  if (pFirst->IsOwnPtrElement())
74  {
75  // unlink from list
76  Element *pANext = pFirst->pNext;
77  pFirst->pPrev = pFirst->pNext = nullptr;
78  pFirst->pParent = nullptr;
79  if ((pFirst = pANext))
80  pFirst->pPrev = nullptr;
81  else
82  pLast = nullptr;
83  }
84  else
85  delete pFirst;
86  }
87  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750
Element * pPrev
Definition: C4Gui.h:377
Container * pParent
Definition: C4Gui.h:376
virtual bool IsOwnPtrElement()
Definition: C4Gui.h:401
Element * pNext
Definition: C4Gui.h:377

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::ClearFrameDeco ( )
inlineinherited

Definition at line 2199 of file C4Gui.h.

References C4GUI::FrameDecoration::Deref().

Referenced by C4Menu::Clear().

2200  {if (pFrameDeco) pFrameDeco->Deref(); pFrameDeco = nullptr; }
FrameDecoration * pFrameDeco
Definition: C4Gui.h:2089

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::ClearItems ( )
inherited

Definition at line 898 of file C4Menu.cpp.

References C4Menu::GetItem(), C4Menu::ItemCount, and C4Menu::UpdateScrollBar().

Referenced by C4Object::ActivateMenu(), C4Menu::Clear(), DoRefillInternal(), and C4ObjectMenu::DoRefillInternal().

899 {
900  C4MenuItem *pItem;
901  while ((pItem = GetItem(0))) delete pItem;
902  ItemCount=0;
903  UpdateScrollBar();
904 }
int32_t ItemCount
Definition: C4Menu.h:138
void UpdateScrollBar()
Definition: C4Menu.cpp:769
C4MenuItem * GetItem(int32_t iIndex)
Definition: C4Menu.cpp:515

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::ClearPointers ( C4Object pObj)
inherited

Definition at line 1161 of file C4Menu.cpp.

References C4MenuItem::ClearPointers(), and C4Menu::GetItem().

Referenced by C4ObjectMenu::ClearPointers(), and C4Player::ClearPointers().

1162 {
1163  C4MenuItem *pItem;
1164  for (int32_t i=0; (pItem = GetItem(i)); ++i)
1165  pItem->ClearPointers(pObj);
1166 }
void ClearPointers(C4Object *pObj)
Definition: C4Menu.h:115
C4MenuItem * GetItem(int32_t iIndex)
Definition: C4Menu.cpp:515

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::ClientPos2ScreenPos ( int32_t &  riX,
int32_t &  riY 
)
inherited

Definition at line 232 of file C4Gui.cpp.

References C4GUI::Container::ApplyInvElementOffset(), C4GUI::Element::GetParent(), C4GUI::Element::pParent, C4GUI::Element::rcBounds, C4Rect::x, and C4Rect::y.

Referenced by C4MapFolderData::CreateGUIElements(), C4GUI::Screen::DoContext(), and C4Menu::Draw().

233  {
234  // apply all parent offsets
235  Container *pCont = pParent;
236  while (pCont)
237  {
238  pCont->ApplyInvElementOffset(riX, riY);
239  pCont = pCont->GetParent();
240  }
241  // apply own offset
242  riX += rcBounds.x; riY += rcBounds.y;
243  }
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
Container * pParent
Definition: C4Gui.h:376
int32_t x
Definition: C4Rect.h:32
friend class Container
Definition: C4Gui.h:472
virtual void ApplyInvElementOffset(int32_t &riX, int32_t &riY)
Definition: C4Gui.h:841

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::Close ( bool  fOK)
inherited

Definition at line 632 of file C4GuiDialogs.cpp.

References C4GUI::Screen::CloseDialog(), C4GUI::Dialog::DestroyConsoleWindow(), C4GUI::Dialog::fOK, C4GUI::Dialog::fShow, C4GUI::Element::GetScreen(), C4GUI::Dialog::OnClosed(), and C4GUI::Dialog::pWindow.

Referenced by ActivateMain(), C4Menu::Clear(), C4GUI::Screen::CloseAllDialogs(), C4FullScreen::CloseMenu(), C4Player::CloseMenu(), C4MessageInput::CloseTypeIn(), DialogWinProc(), C4StartupScenSelDlg::DoBack(), C4Scoreboard::DoDlgShow(), C4Network2::DoLobby(), C4Startup::DontStartup(), C4Menu::Enter(), C4Menu::Execute(), C4Scoreboard::HideDlg(), C4Network2::LeaguePlrAuth(), C4Network2::LeagueStart(), MenuCommand(), C4GUI::MessageDialog::OnEnter(), C4GameLobby::MainDlg::OnExitBtn(), C4DownloadDlg::OnIdle(), C4Menu::Refill(), C4ChatDlg::StopChat(), C4Network2ClientListDlg::Toggle(), C4ChartDialog::Toggle(), C4ChatDlg::ToggleChat(), C4Menu::TryClose(), C4FileSelDlg::UserClose(), C4StartupPlrPropertiesDlg::UserClose(), and C4GUI::Dialog::UserClose().

633  {
634  // already closed?
635  if (!fShow) return;
636  // set OK flag
637  this->fOK = fOK;
638  // get screen
639  Screen *pScreen = GetScreen();
640  if (pScreen) pScreen->CloseDialog(this, false); else fShow = false;
641  // developer mode: Remove window
643  // do callback - last call, because it might do perilous things
644  OnClosed(fOK);
645  }
void DestroyConsoleWindow()
bool fShow
Definition: C4Gui.h:2081
DialogWindow * pWindow
Definition: C4Gui.h:2088
bool fOK
Definition: C4Gui.h:2082
virtual void OnClosed(bool fOK)
friend class Screen
Definition: C4Gui.h:2216
virtual Screen * GetScreen()
Definition: C4Gui.cpp:290

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::Control ( BYTE  byCom,
int32_t  iData 
)
inherited

Definition at line 423 of file C4Menu.cpp.

References C4MN_AdjustPosition, C4Menu::Columns, COM_MenuClose, COM_MenuDown, COM_MenuEnter, COM_MenuEnterAll, COM_MenuLeft, COM_MenuRight, COM_MenuSelect, COM_MenuShowText, COM_MenuUp, C4Menu::Enter(), C4Menu::IsActive(), C4Menu::ItemCount, C4Menu::MoveSelection(), C4Menu::Selection, C4Menu::SetSelection(), C4Menu::SetTextProgress(), and C4Menu::TryClose().

Referenced by C4Menu::Draw(), C4Menu::KeyControl(), and MenuCommand().

424 {
425  if (!IsActive()) return false;
426 
427  switch (byCom)
428  {
429  case COM_MenuEnter: Enter(); break;
430  case COM_MenuEnterAll: Enter(true); break;
431  case COM_MenuClose: TryClose(false, true); break;
432 
433  // organize with nicer subfunction...
434  case COM_MenuLeft:
435  // Top wrap-around
436  if (Selection-1 < 0)
437  MoveSelection(ItemCount - 1 - Selection, true, true);
438  else
439  MoveSelection(-1, true, true);
440  break;
441  case COM_MenuRight:
442  // Bottom wrap-around
443  if (Selection+1 >= ItemCount)
444  MoveSelection(-Selection, true, true);
445  else
446  MoveSelection(+1, true, true);
447  break;
448  case COM_MenuUp:
449  iData = -Columns;
450  // Top wrap-around
451  if (Selection + iData < 0)
452  while (Selection + iData + Columns < ItemCount)
453  iData += Columns;
454  MoveSelection(iData, true, true);
455  break;
456  case COM_MenuDown:
457  iData = +Columns;
458  // Bottom wrap-around
459  if (Selection+iData >= ItemCount)
460  while (Selection+iData-Columns >= 0)
461  iData-=Columns;
462  MoveSelection(iData, true, true);
463  break;
464  case COM_MenuSelect:
465  if (ItemCount)
466  SetSelection(iData & (~C4MN_AdjustPosition), !!(iData & C4MN_AdjustPosition), true);
467  break;
468  case COM_MenuShowText:
469  SetTextProgress(-1, false);
470  break;
471  }
472 
473  return true;
474 }
int32_t Selection
Definition: C4Menu.h:137
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
const BYTE COM_MenuLeft
Definition: C4Constants.h:129
const BYTE COM_MenuShowText
Definition: C4Constants.h:128
bool SetTextProgress(int32_t iToProgress, bool fAdd)
Definition: C4Menu.cpp:961
const BYTE COM_MenuEnterAll
Definition: C4Constants.h:126
const BYTE COM_MenuEnter
Definition: C4Constants.h:125
int32_t ItemCount
Definition: C4Menu.h:138
const BYTE COM_MenuUp
Definition: C4Constants.h:131
const BYTE COM_MenuDown
Definition: C4Constants.h:132
bool IsActive()
Definition: C4Menu.cpp:483
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
const BYTE COM_MenuSelect
Definition: C4Constants.h:133
const BYTE COM_MenuClose
Definition: C4Constants.h:127
const BYTE COM_MenuRight
Definition: C4Constants.h:130
int32_t Columns
Definition: C4Menu.h:142
bool Enter(bool fRight=false)
Definition: C4Menu.cpp:488
bool MoveSelection(int32_t iBy, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:525

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GUI::Dialog::CreateConsoleWindow ( )
protectedinherited

Definition at line 240 of file C4GuiDialogs.cpp.

References Application, StdStrBuf::getData(), C4GUI::Dialog::GetID(), C4GUI::DialogWindow::Init(), C4GUI::DialogWindow::pDialog, C4Window::pSurface, C4GUI::Dialog::pWindow, C4GUI::Element::rcBounds, and C4GUI::Dialog::TitleString.

Referenced by C4GUI::Dialog::Show().

241  {
242 #ifdef WITH_QT_EDITOR
243  // TODO: Implement these as Qt editor windows.
244  // This currently creates an empty window in Windows and a segfault in Linux.
245  return false;
246 #endif
247  // already created?
248  if (pWindow) return true;
249  // create it!
250  pWindow = new DialogWindow();
252  {
253  delete pWindow;
254  pWindow = nullptr;
255  return false;
256  }
257  // create rendering context
259  pWindow->pDialog = this;
260  return true;
261  }
const char * getData() const
Definition: StdBuf.h:450
C4Surface * pSurface
Definition: C4Window.h:279
virtual const char * GetID()
Definition: C4Gui.h:2107
DialogWindow * pWindow
Definition: C4Gui.h:2088
C4Window * Init(C4AbstractApp *pApp, const char *Title, const C4Rect &rcBounds, const char *szID)
StdStrBuf TitleString
Definition: C4Gui.h:2086
Dialog * pDialog
Definition: C4Gui.h:2032
C4Rect rcBounds
Definition: C4Gui.h:385
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

void C4MainMenu::Default ( )
virtual

Reimplemented from C4Menu.

Definition at line 44 of file C4MainMenu.cpp.

References C4Menu::Default(), NO_OWNER, and Player.

Referenced by C4Player::C4Player().

45 {
48 }
int32_t Player
Definition: C4MainMenu.h:41
const int NO_OWNER
Definition: C4Constants.h:138
virtual void Default()
Definition: C4Menu.cpp:247

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::DestroyConsoleWindow ( )
protectedinherited

Definition at line 263 of file C4GuiDialogs.cpp.

References C4Window::Clear(), C4Window::pSurface, and C4GUI::Dialog::pWindow.

Referenced by C4GUI::Dialog::Close(), C4GUI::Dialog::OnClosed(), and C4GUI::Dialog::~Dialog().

264  {
265  if (pWindow)
266  {
267  delete pWindow->pSurface;
268  pWindow->Clear();
269  delete pWindow;
270  pWindow = nullptr;
271  }
272  }
C4Surface * pSurface
Definition: C4Window.h:279
DialogWindow * pWindow
Definition: C4Gui.h:2088
virtual void Clear()
Definition: C4AppT.cpp:100

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GUI::Element::DoContext ( )
inherited

Definition at line 418 of file C4Gui.cpp.

References C4Rect::Hgt, C4GUI::ContextHandler::OnContext(), C4GUI::Element::pContextHandler, C4GUI::Element::rcBounds, and C4Rect::Wdt.

Referenced by C4GUI::Control::KeyContext(), and C4GUI::ContextButton::MouseInput().

419  {
420  if (!pContextHandler) return false;
421  return pContextHandler->OnContext(this, rcBounds.Wdt/2, rcBounds.Hgt/2);
422  }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
int32_t Wdt
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
virtual bool OnContext(Element *pOnElement, int32_t iX, int32_t iY)=0
int32_t Hgt
Definition: C4Rect.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::DoDragging ( CMouse rMouse,
int32_t  iX,
int32_t  iY,
DWORD  dwKeyParam 
)
virtualinherited

Reimplemented in C4GUI::Edit, and C4GUI::ScrollBar.

Definition at line 270 of file C4Gui.cpp.

References C4GUI::Element::iDragX, C4GUI::Element::iDragY, C4GUI::Element::pDragTarget, C4GUI::Element::rcBounds, C4GUI::Element::UpdatePos(), C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Screen::MouseInput(), and C4GUI::Element::StopDragging().

271  {
272  // check if anything moved
273  if (pDragTarget && (iX != iDragX || iY != iDragY))
274  {
275  // move position, then
276  pDragTarget->rcBounds.x += iX-iDragX;
277  pDragTarget->rcBounds.y += iY-iDragY;
278  // drag X/Y is up-to-date if this is a child element of the drag target
280  }
281  }
int32_t iDragY
Definition: C4Gui.h:379
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
Window * pDragTarget
Definition: C4Gui.h:378
virtual void UpdatePos()
Definition: C4Gui.cpp:194
int32_t iDragX
Definition: C4Gui.h:379

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::DoInit ( C4FacetSurface fctSymbol,
const char *  szEmpty,
int32_t  iExtra = C4MN_Extra_None,
int32_t  iExtraData = 0,
int32_t  iId = 0,
int32_t  iStyle = C4MN_Style_Normal 
)
protectedinherited

Definition at line 301 of file C4Menu.cpp.

References C4Menu::Clear(), C4Menu::Default(), C4FacetSurface::GrabFrom(), and C4Menu::Symbol.

Referenced by Init(), and C4ObjectMenu::Init().

302 {
303  Clear(); Default();
304  Symbol.GrabFrom(fctSymbol);
305  return InitMenu(szEmpty, iExtra, iExtraData, iId, iStyle);
306 }
void GrabFrom(C4FacetSurface &rSource)
Definition: C4FacetEx.h:57
virtual void Default()
Definition: C4Menu.cpp:247
C4FacetSurface Symbol
Definition: C4Menu.h:148
void Clear()
Definition: C4Menu.cpp:272

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::DoInitRefSym ( const C4Facet fctSymbol,
const char *  szEmpty,
int32_t  iExtra = C4MN_Extra_None,
int32_t  iExtraData = 0,
int32_t  iId = 0,
int32_t  iStyle = C4MN_Style_Normal 
)
protectedinherited

Definition at line 308 of file C4Menu.cpp.

References C4Menu::Clear(), C4Menu::Default(), C4FacetSurface::Set(), and C4Menu::Symbol.

Referenced by InitRefSym(), and C4ObjectMenu::InitRefSym().

309 {
310  Clear(); Default();
311  Symbol.Set(fctSymbol);
312  return InitMenu(szEmpty, iExtra, iExtraData, iId, iStyle);
313 }
void Set(const C4Facet &cpy)
Definition: C4FacetEx.h:46
virtual void Default()
Definition: C4Menu.cpp:247
C4FacetSurface Symbol
Definition: C4Menu.h:148
void Clear()
Definition: C4Menu.cpp:272

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GUI::Dialog::DoModal ( )
inherited

Definition at line 659 of file C4GuiDialogs.cpp.

References Application, C4GUI::Dialog::fOK, C4GUI::Dialog::fShow, Game, C4Application::IsQuittingGame(), C4Game::IsRunning, C4GUI::Dialog::OnIdle(), and StdScheduler::ScheduleProcs().

Referenced by C4DownloadDlg::ShowModal(), and C4GUI::Screen::ShowModalDlg().

660  {
661  // Cancel all dialogues if game is left (including e.g. league dialogues)
662  if (::Application.IsQuittingGame()) return false;
663  // main message loop
664  while (fShow)
665  {
666  // dialog idle proc
667  OnIdle();
668  // Modal dialogue during running game is tricky. Do not execute game!
669  bool fGameWasRunning = ::Game.IsRunning;
670  ::Game.IsRunning = false;
671  // handle messages - this may block until the next timer
672  if (!Application.ScheduleProcs())
673  return false; // game GUI and lobby will deleted in Game::Clear()
674  // reset game run state
675  if (fGameWasRunning) ::Game.IsRunning = true;
676  }
677  // return whether dlg was OK
678  return fOK;
679  }
bool IsRunning
Definition: C4Game.h:141
bool fShow
Definition: C4Gui.h:2081
C4Game Game
Definition: C4Globals.cpp:52
virtual void OnIdle()
Definition: C4Gui.h:2209
bool fOK
Definition: C4Gui.h:2082
bool IsQuittingGame() const
Definition: C4Application.h:70
bool ScheduleProcs(int iTimeout=1000/36)
C4Application Application
Definition: C4Globals.cpp:44

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool C4GUI::Dialog::DoPlacement ( Screen pOnScreen,
const C4Rect rPreferredDlgRect 
)
inlinevirtualinherited

Reimplemented in C4GUI::FullscreenDialog, C4ChatDlg, and C4ScoreboardDlg.

Definition at line 2175 of file C4Gui.h.

Referenced by C4GUI::Screen::ShowDialog().

2175 { return false; }

Here is the caller graph for this function:

bool C4MainMenu::DoRefillInternal ( bool &  rfRefilled)
protectedvirtual

Reimplemented from C4Menu.

Definition at line 109 of file C4MainMenu.cpp.

References C4Menu::Add(), C4Menu::AddRefSym(), C4MaxTitle, C4MN_Hostility, C4MN_Item_NoCount, C4MN_Observer, C4MN_TeamSelection, C4MN_TeamSwitch, C4SymbolSize, C4Menu::ClearItems(), C4Player::ColorDw, C4FacetSurface::Create(), C4FacetSurface::Default(), C4Facet::Draw(), C4Facet::DrawClr(), C4Player::DrawHostility(), C4Game::DrawTextSpecImage(), C4GraphicsResource::fctCrewClr, C4GraphicsResource::fctPlayerClr, StdStrBuf::Format(), FormatString(), Game, C4PlayerList::Get(), C4PlayerList::GetByIndex(), C4Team::GetColor(), StdStrBuf::getData(), C4GUI::Icon::GetIconFacet(), C4Team::GetIconSpec(), C4Team::GetID(), C4Menu::GetItemCount(), C4Player::GetName(), C4Team::GetNameWithParticipants(), C4Viewport::GetPlayer(), C4Team::GetPlayerCount(), C4TeamList::GetTeamByIndex(), C4ViewportList::GetViewport(), GraphicsResource, C4Player::Hostility, C4GUI::Ico_Star, C4GUI::Ico_Team, C4Menu::Identification, C4TeamList::IsAutoGenerateTeams(), C4Player::IsInvisible(), LoadResStr(), C4GUI::MakeColorReadableOnBlack(), NO_OWNER, C4Player::Number, Player, Players, StdStrBuf::Ref(), SCopy(), C4Menu::SetSelection(), sprintf, StdStrBuf::Take(), TEAMID_New, C4Game::Teams, and Viewports.

110 {
111  // Variables
112  C4FacetSurface fctSymbol;
113  C4Player *pPlayer;
114  C4IDList ListItems;
115  C4Facet fctTarget;
116  bool fWasEmpty = !GetItemCount();
117 
118  // Refill
119  switch (Identification)
120  {
121  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
122  case C4MN_Hostility:
123  {
124  // Clear items
125  ClearItems();
126  // Refill player
127  if (!(pPlayer = ::Players.Get(Player))) return false;
128  // Refill items
129  C4Player *pPlr; int32_t iIndex;
130  for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
131  // Ignore player self and invisible
132  if (pPlr != pPlayer) if (!pPlr->IsInvisible())
133  {
134  // Symbol
135  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
136  pPlayer->DrawHostility(fctSymbol,iIndex);
137  // Message
138  StdStrBuf sMsg;
139  bool isFriendly = pPlayer->Hostility.find(pPlr) == pPlayer->Hostility.end();
140  if (isFriendly)
141  sMsg.Format(LoadResStr("IDS_MENU_ATTACK"),pPlr->GetName());
142  else
143  sMsg.Format(LoadResStr("IDS_MENU_NOATTACK"),pPlr->GetName());
144  // Command
145  char szCommand[1000];
146  sprintf(szCommand,"SetHostility:%i",pPlr->Number);
147  // Info caption
148  char szInfoCaption[C4MaxTitle+1],szFriendly[50],szNot[30]="";
149  SCopy(LoadResStr(isFriendly ? "IDS_MENU_ATTACKHOSTILE" : "IDS_MENU_ATTACKFRIENDLY"),szFriendly);
150  if (!isFriendly) SCopy(LoadResStr("IDS_MENU_ATTACKNOT"),szNot);
151  sprintf(szInfoCaption,LoadResStr("IDS_MENU_ATTACKINFO"),pPlr->GetName(),szFriendly,szNot);
152  if (iIndex==pPlayer->Number) SCopy(LoadResStr("IDS_MENU_ATTACKSELF"),szInfoCaption);
153  // Add item
154  Add(sMsg.getData(),fctSymbol,szCommand,C4MN_Item_NoCount,nullptr,szInfoCaption);
155  fctSymbol.Default();
156  }
157  break;
158  }
159  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
160  case C4MN_TeamSelection:
161  case C4MN_TeamSwitch:
162  {
163  // Clear items
164  ClearItems();
165  // add all teams as menu items
166  // 2do: Icon
167  C4Team *pTeam; int32_t i=0; bool fAddNewTeam=Game.Teams.IsAutoGenerateTeams();
168  for (;;)
169  {
170  pTeam = Game.Teams.GetTeamByIndex(i);
171  if (pTeam)
172  {
173  // next regular team
174  ++i;
175  // do not add a new team if an empty team exists
176  if (!pTeam->GetPlayerCount()) fAddNewTeam = false;
177  }
178  else if (fAddNewTeam)
179  {
180  // join new team
181  fAddNewTeam = false;
182  }
183  else
184  {
185  // all teams done
186  break;
187  }
188  // create team symbol: Icon spec if specified; otherwise flag for empty and crew for nonempty team
189  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
190  const char *szIconSpec = pTeam ? pTeam->GetIconSpec() : nullptr;
191  bool fHasIcon = false;
192  if (szIconSpec && *szIconSpec)
193  {
194  fHasIcon = Game.DrawTextSpecImage(fctSymbol, szIconSpec, nullptr, pTeam->GetColor());
195  }
196  if (!fHasIcon)
197  {
198  if (pTeam && pTeam->GetPlayerCount())
199  ::GraphicsResource.fctCrewClr.DrawClr(fctSymbol, true, pTeam->GetColor());
200  else
202  }
203  StdStrBuf sTeamName;
204  if (pTeam)
205  {
206  sTeamName.Take(pTeam->GetNameWithParticipants());
207  }
208  else
209  sTeamName.Ref(LoadResStr("IDS_PRC_NEWTEAM"));
210  const char *szOperation = (Identification == C4MN_TeamSwitch) ? "TeamSwitch" : "TeamSel";
211  Add(sTeamName.getData(), fctSymbol,FormatString("%s:%d", szOperation, pTeam ? pTeam->GetID() : TEAMID_New).getData(),
212  C4MN_Item_NoCount,nullptr,FormatString(LoadResStr("IDS_MSG_JOINTEAM"), sTeamName.getData()).getData(), C4ID(pTeam ? pTeam->GetID() : 0));
213  fctSymbol.Default();
214  }
215  break;
216  }
217  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
218  case C4MN_Observer: // observer menu
219  {
220  // Clear items
221  ClearItems();
222  // Check validity
224  if (!pVP) return false;
225  int32_t iInitialSelection = 0;
226  // Add free view
227  AddRefSym(LoadResStr("IDS_MSG_FREEVIEW"), C4GUI::Icon::GetIconFacet(C4GUI::Ico_Star), "Observe:Free", C4MN_Item_NoCount, nullptr, LoadResStr("IDS_MSG_FREELYSCROLLAROUNDTHEMAP"));
228  // Add players
229  C4Player *pPlr; int32_t iIndex;
230  for (iIndex=0; (pPlr = ::Players.GetByIndex(iIndex)); iIndex++)
231  {
232  // Ignore invisible
233  if (!pPlr->IsInvisible())
234  {
235  // Symbol
236  fctSymbol.Create(C4SymbolSize,C4SymbolSize);
237  ::GraphicsResource.fctPlayerClr.DrawClr(fctSymbol, true, pPlr->ColorDw);
238  // Message
239  StdStrBuf sMsg;
240  DWORD dwClr = pPlr->ColorDw;
241  sMsg.Format("<c %x>%s</c>", (unsigned int)C4GUI::MakeColorReadableOnBlack(dwClr), pPlr->GetName());
242  // Command
243  StdStrBuf sCommand;
244  sCommand.Format("Observe:%d", (int)pPlr->Number);
245  // Info caption
246  StdStrBuf sInfo;
247  sInfo.Format(LoadResStr("IDS_TEXT_FOLLOWVIEWOFPLAYER"), pPlr->GetName());
248  // Add item
249  Add(sMsg.getData(),fctSymbol,sCommand.getData(),C4MN_Item_NoCount,nullptr,sInfo.getData());
250  fctSymbol.Default();
251  // check if this is the currently selected player
252  if (pVP->GetPlayer() == pPlr->Number) iInitialSelection = GetItemCount()-1;
253  }
254  // Initial selection on followed player
255  if (fWasEmpty) SetSelection(iInitialSelection, false, true);
256  }
257  }
258  break;
259  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
260  default:
261  // No internal refill needed
262  return true;
263  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
264  }
265 
266  // Successfull internal refill
267  rfRefilled = true;
268  return true;
269 }
const char * getData() const
Definition: StdBuf.h:450
int32_t GetPlayerCount() const
Definition: C4Teams.h:64
const char * GetIconSpec() const
Definition: C4Teams.h:71
bool AddRefSym(const char *szCaption, const C4Facet &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:338
int32_t GetID() const
Definition: C4Teams.h:66
bool SetSelection(int32_t iSelection, bool fAdjustPosition, bool fDoCalls)
Definition: C4Menu.cpp:547
bool Add(const char *szCaption, C4FacetSurface &fctSymbol, const char *szCommand, int32_t iCount=C4MN_Item_NoCount, C4Object *pObject=nullptr, const char *szInfoCaption=nullptr, C4ID idID=C4ID::None, const char *szCommand2=nullptr, bool fOwnValue=false, int32_t iValue=0, bool fIsSelectable=true)
Definition: C4Menu.cpp:351
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
const size_t C4MaxTitle
Definition: C4Constants.h:25
C4Game Game
Definition: C4Globals.cpp:52
int32_t Number
Definition: C4Player.h:88
#define sprintf
Definition: Standard.h:171
Definition: C4Teams.h:30
bool IsInvisible() const
Definition: C4Player.cpp:1737
uint32_t GetColor() const
Definition: C4Teams.h:70
bool IsAutoGenerateTeams() const
Definition: C4Teams.h:173
StdStrBuf GetNameWithParticipants() const
Definition: C4Teams.cpp:210
void DrawClr(C4Facet &cgo, bool fAspect=true, DWORD dwClr=0)
Definition: C4Facet.cpp:213
DWORD MakeColorReadableOnBlack(DWORD &rdwClr)
Definition: C4Gui.cpp:99
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:181
C4Viewport * GetViewport(int32_t iPlayer, C4Viewport *pPrev=nullptr)
void DrawHostility(C4Facet &cgo, int32_t iIndex)
Definition: C4Player.cpp:999
C4GraphicsResource GraphicsResource
C4TeamList & Teams
Definition: C4Game.h:72
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
void Default()
Definition: C4FacetEx.h:43
uint32_t ColorDw
Definition: C4Player.h:91
C4Player * Get(int iPlayer) const
C4Player * GetByIndex(int iIndex) const
int32_t Player
Definition: C4MainMenu.h:41
void ClearItems()
Definition: C4Menu.cpp:898
void Take(char *pnData)
Definition: StdBuf.h:465
C4Team * GetTeamByIndex(int32_t iIndex) const
Definition: C4Teams.cpp:405
C4PlayerList Players
int32_t GetItemCount()
Definition: C4Menu.cpp:520
void Draw(C4Facet &cgo, bool fAspect=true, int32_t iPhaseX=0, int32_t iPhaseY=0, bool fTransparent=true)
Definition: C4Facet.cpp:154
const int NO_OWNER
Definition: C4Constants.h:138
Definition: C4Id.h:28
const int32_t TEAMID_New
Definition: C4Teams.h:27
void Ref(const char *pnData)
Definition: StdBuf.h:463
C4ViewportList Viewports
Definition: C4Viewport.cpp:841
const char * GetName() const
Definition: C4Player.h:153
const int C4SymbolSize
Definition: C4Constants.h:58
int32_t GetPlayer()
Definition: C4Viewport.h:67
bool Create(int iWdt, int iHgt, int iWdt2=C4FCT_Full, int iHgt2=C4FCT_Full)
Definition: C4FacetEx.cpp:54
uint32_t DWORD
static C4Facet GetIconFacet(Icons icoIconIndex)
int32_t Identification
Definition: C4Menu.h:141
bool DrawTextSpecImage(C4Facet &fctTarget, const char *szSpec, class C4DrawTransform *pTransform, uint32_t dwClr=0xff)
Definition: C4Game.cpp:3741
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:277
HostilitySet Hostility
Definition: C4Player.h:120

Here is the call graph for this function:

void C4Menu::Draw ( C4TargetFacet cgo)
protectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 778 of file C4Menu.cpp.

References C4MN_InfoCaption_Delay, C4MN_Style_Info, C4GUI::Element::ClientPos2ScreenPos(), C4Menu::Control(), C4GUI::Screen::DrawToolTip(), C4Menu::fTextProgressing, C4Menu::GetSelectedItem(), C4MenuItem::InfoCaption, C4Menu::InitLocation(), C4Menu::IsActive(), C4GUI::CMouse::IsActiveInput(), C4Menu::LocationSet, C4GUI::Screen::Mouse, pGUI, C4GUI::Container::SetVisibility(), C4Menu::Style, and C4Menu::TimeOnSelection.

Referenced by C4Viewport::DrawMenu().

779 {
780  // Inactive
781  if (!IsActive()) return;
782 
783  // Location
784  if (!LocationSet) { InitLocation(cgo); LocationSet=true; }
785 
786  // If drawn by a viewport, then it's made visible
787  SetVisibility(true);
788 
789  // do drawing
790  typedef C4GUI::Dialog ParentClass;
791  ParentClass::Draw(cgo);
792 
793  // draw tooltip if selection time has been long enough
796  if (Style != C4MN_Style_Info) // No tooltips in info menus - doesn't make any sense...
797  if (!::Control.isReplay())
798  if (!::pGUI->Mouse.IsActiveInput())
799  {
800  C4MenuItem *pSel = GetSelectedItem();
801  if (pSel && *pSel->InfoCaption)
802  {
803  int32_t iX=0, iY=0;
804  pSel->ClientPos2ScreenPos(iX, iY);
805  C4GUI::Screen::DrawToolTip(pSel->InfoCaption, cgo, iX, iY);
806  }
807  }
808 }
void InitLocation(C4Facet &cgo)
Definition: C4Menu.cpp:627
int32_t Style
Definition: C4Menu.h:136
bool fTextProgressing
Definition: C4Menu.h:151
static void DrawToolTip(const char *szTip, C4TargetFacet &cgo, float guix, float guiy)
Definition: C4Gui.cpp:1012
bool LocationSet
Definition: C4Menu.h:133
virtual void SetVisibility(bool fToValue)
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1194
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
bool IsActive()
Definition: C4Menu.cpp:483
const int32_t C4MN_InfoCaption_Delay
Definition: C4Menu.cpp:44
char InfoCaption[2 *C4MaxTitle+1]
Definition: C4Menu.h:74
int32_t TimeOnSelection
Definition: C4Menu.h:137
bool Control(BYTE byCom, int32_t iData)
Definition: C4Menu.cpp:423
void ClientPos2ScreenPos(int32_t &riX, int32_t &riY)
Definition: C4Gui.cpp:232
CMouse Mouse
Definition: C4Gui.h:2587
bool IsActiveInput()
Definition: C4Gui.h:2578

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::Draw3DFrame ( C4TargetFacet cgo,
bool  fUp = false,
int32_t  iIndent = 1,
BYTE  byAlpha = C4GUI_BorderAlpha,
bool  fDrawTop = true,
int32_t  iTopOff = 0,
bool  fDrawLeft = true,
int32_t  iLeftOff = 0 
)
protectedinherited

Definition at line 292 of file C4Gui.cpp.

References C4GUI_BorderColor1, C4GUI_BorderColor2, C4GUI_BorderColor3, C4Draw::DrawLineDw(), C4Rect::Hgt, pDraw, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::ProgressBar::DrawElement(), C4GUI::GroupBox::DrawElement(), C4GUI::Edit::DrawElement(), C4GUI::ListBox::DrawElement(), C4GUI::Tabular::DrawElement(), C4GUI::TextWindow::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::ComboBox::DrawElement(), and C4GUI::Dialog::DrawElement().

293  {
294  DWORD dwAlpha = byAlpha<<24;
295  int32_t x0 = cgo.TargetX + rcBounds.x + iLeftOff,
296  y0 = cgo.TargetY + rcBounds.y + iTopOff,
297  x1 = cgo.TargetX + rcBounds.x + rcBounds.Wdt - 1,
298  y1 = cgo.TargetY + rcBounds.y + rcBounds.Hgt - 1;
299  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x1,(float)y0, C4GUI_BorderColor1 | dwAlpha);
300  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y0,(float)x0,(float)y1, C4GUI_BorderColor1 | dwAlpha);
301  if (fDrawTop) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x1-1),(float)(y0+1), C4GUI_BorderColor2 | dwAlpha);
302  if (fDrawLeft) pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y0+1),(float)(x0+1),(float)(y1-1), C4GUI_BorderColor2 | dwAlpha);
303  pDraw->DrawLineDw(cgo.Surface, (float)x0,(float)y1,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
304  pDraw->DrawLineDw(cgo.Surface, (float)x1,(float)y0,(float)x1,(float)y1, C4GUI_BorderColor3 | dwAlpha);
305  pDraw->DrawLineDw(cgo.Surface, (float)(x0+1),(float)(y1-1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
306  pDraw->DrawLineDw(cgo.Surface, (float)(x1-1),(float)(y0+1),(float)(x1-1),(float)(y1-1), C4GUI_BorderColor1 | dwAlpha);
307  }
#define C4GUI_BorderColor2
Definition: C4Gui.h:86
void DrawLineDw(C4Surface *sfcTarget, float x1, float y1, float x2, float y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:617
int32_t Wdt
Definition: C4Rect.h:32
#define C4GUI_BorderColor1
Definition: C4Gui.h:85
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
C4Draw * pDraw
Definition: C4Draw.cpp:45
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
#define C4GUI_BorderColor3
Definition: C4Gui.h:87
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167
uint32_t DWORD

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::DrawBar ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 309 of file C4Gui.cpp.

References C4Facet::Draw(), C4Facet::DrawX(), C4GUI::DynBarFacet::fctBegin, C4GUI::DynBarFacet::fctEnd, C4GUI::DynBarFacet::fctMiddle, C4Rect::Hgt, C4Facet::Hgt, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, and C4Rect::y.

Referenced by C4GUI::WoodenLabel::DrawElement(), and C4GUI::Button::DrawElement().

310  {
311  if (rcBounds.Hgt == rFacets.fctMiddle.Hgt)
312  {
313  // exact bar
314  int32_t x0=cgo.TargetX+rcBounds.x, y0=cgo.TargetY+rcBounds.y;
315  int32_t iX = rFacets.fctBegin.Wdt, w=rFacets.fctMiddle.Wdt, wLeft=rFacets.fctBegin.Wdt, wRight=rFacets.fctEnd.Wdt;
316  int32_t iRightShowLength = wRight/3;
317  bool fOverflow = (wLeft > rcBounds.Wdt);
318  if (fOverflow) rFacets.fctBegin.Wdt = rcBounds.Wdt;
319  rFacets.fctBegin.Draw(cgo.Surface, x0,y0);
320  if (fOverflow) rFacets.fctBegin.Wdt = wLeft;
321  while (iX < rcBounds.Wdt-iRightShowLength)
322  {
323  int32_t w2=std::min(w, rcBounds.Wdt-iRightShowLength-iX); rFacets.fctMiddle.Wdt=w2;
324  rFacets.fctMiddle.Draw(cgo.Surface, x0+iX, y0);
325  iX += w;
326  }
327  rFacets.fctMiddle.Wdt=w;
328  fOverflow = (wRight > rcBounds.Wdt);
329  if (fOverflow)
330  {
331  rFacets.fctEnd.X += wRight - rcBounds.Wdt;
332  rFacets.fctEnd.Wdt = rcBounds.Wdt;
333  }
334  rFacets.fctEnd.Draw(cgo.Surface, x0+rcBounds.Wdt-rFacets.fctEnd.Wdt, y0);
335  if (fOverflow)
336  {
337  rFacets.fctEnd.X -= wRight - rcBounds.Wdt;
338  rFacets.fctEnd.Wdt = wRight;
339  }
340  }
341  else
342  {
343  // zoomed bar
344  float fZoom = (float) rcBounds.Hgt / rFacets.fctMiddle.Hgt;
345  int32_t x0=cgo.TargetX+rcBounds.x, y0=cgo.TargetY+rcBounds.y;
346  int32_t iX = int32_t(fZoom*rFacets.fctBegin.Wdt), w=int32_t(fZoom*rFacets.fctMiddle.Wdt), wOld=rFacets.fctMiddle.Wdt;
347  int32_t iRightShowLength = rFacets.fctEnd.Wdt/3;
348  rFacets.fctBegin.DrawX(cgo.Surface, x0,y0,int32_t(fZoom*rFacets.fctBegin.Wdt),rcBounds.Hgt);
349  while (iX < rcBounds.Wdt-(fZoom*iRightShowLength))
350  {
351  int32_t w2=std::min<int32_t>(w, rcBounds.Wdt-int32_t(fZoom*iRightShowLength)-iX); rFacets.fctMiddle.Wdt=long(float(w2)/fZoom);
352  rFacets.fctMiddle.DrawX(cgo.Surface, x0+iX, y0, w2,rcBounds.Hgt);
353  iX += w;
354  }
355  rFacets.fctMiddle.Wdt=wOld;
356  rFacets.fctEnd.DrawX(cgo.Surface, x0+rcBounds.Wdt-int32_t(fZoom*rFacets.fctEnd.Wdt), y0,int32_t(fZoom*rFacets.fctEnd.Wdt),rcBounds.Hgt);
357  }
358  }
int32_t Wdt
Definition: C4Rect.h:32
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::DrawBuffer ( C4Facet cgo)
protectedinherited
void C4Menu::DrawButton ( C4Facet cgo)
protectedinherited
void C4Menu::DrawElement ( C4TargetFacet cgo)
protectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 811 of file C4Menu.cpp.

References C4FCT_Right, C4Id2Def(), C4MN_Extra_Value, C4MN_SymbolSize, C4Menu::DrawFrame(), C4Facet::DrawValue(), C4Menu::Extra, C4GraphicsResource::fctWealth, C4MenuItem::fOwnValue, C4Menu::GetSelectedItem(), C4Def::GetValue(), GraphicsResource, C4Rect::Hgt, C4Facet::Hgt, C4MenuItem::id, C4MenuItem::iValue, NO_OWNER, C4ID::None, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, C4Facet::X, C4Rect::y, and C4Facet::Y.

812 {
813  // inherited (background)
814  typedef C4GUI::Dialog ParentClass;
815  ParentClass::DrawElement(cgo);
816 
817  // Get selected item id
818  C4ID idSelected; C4MenuItem *pItem;
819  if ((pItem = GetSelectedItem())) idSelected = pItem->id; else idSelected = C4ID::None;
820  C4Def *pDef = C4Id2Def(idSelected);
821  // Get item value
822  int32_t iValue = 0;
823  if (pDef)
824  {
825  if (pItem && pItem->fOwnValue)
826  iValue = pItem->iValue;
827  else
828  iValue = pDef->GetValue(nullptr, NO_OWNER);
829  }
830 
831  // Store and clear global clipper
832 // int32_t iX1,iY1,iX2,iY2;
833 // pDraw->GetPrimaryClipper(iX1,iY1,iX2,iY2);
834 // pDraw->SubPrimaryClipper(rcBounds.x, rcBounds.y, rcBounds.x+rcBounds.Wdt-1, rcBounds.y+rcBounds.Hgt-1);
835 
837 
838  // Draw bar divider
839  if (Extra)
840  {
841  DrawFrame(cgoExtra.Surface, cgoExtra.X-1, cgoExtra.Y-1, cgoExtra.Wdt+1, cgoExtra.Hgt+1);
842  }
843 
844  // Draw specified extra
845  switch (Extra)
846  {
847  case C4MN_Extra_Value:
848  {
849  if (pDef) ::GraphicsResource.fctWealth.DrawValue(cgoExtra,iValue,0,0,C4FCT_Right);
850  }
851  break;
852  }
853 }
void DrawFrame(C4Surface *sfcSurface, int32_t iX, int32_t iY, int32_t iWdt, int32_t iHgt)
Definition: C4Menu.cpp:855
bool fOwnValue
Definition: C4Menu.h:82
const int32_t C4FCT_Right
Definition: C4Facet.h:28
C4GraphicsResource GraphicsResource
C4ID id
Definition: C4Menu.h:76
int32_t Wdt
Definition: C4Rect.h:32
void DrawValue(C4Facet &cgo, int32_t iValue, int32_t iPhaseX=0, int32_t iPhaseY=0, int32_t iAlign=C4FCT_Center)
Definition: C4Facet.cpp:308
int32_t y
Definition: C4Rect.h:32
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
static const C4ID None
Definition: C4Id.h:42
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t iValue
Definition: C4Menu.h:83
Definition: C4Def.h:100
const int NO_OWNER
Definition: C4Constants.h:138
Definition: C4Id.h:28
int32_t x
Definition: C4Rect.h:32
int32_t GetValue(C4Object *pInBase, int32_t iBuyPlayer)
Definition: C4Def.cpp:615
float TargetX
Definition: C4Facet.h:167
C4Def * C4Id2Def(C4ID id)
Definition: C4DefList.h:80
int32_t Extra
Definition: C4Menu.h:140
int32_t Hgt
Definition: C4Rect.h:32
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167

Here is the call graph for this function:

void C4Menu::DrawFrame ( C4Surface sfcSurface,
int32_t  iX,
int32_t  iY,
int32_t  iWdt,
int32_t  iHgt 
)
protectedinherited

Definition at line 855 of file C4Menu.cpp.

References C4RGB, C4Draw::DrawFrameDw(), and pDraw.

Referenced by C4Menu::DrawElement().

856 {
857  pDraw->DrawFrameDw(sfcSurface, iX+1, iY+1, iX+iWdt-1,iY+iHgt-1, C4RGB(0x44, 0, 0));
858 }
void DrawFrameDw(C4Surface *sfcDest, int x1, int y1, int x2, int y2, DWORD dwClr, float width=1.0f)
Definition: C4Draw.cpp:644
C4Draw * pDraw
Definition: C4Draw.cpp:45
#define C4RGB(r, g, b)
Definition: StdColors.h:28

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::DrawHBarByVGfx ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 366 of file C4Gui.cpp.

References C4GUI::Element::DrawHVBar(), C4Rect::Hgt, C4GUI::Element::rcBounds, C4BltTransform::SetRotate(), C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::ScrollBar::DrawElement().

367  {
368  C4DrawTransform trf;
369  float fOffX = cgo.TargetX + rcBounds.x + rcBounds.Hgt/2;
370  float fOffY = cgo.TargetY + rcBounds.y + rcBounds.Hgt/2;
371  trf.SetRotate(-90.0f, fOffX, fOffY);
372 
373  DrawHVBar(cgo, rFacets, trf, rcBounds.Wdt);
374  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:376
int32_t Wdt
Definition: C4Rect.h:32
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
void SetRotate(float iAngle, float fOffX, float fOffY)
int32_t Hgt
Definition: C4Rect.h:32
float TargetY
Definition: C4Facet.h:167

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Element::DrawHVBar ( C4TargetFacet cgo,
DynBarFacet rFacets,
C4DrawTransform trf,
int32_t  iMiddleLength 
)
protectedinherited

Definition at line 376 of file C4Gui.cpp.

References C4Facet::DrawT(), C4GUI::DynBarFacet::fctBegin, C4GUI::DynBarFacet::fctEnd, C4GUI::DynBarFacet::fctMiddle, C4Facet::Hgt, C4GUI::Element::rcBounds, C4Facet::Surface, C4TargetFacet::TargetX, C4TargetFacet::TargetY, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Element::DrawHBarByVGfx(), and C4GUI::Element::DrawVBar().

377  {
378  int32_t y0 = cgo.TargetY + rcBounds.y;
379  int32_t x0 = cgo.TargetX + rcBounds.x;
380 
381  // draw up arrow
382  rFacets.fctBegin.DrawT(cgo.Surface, x0, y0, 0, 0, &trf);
383 
384  // draw middle part
385  int32_t h = rFacets.fctMiddle.Hgt;
386  int32_t barHeight = iMiddleLength - (rFacets.fctBegin.Hgt + rFacets.fctEnd.Hgt);
387 
388  for (int32_t iY = 0; iY <= barHeight; iY += h)
389  {
390  int32_t h2 = std::min(h, barHeight - iY);
391  rFacets.fctMiddle.Hgt = h2;
392  rFacets.fctMiddle.DrawT(cgo.Surface, x0, y0 + rFacets.fctBegin.Hgt + iY, 0, 0, &trf);
393  }
394  rFacets.fctMiddle.Hgt = h;
395 
396  // draw lower arrow
397  rFacets.fctEnd.DrawT(cgo.Surface, x0, y0 + iMiddleLength - rFacets.fctEnd.Hgt, 0, 0, &trf);
398  }
int Hgt
Definition: C4Surface.h:67
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t x
Definition: C4Rect.h:32
float TargetX
Definition: C4Facet.h:167
C4Surface * Surface
Definition: C4Facet.h:119
float TargetY
Definition: C4Facet.h:167

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::DrawScrollbar ( C4Facet cgo,
int32_t  iTotal,
int32_t  iVisible,
int32_t  iPosition 
)
protectedinherited
void C4GUI::Element::DrawVBar ( C4TargetFacet cgo,
DynBarFacet rFacets 
)
protectedinherited

Definition at line 360 of file C4Gui.cpp.

References C4GUI::Element::DrawHVBar(), C4Rect::Hgt, and C4GUI::Element::rcBounds.

Referenced by C4GUI::ScrollBar::DrawElement().

361  {
362  C4DrawTransform trf(1);
363  DrawHVBar(cgo, rFacets, trf, rcBounds.Hgt);
364  }
void DrawHVBar(C4TargetFacet &cgo, DynBarFacet &rFacets, C4DrawTransform &trf, int32_t iMiddleLength)
Definition: C4Gui.cpp:376
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void C4GUI::Container::ElementPosChanged ( Element pOfElement)
inlineprotectedvirtualinherited

Reimplemented in C4GUI::Screen, C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::ListBox, and C4GUI::ScrollWindow.

Definition at line 754 of file C4Gui.h.

Referenced by C4GUI::ScrollWindow::ElementPosChanged(), and C4GUI::Element::UpdatePos().

754 { } // called when an element position is changed

Here is the caller graph for this function:

virtual void C4GUI::Container::ElementSizeChanged ( Element pOfElement)
inlineprotectedvirtualinherited

Reimplemented in C4GUI::ContextMenu, C4GUI::TextWindow, C4GUI::ListBox, and C4GUI::ScrollWindow.

Definition at line 753 of file C4Gui.h.

Referenced by C4GUI::ListBox::ElementPosChanged(), C4GUI::TextWindow::ElementPosChanged(), C4GUI::ContextMenu::ElementPosChanged(), C4GUI::ScrollWindow::ElementSizeChanged(), C4GUI::ListBox::ElementSizeChanged(), C4GUI::TextWindow::ElementSizeChanged(), C4GUI::ContextMenu::ElementSizeChanged(), and C4GUI::Element::UpdateSize().

753 { } // called when an element size is changed

Here is the caller graph for this function:

Iterator C4GUI::Container::end ( )
inlineinherited

Definition at line 825 of file C4Gui.h.

Referenced by C4ScriptGuiWindow::ClearPointers(), and C4ScriptGuiWindow::DrawChildren().

825 { return Iterator(nullptr); }

Here is the caller graph for this function:

bool C4Menu::Enter ( bool  fRight = false)
inherited

Definition at line 488 of file C4Menu.cpp.

References _MAX_FNAME, C4MN_Style_Dialog, C4MN_Style_Info, C4GUI::Dialog::Close(), C4MenuItem::Command, C4MenuItem::Command2, C4Menu::fActive, C4Menu::GetSelectedItem(), C4Menu::IsActive(), C4Menu::MenuCommand(), C4Menu::Permanent, SCopy(), C4Menu::Style, and C4Menu::TryClose().

Referenced by C4Menu::Control(), and OnUserEnter().

489 {
490  // Not active
491  if (!IsActive()) return false;
492  if (Style==C4MN_Style_Info) return false;
493  // Get selected item
494  C4MenuItem *pItem = GetSelectedItem();
495  if (!pItem)
496  {
497  // okay for dialogs: Just close them
498  if (Style == C4MN_Style_Dialog) TryClose(false, true);
499  return true;
500  }
501  // Copy command to buffer (menu might be cleared)
502  char szCommand[_MAX_FNAME+30+1];
503  SCopy(pItem->Command,szCommand);
504  if (fRight && pItem->Command2[0]) SCopy(pItem->Command2,szCommand);
505 
506  // Close if not permanent
507  if (!Permanent) { Close(true); fActive = false; }
508 
509  // exec command (note that menu callback may delete this!)
510  MenuCommand(szCommand, false);
511 
512  return true;
513 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:122
int32_t Style
Definition: C4Menu.h:136
virtual bool MenuCommand(const char *szCommand, bool fIsCloseCommand)
Definition: C4Menu.h:231
void Close(bool fOK)
char Command[_MAX_FNAME+30+1]
Definition: C4Menu.h:72
C4MenuItem * GetSelectedItem()
Definition: C4Menu.cpp:586
bool fActive
Definition: C4Menu.h:153
#define _MAX_FNAME
bool IsActive()
Definition: C4Menu.cpp:483
bool TryClose(bool fOK, bool fControl)
Definition: C4Menu.cpp:281
bool Permanent
Definition: C4Menu.h:134
char Command2[_MAX_FNAME+30+1]
Definition: C4Menu.h:73

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::Execute ( )
inherited

Definition at line 906 of file C4Menu.cpp.

References C4GUI::Dialog::Close(), C4Menu::fTextProgressing, Game, C4Menu::IsActive(), C4Game::iTick35, C4Menu::NeedRefill, C4Menu::RefillInternal(), and C4Menu::SetTextProgress().

Referenced by C4FullScreen::Execute(), C4ObjectMenu::Execute(), and C4Player::Execute().

907 {
908  if (!IsActive()) return;
909  // Refill (timer or flag)
910  if (!Game.iTick35 || NeedRefill)
911  if (!RefillInternal())
912  Close(false);
913  // text progress
914  if (fTextProgressing)
915  SetTextProgress(+1, true);
916 }
bool RefillInternal()
Definition: C4Menu.cpp:870
C4Game Game
Definition: C4Globals.cpp:52
int32_t iTick35
Definition: C4Game.h:131
bool fTextProgressing
Definition: C4Menu.h:151
void Close(bool fOK)
bool SetTextProgress(int32_t iToProgress, bool fAdd)
Definition: C4Menu.cpp:961
bool IsActive()
Definition: C4Menu.cpp:483
bool NeedRefill
Definition: C4Menu.h:135

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4GUI::Dialog::Execute2 ( )
inherited

Definition at line 691 of file C4GuiDialogs.cpp.

References C4GUI::Dialog::Execute().

692  {
693  // execute
694  if (Execute()) return true;
695  // delete self if closed
696  delete this;
697  return false;
698  }

Here is the call graph for this function:

bool C4GUI::Dialog::FadeIn ( Screen pOnScreen)
inherited

Definition at line 715 of file C4GuiDialogs.cpp.

References C4GUI::Dialog::eFade, C4GUI::Element::fVisible, C4GUI::Screen::GetScreenS(), C4GUI::Dialog::iFade, C4GUI::Dialog::OnShown(), and C4GUI::Screen::ShowDialog().

Referenced by C4Network2::DoLobby(), and C4Startup::SwitchDialog().

716  {
717  // default screen
718  if (!pOnScreen) pOnScreen = Screen::GetScreenS();
719  // fade in there
720  pOnScreen->ShowDialog(this, true);
721  iFade = 0;
722  eFade = eFadeIn;
723  fVisible = true;
724  OnShown();
725  // done, success
726  return true;
727  }
Fade eFade
Definition: C4Gui.h:2084
virtual void OnShown()
Definition: C4Gui.h:2208
static Screen * GetScreenS()
Definition: C4Gui.h:2626
bool fVisible
Definition: C4Gui.h:383
int32_t iFade
Definition: C4Gui.h:2083

Here is the call graph for this function:

Here is the caller graph for this function:

void C4GUI::Dialog::FadeOut ( bool  fCloseWithOK)
inherited

Definition at line 729 of file C4GuiDialogs.cpp.

References C4GUI::Screen::CloseDialog(), C4GUI::Dialog::eFade, C4GUI::Dialog::fOK, C4GUI::Element::fVisible, C4GUI::Element::GetScreen(), C4GUI::Dialog::IsShown(), and C4GUI::Dialog::OnClosed().

Referenced by C4Startup::SwitchDialog().

730  {
731  // only if shown, or being faded in
732  if (!IsShown() && (!fVisible || eFade!=eFadeIn)) return;
733  // set OK flag
734  this->fOK = fCloseWithOK;
735  // fade out
736  Screen *pOnScreen = GetScreen();
737  if (!pOnScreen) return;
738  pOnScreen->CloseDialog(this, true);
739  eFade = eFadeOut;
740  // do callback - last call, because it might do perilous things
741  OnClosed(fCloseWithOK);
742  }
Fade eFade
Definition: C4Gui.h:2084
bool IsShown()
Definition: C4Gui.h:2147
bool fOK
Definition: C4Gui.h:2082
virtual void OnClosed(bool fOK)
bool fVisible
Definition: C4Gui.h:383
friend class Screen
Definition: C4Gui.h:2216
virtual Screen * GetScreen()
Definition: C4Gui.cpp:290

Here is the call graph for this function:

Here is the caller graph for this function:

C4Rect& C4GUI::Element::GetBounds ( )
inlineinherited

Definition at line 445 of file C4Gui.h.

References C4GUI::Element::rcBounds.

Referenced by C4GUI::ListBox::AddElement(), C4Menu::AdjustPosition(), C4GameOverDlg::C4GameOverDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextMenu::CheckOpenSubmenu(), C4GUI::ListBox::ContractToElementHeight(), C4MapFolderData::CreateGUIElements(), C4GUI::Screen::DoContext(), C4GUI::Window::Draw(), C4GUI::ListBox::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::TextWindow::ElementPosChanged(), C4GUI::TextWindow::ElementSizeChanged(), C4GUI::Dialog::GetMarginTop(), C4GUI::ScrollBar::GetMaxScroll(), C4GUI::GetScreenHgt(), C4GUI::GetScreenWdt(), C4Menu::InitSize(), C4GUI::ListBox::InsertElement(), C4GUI::ScrollWindow::IsRangeInView(), C4StartupPlrSelDlg::PlayerListItem::Load(), C4GUI::Window::MouseInput(), C4GUI::ScrollBar::MouseInput(), C4GUI::ListBox::MouseInput(), C4GUI::Screen::MouseInput(), C4StartupPlrSelDlg::OnNewBtn(), C4GUI::ScrollBar::OnPosChanged(), C4StartupPlrSelDlg::OnPropertyBtn(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollBy(), C4GUI::ListBox::ScrollItemInView(), C4GUI::ScrollWindow::ScrollPages(), C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ScrollWindow::ScrollToBottom(), C4GUI::Tabular::SetGfx(), C4GoalDisplay::SetGoals(), C4GUI::TextWindow::SetPicture(), C4GUI::Dialog::SetTitle(), C4GUI::ScrollBar::Update(), C4GUI::ScrollWindow::Update(), C4StartupPlrSelDlg::PlayerListItem::UpdateCore(), C4GUI::ListBox::UpdateElementPosition(), C4Menu::UpdateElementPositions(), C4GUI::ListBox::UpdateElementPositions(), C4GUI::ScrollWindow::UpdateOwnPos(), C4Menu::UpdateScrollBar(), and C4GUI::TextWindow::UpdateSize().

445 { return rcBounds; }
C4Rect rcBounds
Definition: C4Gui.h:385

Here is the caller graph for this function:

virtual C4Rect& C4GUI::Window::GetClientRect ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 864 of file C4Gui.h.

References C4GUI::Window::rcClientRect.

Referenced by C4GameOverDlg::C4GameOverDlg(), C4LeagueSignupDialog::C4LeagueSignupDialog(), C4StartupMainDlg::C4StartupMainDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupOptionsDlg::C4StartupOptionsDlg(), C4StartupPlrColorPickerDlg::C4StartupPlrColorPickerDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4StartupPlrSelDlg::C4StartupPlrSelDlg(), C4StartupScenSelDlg::C4StartupScenSelDlg(), C4GUI::ContextMenu::CheckOpenSubmenu(), C4GUI::ListBox::ContractToElementHeight(), C4MapFolderData::CreateGUIElements(), C4GUI::InfoDialog::CreateSubComponents(), C4GUI::Window::Draw(), C4GUI::ListBox::DrawElement(), C4GUI::ContextMenu::DrawElement(), C4GUI::FullscreenDialog::FullscreenDialog(), C4GUI::ListBox::GetItemWidth(), C4FileSelDlg::InitElements(), C4GUI::InputDialog::InputDialog(), C4GUI::LabeledEdit::LabeledEdit(), C4GameLobby::MainDlg::MainDlg(), C4GUI::MessageDialog::MessageDialog(), C4GUI::Window::MouseInput(), C4GUI::ContextMenu::MouseInput(), C4GUI::Screen::MouseInput(), C4GUI::ScrollBar::OnPosChanged(), C4GUI::ProgressDialog::ProgressDialog(), C4GameLobby::ScenDesc::ScenDesc(), C4StartupScenSelDlg::ScenListItem::ScenListItem(), C4GUI::ScrollWindow::ScrollBy(), C4GUI::ScrollWindow::ScrollRangeInView(), C4GUI::ScrollWindow::ScrollToBottom(), C4GUI::ScrollWindow::ScrollWindow(), C4GoalDisplay::SetGoals(), C4GUI::FullscreenDialog::SetTitle(), C4GUI::TextWindow::TextWindow(), C4GUI::ScrollBar::Update(), C4GUI::ListBox::UpdateColumnCount(), and C4GUI::TextWindow::UpdateSize().

864 { return rcClientRect; }
C4Rect rcClientRect
Definition: C4Gui.h:851

Here is the caller graph for this function:

C4Rect C4GUI::Element::GetContainedClientRect ( )
inlineinherited

Definition at line 448 of file C4Gui.h.

References C4GUI::Element::GetClientRect(), C4Rect::x, and C4Rect::y.

Referenced by C4GUI::Tabular::AddSheet(), C4ChartDialog::C4ChartDialog(), C4Network2ClientListDlg::C4Network2ClientListDlg(), C4Network2StartWaitDlg::C4Network2StartWaitDlg(), C4StartupAboutDlg::C4StartupAboutDlg(), C4StartupNetDlg::C4StartupNetDlg(), C4StartupNetListEntry::C4StartupNetListEntry(), C4FileSelDlg::DefaultListItem::DefaultListItem(), C4ChatDlg::DoPlacement(), C4GUI::Element::GetToprightCornerRect(), C4GUI::InputDialog::InputDialog(), C4GameLobby::MainDlg::MainDlg(), C4GUI::TextWindow::TextWindow(), C4Menu::UpdateElementPositions(), C4ChatControl::ChatSheet::NickItem::UpdateOwnPos(), C4FileSelDlg::DefaultListItem::UpdateOwnPos(), C4StartupScenSelDlg::ScenListItem::UpdateOwnPos(), C4GUI::ScrollWindow::UpdateOwnPos(), C4ChatControl::UpdateSize(), C4ChatDlg::UpdateSize(), C4GUI::Tabular::UpdateSize(), and C4GUI::TextWindow::UpdateSize().

448 { C4Rect rc=GetClientRect(); rc.x=rc.y=0; return rc; }
Definition: C4Rect.h:29
int32_t y
Definition: C4Rect.h:32
int32_t x
Definition: C4Rect.h:32
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:447

Here is the call graph for this function:

Here is the caller graph for this function:

virtual Container* C4GUI::Container::GetContainer ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 831 of file C4Gui.h.

831 { return this; } // returns parent for elements; this for containers
virtual ContextHandler* C4GUI::Dialog::GetContextHandler ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 2211 of file C4Gui.h.

References C4GUI::Element::pContextHandler.

2212  { return pContextHandler; }
ContextHandler * pContextHandler
Definition: C4Gui.h:381
virtual int32_t C4MainMenu::GetControllingPlayer ( )
inlineprotectedvirtual

Reimplemented from C4Menu.

Definition at line 69 of file C4MainMenu.h.

References Player.

69 { return Player; }
int32_t Player
Definition: C4MainMenu.h:41
virtual class Control* C4GUI::Dialog::GetDefaultControl ( )
inlinevirtualinherited

Reimplemented in C4ChatDlg, C4StartupNetDlg, and C4GameLobby::MainDlg.

Definition at line 2129 of file C4Gui.h.

Referenced by C4GUI::Dialog::CharIn().

2129 { return nullptr; }

Here is the caller graph for this function:

int32_t C4GUI::Dialog::GetDefaultTitleHeight ( )
staticinherited

Definition at line 331 of file C4GuiDialogs.cpp.

References C4GUI_MinWoodBarHgt, CStdFont::GetLineHeight(), GraphicsResource, and C4GraphicsResource::TextFont.

332  {
333  // default title font
334  return std::min<int32_t>(::GraphicsResource.TextFont.GetLineHeight(), C4GUI_MinWoodBarHgt);
335  }
int GetLineHeight() const
Definition: C4FontLoader.h:132
#define C4GUI_MinWoodBarHgt
Definition: C4Gui.h:158
C4GraphicsResource GraphicsResource

Here is the call graph for this function:

virtual DialogWindow* C4GUI::Dialog::GetDialogWindow ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 2117 of file C4Gui.h.

References C4GUI::Dialog::pWindow.

2117 { return pWindow; }
DialogWindow * pWindow
Definition: C4Gui.h:2088
virtual Dialog* C4GUI::Dialog::GetDlg ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 2116 of file C4Gui.h.

Referenced by C4GUI::Screen::GetDialog(), C4GUI::Screen::GetFullscreenDialog(), C4GUI::Screen::GetMouseControlledDialogCount(), C4GUI::Screen::GetTopDialog(), C4GUI::Screen::MouseInput(), and C4StartupPlrSelDlg::PlayerListItem::UpdateCore().

2116 { return this; } // this is the dialog

Here is the caller graph for this function:

Element * C4GUI::Container::GetElementByIndex ( int32_t  i)
inherited

Definition at line 223 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, and C4GUI::Element::pNext.

Referenced by C4GUI::ContextMenu::GetIndexedEntry(), C4Menu::GetItem(), C4GUI::Tabular::GetSheet(), and C4GUI::ContextMenu::SelectItem().

224  {
225  // get next until end of list or queried index is reached
226  // if i is negative or equal or larger than childcount, the loop will never break and nullptr returned
227  Element *pEl;
228  for (pEl = pFirst; i-- && pEl; pEl=pEl->pNext) {}
229  return pEl;
230  }
Element * pFirst
Definition: C4Gui.h:750
Element * pNext
Definition: C4Gui.h:377

Here is the caller graph for this function:

int32_t C4GUI::Container::GetElementCount ( )
inherited

Definition at line 232 of file C4GuiContainers.cpp.

References C4GUI::Container::pFirst, and C4GUI::Element::pNext.

Referenced by C4ScriptGuiWindow::ExecuteCommand(), C4GUI::Tabular::GetSheetCount(), and C4GUI::ListBox::SortElements().

233  {
234  int32_t cnt=0;
235  for (Element *pEl = pFirst; pEl; pEl=pEl->pNext) ++cnt;
236  return cnt;
237  }
Element * pFirst
Definition: C4Gui.h:750
Element * pNext
Definition: C4Gui.h:377

Here is the caller graph for this function:

virtual Element* C4GUI::Container::GetFirstContained ( )
inlinevirtualinherited

Reimplemented from C4GUI::Element.

Definition at line 773 of file C4Gui.h.

References C4GUI::Container::pFirst.

Referenced by C4GUI::ListBox::OnGetFocus().

773 { return pFirst; }
Element * pFirst
Definition: C4Gui.h:750

Here is the caller graph for this function:

Element * C4GUI::Container::GetFirstNestedElement ( bool  fBackwards)
virtualinherited

Reimplemented from C4GUI::Element.

Definition at line 204 of file C4GuiContainers.cpp.

References C4GUI::Element::GetFirstNestedElement(), C4GUI::Container::pFirst, and C4GUI::Container::pLast.

Referenced by C4GUI::Container::GetNextNestedElement().

205  {
206  // get first/last in own list
207  if (pFirst) return (fBackwards ? pLast : pFirst)->GetFirstNestedElement(fBackwards);
208  // no own list: return this one
209  return this;
210  }
Element * pLast
Definition: C4Gui.h:750
Element * pFirst
Definition: C4Gui.h:750

Here is the call graph for this function:

Here is the caller graph for this function:

Control* C4GUI::Dialog::GetFocus ( )
inlineinherited

Definition at line 2115 of file C4Gui.h.

References C4GUI::Dialog::pActiveCtrl.

Referenced by C4StartupScenSelDlg::DeselectAll(), C4StartupNetDlg::DoOK(), C4GUI::Control::MouseInput(), C4GUI::RenameEdit::OnFinishInput(), C4GUI::RenameEdit::RenameEdit(), and C4GUI::Container::SetVisibility().

2115 { return pActiveCtrl; }
Control * pActiveCtrl
Definition: C4Gui.h:2080

Here is the caller graph for this function:

FrameDecoration* C4GUI::Dialog::GetFrameDecoration ( ) const
inlineinherited

Definition at line 2201 of file C4Gui.h.

References C4GUI::Dialog::pFrameDeco.

2201 { return pFrameDeco; }
FrameDecoration * pFrameDeco
Definition: C4Gui.h:2089
int32_t C4GUI::Element::GetHeight ( )
inlineinherited

Definition at line 444 of file C4Gui.h.

References C4Rect::Hgt.

Referenced by C4GUI::Screen::ShowDialog().

444 { return rcBounds.Hgt; }
C4Rect rcBounds
Definition: C4Gui.h:385
int32_t Hgt
Definition: C4Rect.h:32

Here is the caller graph for this function:

virtual const char* C4Menu::GetID ( )
inlineprotectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 240 of file C4Menu.h.

240 { return 0; } // no ID needed, because it's a viewport dlg
int32_t C4Menu::GetIdentification ( )
inherited

Definition at line 615 of file C4Menu.cpp.

References C4Menu::Identification.

Referenced by C4Player::Execute().

616 {
617  return Identification;
618 }
int32_t Identification
Definition: C4Menu.h:141

Here is the caller graph for this function:

C4MenuItem * C4Menu::GetItem ( int32_t  iIndex)
inherited

Definition at line 515 of file C4Menu.cpp.

References C4GUI::Container::GetElementByIndex(), and C4Menu::pClientWindow.

Referenced by C4Menu::AdjustSelection(), C4Menu::ClearItems(), C4Menu::ClearPointers(), C4Menu::GetSelectedItem(), C4Menu::InitLocation(), C4Menu::MoveSelection(), C4Menu::SetSelection(), and C4Menu::SetTextProgress().

516 {
517  return static_cast<C4MenuItem *>(pClientWindow->GetElementByIndex(iIndex));
518 }
C4GUI::ScrollWindow * pClientWindow
Definition: C4Menu.h:149
Element * GetElementByIndex(int32_t i)

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Menu::GetItemCount ( )
inherited

Definition at line 520 of file C4Menu.cpp.

References C4Menu::ItemCount.

Referenced by ActivateMain(), and DoRefillInternal().

521 {
522  return ItemCount;
523 }
int32_t ItemCount
Definition: C4Menu.h:138

Here is the caller graph for this function:

int32_t C4Menu::GetItemHeight ( )
inlineinherited

Definition at line 166 of file C4Menu.h.

References C4Menu::ItemHeight.

166 { return ItemHeight; }
int32_t ItemHeight
Definition: C4Menu.h:139
Element* C4GUI::Container::GetLast ( )
inlineinherited

Definition at line 830 of file C4Gui.h.

References C4GUI::Container::pLast.

Referenced by C4GUI::ListBox::GetLast(), C4Menu::InitSize(), and C4Menu::UpdateScrollBar().

830 { return pLast; }
Element * pLast
Definition: C4Gui.h:750

Here is the caller graph for this function:

virtual Element* C4GUI::Container::GetLastContained ( )
inlinevirtualinherited

Definition at line 774 of file C4Gui.h.

References C4GUI::Container::pLast.

774 { return pLast; }
Element * pLast
Definition: C4Gui.h:750
virtual int32_t C4GUI::Element::GetListItemTopSpacing ( )
inlinevirtualinherited

Reimplemented in C4StartupNetListEntry.

Definition at line 461 of file C4Gui.h.

References C4GUI_DefaultListSpacing.

Referenced by C4GUI::ListBox::AddElement(), C4GUI::ListBox::DrawElement(), and C4GUI::ListBox::UpdateElementPositions().

461 { return C4GUI_DefaultListSpacing; }
#define C4GUI_DefaultListSpacing
Definition: C4Gui.h:123

Here is the caller graph for this function:

virtual bool C4GUI::Element::GetListItemTopSpacingBar ( )
inlinevirtualinherited

Definition at line 462 of file C4Gui.h.

Referenced by C4GUI::ListBox::DrawElement().

462 { return false; }

Here is the caller graph for this function:

virtual int32_t C4Menu::GetMarginBottom ( )
inlineprotectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 258 of file C4Menu.h.

References C4MN_FrameWidth, C4MN_SymbolSize, and C4GUI::Dialog::GetMarginBottom().

Referenced by C4Menu::InitSize().

virtual int32_t GetMarginBottom()
Definition: C4Gui.h:2143
int32_t Extra
Definition: C4Menu.h:140

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int32_t C4Menu::GetMarginLeft ( )
inlineprotectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 259 of file C4Menu.h.

References C4MN_FrameWidth, and C4GUI::Dialog::GetMarginLeft().

Referenced by C4Menu::InitSize().

virtual int32_t GetMarginLeft()
Definition: C4Gui.h:2141

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int32_t C4Menu::GetMarginRight ( )
inlineprotectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 260 of file C4Menu.h.

References C4MN_FrameWidth, and C4GUI::Dialog::GetMarginRight().

Referenced by C4Menu::InitSize().

virtual int32_t GetMarginRight()
Definition: C4Gui.h:2142

Here is the call graph for this function:

Here is the caller graph for this function:

virtual int32_t C4GUI::Dialog::GetMarginTop ( )
inlinevirtualinherited

Reimplemented from C4GUI::Window.

Reimplemented in C4GUI::FullscreenDialog, C4StartupScenSelDlg, C4StartupPlrPropertiesDlg, and C4StartupPlrSelDlg.

Definition at line 2140 of file C4Gui.h.

References C4GUI::Element::GetBounds(), C4GUI::Window::GetMarginTop(), C4Rect::Hgt, and C4GUI::FrameDecoration::iBorderTop.

Referenced by C4Menu::InitSize(), C4GUI::Dialog::SetClientSize(), and C4ScoreboardDlg::Update().

FrameDecoration * pFrameDeco
Definition: C4Gui.h:2089
virtual int32_t GetMarginTop()
Definition: C4Gui.h:873
C4Rect & GetBounds()
Definition: C4Gui.h:445
WoodenLabel * pTitle
Definition: C4Gui.h:2078
int32_t Hgt
Definition: C4Rect.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

Element * C4GUI::Container::GetNextNestedElement ( Element pPrevElement,
bool  fBackwards 
)
inherited

Definition at line 171 of file C4GuiContainers.cpp.

References C4GUI::Element::GetFirstContained(), C4GUI::Element::GetFirstNestedElement(), C4GUI::Container::GetFirstNestedElement(), C4GUI::Element::pNext, C4GUI::Element::pParent, and C4GUI::Element::pPrev.

Referenced by C4GUI::Dialog::AdvanceFocus().

172  {
173  if (fBackwards)
174  {
175  // this is last
176  if (pPrevElement == this) return nullptr;
177  // no previous given?
178  if (!pPrevElement)
179  // then use last nested for backwards search
180  return GetFirstNestedElement(true);
181  // get nested, previous element if present
182  if (pPrevElement->pPrev) return pPrevElement->pPrev->GetFirstNestedElement(true);
183  // if not, return parent (could be this)
184  return pPrevElement->pParent;
185  }
186  else
187  {
188  // forward search: first element is this
189  if (!pPrevElement) return this;
190  // check next nested
191  Element *pEl;
192  if ((pEl = pPrevElement->GetFirstContained())) return pEl;
193  // check next in list, going upwards until this container is reached
194  while (pPrevElement && pPrevElement != this)
195  {
196  if ((pEl = pPrevElement->pNext)) return pEl;
197  pPrevElement = pPrevElement->pParent;
198  }
199  // nothing found
200  }
201  return nullptr;
202  }
virtual Element * GetFirstNestedElement(bool fBackwards)

Here is the call graph for this function:

Here is the caller graph for this function:

const char* C4GUI::Element::GetOwnToolTip ( )
inlineinherited

Definition at line 440 of file C4Gui.h.

References StdStrBuf::getData().

440 { return ToolTip.getData(); } // return tooltip const char*, without fallback to parent
const char * getData() const
Definition: StdBuf.h:450

Here is the call graph for this function:

virtual C4Object* C4Menu::GetParentObject ( )
inlinevirtualinherited

Reimplemented in C4ObjectMenu.

Definition at line 169 of file C4Menu.h.

169 { return nullptr; }
int32_t C4Menu::GetPosition ( )
inherited
Element* C4GUI::Element::GetPrev ( ) const
inlineinherited

Definition at line 450 of file C4Gui.h.

References C4GUI::Element::pPrev.

Referenced by C4GUI::ListBox::AddElement(), C4GUI::Screen::GetDialog(), C4GUI::Screen::GetTopDialog(), C4GUI::Window::MouseInput(), C4GUI::Screen::MouseInput(), and C4GUI::Container::ReverseIterator::operator++().

450 { return pPrev; }
Element * pPrev
Definition: C4Gui.h:377

Here is the caller graph for this function:

Screen * C4GUI::Element::GetScreen ( )
virtualinherited

Reimplemented in C4GUI::Screen, and C4GUI::ContextMenu.

Definition at line 290 of file C4Gui.cpp.

References C4GUI::Element::GetScreen(), and C4GUI::Element::pParent.

Referenced by C4GUI::Dialog::Close(), C4StartupScenSelDlg::DoOK(), C4GUI::Dialog::Draw(), C4GUI::ContextButton::DrawElement(), C4GUI::ComboBox::DrawElement(), C4GUI::Dialog::FadeOut(), C4GUI::Element::GetScreen(), C4GUI::Control::HasDrawFocus(), C4GUI::Dialog::IsActive(), C4StartupScenSelDlg::KeyDelete(), C4GUI::ComboBox::MouseInput(), C4GameOptionButtons::OnBtnComment(), C4GameOptionButtons::OnBtnPassword(), C4StartupPlrPropertiesDlg::OnClosed(), C4StartupPlrPropertiesDlg::OnClrChangeCustom(), C4ChatControl::OnConnectBtn(), C4GUI::CBContextHandler< CBClass >::OnContext(), C4StartupPlrSelDlg::OnDelBtn(), C4StartupPlrSelDlg::OnDelBtnConfirm(), C4StartupPlrSelDlg::OnNewBtn(), C4StartupPlrPropertiesDlg::OnPictureBtn(), C4StartupPlrSelDlg::OnPropertyBtn(), C4StartupMainDlg::OnShown(), C4StartupMainDlg::OnTODO(), C4StartupOptionsDlg::SaveConfig(), C4GUI::Element::SetVisibility(), C4GameLobby::MainDlg::Start(), C4StartupScenSelDlg::StartScenario(), C4ScoreboardDlg::Update(), C4StartupPlrSelDlg::PlayerListItem::UpdateCore(), C4FileSelDlg::UserClose(), and C4ChatControl::UserQueryQuit().

290 { if (pParent) return pParent->GetScreen(); return nullptr; }
Container * pParent
Definition: C4Gui.h:376
virtual Screen * GetScreen()
Definition: C4Gui.cpp:290

Here is the call graph for this function:

Here is the caller graph for this function:

C4MenuItem * C4Menu::GetSelectedItem ( )
inherited

Definition at line 586 of file C4Menu.cpp.

References C4Menu::GetItem(), and C4Menu::Selection.

Referenced by C4Menu::AdjustPosition(), C4Menu::Draw(), C4Menu::DrawElement(), C4Menu::Enter(), C4Player::Execute(), OnSelectionChanged(), C4Menu::SetSelection(), and C4Menu::UpdateElementPositions().

587 {
588  return GetItem(Selection);
589 }
int32_t Selection
Definition: C4Menu.h:137
C4MenuItem * GetItem(int32_t iIndex)
Definition: C4Menu.cpp:515

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4Menu::GetSelection ( )
inherited

Definition at line 602 of file C4Menu.cpp.

References C4Menu::Selection.

Referenced by MenuCommand().

603 {
604  return Selection;
605 }
int32_t Selection
Definition: C4Menu.h:137

Here is the caller graph for this function:

int C4Menu::GetSymbolSize ( )
inlineinherited

Definition at line 165 of file C4Menu.h.

References C4MN_Style_Dialog, and C4SymbolSize.

165 { return (Style == C4MN_Style_Dialog) ? 64 : C4SymbolSize; }
int32_t Style
Definition: C4Menu.h:136
const int C4SymbolSize
Definition: C4Constants.h:58
const char * C4GUI::Element::GetToolTip ( )
inherited

Definition at line 424 of file C4Gui.cpp.

References StdStrBuf::getData(), C4GUI::Element::GetToolTip(), StdStrBuf::isNull(), and C4GUI::Element::pParent.

Referenced by C4GUI::CMouse::Draw(), C4GUI::Element::GetToolTip(), C4GameLobby::MainDlg::OnRightTabContext(), and C4GameLobby::MainDlg::UpdateRightTab().

425  {
426  // fallback to parent tooltip, if own is not assigned
427  return (!pParent || !ToolTip.isNull()) ? ToolTip.getData() : pParent->GetToolTip();
428  }
const char * getData() const
Definition: StdBuf.h:450
const char * GetToolTip()
Definition: C4Gui.cpp:424
Container * pParent
Definition: C4Gui.h:376
bool isNull() const
Definition: StdBuf.h:449

Here is the call graph for this function:

Here is the caller graph for this function:

C4Rect C4GUI::Element::GetToprightCornerRect ( int32_t  iWidth = 16,
int32_t  iHeight = 16,
int32_t  iHIndent = 4,
int32_t  iVIndent = 4,
int32_t  iIndexX = 0 
)
inherited

Definition at line 400 of file C4Gui.cpp.

References C4GUI::Element::GetClientRect(), C4GUI::Element::GetContainedClientRect(), C4GUI::Element::GetContainer(), C4Rect::Hgt, C4Rect::Wdt, C4Rect::x, and C4Rect::y.

Referenced by C4GUI::ContextButton::ContextButton(), C4GUI::Dialog::SetTitle(), and C4GUI::Dialog::UpdateSize().

401  {
402  // bounds by topright corner of element
403  C4Rect rtBounds = (GetContainer() != this) ? GetClientRect() : GetContainedClientRect();
404  rtBounds.x += rtBounds.Wdt - (iWidth + iHIndent) * (iIndexX + 1);
405  rtBounds.y += iVIndent;
406  rtBounds.Wdt = rtBounds.Hgt = iHeight;
407  return rtBounds;
408  }
virtual Container * GetContainer()
Definition: C4Gui.h:410
Definition: C4Rect.h:29
C4Rect GetContainedClientRect()
Definition: C4Gui.h:448
int32_t Wdt
Definition: C4Rect.h:32
int32_t y
Definition: C4Rect.h:32
int32_t x
Definition: C4Rect.h:32
virtual C4Rect & GetClientRect()
Definition: C4Gui.h:447
int32_t Hgt
Definition: C4Rect.h:32

Here is the call graph for this function:

Here is the caller graph for this function:

C4Viewport * C4Menu::GetViewport ( )
protectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 996 of file C4Menu.cpp.

References C4ViewportList::GetFirstViewport(), C4Viewport::GetNext(), and Viewports.

Referenced by C4ObjectMenu::IsReadOnly().

997 {
998  // ask all viewports
999  for (C4Viewport *pVP = ::Viewports.GetFirstViewport(); pVP; pVP = pVP->GetNext())
1000  if (pVP->IsViewportMenu(this))
1001  return pVP;
1002  // none matching
1003  return nullptr;
1004 }
C4Viewport * GetFirstViewport()
Definition: C4Viewport.h:156
C4Viewport * GetNext()
Definition: C4Viewport.h:66
C4ViewportList Viewports
Definition: C4Viewport.cpp:841

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t C4GUI::Element::GetWidth ( )
inlineinherited

Definition at line 443 of file C4Gui.h.

References C4Rect::Wdt.

Referenced by C4GUI::Screen::ShowDialog().

443 { return rcBounds.Wdt; }
int32_t Wdt
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385

Here is the caller graph for this function:

virtual int32_t C4Menu::GetZOrdering ( )
inlineprotectedvirtualinherited

Reimplemented from C4GUI::Dialog.

Definition at line 251 of file C4Menu.h.

251 { return -1; }
virtual bool C4GUI::Dialog::HasBackground ( )
inlinevirtualinherited

Reimplemented in C4StartupScenSelDlg, C4StartupPlrSelDlg, and C4StartupNetDlg.

Definition at line 2154 of file C4Gui.h.

Referenced by C4GUI::Screen::Draw().

2154 { return false; } // true if dlg draws screen background (fullscreen dialogs only)

Here is the caller graph for this function:

bool C4Menu::HasMouse ( )
protectedinherited

Definition at line 1152 of file C4Menu.cpp.

References C4PlayerList::Get(), C4Menu::GetControllingPlayer(), C4Player::MouseControl, NO_OWNER, and Players.

Referenced by C4Menu::SetSelection(), and C4Menu::UpdateElementPositions().

1153 {
1154  int32_t iPlayer = GetControllingPlayer();
1155  if (iPlayer == NO_OWNER) return true; // free view dialog also has the mouse
1156  C4Player *pPlr = ::Players.Get(iPlayer);
1157  if (pPlr && pPlr->MouseControl) return true;
1158  return false;
1159 }
int32_t MouseControl
Definition: C4Player.h:94
C4Player * Get(int iPlayer) const
C4PlayerList Players
const int NO_OWNER
Definition: C4Constants.h:138
virtual int32_t GetControllingPlayer()
Definition: C4Menu.h:238

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4Menu::HasPortrait ( )
inlineprotectedinherited

Definition at line 242 of file C4Menu.h.

References C4Menu::fHasPortrait.

Referenced by C4Menu::InitLocation(), C4Menu::InitSize(), C4Menu::SetTextProgress(), and C4Menu::UpdateElementPositions().

242 { return fHasPortrait; } // dialog menus only: Whether a portrait is shown in the topleft
bool fHasPortrait
Definition: C4Menu.h:150

Here is the caller graph for this function:

bool C4MainMenu::Init ( C4FacetSurface fctSymbol,
const char *  szEmpty,
int32_t  iPlayer,
int32_t  iExtra = C4MN_Extra_None,
int32_t  iExtraData = 0,
int32_t  iId = 0,
int32_t  iStyle = C4MN_Style_Normal 
)

Definition at line 50 of file C4MainMenu.cpp.

References C4Menu::DoInit(), and Player.

Referenced by ActivateHostility(), and ActivateMain().

51 {
52  if (!DoInit(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle)) return false;
53  Player=iPlayer;
54  return true;
55 }
int32_t Player
Definition: C4MainMenu.h:41
bool DoInit(C4FacetSurface &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4Menu.cpp:301

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::InitLocation ( C4Facet cgo)
protectedinherited

Definition at line 627 of file C4Menu.cpp.

References C4Menu::AdjustPosition(), C4Menu::Alignment, CStdFont::BreakMessage(), C4MN_Align_Bottom, C4MN_Align_Free, C4MN_Align_Left, C4MN_Align_Right, C4MN_Align_Top, C4MN_DefInfoWdt, C4MN_DlgLines, C4MN_DlgPortraitIndent, C4MN_DlgPortraitWdt, C4MN_DlgWdt, C4MN_FrameWidth, C4MN_Style_Context, C4MN_Style_Dialog, C4MN_Style_Info, C4MN_Style_Normal, C4MN_SymbolSize, C4PictureSize, C4SymbolSize, C4MenuItem::Caption, C4Menu::Caption, C4Menu::Columns, C4GraphicsResource::FontRegular, StdStrBuf::getData(), C4Menu::GetItem(), CStdFont::GetLineHeight(), CStdFont::GetTextExtent(), GraphicsResource, C4Menu::HasPortrait(), C4Rect::Hgt, C4Facet::Hgt, C4MenuItem::InfoCaption, C4Menu::InitSize(), C4Menu::ItemCount, C4Menu::ItemHeight, C4Menu::ItemWidth, C4Menu::Lines, C4GUI::Element::rcBounds, C4GUI::Window::SetPos(), C4GUI::Container::SetVisibility(), C4Menu::Style, C4Menu::UpdateElementPositions(), C4Menu::UpdateScrollBar(), C4Rect::Wdt, C4Facet::Wdt, C4Rect::x, X, and C4Rect::y.

Referenced by C4Menu::Draw().

628 {
629 
630  // Item size by style
631  switch (Style)
632  {
633  case C4MN_Style_Normal:
635  break;
636  case C4MN_Style_Context:
637  {
639  int32_t iWdt, iHgt;
641  // FIXME: Blah. This stuff should be calculated correctly by pTitle.
642  ItemWidth += ItemHeight + 16;
643  C4MenuItem *pItem;
644  for (int i = 0; (pItem = GetItem(i)); ++i)
645  {
646  ::GraphicsResource.FontRegular.GetTextExtent(pItem->Caption, iWdt, iHgt, true);
647  ItemWidth = std::max(ItemWidth, iWdt + pItem->GetSymbolWidth(ItemHeight));
648  }
649  ItemWidth += 3; // Add some extra space so text doesn't touch right border frame...
650  break;
651  }
652  case C4MN_Style_Info:
653  {
654  // calculate size from a default size determined by a window width of C4MN_DefInfoWdt
655  int32_t iWdt,iHgt,iLargestTextWdt;
657  iLargestTextWdt = iWdt + 2 * C4MN_SymbolSize + C4MN_FrameWidth;
658  ItemWidth=std::min<int>(cgoArea.Wdt - 2*C4MN_FrameWidth, std::max(iLargestTextWdt, C4MN_DefInfoWdt));
659  ItemHeight=0;
660  StdStrBuf sText;
661  C4MenuItem *pItem;
662  for (int32_t i=0; (pItem=GetItem(i)); ++i)
663  {
665  ::GraphicsResource.FontRegular.GetTextExtent(sText.getData(),iWdt,iHgt, true);
666  assert(iWdt <= ItemWidth);
667  ItemWidth=std::max(ItemWidth,iWdt); ItemHeight=std::max(ItemHeight,iHgt);
668  iLargestTextWdt = std::max(iLargestTextWdt, iWdt);
669  }
670  // although width calculation is done from C4MN_DefInfoWdt, this may be too large for some very tiny info windows
671  // so make sure no space is wasted
672  ItemWidth = std::min(ItemWidth, iLargestTextWdt);
673  // Add some extra space so text doesn't touch right border frame...
674  ItemWidth += 3;
675  // Now add some space to show the picture on the left
677  // And set a minimum item height (again, for the picture)
678  ItemHeight = std::max<int>(ItemHeight, C4PictureSize);
679  break;
680  }
681 
682  case C4MN_Style_Dialog:
683  {
684  // dialog window: Item width is whole dialog, portrait subtracted if any
685  // Item height varies
686  int32_t iWdt,iHgt;
688  ItemWidth=std::min<int>(cgoArea.Wdt - 2*C4MN_FrameWidth, std::max<int>(iWdt + 2 * C4MN_SymbolSize + C4MN_FrameWidth, C4MN_DlgWdt));
689  ItemHeight=iHgt; // Items may be multiline and higher
690  if (HasPortrait())
691  {
692  // subtract portrait only if this would not make the dialog too small
693  if (ItemWidth > C4MN_DlgPortraitWdt*2 && cgoArea.Hgt > cgoArea.Wdt)
695  }
696  }
697  }
698 
699  int DisplayedItemCount = ItemCount - HasPortrait();
700  if (Style == C4MN_Style_Dialog)
702  else
703  Lines = DisplayedItemCount/Columns+std::min<int32_t>(DisplayedItemCount%Columns,1);
704  // adjust by max. height
705  Lines=std::max<int32_t>(std::min<int32_t>((cgoArea.Hgt-100)/std::max<int32_t>(ItemHeight,1),Lines),1);
706 
707  InitSize();
708  int32_t X,Y;
710  {
711  X = rcBounds.x;
712  Y = rcBounds.y;
713  }
714  else
715  {
716  X = (cgoArea.Wdt - rcBounds.Wdt)/2;
717  Y = (cgoArea.Hgt - rcBounds.Hgt)/2;
718  }
719  // Alignment
721  if (Alignment & C4MN_Align_Right) X=cgoArea.Wdt-2*C4SymbolSize-rcBounds.Wdt;
723  if (Alignment & C4MN_Align_Bottom) Y=cgoArea.Hgt-C4SymbolSize-rcBounds.Hgt;
724  if (Alignment & C4MN_Align_Free) { X=Clamp<int32_t>(X,0,cgoArea.Wdt-rcBounds.Wdt); Y=Clamp<int32_t>(Y,0,cgoArea.Hgt-rcBounds.Hgt); }
725  // Centered (due to small viewport size)
726  if (rcBounds.Wdt>cgoArea.Wdt-2*C4SymbolSize) X=(cgoArea.Wdt-rcBounds.Wdt)/2;
727  if (rcBounds.Hgt>cgoArea.Hgt-2*C4SymbolSize) Y=(cgoArea.Hgt-rcBounds.Hgt)/2;
728  SetPos(X, Y);
729 
730  // Position initialized: Make it visible to be used!
731  SetVisibility(true);
732 
733  // now align all menu items correctly
735 
736  // and correct scroll pos
737  UpdateScrollBar();
738  AdjustPosition();
739 }
const char * getData() const
Definition: StdBuf.h:450
int32_t ItemHeight
Definition: C4Menu.h:139
int GetLineHeight() const
Definition: C4FontLoader.h:132
void SetPos(int32_t iXPos, int32_t iYPos)
Definition: C4Gui.h:860
const int32_t C4MN_DlgWdt
Definition: C4Menu.cpp:37
int32_t Style
Definition: C4Menu.h:136
int32_t ItemWidth
Definition: C4Menu.h:139
int32_t Alignment
Definition: C4Menu.h:144
bool GetTextExtent(const char *szText, int32_t &rsx, int32_t &rsy, bool fCheckMarkup=true)
C4GraphicsResource GraphicsResource
virtual void SetVisibility(bool fToValue)
int32_t Wdt
Definition: C4Rect.h:32
int32_t ItemCount
Definition: C4Menu.h:138
int32_t y
Definition: C4Rect.h:32
C4Rect rcBounds
Definition: C4Gui.h:385
const int32_t C4MN_DefInfoWdt
Definition: C4Menu.cpp:36
void UpdateScrollBar()
Definition: C4Menu.cpp:769
const int32_t C4MN_DlgPortraitIndent
Definition: C4Menu.cpp:42
const int32_t C4MN_DlgLines
Definition: C4Menu.cpp:38
std::tuple< std::string, int > BreakMessage(const char *szMsg, int iWdt, bool fCheckMarkup, float fZoom=1.0f)
C4MenuItem * GetItem(int32_t iIndex)
Definition: C4Menu.cpp:515
void AdjustPosition()
Definition: C4Menu.cpp:591
int32_t x
Definition: C4Rect.h:32
const int C4PictureSize
Definition: C4Constants.h:60
char InfoCaption[2 *C4MaxTitle+1]
Definition: C4Menu.h:74
bool HasPortrait()
Definition: C4Menu.h:242
const int C4SymbolSize
Definition: C4Constants.h:58
void InitSize()
Definition: C4Menu.cpp:742
int32_t Columns
Definition: C4Menu.h:142
#define X(sdl, oc)
const int32_t C4MN_DlgPortraitWdt
Definition: C4Menu.cpp:41
int32_t Hgt
Definition: C4Rect.h:32
void UpdateElementPositions()
Definition: C4Menu.cpp:1006
char Caption[C4MaxTitle+1]
Definition: C4Menu.h:147
int32_t Lines
Definition: C4Menu.h:143
char Caption[C4MaxTitle+1]
Definition: C4Menu.h:71

Here is the call graph for this function:

Here is the caller graph for this function:

bool C4MainMenu::InitRefSym ( const C4Facet fctSymbol,
const char *  szEmpty,
int32_t  iPlayer,
int32_t  iExtra = C4MN_Extra_None,
int32_t  iExtraData = 0,
int32_t  iId = 0,
int32_t  iStyle = C4MN_Style_Normal 
)

Definition at line 57 of file C4MainMenu.cpp.

References C4Menu::DoInitRefSym(), and Player.

Referenced by ActivateClient(), ActivateDisplay(), ActivateGoals(), ActivateHost(), C4Player::ActivateMenuTeamSelection(), ActivateNewPlayer(), ActivateObserver(), ActivateOptions(), ActivateRules(), ActivateSavegame(), and ActivateSurrender().

58 {
59  if (!DoInitRefSym(fctSymbol, szEmpty, iExtra, iExtraData, iId, iStyle)) return false;
60  Player=iPlayer;
61  return true;
62 }
int32_t Player
Definition: C4MainMenu.h:41
bool DoInitRefSym(const C4Facet &fctSymbol, const char *szEmpty, int32_t iExtra=C4MN_Extra_None, int32_t iExtraData=0, int32_t iId=0, int32_t iStyle=C4MN_Style_Normal)
Definition: C4Menu.cpp:308

Here is the call graph for this function:

Here is the caller graph for this function:

void C4Menu::InitSize ( )
protectedinherited

Definition at line 742 of file C4Menu.cpp.

References C4GUI_ScrollBarWdt, C4MN_DlgLineMargin, C4MN_DlgPortraitIndent, C4MN_DlgPortraitWdt, C4MN_Style_Dialog, C4Menu::Columns, C4GUI::Element::GetBounds(), C4GUI::Container::GetLast(), C4Menu::GetMarginBottom(), C4GUI::Window::GetMarginBottom(), C4Menu::GetMarginLeft(), C4GUI::Window::GetMarginLeft(), C4Menu::GetMarginRight(), C4GUI::Window::GetMarginRight(), C4GUI::Window::GetMarginTop(), C4GUI::Dialog::GetMarginTop(), C4Menu::HasPortrait(), C4Rect::Hgt, C4Menu::ItemHeight, C4Menu::ItemWidth, C4Menu::Lines, C4Menu::pClientWindow, C4GUI::Container::pLast, C4GUI::Element::rcBounds, C4GUI::Element::SetBounds(), C4GUI::ScrollWindow::SetScrollBarEnabled(), C4Menu::Style, C4Menu::UpdateOwnPos(), C4Menu::VisibleCount, C4Rect::x, and C4Rect::y.

Referenced by C4Menu::InitLocation(), C4Menu::SetSize(), and C4Menu::UpdateScrollBar().

743 {
745  // Size calculation
746  int Width, Height;
747  Width=Columns*ItemWidth;
748  Height=Lines*ItemHeight;
750  bool fBarNeeded;
752  // dialogs have auto-enlarge vertically
753  if (pLast && Style == C4MN_Style_Dialog)
754  {
755  Height = std::max<int>(Height, pLast->GetBounds().y + pLast->GetBounds().Hgt + C4MN_DlgLineMargin);
756  fBarNeeded = false;
757  }
758  else
759  fBarNeeded = pLast && pLast->GetBounds().y + pLast->GetBounds().Hgt > pClientWindow->GetBounds().Hgt;
760  // add dlg margins
763  if (fBarNeeded) Width += C4GUI_ScrollBarWdt;