mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-20 16:20:18 +01:00
Put cards in a Control node
This commit is contained in:
parent
0da9bd3193
commit
ff526c3943
5 changed files with 85 additions and 65 deletions
13
card.gd
13
card.gd
|
@ -13,12 +13,11 @@ var _home_position = null
|
|||
|
||||
func _ready():
|
||||
set_process_unhandled_input(true)
|
||||
position = get_viewport_rect().size
|
||||
|
||||
func _process(delta):
|
||||
if dragged:
|
||||
var mousepos = get_viewport().get_mouse_position()
|
||||
position = mousepos - drag_offset
|
||||
global_position = mousepos - drag_offset
|
||||
|
||||
func _unhandled_input(event):
|
||||
if event is InputEventMouseButton:
|
||||
|
@ -34,9 +33,9 @@ func _unhandled_input(event):
|
|||
modulate.a = 1
|
||||
|
||||
|
||||
if get_viewport().get_mouse_position().y < get_viewport().size.y/2:
|
||||
if get_viewport().get_mouse_position().y < get_viewport().size.y/3*2:
|
||||
if arg_number == 0 :
|
||||
$"../..".terminal.send_command($Label.text)
|
||||
$"../../..".terminal.send_command($Label.text)
|
||||
buuurn()
|
||||
else:
|
||||
move_back()
|
||||
|
@ -62,8 +61,8 @@ func move_back():
|
|||
|
||||
func buuurn():
|
||||
queue_free()
|
||||
#$"..".draw_rand_card()
|
||||
$"..".arrange_cards()
|
||||
$"..".draw_rand_card()
|
||||
#$"..".arrange_cards()
|
||||
|
||||
func dropped_on(other):
|
||||
var full_command = ""
|
||||
|
@ -73,7 +72,7 @@ func dropped_on(other):
|
|||
if ($Label.text.begins_with("git checkout") or $Label.text.begins_with("git rebase")) and other.id.begins_with("refs/heads"):
|
||||
argument = Array(other.id.split("/")).pop_back()
|
||||
full_command = $Label.text + " " + argument
|
||||
$"../..".terminal.send_command(full_command)
|
||||
$"../../..".terminal.send_command(full_command)
|
||||
buuurn()
|
||||
# 2:
|
||||
# if _first_argument:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
extends Node2D
|
||||
extends Control
|
||||
|
||||
var cards = [
|
||||
{"command": 'git add .', "arg_number": 0, "description": "Add all files in the working directory to the index."},
|
||||
|
@ -46,6 +46,7 @@ func draw_rand_card():
|
|||
new_card.command = card.command
|
||||
new_card.arg_number = card.arg_number
|
||||
new_card.description = card.description
|
||||
new_card.position = Vector2(rect_size.x, rect_size.y*2)
|
||||
add_child(new_card)
|
||||
arrange_cards()
|
||||
|
||||
|
@ -64,7 +65,7 @@ func arrange_cards():
|
|||
|
||||
var current_angle = -total_angle/2
|
||||
for card in get_tree().get_nodes_in_group("cards"):
|
||||
var target_position = Vector2(get_viewport_rect().size.x/2, get_viewport_rect().size.y + 1500)
|
||||
var target_position = Vector2(rect_size.x/2, rect_size.y + 1500)
|
||||
var target_rotation = current_angle
|
||||
var translation_vec = Vector2(0,-1500).rotated(current_angle/180.0*PI)
|
||||
target_position += translation_vec
|
||||
|
|
18
cards.tscn
18
cards.tscn
|
@ -3,14 +3,22 @@
|
|||
[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1]
|
||||
[ext_resource path="res://cardgame.gd" type="Script" id=3]
|
||||
|
||||
[node name="Cards" type="Node2D"]
|
||||
[node name="Cards" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
mouse_filter = 2
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Button" type="Button" parent="."]
|
||||
margin_left = 1719.41
|
||||
margin_top = 814.594
|
||||
margin_right = 1892.41
|
||||
margin_bottom = 856.594
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
margin_left = -172.0
|
||||
margin_top = 16.0
|
||||
margin_right = -16.0
|
||||
margin_bottom = 47.0
|
||||
custom_fonts/font = ExtResource( 1 )
|
||||
text = "Draw new cards"
|
||||
__meta__ = {
|
||||
|
|
16
main.gd
16
main.gd
|
@ -5,17 +5,17 @@ var dragged = null
|
|||
var current_chapter
|
||||
var current_level
|
||||
|
||||
onready var terminal = $Columns/RightSide/Terminal
|
||||
onready var terminal = $Rows/Columns/RightSide/Terminal
|
||||
onready var input = terminal.input
|
||||
onready var output = terminal.output
|
||||
onready var repositories_node = $Columns/Repositories
|
||||
onready var repositories_node = $Rows/Columns/Repositories
|
||||
var repositories = {}
|
||||
onready var level_select = $Columns/RightSide/TopStuff/Menu/LevelSelect
|
||||
onready var chapter_select = $Columns/RightSide/TopStuff/Menu/ChapterSelect
|
||||
onready var next_level_button = $Columns/RightSide/TopStuff/Menu/NextLevelButton
|
||||
onready var level_name = $Columns/RightSide/TopStuff/LevelPanel/LevelName
|
||||
onready var level_description = $Columns/RightSide/TopStuff/LevelPanel/Text/LevelDescription
|
||||
onready var level_congrats = $Columns/RightSide/TopStuff/LevelPanel/Text/LevelCongrats
|
||||
onready var level_select = $Rows/Columns/RightSide/TopStuff/Menu/LevelSelect
|
||||
onready var chapter_select = $Rows/Columns/RightSide/TopStuff/Menu/ChapterSelect
|
||||
onready var next_level_button = $Rows/Columns/RightSide/TopStuff/Menu/NextLevelButton
|
||||
onready var level_name = $Rows/Columns/RightSide/TopStuff/LevelPanel/LevelName
|
||||
onready var level_description = $Rows/Columns/RightSide/TopStuff/LevelPanel/Text/LevelDescription
|
||||
onready var level_congrats = $Rows/Columns/RightSide/TopStuff/LevelPanel/Text/LevelCongrats
|
||||
|
||||
func _ready():
|
||||
var args = helpers.parse_args()
|
||||
|
|
98
main.tscn
98
main.tscn
|
@ -23,7 +23,6 @@ corner_radius_bottom_left = 3
|
|||
[node name="Main" type="Control"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_bottom = -285.0
|
||||
mouse_filter = 2
|
||||
theme = ExtResource( 6 )
|
||||
script = ExtResource( 2 )
|
||||
|
@ -43,21 +42,27 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Columns" type="HSplitContainer" parent="."]
|
||||
[node name="Rows" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 5.0
|
||||
margin_top = 5.0
|
||||
margin_right = -5.0
|
||||
margin_bottom = -5.0
|
||||
mouse_filter = 2
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Repositories" type="HBoxContainer" parent="Columns"]
|
||||
margin_right = 1267.0
|
||||
margin_bottom = 785.0
|
||||
[node name="Columns" type="HSplitContainer" parent="Rows"]
|
||||
margin_right = 1920.0
|
||||
margin_bottom = 796.0
|
||||
mouse_filter = 2
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Repositories" type="HBoxContainer" parent="Rows/Columns"]
|
||||
margin_right = 1274.0
|
||||
margin_bottom = 796.0
|
||||
mouse_filter = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_stretch_ratio = 2.0
|
||||
|
@ -66,29 +71,29 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="RightSide" type="VSplitContainer" parent="Columns"]
|
||||
margin_left = 1279.0
|
||||
margin_right = 1910.0
|
||||
margin_bottom = 785.0
|
||||
[node name="RightSide" type="VSplitContainer" parent="Rows/Columns"]
|
||||
margin_left = 1286.0
|
||||
margin_right = 1920.0
|
||||
margin_bottom = 796.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="TopStuff" type="VBoxContainer" parent="Columns/RightSide"]
|
||||
margin_right = 631.0
|
||||
margin_bottom = 386.0
|
||||
[node name="TopStuff" type="VBoxContainer" parent="Rows/Columns/RightSide"]
|
||||
margin_right = 634.0
|
||||
margin_bottom = 392.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Menu" type="HBoxContainer" parent="Columns/RightSide/TopStuff"]
|
||||
margin_right = 631.0
|
||||
[node name="Menu" type="HBoxContainer" parent="Rows/Columns/RightSide/TopStuff"]
|
||||
margin_right = 634.0
|
||||
margin_bottom = 35.0
|
||||
|
||||
[node name="ChapterSelect" type="OptionButton" parent="Columns/RightSide/TopStuff/Menu"]
|
||||
[node name="ChapterSelect" type="OptionButton" parent="Rows/Columns/RightSide/TopStuff/Menu"]
|
||||
margin_right = 168.0
|
||||
margin_bottom = 35.0
|
||||
focus_mode = 0
|
||||
enabled_focus_mode = 0
|
||||
text = "Select chapter..."
|
||||
|
||||
[node name="LevelSelect" type="OptionButton" parent="Columns/RightSide/TopStuff/Menu"]
|
||||
[node name="LevelSelect" type="OptionButton" parent="Rows/Columns/RightSide/TopStuff/Menu"]
|
||||
margin_left = 173.0
|
||||
margin_right = 317.0
|
||||
margin_bottom = 35.0
|
||||
|
@ -97,7 +102,7 @@ enabled_focus_mode = 0
|
|||
text = "Select level..."
|
||||
expand_icon = true
|
||||
|
||||
[node name="ReloadButton" type="Button" parent="Columns/RightSide/TopStuff/Menu"]
|
||||
[node name="ReloadButton" type="Button" parent="Rows/Columns/RightSide/TopStuff/Menu"]
|
||||
margin_left = 322.0
|
||||
margin_right = 401.0
|
||||
margin_bottom = 35.0
|
||||
|
@ -108,7 +113,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="NextLevelButton" type="Button" parent="Columns/RightSide/TopStuff/Menu"]
|
||||
[node name="NextLevelButton" type="Button" parent="Rows/Columns/RightSide/TopStuff/Menu"]
|
||||
margin_left = 406.0
|
||||
margin_right = 516.0
|
||||
margin_bottom = 35.0
|
||||
|
@ -121,14 +126,14 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LevelPanel" type="VBoxContainer" parent="Columns/RightSide/TopStuff"]
|
||||
[node name="LevelPanel" type="VBoxContainer" parent="Rows/Columns/RightSide/TopStuff"]
|
||||
margin_top = 40.0
|
||||
margin_right = 631.0
|
||||
margin_bottom = 386.0
|
||||
margin_right = 634.0
|
||||
margin_bottom = 392.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LevelName" type="RichTextLabel" parent="Columns/RightSide/TopStuff/LevelPanel"]
|
||||
margin_right = 631.0
|
||||
[node name="LevelName" type="RichTextLabel" parent="Rows/Columns/RightSide/TopStuff/LevelPanel"]
|
||||
margin_right = 634.0
|
||||
margin_bottom = 60.0
|
||||
rect_min_size = Vector2( 0, 60 )
|
||||
custom_fonts/normal_font = ExtResource( 7 )
|
||||
|
@ -137,13 +142,13 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Text" type="Control" parent="Columns/RightSide/TopStuff/LevelPanel"]
|
||||
[node name="Text" type="Control" parent="Rows/Columns/RightSide/TopStuff/LevelPanel"]
|
||||
margin_top = 65.0
|
||||
margin_right = 631.0
|
||||
margin_bottom = 346.0
|
||||
margin_right = 634.0
|
||||
margin_bottom = 352.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="LevelDescription" type="RichTextLabel" parent="Columns/RightSide/TopStuff/LevelPanel/Text"]
|
||||
[node name="LevelDescription" type="RichTextLabel" parent="Rows/Columns/RightSide/TopStuff/LevelPanel/Text"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_vertical = 3
|
||||
|
@ -154,7 +159,7 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LevelCongrats" type="RichTextLabel" parent="Columns/RightSide/TopStuff/LevelPanel/Text"]
|
||||
[node name="LevelCongrats" type="RichTextLabel" parent="Rows/Columns/RightSide/TopStuff/LevelPanel/Text"]
|
||||
visible = false
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
@ -166,14 +171,23 @@ __meta__ = {
|
|||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Terminal" parent="Columns/RightSide" instance=ExtResource( 1 )]
|
||||
[node name="Terminal" parent="Rows/Columns/RightSide" instance=ExtResource( 1 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 398.0
|
||||
margin_right = 631.0
|
||||
margin_bottom = 785.0
|
||||
margin_top = 404.0
|
||||
margin_right = 634.0
|
||||
margin_bottom = 796.0
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Cards" parent="Rows" instance=ExtResource( 3 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 801.0
|
||||
margin_right = 1920.0
|
||||
margin_bottom = 1080.0
|
||||
size_flags_vertical = 3
|
||||
size_flags_stretch_ratio = 0.35
|
||||
|
||||
[node name="Test" type="Node2D" parent="."]
|
||||
visible = false
|
||||
script = ExtResource( 9 )
|
||||
|
@ -189,11 +203,9 @@ caret_blink = true
|
|||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Cards" parent="." instance=ExtResource( 3 )]
|
||||
[connection signal="button_down" from="Columns/RightSide/TopStuff/Menu/ChapterSelect" to="." method="repopulate_chapters"]
|
||||
[connection signal="button_down" from="Columns/RightSide/TopStuff/Menu/LevelSelect" to="." method="repopulate_levels"]
|
||||
[connection signal="pressed" from="Columns/RightSide/TopStuff/Menu/ReloadButton" to="." method="reload_level"]
|
||||
[connection signal="pressed" from="Columns/RightSide/TopStuff/Menu/NextLevelButton" to="." method="load_next_level"]
|
||||
[connection signal="command_done" from="Columns/RightSide/Terminal" to="." method="update_repos"]
|
||||
[connection signal="button_down" from="Rows/Columns/RightSide/TopStuff/Menu/ChapterSelect" to="." method="repopulate_chapters"]
|
||||
[connection signal="button_down" from="Rows/Columns/RightSide/TopStuff/Menu/LevelSelect" to="." method="repopulate_levels"]
|
||||
[connection signal="pressed" from="Rows/Columns/RightSide/TopStuff/Menu/ReloadButton" to="." method="reload_level"]
|
||||
[connection signal="pressed" from="Rows/Columns/RightSide/TopStuff/Menu/NextLevelButton" to="." method="load_next_level"]
|
||||
[connection signal="command_done" from="Rows/Columns/RightSide/Terminal" to="." method="update_repos"]
|
||||
[connection signal="text_entered" from="Test/LineEdit" to="Test" method="send"]
|
||||
|
|
Loading…
Reference in a new issue