Skip to content

Commit

Permalink
Merge pull request #46 from snipercup/item-editor-ranged
Browse files Browse the repository at this point in the history
Item editor ranged, magazine and ammo configuration
  • Loading branch information
snipercup authored Mar 5, 2024
2 parents 9349bf4 + b3880ec commit 8d3fb1d
Show file tree
Hide file tree
Showing 16 changed files with 616 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Defaults/Mobs/mob_corpse.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
55 changes: 54 additions & 1 deletion ItemProtosets.tres
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down Expand Up @@ -31,6 +31,9 @@ json_data = "[
\"width\": \"2\"
},
{
\"Ammo\": {
\"damage\": \"25\"
},
\"description\": \"Standard type of ammunition. Very common.\",
\"height\": \"1\",
\"id\": \"bullet_9mm\",
Expand All @@ -43,6 +46,10 @@ json_data = "[
\"width\": \"1\"
},
{
\"Magazine\": {
\"max_ammo\": \"20\",
\"used_ammo\": \"9mm\"
},
\"description\": \"In order for your pistol to fire a bullet, it needs to have a magazine loaded with bullets\",
\"height\": \"1\",
\"id\": \"pistol_magazine\",
Expand All @@ -53,5 +60,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\"
}
]"
53 changes: 53 additions & 0 deletions Mods/Core/Items/Items.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
"width": "2"
},
{
"Ammo": {
"damage": "25"
},
"description": "Standard type of ammunition. Very common.",
"height": "1",
"id": "bullet_9mm",
Expand All @@ -37,6 +40,10 @@
"width": "1"
},
{
"Magazine": {
"max_ammo": "20",
"used_ammo": "9mm"
},
"description": "In order for your pistol to fire a bullet, it needs to have a magazine loaded with bullets",
"height": "1",
"id": "pistol_magazine",
Expand All @@ -47,5 +54,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"
}
]
Binary file added Mods/Core/Items/pistol_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Mods/Core/Items/pistol_64.png.import
Original file line number Diff line number Diff line change
@@ -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
Binary file added Mods/Core/Items/rifle_128_64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Mods/Core/Items/rifle_128_64.png.import
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[gd_scene load_steps=2 format=3 uid="uid://c2uiumyeepree"]

[ext_resource type="Script" path="res://Scripts/ItemAmmoEditor.gd" id="1_5v06u"]

