summaryrefslogtreecommitdiff
path: root/ui/gameMainSelector.h
blob: cc30707feffca0cc56409d7d9d4e0403da880e30 (plain)
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
#pragma once

#include "SDL_events.h"
#include "config/types.h"
#include "special_members.h"
#include "uiComponent.h"
#include "worldOverlay.h"
#include <glm/glm.hpp>
#include <memory>
#include <string>

class SceneShader;
template<typename> class Ray;
class UIShader;
class Camera;

class GameMainSelector : public UIComponent, public WorldOverlay {
public:
	class Component {
	public:
		virtual ~Component() = default;

		virtual bool click(const SDL_MouseButtonEvent &, const Ray<GlobalPosition3D> &);
		virtual bool move(const SDL_MouseMotionEvent &, const Ray<GlobalPosition3D> &);
		virtual bool handleInput(const SDL_Event &, const Position & pos);
		virtual void render(const UIShader & shader, const Position & pos) const;
		virtual void render(const SceneShader &) const;
	};

	GameMainSelector(const Camera * c, ScreenAbsCoord size);

	void render(const UIShader & shader, const Position & pos) const override;
	void render(const SceneShader & shader) const override;

	bool handleInput(const SDL_Event & e, const Position &) override;

	void defaultClick(const Ray<GlobalPosition3D> & ray);

	std::unique_ptr<Component> target;

private:
	const Camera * camera;
	std::string clicked;
};