-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathScreenExample.php
More file actions
128 lines (108 loc) · 4.13 KB
/
ScreenExample.php
File metadata and controls
128 lines (108 loc) · 4.13 KB
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
namespace refaltor\roots;
use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;
use refaltor\ui\colors\BasicColor;
use refaltor\ui\elements\Element;
use refaltor\ui\elements\Image;
use refaltor\ui\elements\Label;
use refaltor\ui\elements\Panel;
use refaltor\ui\elements\Screen;
/**
* ScreenExample - Demonstrates Screen element configurations.
*
* Shows: screen render flags, modal screens, input absorption,
* game rendering behind UI, close on player hurt.
*/
class ScreenExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
// Standard modal screen (blocks game behind)
$modalScreen = Screen::create("modal_screen")
->setRenderOnlyWhenTopMost(true)
->setRenderGameBehind(false)
->setAbsorbInput(true)
->setIsShowingMenu(true)
->setIsModal(true)
->setLowFreqRendering(true)
->setSizePercentage(100, 100);
$modalBg = Image::create("modal_screen_bg", "textures/ui/dialog_background_opaque")
->setSizePercentage(100, 100)
->setNinesliceSize(4)
->setLayer(-1);
$modalScreen->addChild($modalBg);
$modalTitle = Label::create("modal_screen_title", "Modal Screen (blocks game)")
->setFontSize(Label::FONT_LARGE)
->setShadow()
->setColor(BasicColor::red())
->setAnchorFrom(Element::ANCHOR_TOP_MIDDLE)
->setAnchorTo(Element::ANCHOR_TOP_MIDDLE)
->setOffset(0, 20);
$modalScreen->addChild($modalTitle);
$root->addElement($modalScreen);
// HUD overlay screen (game visible behind)
$hudScreen = Screen::create("hud_overlay")
->setRenderOnlyWhenTopMost(false)
->setRenderGameBehind(true)
->setAbsorbInput(false)
->setIsShowingMenu(false)
->setIsModal(false)
->setForceRenderBelow(true)
->setSizePercentage(100, 100);
$hudLabel = Label::create("hud_info", "HUD Overlay - Game visible behind")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::green())
->setShadow()
->setAnchorFrom(Element::ANCHOR_TOP_LEFT)
->setAnchorTo(Element::ANCHOR_TOP_LEFT)
->setOffset(5, 5);
$hudScreen->addChild($hudLabel);
$root->addElement($hudScreen);
// Screen that closes when player takes damage
$fragileScreen = Screen::create("fragile_screen")
->setCloseOnPlayerHurt(true)
->setRenderGameBehind(true)
->setIsModal(false)
->setAbsorbInput(true)
->setSizePercentage(100, 100);
$fragileLabel = Label::create("fragile_info", "This screen closes if you take damage!")
->setFontSize(Label::FONT_LARGE)
->setColor(BasicColor::yellow())
->setShadow()
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$fragileScreen->addChild($fragileLabel);
$root->addElement($fragileScreen);
// Cached screen (kept in memory for fast re-opening)
$cachedScreen = Screen::create("cached_screen")
->setCacheScreen(true)
->setRenderOnlyWhenTopMost(true)
->setRenderGameBehind(false)
->setIsModal(true)
->setShouldStealMouse(true)
->setSizePercentage(100, 100);
$cachedLabel = Label::create("cached_info", "Cached & Mouse-Stealing Screen")
->setFontSize(Label::FONT_LARGE)
->setColor(BasicColor::magenta())
->setShadow()
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
$cachedScreen->addChild($cachedLabel);
$root->addElement($cachedScreen);
return $root;
}
public function getNamespace(): string
{
return "screen_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "SCREEN_EXAMPLE";
}
}