diff --git a/project.godot b/project.godot index 33a84c4..c5ef88d 100644 --- a/project.godot +++ b/project.godot @@ -39,14 +39,9 @@ window/size/width=800 window/size/height=500 window/size/resizable=false window/energy_saving/keep_screen_on=false -mouse_cursor/custom_image="res://sprites/clothes/cursor.png" window/stretch/mode="2d" window/stretch/aspect="keep" -[gui] - -theme/custom_font="res://fonts/kenny_pixel_25.tres" - [importer_defaults] texture={ diff --git a/scenes/character_base.tscn b/scenes/character_base.tscn index 0d83121..bea928c 100644 --- a/scenes/character_base.tscn +++ b/scenes/character_base.tscn @@ -30,7 +30,7 @@ [ext_resource path="res://sprites/character/mouth/mouth11.png" type="Texture" id=28] [ext_resource path="res://scripts/character_base.gd" type="Script" id=29] -[sub_resource type="SpriteFrames" id=2] +[sub_resource type="SpriteFrames" id=1] animations = [ { "frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ) ], "loop": true, @@ -38,7 +38,7 @@ animations = [ { "speed": 2.0 } ] -[sub_resource type="SpriteFrames" id=3] +[sub_resource type="SpriteFrames" id=2] animations = [ { "frames": [ ExtResource( 6 ), ExtResource( 7 ), ExtResource( 8 ), ExtResource( 9 ), ExtResource( 10 ), ExtResource( 11 ), ExtResource( 12 ) ], "loop": true, @@ -46,7 +46,7 @@ animations = [ { "speed": 2.0 } ] -[sub_resource type="SpriteFrames" id=4] +[sub_resource type="SpriteFrames" id=3] 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, @@ -54,56 +54,97 @@ animations = [ { "speed": 2.0 } ] -[node name="characterBase" type="Node2D"] +[node name="CharacterBase" type="Node2D"] position = Vector2( -19, -92 ) script = ExtResource( 29 ) [node name="Click" type="AudioStreamPlayer" parent="."] stream = ExtResource( 24 ) -[node name="shadow" type="Sprite" parent="."] +[node name="Shadow" type="Sprite" parent="."] position = Vector2( 4.84271, 244.714 ) texture = ExtResource( 1 ) -[node name="body" type="Node2D" parent="."] +[node name="Body" type="Node2D" parent="."] __meta__ = { "_edit_lock_": true } -[node name="tail" type="AnimatedSprite" parent="body"] +[node name="Tail" type="AnimatedSprite" parent="Body"] position = Vector2( -33.7592, 99.4079 ) scale = Vector2( 0.927713, 1 ) -frames = SubResource( 2 ) -frame = 1 +frames = SubResource( 1 ) +frame = 2 playing = true -[node name="legs" type="Sprite" parent="body"] +[node name="Legs" type="Sprite" parent="Body"] position = Vector2( 1.47027, 191.868 ) texture = ExtResource( 5 ) -[node name="top" type="Sprite" parent="body"] +[node name="Top" type="Sprite" parent="Body"] position = Vector2( 7, 78 ) texture = ExtResource( 25 ) -[node name="head" type="Sprite" parent="body"] +[node name="Head" type="Sprite" parent="Body"] position = Vector2( 10.6805, -25.1047 ) texture = ExtResource( 27 ) -[node name="eyes" type="AnimatedSprite" parent="body/head"] +[node name="Eyes" type="AnimatedSprite" parent="Body/Head"] position = Vector2( 17.6857, 4.22147 ) -frames = SubResource( 3 ) -frame = 1 +frames = SubResource( 2 ) +frame = 2 playing = true -[node name="mouth" type="AnimatedSprite" parent="body/head"] +[node name="Mouth" type="AnimatedSprite" parent="Body/Head"] position = Vector2( 38.1195, 8.68453 ) -frames = SubResource( 4 ) -frame = 9 +frames = SubResource( 3 ) +frame = 10 playing = true -[node name="accessory" type="Sprite" parent="body"] +[node name="Accessory" type="Sprite" parent="Body"] position = Vector2( 9.54095, 73.0832 ) texture = ExtResource( 26 ) __meta__ = { "_edit_lock_": true } + +[node name="Controls" type="CanvasLayer" parent="."] + +[node name="Container" type="Control" parent="Controls"] +anchor_right = 1.0 +anchor_bottom = 1.0 +margin_left = -19.0 +margin_top = -92.0 +margin_right = -19.0 +margin_bottom = -92.0 +__meta__ = { +"_edit_lock_": true, +"_edit_use_anchors_": true +} + +[node name="ExportWin" type="FileDialog" parent="Controls/Container"] +anchor_left = 0.215 +anchor_top = 0.21 +anchor_right = 0.785 +anchor_bottom = 0.79 +window_title = "Export" +access = 1 +current_dir = "user://Users/tonytins/Projects/tonysdressup" +current_path = "user://Users/tonytins/Projects/tonysdressup/" +__meta__ = { +"_edit_use_anchors_": true +} + +[node name="ImportWin" type="FileDialog" parent="Controls/Container"] +anchor_left = 0.215 +anchor_top = 0.21 +anchor_right = 0.785 +anchor_bottom = 0.79 +window_title = "Open a File" +mode = 0 +access = 1 +current_dir = "user://Users/tonytins/Projects/tonysdressup" +current_path = "user://Users/tonytins/Projects/tonysdressup/" +__meta__ = { +"_edit_use_anchors_": true +} diff --git a/scenes/game.tscn b/scenes/game.tscn index 1bc2e2b..519fbe6 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=15 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] @@ -9,6 +9,8 @@ [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://sprites/symbols/file-download.svg" type="Texture" id=9] +[ext_resource path="res://sprites/symbols/file-upload-disabled.svg" type="Texture" id=10] +[ext_resource path="res://sprites/symbols/file-download-disabled.svg" type="Texture" id=11] [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] @@ -35,7 +37,7 @@ position = Vector2( 35.118, -14.56 ) texture = ExtResource( 6 ) [node name="characterBase" parent="." instance=ExtResource( 1 )] -position = Vector2( 133.807, 230.615 ) +position = Vector2( 141.307, 225.012 ) [node name="Controls" type="CanvasLayer" parent="."] @@ -81,34 +83,33 @@ __meta__ = { } [node name="ButtonCtr" type="HBoxContainer" parent="Controls/Container/CenterBtns"] -margin_left = 179.0 -margin_top = 4.0 -margin_right = 330.0 -margin_bottom = 42.0 +margin_left = 197.0 +margin_top = 7.0 +margin_right = 312.0 +margin_bottom = 39.0 custom_constants/separation = 20 -[node name="ExportBtn" type="Button" parent="Controls/Container/CenterBtns/ButtonCtr"] -margin_right = 37.0 -margin_bottom = 38.0 +[node name="ExportBtn" type="TextureButton" parent="Controls/Container/CenterBtns/ButtonCtr"] +margin_right = 25.0 +margin_bottom = 32.0 hint_tooltip = "Export" -icon = ExtResource( 7 ) -flat = true +texture_normal = ExtResource( 7 ) +texture_disabled = ExtResource( 10 ) -[node name="ImportBtn" type="Button" parent="Controls/Container/CenterBtns/ButtonCtr"] -margin_left = 57.0 -margin_right = 94.0 -margin_bottom = 38.0 +[node name="ImportBtn" type="TextureButton" parent="Controls/Container/CenterBtns/ButtonCtr"] +margin_left = 45.0 +margin_right = 70.0 +margin_bottom = 32.0 hint_tooltip = "Import" -icon = ExtResource( 9 ) -flat = true +texture_normal = ExtResource( 9 ) +texture_disabled = ExtResource( 11 ) -[node name="ClearBtn" type="Button" parent="Controls/Container/CenterBtns/ButtonCtr"] -margin_left = 114.0 -margin_right = 151.0 -margin_bottom = 38.0 +[node name="ClearBtn" type="TextureButton" parent="Controls/Container/CenterBtns/ButtonCtr"] +margin_left = 90.0 +margin_right = 115.0 +margin_bottom = 32.0 hint_tooltip = "Clear" -icon = ExtResource( 3 ) -flat = true +texture_normal = ExtResource( 3 ) [node name="versionLbl" type="Label" parent="Controls/Container"] anchor_left = 0.88125 diff --git a/scripts/character_base.gd b/scripts/character_base.gd index 3557c63..83bc355 100644 --- a/scripts/character_base.gd +++ b/scripts/character_base.gd @@ -10,12 +10,16 @@ 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 export_win = $Controls/Container/ExportWin +onready var import_win = $Controls/Container/ImportWin +onready var unsupported_win = $Controls/Container/NotSupportedWin + +onready var accessory = $Body/Accessory #onready var underwear = $Undies -onready var bottom = $body/legs -onready var top = $body/top -onready var eyes = $body/head/eyes -onready var mouth = $body/head/mouth +onready var bottom = $Body/Legs +onready var top = $Body/Top +# onready var eyes = $Body/Head/Eyes +# onready var mouth = $Body/Head/Mouth func _process(delta): @@ -43,13 +47,16 @@ func save_game(): 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) + + GameEvents.emit_signal("indicate") + file.store_line(json_file) - print_debug(json_file) file.close() func load_game(): @@ -62,8 +69,8 @@ func load_game(): if file.open(_SAVE_FILE, File.READ) != 0: print("Error opening file") return - - var data = parse_json(file.get_line()) + + var data = parse_json(file.get_as_text()) var top_texture = ImageTexture.new() var accessory_texture = ImageTexture.new() @@ -72,6 +79,8 @@ func load_game(): var accessory_image = Image.new() var bottom_image = Image.new() + GameEvents.emit_signal("indicate") + top_image.load(data["top"]) top_texture.create_from_image(top_image) top.texture = top_texture @@ -94,10 +103,8 @@ func _on_clearBtn_pressed(): func _on_SaveBtn_pressed(): $Click.play() - GameEvents.emit_signal("indicate") save_game() func _on_LoadBtn_pressed(): $Click.play() - GameEvents.emit_signal("indicate") load_game() diff --git a/scripts/game.gd b/scripts/game.gd index 6aea0f7..5dbd88c 100644 --- a/scripts/game.gd +++ b/scripts/game.gd @@ -1,3 +1,3 @@ # This project is licensed under the Artistic-2.0 license. # See the LICENSE file in the project root for more information. -extends Node2D \ No newline at end of file +extends Node2D diff --git a/scripts/ui.gd b/scripts/ui.gd index d588ce2..9c6785a 100644 --- a/scripts/ui.gd +++ b/scripts/ui.gd @@ -9,7 +9,14 @@ 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 export_btn = $CenterBtns/ButtonCtr/ExportBtn +onready var import_btn = $CenterBtns/ButtonCtr/ImportBtn + func _ready(): var verLabel = $versionLbl verLabel.text = "v" + version GameData.version = version + + if OS.get_name() == "HTML5": + export_btn.disabled == true + import_btn.disabled == true