Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keyboard controls #3

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Assets/UI/TextBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Assets/UI/TextBox.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="StreamTexture"
path="res://.import/TextBox.png-2ad7bec0b4178924442104273f95e7b4.stex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Assets/UI/TextBox.png"
dest_files=[ "res://.import/TextBox.png-2ad7bec0b4178924442104273f95e7b4.stex" ]

[params]

compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
387 changes: 171 additions & 216 deletions Levels/ArenaManager.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Levels/ClassSelect.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ __meta__ = {

[node name="SelectPlayer" type="AudioStreamPlayer" parent="."]
stream = ExtResource( 10 )

[connection signal="mouse_entered" from="Classes/Basic" to="Players" method="_on_button_mouse_entered"]
[connection signal="pressed" from="Classes/Basic" to="Players" method="_on_Basic_pressed"]
[connection signal="mouse_entered" from="Classes/Archer" to="Players" method="_on_button_mouse_entered"]
Expand Down
100 changes: 47 additions & 53 deletions Levels/NavigationArena.tscn

Large diffs are not rendered by default.

86 changes: 0 additions & 86 deletions Levels/UI/Basic.tscn

This file was deleted.

111 changes: 68 additions & 43 deletions Levels/UI/MainUI.tscn
Original file line number Diff line number Diff line change
@@ -1,62 +1,87 @@
[gd_scene load_steps=7 format=2]

[ext_resource path="res://Assets/UI/End Move Button Pressed.png" type="Texture" id=1]
[ext_resource path="res://Assets/UI/End Move Button.png" type="Texture" id=2]
[ext_resource path="res://Assets/UI/Attack Button.png" type="Texture" id=3]
[ext_resource path="res://Assets/UI/Walk Button.png" type="Texture" id=4]
[ext_resource path="res://Assets/UI/Attack Button Pressed.png" type="Texture" id=5]
[ext_resource path="res://Assets/UI/Walk Button Pressedt.png" type="Texture" id=6]
[ext_resource path="res://Assets/UI/TextBox.png" type="Texture" id=1]
[ext_resource path="res://Assets/Jeebz-Regular.ttf" type="DynamicFontData" id=2]
[ext_resource path="res://Levels/UI/TextBox.cs" type="Script" id=3]
[ext_resource path="res://Levels/UI/TroopDisplayYellow.tscn" type="PackedScene" id=4]
[ext_resource path="res://Levels/UI/TroopDisplayRed.tscn" type="PackedScene" id=5]

[sub_resource type="DynamicFont" id=1]
size = 8
font_data = ExtResource( 2 )

[node name="Screen" type="Control"]
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = -0.314972
margin_top = 0.944946
margin_right = -0.314972
margin_bottom = 0.944946
script = ExtResource( 3 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Buttons" type="Control" parent="."]
margin_right = 40.0
margin_bottom = 40.0

[node name="Attack Button" type="TextureButton" parent="Buttons"]
margin_left = 1.444
margin_top = 136.318
margin_right = 33.444
margin_bottom = 168.318
disabled = true
texture_normal = ExtResource( 3 )
texture_pressed = ExtResource( 5 )
texture_disabled = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 49.7081, 153.013 )
texture = ExtResource( 1 )

[node name="Walk Button" type="TextureButton" parent="Buttons"]
margin_left = 30.5796
margin_top = 136.021
margin_right = 62.5796
margin_bottom = 168.021
disabled = true
texture_normal = ExtResource( 4 )
texture_pressed = ExtResource( 6 )
texture_disabled = ExtResource( 6 )
[node name="TextBox" type="Label" parent="."]
margin_left = 7.0079
margin_top = 157.176
margin_right = 99.0079
margin_bottom = 176.176
custom_fonts/font = SubResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}

[node name="End Button" type="TextureButton" parent="Buttons"]
margin_left = 61.2949
margin_top = 136.209
margin_right = 93.2949
margin_bottom = 168.209
disabled = true
texture_normal = ExtResource( 2 )
texture_pressed = ExtResource( 1 )
texture_disabled = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Yellow" type="Node2D" parent="."]

[node name="TroopDisplay" parent="Yellow" instance=ExtResource( 4 )]

[node name="TroopDisplay2" parent="Yellow" instance=ExtResource( 4 )]
margin_left = 56.2564
margin_top = 0.216707
margin_right = 56.2564
margin_bottom = 0.216707

[node name="TroopDisplay3" parent="Yellow" instance=ExtResource( 4 )]
margin_left = 0.172743
margin_top = 23.5213
margin_right = 0.172743
margin_bottom = 23.5213

[node name="TroopDisplay4" parent="Yellow" instance=ExtResource( 4 )]
margin_left = 55.7921
margin_top = 24.0142
margin_right = 55.7921
margin_bottom = 24.0142

[node name="Node2D" type="Node2D" parent="."]
position = Vector2( 304.108, -0.768139 )

[node name="TroopDisplay" parent="Node2D" instance=ExtResource( 5 )]
margin_left = -58.596
margin_top = -0.1982
margin_right = -58.596
margin_bottom = -0.1982

[node name="TroopDisplay2" parent="Node2D" instance=ExtResource( 5 )]
margin_left = -58.7944
margin_top = 24.2081
margin_right = -58.7944
margin_bottom = 24.2081

[node name="TroopDisplay3" parent="Node2D" instance=ExtResource( 5 )]
margin_left = -114.949
margin_top = 25.0018
margin_right = -114.949
margin_bottom = 25.0018

[node name="TroopDisplay4" parent="Node2D" instance=ExtResource( 5 )]
margin_left = -114.949
margin_top = 0.992348
margin_right = -114.949
margin_bottom = 0.992348
1 change: 0 additions & 1 deletion Levels/UI/RedDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public override void _Ready()

private void DisplayStats(int hp, int moves, string troop, string team)
{
Show();
if(team == "Red")
GetNode<Sprite>("Sprite").Texture = ResourceLoader.Load("res://Assets/UI/Red UI.png") as Texture;
else
Expand Down
42 changes: 42 additions & 0 deletions Levels/UI/TextBox.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using Godot;
using System;

public class TextBox : Control
{
[Signal] public delegate void Enter(string token1, string token2, string token3);
private Label _textBox;
public override void _Ready()
{
_textBox = GetNode<Label>("TextBox");
}

public override void _Input(InputEvent @event)
{
if(@event is InputEventKey eventKey && @event.IsPressed())
{
if(eventKey.IsActionPressed("ui_accept"))
{
string[] tokens = _textBox.Text.Split(' ');
if(tokens.Length == 2)
EmitSignal(nameof(Enter), tokens[0], tokens[1]);
else if (tokens.Length == 3)
EmitSignal(nameof(Enter), tokens[0], tokens[1], tokens[2]);

_textBox.Text = string.Empty;
}
else if (eventKey.IsActionPressed("backspace"))
{
if(_textBox.Text.Length > 0)
_textBox.Text = _textBox.Text.Remove(_textBox.Text.Length - 1);
}
else
{
_textBox.Text += (char)eventKey.Scancode;
_textBox.Text = _textBox.Text.ToLower();
}


}
}
}

Loading