解决部分分辨率缩放问题

This commit is contained in:
TsubakiLoL 2024-10-16 11:54:14 +08:00
parent 08317b644f
commit be558aac4a
22 changed files with 203 additions and 18 deletions

View File

@ -313,5 +313,25 @@
},]
}
]
},
"event_socialize":{
"name":"社交",
"texture":"test_scene",
"text":"你需要社交",
"choice":[
{
"name":"魅力鉴定",
"triger":[
{
"type":"show_identifaction",
"data":"AM_judge"
},
{
"type":"end_event",
"data":""
}
]
}
]
}
}

View File

@ -30,5 +30,12 @@
"fish_single":{
"type":0,
"preview":"fish_preview",
},
"AM_judge":{
"name":"魅力鉴定",
"type":0,
"attribute_name":"AM",
"attribute_value":100,
}
}

View File

@ -43,6 +43,10 @@
{
"name":"卡牌制作测试",
"event":"make_card_test"
},
{
"name":"社交",
"event":"event_socialize"
}
],
"linked_scene":[{

View File

@ -28,6 +28,8 @@ Database="*res://autoload/database/tscn/database.tscn"
window/size/viewport_width=1920
window/size/viewport_height=1080
window/size/mode=3
window/size/initial_position_type=0
window/size/initial_position=Vector2i(200, 200)
[editor_plugins]

View File

@ -52,9 +52,12 @@ stretch_mode = 4
[node name="mask" type="TextureRect" parent="."]
show_behind_parent = true
layout_mode = 0
offset_right = 40.0
offset_bottom = 40.0
anchor_right = 0.987654
anchor_bottom = 0.990476
offset_right = -120.0
offset_bottom = -168.0
texture = ExtResource("4_yka8x")
metadata/_edit_use_anchors_ = true
[node name="lock" type="TextureRect" parent="."]
unique_name_in_owner = true

View File

@ -165,14 +165,14 @@ layout_mode = 2
unique_name_in_owner = true
layout_mode = 1
anchors_preset = -1
anchor_left = 0.290417
anchor_left = 0.148
anchor_top = 1.0
anchor_right = 0.33
anchor_right = 0.469
anchor_bottom = 1.0
offset_left = -266.6
offset_left = 6.84058
offset_top = -977.0
offset_right = 266.4
expand_mode = 1
offset_right = -0.480042
expand_mode = 5
stretch_mode = 6
metadata/_edit_use_anchors_ = true

View File

@ -60,6 +60,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_nt8m8")
expand_mode = 1
[node name="MarginContainer" type="MarginContainer" parent="."]
layout_mode = 1

View File

@ -27,6 +27,7 @@ anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_dy7pb")
expand_mode = 1
[node name="CenterContainer" type="CenterContainer" parent="."]
layout_mode = 1

View File

@ -67,16 +67,29 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_cpmb4")
[node name="TextureRect" type="TextureRect" parent="."]
[node name="ColorRect" type="ColorRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0, 0, 0, 0.384314)
[node name="TextureRect" type="TextureRect" parent="."]
layout_mode = 1
anchors_preset = -1
anchor_left = 0.0520833
anchor_top = 0.0925926
anchor_right = 0.947917
anchor_bottom = 0.907407
grow_horizontal = 2
grow_vertical = 2
texture = ExtResource("1_u31m8")
expand_mode = 1
stretch_mode = 6
metadata/_edit_use_anchors_ = true
[node name="MarginContainer" type="MarginContainer" parent="."]
modulate = Color(0.454524, 0.454524, 0.454524, 1)
@ -86,10 +99,10 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/margin_left = 44
theme_override_constants/margin_top = 40
theme_override_constants/margin_right = 44
theme_override_constants/margin_bottom = 39
theme_override_constants/margin_left = 100
theme_override_constants/margin_top = 100
theme_override_constants/margin_right = 100
theme_override_constants/margin_bottom = 100
[node name="HBoxContainer" type="HBoxContainer" parent="MarginContainer"]
show_behind_parent = true

View File

@ -18,6 +18,7 @@ const GAME_FLOW_EVENT = preload("res://scene/game_flow_event.tscn")
const GAME_FLOW_PLACE = preload("res://scene/game_flow_place.tscn")
var scene_data:Dictionary
func _ready() -> void:
#get_window().size=Vector2i(2560,1440)
if Global.is_script_finish():
%points_settlement.show()
%points_settlement.show_mes({})

View File

@ -88,14 +88,15 @@ func set_map(id:String):
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])
#var _init_size=map_data["init_size"]
#init_size=Vector2(_init_size[0],_init_size[1])
pass
func update_time():
var time_dic:Dictionary=Global.get_time_dictionary()
date.text=str(time_dic["year"])+"/"+str(time_dic["month"])+"/"+str(time_dic["day"])
time.text=str(time_dic["hour"])+":"+"%02d"%[time_dic["minute"]]
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
@ -118,11 +119,13 @@ func click(scene_id:String):
self.hide()
self.set_process(false)
var init_size:Vector2=Vector2(1920,1080)
@onready var init_size:Vector2=get_viewport().size
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
set_map("map_01")
update_time()
get_window().size_changed.connect(resize_map.bindv([scale_rag,scale_rag,get_global_mouse_position(),init_size]))
Global.time_changed.connect(update_time)
h_box_container.custom_minimum_size=init_size
pass # Replace with function body.
@ -130,6 +133,7 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
init_size=get_viewport().size
update_pointer()
pass
@ -162,3 +166,13 @@ func _on_back_pressed() -> void:
set_process(false)
self.hide()
pass # Replace with function body.
func _on_visibility_changed() -> void:
#当地图开始显示的时候
if visible:
var tween=create_tween()
tween.tween_property(self,"scale_rag",2,0.1)
pass

View File

@ -194,5 +194,6 @@ texture = ExtResource("9_u7qpf")
[node name="back" parent="back" instance=ExtResource("10_vgkwd")]
layout_mode = 1
[connection signal="visibility_changed" from="." to="." method="_on_visibility_changed"]
[connection signal="gui_input" from="ScrollContainer" to="." method="_on_scroll_container_gui_input"]
[connection signal="pressed" from="back/back" to="." method="_on_back_pressed"]

1
scene/map_2d.gd Normal file
View File

@ -0,0 +1 @@
extends Control

75
scene/map_2d.tscn Normal file
View File

@ -0,0 +1,75 @@
[gd_scene load_steps=6 format=3 uid="uid://7agx3qjkgnwl"]
[ext_resource type="Script" path="res://scene/map_2d.gd" id="1_j8foi"]
[ext_resource type="PackedScene" uid="uid://dtbfpnr54ifod" path="res://test/scene/map_example0.tscn" id="2_7c5c8"]
[ext_resource type="Texture2D" uid="uid://bx2layh7wm6ft" path="res://res/ui/ui_021_map/tuceng309.png" id="3_pyawj"]
[ext_resource type="Texture2D" uid="uid://bc4vkd7u4s4sb" path="res://res/ui/ui_021_map/tuceng308.png" id="4_0ppjt"]
[sub_resource type="ViewportTexture" id="ViewportTexture_32us8"]
viewport_path = NodePath("SubViewport")
[node name="Map2d" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_j8foi")
[node name="ColorRect" type="ColorRect" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
color = Color(0.505882, 0.552941, 0.262745, 1)
[node name="SubViewport" type="SubViewport" parent="."]
transparent_bg = true
[node name="Node2D" type="Node2D" parent="SubViewport"]
[node name="Camera2D" type="Camera2D" parent="SubViewport/Node2D"]
[node name="map_example" parent="SubViewport/Node2D" instance=ExtResource("2_7c5c8")]
[node name="HBoxContainer" type="HBoxContainer" parent="."]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_constants/separation = 0
[node name="TextureRect2" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 0
texture = ExtResource("3_pyawj")
expand_mode = 3
[node name="TextureRect3" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 0
texture = ExtResource("4_0ppjt")
expand_mode = 3
[node name="TextureRect" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
texture = SubResource("ViewportTexture_32us8")
[node name="TextureRect4" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 8
texture = ExtResource("4_0ppjt")
expand_mode = 3
flip_h = true
[node name="TextureRect5" type="TextureRect" parent="HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 4
texture = ExtResource("3_pyawj")
expand_mode = 3

View File

@ -17,6 +17,8 @@ func set_data(_data:Dictionary):
else:
%multi_pre.hide()
%single.show()
%single_name.text=data["name"]
%indetification_value.text=CharacterTool.get_name_by_attribute_key(data["attribute_name"])+":"+str(data["attribute_value"])
var apped_item_data:Array=[]
#从背包中寻找可用item
func search_bag():

View File

@ -111,7 +111,6 @@ stretch_mode = 6
[node name="single" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.257813
@ -121,7 +120,8 @@ anchor_bottom = 0.597222
theme_override_styles/panel = SubResource("StyleBoxTexture_meexh")
metadata/_edit_use_anchors_ = true
[node name="Label" type="Label" parent="single"]
[node name="single_name" type="Label" parent="single"]
unique_name_in_owner = true
layout_mode = 1
anchors_preset = 5
anchor_left = 0.5
@ -244,6 +244,7 @@ vertical_alignment = 1
[node name="multi_pre" type="Panel" parent="."]
unique_name_in_owner = true
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.257813

View File

@ -12,6 +12,7 @@ var target = null:
#$TextureRect3.global_position = target.global_position + Vector2(target.size.x, target.size.y/2)
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
#get_window().size=Vector2i(2560,1440)
#var tween = get_tree().create_tween()
#tween.set_loops()
#tween.tween_property($TextureRect2, "scale", Vector2(1,0), 0.4)

View File

@ -31,3 +31,18 @@ metadata/_edit_use_anchors_ = true
[node name="ToolButton" parent="TextureRect" instance=ExtResource("4_d7xih")]
layout_mode = 1
[node name="TextureRect2" type="TextureRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.614583
anchor_top = 0.456481
anchor_right = 0.64375
anchor_bottom = 0.508333
texture = ExtResource("3_4ivo3")
expand_mode = 1
metadata/_edit_use_anchors_ = true
[node name="ToolButton" parent="TextureRect2" instance=ExtResource("4_d7xih")]
layout_mode = 1

View File

@ -31,3 +31,18 @@ metadata/_edit_use_anchors_ = true
[node name="ToolButton" parent="TextureRect" instance=ExtResource("4_wygvp")]
layout_mode = 1
[node name="TextureRect2" type="TextureRect" parent="."]
visible = false
layout_mode = 1
anchors_preset = -1
anchor_left = 0.614583
anchor_top = 0.456481
anchor_right = 0.64375
anchor_bottom = 0.508333
texture = ExtResource("3_rdri5")
expand_mode = 1
metadata/_edit_use_anchors_ = true
[node name="ToolButton" parent="TextureRect2" instance=ExtResource("4_wygvp")]
layout_mode = 1

View File

@ -6,10 +6,13 @@ extends MapIndex
func _on_tool_button_pressed() -> void:
click_scene("scene_tower")
pass # Replace with function body.
func get_scene_global_pos(scene_id:String):
match scene_id:
"scene_tower":
return $TextureRect/ToolButton.global_position
"scene_01":
return $TextureRect2.global_position+Vector2($TextureRect2.size.x/2,0)
_:return Vector2(0,0)
pass

View File

@ -10,6 +10,9 @@ func get_scene_global_pos(scene_id:String):
match scene_id:
"scene_tower":
return $TextureRect/ToolButton.global_position
"scene_01":
return $TextureRect2.global_position+Vector2($TextureRect2.size.x/2,0)
_:return Vector2(0,0)
pass

View File

@ -9,6 +9,8 @@ func get_scene_global_pos(scene_id:String):
match scene_id:
"scene_tower":
return $TextureRect/ToolButton.global_position+Vector2($TextureRect/ToolButton.size.x/2,0)
"scene_01":
return $TextureRect2.global_position+Vector2($TextureRect2.size.x/2,0)
_:return Vector2(0,0)
pass