diff --git a/resources/character.tres b/resources/character.tres index a61bf7c..20af6e3 100644 --- a/resources/character.tres +++ b/resources/character.tres @@ -1,6 +1,3 @@ -[gd_resource type="Resource" load_steps=2 format=2] - -[ext_resource path="res://scripts/character.gd" type="Script" id=1] +[gd_resource type="Resource" format=2] [resource] -script = ExtResource( 1 ) diff --git a/scenes/CharacterBase.tscn b/scenes/Character.tscn similarity index 97% rename from scenes/CharacterBase.tscn rename to scenes/Character.tscn index bea928c..2251b6b 100644 --- a/scenes/CharacterBase.tscn +++ b/scenes/Character.tscn @@ -28,7 +28,7 @@ [ext_resource path="res://sprites/clothes/blank_top.png" type="Texture" id=26] [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] -[ext_resource path="res://scripts/character_base.gd" type="Script" id=29] +[ext_resource path="res://scripts/character.gd" type="Script" id=29] [sub_resource type="SpriteFrames" id=1] animations = [ { @@ -54,7 +54,7 @@ animations = [ { "speed": 2.0 } ] -[node name="CharacterBase" type="Node2D"] +[node name="Character" type="Node2D"] position = Vector2( -19, -92 ) script = ExtResource( 29 ) @@ -92,7 +92,7 @@ texture = ExtResource( 27 ) [node name="Eyes" type="AnimatedSprite" parent="Body/Head"] position = Vector2( 17.6857, 4.22147 ) frames = SubResource( 2 ) -frame = 2 +frame = 1 playing = true [node name="Mouth" type="AnimatedSprite" parent="Body/Head"] diff --git a/scenes/NewsWin.tscn b/scenes/NewsWin.tscn index 40a4eb6..3a10663 100644 --- a/scenes/NewsWin.tscn +++ b/scenes/NewsWin.tscn @@ -5,7 +5,6 @@ [ext_resource path="res://scripts/news_window.gd" type="Script" id=3] [node name="NewsWin" type="WindowDialog"] -visible = true anchor_left = 0.15375 anchor_top = 0.144 anchor_right = 0.84625 diff --git a/scenes/clothing/base/tops_base.tscn b/scenes/clothing/base/tops_base.tscn index 36d3053..2160fac 100644 --- a/scenes/clothing/base/tops_base.tscn +++ b/scenes/clothing/base/tops_base.tscn @@ -3,8 +3,7 @@ [ext_resource path="res://scenes/clothing/base/clothing_base.tscn" type="PackedScene" id=1] [ext_resource path="res://scripts/clothing/tops_base.gd" type="Script" id=2] - - [node name="topsBase" instance=ExtResource( 1 )] script = ExtResource( 2 ) + [connection signal="pressed" from="." to="." method="_on_tops_pressed"] diff --git a/scenes/clothing/camera.tscn b/scenes/clothing/camera.tscn index 104d91d..2b06d09 100644 --- a/scenes/clothing/camera.tscn +++ b/scenes/clothing/camera.tscn @@ -3,10 +3,6 @@ [ext_resource path="res://scenes/clothing/base/accessory_base.tscn" type="PackedScene" id=1] [ext_resource path="res://sprites/clothes/camera.png" type="Texture" id=2] - - - - [node name="camera" instance=ExtResource( 1 )] anchor_right = 0.0 anchor_bottom = 0.0 diff --git a/scenes/game.tscn b/scenes/game.tscn index 1069077..5491da0 100644 --- a/scenes/game.tscn +++ b/scenes/game.tscn @@ -1,45 +1,43 @@ -[gd_scene load_steps=18 format=2] +[gd_scene load_steps=17 format=2] -[ext_resource path="res://scenes/CharacterBase.tscn" type="PackedScene" id=1] +[ext_resource path="res://scenes/Character.tscn" type="PackedScene" id=1] [ext_resource path="res://sprites/world/background.svg" type="Texture" id=2] [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/symbols/file-upload.svg" type="Texture" id=7] -[ext_resource path="res://scripts/ui.gd" type="Script" id=8] +[ext_resource path="res://scripts/interface.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] [ext_resource path="res://sprites/symbols/newspaper.svg" type="Texture" id=15] [ext_resource path="res://scenes/NewsWin.tscn" type="PackedScene" id=16] [ext_resource path="res://sprites/symbols/newspaper-disabled.svg" type="Texture" id=17] -[node name="game" type="Node2D"] -script = ExtResource( 14 ) +[node name="Game" type="Node2D"] -[node name="Bg" type="Sprite" parent="."] +[node name="Background" type="Sprite" parent="."] position = Vector2( 504.046, 202.426 ) texture = ExtResource( 2 ) __meta__ = { "_edit_lock_": true } -[node name="picFrame" type="Sprite" parent="."] +[node name="PictureFrame" type="Sprite" parent="."] position = Vector2( 127.602, 111.895 ) texture = ExtResource( 5 ) __meta__ = { "_edit_group_": true } -[node name="light" type="Light2D" parent="picFrame"] +[node name="Light" type="Light2D" parent="PictureFrame"] position = Vector2( 35.118, -14.56 ) texture = ExtResource( 6 ) -[node name="characterBase" parent="." instance=ExtResource( 1 )] +[node name="Character" parent="." instance=ExtResource( 1 )] position = Vector2( 141.307, 225.012 ) [node name="Controls" type="CanvasLayer" parent="."] @@ -130,7 +128,7 @@ margin_bottom = 32.0 hint_tooltip = "Clear" texture_normal = ExtResource( 3 ) -[node name="versionLbl" type="Label" parent="Controls/Container"] +[node name="VersionLbl" type="Label" parent="Controls/Container"] anchor_left = 0.88125 anchor_top = 0.944 anchor_right = 0.9825 @@ -147,6 +145,6 @@ visible = false [connection signal="timeout" from="Controls/Container/Spinner/Timer" to="Controls/Container/Spinner" method="_on_Timer_timeout"] [connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/NewsBtn" to="Controls/Container" method="_on_NewsBtn_pressed"] -[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ExportBtn" to="characterBase" method="_on_SaveBtn_pressed"] -[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ImportBtn" to="characterBase" method="_on_LoadBtn_pressed"] -[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ClearBtn" to="characterBase" method="_on_clearBtn_pressed"] +[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ExportBtn" to="Character" method="_on_SaveBtn_pressed"] +[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ImportBtn" to="Character" method="_on_LoadBtn_pressed"] +[connection signal="pressed" from="Controls/Container/CenterBtns/ButtonCtr/ClearBtn" to="Character" method="_on_clearBtn_pressed"] diff --git a/scenes/wardrobe.tscn b/scenes/wardrobe.tscn index 57e440c..7a97153 100644 --- a/scenes/wardrobe.tscn +++ b/scenes/wardrobe.tscn @@ -108,10 +108,10 @@ margin_bottom = 258.0 visible = false anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 4.0 -margin_top = 38.0 -margin_right = -4.0 -margin_bottom = -4.0 +margin_left = 5.0 +margin_top = 40.0 +margin_right = -5.0 +margin_bottom = -10.0 [node name="ShirtsScroll" type="ScrollContainer" parent="Shirts"] anchor_right = 1.0 @@ -120,8 +120,8 @@ margin_left = 10.0 margin_top = 10.0 [node name="ShirtsGrid" type="GridContainer" parent="Shirts/ShirtsScroll"] -margin_right = 782.0 -margin_bottom = 448.0 +margin_right = 780.0 +margin_bottom = 440.0 size_flags_horizontal = 3 size_flags_vertical = 3 columns = 4 @@ -181,10 +181,10 @@ texture_normal = ExtResource( 2 ) visible = false anchor_right = 1.0 anchor_bottom = 1.0 -margin_left = 4.0 -margin_top = 38.0 -margin_right = -4.0 -margin_bottom = -4.0 +margin_left = 5.0 +margin_top = 40.0 +margin_right = -5.0 +margin_bottom = -10.0 [node name="AccsScroll" type="ScrollContainer" parent="Accessoires"] anchor_right = 1.0 @@ -194,8 +194,8 @@ __meta__ = { } [node name="AccsGrid" type="GridContainer" parent="Accessoires/AccsScroll"] -margin_right = 792.0 -margin_bottom = 458.0 +margin_right = 790.0 +margin_bottom = 450.0 size_flags_horizontal = 3 size_flags_vertical = 3 columns = 3 diff --git a/scripts/Character.gd b/scripts/Character.gd index d3d2111..7f161e5 100644 --- a/scripts/Character.gd +++ b/scripts/Character.gd @@ -1,8 +1,108 @@ # This project is licensed under the Artistic-2.0 license. # See the LICENSE file in the project root for more information. -extends Resource +extends Node2D -var top = null -var bottom = null -var underwear = null -var accessory = null +const _TDU_VERSION = "0.2" +const _SAVE_FILE = "user://character.tdu" + +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_win = $Controls/Container/ExportWin +onready var import_win = $Controls/Container/ImportWin + +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 + +func _process(delta): + + if GameData.accessory != null: + accessory.texture = GameData.accessory + +# if GameData.underwear != null: +# underwear.texture = GameData.underwear + + if GameData.bottom != null: + bottom.texture = GameData.bottom + + if GameData.top != null: + top.texture = GameData.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) + + GameEvents.emit_signal("indicate") + + file.store_line(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_as_text()) + + 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() + + GameEvents.emit_signal("indicate") + + 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() + GameData.accessory = blank_accessory + GameData.bottom = base_bottom + GameData.top = base_top + +func _on_SaveBtn_pressed(): + $Click.play() + save_game() + +func _on_LoadBtn_pressed(): + $Click.play() + load_game() diff --git a/scripts/autoload/game_data.gd b/scripts/autoload/game_data.gd index 50cb78d..f978595 100644 --- a/scripts/autoload/game_data.gd +++ b/scripts/autoload/game_data.gd @@ -3,3 +3,15 @@ extends Node var version = "0.0.0" + +const NEWS_API = "https://static.tonybark.com/news/dressup.json" + +var top = null +var bottom = null +var underwear = null +var accessory = null + +enum characters { + ZACK, + ANTHONY +} diff --git a/scripts/character_base.gd b/scripts/character_base.gd deleted file mode 100644 index 261b40d..0000000 --- a/scripts/character_base.gd +++ /dev/null @@ -1,109 +0,0 @@ -# This project is licensed under the Artistic-2.0 license. -# 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 export_win = $Controls/Container/ExportWin -onready var import_win = $Controls/Container/ImportWin - -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 - -func _process(delta): - - if character.accessory != null: - accessory.texture = character.accessory - -# if character.underwear != null: -# underwear.texture = character.underwear - - if character.bottom != null: - bottom.texture = character.bottom - - 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) - - GameEvents.emit_signal("indicate") - - file.store_line(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_as_text()) - - 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() - - GameEvents.emit_signal("indicate") - - 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() - save_game() - -func _on_LoadBtn_pressed(): - $Click.play() - load_game() diff --git a/scripts/clothing/accessory_base.gd b/scripts/clothing/accessory_base.gd index ad1030e..42e200a 100644 --- a/scripts/clothing/accessory_base.gd +++ b/scripts/clothing/accessory_base.gd @@ -3,5 +3,5 @@ extends "res://scripts/clothing/clothing_base.gd" func _on_accessory_pressed(): - character.accessory = texture_normal + GameData.accessory = texture_normal $select.play() diff --git a/scripts/clothing/bottoms_base.gd b/scripts/clothing/bottoms_base.gd index f02bf1f..0bd40f6 100644 --- a/scripts/clothing/bottoms_base.gd +++ b/scripts/clothing/bottoms_base.gd @@ -3,5 +3,5 @@ extends "res://scripts/clothing/clothing_base.gd" func _on_bottoms_pressed(): - character.bottom = texture_normal + GameData.bottom = texture_normal $select.play() diff --git a/scripts/clothing/tops_base.gd b/scripts/clothing/tops_base.gd index 3848a51..40308b0 100644 --- a/scripts/clothing/tops_base.gd +++ b/scripts/clothing/tops_base.gd @@ -3,5 +3,5 @@ extends "res://scripts/clothing/clothing_base.gd" func _on_tops_pressed(): - character.top = texture_normal + GameData.top = texture_normal $select.play() diff --git a/scripts/clothing/undies_base.gd b/scripts/clothing/undies_base.gd index e764089..6c6fb7b 100644 --- a/scripts/clothing/undies_base.gd +++ b/scripts/clothing/undies_base.gd @@ -3,5 +3,5 @@ extends "res://scripts/clothing/clothing_base.gd" func _on_undies_pressed(): - character.underwear = texture_normal + GameData.underwear = texture_normal $select.play() diff --git a/scripts/game.gd b/scripts/game.gd deleted file mode 100644 index 5dbd88c..0000000 --- a/scripts/game.gd +++ /dev/null @@ -1,3 +0,0 @@ -# This project is licensed under the Artistic-2.0 license. -# See the LICENSE file in the project root for more information. -extends Node2D diff --git a/scripts/ui.gd b/scripts/interface.gd similarity index 87% rename from scripts/ui.gd rename to scripts/interface.gd index e4f8b24..f6a4cc4 100644 --- a/scripts/ui.gd +++ b/scripts/interface.gd @@ -2,8 +2,6 @@ # See the LICENSE file in the project root for more information. extends Control -const _NEWS_API = "https://static.tonybark.com/news/dressup.json" - export var version: String = "1.0.0" onready var character = preload("res://resources/character.tres") @@ -18,11 +16,11 @@ onready var news_btn = $CenterBtns/ButtonCtr/NewsBtn onready var http_request = $NewsWin/NewsBtns/HTTPRequest func _ready(): - var verLabel = $versionLbl + var verLabel = $VersionLbl verLabel.text = "v" + version GameData.version = version - var err = http_request.request(_NEWS_API) + var err = http_request.request(GameData.NEWS_API) if err != OK: news_btn.disabled = true diff --git a/scripts/news_window.gd b/scripts/news_window.gd index 59acefc..1f38e6b 100644 --- a/scripts/news_window.gd +++ b/scripts/news_window.gd @@ -1,7 +1,5 @@ extends WindowDialog -const _NEWS_API = "https://static.tonybark.com/news/dressup.json" - onready var news_list = $News onready var http_request = $NewsBtns/HTTPRequest @@ -16,4 +14,4 @@ func _on_HTTPRequest_request_completed(result, response_code, headers, body): func _on_SyncBtn_pressed(): news_list.clear() - http_request.request(_NEWS_API) + http_request.request(GameData.NEWS_API) diff --git a/sprites/character.blend b/sprites/character.blend new file mode 100644 index 0000000..7fc626b Binary files /dev/null and b/sprites/character.blend differ