From 413960ed70626575f85263d6134dd67e85884781 Mon Sep 17 00:00:00 2001 From: Ategon Date: Sat, 14 Sep 2024 22:20:30 -0400 Subject: [PATCH] Add text on hover --- BuildingLevel.gd | 36 ++++++++++++++++++++++++++++++++--- Main.tscn | 10 ++++++++++ NameIcon.tscn | 18 ++++++++++++++++++ TIleSet.tres | 44 ++++++++++++++++++++++++++++++++++++++++++- name_icon.gd | 25 ++++++++++++++++++++++++ tilerocks.png | Bin 0 -> 1486 bytes tilerocks.png.import | 34 +++++++++++++++++++++++++++++++++ tiletrees.png | Bin 0 -> 1056 bytes tiletrees.png.import | 34 +++++++++++++++++++++++++++++++++ 9 files changed, 197 insertions(+), 4 deletions(-) create mode 100644 NameIcon.tscn create mode 100644 name_icon.gd create mode 100644 tilerocks.png create mode 100644 tilerocks.png.import create mode 100644 tiletrees.png create mode 100644 tiletrees.png.import diff --git a/BuildingLevel.gd b/BuildingLevel.gd index 15b8228..6eb6ed1 100644 --- a/BuildingLevel.gd +++ b/BuildingLevel.gd @@ -1,28 +1,58 @@ extends TileMapLayer @export var building_spots: Array[Vector2i] +@export var tree_spots: Array[Vector2i] +@export var rock_spots: Array[Vector2i] var building_data = {} +var last_tile +var last_text +const NAME_ICON = preload("res://NameIcon.tscn") func _process(delta: float) -> void: var tile = local_to_map(get_global_mouse_position()) var building_mode = Persister.get_value("building_mode") for spot in building_spots: - if not building_data.has(spot): + if not building_data.has(spot) and not tree_spots.has(spot) and not rock_spots.has(spot): erase_cell(spot) + if last_tile != tile: + if last_text and is_instance_valid(last_text) and last_text.selected: + last_text._deselect() + + if not Persister.get_value("building_mode"): + if rock_spots.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]Rock" + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + elif tree_spots.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]Tree" + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + elif building_data.has(tile): + last_text = NAME_ICON.instantiate() + last_text.text = "[center]%s" % [Data.data.buildings[building_data[tile].key].name] + last_text.position = map_to_local(tile) + Vector2(-25, -10) + add_sibling(last_text) + + last_tile = tile + if not building_mode: return - if building_spots.has(tile): + if building_spots.has(tile) and not rock_spots.has(tile) and not tree_spots.has(tile): set_cell(tile, 0, Vector2i(0,0), 0) + + func place_building(): var tile = local_to_map(get_global_mouse_position()) - if building_spots.has(tile): + if building_spots.has(tile) and not building_data.has(tile) and not tree_spots.has(tile) and not rock_spots.has(tile): Persister.persist_data("building_mode", false) building_data[tile] = { "key": Persister.get_value("building_key"), diff --git a/Main.tscn b/Main.tscn index 96ff527..72daa4a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -93,9 +93,12 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel2" type="TileMapLayer" parent="Node2D/Level2"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAmAAQABQAAAAEAAAAqAAQABQAAAAAAAAApAAAABgABAAAAAAApAPz/BgAAAAEAAAAhAAMABQAAAAAAAAAiAAEABgAAAAAAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(33, 5), Vector2i(33, 4), Vector2i(33, 3), Vector2i(34, 4), Vector2i(34, 3), Vector2i(34, 2), Vector2i(34, 1), Vector2i(35, 3), Vector2i(35, 2), Vector2i(36, 3), Vector2i(36, 2), Vector2i(37, 3), Vector2i(38, 4), Vector2i(38, 3), Vector2i(39, 4), Vector2i(39, 3), Vector2i(39, 5), Vector2i(40, 5), Vector2i(40, 4), Vector2i(40, 3), Vector2i(40, 2), Vector2i(40, 1), Vector2i(41, 4), Vector2i(41, 3), Vector2i(41, 2), Vector2i(41, 1), Vector2i(41, 0), Vector2i(42, 4), Vector2i(42, 3), Vector2i(42, 2), Vector2i(42, 1), Vector2i(43, 2), Vector2i(43, 3), Vector2i(44, 3), Vector2i(41, -4), Vector2i(41, -5), Vector2i(42, -3), Vector2i(42, -4), Vector2i(42, -5), Vector2i(43, -5)]) +tree_spots = Array[Vector2i]([Vector2i(34, 1), Vector2i(41, 0), Vector2i(41, -4)]) +rock_spots = Array[Vector2i]([Vector2i(33, 3), Vector2i(38, 4), Vector2i(42, 4)]) [node name="UILevel2" type="TileMapLayer" parent="Node2D/Level2"] y_sort_enabled = true @@ -117,9 +120,12 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel3" type="TileMapLayer" parent="Node2D/Level3"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAnAPr/BgABAAEAAAAmAPv/BgACAAAAAAAnAPv/BgAAAAAAAAAkAPz/BgAAAAEAAAAlAAAABgACAAEAAAAnAP//BQABAAAAAAAlAAEABQABAAEAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(37, 0), Vector2i(38, 1), Vector2i(38, 0), Vector2i(36, -3), Vector2i(36, -4), Vector2i(37, -2), Vector2i(37, -3), Vector2i(37, -4), Vector2i(38, -1), Vector2i(38, -2), Vector2i(38, -3), Vector2i(38, -4), Vector2i(38, -5), Vector2i(39, -2), Vector2i(39, -1), Vector2i(39, -3), Vector2i(39, -4), Vector2i(39, -5), Vector2i(39, -6), Vector2i(40, -3), Vector2i(40, -4)]) +tree_spots = Array[Vector2i]([Vector2i(37, 0), Vector2i(36, -4), Vector2i(38, -5), Vector2i(39, -5), Vector2i(39, -6)]) +rock_spots = Array[Vector2i]([Vector2i(37, 1), Vector2i(39, -1)]) [node name="UILevel3" type="TileMapLayer" parent="Node2D/Level3"] y_sort_enabled = true @@ -141,9 +147,11 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel4" type="TileMapLayer" parent="Node2D/Level4"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAfAP3/BQACAAAAAAAlAPn/BQACAAEAAAAjAP7/BQACAAEAAAAfAAAABQACAAEAAAAhAPz/BQACAAAAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(31, -3), Vector2i(31, -2), Vector2i(31, -1), Vector2i(31, 0), Vector2i(32, -2), Vector2i(32, -3), Vector2i(32, -4), Vector2i(33, -3), Vector2i(33, -4), Vector2i(33, -5), Vector2i(33, -2), Vector2i(33, -1), Vector2i(34, -2), Vector2i(34, -3), Vector2i(34, -1), Vector2i(34, -4), Vector2i(34, -5), Vector2i(35, -6), Vector2i(35, -3), Vector2i(35, -2), Vector2i(35, -1), Vector2i(35, 0), Vector2i(36, -2), Vector2i(36, -6), Vector2i(36, -7), Vector2i(37, -7)]) +rock_spots = Array[Vector2i]([Vector2i(31, 0), Vector2i(31, -3), Vector2i(33, -4), Vector2i(35, -2), Vector2i(37, -7)]) [node name="UILevel4" type="TileMapLayer" parent="Node2D/Level4"] y_sort_enabled = true @@ -165,9 +173,11 @@ tile_set = ExtResource("2_68wnv") [node name="BuildingLevel5" type="TileMapLayer" parent="Node2D/Level5"] y_sort_enabled = true +tile_map_data = PackedByteArray("AAAgAPj/BQAEAAAAAAAfAPn/BQAEAAEAAAA=") tile_set = ExtResource("2_68wnv") script = ExtResource("5_3vufn") building_spots = Array[Vector2i]([Vector2i(30, -6), Vector2i(30, -5), Vector2i(31, -6), Vector2i(31, -7), Vector2i(32, -7), Vector2i(32, -8), Vector2i(33, -7), Vector2i(33, -8), Vector2i(34, -8)]) +rock_spots = Array[Vector2i]([Vector2i(31, -7), Vector2i(32, -8)]) [node name="UILevel5" type="TileMapLayer" parent="Node2D/Level5"] y_sort_enabled = true diff --git a/NameIcon.tscn b/NameIcon.tscn new file mode 100644 index 0000000..5aabe66 --- /dev/null +++ b/NameIcon.tscn @@ -0,0 +1,18 @@ +[gd_scene load_steps=3 format=3 uid="uid://vlp1qstcv4no"] + +[ext_resource type="Theme" uid="uid://d035h7upxrw3h" path="res://theme.tres" id="1_yw1uq"] +[ext_resource type="Script" path="res://name_icon.gd" id="2_tyt57"] + +[node name="NameIcon" type="RichTextLabel"] +z_index = 10 +clip_contents = false +offset_left = 280.0 +offset_top = 104.0 +offset_right = 332.0 +offset_bottom = 121.0 +pivot_offset = Vector2(25, 4) +theme = ExtResource("1_yw1uq") +theme_override_constants/outline_size = 3 +bbcode_enabled = true +text = "[center]Rock" +script = ExtResource("2_tyt57") diff --git a/TIleSet.tres b/TIleSet.tres index f9cbad4..08b3b92 100644 --- a/TIleSet.tres +++ b/TIleSet.tres @@ -1,10 +1,12 @@ -[gd_resource type="TileSet" load_steps=11 format=3 uid="uid://dhy53lakrlutm"] +[gd_resource type="TileSet" load_steps=15 format=3 uid="uid://dhy53lakrlutm"] [ext_resource type="Texture2D" uid="uid://bvn5lewpp7pmd" path="res://iso_tile.png" id="1_sa4j6"] [ext_resource type="Texture2D" uid="uid://bsrh0u02bckhy" path="res://iso_building.png" id="2_bubm3"] [ext_resource type="Texture2D" uid="uid://bdmao1k7ngu2m" path="res://basic_tiles.png" id="3_rchy6"] [ext_resource type="Texture2D" uid="uid://w1abxk1m0fae" path="res://tiles-v3.png" id="4_p6xw0"] [ext_resource type="Texture2D" uid="uid://cjfpd778ggjer" path="res://select.png" id="5_s3lj1"] +[ext_resource type="Texture2D" uid="uid://cvn1fg4v6kur3" path="res://tilerocks.png" id="6_f8tld"] +[ext_resource type="Texture2D" uid="uid://c43udkovhiiv8" path="res://tiletrees.png" id="7_grd50"] [sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_dxrqb"] texture = ExtResource("1_sa4j6") @@ -71,6 +73,44 @@ texture = ExtResource("5_s3lj1") 0:0/0 = 0 0:0/0/texture_origin = Vector2i(0, 4) +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_l16yl"] +texture = ExtResource("6_f8tld") +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 3) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 3) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 3) +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 3) +3:1/0 = 0 +3:1/0/texture_origin = Vector2i(0, 3) +4:1/0 = 0 +4:1/0/texture_origin = Vector2i(0, 3) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 3) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 3) +3:0/0 = 0 +3:0/0/texture_origin = Vector2i(0, 3) +4:0/0 = 0 +4:0/0/texture_origin = Vector2i(0, 3) + +[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_ffqbc"] +texture = ExtResource("7_grd50") +2:1/0 = 0 +2:1/0/texture_origin = Vector2i(0, 3) +1:1/0 = 0 +1:1/0/texture_origin = Vector2i(0, 3) +0:1/0 = 0 +0:1/0/texture_origin = Vector2i(0, 3) +0:0/0 = 0 +0:0/0/texture_origin = Vector2i(0, 3) +1:0/0 = 0 +1:0/0/texture_origin = Vector2i(0, 3) +2:0/0 = 0 +2:0/0/texture_origin = Vector2i(0, 3) + [resource] tile_shape = 1 tile_layout = 5 @@ -80,3 +120,5 @@ sources/1 = SubResource("TileSetAtlasSource_j7eew") sources/2 = SubResource("TileSetAtlasSource_w6tof") sources/3 = SubResource("TileSetAtlasSource_5o051") sources/4 = SubResource("TileSetAtlasSource_sneuq") +sources/5 = SubResource("TileSetAtlasSource_l16yl") +sources/6 = SubResource("TileSetAtlasSource_ffqbc") diff --git a/name_icon.gd b/name_icon.gd new file mode 100644 index 0000000..333c413 --- /dev/null +++ b/name_icon.gd @@ -0,0 +1,25 @@ +extends RichTextLabel + +var tween +var selected = true + +func _ready() -> void: + scale = Vector2.ZERO + tween = create_tween() + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_BACK) + tween.tween_property(self, "scale", Vector2.ONE, 0.25) + + +func _deselect() -> void: + selected = false + if tween: + tween.kill() + + tween = create_tween() + tween.set_ease(Tween.EASE_OUT) + tween.set_trans(Tween.TRANS_QUAD) + tween.tween_property(self, "scale", Vector2.ZERO, 0.25) + tween.tween_callback(func(): + queue_free() + ) diff --git a/tilerocks.png b/tiler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A*w6ThzvCB&T=SL35UK_`LEAAWSGcr1>BzvZaY-mFp=lEl~pO zZ9R>(cohJVNQBIg^k%-ia!Yd$oA>XI+VAba&8Ys~Zn4KMjXCS0fFHr9wwz<1>e-7Ob*RJ<-%; zC`4Ip<)pp>K(VJ1tq>FHELpCCq_F_Q-;2mnb^F%6Y~Q+<^13y;3QHzYc#zxyCL+zb zMD+i78<3QiEL0CQG{jY<9%?t3h@@XC%_~V&DsU_i)Ll$%W7Iy-NQknH>GAsL@%qTH zXDJ>~OJV7e>nKxXs>9(hG)ArUWh;GP*Qc82q2?Lrz4$|1+oQt!(5JtNOKnHVezIX# zB#%3zSIM&H8dmxsX?;LZSkJ(LBmOjL}NK}B}q~tIMM*W)CBn)tHw#(wA zFfMUDoi!7DXkj%1;NI9+oD)n&@8q;)8PeEDB$BY-&_pWQx;o-~pxzlc(A;gIfw=ds zbq4+`Pgdufr3uU3s1uX}G$K%wv3dV)F&7^QPsJ+0#=Jt)1)7-rKlulUqJX#vXrwRz o000hUSV?A0O#mtY000O800000007cclK=n!07*qoM6N<$g6FZhQ~&?~ literal 0 HcmV?d00001 diff --git a/tilerocks.png.import b/tilerocks.png.import new file mode 100644 index 0000000..f01027d --- /dev/null +++ b/tilerocks.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cvn1fg4v6kur3" +path="res://.godot/imported/tilerocks.png-063e8153e6858a592ae59551c57b5a24.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://tilerocks.png" +dest_files=["res://.godot/imported/tilerocks.png-063e8153e6858a592ae59551c57b5a24.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 diff --git a/tiletrees.png b/tiletrees.png new file mode 100644 index 0000000000000000000000000000000000000000..1643c11422b520317c55a3e72861217c4aa43714 GIT binary patch literal 1056 zcmV+*1mF9KP)Px&z)3_wR9J=Wm{CYnSs2HEH)0=Rh?dM)#&8Xs2ox#kK^9*|DC=Pgd?})&hbXd# zh&o}&o}4)o&R^fbI*L=z)uR{(N?UluZA_c1)m(+le@5pUp!EZ7|~PJUJTDOas!a! zEw*Lx+&x?CMU4Djil?=t$zm@~svhP5l=$0^hLuf<_Xx3=4ueU&gbYHH-MqfM%rggI z?6}pZ2Ind^s^`>flGJPx@Ro(ebeP8R7T#u(yv-yj@%>8cTo;<`I>O8Gvt*#Nrkvqt zaVpmPxG+7>;Q3k`VSh9RU^qElxBf4Bs@nO@w;6!B%mS??P3*YU$GiFW+}pj&RhUGx zFXTAal7Zu+2{kxZv5~sAnA-Wr@fpA|1ERmTn%Gbu{k_#H0|2R|1yV~3YU191AA|EI zh@Pr;#diuK_a!!tk0uyc`j|HZUQpjK#--oSsPXoatz6FhO;g=gy8oZ|BtDm$k7K(= zBf$Wb{!)ug?*3$AhRMVX(Z(%c-w~s}VN9#&`P>xEz7So5Q*;eZIUYa2XdG{`7~GDL z4Uu5LeC3H~;}-S7{dN#Xwrx=JntdVB>SFy z%9an2U?BT2@xcH{`vN1KmnDfCx1GlTL6Xj0*WUq&(50iLU@XwJ5D`3t@V>HfbV(j zi7Ut2v>Ia9_u1^)mQp&1Up%0yQ79}6@8;jD=K``I*XHETgOVe6AFu~uYbnhRr1;cq zlF7u37u^72x!z~^S==kfvbMy@od+?C2dF*z511+lOGA_E;O4z@z*>#wsYJCX+ng;S zrqdbO;W_b)Q`gP|@N_g=)pm?@v+0jZ0KA%<0_+*ctxd$0V{OX8;k^k<003uuUh8;@ zFLz&J@MU)43)Aj>!1A%Np<|?*BilB}V$$Nr>`?1K22s}*({Z#yWDrukL@_~hjC2DS zkzhdRia}cjK)pajACz%o*Hr*+xRkXzKbTF0000