mirror of
https://github.com/Ikatono/TierMaker.git
synced 2025-10-28 20:45:34 -05:00
misc updates, going to start over using controls
This commit is contained in:
BIN
.vs/ProjectEvaluation/tiermaker.metadata.v7.bin
Normal file
BIN
.vs/ProjectEvaluation/tiermaker.metadata.v7.bin
Normal file
Binary file not shown.
BIN
.vs/ProjectEvaluation/tiermaker.projects.v7.bin
Normal file
BIN
.vs/ProjectEvaluation/tiermaker.projects.v7.bin
Normal file
Binary file not shown.
BIN
.vs/TIERMAKER/DesignTimeBuild/.dtbcache.v2
Normal file
BIN
.vs/TIERMAKER/DesignTimeBuild/.dtbcache.v2
Normal file
Binary file not shown.
Binary file not shown.
BIN
.vs/TIERMAKER/v17/.futdcache.v2
Normal file
BIN
.vs/TIERMAKER/v17/.futdcache.v2
Normal file
Binary file not shown.
BIN
.vs/TIERMAKER/v17/.suo
Normal file
BIN
.vs/TIERMAKER/v17/.suo
Normal file
Binary file not shown.
37
.vs/TIERMAKER/v17/DocumentLayout.json
Normal file
37
.vs/TIERMAKER/v17/DocumentLayout.json
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"Version": 1,
|
||||||
|
"WorkspaceRootPath": "C:\\Users\\Cameron\\Godot\\TierMaker\\",
|
||||||
|
"Documents": [
|
||||||
|
{
|
||||||
|
"AbsoluteMoniker": "D:0:0:{08AED6D9-4B08-4196-8211-B04CD7ED8440}|TierMaker.csproj|c:\\users\\cameron\\godot\\tiermaker\\cardsprite.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
|
||||||
|
"RelativeMoniker": "D:0:0:{08AED6D9-4B08-4196-8211-B04CD7ED8440}|TierMaker.csproj|solutionrelative:cardsprite.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"DocumentGroupContainers": [
|
||||||
|
{
|
||||||
|
"Orientation": 0,
|
||||||
|
"VerticalTabListWidth": 256,
|
||||||
|
"DocumentGroups": [
|
||||||
|
{
|
||||||
|
"DockedWidth": 193,
|
||||||
|
"SelectedChildIndex": 0,
|
||||||
|
"Children": [
|
||||||
|
{
|
||||||
|
"$type": "Document",
|
||||||
|
"DocumentIndex": 0,
|
||||||
|
"Title": "CardSprite.cs",
|
||||||
|
"DocumentMoniker": "C:\\Users\\Cameron\\Godot\\TierMaker\\CardSprite.cs",
|
||||||
|
"RelativeDocumentMoniker": "CardSprite.cs",
|
||||||
|
"ToolTip": "C:\\Users\\Cameron\\Godot\\TierMaker\\CardSprite.cs",
|
||||||
|
"RelativeToolTip": "CardSprite.cs",
|
||||||
|
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
||||||
|
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
|
||||||
|
"WhenOpened": "2024-04-14T23:28:03.053Z",
|
||||||
|
"EditorCaption": ""
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
23
CardShape.cs
Normal file
23
CardShape.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class CardShape : CollisionShape2D, IUsesCardSize
|
||||||
|
{
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateCardSize(Vector2 size)
|
||||||
|
{
|
||||||
|
Shape = new RectangleShape2D
|
||||||
|
{
|
||||||
|
Size = size
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
24
CardSprite.cs
Normal file
24
CardSprite.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class CardSprite : Sprite2D, IUsesCardSize
|
||||||
|
{
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
//set scale for default color
|
||||||
|
// if (GetParent<CardCollisionShape2D>()?.Shape is RectangleShape2D rect)
|
||||||
|
// Scale = rect.Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateCardSize(Vector2 size)
|
||||||
|
{
|
||||||
|
var s = Texture.GetSize();
|
||||||
|
Scale = new Vector2(size.X / s.X, size.Y / s.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Extensions.cs
Normal file
55
Extensions.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Godot;
|
||||||
|
|
||||||
|
public static class ExtensionHelper
|
||||||
|
{
|
||||||
|
public static Card GetCardWithId(this SceneTree tree, string id)
|
||||||
|
{
|
||||||
|
const string CardGroup = "Card";
|
||||||
|
var cards = tree.GetNodesInGroup(CardGroup);
|
||||||
|
foreach (var card in cards)
|
||||||
|
{
|
||||||
|
if (card is Card c)
|
||||||
|
{
|
||||||
|
if (c.Id == id)
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new System.Exception($"Node in group {CardGroup} is not of type {nameof(Card)}");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static Row GetRowWithId(this SceneTree tree, string id)
|
||||||
|
{
|
||||||
|
const string RowGroup = "Card";
|
||||||
|
var rows = tree.GetNodesInGroup(RowGroup);
|
||||||
|
foreach (var row in rows)
|
||||||
|
{
|
||||||
|
if (row is Row r)
|
||||||
|
{
|
||||||
|
if (r.Id == id)
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw new System.Exception($"Node in group {RowGroup} is not of type {nameof(Row)}");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public static IEnumerable<Node> GetAllDescendents(this Node node, bool includeInternal = false)
|
||||||
|
{
|
||||||
|
foreach (Node n in node.GetChildren(includeInternal))
|
||||||
|
{
|
||||||
|
yield return n;
|
||||||
|
foreach (Node c in n.GetAllDescendents())
|
||||||
|
yield return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// gets all descendents of a given type (in undefined order)
|
||||||
|
public static IEnumerable<T> GetAllDescendents<T>(this Node node,
|
||||||
|
bool includeInternal = false)
|
||||||
|
{
|
||||||
|
foreach (var n in node.GetAllDescendents(includeInternal))
|
||||||
|
if (n is T t)
|
||||||
|
yield return t;
|
||||||
|
}
|
||||||
|
}
|
||||||
26
IdLabel.cs
Normal file
26
IdLabel.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class IdLabel : Label, IUsesCardId, IUsesCardSize
|
||||||
|
{
|
||||||
|
// Called when the node enters the scene tree for the first time.
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
public override void _Process(double delta)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
public void UpdateCardId(string id)
|
||||||
|
{
|
||||||
|
Text = id;
|
||||||
|
}
|
||||||
|
//doesn't resize, but realigns
|
||||||
|
public void UpdateCardSize(Vector2 size)
|
||||||
|
{
|
||||||
|
var parentBottomLeft = new Vector2(-size.X, size.Y) / 2;
|
||||||
|
var thisBottomLeft = new Vector2(0, Size.Y);
|
||||||
|
Position = parentBottomLeft - thisBottomLeft;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class CardCollisionShape2D : CollisionShape2D
|
public partial class Row : Area2D
|
||||||
{
|
{
|
||||||
private Vector2 MouseOffset { get; set; }
|
[Export]
|
||||||
|
public string Id { get; set; }
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
BIN
Sprites/SingleWhitePixel.png
Normal file
BIN
Sprites/SingleWhitePixel.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 119 B |
34
Sprites/SingleWhitePixel.png.import
Normal file
34
Sprites/SingleWhitePixel.png.import
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://b8acjd4lvei07"
|
||||||
|
path="res://.godot/imported/SingleWhitePixel.png-24ae9a98b3e2a24518720903e0c57636.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://Sprites/SingleWhitePixel.png"
|
||||||
|
dest_files=["res://.godot/imported/SingleWhitePixel.png-24ae9a98b3e2a24518720903e0c57636.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
52
card.cs
52
card.cs
@@ -1,23 +1,61 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Drawing;
|
||||||
|
|
||||||
public partial class card : Area2D
|
public partial class Card : Area2D
|
||||||
{
|
{
|
||||||
private Vector2 MouseOffset { get; set; }
|
private Vector2 MouseOffset { get; set; }
|
||||||
|
public Vector2 _Size;
|
||||||
|
[Export]
|
||||||
|
public Vector2 Size
|
||||||
|
{
|
||||||
|
get => _Size;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_Size = value;
|
||||||
|
UpdateChildrenSize(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public CollisionShape2D CollisionObject
|
||||||
|
=> GetNode<CollisionShape2D>("CollisionShape2D");
|
||||||
|
public string _Id;
|
||||||
|
[Export]
|
||||||
|
public string Id
|
||||||
|
{
|
||||||
|
get => _Id;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_Id = value;
|
||||||
|
UpdateChildrenId(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
protected void UpdateChildrenId(string id)
|
||||||
|
{
|
||||||
|
foreach (var child in this.GetAllDescendents<IUsesCardId>())
|
||||||
|
child.UpdateCardId(id);
|
||||||
|
}
|
||||||
|
protected void UpdateChildrenSize(Vector2 size)
|
||||||
|
{
|
||||||
|
foreach (var child in this.GetAllDescendents<IUsesCardSize>())
|
||||||
|
child.UpdateCardSize(size);
|
||||||
|
}
|
||||||
|
//private Theme CardTheme = GD.Load<Theme>("res://card_theme.tres");
|
||||||
// Called when the node enters the scene tree for the first time.
|
// Called when the node enters the scene tree for the first time.
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
InputPickable = true;
|
InputPickable = true;
|
||||||
//TODO worry about dragging later, websocket control is more important
|
//TODO worry about dragging later, websocket control is more important
|
||||||
//InputEvent += MouseClick;
|
//InputEvent += MouseClick;
|
||||||
|
UpdateChildrenId(_Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MouseClick(Node viewport, InputEvent @event, long shapeIdx)
|
private static void MouseClick(Node viewport, InputEvent @event, long shapeIdx)
|
||||||
{
|
{
|
||||||
if (@event is InputEventMouse mouseEvent)
|
if (@event is InputEventMouse mouseEvent)
|
||||||
{
|
{
|
||||||
@@ -32,3 +70,13 @@ public partial class card : Area2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public interface IUsesCardId
|
||||||
|
{
|
||||||
|
public void UpdateCardId(string id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IUsesCardSize
|
||||||
|
{
|
||||||
|
public void UpdateCardSize(Vector2 size);
|
||||||
|
}
|
||||||
37
card.tscn
37
card.tscn
@@ -1,10 +1,39 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://bcmgf041scwb4"]
|
[gd_scene load_steps=8 format=3 uid="uid://bcmgf041scwb4"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Card.cs" id="1_sy5mp"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://b8acjd4lvei07" path="res://Sprites/SingleWhitePixel.png" id="2_v2iad"]
|
||||||
|
[ext_resource type="Script" path="res://CardShape.cs" id="2_w7o1r"]
|
||||||
|
[ext_resource type="Script" path="res://CardSprite.cs" id="3_0aoyx"]
|
||||||
|
[ext_resource type="Script" path="res://IdLabel.cs" id="4_0khjp"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_25ape"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_25ape"]
|
||||||
|
size = Vector2(1, 1)
|
||||||
|
|
||||||
[node name="Card" type="Area2D"]
|
[sub_resource type="LabelSettings" id="LabelSettings_vre1j"]
|
||||||
|
outline_size = 1
|
||||||
|
outline_color = Color(0, 0, 0, 1)
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="Card" type="Area2D" groups=["Card"]]
|
||||||
|
script = ExtResource("1_sy5mp")
|
||||||
|
Size = Vector2(150, 150)
|
||||||
|
|
||||||
|
[node name="CardShape" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_25ape")
|
shape = SubResource("RectangleShape2D_25ape")
|
||||||
|
script = ExtResource("2_w7o1r")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="IdLabel" type="Label" parent="CardShape"]
|
||||||
|
anchors_preset = 2
|
||||||
|
anchor_top = 1.0
|
||||||
|
anchor_bottom = 1.0
|
||||||
|
offset_top = -23.0
|
||||||
|
offset_right = 40.0
|
||||||
|
grow_vertical = 0
|
||||||
|
text = "A1"
|
||||||
|
label_settings = SubResource("LabelSettings_vre1j")
|
||||||
|
vertical_alignment = 2
|
||||||
|
script = ExtResource("4_0khjp")
|
||||||
|
|
||||||
|
[node name="CardSprite" type="Sprite2D" parent="CardShape"]
|
||||||
|
modulate = Color(0.721569, 0, 0.572549, 1)
|
||||||
|
texture = ExtResource("2_v2iad")
|
||||||
|
script = ExtResource("3_0aoyx")
|
||||||
|
|||||||
3
card_theme.tres
Normal file
3
card_theme.tres
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
[gd_resource type="Theme" format=3 uid="uid://dhyp0ou15akxv"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
@@ -11,7 +11,7 @@ config_version=5
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="TierMaker"
|
config/name="TierMaker"
|
||||||
config/features=PackedStringArray("4.2", "Forward Plus")
|
config/features=PackedStringArray("4.2", "C#", "Forward Plus")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
[dotnet]
|
[dotnet]
|
||||||
|
|||||||
7
row.tscn
7
row.tscn
@@ -1,8 +1,11 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://d4j824viqwho2"]
|
[gd_scene load_steps=3 format=3 uid="uid://d4j824viqwho2"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" path="res://Row.cs" id="1_lr7oy"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_n14fa"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_n14fa"]
|
||||||
|
|
||||||
[node name="Row" type="Area2D"]
|
[node name="Row" type="Area2D" groups=["Row"]]
|
||||||
|
script = ExtResource("1_lr7oy")
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_n14fa")
|
shape = SubResource("RectangleShape2D_n14fa")
|
||||||
|
|||||||
Reference in New Issue
Block a user