Skip to content

Commit 3d43161

Browse files
committed
feat: add level name header
1 parent be42b56 commit 3d43161

File tree

2 files changed

+137
-0
lines changed

2 files changed

+137
-0
lines changed

scenes/levels_redesign.gd

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
extends VBoxContainer
2+
3+
const LEVELS = [
4+
BubbleSort,
5+
InsertionSort,
6+
SelectionSort,
7+
MergeSort,
8+
QuickSort,
9+
CocktailSort,
10+
ShellSort,
11+
CombSort,
12+
CycleSort,
13+
OddEvenSort,
14+
]
15+
16+
var _index = 0
17+
var _level: ComparisonSort
18+
19+
func _ready():
20+
_level = LEVELS[_index].new(ArrayModel.new())
21+
$Names/Current.text = "< " + _level.NAME + " >"
22+
23+
func _switch_level(index):
24+
if index == -1:
25+
_index = LEVELS.size() - 1
26+
elif index == LEVELS.size():
27+
_index = 0
28+
else:
29+
_index = index
30+
_ready()
31+
32+
func _input(event):
33+
if event.is_action_pressed("ui_left", true):
34+
_switch_level(_index - 1)
35+
if event.is_action_pressed("ui_right", true):
36+
_switch_level(_index + 1)

scenes/levels_redesign.tscn

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
[gd_scene load_steps=3 format=2]
2+
3+
[ext_resource path="res://assets/theme.theme" type="Theme" id=1]
4+
[ext_resource path="res://scenes/levels_redesign.gd" type="Script" id=2]
5+
6+
[node name="Viewport" type="MarginContainer"]
7+
anchor_right = 1.0
8+
anchor_bottom = 1.0
9+
theme = ExtResource( 1 )
10+
__meta__ = {
11+
"_edit_use_anchors_": false
12+
}
13+
14+
[node name="Levels" type="VBoxContainer" parent="."]
15+
margin_left = 20.0
16+
margin_top = 20.0
17+
margin_right = 1260.0
18+
margin_bottom = 700.0
19+
script = ExtResource( 2 )
20+
21+
[node name="Names" type="HBoxContainer" parent="Levels"]
22+
margin_right = 1240.0
23+
margin_bottom = 19.0
24+
25+
[node name="Current" type="Label" parent="Levels/Names"]
26+
margin_right = 1240.0
27+
margin_bottom = 19.0
28+
size_flags_horizontal = 3
29+
text = "< CURRENT >"
30+
align = 1
31+
32+
[node name="HBoxContainer" type="HBoxContainer" parent="Levels"]
33+
margin_top = 27.0
34+
margin_right = 1240.0
35+
margin_bottom = 134.0
36+
37+
[node name="MarginContainer" type="MarginContainer" parent="Levels/HBoxContainer"]
38+
margin_right = 616.0
39+
margin_bottom = 107.0
40+
size_flags_horizontal = 3
41+
42+
[node name="Label" type="Label" parent="Levels/HBoxContainer/MarginContainer"]
43+
margin_left = 20.0
44+
margin_top = 44.0
45+
margin_right = 596.0
46+
margin_bottom = 63.0
47+
48+
[node name="VBoxContainer" type="VBoxContainer" parent="Levels/HBoxContainer"]
49+
margin_left = 624.0
50+
margin_right = 1240.0
51+
margin_bottom = 107.0
52+
size_flags_horizontal = 3
53+
54+
[node name="MarginContainer" type="MarginContainer" parent="Levels/HBoxContainer/VBoxContainer"]
55+
margin_right = 616.0
56+
margin_bottom = 40.0
57+
size_flags_vertical = 3
58+
59+
[node name="HBoxContainer" type="HBoxContainer" parent="Levels/HBoxContainer/VBoxContainer"]
60+
margin_top = 48.0
61+
margin_right = 616.0
62+
margin_bottom = 107.0
63+
size_flags_vertical = 3
64+
65+
[node name="MarginContainer" type="MarginContainer" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer"]
66+
margin_right = 200.0
67+
margin_bottom = 59.0
68+
size_flags_horizontal = 3
69+
70+
[node name="Label" type="Label" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer/MarginContainer"]
71+
margin_left = 20.0
72+
margin_top = 20.0
73+
margin_right = 180.0
74+
margin_bottom = 39.0
75+
size_flags_horizontal = 3
76+
77+
[node name="MarginContainer2" type="MarginContainer" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer"]
78+
margin_left = 208.0
79+
margin_right = 408.0
80+
margin_bottom = 59.0
81+
size_flags_horizontal = 3
82+
83+
[node name="Label" type="Label" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer/MarginContainer2"]
84+
margin_left = 20.0
85+
margin_top = 20.0
86+
margin_right = 180.0
87+
margin_bottom = 39.0
88+
size_flags_horizontal = 3
89+
90+
[node name="MarginContainer3" type="MarginContainer" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer"]
91+
margin_left = 416.0
92+
margin_right = 616.0
93+
margin_bottom = 59.0
94+
size_flags_horizontal = 3
95+
96+
[node name="Label" type="Label" parent="Levels/HBoxContainer/VBoxContainer/HBoxContainer/MarginContainer3"]
97+
margin_left = 20.0
98+
margin_top = 20.0
99+
margin_right = 180.0
100+
margin_bottom = 39.0
101+
size_flags_horizontal = 3

0 commit comments

Comments
 (0)