From 0418606bd8f44d55dc99a324d5dd81a9089ebba1 Mon Sep 17 00:00:00 2001 From: rendo Date: Thu, 19 Feb 2026 11:03:29 +0500 Subject: [PATCH] Card drag --- cards/card-resource.gd | 4 ++++ cards/card.gd | 28 ++++++++++++++++++++++++++++ cards/card.tscn | 24 ++++++++++++++++++++++++ cards/resources/doh.tres | 2 ++ cards/resources/fosma.tres | 2 ++ cards/resources/zlosma.tres | 2 ++ project.godot | 4 ++++ translations/units.csv | 7 +++++++ translations/units.csv.import | 19 +++++++++++++++++++ translations/units.en.translation | Bin 0 -> 644 bytes translations/units.ru.translation | Bin 0 -> 775 bytes 11 files changed, 92 insertions(+) create mode 100644 translations/units.csv create mode 100644 translations/units.csv.import create mode 100644 translations/units.en.translation create mode 100644 translations/units.ru.translation diff --git a/cards/card-resource.gd b/cards/card-resource.gd index 7f0e684..d1da5cd 100644 --- a/cards/card-resource.gd +++ b/cards/card-resource.gd @@ -10,3 +10,7 @@ class_name CardResource @export var preview: Texture2D @export var experimental: bool = false @export var background: Texture2D = preload("uid://c6akwwb58fidc") + +@export_group("Reference") +@export var name_key: StringName +@export var description_key: StringName diff --git a/cards/card.gd b/cards/card.gd index 9c5a50b..7bae5c2 100644 --- a/cards/card.gd +++ b/cards/card.gd @@ -2,10 +2,38 @@ extends TextureRect class_name Card +const PIXEL_PER_ROTATION: float = 32. +const ROTATION = PI/6. + @export var card_resource: CardResource +var dragged: bool = false func _ready() -> void: $UnitPreview.texture = card_resource.preview texture = card_resource.background $CostBubble/Cost.text = str(card_resource.cost) $ExperimentalBadge.visible = card_resource.experimental + $Name.text = tr(card_resource.name_key) + $Description.text = tr(card_resource.description_key) + +func _gui_input(event: InputEvent) -> void: + if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed: + dragged = true + top_level = true + accept_event() + +func _input(event: InputEvent) -> void: + if dragged and event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and not event.pressed: + dragged = false + top_level = false + accept_event() + +func _process(_delta: float) -> void: + if not dragged: + rotation = lerp(rotation,0.,0.25) + return + + var mouse_pos = get_global_mouse_position()-get_combined_pivot_offset() + position = lerp(position,mouse_pos,0.25) + var relative_x = mouse_pos.x - position.x + rotation = lerp(rotation,clamp(relative_x/PIXEL_PER_ROTATION*ROTATION,-ROTATION,ROTATION),0.25) diff --git a/cards/card.tscn b/cards/card.tscn index 063b938..2cc9690 100644 --- a/cards/card.tscn +++ b/cards/card.tscn @@ -6,6 +6,11 @@ [ext_resource type="Texture2D" uid="uid://c3p3hl0epd5rg" path="res://cards/templates/cost-bubble.png" id="3_4k7q8"] [ext_resource type="Texture2D" uid="uid://b5vvxpoic7glj" path="res://cards/templates/experimental.png" id="4_f61jr"] +[sub_resource type="LabelSettings" id="LabelSettings_jsqqk"] +line_spacing = 1.0 +font_size = 12 +font_color = Color(0, 0, 0, 1) + [node name="Card" type="TextureRect" unique_id=267582807] anchors_preset = -1 anchor_right = 0.098000005 @@ -66,3 +71,22 @@ offset_bottom = 33.0 grow_horizontal = 0 mouse_filter = 2 texture = ExtResource("4_f61jr") + +[node name="Name" type="Label" parent="." unique_id=1153228998] +layout_mode = 0 +offset_left = 12.0 +offset_top = 82.0 +offset_right = 104.0 +offset_bottom = 105.0 +label_settings = SubResource("LabelSettings_jsqqk") +horizontal_alignment = 1 + +[node name="Description" type="Label" parent="." unique_id=364325297] +layout_mode = 0 +offset_left = 12.0 +offset_top = 99.0 +offset_right = 104.0 +offset_bottom = 163.0 +label_settings = SubResource("LabelSettings_jsqqk") +autowrap_mode = 2 +text_overrun_behavior = 4 diff --git a/cards/resources/doh.tres b/cards/resources/doh.tres index 4d65b32..5764db1 100644 --- a/cards/resources/doh.tres +++ b/cards/resources/doh.tres @@ -7,4 +7,6 @@ [resource] script = ExtResource("2_61y7x") preview = ExtResource("2_m3011") +name_key = &"doh" +description_key = &"doh_desc" metadata/_custom_type_script = "uid://bmc0rqt8jb8vh" diff --git a/cards/resources/fosma.tres b/cards/resources/fosma.tres index fafff32..c92033b 100644 --- a/cards/resources/fosma.tres +++ b/cards/resources/fosma.tres @@ -8,4 +8,6 @@ script = ExtResource("2_r84ts") cost = 1 preview = ExtResource("2_uc1ms") +name_key = &"fosma" +description_key = &"fosma_desc" metadata/_custom_type_script = "uid://bmc0rqt8jb8vh" diff --git a/cards/resources/zlosma.tres b/cards/resources/zlosma.tres index d4d5956..f625633 100644 --- a/cards/resources/zlosma.tres +++ b/cards/resources/zlosma.tres @@ -9,4 +9,6 @@ script = ExtResource("2_ongak") preview = ExtResource("2_xu3vf") experimental = true background = ExtResource("1_ongak") +name_key = &"zlosma" +description_key = &"zlosma_desc" metadata/_custom_type_script = "uid://bmc0rqt8jb8vh" diff --git a/project.godot b/project.godot index 7bd516c..e9f75fe 100644 --- a/project.godot +++ b/project.godot @@ -15,6 +15,10 @@ run/main_scene="uid://bxt4kgs6px3t8" config/features=PackedStringArray("4.6", "GL Compatibility") config/icon="res://icon.svg" +[internationalization] + +locale/translations=PackedStringArray("res://translations/units.ru.translation", "res://translations/units.en.translation") + [physics] 3d/physics_engine="Jolt Physics" diff --git a/translations/units.csv b/translations/units.csv new file mode 100644 index 0000000..9e2c50d --- /dev/null +++ b/translations/units.csv @@ -0,0 +1,7 @@ +key;en;ru +fosma;Fosma;Фосма +fosma_desc;Fosma is a brave Pelkut warrior;Фосма — это храбрый Пелкутский воин +doh;Doh;Дох +doh_desc;Doh is a mighty Projog mage;Дох — это великий Прожоговый борец +zlosma;Zlosma;Злосма +zlosma_desc;Zlosma is an evil Fosma brother;Злосма — злой брат Фосмы diff --git a/translations/units.csv.import b/translations/units.csv.import new file mode 100644 index 0000000..7d26b81 --- /dev/null +++ b/translations/units.csv.import @@ -0,0 +1,19 @@ +[remap] + +importer="csv_translation" +type="Translation" +uid="uid://dpyvh0nj18jvu" + +[deps] + +files=["res://translations/units.en.translation", "res://translations/units.ru.translation"] + +source_file="res://translations/units.csv" +dest_files=["res://translations/units.en.translation", "res://translations/units.ru.translation"] + +[params] + +compress=1 +delimiter=1 +unescape_keys=false +unescape_translations=true diff --git a/translations/units.en.translation b/translations/units.en.translation new file mode 100644 index 0000000000000000000000000000000000000000..7170bd9e88700258fb04e44169b5b1c65ae49038 GIT binary patch literal 644 zcma))Jxc>Y5QZm-`B0;vVzf|HeAH7b&KyeIx67{)!bh+vZY!eE-k4c*c_u1SMA495F&j&3uc3Y$r( z*O`PkE;@JK4L z38_zmiJs=F6lnr){s2?h=3fx>d+V$mqTqv%_vU-=do%N9xAd+wE37?&@3VLYKbNFI zHCUD9dF4eq^wJ=XY^e|r5&a)*O;2u$iEHv6K|g9<07~jOQ@(V=*!My=ja}`_NQ$BE zT;x@yU`17G?JY?y9%GR!q6(lK0AszsuK)%QH`1oxzaD&LNOo&;oh21%-UL<);g;!Y~I-vMS zY!`PJKf~aSJl~gj2Y3na_KcBaD&ZURJ2DFX@7bSWEc0n_zQ^XiE&MxwgP2Fj_^_~j z`W}A9qR{Vby?y-|+?WN|z5;#&^p!ehjZUc56*_0Nrei*tI&~bgZfew`JySCcI&x^2 z4(OQL=A)@Y*QP@z_o;*6m!KxPty|aK1r;niECjn~+Myr7cVPdj^&Z4EIxri8zM$Bi cD{n(Tnc%H(5NesaQyknh1b+p5*Ajk#OG7vYj{pDw literal 0 HcmV?d00001