git repos / blockattack-game

blame: source/code/DialogBox.hpp

normal view · raw

59dcb571 sago007 2016-02-14 15:34 1
/*
7a956470 sago007 2016-02-14 17:09 2
===========================================================================
7a956470 sago007 2016-02-14 17:09 3
blockattack - Block Attack - Rise of the Blocks
7a956470 sago007 2016-02-14 17:09 4
Copyright (C) 2005-2016 Poul Sander
7a956470 sago007 2016-02-14 17:09 5
7a956470 sago007 2016-02-14 17:09 6
This program is free software: you can redistribute it and/or modify
7a956470 sago007 2016-02-14 17:09 7
it under the terms of the GNU General Public License as published by
7a956470 sago007 2016-02-14 17:09 8
the Free Software Foundation, either version 2 of the License, or
7a956470 sago007 2016-02-14 17:09 9
(at your option) any later version.
7a956470 sago007 2016-02-14 17:09 10
7a956470 sago007 2016-02-14 17:09 11
This program is distributed in the hope that it will be useful,
7a956470 sago007 2016-02-14 17:09 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
7a956470 sago007 2016-02-14 17:09 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
7a956470 sago007 2016-02-14 17:09 14
GNU General Public License for more details.
7a956470 sago007 2016-02-14 17:09 15
7a956470 sago007 2016-02-14 17:09 16
You should have received a copy of the GNU General Public License
7a956470 sago007 2016-02-14 17:09 17
along with this program.  If not, see http://www.gnu.org/licenses/
7a956470 sago007 2016-02-14 17:09 18
7a956470 sago007 2016-02-14 17:09 19
Source information and contacts persons can be found at
7a956470 sago007 2016-02-14 17:09 20
http://www.blockattack.net
7a956470 sago007 2016-02-14 17:09 21
===========================================================================
7a956470 sago007 2016-02-14 17:09 22
*/
59dcb571 sago007 2016-02-14 15:34 23
59dcb571 sago007 2016-02-14 15:34 24
#ifndef DIALOGBOX_HPP
59dcb571 sago007 2016-02-14 15:34 25
#define DIALOGBOX_HPP
59dcb571 sago007 2016-02-14 15:34 26
59dcb571 sago007 2016-02-14 15:34 27
#include "sago/GameStateInterface.hpp"
59dcb571 sago007 2016-02-14 15:34 28
#include <string>
59dcb571 sago007 2016-02-14 15:34 29
#include "ReadKeyboard.h"
59dcb571 sago007 2016-02-14 15:34 30
#include <memory>
59dcb571 sago007 2016-02-14 15:34 31
#include "scopeHelpers.hpp"
0c201300 sago007 2016-02-20 12:12 32
#include "global.hpp"
59dcb571 sago007 2016-02-14 15:34 33
45d36316 Poul Sander 2020-06-01 19:23 34
struct VirtualKeyboard {
45d36316 Poul Sander 2020-06-01 19:23 35
	const std::string leftChar = "‹";
45d36316 Poul Sander 2020-06-01 19:23 36
	const std::string rightChar = "›";
45d36316 Poul Sander 2020-06-01 19:23 37
	const std::string backspace = "«";
45d36316 Poul Sander 2020-06-01 19:23 38
	std::string alphabet = std::string(_("ABCDEFGHIJKLMNOPQRSTUVWXYZ"
45d36316 Poul Sander 2020-06-01 19:23 39
	                       "abcdefghijklmnopqrstuvwxyz"
45d36316 Poul Sander 2020-06-01 19:23 40
	                       ".,:!?+_^@#%&=*")) + leftChar + rightChar + backspace;
45d36316 Poul Sander 2020-06-01 19:23 41
	std::vector<std::string> gamePadChars;
45d36316 Poul Sander 2020-06-01 19:23 42
	std::vector<sago::SagoTextField> gamePadCharFields;
45d36316 Poul Sander 2020-06-01 19:23 43
	int selectedChar = 0;
45d36316 Poul Sander 2020-06-01 19:23 44
};
45d36316 Poul Sander 2020-06-01 19:23 45
59dcb571 sago007 2016-02-14 15:34 46
class DialogBox : public sago::GameStateInterface {
59dcb571 sago007 2016-02-14 15:34 47
public:
96e759d9 sago007 2016-04-17 18:45 48
	DialogBox(int x, int y, const std::string& name, const std::string& header);
59dcb571 sago007 2016-02-14 15:34 49
	DialogBox(const DialogBox& orig) = delete;
e373cd75 Poul Sander 2018-11-07 19:21 50
	DialogBox& operator=(const DialogBox& orig) = delete;
59dcb571 sago007 2016-02-14 15:34 51
	virtual ~DialogBox();
e373cd75 Poul Sander 2018-11-07 19:21 52
59dcb571 sago007 2016-02-14 15:34 53
	bool IsActive() override;
59dcb571 sago007 2016-02-14 15:34 54
	void Draw(SDL_Renderer* target) override;
59dcb571 sago007 2016-02-14 15:34 55
	void ProcessInput(const SDL_Event& event, bool &processed) override;
47fef8e8 sago007 2016-11-24 21:37 56
	void SetName(const std::string& name);
47fef8e8 sago007 2016-11-24 21:37 57
	std::string GetName() const;
47fef8e8 sago007 2016-11-24 21:37 58
	bool IsUpdated() const;
59dcb571 sago007 2016-02-14 15:34 59
private:
eb4cc88e Poul Sander 2020-05-30 20:42 60
	void virtualKeyboardWriteSelectedChar(ReadKeyboard *rk, const std::string& insertChar) const;
59dcb571 sago007 2016-02-14 15:34 61
	bool isActive = true;
610539a5 Poul Sander 2019-12-04 16:47 62
	bool bMouseUp = false;
59dcb571 sago007 2016-02-14 15:34 63
	std::shared_ptr<ReadKeyboard> rk;
e373cd75 Poul Sander 2018-11-07 19:21 64
	int x;
59dcb571 sago007 2016-02-14 15:34 65
	int y;
59dcb571 sago007 2016-02-14 15:34 66
	std::string name;
96e759d9 sago007 2016-04-17 18:45 67
	std::string header;
59dcb571 sago007 2016-02-14 15:34 68
	bool updated = false;
59dcb571 sago007 2016-02-14 15:34 69
	SDL_TextInput textInputScope;
34f6ec6d sago007 2018-03-29 16:17 70
	sago::SagoTextField headerLabel;
34f6ec6d sago007 2018-03-29 16:17 71
	sago::SagoTextField enterLabel;
34f6ec6d sago007 2018-03-29 16:17 72
	sago::SagoTextField cancelLabel;
bd788178 sago007 2018-03-31 16:03 73
	sago::SagoTextField textField;
bd788178 sago007 2018-03-31 16:03 74
	sago::SagoTextField cursorLabel;
45d36316 Poul Sander 2020-06-01 19:23 75
	VirtualKeyboard virtualKeyboard;
d0739659 Poul Sander 2020-06-01 19:17 76
	int oldmousex = 0;
d0739659 Poul Sander 2020-06-01 19:17 77
	int oldmousey = 0;
59dcb571 sago007 2016-02-14 15:34 78
};
59dcb571 sago007 2016-02-14 15:34 79
d7f4a888 sago007 2020-06-28 09:22 80
void DrawRectYellow(SDL_Renderer* target, int topx, int topy, int height, int width);
d7f4a888 sago007 2020-06-28 09:22 81
59dcb571 sago007 2016-02-14 15:34 82
#endif /* DIALOGBOX_HPP */
59dcb571 sago007 2016-02-14 15:34 83
1970-01-01 00:00 84