Colobot
maindialog.h
1 /*
2  * This file is part of the Colobot: Gold Edition source code
3  * Copyright (C) 2001-2016, Daniel Roux, EPSITEC SA & TerranovaTeam
4  * http://epsitec.ch; http://colobot.info; http://github.com/colobot
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see http://gnu.org/licenses
18  */
19 
20 #pragma once
21 
22 #include "common/restext.h"
23 
24 #include "math/point.h"
25 
26 #include <vector>
27 #include <functional>
28 
29 
30 class CSettings;
31 class CSoundInterface;
32 class CRobotMain;
33 struct Event;
34 
35 namespace Gfx
36 {
37 class CEngine;
38 class CParticle;
39 } // namespace Gfx
40 
41 namespace Ui
42 {
43 
44 class CInterface;
45 
47 {
48 public:
49  CMainDialog();
50  ~CMainDialog();
51 
52  bool EventProcess(const Event &event);
53 
54 
55  using DialogCallback = std::function<void()>;
56  void StartQuestion(const std::string& text,
57  bool warningYes = false, bool warningNo = false,
58  bool fireParticles = false,
59  DialogCallback yes = nullptr, DialogCallback no = nullptr);
60  void StartQuestion(ResTextType text,
61  bool warningYes = false, bool warningNo = false,
62  bool fireParticles = false,
63  DialogCallback yes = nullptr, DialogCallback no = nullptr);
64  void StartInformation(const std::string& title,
65  const std::string& text,
66  const std::string& details,
67  bool warning = false,
68  bool fireParticles = false,
69  DialogCallback ok = nullptr);
70  void StartPauseMenu();
71  void StopDialog();
72  bool IsDialog();
73 
74 protected:
75  void StartDialog(Math::Point dim, bool fireParticles);
76  void FrameDialog(float rTime);
77 
78 protected:
79  CRobotMain* m_main;
80  Gfx::CEngine* m_engine;
81  Gfx::CParticle* m_particle;
82  CInterface* m_interface;
83  CSoundInterface* m_sound;
84  CSettings* m_settings;
85 
86  enum class DialogType
87  {
88  Question,
89  PauseMenu
90  };
91 
92  bool m_dialogOpen;
93  DialogType m_dialogType;
94  bool m_dialogFireParticles;
95  Math::Point m_dialogPos;
96  Math::Point m_dialogDim;
97  float m_dialogTime;
98  float m_dialogParti;
99 
100  DialogCallback m_callbackYes;
101  DialogCallback m_callbackNo;
102 };
103 
104 } // namespace Ui
Definition: maindialog.h:46
Definition: robotmain.h:108
Point struct and related functions.
Definition: robotmain.h:159
Particle engine.
Definition: particle.h:223
ResTextType
Text resources available for translation.
Definition: restext.h:49
Definition: settings.h:32
Translation and string resource utilities.
2D point
Definition: point.h:50
Namespace for (new) graphics code.
Definition: app.h:49
The graphics engine.
Definition: engine.h:585
Event sent by system, interface or game.
Definition: event.h:735
Definition: interface.h:59
Sound plugin interface.
Definition: sound.h:60