-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEditBoxExample.php
More file actions
140 lines (120 loc) · 4.55 KB
/
EditBoxExample.php
File metadata and controls
140 lines (120 loc) · 4.55 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
129
130
131
132
133
134
135
136
137
138
139
140
<?php
namespace refaltor\roots;
use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;
use refaltor\ui\colors\BasicColor;
use refaltor\ui\elements\EditBox;
use refaltor\ui\elements\Element;
use refaltor\ui\elements\Image;
use refaltor\ui\elements\Label;
use refaltor\ui\elements\Panel;
use refaltor\ui\elements\StackPanel;
use refaltor\ui\helpers\OrientationHelper;
/**
* EditBoxExample - Demonstrates EditBox (text input) configurations.
*
* Shows: basic text input, number-only input, placeholder text,
* max length, custom colors, locked state.
*/
class EditBoxExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
$mainPanel = Panel::create("editbox_container")
->setSizePercentage(100, 100);
// Background
$bg = Image::create("editbox_bg", "textures/ui/dialog_background_opaque")
->setSizePercentage(100, 100)
->setNinesliceSize(4)
->setLayer(-1);
$mainPanel->addChild($bg);
// Title
$title = Label::create("editbox_title", "EditBox Examples")
->setFontSize(Label::FONT_EXTRA_LARGE)
->setShadow()
->setColor(BasicColor::yellow())
->setAnchorFrom(Element::ANCHOR_TOP_MIDDLE)
->setAnchorTo(Element::ANCHOR_TOP_MIDDLE)
->setOffset(0, 10);
$mainPanel->addChild($title);
$stack = StackPanel::create("editbox_stack")
->setOrientation(OrientationHelper::VERTICAL)
->setSize(300, 250)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER);
// Username input
$usernameLabel = Label::create("username_label", "Username:")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::white())
->setShadow()
->setSize(300, 18);
$stack->addChild($usernameLabel);
$usernameInput = EditBox::create("username_input")
->setTextBoxName("username_field")
->setPlaceHolderText("Enter your username...")
->setMaxLength(32)
->setTextType(EditBox::TEXT_TYPE_EXTENDED_ASCII)
->setTextColor(BasicColor::white())
->setSize(280, 25);
$stack->addChild($usernameInput);
// Number input (e.g., for a seed)
$seedLabel = Label::create("seed_label", "World Seed:")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::white())
->setShadow()
->setSize(300, 18);
$stack->addChild($seedLabel);
$seedInput = EditBox::create("seed_input")
->setTextBoxName("seed_field")
->setPlaceHolderText("Enter seed number...")
->setMaxLength(20)
->setTextType(EditBox::TEXT_TYPE_NUMBER_CHARS)
->setTextColor(BasicColor::cyan())
->setSize(280, 25);
$stack->addChild($seedInput);
// Chat/message input with longer max length
$messageLabel = Label::create("message_label", "Message:")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::white())
->setShadow()
->setSize(300, 18);
$stack->addChild($messageLabel);
$messageInput = EditBox::create("message_input")
->setTextBoxName("message_field")
->setPlaceHolderText("Type a message...")
->setMaxLength(256)
->setTextColor(BasicColor::white())
->setSize(280, 25);
$stack->addChild($messageInput);
// Locked/disabled input
$lockedLabel = Label::create("locked_label", "Locked Field:")
->setFontSize(Label::FONT_NORMAL)
->setColor(BasicColor::rgb(0.6, 0.6, 0.6))
->setSize(300, 18);
$stack->addChild($lockedLabel);
$lockedInput = EditBox::create("locked_input")
->setTextBoxName("locked_field")
->setPlaceHolderText("This field is locked")
->setEnabled(false)
->setLockedColor(BasicColor::rgb(0.4, 0.4, 0.4))
->setTextColor(BasicColor::rgb(0.6, 0.6, 0.6))
->setSize(280, 25);
$stack->addChild($lockedInput);
$mainPanel->addChild($stack);
$root->addElement($mainPanel);
return $root;
}
public function getNamespace(): string
{
return "editbox_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "EDITBOX_EXAMPLE";
}
}