File: StartConditionsPanel.h

package info (click to toggle)
endless-sky 0.10.16-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 414,608 kB
  • sloc: cpp: 73,435; python: 893; xml: 666; sh: 271; makefile: 28
file content (91 lines) | stat: -rw-r--r-- 2,800 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* StartConditionsPanel.h
Copyright (c) 2020-2021 by FranchuFranchu <fff999abc999@gmail.com>
Copyright (c) 2021 by Benjamin Hauch

Endless Sky is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later version.

Endless Sky is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with
this program. If not, see <https://www.gnu.org/licenses/>.
*/

#pragma once

#include "Panel.h"

#include "ClickZone.h"
#include "Color.h"
#include "Information.h"
#include "Point.h"
#include "Rectangle.h"
#include "text/WrappedText.h"

#include <vector>

class PlayerInfo;
class StartConditions;
class UI;



class StartConditionsPanel : public Panel {
	using StartConditionsList = std::vector<StartConditions>;
public:
	StartConditionsPanel(PlayerInfo &player, UI &gamePanels, const StartConditionsList &allScenarios, const Panel *parent);

	virtual void Draw() override final;


protected:
	// Only override the ones you need; the default action is to return false.
	virtual bool KeyDown(SDL_Keycode key, Uint16 mod, const Command &command, bool isNewPress) override final;
	virtual bool Click(int x, int y, MouseButton button, int clicks) override final;
	virtual bool Hover(int x, int y) override final;
	virtual bool Drag(double dx, double dy) override final;
	virtual bool Scroll(double dx, double dy) override final;


private:
	void OnConversationEnd(int);
	void ScrollToSelected();
	void Select(StartConditionsList::iterator it);


private:
	PlayerInfo &player;
	UI &gamePanels;
	// The panel to close when a scenario is chosen.
	const Panel *parent;
	// The list of starting scenarios to pick from.
	StartConditionsList scenarios;
	// The currently selected starting scenario.
	StartConditionsList::iterator startIt;
	// Colors with which to draw text.
	const Color &bright;
	const Color &medium;
	const Color &selectedBackground;
	// The selected scenario's description.
	WrappedText description;
	// Displayed information for the selected scenario.
	Information info;

	bool hasHover = false;
	Point hoverPoint;

	double entriesScroll = 0.;
	double descriptionScroll = 0.;

	// This is a map that will let us figure out which start conditions item the user clicked on.
	std::vector<ClickZone<StartConditionsList::iterator>> startConditionsClickZones;

	// Interface-controlled positions & dimensions.
	Rectangle descriptionBox;
	Rectangle entryBox;
	Rectangle entriesContainer;
	Point entryTextPadding;
};