From 160ec24da9a7efa9754d9d4d7d9d9cacad72d0f7 Mon Sep 17 00:00:00 2001 From: snipercup <50166150+snipercup@users.noreply.github.com> Date: Wed, 24 Jan 2024 00:30:58 +0100 Subject: [PATCH] Add pistol and rifle json in item editor --- Defaults/Mobs/mob_corpse.tscn | 2 +- ItemProtosets.tres | 48 +++++++++++++++++- Mods/Core/Items/Items.json | 46 +++++++++++++++++ Mods/Core/Items/pistol_64.png | Bin 0 -> 2902 bytes Mods/Core/Items/pistol_64.png.import | 34 +++++++++++++ Mods/Core/Items/rifle_128_64.png | Bin 0 -> 5209 bytes Mods/Core/Items/rifle_128_64.png.import | 34 +++++++++++++ .../ItemEditor/ItemAmmoEditor.tscn | 1 + .../Custom_Editors/ItemEditor/ItemEditor.tscn | 2 +- .../ItemEditor/ItemMagazineEditor.tscn | 1 + .../ItemEditor/ItemRangedEditor.tscn | 2 + Scripts/ItemAmmoEditor.gd | 8 +++ Scripts/ItemEditor.gd | 24 ++++++++- Scripts/ItemMagazineEditor.gd | 16 +++++- Scripts/ItemRangedEditor.gd | 33 +++++++++++- 15 files changed, 244 insertions(+), 7 deletions(-) create mode 100644 Mods/Core/Items/pistol_64.png create mode 100644 Mods/Core/Items/pistol_64.png.import create mode 100644 Mods/Core/Items/rifle_128_64.png create mode 100644 Mods/Core/Items/rifle_128_64.png.import diff --git a/Defaults/Mobs/mob_corpse.tscn b/Defaults/Mobs/mob_corpse.tscn index 74addc8f..662defea 100644 --- a/Defaults/Mobs/mob_corpse.tscn +++ b/Defaults/Mobs/mob_corpse.tscn @@ -3,7 +3,7 @@ [ext_resource type="Script" path="res://Scripts/container.gd" id="1_4celg"] [ext_resource type="Texture2D" uid="uid://cy56wx4qynp3m" path="res://Textures/enemy.png" id="2_pvjek"] [ext_resource type="Script" path="res://addons/gloot/core/inventory_grid_stacked.gd" id="3_131gg"] -[ext_resource type="Resource" uid="uid://bvrl0obu5ejqq" path="res://ItemProtosets.tres" id="4_ehn4b"] +[ext_resource type="Resource" uid="uid://b1tngttyk4w2s" path="res://ItemProtosets.tres" id="4_ehn4b"] [sub_resource type="SphereShape3D" id="SphereShape3D_0pnwx"] radius = 0.2 diff --git a/ItemProtosets.tres b/ItemProtosets.tres index 359c581a..d93a95f7 100644 --- a/ItemProtosets.tres +++ b/ItemProtosets.tres @@ -1,4 +1,4 @@ -[gd_resource type="Resource" script_class="ItemProtoset" load_steps=2 format=3 uid="uid://bvrl0obu5ejqq"] +[gd_resource type="Resource" script_class="ItemProtoset" load_steps=2 format=3 uid="uid://b1tngttyk4w2s"] [ext_resource type="Script" path="res://addons/gloot/core/item_protoset.gd" id="1_o35lu"] @@ -53,5 +53,51 @@ json_data = "[ \"stack_size\": \"1\", \"weight\": \"0.25\", \"width\": \"1\" + }, + { + \"Ranged\": { + \"firing_speed\": \"0.25\", + \"range\": \"1000\", + \"recoil\": \"20\", + \"reload_speed\": \"2.5\", + \"spread\": \"5\", + \"sway\": \"5\", + \"used_ammo\": \"9mm\", + \"used_magazine\": \"pistol_magazine\", + \"used_skill\": \"short_guns\" + }, + \"description\": \"A standard issue pistol that uses 9mm ammunition\", + \"height\": \"2\", + \"id\": \"pistol_9mm\", + \"image\": \"./Mods/Core/Items/pistol_64.png\", + \"max_stack_size\": \"1\", + \"name\": \"Pistol 9mm\", + \"sprite\": \"pistol_64.png\", + \"stack_size\": \"1\", + \"weight\": \"2\", + \"width\": \"2\" + }, + { + \"Ranged\": { + \"firing_speed\": \"0.1\", + \"range\": \"1000\", + \"recoil\": \"15\", + \"reload_speed\": \"2.5\", + \"spread\": \"8\", + \"sway\": \"5\", + \"used_ammo\": \"9mm\", + \"used_magazine\": \"pistol_magazine\", + \"used_skill\": \"short_guns\" + }, + \"description\": \"A standard issue rifle that uses 9mm ammunition\", + \"height\": \"2\", + \"id\": \"rifle_m4a1\", + \"image\": \"./Mods/Core/Items/rifle_128_64.png\", + \"max_stack_size\": \"1\", + \"name\": \"M4a1 rifle\", + \"sprite\": \"rifle_128_64.png\", + \"stack_size\": \"1\", + \"weight\": \"4\", + \"width\": \"4\" } ]" diff --git a/Mods/Core/Items/Items.json b/Mods/Core/Items/Items.json index 0b691ae2..fbecc878 100644 --- a/Mods/Core/Items/Items.json +++ b/Mods/Core/Items/Items.json @@ -47,5 +47,51 @@ "stack_size": "1", "weight": "0.25", "width": "1" + }, + { + "Ranged": { + "firing_speed": "0.25", + "range": "1000", + "recoil": "20", + "reload_speed": "2.5", + "spread": "5", + "sway": "5", + "used_ammo": "9mm", + "used_magazine": "pistol_magazine", + "used_skill": "short_guns" + }, + "description": "A standard issue pistol that uses 9mm ammunition", + "height": "2", + "id": "pistol_9mm", + "image": "./Mods/Core/Items/pistol_64.png", + "max_stack_size": "1", + "name": "Pistol 9mm", + "sprite": "pistol_64.png", + "stack_size": "1", + "weight": "2", + "width": "2" + }, + { + "Ranged": { + "firing_speed": "0.1", + "range": "1000", + "recoil": "15", + "reload_speed": "2.5", + "spread": "8", + "sway": "5", + "used_ammo": "9mm", + "used_magazine": "pistol_magazine", + "used_skill": "short_guns" + }, + "description": "A standard issue rifle that uses 9mm ammunition", + "height": "2", + "id": "rifle_m4a1", + "image": "./Mods/Core/Items/rifle_128_64.png", + "max_stack_size": "1", + "name": "M4a1 rifle", + "sprite": "rifle_128_64.png", + "stack_size": "1", + "weight": "4", + "width": "4" } ] \ No newline at end of file diff --git a/Mods/Core/Items/pistol_64.png b/Mods/Core/Items/pistol_64.png new file mode 100644 index 0000000000000000000000000000000000000000..4091748ce5917e2e92288ddce0863fdd90bcb151 GIT binary patch literal 2902 zcmZ{mc{JN;7so@Zrd71fFnv+c(bAb}A|(hy7fVgGs;ab&*r_e}MJ^v^Q2z7Xs^6S zV-E-fQg%3Jb6FNoeYNj)$^7e}$Wd9?9dYg&4g^vHe>FK!9`&FMdPUi~N7)61`h(7z zqg`?S0PdSd+l0qpL&LrOaA==Uf2^NBa3Ufo)<4u6h&mDGjf?UJ{xA0h{Jo=Y0sfvQ z#u2g5Z`B~*3@=%)gI{~uct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Uh@>Ovv&@#n zaQL9@rsZ}sQof6pXPiSsza9&r#9^e>UpBwKrDye9QvEaN)<2ofRS$3X>hFRd{5QHD B6pa7? literal 0 HcmV?d00001 diff --git a/Mods/Core/Items/rifle_128_64.png.import b/Mods/Core/Items/rifle_128_64.png.import new file mode 100644 index 00000000..0e178e0a --- /dev/null +++ b/Mods/Core/Items/rifle_128_64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://iaxknyj2b5s2" +path="res://.godot/imported/rifle_128_64.png-b12f38a9f7ff52df43988cce360173b4.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Mods/Core/Items/rifle_128_64.png" +dest_files=["res://.godot/imported/rifle_128_64.png-b12f38a9f7ff52df43988cce360173b4.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemAmmoEditor.tscn b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemAmmoEditor.tscn index 6a668c63..f2cc5d5b 100644 --- a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemAmmoEditor.tscn +++ b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemAmmoEditor.tscn @@ -13,6 +13,7 @@ script = ExtResource("1_5v06u") DamageNumberBox = NodePath("Ammo/DamageNumber") [node name="Ammo" type="GridContainer" parent="."] +layout_mode = 0 size_flags_vertical = 3 columns = 2 diff --git a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemEditor.tscn b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemEditor.tscn index 2a6fa0c0..aad0ead9 100644 --- a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemEditor.tscn +++ b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemEditor.tscn @@ -173,7 +173,7 @@ value = 1.0 layout_mode = 2 text = "Type(s)" -[node name="TypesContainer" type="HBoxContainer" parent="VBoxContainer/TabContainer/Basic"] +[node name="TypesContainer" type="HFlowContainer" parent="VBoxContainer/TabContainer/Basic"] layout_mode = 2 [node name="RangedWeaponCheck" type="CheckBox" parent="VBoxContainer/TabContainer/Basic/TypesContainer"] diff --git a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemMagazineEditor.tscn b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemMagazineEditor.tscn index a9e27e16..5c068b19 100644 --- a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemMagazineEditor.tscn +++ b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemMagazineEditor.tscn @@ -12,6 +12,7 @@ grow_vertical = 2 script = ExtResource("1_cgvqr") [node name="Magazine" type="GridContainer" parent="."] +layout_mode = 0 size_flags_vertical = 3 columns = 2 diff --git a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemRangedEditor.tscn b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemRangedEditor.tscn index c8832a6d..219f960d 100644 --- a/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemRangedEditor.tscn +++ b/Scenes/ContentManager/Custom_Editors/ItemEditor/ItemRangedEditor.tscn @@ -47,6 +47,7 @@ layout_mode = 2 text = "Magazine" [node name="UsedMagazineTextEdit" type="TextEdit" parent="Ranged"] +custom_minimum_size = Vector2(0, 28) layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 0.9 @@ -100,6 +101,7 @@ layout_mode = 2 text = "Skill" [node name="UsedSkillTextEdit" type="TextEdit" parent="Ranged"] +custom_minimum_size = Vector2(0, 28) layout_mode = 2 size_flags_horizontal = 3 size_flags_stretch_ratio = 0.9 diff --git a/Scripts/ItemAmmoEditor.gd b/Scripts/ItemAmmoEditor.gd index a1a816c8..e7cf0158 100644 --- a/Scripts/ItemAmmoEditor.gd +++ b/Scripts/ItemAmmoEditor.gd @@ -7,3 +7,11 @@ extends Control # Form elements @export var DamageNumberBox: SpinBox = null +func get_properties() -> Dictionary: + return { + "damage": DamageNumberBox.get_line_edit().text + } + +func set_properties(properties: Dictionary) -> void: + if properties.has("damage"): + DamageNumberBox.get_line_edit().text = properties["damage"] diff --git a/Scripts/ItemEditor.gd b/Scripts/ItemEditor.gd index c1bde7da..021e9db2 100644 --- a/Scripts/ItemEditor.gd +++ b/Scripts/ItemEditor.gd @@ -29,7 +29,7 @@ extends Control @export var StackSizeNumberBox: SpinBox = null @export var MaxStackSizeNumberBox: SpinBox = null -@export var typesContainer: HBoxContainer = null +@export var typesContainer: HFlowContainer = null @@ -72,6 +72,18 @@ func load_item_data() -> void: if MaxStackSizeNumberBox != null and contentData.has("max_stack_size"): MaxStackSizeNumberBox.get_line_edit().text = contentData["max_stack_size"] + # Loop through typesContainer children to load additional properties and set button_pressed + for i in range(typesContainer.get_child_count()): + var child = typesContainer.get_child(i) + if child is CheckBox: + var tabIndex = get_tab_by_title(child.text) + var tab = tabContainer.get_child(tabIndex) + if tab and tab.has_method("set_properties") and contentData.has(child.text): + tab.set_properties(contentData[child.text]) + # Set button_pressed to true if contentData has the property + child.button_pressed = true + refresh_tab_visibility() + #The editor is closed, destroy the instance #TODO: Check for unsaved changes func _on_close_button_button_up() -> void: @@ -92,6 +104,16 @@ func _on_save_button_button_up() -> void: contentData["weight"] = WeightNumberBox.get_line_edit().text contentData["stack_size"] = StackSizeNumberBox.get_line_edit().text contentData["max_stack_size"] = MaxStackSizeNumberBox.get_line_edit().text + + # Loop through typesContainer children to save additional properties + for i in range(typesContainer.get_child_count()): + var child = typesContainer.get_child(i) + # Check if the child is a CheckBox and its button_pressed is true + if child is CheckBox and child.button_pressed: + var tabIndex = get_tab_by_title(child.text) + var tab = tabContainer.get_child(tabIndex) + if tab and tab.has_method("get_properties"): + contentData[child.text] = tab.get_properties() data_changed.emit() #When the itemImageDisplay is clicked, the user will be prompted to select an image from diff --git a/Scripts/ItemMagazineEditor.gd b/Scripts/ItemMagazineEditor.gd index 5aabb3e7..87a34da1 100644 --- a/Scripts/ItemMagazineEditor.gd +++ b/Scripts/ItemMagazineEditor.gd @@ -5,6 +5,18 @@ extends Control # Form elements -@export var ReloadSpeedNumberBox: SpinBox = null -@export var FiringSpeedNumberBox: SpinBox = null +@export var UsedAmmoTextEdit: TextEdit = null +@export var MaxAmmoNumberBox: SpinBox = null + +func get_properties() -> Dictionary: + return { + "used_ammo": UsedAmmoTextEdit.text, + "max_ammo": MaxAmmoNumberBox.get_line_edit().text + } + +func set_properties(properties: Dictionary) -> void: + if properties.has("used_ammo"): + UsedAmmoTextEdit.text = properties["used_ammo"] + if properties.has("max_ammo"): + MaxAmmoNumberBox.get_line_edit().text = properties["max_ammo"] diff --git a/Scripts/ItemRangedEditor.gd b/Scripts/ItemRangedEditor.gd index bda84bbe..952da4d0 100644 --- a/Scripts/ItemRangedEditor.gd +++ b/Scripts/ItemRangedEditor.gd @@ -3,7 +3,6 @@ extends Control # This scene is intended to be used inside the item editor # It is supposed to edit exactly one ranged weapon - # Ranged form elements @export var UsedAmmoTextEdit: TextEdit = null @export var UsedMagazineTextEdit: TextEdit = null @@ -15,3 +14,35 @@ extends Control @export var ReloadSpeedNumberBox: SpinBox = null @export var FiringSpeedNumberBox: SpinBox = null +func get_properties() -> Dictionary: + return { + "used_ammo": UsedAmmoTextEdit.text, + "used_magazine": UsedMagazineTextEdit.text, + "range": RangeNumberBox.get_line_edit().text, + "spread": SpreadNumberBox.get_line_edit().text, + "sway": SwayNumberBox.get_line_edit().text, + "recoil": RecoilNumberBox.get_line_edit().text, + "used_skill": UsedSkillTextEdit.text, + "reload_speed": ReloadSpeedNumberBox.get_line_edit().text, + "firing_speed": FiringSpeedNumberBox.get_line_edit().text + } + +func set_properties(properties: Dictionary) -> void: + if properties.has("used_ammo"): + UsedAmmoTextEdit.text = properties["used_ammo"] + if properties.has("used_magazine"): + UsedMagazineTextEdit.text = properties["used_magazine"] + if properties.has("range"): + RangeNumberBox.get_line_edit().text = properties["range"] + if properties.has("spread"): + SpreadNumberBox.get_line_edit().text = properties["spread"] + if properties.has("sway"): + SwayNumberBox.get_line_edit().text = properties["sway"] + if properties.has("recoil"): + RecoilNumberBox.get_line_edit().text = properties["recoil"] + if properties.has("used_skill"): + UsedSkillTextEdit.text = properties["used_skill"] + if properties.has("reload_speed"): + ReloadSpeedNumberBox.get_line_edit().text = properties["reload_speed"] + if properties.has("firing_speed"): + FiringSpeedNumberBox.get_line_edit().text = properties["firing_speed"]