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 00000000..4091748c Binary files /dev/null and b/Mods/Core/Items/pistol_64.png differ diff --git a/Mods/Core/Items/pistol_64.png.import b/Mods/Core/Items/pistol_64.png.import new file mode 100644 index 00000000..7bad1fae --- /dev/null +++ b/Mods/Core/Items/pistol_64.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://hktpdnah1cbg" +path="res://.godot/imported/pistol_64.png-feaeec3d09921e141e026bd860429ada.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://Mods/Core/Items/pistol_64.png" +dest_files=["res://.godot/imported/pistol_64.png-feaeec3d09921e141e026bd860429ada.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/Mods/Core/Items/rifle_128_64.png b/Mods/Core/Items/rifle_128_64.png new file mode 100644 index 00000000..690dd606 Binary files /dev/null and b/Mods/Core/Items/rifle_128_64.png differ 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"]