Skip to content

Commit edbecda

Browse files
committed
Pomoce w menu
1 parent 3cb6366 commit edbecda

13 files changed

+161
-29
lines changed

Nodes/UI/Key.tscn

+15-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
[gd_scene load_steps=5 format=2]
1+
[gd_scene load_steps=6 format=2]
22

33
[ext_resource path="res://Graphics/UI/Keys/Normal.png" type="Texture" id=1]
4-
[ext_resource path="res://Resources/UI/BoldFont.tres" type="DynamicFont" id=2]
4+
[ext_resource path="res://Resources/UI/DejaVuSerif.ttf" type="DynamicFontData" id=2]
55
[ext_resource path="res://Resources/UI/BiggerFont.tres" type="DynamicFont" id=3]
66

77
[sub_resource type="GDScript" id=1]
@@ -13,21 +13,29 @@ export var action = \"\"
1313
export var function = \"\"
1414

1515
func _ready():
16-
var key = KEY_SPACE
16+
var key = Com.controls.mappping[Com.controls.NAMES.find(action)]
1717
texture = TEXTURES[KeyList.keys[key].type]
1818
get_child(0).text = KeyList.keys[key].name
19-
get_child(1).text = function"
19+
get_child(1).text = function
20+
21+
func set_text(text):
22+
get_child(1).text = text"
23+
24+
[sub_resource type="DynamicFont" id=2]
25+
size = 10
26+
font_data = ExtResource( 2 )
2027
2128
[node name="Key" type="TextureRect"]
22-
margin_right = 100.0
23-
margin_bottom = 100.0
29+
margin_right = 80.0
30+
margin_bottom = 80.0
2431
texture = ExtResource( 1 )
32+
expand = true
2533
script = SubResource( 1 )
2634
2735
[node name="Name" type="Label" parent="."]
2836
anchor_right = 1.0
2937
anchor_bottom = 1.0
30-
custom_fonts/font = ExtResource( 2 )
38+
custom_fonts/font = SubResource( 2 )
3139
custom_colors/font_color = Color( 0, 0, 0, 1 )
3240
text = "ESC"
3341
align = 1

Nodes/UI/PlayerMenu.tscn

+64-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[gd_scene load_steps=16 format=2]
1+
[gd_scene load_steps=17 format=2]
22

33
[ext_resource path="res://Resources/UI/Standard.tres" type="Theme" id=1]
44
[ext_resource path="res://Scripts/UI/PlayerMenu/PlayerMenu.gd" type="Script" id=2]
@@ -15,6 +15,7 @@
1515
[ext_resource path="res://Nodes/UI/SoulSlot.tscn" type="PackedScene" id=13]
1616
[ext_resource path="res://Nodes/UI/SoulItem.tscn" type="PackedScene" id=14]
1717
[ext_resource path="res://Graphics/UI/SoulSelect.png" type="Texture" id=15]
18+
[ext_resource path="res://Nodes/UI/Key.tscn" type="PackedScene" id=16]
1819

1920
[node name="PlayerMenu" type="Panel"]
2021
margin_right = 736.0
@@ -250,7 +251,6 @@ margin_bottom = 131.0
250251
rect_min_size = Vector2( 0, 16 )
251252

252253
[node name="Tabs" type="Control" parent="Container"]
253-
editor/display_folded = true
254254
margin_top = 131.0
255255
margin_right = 736.0
256256
margin_bottom = 131.0
@@ -848,6 +848,7 @@ custom_fonts/font = ExtResource( 8 )
848848
text = "hello this is description"
849849

850850
[node name="Souls" type="VBoxContainer" parent="Container/Tabs"]
851+
editor/display_folded = true
851852
anchor_right = 1.0
852853
anchor_bottom = 1.0
853854
margin_left = 4.0
@@ -1244,8 +1245,67 @@ patch_margin_right = 4
12441245
patch_margin_bottom = 4
12451246

