mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-12-22 20:32:38 +01:00
tip system
This commit is contained in:
parent
275ffc5ec4
commit
676dcadb81
4 changed files with 57 additions and 24 deletions
|
@ -11,6 +11,13 @@ When you do commits or merges while you're on a branch, the branch will grow wit
|
|||
|
||||
Finally, merge all timelines together, in a way so that the "main" branch points to the result. That's base reality!
|
||||
|
||||
---
|
||||
tipp1
|
||||
---
|
||||
tipp2
|
||||
---
|
||||
tipp3
|
||||
|
||||
[setup]
|
||||
|
||||
echo "A friendly old lady.
|
||||
|
|
|
@ -7,6 +7,8 @@ var description
|
|||
var congrats
|
||||
var cards
|
||||
var repos = {}
|
||||
var tipp_level = 0
|
||||
|
||||
|
||||
# The path is an outer path.
|
||||
func load(path):
|
||||
|
@ -20,6 +22,12 @@ func load(path):
|
|||
|
||||
title = config.get("title", slug)
|
||||
description = config.get("description", "(no description)")
|
||||
# Surround all lines indented with four spaces with [code] tags.
|
||||
var monospace_regex = RegEx.new()
|
||||
monospace_regex.compile("\\n ([^\\n]*)")
|
||||
description = monospace_regex.sub(description, "\n [code]$1[/code]", true)
|
||||
description = description.split("---")
|
||||
|
||||
congrats = config.get("congrats", "Good job, you solved the level!\n\nFeel free to try a few more things or click 'Next level'.")
|
||||
cards = Array(config.get("cards", "").split(" "))
|
||||
if cards == [""]:
|
||||
|
@ -56,14 +64,14 @@ func load(path):
|
|||
else:
|
||||
repo = "yours"
|
||||
|
||||
var description = "Goal"
|
||||
var desc = "Goal"
|
||||
for line in Array(config[k].split("\n")):
|
||||
if line.length() > 0 and line[0] == "#":
|
||||
description = line.substr(1)
|
||||
desc = line.substr(1)
|
||||
else:
|
||||
if not repos[repo].win_conditions.has(description):
|
||||
repos[repo].win_conditions[description] = ""
|
||||
repos[repo].win_conditions[description] += line+"\n"
|
||||
if not repos[repo].win_conditions.has(desc):
|
||||
repos[repo].win_conditions[desc] = ""
|
||||
repos[repo].win_conditions[desc] += line+"\n"
|
||||
|
||||
for k in repo_actions:
|
||||
var repo
|
||||
|
@ -84,10 +92,7 @@ func load(path):
|
|||
repos[repo].path = game.tmp_prefix+"repos/%s/" % repo
|
||||
repos[repo].slug = repo
|
||||
|
||||
# Surround all lines indented with four spaces with [code] tags.
|
||||
var monospace_regex = RegEx.new()
|
||||
monospace_regex.compile("\\n ([^\\n]*)")
|
||||
description = monospace_regex.sub(description, "\n [code]$1[/code]", true)
|
||||
|
||||
|
||||
func construct():
|
||||
for r in repos:
|
||||
|
|
|
@ -76,7 +76,7 @@ func load_level(level_id):
|
|||
levels.chapters[current_chapter].levels[current_level].construct()
|
||||
|
||||
var level = levels.chapters[current_chapter].levels[current_level]
|
||||
level_description.bbcode_text = level.description
|
||||
level_description.bbcode_text = level.description[0]
|
||||
level_congrats.bbcode_text = level.congrats
|
||||
level_name.text = level.title
|
||||
if levels.chapters[current_chapter].levels[current_level].cards.size() == 0:
|
||||
|
@ -141,7 +141,10 @@ func show_win_status(win_states):
|
|||
win_text += "%s: %s\n" % [state, win_states[state]]
|
||||
if not win_states[state]:
|
||||
all_won = false
|
||||
level_description.text = levels.chapters[current_chapter].levels[current_level].description + win_text
|
||||
var level = levels.chapters[current_chapter].levels[current_level]
|
||||
level_description.bbcode_text = level.description[0] + win_text
|
||||
for i in range(1,level.tipp_level+1):
|
||||
level_description.bbcode_text += level.description[i]
|
||||
|
||||
if not level_congrats.visible and all_won and win_states.size() > 0:
|
||||
next_level_button.show()
|
||||
|
@ -179,3 +182,9 @@ func update_repos():
|
|||
|
||||
func toggle_cards():
|
||||
cards.visible = not cards.visible
|
||||
|
||||
func new_tip():
|
||||
var level = levels.chapters[current_chapter].levels[current_level]
|
||||
if level.description.size() - 1 > level.tipp_level :
|
||||
level.tipp_level += 1
|
||||
level_description.bbcode_text += level.description[level.tipp_level]
|
||||
|
|
|
@ -67,7 +67,7 @@ mouse_filter = 2
|
|||
size_flags_vertical = 3
|
||||
|
||||
[node name="Repositories" type="VBoxContainer" parent="Rows/Columns"]
|
||||
margin_right = 1266.0
|
||||
margin_right = 1260.0
|
||||
margin_bottom = 782.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
|
@ -75,7 +75,7 @@ size_flags_stretch_ratio = 2.0
|
|||
custom_constants/separation = 8
|
||||
|
||||
[node name="RightSide" type="VBoxContainer" parent="Rows/Columns"]
|
||||
margin_left = 1271.0
|
||||
margin_left = 1265.0
|
||||
margin_right = 1904.0
|
||||
margin_bottom = 782.0
|
||||
size_flags_horizontal = 3
|
||||
|
@ -83,14 +83,14 @@ size_flags_vertical = 3
|
|||
custom_constants/separation = 8
|
||||
|
||||
[node name="LevelInfo" type="VBoxContainer" parent="Rows/Columns/RightSide"]
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 383.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
custom_constants/separation = 8
|
||||
|
||||
[node name="Menu" type="HBoxContainer" parent="Rows/Columns/RightSide/LevelInfo"]
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 39.0
|
||||
custom_constants/separation = 8
|
||||
|
||||
|
@ -123,9 +123,9 @@ __meta__ = {
|
|||
|
||||
[node name="CardsButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
||||
visible = false
|
||||
margin_left = 406.0
|
||||
margin_right = 478.0
|
||||
margin_bottom = 35.0
|
||||
margin_left = 458.0
|
||||
margin_right = 539.0
|
||||
margin_bottom = 39.0
|
||||
focus_mode = 0
|
||||
enabled_focus_mode = 0
|
||||
text = "Cards!"
|
||||
|
@ -133,9 +133,20 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
||||
[node name="Tip!" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
||||
margin_left = 458.0
|
||||
margin_right = 575.0
|
||||
margin_right = 514.0
|
||||
margin_bottom = 39.0
|
||||
focus_mode = 0
|
||||
enabled_focus_mode = 0
|
||||
text = "Tip!"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/LevelInfo/Menu"]
|
||||
margin_left = 522.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 39.0
|
||||
focus_mode = 0
|
||||
custom_styles/hover = SubResource( 1 )
|
||||
|
@ -148,7 +159,7 @@ __meta__ = {
|
|||
|
||||
[node name="LevelPanel" type="VBoxContainer" parent="Rows/Columns/RightSide/LevelInfo"]
|
||||
margin_top = 47.0
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 383.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
|
@ -164,7 +175,7 @@ __meta__ = {
|
|||
}
|
||||
|
||||
[node name="Text" type="Control" parent="Rows/Columns/RightSide/LevelInfo/LevelPanel"]
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 336.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
|
@ -195,7 +206,7 @@ __meta__ = {
|
|||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 391.0
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 582.0
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.5
|
||||
|
@ -206,7 +217,7 @@ mode = 2
|
|||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 590.0
|
||||
margin_right = 633.0
|
||||
margin_right = 639.0
|
||||
margin_bottom = 782.0
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.5
|
||||
|
@ -257,5 +268,6 @@ shape = SubResource( 2 )
|
|||
[connection signal="button_down" from="Rows/Columns/RightSide/LevelInfo/Menu/LevelSelect" to="." method="repopulate_levels"]
|
||||
[connection signal="pressed" from="Rows/Columns/RightSide/LevelInfo/Menu/ReloadButton" to="." method="reload_level"]
|
||||
[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="command_done" from="Rows/Controls/Terminal" to="." method="update_repos"]
|
||||
|
|
Loading…
Reference in a new issue