mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-03 19:04:40 +01:00
Extend the hint system to explain GUI elements
This commit is contained in:
parent
d258f812ce
commit
e87e29a3ed
9 changed files with 83 additions and 28 deletions
|
@ -54,6 +54,9 @@ func draw(ids):
|
|||
|
||||
arrange_cards()
|
||||
|
||||
if ids.size() > 0:
|
||||
game.notify("These are your cards! Drag them to highlighted areas to play them!", self, "cards")
|
||||
|
||||
func arrange_cards():
|
||||
var t = Timer.new()
|
||||
t.wait_time = 0.05
|
||||
|
|
|
@ -80,6 +80,9 @@ func update():
|
|||
item.repository = repository
|
||||
item.connect("clicked", self, "item_clicked")
|
||||
grid.add_child(item)
|
||||
|
||||
if files.size() > 0:
|
||||
game.notify("Click on these files to edit them!", self, "file-browser")
|
||||
|
||||
if false:
|
||||
match mode:
|
||||
|
|
|
@ -28,7 +28,7 @@ func copy_script_to_game_env(name):
|
|||
global_shell.run("chmod u+x '%s'" % (tmp_prefix + name))
|
||||
|
||||
func _initial_state():
|
||||
return {"history": [], "solved_levels": []}
|
||||
return {"history": [], "solved_levels": [], "received_hints": []}
|
||||
|
||||
func save_state():
|
||||
var savegame = File.new()
|
||||
|
@ -56,8 +56,19 @@ func create_file_in_game_env(filename, content):
|
|||
# Quoted HERE doc doesn't do any substitutions inside.
|
||||
global_shell.run("cat > '%s' <<'HEREHEREHERE'\n%s\nHEREHEREHERE" % [filename, content])
|
||||
|
||||
func notify(text):
|
||||
print(text)
|
||||
func notify(text, target=null, hint_slug=null):
|
||||
if hint_slug:
|
||||
if not state.has("received_hints"):
|
||||
state["received_hints"] = []
|
||||
if hint_slug in state["received_hints"]:
|
||||
return
|
||||
|
||||
var notification = preload("res://scenes/notification.tscn").instance()
|
||||
notification.text = text
|
||||
get_tree().root.call_deferred("add_child", notification)
|
||||
if not target:
|
||||
target = get_tree().root
|
||||
target.call_deferred("add_child", notification)
|
||||
|
||||
if hint_slug:
|
||||
state["received_hints"].push_back(hint_slug)
|
||||
save_state()
|
||||
|
|
|
@ -113,7 +113,7 @@ func load_level(level_id):
|
|||
|
||||
# chapter_select.select(game.current_chapter)
|
||||
# level_select.select(game.current_level)
|
||||
|
||||
#game.notify("These are your cards!", cards)
|
||||
|
||||
func reload_level():
|
||||
cards.load_card_store()
|
||||
|
|
|
@ -80,6 +80,7 @@ func type_set(new_type):
|
|||
$Sprite.texture = preload("res://nodes/tree.svg")
|
||||
"commit":
|
||||
$Sprite.texture = preload("res://nodes/commit.svg")
|
||||
game.notify("You can drag these around with your mouse!", self, "drag-nodes")
|
||||
"tag":
|
||||
$Sprite.texture = preload("res://nodes/blob.svg")
|
||||
"ref":
|
||||
|
|
|
@ -1,14 +1,20 @@
|
|||
extends PopupPanel
|
||||
extends Node2D
|
||||
|
||||
var text setget _set_text
|
||||
var button_texts = ["Got it!", "Interesting!", "Very useful!", "Cool!", "Nice!", "Thanks!", "Whatever...", "Okay!", "Yay!", "Awesome!"]
|
||||
|
||||
func _ready():
|
||||
popup()
|
||||
button_texts.shuffle()
|
||||
$Panel/CenterContainer/OK.text = button_texts[0]
|
||||
|
||||
func _gui_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
queue_free()
|
||||
#func _gui_input(event):
|
||||
# if event is InputEventMouseButton:
|
||||
# queue_free()
|
||||
|
||||
func _set_text(new_text):
|
||||
text = new_text
|
||||
$Label.text = new_text
|
||||
$Panel/Label.text = new_text
|
||||
|
||||
|
||||
func confirm():
|
||||
queue_free()
|
||||
|
|
|
@ -1,33 +1,61 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://styles/theme.tres" type="Theme" id=2]
|
||||
[ext_resource path="res://scenes/notification.gd" type="Script" id=3]
|
||||
|
||||
[node name="Notification" type="PopupPanel"]
|
||||
visible = true
|
||||
margin_left = 16.0
|
||||
margin_top = 16.0
|
||||
margin_right = 369.0
|
||||
margin_bottom = 212.0
|
||||
theme = ExtResource( 2 )
|
||||
[sub_resource type="StyleBoxFlat" id=1]
|
||||
bg_color = Color( 0.0431373, 0.368627, 0.141176, 0.843137 )
|
||||
corner_radius_top_left = 8
|
||||
corner_radius_top_right = 8
|
||||
corner_radius_bottom_right = 8
|
||||
corner_radius_bottom_left = 8
|
||||
|
||||
[node name="Notification" type="Node2D"]
|
||||
z_index = 4096
|
||||
script = ExtResource( 3 )
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = 492.0
|
||||
margin_bottom = 170.0
|
||||
theme = ExtResource( 2 )
|
||||
custom_styles/panel = SubResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Label" type="Label" parent="."]
|
||||
anchor_left = 0.045
|
||||
anchor_top = 0.082
|
||||
anchor_right = 0.955
|
||||
anchor_bottom = 0.918
|
||||
margin_left = 0.115
|
||||
margin_top = -0.0720005
|
||||
margin_right = -0.115021
|
||||
margin_bottom = 0.071991
|
||||
[node name="Label" type="Label" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 16.0
|
||||
margin_top = 13.0
|
||||
margin_right = -15.0
|
||||
margin_bottom = -15.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "This is a hint! This is a hint! This is a hint! This is a hint! This is a hint! This is a hint! This is a hint! This is a hint! This is a hint!"
|
||||
autowrap = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="Panel"]
|
||||
anchor_top = 1.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_top = -58.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="OK" type="Button" parent="Panel/CenterContainer"]
|
||||
margin_left = 202.0
|
||||
margin_top = 9.0
|
||||
margin_right = 282.0
|
||||
margin_bottom = 48.0
|
||||
text = "Got it!"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
[connection signal="pressed" from="Panel/CenterContainer/OK" to="." method="confirm"]
|
||||
|
|
|
@ -88,6 +88,8 @@ func set_label(new_label):
|
|||
new_label = ""
|
||||
$Rows/RepoVis/SeparatorLine/DropArea.queue_free()
|
||||
$Rows/RepoVis/SeparatorLine.hide()
|
||||
else:
|
||||
game.notify("This is the time machine of another person! To interact with it, you need special commands!", self, "remote")
|
||||
label_node.text = new_label
|
||||
|
||||
func random_position():
|
||||
|
|
|
@ -96,6 +96,7 @@ func command_done(cmd):
|
|||
|
||||
if cmd.output.length() <= 1000:
|
||||
output.text = output.text + "$ " + cmd.command + "\n" + cmd.output
|
||||
game.notify("This is your terminal! All commands are executed here, and you can see their output. You can also type your own commands here!", self, "terminal")
|
||||
else:
|
||||
$Pager/Text.text = cmd.output
|
||||
$Pager.popup()
|
||||
|
|
Loading…
Reference in a new issue