Debian Codegraph @

source/code/DialogBox.hpp

raw symbols SCIP
1 /*
2 ===========================================================================
3 blockattack - Block Attack - Rise of the Blocks
4 Copyright (C) 2005-2016 Poul Sander
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 2 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. See the
14 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://www.gnu.org/licenses/
18
19 Source information and contacts persons can be found at
20 http://www.blockattack.net
21 ===========================================================================
22 */
23
24 #ifndef DIALOGBOX_HPP
25 #define DIALOGBOX_HPP
26
27 #include "sago/GameStateInterface.hpp"
28 #include <string>
29 #include "ReadKeyboard.h"
30 #include <memory>
31 #include "scopeHelpers.hpp"
32 #include "global.hpp"
33
34 struct VirtualKeyboard {
35 const std::string leftChar = "‹";
36 const std::string rightChar = "›";
37 const std::string backspace = "«";
38 std::string alphabet = std::string(_("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
39 "abcdefghijklmnopqrstuvwxyz"
40 ".,:!?+_^@#%&=*")) + leftChar + rightChar + backspace;
41 std::vector<std::string> gamePadChars;
42 std::vector<sago::SagoTextField> gamePadCharFields;
43 int selectedChar = 0;
44 };
45
46 class DialogBox : public sago::GameStateInterface {
47 public:
48 DialogBox(int x, int y, const std::string& name, const std::string& header);
49 DialogBox(const DialogBox& orig) = delete;
50 DialogBox& operator=(const DialogBox& orig) = delete;
51 virtual ~DialogBox();
52
53 bool IsActive() override;
54 void Draw(SDL_Renderer* target) override;
55 void ProcessInput(const SDL_Event& event, bool& processed) override;
56 void SetName(const std::string& name);
57 std::string GetName() const;
58 bool IsUpdated() const;
59 private:
60 void virtualKeyboardWriteSelectedChar(ReadKeyboard* rk, const std::string& insertChar) const;
61 bool isActive = true;
62 bool bMouseUp = false;
63 std::shared_ptr<ReadKeyboard> rk;
64 int x;
65 int y;
66 std::string name;
67 std::string header;
68 bool updated = false;
69 SDL_TextInput textInputScope;
70 sago::SagoTextField headerLabel;
71 sago::SagoTextField enterLabel;
72 sago::SagoTextField cancelLabel;
73 sago::SagoTextField textField;
74 sago::SagoTextField cursorLabel;
75 VirtualKeyboard virtualKeyboard;
76 int oldmousex = 0;
77 int oldmousey = 0;
78 };
79
80 void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height, int width, sago::SagoLogicalResize* resize = nullptr);
81
82 #endif /* DIALOGBOX_HPP */
83