From a01a0215cdb7e61f6fa11ff75bb8e83e63f0118b Mon Sep 17 00:00:00 2001 From: Hamcha Date: Tue, 28 Jul 2020 09:54:04 +0200 Subject: [PATCH] Add item boxes, add asking --- Graphics/UI/handicons.png | Bin 0 -> 293 bytes Graphics/UI/handicons.png.import | 34 +++++++++ Graphics/UI/selected.png | Bin 0 -> 177 bytes Graphics/UI/selected.png.import | 34 +++++++++ Graphics/tgstation/midnight.png | Bin 0 -> 9054 bytes Graphics/tgstation/midnight.png.import | 34 +++++++++ Scenes/UI.gd | 94 ++++++++++++++++++++++++- Scenes/UI.tscn | 12 ++++ Scenes/UI/Items/ItemBox.gd | 64 +++++++++++++++++ Scenes/UI/Items/ItemBox.tscn | 53 ++++++++++++++ Scenes/UI/SpaceMap.tscn | 1 + Scenes/UI/SpaceMapInside.gd | 5 +- project.godot | 28 +++++++- 13 files changed, 356 insertions(+), 3 deletions(-) create mode 100644 Graphics/UI/handicons.png create mode 100644 Graphics/UI/handicons.png.import create mode 100644 Graphics/UI/selected.png create mode 100644 Graphics/UI/selected.png.import create mode 100644 Graphics/tgstation/midnight.png create mode 100644 Graphics/tgstation/midnight.png.import create mode 100644 Scenes/UI/Items/ItemBox.gd create mode 100644 Scenes/UI/Items/ItemBox.tscn diff --git a/Graphics/UI/handicons.png b/Graphics/UI/handicons.png new file mode 100644 index 0000000000000000000000000000000000000000..39291b718e7e886c93995e17ef74614ab33a9da7 GIT binary patch literal 293 zcmV+=0owkFP)Px#-$_J4R9J=WmQf4CAPj`hvfu5K(4UA2pJ>liKTC|k1|%Oc%$NbB7>k44ofy`glX(f`WP7?ehD5Z! zy`ji=z<`IvG5+8Gbnz{oYnt>{Gv_%vq?~MCdn5JBvac>KY2T`r++N&u@$>I;VFgV$ z!EFimb|1f<;La9^8**Q%R9LmU-zMU0pT*1AM;TJi0Sm2KfYvg2y85}Sb4q9e00zN3 AcK`qY literal 0 HcmV?d00001 diff --git a/Graphics/UI/selected.png.import b/Graphics/UI/selected.png.import new file mode 100644 index 0000000..18ca8ad --- /dev/null +++ b/Graphics/UI/selected.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/selected.png-edb67f7b3e4969e516febc7f79b42937.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Graphics/UI/selected.png" +dest_files=[ "res://.import/selected.png-edb67f7b3e4969e516febc7f79b42937.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Graphics/tgstation/midnight.png b/Graphics/tgstation/midnight.png new file mode 100644 index 0000000000000000000000000000000000000000..429526fadae2f4ce07a6c409b13f36ceb9ad2316 GIT binary patch literal 9054 zcmZ{KXEebB<+Xit zeVuQ2O~4*{?7Sy6pbg}BhrhwzJf#fYCQC#qaYjazLK&kM%v8cg2UJ;0PE9ym`i^SF zGDrZ4=H?Jfg?xcL?j^Qih$)cc7fuI=@zUwe8Y$${5tJz#G7KaPUSJesj#jsv*4nRE;Im)P*_ zq)T&Ez{UG^HYK)N{PER^mDS^&&5E}+mW2zoiGNN6aebzwpfrGgkr0$~cx6VSAh2cp z;R_Y`-RX5X2l7v^U{^qsrWzH=U*VoEp!s!Gjtq4@E z^S`CLAvY3-6Bk!|(Ew%&rR_1U4+dFWmTb^(on0MTGJ=PNgebuewB$R#lb6zh{)K2i z}Qkc^82uFU|XQ;ph)p z``H#oq8iiyEq@W-57+DYGOcGO%(kJQb$O0Hgecf`(YBYcEB#7Keg2(v zWQi8UKv*1`O{ZkH1Y7OvSMwJV?JK5FyU!X-goIVuqUMhJlQ!6s2RAJL^7e_cv`o^m zw~o=B-ITq)YWsrAIW*v}81*TIod5bfnrjLlLj^n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L-v8WZOi(v62+}SY6P)w=uAJ>LNLXaR zH|f;LtU(v@b_ScvFg-=ty+fg{T%_#irtY{Bq}{x3JoiV#>hLmNT+iS;5r1NbG-tSp z4hI!~p(c>c9bWQmFvsv)^~#*;9NvZM(^Wg&CFvKVfk$@8bMeDJ)Kscepn;1la2hV8 z0M5}=Cr~6Qt9D+a$c{2qwxGu=nV*9prkvkgY-FAA2A*ILVhXW#qV+$Xq4QuUY1F@i zxT2uLlW78g)X_7X!|2afHD75oOw(cl1ONtIm+=+qJF1gtcvPDM4)$bqn+Zk^_T7A#e7sI!-1dJoe=?LvRQqZ8 zvK$H0f)gUey7rApfjMvnir!Bh<#*dEUDWXbjoKdL-kycutW`Kt&{o$|t5mU% F{2w>93g7?$ literal 0 HcmV?d00001 diff --git a/Graphics/tgstation/midnight.png.import b/Graphics/tgstation/midnight.png.import new file mode 100644 index 0000000..9e65beb --- /dev/null +++ b/Graphics/tgstation/midnight.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/midnight.png-3d811938da348be9b831f07b37a9d5f1.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Graphics/tgstation/midnight.png" +dest_files=[ "res://.import/midnight.png-3d811938da348be9b831f07b37a9d5f1.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +stream=false +size_limit=0 +detect_3d=true +svg/scale=1.0 diff --git a/Scenes/UI.gd b/Scenes/UI.gd index c3306d7..c2c8c36 100644 --- a/Scenes/UI.gd +++ b/Scenes/UI.gd @@ -13,10 +13,18 @@ enum PopupName { onready var logs = $Logs onready var inspect_box = $InspectBox as RichTextLabel +onready var item_slots_container = $ItemSlots + +onready var map_popup = $MapPopup +onready var sever_info_popup = $ServerInfoPopup onready var scene = $"/root/scene" onready var netgame = $"/root/Multiplayer" +const ItemBox = preload("res://Scenes/UI/Items/ItemBox.tscn") +var left_selected = null +var right_selected = null + const WHISPER_RADIUS = 32*3 const CHAT_RADIUS = 32*10 const SHOUT_RADIUS = 32*14 @@ -29,6 +37,26 @@ func _ready() -> void: var serverMenu = $Menu/Margins/Grid/Server.get_popup() serverMenu.connect("id_pressed", self, "_server_option_chosen") serverMenu.add_item("Server info", ServerMenuItem.ServerInfo) + + # Create item slots + for slot_id in range(4): + var item_slot = ItemBox.instance() + + # By default, slot 2/3 are L/R, and 2 is selected + match slot_id: + 1: + item_slot.selected = true + item_slot.current_hand = UIItemBox.CurrentHand.Left + left_selected = item_slot + 2: + item_slot.current_hand = UIItemBox.CurrentHand.Right + right_selected = item_slot + + # Connect signals + item_slot.connect("selected", self, "_itembox_selected", [item_slot]) + item_slot.connect("used_in_hand", self, "_itembox_used", [item_slot]) + + item_slots_container.add_child(item_slot) func _physics_process(_delta: float) -> void: if inspect_mode: @@ -75,10 +103,13 @@ func close_popup(popup_name) -> void: pass const say_format = "%s says \"%s\"\n" +const ask_format = "%s asks \"%s\"\n" const shout_format = "%s shouts \"[b]%s[/b]\"\n" const whisper_format = "[i]%s whispers \"%s\"[/i]\n" func _send_chat(text: String) -> void: - var escaped_text = text.replace("[", "[\u8203") # Hacky way to escape BBCode + var escaped_text = text.replace("[", "[\u8203").strip_edges() # Hacky way to escape BBCode + if text.ends_with("?"): + scene.rpc("broadcast_zone", ask_format % [netgame.player_name, escaped_text], scene.world.player.global_position, SHOUT_RADIUS) if text.ends_with("!!"): scene.rpc("broadcast_zone", shout_format % [netgame.player_name, escaped_text], scene.world.player.global_position, SHOUT_RADIUS) elif text.begins_with("#"): @@ -93,11 +124,72 @@ func set_inspect(active: bool) -> void: inspect_box.rect_global_position = get_viewport().get_mouse_position() + inspect_offset func _input(event: InputEvent) -> void: + var no_popups = not check_popups() if event.is_action_released("inspect"): set_inspect(false) elif event.is_action_pressed("inspect"): set_inspect(true) + elif event.is_action_pressed("ui_scroll_left") and no_popups: + select_next_box(-1, Input.is_action_pressed("alt_hand")) + elif event.is_action_pressed("ui_scroll_right") and no_popups: + select_next_box(1, Input.is_action_pressed("alt_hand")) + elif event.is_action_pressed("swap_hands"): + swap_hands() elif event is InputEventMouseMotion: var mousemotion = event as InputEventMouseMotion if inspect_mode: inspect_box.rect_global_position = mousemotion.position + inspect_offset + +func _itembox_selected(hand, item_box: UIItemBox) -> void: + left_selected.selected = false + right_selected.selected = false + match hand: + UIItemBox.CurrentHand.Left: + if item_box.current_hand != UIItemBox.CurrentHand.None: + left_selected.current_hand = item_box.current_hand + match item_box.current_hand: + UIItemBox.CurrentHand.Right: + right_selected = left_selected + else: + left_selected.current_hand = UIItemBox.CurrentHand.None + left_selected = item_box + UIItemBox.CurrentHand.Right: + if item_box.current_hand != UIItemBox.CurrentHand.None: + right_selected.current_hand = item_box.current_hand + match item_box.current_hand: + UIItemBox.CurrentHand.Left: + left_selected = right_selected + else: + right_selected.current_hand = UIItemBox.CurrentHand.None + right_selected = item_box + item_box.selected = true + item_box.current_hand = hand + +func _itembox_used(item_box) -> void: + pass + +func check_popups() -> bool: + return map_popup.visible or sever_info_popup.visible + +func select_next_box(direction: int, right_hand: bool) -> void: + var box = left_selected as UIItemBox + if right_hand: + box = right_selected + var parent = box.get_parent() + var child_count = parent.get_child_count() + var index = box.get_index() + index += direction + if index < 0: + index = child_count + index + elif index >= child_count: + index -= child_count + var hand = UIItemBox.CurrentHand.Left + if right_hand: + hand = UIItemBox.CurrentHand.Right + _itembox_selected(hand, parent.get_child(index)) + +func swap_hands() -> void: + if left_selected.selected: + _itembox_selected(UIItemBox.CurrentHand.Left, right_selected) + else: + _itembox_selected(UIItemBox.CurrentHand.Right, left_selected) diff --git a/Scenes/UI.tscn b/Scenes/UI.tscn index a6b362e..971e22a 100644 --- a/Scenes/UI.tscn +++ b/Scenes/UI.tscn @@ -189,6 +189,18 @@ scroll_active = false __meta__ = { "_edit_use_anchors_": false } + +[node name="ItemSlots" type="HBoxContainer" parent="."] +anchor_top = 1.0 +anchor_right = 0.5 +anchor_bottom = 1.0 +margin_top = -100.0 +margin_bottom = -50.0 +rect_scale = Vector2( 2, 2 ) +alignment = 1 +__meta__ = { +"_edit_use_anchors_": false +} [connection signal="chat_message_sent" from="Logs" to="." method="_send_chat"] [connection signal="focus_entered" from="Logs/ResizablePanel/LineEdit" to="Logs" method="_chat_bar_status" binds= [ true ]] [connection signal="focus_exited" from="Logs/ResizablePanel/LineEdit" to="Logs" method="_chat_bar_status" binds= [ false ]] diff --git a/Scenes/UI/Items/ItemBox.gd b/Scenes/UI/Items/ItemBox.gd new file mode 100644 index 0000000..70c0e77 --- /dev/null +++ b/Scenes/UI/Items/ItemBox.gd @@ -0,0 +1,64 @@ +extends TextureRect + +class_name UIItemBox + +signal selected(hand) +signal used_in_hand() + +enum CurrentHand { + None, + Left, + Right +} + +var hovering = false +export var selected = false setget set_selected +export(CurrentHand) var current_hand = CurrentHand.None setget set_hand + +const LEFT_Y_OFFSET = 0 +const RIGHT_Y_OFFSET = 10 + +onready var hand_icon = $HandIcon + +func _ready(): + hand_icon.texture = hand_icon.texture.duplicate() + set_hand(current_hand) + +func _mouse_hover(inside: bool) -> void: + hovering = inside + if hovering: + self_modulate.a = 1 + else: + self_modulate.a = 0.86 + +func set_selected(val: bool) -> void: + selected = val + $SelectedOverlay.visible = selected + +func set_hand(hand): + current_hand = hand + if hand_icon != null: + match hand: + CurrentHand.None: + hand_icon.visible = false + CurrentHand.Left: + hand_icon.visible = true + (hand_icon.texture as AtlasTexture).region.position.y = LEFT_Y_OFFSET + CurrentHand.Right: + hand_icon.visible = true + (hand_icon.texture as AtlasTexture).region.position.y = RIGHT_Y_OFFSET + +func _gui_input(event): + if event is InputEventMouseButton: + var mouse_event = event as InputEventMouseButton + if mouse_event.pressed: + if mouse_event.button_index == BUTTON_LEFT: + if current_hand != CurrentHand.Left: + emit_signal("selected", CurrentHand.Left) + else: + emit_signal("used_in_hand") + elif mouse_event.button_index == BUTTON_RIGHT: + if current_hand != CurrentHand.Right: + emit_signal("selected", CurrentHand.Right) + else: + emit_signal("used_in_hand") diff --git a/Scenes/UI/Items/ItemBox.tscn b/Scenes/UI/Items/ItemBox.tscn new file mode 100644 index 0000000..8a1a65e --- /dev/null +++ b/Scenes/UI/Items/ItemBox.tscn @@ -0,0 +1,53 @@ +[gd_scene load_steps=7 format=2] + +[ext_resource path="res://Graphics/tgstation/midnight.png" type="Texture" id=1] +[ext_resource path="res://Scenes/UI/Items/ItemBox.gd" type="Script" id=2] +[ext_resource path="res://Graphics/UI/selected.png" type="Texture" id=3] +[ext_resource path="res://Graphics/UI/handicons.png" type="Texture" id=4] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 32, 32, 32, 32 ) +margin = Rect2( 2, 2, 4, 4 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 4 ) +region = Rect2( 1, 0, 21, 9 ) +margin = Rect2( 2, 2, 4, 4 ) + +[node name="ItemBox" type="TextureRect"] +self_modulate = Color( 1, 1, 1, 0.862745 ) +margin_left = -1.0 +margin_right = 35.0 +margin_bottom = 53.0 +mouse_default_cursor_shape = 2 +texture = SubResource( 1 ) +stretch_mode = 4 +script = ExtResource( 2 ) +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="SelectedOverlay" type="TextureRect" parent="."] +visible = false +modulate = Color( 1, 1, 1, 0.5 ) +anchor_right = 1.0 +anchor_bottom = 1.0 +mouse_filter = 2 +texture = ExtResource( 3 ) +stretch_mode = 4 +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="HandIcon" type="TextureRect" parent="."] +visible = false +anchor_right = 1.0 +margin_left = -0.176781 +margin_top = -5.0 +margin_right = -0.176781 +mouse_filter = 2 +texture = SubResource( 2 ) +stretch_mode = 6 +[connection signal="mouse_entered" from="." to="." method="_mouse_hover" binds= [ true ]] +[connection signal="mouse_exited" from="." to="." method="_mouse_hover" binds= [ false ]] diff --git a/Scenes/UI/SpaceMap.tscn b/Scenes/UI/SpaceMap.tscn index ee88dc6..28eb717 100644 --- a/Scenes/UI/SpaceMap.tscn +++ b/Scenes/UI/SpaceMap.tscn @@ -109,3 +109,4 @@ script = ExtResource( 4 ) background = ExtResource( 2 ) font = ExtResource( 3 ) [connection signal="about_to_show" from="." to="MarginContainer/VBoxContainer/Map" method="_reset_position"] +[connection signal="popup_hide" from="." to="MarginContainer/VBoxContainer/Map" method="_on_hide"] diff --git a/Scenes/UI/SpaceMapInside.gd b/Scenes/UI/SpaceMapInside.gd index 66055c8..d89c03c 100644 --- a/Scenes/UI/SpaceMapInside.gd +++ b/Scenes/UI/SpaceMapInside.gd @@ -27,6 +27,7 @@ var text_two_lines = false onready var scene = $"/root/scene" onready var speed_text = $"../HBoxContainer/HBoxContainer/CurrentSpeed" onready var dir_text = $"../HBoxContainer/HBoxContainer/CurrentAngle" +onready var popup = $"../../.." var last_pos = [] @@ -139,7 +140,6 @@ func _input(event): return func update_font(): - print(cell_size) text_two_lines = cell_size < 70 if cell_size < 100: font.size = 11 @@ -152,3 +152,6 @@ func _recalc_offset(mult: float): func _reset_position(): set_position = true + +func _on_hide(): + popup.visible = false diff --git a/project.godot b/project.godot index 36e66f5..73130ed 100644 --- a/project.godot +++ b/project.godot @@ -123,6 +123,11 @@ _global_script_classes=[ { "class": "UICommand", "language": "GDScript", "path": "res://Classes/UICommand.gd" +}, { +"base": "TextureRect", +"class": "UIItemBox", +"language": "GDScript", +"path": "res://Scenes/UI/Items/ItemBox.gd" } ] _global_script_class_icons={ "ActivationRange": "", @@ -147,7 +152,8 @@ _global_script_class_icons={ "ProbeArea": "", "ProbeElectric": "", "ResourceQueue": "", -"UICommand": "" +"UICommand": "", +"UIItemBox": "" } [application] @@ -241,6 +247,26 @@ ui_zoomout={ "events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null) ] } +ui_scroll_left={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":4,"pressed":false,"doubleclick":false,"script":null) + ] +} +ui_scroll_right={ +"deadzone": 0.5, +"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":5,"pressed":false,"doubleclick":false,"script":null) + ] +} +alt_hand={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777237,"unicode":0,"echo":false,"script":null) + ] +} +swap_hands={ +"deadzone": 0.5, +"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":88,"unicode":0,"echo":false,"script":null) + ] +} [layer_names]