-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathButtonExample.php
More file actions
82 lines (69 loc) · 2.42 KB
/
ButtonExample.php
File metadata and controls
82 lines (69 loc) · 2.42 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
<?php
namespace refaltor\roots;
use refaltor\ui\builders\Root;
use refaltor\ui\builders\RootBuild;
use refaltor\ui\elements\Button;
use refaltor\ui\elements\Element;
use refaltor\ui\elements\Panel;
/**
* ButtonExample - Demonstrates Button configurations.
*
* Shows: custom textures, visibility conditions, button text, sizing.
*/
class ButtonExample implements RootBuild
{
public function root(): Root
{
$root = Root::create();
// Container panel
$panel = Panel::create("button_container")
->setSizePercentage(100, 100);
// Enable button factory (required for buttons)
$panel->enableFactoryButton($root);
// Simple button with default textures
$simpleBtn = Button::create("simple_button", $root)
->setButtonText("Click Me")
->setVisibleIfTitle("Click Me")
->setSize(200, 30)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER)
->setOffset(0, -30);
$panel->addChild($simpleBtn);
// Button with custom textures
$customBtn = Button::create("custom_button", $root)
->setButtonText("Custom Style")
->setVisibleIfTitle("Custom Style")
->setDefaultButtonTexture("textures/ui/button_default")
->setHoverButtonTexture("textures/ui/button_hover")
->setPressedButtonTexture("textures/ui/button_pressed")
->setLockedButtonTexture("textures/ui/button_locked")
->setSize(200, 30)
->setAnchorFrom(Element::ANCHOR_CENTER)
->setAnchorTo(Element::ANCHOR_CENTER)
->setOffset(0, 10);
$panel->addChild($customBtn);
// Small button anchored to bottom
$smallBtn = Button::create("small_button", $root)
->setButtonText("Exit")
->setVisibleIfTitle("Exit")
->setSize(100, 20)
->setAnchorFrom(Element::ANCHOR_BOTTOM_MIDDLE)
->setAnchorTo(Element::ANCHOR_BOTTOM_MIDDLE)
->setOffset(0, -10);
$panel->addChild($smallBtn);
$root->addElement($panel);
return $root;
}
public function getNamespace(): string
{
return "button_example";
}
public function getPathName(): string
{
return "./resources/pack_example/";
}
public function titleCondition(): string
{
return "BUTTON_EXAMPLE";
}
}