12461247
[node name="Help" type="Control" parent="."]
1247-
margin_right = 40.0
1248-
margin_bottom = 40.0
1248+
anchor_right = 1.0
1249+
anchor_bottom = 1.0
1250+
1251+
[node name="ChangeTab" parent="Help" instance=ExtResource( 16 )]
1252+
anchor_left = 1.0
1253+
anchor_top = 0.5
1254+
anchor_right = 1.0
1255+
anchor_bottom = 0.5
1256+
margin_left = -716.131
1257+
margin_top = -132.878
1258+
margin_right = -636.131
1259+
margin_bottom = -52.8775
1260+
action = "MAP"
1261+
1262+
[node name="Close" parent="Help" instance=ExtResource( 16 )]
1263+
anchor_left = 0.5
1264+
anchor_top = 1.0
1265+
anchor_right = 0.5
1266+
anchor_bottom = 1.0
1267+
margin_left = 24.1001
1268+
margin_top = 83.3499
1269+
margin_right = 104.1
1270+
margin_bottom = 163.35
1271+
action = "MENU"
1272+
function = "Close"
1273+
1274+
[node name="Select" parent="Help" instance=ExtResource( 16 )]
1275+
anchor_left = 0.5
1276+
anchor_top = 1.0
1277+
anchor_right = 0.5
1278+
anchor_bottom = 1.0
1279+
margin_left = 24.1
1280+
margin_top = 1.64996
1281+
margin_right = 104.1
1282+
margin_bottom = 81.65
1283+
action = "ACCEPT"
1284+
function = "Select"
1285+
1286+
[node name="Cancel" parent="Help" instance=ExtResource( 16 )]
1287+
anchor_left = 0.5
1288+
anchor_top = 1.0
1289+
anchor_right = 0.5
1290+
anchor_bottom = 1.0
1291+
margin_left = 210.3
1292+
margin_top = 1.64999
1293+
margin_right = 290.3
1294+
margin_bottom = 81.65
1295+
action = "CANCEL"
1296+
function = "Cancel"
1297+
1298+
[node name="Unequip" parent="Help" instance=ExtResource( 16 )]
1299+
anchor_left = 0.5
1300+
anchor_top = 1.0
1301+
anchor_right = 0.5
1302+
anchor_bottom = 1.0
1303+
margin_left = 212.2
1304+
margin_top = 83.3499
1305+
margin_right = 292.2
1306+
margin_bottom = 163.35
1307+
action = "SOUL"
1308+
function = "Unequip"
12491309

12501310
[editable path="Container/Tabs/Souls/Slots/Active"]
12511311

Resources/UI/DefaultFont.tres

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
[resource]
66
size = 14
77
font_data = ExtResource( 1 )
8-

Resources/UI/SmallFont.tres

-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@
55
[resource]
66
size = 12
77
font_data = ExtResource( 1 )
8-

Scenes/Title.tscn

