Loading [MathJax]/extensions/TeX/AMSsymbols.js
Cytopia  0.3
A city building simulation game
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PauseMenu Struct Reference

#include <PauseMenu.hxx>

+ Inheritance diagram for PauseMenu:
+ Collaboration diagram for PauseMenu:

Public Member Functions

virtual void draw () const override
 
- Public Member Functions inherited from GameMenu
virtual ~GameMenu ()=default
 
virtual bool isMouseHovered () const
 
virtual void closeSubmenus ()
 

Additional Inherited Members

- Public Types inherited from GameMenu
using Ptr = std::shared_ptr< GameMenu >
 

Detailed Description

Definition at line 6 of file PauseMenu.hxx.

Member Function Documentation

◆ draw()

void PauseMenu::draw ( ) const
overridevirtual

Reimplemented from GameMenu.

Definition at line 13 of file PauseMenu.cxx.

14 {
15  ImVec2 windowSize(300, 400);
16  ImVec2 screenSize = ui::GetIO().DisplaySize;
17 
18  // dont remove yet, need for tuning
19  //bool show = true;
20  //ui::ShowDemoWindow(&show);
21 
22  auto &uiManager = UIManager::instance();
23 
24  const auto &layout = uiManager.getLayouts()["PauseMenuButtons"];
25  ui::SetNextWindowPos(ImVec2((screenSize.x - windowSize.x) / 2, (screenSize.y - windowSize.y) / 2));
26  ui::SetNextWindowSize(windowSize);
27 
28  const ImVec2 buttonSize(200, 40);
29  const ImVec2 buttonOffset((windowSize.x - buttonSize.x) / 2, buttonSize.y / 2);
30 
31  ui::PushFont(layout.font);
32  ui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
33  ui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(0, 0));
34  ui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(buttonOffset.x, 0));
35  ui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(0, buttonOffset.y));
36 
37  bool open = true;
38  ui::BeginCt("PauseMenu", &open,
39  ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoScrollbar |
40  ImGuiWindowFlags_NoScrollWithMouse);
41 
42  ui::Dummy({0.f, (windowSize.y - (buttonSize.y + buttonOffset.y) * 5) / 2});
43  if (ui::ButtonCt("Settings", buttonSize))
44  {
46  uiManager.openMenu<SettingsMenu>();
47  }
48 
49  if (ui::ButtonCt("New Game", buttonSize))
50  {
52  }
53 
54  if (ui::ButtonCt("Save Game", buttonSize))
55  {
56  SignalMediator::instance().signalSaveGame.emit("save.cts");
57  }
58 
59  if (ui::ButtonCt("Load Game", buttonSize))
60  {
61  SignalMediator::instance().signalLoadGame.emit("save.cts");
62  }
63 
64  if (ui::ButtonCt("Quit Game", buttonSize))
65  {
67  }
68 
69  ui::PopFont();
70  ui::PopStyleVar(4);
71 
72  ui::End();
73 }
+ Here is the call graph for this function:

The documentation for this struct was generated from the following files:
SignalMediator::signalSaveGame
Signal::Signal< void(const std::string &)> signalSaveGame
Definition: SignalMediator.hxx:24
Settings::writeFile
void writeFile()
Save settings to file.
Definition: Settings.cxx:57
SettingsMenu
Definition: SettingsMenu.hxx:6
SignalMediator::signalLoadGame
Signal::Signal< void(const std::string &)> signalLoadGame
Definition: SignalMediator.hxx:23
SignalMediator::signalNewGame
Signal::Signal< void(bool)> signalNewGame
Definition: SignalMediator.hxx:18
Singleton< UIManager >::instance
static UIManager & instance(void)
Get an instance of the singleton.
Definition: Singleton.hxx:15
SignalMediator::signalQuitGame
Signal::Signal< void()> signalQuitGame
Definition: SignalMediator.hxx:22