OpenClonk
C4FullScreen Class Reference

#include <C4FullScreen.h>

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

Public Types

enum  WindowKind {
  W_GuiWindow , W_Console , W_Viewport , W_Fullscreen ,
  W_Control
}
 

Public Member Functions

 C4FullScreen ()
 
 ~C4FullScreen () override
 
void Execute ()
 
bool ViewportCheck ()
 
bool ShowAbortDlg ()
 
bool ActivateMenuMain ()
 
void CloseMenu ()
 
bool MenuKeyControl (BYTE command)
 
C4WindowInit (C4AbstractApp *application)
 
void Close () override
 
void Clear () override
 
void CharIn (const char *c) override
 
void PerformUpdate () override
 
virtual C4WindowInit (WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
 
virtual bool ReInit (C4AbstractApp *pApp)
 
virtual void EnumerateMultiSamples (std::vector< int > &samples, int min_expected=0) const
 
bool StorePosition (const char *szWindowName, const char *szSubKey, bool fStoreSize=true)
 
bool RestorePosition (const char *szWindowName, const char *szSubKey, bool fHidden=false)
 
bool GetSize (C4Rect *pRect)
 
void SetSize (unsigned int cx, unsigned int cy)
 
void SetTitle (const char *Title)
 
void FlashWindow ()
 
void GrabMouse (bool grab)
 
virtual void RequestUpdate ()
 

Public Attributes

C4MainMenuMainMenu
 
bool Active {false}
 
C4SurfacepSurface {nullptr}
 
WindowKind eKind
 

Protected Member Functions

virtual C4WindowInit (WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
 

Detailed Description

Definition at line 27 of file C4FullScreen.h.

Member Enumeration Documentation

◆ WindowKind

enum C4Window::WindowKind
inherited
Enumerator
W_GuiWindow 
W_Console 
W_Viewport 
W_Fullscreen 
W_Control 

Definition at line 263 of file C4Window.h.

264  {
265  W_GuiWindow,
266  W_Console,
267  W_Viewport,
268  W_Fullscreen,
269  W_Control // wrapper to a render target control inside a window
270  };
@ W_Fullscreen
Definition: C4Window.h:268
@ W_GuiWindow
Definition: C4Window.h:265
@ W_Control
Definition: C4Window.h:269
@ W_Viewport
Definition: C4Window.h:267
@ W_Console
Definition: C4Window.h:266

Constructor & Destructor Documentation

◆ C4FullScreen()

C4FullScreen::C4FullScreen ( )

Definition at line 36 of file C4FullScreen.cpp.

37 {
38  MainMenu = nullptr;
39 }
C4MainMenu * MainMenu
Definition: C4FullScreen.h:30

References MainMenu.

◆ ~C4FullScreen()

C4FullScreen::~C4FullScreen ( )
override

Definition at line 41 of file C4FullScreen.cpp.

42 {
43  if (MainMenu)
44  {
45  delete MainMenu;
46  }
47  if (pSurface)
48  {
49  delete pSurface;
50  }
51 }
C4Surface * pSurface
Definition: C4Window.h:275

References MainMenu, and C4Window::pSurface.

Member Function Documentation

◆ ActivateMenuMain()

bool C4FullScreen::ActivateMenuMain ( )

Definition at line 181 of file C4FullScreen.cpp.

182 {
183  // Not during game over dialog
185  {
186  return false;
187  }
188  // Close previous
189  CloseMenu();
190  // Open menu
191  MainMenu = new C4MainMenu();
192  return MainMenu->ActivateMain(NO_OWNER);
193 }
const int NO_OWNER
Definition: C4Constants.h:137
static bool IsShown()
Definition: C4GameOverDlg.h:91
bool ActivateMain(int32_t iPlayer)
Definition: C4MainMenu.cpp:566

References C4MainMenu::ActivateMain(), CloseMenu(), C4GameOverDlg::IsShown(), MainMenu, and NO_OWNER.

Referenced by C4Game::InitKeyboard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CharIn()

void C4FullScreen::CharIn ( const char *  c)
overridevirtual

Reimplemented from C4Window.

Definition at line 34 of file C4FullScreen.cpp.

34 { ::pGUI->CharIn(c); }
C4GUIScreen * pGUI
Definition: C4Gui.cpp:1191
virtual bool CharIn(const char *c)
Definition: C4Gui.cpp:779

References C4GUI::Screen::CharIn(), and pGUI.

Here is the call graph for this function:

◆ Clear()

void C4FullScreen::Clear ( )
overridevirtual

Reimplemented from C4Window.

Definition at line 72 of file C4FullScreen.cpp.

73 {
74  if (pSurface)
75  {
76  delete pSurface;
77  }
78  pSurface = nullptr;
80 }
virtual void Clear()
Definition: C4AppT.cpp:102

References C4Window::Clear(), and C4Window::pSurface.

Referenced by C4Application::Clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Close()

void C4FullScreen::Close ( )
overridevirtual

Implements C4Window.

Definition at line 60 of file C4FullScreen.cpp.

61 {
62  if (Game.IsRunning)
63  {
64  ShowAbortDlg();
65  }
66  else
67  {
68  Application.Quit();
69  }
70 }
C4Game Game
Definition: C4Globals.cpp:52
C4Application Application
Definition: C4Globals.cpp:44
void Quit() override
bool ShowAbortDlg()
bool IsRunning
Definition: C4Game.h:140

References Application, Game, C4Game::IsRunning, C4Application::Quit(), and ShowAbortDlg().

Here is the call graph for this function:

◆ CloseMenu()

void C4FullScreen::CloseMenu ( )

Definition at line 195 of file C4FullScreen.cpp.

196 {
197  if (MainMenu)
198  {
199  if (MainMenu->IsActive())
200  {
201  MainMenu->Close(false);
202  }
203  delete MainMenu;
204  MainMenu = nullptr;
205  }
206 }
void Close(bool fOK)
bool IsActive()
Definition: C4Menu.cpp:480

References C4GUI::Dialog::Close(), C4Menu::IsActive(), and MainMenu.

Referenced by ActivateMenuMain(), C4Game::Clear(), C4Game::Init(), C4GameOverDlg::OnShown(), and ViewportCheck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnumerateMultiSamples()

void C4Window::EnumerateMultiSamples ( std::vector< int > &  samples,
int  min_expected = 0 
) const
virtualinherited

Definition at line 105 of file C4AppT.cpp.

105 {}

Referenced by C4StartupOptionsDlg::C4StartupOptionsDlg().

Here is the caller graph for this function:

◆ Execute()

void C4FullScreen::Execute ( )

Definition at line 82 of file C4FullScreen.cpp.

83 {
84  // Execute menu
85  if (MainMenu)
86  {
87  MainMenu->Execute();
88  }
89  // Draw
90  RequestUpdate();
91 }
void Execute()
Definition: C4Menu.cpp:903
virtual void RequestUpdate()
Definition: C4AppT.cpp:112

References C4Menu::Execute(), MainMenu, and C4Window::RequestUpdate().

Referenced by C4Application::Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FlashWindow()

void C4Window::FlashWindow ( )
inherited

Definition at line 75 of file C4AppMac.mm.

76 {
77  [NSApp requestUserAttention:NSCriticalRequest];
78 }

Referenced by C4AbstractApp::NotifyUserIfInactive().

Here is the caller graph for this function:

◆ GetSize()

bool C4Window::GetSize ( C4Rect pRect)
inherited

Definition at line 108 of file C4AppT.cpp.

108 {return false;}

Referenced by C4Application::OnResolutionChanged(), C4GUI::DialogWindow::PerformUpdate(), and C4Game::PreInit().

Here is the caller graph for this function:

◆ GrabMouse()

void C4Window::GrabMouse ( bool  grab)
inherited

Definition at line 107 of file C4AppT.cpp.

107 {}

Referenced by C4Application::GameTick().

Here is the caller graph for this function:

◆ Init() [1/3]

C4Window * C4FullScreen::Init ( C4AbstractApp application)

Definition at line 54 of file C4FullScreen.cpp.

55 {
57  return Init(C4Window::W_Fullscreen, application, C4ENGINECAPTION, &r);
58 }
int GetConfigWidth()
Definition: C4Application.h:83
int GetConfigHeight()
Definition: C4Application.h:84
virtual C4Window * Init(WindowKind windowKind, C4AbstractApp *pApp, const char *Title, const C4Rect *size)
Definition: C4AppT.cpp:109
Definition: C4Rect.h:28

References Application, C4Application::GetConfigHeight(), C4Application::GetConfigWidth(), Init(), and C4Window::W_Fullscreen.

Referenced by C4Application::DoInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init() [2/3]

C4Window * C4Window::Init

Definition at line 322 of file C4AppT.cpp.

109 {return this;}

Referenced by Init().

Here is the caller graph for this function:

◆ Init() [3/3]

C4Window * C4Window::Init ( C4Window::WindowKind  windowKind,
C4AbstractApp pApp,
const char *  Title,
const C4Rect size 
)
protectedvirtualinherited

Definition at line 109 of file C4AppT.cpp.

109 {return this;}

Referenced by C4ConsoleGUIPreviewWindow::C4ConsoleGUIPreviewWindow(), C4ConsoleGUI::CreateConsoleWindow(), C4GUI::DialogWindow::Init(), and C4ViewportWindow::Init().

Here is the caller graph for this function:

◆ MenuKeyControl()

bool C4FullScreen::MenuKeyControl ( BYTE  command)

Definition at line 213 of file C4FullScreen.cpp.

214 {
215  if (MainMenu)
216  {
217  return MainMenu->KeyControl(command);
218  }
219  return false;
220 }
bool KeyControl(BYTE byCom)
Definition: C4Menu.cpp:473

References C4Menu::KeyControl(), and MainMenu.

Referenced by C4Game::InitKeyboard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PerformUpdate()

void C4FullScreen::PerformUpdate ( )
overridevirtual

Reimplemented from C4Window.

Definition at line 208 of file C4FullScreen.cpp.

209 {
211 }
C4GraphicsSystem GraphicsSystem
Definition: C4Globals.cpp:51

References C4GraphicsSystem::Execute(), and GraphicsSystem.

Here is the call graph for this function:

◆ ReInit()

bool C4Window::ReInit ( C4AbstractApp pApp)
virtualinherited

Definition at line 110 of file C4AppT.cpp.

110 {return false;}

◆ RequestUpdate()

void C4Window::RequestUpdate ( )
virtualinherited

Definition at line 112 of file C4AppT.cpp.

112 {}

Referenced by Execute().

Here is the caller graph for this function:

◆ RestorePosition()

bool C4Window::RestorePosition ( const char *  szWindowName,
const char *  szSubKey,
bool  fHidden = false 
)
inherited

Definition at line 111 of file C4AppT.cpp.

111 {return false;}

Referenced by C4GUI::DialogWindow::Init(), and C4ViewportWindow::Init().

Here is the caller graph for this function:

◆ SetSize()

void C4Window::SetSize ( unsigned int  cx,
unsigned int  cy 
)
inherited

Definition at line 113 of file C4AppT.cpp.

113 {}

Referenced by C4Application::DoInit(), C4GUI::DialogWindow::Init(), C4AbstractApp::SetVideoMode(), and C4GUI::Dialog::UpdateSize().

Here is the caller graph for this function:

◆ SetTitle()

void C4Window::SetTitle ( const char *  Title)
inherited

Definition at line 114 of file C4AppT.cpp.

114 {}

Referenced by C4Console::CloseGame(), C4Console::SetCaptionToFilename(), and C4GUI::Dialog::SetTitle().

Here is the caller graph for this function:

◆ ShowAbortDlg()

bool C4FullScreen::ShowAbortDlg ( )

Definition at line 165 of file C4FullScreen.cpp.

166 {
167  // abort dialog already shown
169  {
170  return false;
171  }
172  // not while game over dialog is open
174  {
175  return false;
176  }
177  // show abort dialog
179 }
static bool IsShown()
Definition: C4GameDialogs.h:47
bool ShowRemoveDlg(Dialog *pDlg)

References C4AbortGameDialog::IsShown(), C4GameOverDlg::IsShown(), pGUI, and C4GUI::Screen::ShowRemoveDlg().

Referenced by Close(), C4Game::InitKeyboard(), and C4MainMenu::MenuCommand().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StorePosition()

bool C4Window::StorePosition ( const char *  szWindowName,
const char *  szSubKey,
bool  fStoreSize = true 
)
inherited

Definition at line 153 of file C4WindowSDL.cpp.

153 { return true; }

◆ ViewportCheck()

bool C4FullScreen::ViewportCheck ( )

Definition at line 93 of file C4FullScreen.cpp.

94 {
95  // Not active
96  if (!Active)
97  {
98  return false;
99  }
100 
101 
102  // Determine film mode
103  bool is_film_mode = (Game.C4S.Head.Replay && Game.C4S.Head.Film);
104 
105  // Check viewports
106  C4Player *player;
107  switch (::Viewports.GetViewportCount())
108  {
109  // No viewports: create no-owner viewport
110  case 0:
111  {
112  int player_count = NO_OWNER;
113  // Film mode: create viewport for first player (instead of no-owner)
114  if (is_film_mode)
115  {
116  if ((player = ::Players.First))
117  {
118  player_count = player->Number;
119  }
120  }
121  // Create viewport
122  ::Viewports.CreateViewport(player_count, player_count == NO_OWNER);
123  // Non-film (observer mode)
124  if (!is_film_mode)
125  {
126  // Activate mouse control
127  ::MouseControl.Init(player_count);
128  // Display message for how to open observer menu (this message will be cleared if any owned viewport opens)
129  StdStrBuf key;
130  key.Format("<c ffff00><%s></c>", Game.KeyboardInput.GetKeyCodeNameByKeyName("FullscreenMenuOpen", false).getData());
131  ::GraphicsSystem.FlashMessage(FormatString(LoadResStr("IDS_MSG_PRESSORPUSHANYGAMEPADBUTT"), key.getData()).getData());
132  }
133  }
134  break;
135  // One viewport: do nothing
136  case 1:
137  break;
138  // More than one viewport: remove all no-owner viewports
139  default:
141  break;
142  }
143  // Look for no-owner viewport
144  C4Viewport *no_owner_viewport = ::Viewports.GetViewport(NO_OWNER);
145  // No no-owner viewport found
146  if (!no_owner_viewport)
147  {
148  // Close any open fullscreen menu
149  CloseMenu();
150  }
151  // No-owner viewport present
152  else
153  {
154  // movie mode: player present, and no valid viewport assigned?
155  if (Game.C4S.Head.Replay && Game.C4S.Head.Film && (player = ::Players.First))
156  {
157  // assign viewport to joined player
158  no_owner_viewport->Init(player->Number, true);
159  }
160  }
161  // Done
162  return true;
163 }
C4MouseControl MouseControl
Definition: C4Globals.cpp:47
const char * LoadResStr(const char *id)
Definition: C4Language.h:83
C4PlayerList Players
C4ViewportList Viewports
StdStrBuf FormatString(const char *szFmt,...)
Definition: StdBuf.cpp:270
C4Scenario C4S
Definition: C4Game.h:74
C4KeyboardInput & KeyboardInput
Definition: C4Game.h:96
void FlashMessage(const char *message)
StdStrBuf GetKeyCodeNameByKeyName(const char *szKeyName, bool fShort=false, int32_t iIndex=0)
bool Init(int32_t iPlayer)
C4Player * First
Definition: C4PlayerList.h:31
bool Replay
Definition: C4Scenario.h:72
int32_t Film
Definition: C4Scenario.h:73
C4SHead Head
Definition: C4Scenario.h:232
bool Init(int32_t for_player, bool set_temporary_only)
Definition: C4Viewport.cpp:786
int32_t GetViewportCount()
C4Viewport * GetViewport(int32_t player_nr, C4Viewport *prev=nullptr)
bool CloseViewport(int32_t player_nr, bool silent)
bool CreateViewport(int32_t player_nr, bool silent=false)
bool Active
Definition: C4Window.h:274
const char * getData() const
Definition: StdBuf.h:442
void Format(const char *szFmt,...) GNUC_FORMAT_ATTRIBUTE_O
Definition: StdBuf.cpp:174

References C4Window::Active, C4Game::C4S, CloseMenu(), C4ViewportList::CloseViewport(), C4ViewportList::CreateViewport(), C4SHead::Film, C4PlayerList::First, C4GraphicsSystem::FlashMessage(), StdStrBuf::Format(), FormatString(), Game, StdStrBuf::getData(), C4KeyboardInput::GetKeyCodeNameByKeyName(), C4ViewportList::GetViewport(), C4ViewportList::GetViewportCount(), GraphicsSystem, C4Scenario::Head, C4Viewport::Init(), C4MouseControl::Init(), C4Game::KeyboardInput, LoadResStr(), MouseControl, NO_OWNER, C4ScriptGuiWindowPropertyName::player, Players, C4SHead::Replay, and Viewports.

Referenced by C4Game::InitGameFinal(), C4Game::JoinPlayer(), and C4PlayerList::Remove().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ Active

◆ eKind

WindowKind C4Window::eKind
inherited

Definition at line 276 of file C4Window.h.

◆ MainMenu

◆ pSurface


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