File: PlanetPanel.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 (94 lines) | stat: -rw-r--r-- 2,651 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
92
93
94
/* PlanetPanel.h
Copyright (c) 2014 by Michael Zahniser

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 "Sale.h"

#include <functional>
#include <map>
#include <memory>
#include <string>
#include <vector>

class Interface;
class Outfit;
class Planet;
class PlayerInfo;
class Ship;
class SpaceportPanel;
class System;
class TextArea;



// Dialog that pops up when you land on a planet. The shipyard and outfitter are
// shown in full-screen panels that pop up above this one, but the remaining views
// (trading, jobs, bank, port, and crew) are displayed within this dialog.
class PlanetPanel : public Panel {
public:
	PlanetPanel(PlayerInfo &player, std::function<void()> callback);
	virtual ~PlanetPanel() override;

	virtual void Step() override;
	virtual void Draw() override;


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;

	virtual void Resize() override;


private:
	void TakeOffIfReady();
	void CheckWarningsAndTakeOff();
	void WarningsDialogCallback(bool isOk);
	void TakeOff(bool distributeCargo);


private:
	PlayerInfo &player;
	std::function<void()> callback = nullptr;
	bool requestedLaunch = false;

	const Planet &planet;
	const System &system;

	// Whether this planet has a shipyard or outfitter
	// and the items that are for sale in each shop.
	bool initializedShops = false;
	bool hasShipyard = false;
	bool hasOutfitter = false;
	Sale<Ship> shipyardStock;
	Sale<Outfit> outfitterStock;

	std::shared_ptr<Panel> trading;
	std::shared_ptr<Panel> bank;
	std::shared_ptr<SpaceportPanel> spaceport;
	std::shared_ptr<Panel> hiring;
	Panel *selectedPanel = nullptr;

	std::shared_ptr<TextArea> description;

	// Out of system (absent) ships that cannot fly for some reason.
	std::vector<std::shared_ptr<Ship>> absentCannotFly;

	// Cache flight checks to not calculate them twice before each takeoff.
	std::map<const std::shared_ptr<Ship>, std::vector<std::string>> flightChecks;
};