Card drag
This commit is contained in:
parent
621bcf75cb
commit
0418606bd8
11 changed files with 92 additions and 0 deletions
|
|
@ -10,3 +10,7 @@ class_name CardResource
|
||||||
@export var preview: Texture2D
|
@export var preview: Texture2D
|
||||||
@export var experimental: bool = false
|
@export var experimental: bool = false
|
||||||
@export var background: Texture2D = preload("uid://c6akwwb58fidc")
|
@export var background: Texture2D = preload("uid://c6akwwb58fidc")
|
||||||
|
|
||||||
|
@export_group("Reference")
|
||||||
|
@export var name_key: StringName
|
||||||
|
@export var description_key: StringName
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,38 @@ extends TextureRect
|
||||||
|
|
||||||
class_name Card
|
class_name Card
|
||||||
|
|
||||||
|
const PIXEL_PER_ROTATION: float = 32.
|
||||||
|
const ROTATION = PI/6.
|
||||||
|
|
||||||
@export var card_resource: CardResource
|
@export var card_resource: CardResource
|
||||||
|
var dragged: bool = false
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
$UnitPreview.texture = card_resource.preview
|
$UnitPreview.texture = card_resource.preview
|
||||||
texture = card_resource.background
|
texture = card_resource.background
|
||||||
$CostBubble/Cost.text = str(card_resource.cost)
|
$CostBubble/Cost.text = str(card_resource.cost)
|
||||||
$ExperimentalBadge.visible = card_resource.experimental
|
$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)
|
||||||
|
|
|
||||||
|
|
@ -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://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"]
|
[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]
|
[node name="Card" type="TextureRect" unique_id=267582807]
|
||||||
anchors_preset = -1
|
anchors_preset = -1
|
||||||
anchor_right = 0.098000005
|
anchor_right = 0.098000005
|
||||||
|
|
@ -66,3 +71,22 @@ offset_bottom = 33.0
|
||||||
grow_horizontal = 0
|
grow_horizontal = 0
|
||||||
mouse_filter = 2
|
mouse_filter = 2
|
||||||
texture = ExtResource("4_f61jr")
|
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
|
||||||
|
|
|
||||||
|
|
@ -7,4 +7,6 @@
|
||||||
[resource]
|
[resource]
|
||||||
script = ExtResource("2_61y7x")
|
script = ExtResource("2_61y7x")
|
||||||
preview = ExtResource("2_m3011")
|
preview = ExtResource("2_m3011")
|
||||||
|
name_key = &"doh"
|
||||||
|
description_key = &"doh_desc"
|
||||||
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,6 @@
|
||||||
script = ExtResource("2_r84ts")
|
script = ExtResource("2_r84ts")
|
||||||
cost = 1
|
cost = 1
|
||||||
preview = ExtResource("2_uc1ms")
|
preview = ExtResource("2_uc1ms")
|
||||||
|
name_key = &"fosma"
|
||||||
|
description_key = &"fosma_desc"
|
||||||
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,6 @@ script = ExtResource("2_ongak")
|
||||||
preview = ExtResource("2_xu3vf")
|
preview = ExtResource("2_xu3vf")
|
||||||
experimental = true
|
experimental = true
|
||||||
background = ExtResource("1_ongak")
|
background = ExtResource("1_ongak")
|
||||||
|
name_key = &"zlosma"
|
||||||
|
description_key = &"zlosma_desc"
|
||||||
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
metadata/_custom_type_script = "uid://bmc0rqt8jb8vh"
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@ run/main_scene="uid://bxt4kgs6px3t8"
|
||||||
config/features=PackedStringArray("4.6", "GL Compatibility")
|
config/features=PackedStringArray("4.6", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[internationalization]
|
||||||
|
|
||||||
|
locale/translations=PackedStringArray("res://translations/units.ru.translation", "res://translations/units.en.translation")
|
||||||
|
|
||||||
[physics]
|
[physics]
|
||||||
|
|
||||||
3d/physics_engine="Jolt Physics"
|
3d/physics_engine="Jolt Physics"
|
||||||
|
|
|
||||||
7
translations/units.csv
Normal file
7
translations/units.csv
Normal file
|
|
@ -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;Злосма — злой брат Фосмы
|
||||||
|
19
translations/units.csv.import
Normal file
19
translations/units.csv.import
Normal file
|
|
@ -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
|
||||||
BIN
translations/units.en.translation
Normal file
BIN
translations/units.en.translation
Normal file
Binary file not shown.
BIN
translations/units.ru.translation
Normal file
BIN
translations/units.ru.translation
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue