From 4910e4d566f1eef6c3749a93f54338a4cc74998e Mon Sep 17 00:00:00 2001 From: blinry Date: Fri, 8 Jan 2021 13:54:37 +0100 Subject: [PATCH] Prettier goal boxes, remote tip button for now --- scenes/file_browser.gd | 5 ++++- scenes/level.gd | 2 +- scenes/main.gd | 26 +++++++++++++++++++++++++- scenes/main.tscn | 14 +++++++++++--- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/scenes/file_browser.gd b/scenes/file_browser.gd index 2076747..96ff65f 100644 --- a/scenes/file_browser.gd +++ b/scenes/file_browser.gd @@ -6,6 +6,8 @@ enum FileBrowserMode { INDEX } +signal saved + export(String) var title setget _set_title export(FileBrowserMode) var mode = FileBrowserMode.WORKING_DIRECTORY setget _set_mode @@ -183,7 +185,8 @@ func save(): text_edit.text += "\n" helpers.write_file(fixme_path+open_file, text_edit.text) - update() + update() + emit_signal("saved") close() func _set_commit(new_commit): diff --git a/scenes/level.gd b/scenes/level.gd index ae51878..a0f5e3a 100644 --- a/scenes/level.gd +++ b/scenes/level.gd @@ -67,7 +67,7 @@ func load(path): var desc = "Goal" for line in Array(config[k].split("\n")): if line.length() > 0 and line[0] == "#": - desc = line.substr(1) + desc = line.substr(1).strip_edges(true, true) else: if not repos[repo].win_conditions.has(desc): repos[repo].win_conditions[desc] = "" diff --git a/scenes/main.gd b/scenes/main.gd index 36109a2..1928177 100644 --- a/scenes/main.gd +++ b/scenes/main.gd @@ -15,6 +15,7 @@ onready var level_description = $Rows/Columns/RightSide/LevelInfo/LevelPanel/Tex onready var level_congrats = $Rows/Columns/RightSide/LevelInfo/LevelPanel/Text/LevelCongrats onready var cards = $Rows/Controls/Cards onready var file_browser = $Rows/Columns/RightSide/FileBrowser +onready var goals = $Rows/Columns/RightSide/LevelInfo/LevelPanel/Goals var _hint_server var _hint_client_connection @@ -129,8 +130,31 @@ func load_next_level(): func show_win_status(win_states): var all_won = true var win_text = "\n\n" + for child in goals.get_children(): + child.queue_free() for state in win_states: - win_text += "%s: %s\n" % [state, win_states[state]] + var b = Label.new() + b.text = state + b.align = HALIGN_LEFT + var bg = StyleBoxFlat.new() + if win_states[state]: + bg.bg_color = Color(0.1, 0.5, 0.1) + else: + bg.bg_color = Color(0.5, 0.1, 0.1) + bg.corner_radius_bottom_left = 8 + bg.corner_radius_bottom_right = 8 + bg.corner_radius_top_left = 8 + bg.corner_radius_top_right = 8 + bg.content_margin_bottom = 8 + bg.content_margin_top = 8 + bg.content_margin_left = 8 + bg.content_margin_right = 8 + b.set("custom_styles/normal", bg) + #b.connect("pressed", self, "load", [chapter_id, level_id]) + #var slug = chapter.slug + "/" + level.slug + + goals.add_child(b) + b.autowrap = true if not win_states[state]: all_won = false var level = levels.chapters[game.current_chapter].levels[game.current_level] diff --git a/scenes/main.tscn b/scenes/main.tscn index a273993..39bd18b 100644 --- a/scenes/main.tscn +++ b/scenes/main.tscn @@ -145,6 +145,7 @@ __meta__ = { } [node name="Tip!" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"] +visible = false margin_left = 169.0 margin_right = 225.0 margin_bottom = 39.0 @@ -156,8 +157,8 @@ __meta__ = { } [node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"] -margin_left = 233.0 -margin_right = 350.0 +margin_left = 169.0 +margin_right = 286.0 margin_bottom = 39.0 focus_mode = 0 custom_styles/hover = SubResource( 1 ) @@ -187,7 +188,7 @@ __meta__ = { [node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] margin_top = 65.0 margin_right = 633.0 -margin_bottom = 469.0 +margin_bottom = 264.0 size_flags_vertical = 3 [node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel/Text"] @@ -213,6 +214,12 @@ __meta__ = { "_edit_use_anchors_": false } +[node name="Goals" type="VBoxContainer" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"] +margin_top = 269.0 +margin_right = 633.0 +margin_bottom = 469.0 +size_flags_vertical = 3 + [node name="FileBrowser" parent="Rows/Columns/RightSide" instance=ExtResource( 5 )] anchor_right = 0.0 anchor_bottom = 0.0 @@ -270,4 +277,5 @@ shape = SubResource( 2 ) [connection signal="pressed" from="Rows/Columns/RightSide/LevelInfo/Menu/CardsButton" to="." method="toggle_cards"] [connection signal="pressed" from="Rows/Columns/RightSide/LevelInfo/Menu/Tip!" to="." method="new_tip"] [connection signal="pressed" from="Rows/Columns/RightSide/LevelInfo/Menu/NextLevelButton" to="." method="load_next_level"] +[connection signal="saved" from="Rows/Columns/RightSide/FileBrowser" to="." method="update_repos"] [connection signal="command_done" from="Rows/Controls/Terminal" to="." method="update_repos"]