+10-6
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,19 @@ func _ready():
2626
Network.connect(\"game_over\", self, \"on_game_over\")
2727

2828
Com.controls.set_process(true)
29+
Com.controls.connect(\"key_press\", self, \"on_key_press\")
30+
Com.controls.state = Controls.State.MENU
31+
2932
self.select = 0
3033

31-
func _input(event):
34+
func on_key_press(p_id, key, _state):
3235
if state == MAIN:
33-
if Input.is_action_just_pressed(\"ui_down\") and select < max_select:
36+
if key == Controls.DOWN and select < max_select:
3437
self.select += 1
35-
elif Input.is_action_just_pressed(\"ui_up\") and select > 0:
38+
elif key == Controls.UP and select > 0:
3639
self.select -= 1
3740

38-
if Input.is_action_just_pressed(\"ui_accept\"):
41+
if key == Controls.ACCEPT:
3942
match state:
4043
MAIN:
4144
match select:
@@ -72,7 +75,7 @@ func _input(event):
7275
2:
7376
Packet.new(Packet.TYPE.REGISTER).add_string($Menu/Register/LoginInput.text).add_string($Menu/Register/PasswordInput.text).add_u16($Menu/Register/Hue.value).send()
7477
$Menu/Preview.visible = false
75-
elif Input.is_action_just_pressed(\"ui_cancel\"):
78+
elif key == Controls.CANCEL:
7679
match state:
7780
LOGIN:
7881
match select:
@@ -97,7 +100,8 @@ func _input(event):
97100
self.select = 1
98101
$Menu/Register/PasswordInput.grab_focus()
99102
$Menu/Register/PasswordInput.select_all()
100-
103+
104+
func _input(event):
101105
if event is InputEventKey:
102106
if event.pressed and event.scancode == KEY_F1:
103107
Packet.new(Packet.TYPE.LOGIN).add_string(\"KoBeWi\").add_string(\"vEryHaRdAnDlOnGpAsSwOrD\").send()

Scripts/KeySuperlist.gd

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ const keys = {
77
KEY_TAB: {name = "TAB", type = WIDE},
88
KEY_BACKTAB: {name = "BACKTAB", type = WIDE},
99
KEY_BACKSPACE: {name = "BACKSPACE", type = WIDE},
10-
KEY_ENTER: {name = "ENTER", type = CURVY},
10+
KEY_ENTER: {name = "", type = CURVY},
11+
# KEY_ENTER: {name = "ENTER", type = CURVY},
1112
KEY_KP_ENTER: {name = "ENTER", type = TALL},
1213
KEY_INSERT: {name = "INSERT", type = NORMAL},
1314
KEY_DELETE: {name = "DELETE", type = NORMAL},
@@ -24,7 +25,7 @@ const keys = {
2425
KEY_PAGEUP: {name = "PAGEUP", type = NORMAL},
2526
KEY_PAGEDOWN: {name = "PAGEDOWN", type = NORMAL},
2627
KEY_SHIFT: {name = "SHIFT", type = WIDE},
27-
KEY_CONTROL: {name = "CONTROL", type = NORMAL},
28+
KEY_CONTROL: {name = "CTRL", type = NORMAL},
2829
KEY_META: {name = "META", type = NORMAL},
2930
KEY_ALT: {name = "ALT", type = NORMAL},
3031
KEY_CAPSLOCK: {name = "CAPSLOCK", type = WIDE},

Scripts/System/Controls.gd

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class_name Controls
22
extends Node
33

44
enum{ATTACK, JUMP, UP, RIGHT, DOWN, LEFT, SOUL, ACCEPT, CANCEL, MAP, MENU, CHAT, COMMAND, CLOSE_CHAT}
5+
const NAMES = ["ATTACK", "JUMP", "UP", "RIGHT", "DOWN", "LEFT", "SOUL", "ACCEPT", "CANCEL", "MAP", "MENU", "CHAT", "COMMAND", "CLOSE_CHAT"]
56

67
enum State{NONE, ACTION, CHAT, MENU, MAP, GAME_OVER}
78
var state = State.NONE

Scripts/UI/PlayerMenu/Equipment.gd

+28-4
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ func update_equipment_inventory(items = null):
4444
select_inventory()
4545

4646
func select():
47+
slot_help()
4748
var selected = slots.get_child(select)
4849
for slot in slots.get_children():
49-
slot.select(selected, inventory_select == -1)
50+
slot.select(selected, !is_slot_selected())
5051

5152
if selected.empty():
5253
description.visible = false
@@ -61,6 +62,7 @@ func select():
6162

6263
func select_inventory():
6364
if inventory_select > -1:
65+
inventory_help()
6466
var selected = inventory.get_child(inventory_select)
6567
for slot in inventory.get_children():
6668
slot.select(selected)
@@ -99,9 +101,12 @@ func get_filter():
99101
return ["cape"]
100102
7, 8:
101103
return ["accessory"]
102-
104+
105+
func is_slot_selected():
106+
return inventory_select != -1
107+
103108
func on_press_key(key):
104-
if inventory_select == -1:
109+
if !is_slot_selected():
105110
var old_select = select
106111
if key == Controls.RIGHT:
107112
select = min(select + 1, slots.get_child_count()-1)
@@ -160,4 +165,23 @@ func unequip_item():
160165
select()
161166

162167
func preview_stats(item):
163-
main.preview_stats(item, slots.get_child(select).item_name)
168+
main.preview_stats(item, slots.get_child(select).item_name)
169+
170+
func _notification(what):
171+
if what == NOTIFICATION_VISIBILITY_CHANGED and visible:
172+
if is_slot_selected():
173+
inventory_help()
174+
else:
175+
slot_help()
176+
177+
func inventory_help():
178+
main.get_help("Select").visible = true
179+
main.get_help("Select").set_text("Equip")
180+
main.get_help("Unequip").visible = false
181+
main.get_help("Cancel").visible = true
182+
183+
func slot_help():
184+
main.get_help("Select").visible = true
185+
main.get_help("Select").set_text("Select")
186+
main.get_help("Unequip").visible = true
187+
main.get_help("Cancel").visible = false

Scripts/UI/PlayerMenu/Inventory.gd

+7-1
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,10 @@ func on_press_key(key):
5959
select = max(select - slots.columns, 0)
6060

6161
if select != old_select:
62-
select()
62+
select()
63+
64+
func _notification(what):
65+
if what == NOTIFICATION_VISIBILITY_CHANGED and visible:
66+
main.get_help("Select").visible = false
67+
main.get_help("Unequip").visible = false
68+
main.get_help("Cancel").visible = false

Scripts/UI/PlayerMenu/PlayerMenu.gd

+4-1
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,7 @@ func preview_stats(item, item2):
9090
set_main_stat(stat, newest_stats[stat] + data[stat] - data2.get(stat, 0) if item2 else newest_stats[stat] + data[stat], true)
9191
else:
9292
for stat in MAIN_STAT_LIST:
93-
set_main_stat(stat, newest_stats[stat])
93+
set_main_stat(stat, newest_stats[stat])
94+
95+
func get_help(help):
96+
return $Help.get_node(help)

Scripts/UI/PlayerMenu/Souls.gd

+16
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ func _notification(what):
7777
if visible:
7878
select_rect.visible = true
7979
if inventory_mode:
80+
inventory_help()
8081
select_inventory()
8182
else:
83+
slot_help()
8284
select()
8385
else:
8486
select_rect.visible = false
@@ -106,6 +108,7 @@ func select_inventory():
106108
description.visible = false
107109

108110
func inventory_mode():
111+
inventory_help()
109112
$Slots.visible = false
110113
$Inventory.visible = true
111114

@@ -118,11 +121,24 @@ func inventory_mode():
118121
call_deferred("update_inventory")
119122

120123
func slot_mode():
124+
slot_help()
121125
$Slots.visible = true
122126
$Inventory.visible = false
123127
inventory_mode = false
124128
select()
125129

130+
func inventory_help():
131+
main.get_help("Select").visible = true
132+
main.get_help("Select").set_text("Equip")
133+
main.get_help("Unequip").visible = false
134+
main.get_help("Cancel").visible = true
135+
136+
func slot_help():
137+
main.get_help("Select").visible = true
138+
main.get_help("Select").set_text("Select")
139+
main.get_help("Unequip").visible = true
140+
main.get_help("Cancel").visible = false
141+
126142
func sync_souls(data):
127143
souls = data
128144

Scripts/UI/PlayerMenu/Stats.gd

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
extends HBoxContainer
22

3+
export(NodePath) var main = @"../../.."
4+
35
onready var stat_list = $Grid
46

57
var level = 1
68

9+
func _ready():
10+
main = get_node(main)
11+
712
func update_stats(stats):
813
if "level" in stats:
914
level = stats.level
@@ -13,4 +18,10 @@ func update_stats(stats):
1318
stat_list.get_node("NEXTValue").text = str(Com.exp_for_level(level) - stats.exp + Com.total_exp_for_level(level-1))
1419

1520
func on_press_key(key):
16-
pass
21+
pass
22+
23+
func _notification(what):
24+
if what == NOTIFICATION_VISIBILITY_CHANGED and visible:
25+
main.get_help("Select").visible = false
26+
main.get_help("Unequip").visible = false
27+
main.get_help("Cancel").visible = false

TODO.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-błąd +dodatek >zmiana
22

3-
+pomoc w menu gracza
3+
+pomoc do mapy i menu (że można otworzyć je)
44
+info o klawiszach, gdy gracz wchodzi
55
+puszczanie klaiwszy po zmianie stanu sterowania (np. idzie grazc i mapa)
66
+kucanie

0 commit comments

Comments
 (0)