-
Notifications
You must be signed in to change notification settings - Fork 289
/
State_CodeTest.hx
189 lines (145 loc) · 5.12 KB
/
State_CodeTest.hx
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
import flash.geom.Rectangle;
import flixel.addons.ui.FlxUI;
import flixel.addons.ui.FlxUI9SliceSprite;
import flixel.addons.ui.FlxUIButton;
import flixel.addons.ui.FlxUICheckBox;
import flixel.addons.ui.FlxUIRadioGroup;
import flixel.addons.ui.FlxUISprite;
import flixel.addons.ui.FlxUITabMenu;
import flixel.addons.ui.FlxUIText;
import flixel.FlxG;
import flixel.addons.ui.FlxUIState;
/**
* @author Lars Doucet
*/
class State_CodeTest extends FlxUIState
{
public function new()
{
super();
}
override public function create()
{
super.create();
// NO XML is referenced or created!
makeStuffByHand();
}
override public function getRequest(event:String, sender:Dynamic, data:Dynamic, ?params:Array<Dynamic>):Dynamic
{
return null;
}
override public function getEvent(event:String, target:Dynamic, data:Dynamic, ?params:Array<Dynamic>):Void
{
if (params != null)
{
switch (event)
{
case "click_button":
switch (Std.string(params[0]))
{
case "back": FlxG.switchState(State_Title.new);
}
}
}
}
function makeStuffByHand():Void
{
/***Basic Sprite***/
var back = new FlxUISprite(0, 0, "assets/gfx/ui/title_back.png");
add(back);
/***Basic Text***/
var text = new FlxUIText(0, 150, 350, _tongue.get("$CODE_DESC", "ui"));
text.x = (FlxG.width - text.width) / 2;
text.alignment = CENTER;
add(text);
/***Basic Chrome***/
var chrome = new FlxUI9SliceSprite(50, 180, null, new Rectangle(0, 0, 700, 300));
add(chrome);
/***Check boxes***/
var check_1 = new FlxUICheckBox(60, 200, null, null, _tongue.get("$MENU_THING_1", "ui"), 100, ["thing 1"]);
var check_2 = new FlxUICheckBox(60, check_1.y + 20, null, null, _tongue.get("$MENU_THING_2", "ui"), 100, ["thing 2"]);
add(check_1);
add(check_2);
/***Radio group***/
var radio_1 = new FlxUIRadioGroup(170, 200, ["1_fish", "2_fish", "0xff000000_fish", "0x0000ff_fish"], [
_tongue.get("$MENU_1_FISH", "ui"),
_tongue.get("$MENU_2_FISH", "ui"),
_tongue.get("$MENU_RED_FISH", "ui"),
_tongue.get("$MENU_BLUE_FISH", "ui")
]);
add(radio_1);
/***Toggle buttons***/
var button1 = new FlxUIButton(300, 200, _tongue.get("$MENU_TOGGLE", "ui"));
button1.loadGraphicSlice9(null, 0, 0, null, FlxUI9SliceSprite.TILE_NONE, -1, true);
var button2 = new FlxUIButton(300, 230, _tongue.get("$MENU_TOGGLE", "ui"));
button2.loadGraphicSlice9(null, 0, 0, null, FlxUI9SliceSprite.TILE_NONE, -1, true);
var button3 = new FlxUIButton(300, 260, _tongue.get("$MENU_TOGGLE", "ui"));
button3.loadGraphicSlice9(null, 0, 0, null, FlxUI9SliceSprite.TILE_NONE, -1, true);
var button4 = new FlxUIButton(300, 290, _tongue.get("$MENU_TOGGLE", "ui"));
button4.loadGraphicSlice9(null, 0, 0, null, FlxUI9SliceSprite.TILE_NONE, -1, true);
add(button1);
add(button2);
add(button3);
add(button4);
/***TAB GROUP***/
// This one is particularly unwieldy to create by hand
// Define the tabs:
var tabs = [
{name: "tab_1", label: _tongue.get("$MENU_TAB_1", "ui")},
{name: "tab_2", label: _tongue.get("$MENU_TAB_2", "ui")},
{name: "tab_3", label: _tongue.get("$MENU_TAB_3", "ui")},
{name: "tab_4", label: _tongue.get("$MENU_TAB_4", "ui")}
];
// Make the tab menu itself:
var tab_menu = new FlxUITabMenu(null, tabs, true);
tab_menu.x = 500;
tab_menu.y = 212;
// Now make some content for it:
/***TAB GROUP 1***/
var tabs_radio_1 = new FlxUIRadioGroup(10, 10, ["1_fish", "2_fish", "0xff000000_fish", "0x0000ff_fish"], [
_tongue.get("$MENU_1_FISH", "ui"),
_tongue.get("$MENU_2_FISH", "ui"),
_tongue.get("$MENU_RED_FISH", "ui"),
_tongue.get("$MENU_BLUE_FISH", "ui")
]);
var tab_group_1 = new FlxUI(null, tab_menu, null, _tongue);
tab_group_1.name = "tab_1";
tab_group_1.add(tabs_radio_1);
/***TAB GROUP 2***/
var tabs_check_1 = new FlxUICheckBox(10, 10, null, null, _tongue.get("$MENU_THING_1", "ui"), 100, ["thing 1"]);
var tabs_check_2 = new FlxUICheckBox(10, 40, null, null, _tongue.get("$MENU_THING_2", "ui"), 100, ["thing 2"]);
var tab_group_2 = new FlxUI(null, tab_menu, null, _tongue);
tab_group_2.name = "tab_2";
tab_group_2.add(tabs_check_1);
tab_group_2.add(tabs_check_2);
// Add tab groups to tab menu
tab_menu.addGroup(tab_group_1);
tab_menu.addGroup(tab_group_2);
// Add tab group itself to the state
add(tab_menu);
/***"Back" button***/
var back_btn = new FlxUIButton(0, 535, _tongue.get("$MISC_BACK", "ui"));
back_btn.params = ["back"];
var W:Int = 0;
if (_tongue.locale == "nb-NO")
{
W = 96;
}
back_btn.loadGraphicSlice9(null, W, 0, null);
back_btn.name = "start";
back_btn.x = (FlxG.width - back_btn.width) / 2;
add(back_btn);
}
/*function _onClickRadioGroup(params:Dynamic = null):Void {
FlxG.log.add("FlxUI._onClickRadioGroup(" + params + ")");
getEvent("click_radio_group", this, null, params);
}*/
/*function _onClickButton(params:Array<Dynamic> = null):Void{
FlxG.log.add("FlxUI._onClickButton(" + params + ")");
getEvent("click_button", this, null, params);
}*/
/*function _onClickCheckBox(params:Dynamic = null):Void {
FlxG.log.add("FlxUI._onClickCheckBox(" + params + ")");
getEvent("click_checkbox", this, null, params);
}*/
}