126 lines
4.0 KiB
GDScript
126 lines
4.0 KiB
GDScript
extends Control
|
|
@onready var date: Label = $TextureRect/date
|
|
@onready var time: Label = $TextureRect/time
|
|
@onready var weather: Label = $TextureRect/weather
|
|
@onready var pos: Label = $TextureRect/pos
|
|
@onready var h_box_container: HBoxContainer = $ScrollContainer/HBoxContainer
|
|
@onready var scroll_container: ScrollContainer = $ScrollContainer
|
|
@onready var map_0
|
|
@onready var map_1
|
|
@onready var map_2
|
|
@onready var map_now
|
|
@onready var map_add_pos: MarginContainer = $ScrollContainer/HBoxContainer/map_add_pos
|
|
|
|
var scale_rag:float=1:
|
|
set(val):
|
|
if val>scale_index_1 and val<scale_index_2 and (scale_rag<scale_index_1 or scale_rag>scale_index_2):
|
|
var t=get_tree().create_tween()
|
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
|
t.tween_callback(map_now.hide)
|
|
var t2=get_tree().create_tween()
|
|
map_1.modulate.a=0
|
|
map_1.show()
|
|
map_now=map_1
|
|
t2.tween_property(map_1,"modulate:a",1,0.1)
|
|
elif val<=scale_index_1 and scale_rag>scale_index_1:
|
|
var t=get_tree().create_tween()
|
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
|
t.tween_callback(map_now.hide)
|
|
var t2=get_tree().create_tween()
|
|
map_0.modulate.a=0
|
|
map_0.show()
|
|
map_now=map_0
|
|
t2.tween_property(map_0,"modulate:a",1,0.1)
|
|
elif val>scale_index_2 and scale_rag<scale_index_2:
|
|
var t=get_tree().create_tween()
|
|
t.tween_property(map_now,"modulate:a",0,0.1)
|
|
t.tween_callback(map_now.hide)
|
|
var t2=get_tree().create_tween()
|
|
map_2.modulate.a=0
|
|
map_2.show()
|
|
map_now=map_2
|
|
t2.tween_property(map_2,"modulate:a",1,0.1)
|
|
resize_map(scale_rag,val,get_global_mouse_position(),init_size)
|
|
scale_rag=val
|
|
pass
|
|
var scale_limit_min:float=1
|
|
var scale_limit_max:float=2
|
|
var scale_index_1:float=1.2
|
|
var scale_index_2:float=1.5
|
|
var map_data:Dictionary
|
|
func set_map(id:String):
|
|
map_data=Global.get_map_data(id)
|
|
var map_index:Array=map_data["index"]
|
|
for i in map_add_pos.get_children():
|
|
i.queue_free()
|
|
var tscn=[load(map_index[0]).instantiate(),load(map_index[1]).instantiate(),load(map_index[2]).instantiate()]
|
|
for i in tscn:
|
|
map_add_pos.add_child(i)
|
|
i.click.connect(click)
|
|
map_0=tscn[0]
|
|
map_1=tscn[1]
|
|
map_2=tscn[2]
|
|
map_1.hide()
|
|
map_2.hide()
|
|
map_now=map_0
|
|
var scale_index:Array=map_data["scale_index"]
|
|
var scale_limit:Array=map_data["scale_limit"]
|
|
scale_limit_min=scale_limit[0]
|
|
scale_limit_max=scale_limit[1]
|
|
scale_index_1=scale_index[0]
|
|
scale_index_2=scale_index[1]
|
|
var _init_size=map_data["init_size"]
|
|
init_size=Vector2(_init_size[0],_init_size[1])
|
|
pass
|
|
|
|
func resize_map(before_rag:float,rag:float,mouse_pos:Vector2,init:Vector2):
|
|
var l=rag/before_rag
|
|
var now_pos=Vector2(scroll_container.scroll_horizontal,scroll_container.scroll_vertical)+mouse_pos
|
|
now_pos*=l
|
|
var result=now_pos-mouse_pos
|
|
h_box_container.custom_minimum_size=init*rag
|
|
scroll_container.set_deferred("scroll_horizontal", result.x)
|
|
scroll_container.set_deferred("scroll_vertical", result.y)
|
|
|
|
|
|
pass
|
|
func click(scene_id:String):
|
|
|
|
|
|
|
|
pass
|
|
|
|
var init_size:Vector2=Vector2(1920,1080)
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
set_map("map_01")
|
|
h_box_container.custom_minimum_size=init_size
|
|
pass # Replace with function body.
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
func _process(delta: float) -> void:
|
|
pass
|
|
|
|
var keep_tween:Tween
|
|
func _gui_input(event: InputEvent) -> void:
|
|
if event is InputEventMouseMotion and Input.is_action_pressed("mouse_left"):
|
|
var relative:Vector2=event.relative
|
|
scroll_container.scroll_horizontal-=relative.x
|
|
scroll_container.scroll_vertical-=relative.y
|
|
if Input.is_action_pressed("mouse_up"):
|
|
if keep_tween==null:
|
|
keep_tween=create_tween()
|
|
else:
|
|
keep_tween.stop()
|
|
keep_tween=create_tween()
|
|
keep_tween.tween_property(self,"scale_rag",clamp(scale_rag+0.2,scale_limit_min,scale_limit_max),0.1)
|
|
if Input.is_action_just_pressed("mouse_down"):
|
|
if keep_tween==null:
|
|
keep_tween=create_tween()
|
|
else:
|
|
keep_tween.stop()
|
|
keep_tween=create_tween()
|
|
keep_tween.tween_property(self,"scale_rag",clamp(scale_rag-0.2,scale_limit_min,scale_limit_max),0.1)
|
|
|