Доработка. Настройки - копировать/вставлять/выделять в редактируемых полях. Работа - вывод текущих координат и масштаба цифрами, показ значком коробля текущие координаты коробля на карте, показ значком дрона текущие цели(угрозы)
This commit is contained in:
BIN
scenes/tilemap/ship.png
Normal file
BIN
scenes/tilemap/ship.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
34
scenes/tilemap/ship.png.import
Normal file
34
scenes/tilemap/ship.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bry3qqgbuvpdt"
|
||||
path="res://.godot/imported/ship.png-1e5b46229cc4c1adf618fcb5da01fb4c.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship.png"
|
||||
dest_files=["res://.godot/imported/ship.png-1e5b46229cc4c1adf618fcb5da01fb4c.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
|
||||
BIN
scenes/tilemap/ship1.png
Normal file
BIN
scenes/tilemap/ship1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
34
scenes/tilemap/ship1.png.import
Normal file
34
scenes/tilemap/ship1.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://dct2op842kyxo"
|
||||
path="res://.godot/imported/ship1.png-fb0d0fe319583fdccb34710f90651bfb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship1.png"
|
||||
dest_files=["res://.godot/imported/ship1.png-fb0d0fe319583fdccb34710f90651bfb.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
|
||||
BIN
scenes/tilemap/ship2.png
Normal file
BIN
scenes/tilemap/ship2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
34
scenes/tilemap/ship2.png.import
Normal file
34
scenes/tilemap/ship2.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b3i0dm4vk3fvu"
|
||||
path="res://.godot/imported/ship2.png-dfba13504c314fdc4446dacd0ce91bc5.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/ship2.png"
|
||||
dest_files=["res://.godot/imported/ship2.png-dfba13504c314fdc4446dacd0ce91bc5.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
|
||||
8
scenes/tilemap/ship_mark.tscn
Normal file
8
scenes/tilemap/ship_mark.tscn
Normal file
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c2523fcn14gn4"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b3i0dm4vk3fvu" path="res://scenes/tilemap/ship2.png" id="1_o15fj"]
|
||||
|
||||
[node name="Ship_mark" type="Sprite2D"]
|
||||
position = Vector2(2.38419e-07, -1.19209e-07)
|
||||
scale = Vector2(0.496428, 0.496429)
|
||||
texture = ExtResource("1_o15fj")
|
||||
BIN
scenes/tilemap/threat.png
Normal file
BIN
scenes/tilemap/threat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
34
scenes/tilemap/threat.png.import
Normal file
34
scenes/tilemap/threat.png.import
Normal file
@@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://mobingoxskg1"
|
||||
path="res://.godot/imported/threat.png-602b9c318dc5f1342d23490e047ca526.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/tilemap/threat.png"
|
||||
dest_files=["res://.godot/imported/threat.png-602b9c318dc5f1342d23490e047ca526.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
|
||||
9
scenes/tilemap/threat.tscn
Normal file
9
scenes/tilemap/threat.tscn
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cv342kc1jj5hb"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://mobingoxskg1" path="res://scenes/tilemap/threat.png" id="1_pvxsy"]
|
||||
|
||||
[node name="Threat" type="Node2D"]
|
||||
|
||||
[node name="Threat" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.171358, 0.171358)
|
||||
texture = ExtResource("1_pvxsy")
|
||||
@@ -22,10 +22,17 @@ class_name MercatorTileMap
|
||||
@export_range(0, 20, 1) var min_zoom_level: int = 0
|
||||
@export_range(0, 20, 1) var max_zoom_level_server: int = 20
|
||||
@export_color_no_alpha() var back_color: = Color.BLACK
|
||||
@onready var scale_label: String
|
||||
@onready var coordinates_label: String
|
||||
@onready var threat_mark: PackedScene = load("res://scenes/tilemap/threat.tscn")
|
||||
@onready var ship_mark: PackedScene = load("res://scenes/tilemap/ship_mark.tscn")
|
||||
var ship_id := 9999
|
||||
var ship_instance: Node2D = null
|
||||
const default_size: = 400.0
|
||||
var is_centered: = false
|
||||
var is_out_border1: = true
|
||||
var is_out_border2: = true
|
||||
var threat_markers := {}
|
||||
|
||||
@export var animation_time: float = 0.1:
|
||||
set(val):
|
||||
@@ -94,6 +101,7 @@ signal map_server_online()
|
||||
## Вызывается при отсутствии ответа от сервера карт
|
||||
signal map_server_offline()
|
||||
|
||||
|
||||
const image_load_proc_names = {
|
||||
'png': 'load_png_from_buffer',
|
||||
'jpg': 'load_jpg_from_buffer',
|
||||
@@ -131,6 +139,9 @@ func _ready() -> void:
|
||||
var unit_nav = network.units[key]
|
||||
unit_nav.connect('data_received', on_data_received)
|
||||
ProjectSettings.connect('settings_changed', _settings_changed)
|
||||
threats.connect('threat_new', Callable(self, '_on_threat_new'))
|
||||
threats.connect('threat_lost', Callable(self, '_on_threat_lost'))
|
||||
threats.connect('threat_update', Callable(self, '_on_threat_update'))
|
||||
|
||||
|
||||
func _settings_changed():
|
||||
@@ -150,7 +161,7 @@ func _on_resize() -> void:
|
||||
$canvas/spr_mask.scale = $canvas.size / default_size
|
||||
|
||||
|
||||
## Создаёт новую отметку из координат экрана
|
||||
## Создаёт новую отметку из координат экранаa
|
||||
func add_mark_from_screen_pos(id: int, scr_xy: Vector2, mark: Node) -> bool:
|
||||
if _marks.has(id):
|
||||
return false
|
||||
@@ -238,6 +249,7 @@ func _input(e) -> void:
|
||||
func multiply_zoom(multiplier: float, pivot: Vector2) -> void:
|
||||
var p1: = screen_to_world(_xyz, pivot)
|
||||
_xyz.z = clampf(_xyz.z * multiplier, min_zoom_level, max_zoom_level)
|
||||
update_scale_label()
|
||||
var p2: = screen_to_world(_xyz, pivot)
|
||||
_xyz.x -= p2.x - p1.x
|
||||
_xyz.y -= p2.y - p1.y
|
||||
@@ -279,6 +291,7 @@ func _draw() -> void:
|
||||
var scr_pos = world_to_screen(dot.position)
|
||||
scr_pos.x = posmod(scr_pos.x, dx)
|
||||
dot.mark.position = scr_pos
|
||||
dot.mark.visible = is_mark_visible(dot)
|
||||
dot.mark.visible = c.distance_to(scr_pos) < (r - dot.gap_size)
|
||||
visible_marks_count += int(dot.mark.visible)
|
||||
# Рисование границ
|
||||
@@ -349,6 +362,8 @@ func _process(delta) -> void:
|
||||
push_error('запрос \"%s\" не отправлен' % tile.url)
|
||||
if _queue.is_empty():
|
||||
emit_signal('load_completed')
|
||||
|
||||
update_scale_label()
|
||||
|
||||
|
||||
func _response(result, code, _headers: Array, body: PackedByteArray, req, tile: Tile) -> void:
|
||||
@@ -552,8 +567,9 @@ func get_tile(x: int, y: int, z: int) -> Tile:
|
||||
var req = get_node_or_null(NodePath(str(idx)))
|
||||
if req:
|
||||
tile = req.get_meta('tile')
|
||||
tile.t = now
|
||||
return tile
|
||||
if tile != null:
|
||||
tile.t = now
|
||||
return tile
|
||||
|
||||
tile = _cache.get(idx)
|
||||
if tile:
|
||||
@@ -670,8 +686,49 @@ func set_coordinates(lon: float, lat: float) -> void:
|
||||
anim.track_insert_key(0, animation_time, new_pos.x)
|
||||
anim.track_insert_key(1, animation_time, new_pos.y)
|
||||
$player.play('goto')
|
||||
update_coordinates_label(lon, lat)
|
||||
if not _marks.has(ship_id):
|
||||
ship_instance = ship_mark.instantiate()
|
||||
add_mark_from_lon_lat(ship_id, lon, lat, ship_instance, 0.0)
|
||||
else:
|
||||
_marks[ship_id].position = lonlat_to_world(lon, lat)
|
||||
|
||||
|
||||
func blend_mask(val: bool) -> void:
|
||||
$canvas/spr_mask.visible = val
|
||||
queue_redraw()
|
||||
|
||||
|
||||
func update_coordinates_label(lon: float, lat: float) -> void:
|
||||
coordinates_label = "Координаты:\nNS:%f\nEW: %f" % [lat, lon]
|
||||
signaller.emit_signal('update_coordinates_map', coordinates_label)
|
||||
|
||||
|
||||
func update_scale_label() -> void:
|
||||
scale_label = "Масштаб: " + str(round(_xyz.z))
|
||||
signaller.emit_signal('update_scale_map', scale_label)
|
||||
|
||||
|
||||
func _on_threat_new(th) -> void:
|
||||
var bip_instance = threat_mark.instantiate()
|
||||
if bip_instance:
|
||||
bip_instance.name = str(th.id)
|
||||
bip_instance.position = lonlat_to_world(th.lon, th.lat)
|
||||
add_mark_from_lon_lat(th.id, th.lon, th.lat, bip_instance, 32)
|
||||
|
||||
|
||||
func _on_threat_update(th) -> void:
|
||||
var target = get_parent().get_node(str(th.id))
|
||||
if not target:
|
||||
return
|
||||
var new_position = lonlat_to_world(th.lon, th.lat)
|
||||
if _marks.has(th.id):
|
||||
_marks[th.id].position = new_position
|
||||
if new_position != target.position:
|
||||
target.position = new_position
|
||||
|
||||
|
||||
func _on_threat_lost(th) -> void:
|
||||
var target = get_parent().get_node(str(th.id))
|
||||
if target:
|
||||
target.queue_free()
|
||||
|
||||
@@ -28,8 +28,6 @@ size = Vector2(400, 400)
|
||||
|
||||
[node name="tilemap" type="CanvasGroup" groups=["gui_items"]]
|
||||
script = ExtResource("1_l64tp")
|
||||
border_scene = "uid://bumg0moa26skt"
|
||||
zoom_step = 0.1
|
||||
|
||||
[node name="canvas" type="TextureRect" parent="." groups=["gui_items"]]
|
||||
clip_contents = true
|
||||
|
||||
Reference in New Issue
Block a user