[node name="ItemAmmoEditor" type="Control" node_paths=PackedStringArray("DamageNumberBox")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_5v06u")
DamageNumberBox = NodePath("Ammo/DamageNumber")

[node name="Ammo" type="GridContainer" parent="."]
layout_mode = 0
size_flags_vertical = 3
columns = 2

[node name="DamageLabel" type="Label" parent="Ammo"]
layout_mode = 2
text = "Damage"

[node name="DamageNumber" type="SpinBox" parent="Ammo"]
layout_mode = 2
tooltip_text = "The width of this item in the inventory. A larger number means it will take up more horizontal inventory slots"
value = 25.0
49 changes: 46 additions & 3 deletions Scenes/ContentManager/Custom_Editors/ItemEditor/ItemEditor.tscn
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
[gd_scene load_steps=4 format=3 uid="uid://dmpomdwta1pgq"]
[gd_scene load_steps=7 format=3 uid="uid://dmpomdwta1pgq"]

[ext_resource type="Script" path="res://Scripts/ItemEditor.gd" id="1_ef3j7"]
[ext_resource type="Texture2D" uid="uid://c8ragmxitca47" path="res://Scenes/ContentManager/Mapeditor/Images/emptyTile.png" id="2_ghd7c"]
[ext_resource type="PackedScene" uid="uid://d1h1rpwt8f807" path="res://Scenes/ContentManager/Custom_Widgets/Sprite_Selector_Popup.tscn" id="3_qb68r"]
[ext_resource type="PackedScene" uid="uid://cbke1yb3m7dra" path="res://Scenes/ContentManager/Custom_Editors/ItemEditor/ItemRangedEditor.tscn" id="3_qqmud"]
[ext_resource type="PackedScene" uid="uid://27f4k2pq2odn" path="res://Scenes/ContentManager/Custom_Editors/ItemEditor/ItemMagazineEditor.tscn" id="4_x8xa3"]
[ext_resource type="PackedScene" uid="uid://c2uiumyeepree" path="res://Scenes/ContentManager/Custom_Editors/ItemEditor/ItemAmmoEditor.tscn" id="5_mr1dn"]

[node name="ItemEditor" type="Control" node_paths=PackedStringArray("itemImageDisplay", "IDTextLabel", "PathTextLabel", "NameTextEdit", "DescriptionTextEdit", "itemSelector", "WidthNumberBox", "HeightNumberBox", "WeightNumberBox", "StackSizeNumberBox", "MaxStackSizeNumberBox")]
[node name="ItemEditor" type="Control" node_paths=PackedStringArray("tabContainer", "itemImageDisplay", "IDTextLabel", "PathTextLabel", "NameTextEdit", "DescriptionTextEdit", "itemSelector", "WidthNumberBox", "HeightNumberBox", "WeightNumberBox", "StackSizeNumberBox", "MaxStackSizeNumberBox", "typesContainer")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_ef3j7")
tabContainer = NodePath("VBoxContainer/TabContainer")
itemImageDisplay = NodePath("VBoxContainer/TabContainer/Basic/ItemImageDisplay")
IDTextLabel = NodePath("VBoxContainer/TabContainer/Basic/IDTextLabel")
PathTextLabel = NodePath("VBoxContainer/TabContainer/Basic/PathTextLabel")
Expand All @@ -23,6 +27,7 @@ HeightNumberBox = NodePath("VBoxContainer/TabContainer/Basic/HeightNumber")
WeightNumberBox = NodePath("VBoxContainer/TabContainer/Basic/WeightNumber")
StackSizeNumberBox = NodePath("VBoxContainer/TabContainer/Basic/StackSizeNumber")
MaxStackSizeNumberBox = NodePath("VBoxContainer/TabContainer/Basic/MaxStackSizeNumber")
typesContainer = NodePath("VBoxContainer/TabContainer/Basic/TypesContainer")

[node name="VBoxContainer" type="VBoxContainer" parent="."]
layout_mode = 1
Expand Down Expand Up @@ -168,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"]
Expand Down Expand Up @@ -211,10 +216,48 @@ layout_mode = 2
tooltip_text = "If this is checked, the item can be disassembled and disassembly tab will be visible. Otherwise, this item cannot be disassembled and the disassembly tab will not be visible"
text = "Disassemble"

[node name="ContainerCheck" type="CheckBox" parent="VBoxContainer/TabContainer/Basic/TypesContainer"]
layout_mode = 2
tooltip_text = "If this is checked, the item can contain items and the container tab will be visible. Otherwise, this item cannot contain items and the container tab will not be visible"
text = "Container"

[node name="ClothingCheck" type="CheckBox" parent="VBoxContainer/TabContainer/Basic/TypesContainer"]
layout_mode = 2
tooltip_text = "If this is checked, the item functions as clothing and the clothing properties tab will be visible. Otherwise, this item will not function as clothing and the clothing properties tab will not be visible"
text = "Clothing"

[node name="Food" type="CheckBox" parent="VBoxContainer/TabContainer/Basic/TypesContainer"]
layout_mode = 2
tooltip_text = "If this is checked, the item functions as food and the food properties tab will be visible. Otherwise, this item will not function as food and the food properties tab will not be visible"
text = "Food"

[node name="Ranged" parent="VBoxContainer/TabContainer" instance=ExtResource("3_qqmud")]
visible = false
layout_mode = 2

[node name="Magazine" parent="VBoxContainer/TabContainer" instance=ExtResource("4_x8xa3")]
visible = false
layout_mode = 2

[node name="Ammo" parent="VBoxContainer/TabContainer" instance=ExtResource("5_mr1dn")]
visible = false
layout_mode = 2

[node name="Sprite_selector" parent="." instance=ExtResource("3_qb68r")]
visible = false

[connection signal="button_up" from="VBoxContainer/HBoxContainer/CloseButton" to="." method="_on_close_button_button_up"]
[connection signal="button_up" from="VBoxContainer/HBoxContainer/SaveButton" to="." method="_on_save_button_button_up"]
[connection signal="gui_input" from="VBoxContainer/TabContainer/Basic/ItemImageDisplay" to="." method="_on_item_image_display_gui_input"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/RangedWeaponCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/MeleeCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/MedicalCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/MagazineCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/AmmunitionCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/BookCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/CraftableCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/DisassembleCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/ContainerCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/ClothingCheck" to="." method="_on_type_check_button_up"]
[connection signal="button_up" from="VBoxContainer/TabContainer/Basic/TypesContainer/Food" to="." method="_on_type_check_button_up"]
[connection signal="sprite_selected_ok" from="Sprite_selector" to="." method="_on_sprite_selector_sprite_selected_ok"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[gd_scene load_steps=2 format=3 uid="uid://27f4k2pq2odn"]

[ext_resource type="Script" path="res://Scripts/ItemMagazineEditor.gd" id="1_cgvqr"]

[node name="ItemMagazineEditor" type="Control" node_paths=PackedStringArray("UsedAmmoTextEdit", "MaxAmmoNumberBox")]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_cgvqr")
UsedAmmoTextEdit = NodePath("Magazine/UsedAmmoTextEdit")
MaxAmmoNumberBox = NodePath("Magazine/MaxAmmoNumber")

[node name="Magazine" type="GridContainer" parent="."]
layout_mode = 0
size_flags_vertical = 3
columns = 2

[node name="UsedAmmoLabel" type="Label" parent="Magazine"]
layout_mode = 2
text = "Ammo"

[node name="UsedAmmoTextEdit" type="TextEdit" parent="Magazine"]
custom_minimum_size = Vector2(0, 30)
layout_mode = 2
size_flags_horizontal = 3
size_flags_stretch_ratio = 0.1
placeholder_text = "9mm"

[node name="MaxAmmoLabel" type="Label" parent="Magazine"]
layout_mode = 2
text = "Max ammo"

[node name="MaxAmmoNumber" type="SpinBox" parent="Magazine"]
layout_mode = 2
tooltip_text = "The width of this item in the inventory. A larger number means it will take up more horizontal inventory slots"
value = 20.0
Loading

0 comments on commit 8d3fb1d

Please sign in to comment.