From fe711f9fc2046baaf86330c0b2b7fbf68f822cd3 Mon Sep 17 00:00:00 2001 From: Sebastian Morr Date: Wed, 14 Oct 2020 00:27:37 +0200 Subject: [PATCH] Add card descriptions --- card.gd | 10 ++++++++-- card.tscn | 47 ++++++++++++++++++++++++++++++++++++++--------- cardgame.gd | 20 ++++++++++---------- cardgame.tscn | 12 +++++++----- 4 files changed, 63 insertions(+), 26 deletions(-) diff --git a/card.gd b/card.gd index 76f4091..233b288 100644 --- a/card.gd +++ b/card.gd @@ -3,12 +3,14 @@ extends Node2D var hovered = false var dragged = false var drag_offset + export var arg_number = 0 export var command = "" setget set_command +export var description = "" setget set_description + var _first_argument = null var _home_position = null - func _ready(): set_process_unhandled_input(true) position = get_viewport_rect().size @@ -49,7 +51,11 @@ func _mouse_exited(): func set_command(new_command): command = new_command - $Label.text = self.command + $Label.text = command + +func set_description(new_description): + description = new_description + $Description.text = description func move_back(): position = _home_position diff --git a/card.tscn b/card.tscn index 2dcbdb6..c5a6985 100644 --- a/card.tscn +++ b/card.tscn @@ -1,10 +1,10 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] [ext_resource path="res://card.gd" type="Script" id=1] [ext_resource path="res://fonts/default.tres" type="DynamicFont" id=2] -[sub_resource type="StyleBoxFlat" id=2] -bg_color = Color( 0.145098, 0.529412, 0.682353, 1 ) +[sub_resource type="StyleBoxFlat" id=1] +bg_color = Color( 0.45098, 0.584314, 0.843137, 1 ) border_color = Color( 0.0627451, 0.141176, 0.176471, 1 ) corner_radius_top_left = 10 corner_radius_top_right = 10 @@ -14,9 +14,16 @@ shadow_color = Color( 0, 0, 0, 0.392157 ) shadow_size = 4 shadow_offset = Vector2( -2, 2 ) -[sub_resource type="RectangleShape2D" id=1] +[sub_resource type="RectangleShape2D" id=2] extents = Vector2( 105.74, 143.46 ) +[sub_resource type="StyleBoxFlat" id=3] +bg_color = Color( 1, 1, 1, 0.243137 ) +corner_radius_top_left = 10 +corner_radius_top_right = 10 +corner_radius_bottom_right = 10 +corner_radius_bottom_left = 10 + [node name="Card" type="Node2D" groups=[ "cards", ]] @@ -28,7 +35,7 @@ margin_top = -291.0 margin_right = 104.0 margin_bottom = -2.0 mouse_filter = 2 -custom_styles/panel = SubResource( 2 ) +custom_styles/panel = SubResource( 1 ) __meta__ = { "_edit_use_anchors_": false } @@ -50,16 +57,38 @@ position = Vector2( 0, -145.336 ) [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] position = Vector2( -6.10352e-05, 0.00012207 ) -shape = SubResource( 1 ) +shape = SubResource( 2 ) [node name="Label" type="Label" parent="."] margin_left = -89.0 -margin_top = -276.336 +margin_top = -276.0 margin_right = 85.0 -margin_bottom = -174.336 +margin_bottom = -185.0 custom_fonts/font = ExtResource( 2 ) custom_colors/font_color = Color( 0, 0, 0, 1 ) -text = "git checkout" +text = "Name" +autowrap = true +__meta__ = { +"_edit_use_anchors_": false +} + +[node name="ColorRect2" type="Panel" parent="."] +margin_left = -97.0 +margin_top = -169.0 +margin_right = 94.0 +margin_bottom = -10.0 +mouse_filter = 2 +custom_styles/panel = SubResource( 3 ) + +[node name="Description" type="Label" parent="."] +margin_left = -92.0 +margin_top = -164.0 +margin_right = 133.0 +margin_bottom = 23.0 +rect_scale = Vector2( 0.75, 0.75 ) +custom_fonts/font = ExtResource( 2 ) +custom_colors/font_color = Color( 0, 0, 0, 1 ) +text = "Description" autowrap = true __meta__ = { "_edit_use_anchors_": false diff --git a/cardgame.gd b/cardgame.gd index e69e264..bce5bee 100644 --- a/cardgame.gd +++ b/cardgame.gd @@ -1,16 +1,15 @@ extends Node2D var cards = [ - {"command": 'git add .', "arg_number": 0}, - {"command": 'git checkout', "arg_number": 1}, - {"command": 'touch "file$RANDOM"', "arg_number": 0}, - {"command": 'git commit --allow-empty -m "$RANDOM"', "arg_number": 0}, - {"command": 'git checkout -b "$RANDOM"', "arg_number": 0}, - {"command": 'git merge', "arg_number": 1}, - {"command": 'git symbolic-ref HEAD', "arg_number": 1}, - {"command": 'git update-ref -d', "arg_number": 1}, - {"command": 'git reflog expire --expire=now --all; git prune', "arg_number": 0}, - {"command": 'git rebase', "arg_number": 1} + {"command": 'git add .', "arg_number": 0, "description": "Add all files in the working directory to the index."}, + {"command": 'git checkout', "arg_number": 1, "description": "Point HEAD to a branch or commit, and update the index and the working directory."}, + {"command": 'touch "file$RANDOM"', "arg_number": 0, "description": "Create a new file."}, + {"command": 'git commit --allow-empty -m "$RANDOM"', "arg_number": 0, "description": "Add a new commit under HEAD."}, + {"command": 'git checkout -b "$RANDOM"', "arg_number": 0, "description": "Create a new branch and switch to it."}, + {"command": 'git merge', "arg_number": 1, "description": "Merge specified commit into HEAD."}, + {"command": 'git update-ref -d', "arg_number": 1, "description": "Delete a ref."}, + {"command": 'git reflog expire --expire=now --all; git prune', "arg_number": 0, "description": "Delete all unreferenced objects."}, + {"command": 'git rebase', "arg_number": 1, "description": "Rebase current branch on top of specified commit."} ] func _ready(): @@ -40,6 +39,7 @@ func draw_rand_card(): var card = cards[randi() % cards.size()] new_card.command = card.command new_card.arg_number = card.arg_number + new_card.description = card.description add_child(new_card) arrange_cards() diff --git a/cardgame.tscn b/cardgame.tscn index e6f8169..a3389e7 100644 --- a/cardgame.tscn +++ b/cardgame.tscn @@ -1,5 +1,6 @@ -[gd_scene load_steps=5 format=2] +[gd_scene load_steps=6 format=2] +[ext_resource path="res://fonts/default.tres" type="DynamicFont" id=1] [ext_resource path="res://drop_area.tscn" type="PackedScene" id=2] [ext_resource path="res://repository.tscn" type="PackedScene" id=3] [ext_resource path="res://cardgame.gd" type="Script" id=4] @@ -31,10 +32,11 @@ margin_right = 1914.0 margin_bottom = 586.0 [node name="Button" type="Button" parent="."] -margin_left = 1726.67 -margin_top = 1021.41 -margin_right = 1899.67 -margin_bottom = 1063.41 +margin_left = 1719.41 +margin_top = 814.594 +margin_right = 1892.41 +margin_bottom = 856.594 +custom_fonts/font = ExtResource( 1 ) text = "redraw cards" __meta__ = { "_edit_use_anchors_": false