mirror of
https://github.com/tonytins/dressupzack
synced 2025-08-14 04:34:43 -04:00
Basic saving and loading
- You can finally save and load your different styles! - Brand new icons from Font Awesome! - The clear button was refreshed and replaced with the trash can. While I've never gotten complaints about the interface, this should prove to be less confusing. - Clear button moved next to save/load. - Introduced a basic indicator when loading and saving - Bumped version to 1.10
This commit is contained in:
parent
c846932fc8
commit
739692d970
44 changed files with 1093 additions and 313 deletions
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=32 format=2]
|
||||
[gd_scene load_steps=33 format=2]
|
||||
|
||||
[ext_resource path="res://sprites/character/shadow.svg" type="Texture" id=1]
|
||||
[ext_resource path="res://sprites/character/tail/tail0.svg" type="Texture" id=2]
|
||||
|
@ -23,9 +23,10 @@
|
|||
[ext_resource path="res://sprites/character/mouth/mouth9.png" type="Texture" id=21]
|
||||
[ext_resource path="res://sprites/character/mouth/mouth10.png" type="Texture" id=22]
|
||||
[ext_resource path="res://sprites/character/mouth/mouth12.png" type="Texture" id=23]
|
||||
[ext_resource path="res://sprites/character_base_top.svg" type="Texture" id=25]
|
||||
[ext_resource path="res://sounds/select_006.ogg" type="AudioStream" id=24]
|
||||
[ext_resource path="res://sprites/character/character_base_top.svg" type="Texture" id=25]
|
||||
[ext_resource path="res://sprites/clothes/blank_top.png" type="Texture" id=26]
|
||||
[ext_resource path="res://sprites/character_base_head.svg" type="Texture" id=27]
|
||||
[ext_resource path="res://sprites/character/character_base_head.svg" type="Texture" id=27]
|
||||
[ext_resource path="res://sprites/character/mouth/mouth11.png" type="Texture" id=28]
|
||||
|
||||
[sub_resource type="GDScript" id=1]
|
||||
|
@ -33,7 +34,14 @@ script/source = "# Anthony Wilcox licenses this file to you under the MPL licens
|
|||
# See the LICENSE file in the project root for more information.
|
||||
extends Node2D
|
||||
|
||||
const _TDU_VERSION = \"0.2\"
|
||||
const _SAVE_FILE = \"user://character.tdu\"
|
||||
|
||||
onready var character = preload(\"res://resources/character.tres\")
|
||||
onready var blank_accessory = preload(\"res://sprites/clothes/blank_top.png\")
|
||||
onready var base_top = preload(\"res://sprites/character/character_base_top.svg\")
|
||||
onready var base_bottom = preload(\"res://sprites/character/character_base_legs.svg\")
|
||||
|
||||
onready var accessory = $body/accessory
|
||||
#onready var underwear = $Undies
|
||||
onready var bottom = $body/legs
|
||||
|
@ -54,9 +62,80 @@ func _process(delta):
|
|||
|
||||
if character.top != null:
|
||||
top.texture = character.top
|
||||
|
||||
func save_game():
|
||||
var data_file = {
|
||||
\"version\": _TDU_VERSION,
|
||||
\"game_ver\": GameData.version,
|
||||
\"accessory\": \"res://sprites/clothes/blank_top.png\",
|
||||
\"top\": \"res://sprites/clothes/blank_top.png\",
|
||||
\"bottom\": \"res://sprites/character/character_base_legs.svg\",
|
||||
}
|
||||
|
||||
data_file[\"accessory\"] = accessory.texture.resource_path
|
||||
data_file[\"top\"] = top.texture.resource_path
|
||||
data_file[\"bottom\"] = bottom.texture.resource_path
|
||||
var file = File.new()
|
||||
if file.open(_SAVE_FILE, File.WRITE) != 0:
|
||||
print(\"Error opening file\")
|
||||
return
|
||||
var json_file = to_json(data_file)
|
||||
file.store_line(json_file)
|
||||
print_debug(json_file)
|
||||
file.close()
|
||||
|
||||
func load_game():
|
||||
var file = File.new()
|
||||
|
||||
if not file.file_exists(_SAVE_FILE):
|
||||
print(\"File not found!\")
|
||||
return
|
||||
|
||||
if file.open(_SAVE_FILE, File.READ) != 0:
|
||||
print(\"Error opening file\")
|
||||
return
|
||||
|
||||
var data = parse_json(file.get_line())
|
||||
|
||||
var top_texture = ImageTexture.new()
|
||||
var accessory_texture = ImageTexture.new()
|
||||
var bottom_texture = ImageTexture.new()
|
||||
var top_image = Image.new()
|
||||
var accessory_image = Image.new()
|
||||
var bottom_image = Image.new()
|
||||
|
||||
top_image.load(data[\"top\"])
|
||||
top_texture.create_from_image(top_image)
|
||||
top.texture = top_texture
|
||||
|
||||
bottom_image.load(data[\"bottom\"])
|
||||
top_texture.create_from_image(top_image)
|
||||
bottom.texture = top_texture
|
||||
|
||||
accessory_image.load(data[\"accessory\"])
|
||||
accessory_texture.create_from_image(top_image)
|
||||
accessory.texture = accessory_texture
|
||||
|
||||
file.close()
|
||||
|
||||
func _on_clearBtn_pressed():
|
||||
$Click.play()
|
||||
character.accessory = blank_accessory
|
||||
character.bottom = base_bottom
|
||||
character.top = base_top
|
||||
|
||||
func _on_SaveBtn_pressed():
|
||||
$Click.play()
|
||||
GameEvents.emit_signal(\"indicate\")
|
||||
save_game()
|
||||
|
||||
func _on_LoadBtn_pressed():
|
||||
$Click.play()
|
||||
GameEvents.emit_signal(\"indicate\")
|
||||
load_game()
|
||||
"
|
||||
|
||||
[sub_resource type="SpriteFrames" id=4]
|
||||
[sub_resource type="SpriteFrames" id=2]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ) ],
|
||||
"loop": true,
|
||||
|
@ -64,7 +143,7 @@ animations = [ {
|
|||
"speed": 2.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=2]
|
||||
[sub_resource type="SpriteFrames" id=3]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ) ],
|
||||
"loop": true,
|
||||
|
@ -72,7 +151,7 @@ animations = [ {
|
|||
"speed": 2.0
|
||||
} ]
|
||||
|
||||
[sub_resource type="SpriteFrames" id=3]
|
||||
[sub_resource type="SpriteFrames" id=4]
|
||||
animations = [ {
|
||||
"frames": [ ExtResource( 13 ), ExtResource( 14 ), ExtResource( 15 ), ExtResource( 16 ), ExtResource( 17 ), ExtResource( 18 ), ExtResource( 19 ), ExtResource( 20 ), ExtResource( 21 ), ExtResource( 22 ), ExtResource( 28 ), ExtResource( 23 ) ],
|
||||
"loop": true,
|
||||
|
@ -84,6 +163,9 @@ animations = [ {
|
|||
position = Vector2( -19, -92 )
|
||||
script = SubResource( 1 )
|
||||
|
||||
[node name="Click" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource( 24 )
|
||||
|
||||
[node name="shadow" type="Sprite" parent="."]
|
||||
position = Vector2( 4.84271, 244.714 )
|
||||
texture = ExtResource( 1 )
|
||||
|
@ -96,11 +178,11 @@ __meta__ = {
|
|||
[node name="tail" type="AnimatedSprite" parent="body"]
|
||||
position = Vector2( -33.7592, 99.4079 )
|
||||
scale = Vector2( 0.927713, 1 )
|
||||
frames = SubResource( 4 )
|
||||
frames = SubResource( 2 )
|
||||
playing = true
|
||||
|
||||
[node name="legs" type="Sprite" parent="body"]
|
||||
position = Vector2( 1.47027, 192.868 )
|
||||
position = Vector2( 1.47027, 191.868 )
|
||||
texture = ExtResource( 5 )
|
||||
|
||||
[node name="top" type="Sprite" parent="body"]
|
||||
|
@ -113,13 +195,13 @@ texture = ExtResource( 27 )
|
|||
|
||||
[node name="eyes" type="AnimatedSprite" parent="body/head"]
|
||||
position = Vector2( 17.6857, 4.22147 )
|
||||
frames = SubResource( 2 )
|
||||
frame = 3
|
||||
frames = SubResource( 3 )
|
||||
frame = 2
|
||||
playing = true
|
||||
|
||||
[node name="mouth" type="AnimatedSprite" parent="body/head"]
|
||||
position = Vector2( 38.1195, 8.68453 )
|
||||
frames = SubResource( 3 )
|
||||
frames = SubResource( 4 )
|
||||
frame = 5
|
||||
playing = true
|
||||
|
||||
|
|
126
scenes/game.tscn
126
scenes/game.tscn
|
@ -1,23 +1,30 @@
|
|||
[gd_scene load_steps=10 format=2]
|
||||
[gd_scene load_steps=13 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/character_base.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://sprites/world/background.svg" type="Texture" id=2]
|
||||
[ext_resource path="res://sprites/ui/blue_boxCross.png" type="Texture" id=3]
|
||||
[ext_resource path="res://sprites/symbols/trash.svg" type="Texture" id=3]
|
||||
[ext_resource path="res://scenes/wardrobe.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://sprites/clothes/icrazy_frame.svg" type="Texture" id=5]
|
||||
[ext_resource path="res://sprites/clothes/lights.png" type="Texture" id=6]
|
||||
[ext_resource path="res://sprites/ui/grey_boxCross.png" type="Texture" id=7]
|
||||
[ext_resource path="res://sprites/symbols/file-upload.svg" type="Texture" id=7]
|
||||
[ext_resource path="res://scripts/ui.gd" type="Script" id=8]
|
||||
[ext_resource path="res://sounds/select_006.ogg" type="AudioStream" id=9]
|
||||
[ext_resource path="res://sprites/symbols/file-download.svg" type="Texture" id=9]
|
||||
[ext_resource path="res://sprites/symbols/spinner.svg" type="Texture" id=12]
|
||||
[ext_resource path="res://scripts/spinner.gd" type="Script" id=13]
|
||||
[ext_resource path="res://scripts/game.gd" type="Script" id=14]
|
||||
|
||||
[node name="game" type="Node2D"]
|
||||
script = ExtResource( 14 )
|
||||
|
||||
[node name="background" type="Sprite" parent="."]
|
||||
[node name="Bg" type="Sprite" parent="."]
|
||||
position = Vector2( 504.046, 202.426 )
|
||||
texture = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_lock_": true
|
||||
}
|
||||
|
||||
[node name="picFrame" type="Sprite" parent="."]
|
||||
position = Vector2( 127.602, 96.8945 )
|
||||
position = Vector2( 127.602, 111.895 )
|
||||
texture = ExtResource( 5 )
|
||||
__meta__ = {
|
||||
"_edit_group_": true
|
||||
|
@ -28,11 +35,11 @@ position = Vector2( 35.118, -14.56 )
|
|||
texture = ExtResource( 6 )
|
||||
|
||||
[node name="characterBase" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( 133.807, 215.615 )
|
||||
position = Vector2( 133.807, 230.615 )
|
||||
|
||||
[node name="ui" type="CanvasLayer" parent="."]
|
||||
[node name="Controls" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="base" type="Control" parent="ui"]
|
||||
[node name="DressUp" type="Control" parent="Controls"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 8 )
|
||||
|
@ -40,47 +47,82 @@ __meta__ = {
|
|||
"_edit_lock_": true,
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
version = "1.5"
|
||||
version = "1.10"
|
||||
|
||||
[node name="wardrobe" parent="ui/base" instance=ExtResource( 4 )]
|
||||
anchor_left = 0.345
|
||||
anchor_top = 0.072
|
||||
anchor_right = 0.975
|
||||
anchor_bottom = 0.658
|
||||
margin_left = -5.0
|
||||
margin_top = -20.0
|
||||
margin_right = 60.0
|
||||
margin_bottom = 109.0
|
||||
[node name="wardrobe" parent="Controls/DressUp" instance=ExtResource( 4 )]
|
||||
anchor_left = 0.33875
|
||||
anchor_top = 0.054
|
||||
anchor_right = 1.05
|
||||
anchor_bottom = 0.9
|
||||
margin_right = 6.10352e-05
|
||||
|
||||
[node name="clearBtn" type="TextureButton" parent="ui/base"]
|
||||
margin_left = 752.0
|
||||
margin_top = 9.0
|
||||
margin_right = 788.0
|
||||
margin_bottom = 45.0
|
||||
hint_tooltip = "Clear all clothing"
|
||||
texture_normal = ExtResource( 3 )
|
||||
texture_pressed = ExtResource( 3 )
|
||||
texture_hover = ExtResource( 7 )
|
||||
texture_disabled = ExtResource( 7 )
|
||||
[node name="Spinner" type="TextureRect" parent="Controls/DressUp"]
|
||||
visible = false
|
||||
anchor_left = 0.945785
|
||||
anchor_top = 0.153026
|
||||
anchor_right = 0.985785
|
||||
anchor_bottom = 0.217026
|
||||
texture = ExtResource( 12 )
|
||||
script = ExtResource( 13 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="clear" type="AudioStreamPlayer" parent="ui/base"]
|
||||
stream = ExtResource( 9 )
|
||||
[node name="Timer" type="Timer" parent="Controls/DressUp/Spinner"]
|
||||
wait_time = 2.0
|
||||
|
||||
[node name="versionLbl" type="Label" parent="ui/base"]
|
||||
anchor_left = 1.0
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = -81.0
|
||||
margin_top = -28.0
|
||||
text = "[version]"
|
||||
[node name="CenterBtns" type="CenterContainer" parent="Controls/DressUp"]
|
||||
anchor_left = 0.35875
|
||||
anchor_top = 0.792
|
||||
anchor_right = 0.99625
|
||||
anchor_bottom = 0.886
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[node name="ButtonCtr" type="HBoxContainer" parent="Controls/DressUp/CenterBtns"]
|
||||
margin_left = 179.0
|
||||
margin_top = 4.0
|
||||
margin_right = 330.0
|
||||
margin_bottom = 42.0
|
||||
custom_constants/separation = 20
|
||||
|
||||
[node name="SaveBtn" type="Button" parent="Controls/DressUp/CenterBtns/ButtonCtr"]
|
||||
margin_right = 37.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Save"
|
||||
icon = ExtResource( 7 )
|
||||
flat = true
|
||||
|
||||
[node name="LoadBtn" type="Button" parent="Controls/DressUp/CenterBtns/ButtonCtr"]
|
||||
margin_left = 57.0
|
||||
margin_right = 94.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Load"
|
||||
icon = ExtResource( 9 )
|
||||
flat = true
|
||||
|
||||
[node name="clearBtn" type="Button" parent="Controls/DressUp/CenterBtns/ButtonCtr"]
|
||||
margin_left = 114.0
|
||||
margin_right = 151.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Clear"
|
||||
icon = ExtResource( 3 )
|
||||
flat = true
|
||||
|
||||
[node name="versionLbl" type="Label" parent="Controls/DressUp"]
|
||||
anchor_left = 0.88125
|
||||
anchor_top = 0.944
|
||||
anchor_right = 0.9825
|
||||
anchor_bottom = 0.984
|
||||
text = "0.0.0"
|
||||
align = 2
|
||||
valign = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
"_edit_use_anchors_": true
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="ui/base/clearBtn" to="ui/base" method="_on_clearBtn_pressed"]
|
||||
[connection signal="timeout" from="Controls/DressUp/Spinner/Timer" to="Controls/DressUp/Spinner" method="_on_Timer_timeout"]
|
||||
[connection signal="pressed" from="Controls/DressUp/CenterBtns/ButtonCtr/SaveBtn" to="characterBase" method="_on_SaveBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/DressUp/CenterBtns/ButtonCtr/LoadBtn" to="characterBase" method="_on_LoadBtn_pressed"]
|
||||
[connection signal="pressed" from="Controls/DressUp/CenterBtns/ButtonCtr/clearBtn" to="characterBase" method="_on_clearBtn_pressed"]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=17 format=2]
|
||||
[gd_scene load_steps=18 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/clothing/camera.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://sprites/clothes/retro_shirt.svg" type="Texture" id=2]
|
||||
|
@ -12,6 +12,7 @@
|
|||
[ext_resource path="res://scenes/clothing/tops/whatsnew_shirt.tscn" type="PackedScene" id=10]
|
||||
[ext_resource path="res://scenes/clothing/tops/fullsnack_shirt.tscn" type="PackedScene" id=11]
|
||||
[ext_resource path="res://scenes/clothing/tops/rawShirt.tscn" type="PackedScene" id=12]
|
||||
[ext_resource path="res://resources/Game.theme" type="Theme" id=13]
|
||||
[ext_resource path="res://scenes/clothing/tops/atomic_shirt.tscn" type="PackedScene" id=15]
|
||||
[ext_resource path="res://scenes/clothing/pants/sweatPants.tscn" type="PackedScene" id=17]
|
||||
[ext_resource path="res://scenes/clothing/tops/retro_shirt.tscn" type="PackedScene" id=18]
|
||||
|
@ -20,6 +21,7 @@
|
|||
[node name="Wordrobe" type="TabContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 13 )
|
||||
custom_colors/font_color_disabled = Color( 0, 0, 0, 1 )
|
||||
custom_colors/font_color_bg = Color( 0.921569, 0.921569, 0.921569, 1 )
|
||||
custom_colors/font_color_fg = Color( 1, 1, 1, 1 )
|
||||
|
@ -106,10 +108,10 @@ margin_bottom = 258.0
|
|||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = 40.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -10.0
|
||||
margin_left = 4.0
|
||||
margin_top = 38.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
|
||||
[node name="ShirtsScroll" type="ScrollContainer" parent="Shirts"]
|
||||
anchor_right = 1.0
|
||||
|
@ -118,8 +120,8 @@ margin_left = 10.0
|
|||
margin_top = 10.0
|
||||
|
||||
[node name="ShirtsGrid" type="GridContainer" parent="Shirts/ShirtsScroll"]
|
||||
margin_right = 780.0
|
||||
margin_bottom = 440.0
|
||||
margin_right = 782.0
|
||||
margin_bottom = 448.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 4
|
||||
|
@ -161,17 +163,17 @@ margin_bottom = 229.0
|
|||
[node name="whatsNewShirt" parent="Shirts/ShirtsScroll/ShirtsGrid" instance=ExtResource( 10 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 220.0
|
||||
margin_left = 110.0
|
||||
margin_top = 117.0
|
||||
margin_right = 326.0
|
||||
margin_right = 216.0
|
||||
margin_bottom = 229.0
|
||||
|
||||
[node name="retroShirt" parent="Shirts/ShirtsScroll/ShirtsGrid" instance=ExtResource( 18 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 330.0
|
||||
margin_left = 220.0
|
||||
margin_top = 117.0
|
||||
margin_right = 436.0
|
||||
margin_right = 326.0
|
||||
margin_bottom = 229.0
|
||||
texture_normal = ExtResource( 2 )
|
||||
|
||||
|
@ -179,20 +181,21 @@ texture_normal = ExtResource( 2 )
|
|||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = 40.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -10.0
|
||||
margin_left = 4.0
|
||||
margin_top = 38.0
|
||||
margin_right = -4.0
|
||||
margin_bottom = -4.0
|
||||
|
||||
[node name="AccsScroll" type="ScrollContainer" parent="Accessoires"]
|
||||
margin_left = 19.0
|
||||
margin_top = 22.0
|
||||
margin_right = 369.0
|
||||
margin_bottom = 494.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="AccsGrid" type="GridContainer" parent="Accessoires/AccsScroll"]
|
||||
margin_right = 350.0
|
||||
margin_bottom = 472.0
|
||||
margin_right = 792.0
|
||||
margin_bottom = 458.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
columns = 3
|
||||
|
@ -206,6 +209,7 @@ texture_normal = ExtResource( 9 )
|
|||
margin_left = 110.0
|
||||
margin_right = 195.0
|
||||
margin_bottom = 112.0
|
||||
|
||||
[connection signal="pressed" from="Pants/PantsScroll/PantsGrid/removePants" to="." method="_on_removePants_pressed"]
|
||||
[connection signal="pressed" from="Shirts/ShirtsScroll/ShirtsGrid/removeShirt" to="." method="_on_removeShirt_pressed"]
|
||||
[connection signal="pressed" from="Accessoires/AccsScroll/AccsGrid/removeAccessory" to="." method="_on_removeAccessory_pressed"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue