Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Last changes before 0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
AndusDEV committed May 1, 2023
1 parent b4f9026 commit f110908
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 12 deletions.
5 changes: 5 additions & 0 deletions levels/test_level/testlevel_states.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ extends Node
var has_talked_testnpc: bool = false
func addquest():
Quests.new("Test Quest", "Find two LonelyPie logos!", 2)

func _process(delta):
if Quests.exists("Test Quest"):
if Quests.is_completed("Test Quest"):
AchievementManager.unlock("Test and Find")
13 changes: 7 additions & 6 deletions scenes/misc/other/Notification.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ tracks/0/keys = {
"times": PoolRealArray( 0, 1, 2.5 ),
"transitions": PoolRealArray( 1, 1, 1 ),
"update": 0,
"values": [ Vector2( 1920, 0 ), Vector2( 1408, 0 ), Vector2( 1408, 0 ) ]
"values": [ Vector2( 1920, 0 ), Vector2( 1344, 0 ), Vector2( 1344, 0 ) ]
}

[sub_resource type="Animation" id=2]
Expand Down Expand Up @@ -47,7 +47,7 @@ anims/RESET = SubResource( 2 )
[node name="Panel" type="Panel" parent="."]
anchor_left = 1.0
anchor_right = 1.0
margin_right = 512.0
margin_right = 576.0
margin_bottom = 128.0

[node name="Sprite" type="Sprite" parent="Panel"]
Expand All @@ -57,15 +57,16 @@ texture = ExtResource( 1 )

[node name="NotTitle" type="Label" parent="Panel"]
margin_left = 128.0
margin_right = 440.0
margin_bottom = 30.0
margin_right = 544.0
margin_bottom = 38.0
theme = ExtResource( 2 )
text = "Notification Title"

[node name="NotDesc" type="Label" parent="Panel"]
margin_left = 128.0
margin_top = 38.0
margin_right = 440.0
margin_top = 48.0
margin_right = 544.0
margin_bottom = 120.0
theme = ExtResource( 3 )
text = "Notification Description"
autowrap = true
14 changes: 8 additions & 6 deletions scripts/misc/achievements/AchievementManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ func add_achievement(name: String, description: String):
func unlock(name: String):
if achievements.has(name):
if !is_unlocked(name):
print("Achievement Unlocked")
achievements[name].unlocked = true
Utils.send_notification(
("\"" + achievements[name].name + "\" unlocked!"),
achievements[name].description,
"achievement")
save_achievements()

func save_achievements():
Expand All @@ -34,9 +37,9 @@ func load_achievements():
var json_str = file.get_as_text()
var progress = parse_json(json_str)

for achievement in achievements:
if progress.has(achievement):
achievements[achievement].unlocked = progress[achievement]
for achievement_name in achievements.keys():
if progress.has(achievement_name):
achievements[achievement_name].unlocked = progress[achievement_name]["unlocked"]
file.close()

func is_unlocked(name: String) -> bool:
Expand All @@ -45,5 +48,4 @@ func is_unlocked(name: String) -> bool:
return false

func init_achievements():
add_achievement("My Achievement", "Description of my achievement")
add_achievement("Achievement 2", "Another Achievement")
add_achievement("Test and Find", "Testing and Finding... That's a pretty basic skill actually.")
3 changes: 3 additions & 0 deletions scripts/misc/other/Notification.gd
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ func display_next_notification():
if notification["icon"] == "quest":
$Panel/Sprite.scale = Vector2(3.5, 3.5)
$Panel/Sprite.texture = load("res://sprites/icons/misc/quest.png")
elif notification["icon"] == "achievement":
$Panel/Sprite.scale = Vector2(3.5, 3.5)
$Panel/Sprite.texture = load("res://sprites/icons/misc/achievement.png")
$AnimationPlayer.play("Notification")
yield($AnimationPlayer, "animation_finished")
$AnimationPlayer.play_backwards("Notification")
Expand Down
4 changes: 4 additions & 0 deletions scripts/misc/settings/Save.gd
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,20 @@ func save_data(slot):
func load_data(slot):
var file = File.new()
var cfg = ConfigFile.new()
# Load save.dat
if file.file_exists(Utils.savesFolder + "save" + str(slot) + "/save.dat"):
file.open(Utils.savesFolder + "save" + str(slot) + "/save.dat", File.READ)
var json = file.get_as_text()
player_data = JSON.parse(json).result
file.close()
# Load save.cfg
if file.file_exists(Utils.savesFolder + "save" + str(slot) + "/save.cfg"):
cfg.load(Utils.savesFolder + "save" + str(slot) + "/save.cfg")
save_info["save_name"] = cfg.get_value("Info", "name")
save_info["save_creation"] = cfg.get_value("Info", "created")
save_info["last_saved"] = cfg.get_value("Info", "last_saved")
# Load achievements.json
AchievementManager.load_achievements()

func exists(slot, type = 0):
var file = File.new()
Expand Down
Binary file added sprites/icons/misc/achievement.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions sprites/icons/misc/achievement.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/achievement.png-c7e35b5f003f469cdb8a3edd323fd4ca.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://sprites/icons/misc/achievement.png"
dest_files=[ "res://.import/achievement.png-c7e35b5f003f469cdb8a3edd323fd4ca.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0

0 comments on commit f110908

Please sign in to comment.