aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIGroup.h
blob: 403a32ae6e64a72f27ff361bba331604357484da (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
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#pragma once
#include "UILayer.h"
#include "UIEnums.h"

class UIComponent_Tooltips;
class UIComponent_TutorialPopup;
class UIScene_HUD;
class UIComponent_PressStartToPlay;

// A group contains a collection of layers for a specific context (e.g. each player has 1 group)
class UIGroup
{
private:
	UILayer *m_layers[eUILayer_COUNT];

	UIComponent_Tooltips *m_tooltips;
	UIComponent_TutorialPopup *m_tutorialPopup;
	UIComponent_PressStartToPlay *m_pressStartToPlay;
	UIScene_HUD *m_hud;

	C4JRender::eViewportType m_viewportType;

	EUIGroup m_group;
	int m_iPad;

	bool m_bMenuDisplayed;
	bool m_bPauseMenuDisplayed;
	bool m_bContainerMenuDisplayed;
	bool m_bIgnoreAutosaveMenuDisplayed;
	bool m_bIgnorePlayerJoinMenuDisplayed;

	// Countdown in ticks to update focus state
	int m_updateFocusStateCountdown;

	int m_commandBufferList;

public:
	UIGroup(EUIGroup group, int iPad);

	EUIGroup GetGroup() {return m_group;}
	UIComponent_Tooltips *getTooltips() { return m_tooltips; }
	UIComponent_TutorialPopup *getTutorialPopup() { return m_tutorialPopup; }
	UIScene_HUD *getHUD() { return m_hud; }
	UIComponent_PressStartToPlay *getPressStartToPlay() { return m_pressStartToPlay; }

	void DestroyAll();
	void ReloadAll();

	void tick();
	void render();
	bool hidesLowerScenes();
	void getRenderDimensions(S32 &width, S32 &height);

	// NAVIGATION
	bool NavigateToScene(int iPad, EUIScene scene, void *initData, EUILayer layer);
	bool NavigateBack(int iPad, EUIScene eScene, EUILayer eLayer = eUILayer_COUNT);
	void closeAllScenes();
	UIScene *GetTopScene(EUILayer layer);

	bool IsSceneInStack(EUIScene scene);
	bool HasFocus(int iPad);

	bool RequestFocus(UILayer* layerPtr);
	void UpdateFocusState();

	bool GetMenuDisplayed();
	bool IsPauseMenuDisplayed() { return m_bPauseMenuDisplayed; }
	bool IsContainerMenuDisplayed() { return m_bContainerMenuDisplayed; }
	bool IsIgnoreAutosaveMenuDisplayed() { return m_bIgnoreAutosaveMenuDisplayed; }
	bool IsIgnorePlayerJoinMenuDisplayed() { return m_bIgnorePlayerJoinMenuDisplayed; }

	// INPUT
	void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled);

#ifdef __PSVITA__
	// Current active scene
	UIScene *getCurrentScene();
#endif

	// FOCUS
	bool getFocusState();

	// A component is an element on a layer that displays BELOW other scenes in this layer, but does not engage in any navigation
	// E.g. you can keep a component active while performing navigation with other scenes on this layer
	void showComponent(int iPad, EUIScene scene, EUILayer layer, bool show);
	UIScene *addComponent(int iPad, EUIScene scene, EUILayer layer);
	void removeComponent(EUIScene scene, EUILayer layer);

	void SetViewportType(C4JRender::eViewportType type);
	C4JRender::eViewportType GetViewportType();

	virtual void HandleDLCMountingComplete();
	virtual void HandleDLCInstalled();
#ifdef _XBOX_ONE
	virtual void HandleDLCLicenseChange();
#endif
	virtual void HandleMessage(EUIMessage message, void *data);

	bool IsFullscreenGroup();

	void handleUnlockFullVersion();

	void PrintTotalMemoryUsage(int64_t &totalStatic, int64_t &totalDynamic);

	unsigned int GetLayerIndex(UILayer* layerPtr);

	int getCommandBufferList();
	UIScene *FindScene(EUIScene sceneType);

private:
	void _UpdateFocusState();
	void updateStackStates();
};