aboutsummaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2024-03-15 00:23:34 +0100
committer GitHub <noreply@github.com>2024-03-15 00:23:34 +0100
commit8088824d7b78311c0613b3876ba9555fbbe96c17 (patch)
treea65df845b8024a1635a0751a9297ebd81b212b65 /game
parent8ccddb71dd634ed3fbb31df9994f0a71dd1d81d1 (diff)
parent1d64ee9a6465e75381e40cb56098a8e728c685dc (diff)
Merge pull request #213 from OpenVicProject/map-background
Add map background plane to hide transparent window
Diffstat (limited to 'game')
-rw-r--r--game/src/Game/GameSession/MapView.gd20
-rw-r--r--game/src/Game/GameSession/MapView.tscn16
2 files changed, 31 insertions, 5 deletions
diff --git a/game/src/Game/GameSession/MapView.gd b/game/src/Game/GameSession/MapView.gd
index 63e8168..f522bcb 100644
--- a/game/src/Game/GameSession/MapView.gd
+++ b/game/src/Game/GameSession/MapView.gd
@@ -44,6 +44,8 @@ var _map_shader_material : ShaderMaterial
var _map_mesh_corner : Vector2
var _map_mesh_dims : Vector2
+@export var _map_background_instance : MeshInstance3D
+
var _mouse_pos_viewport : Vector2 = Vector2(0.5, 0.5)
var _mouse_pos_map : Vector2 = Vector2(0.5, 0.5)
var _viewport_dims : Vector2 = Vector2(1, 1)
@@ -56,12 +58,12 @@ var _viewport_dims : Vector2 = Vector2(1, 1)
# editor, GDExtension, my own extension, or a combination of them.
# This was an absolute pain to track down. --- hop311
func _ready() -> void:
- if _camera == null:
+ if not _camera:
push_error("MapView's _camera variable hasn't been set!")
return
_zoom_target = _camera.position.y
- if _map_mesh_instance == null:
- push_error("MapView's _map_mesh variable hasn't been set!")
+ if not _map_mesh_instance:
+ push_error("MapView's _map_mesh_instance variable hasn't been set!")
return
# Shader Material
@@ -91,6 +93,18 @@ func _ready() -> void:
GameSingleton.province_selected.connect(_on_province_selected)
+ if not _map_background_instance:
+ push_error("MapView's _map_background_instance variable hasn't been set!")
+ return
+
+ if not _map_background_instance.mesh is PlaneMesh:
+ push_error("Invalid map background mesh class: ", _map_background_instance.mesh.get_class(), "(expected PlaneMesh)")
+ return
+ var scaled_dims : Vector3 = _map_background_instance.transform.affine_inverse() * Vector3(_map_mesh_dims.x, 0.0, _map_mesh_dims.y)
+ scaled_dims.x *= 1.0 + 2.0 * _map_mesh.get_repeat_proportion()
+ scaled_dims.z *= 2.0
+ (_map_background_instance.mesh as PlaneMesh).set_size(Vector2(scaled_dims.x, scaled_dims.z))
+
func _notification(what : int) -> void:
match what:
NOTIFICATION_WM_MOUSE_ENTER: # Mouse inside window
diff --git a/game/src/Game/GameSession/MapView.tscn b/game/src/Game/GameSession/MapView.tscn
index 0296156..bf22ef8 100644
--- a/game/src/Game/GameSession/MapView.tscn
+++ b/game/src/Game/GameSession/MapView.tscn
@@ -1,4 +1,4 @@
-[gd_scene load_steps=5 format=3 uid="uid://dkehmdnuxih2r"]
+[gd_scene load_steps=7 format=3 uid="uid://dkehmdnuxih2r"]
[ext_resource type="Script" path="res://src/Game/GameSession/MapView.gd" id="1_exccw"]
[ext_resource type="Shader" path="res://src/Game/GameSession/TerrainMap.gdshader" id="1_upocn"]
@@ -16,11 +16,19 @@ shader_parameter/overlay_tile_factor = null
[sub_resource type="MapMesh" id="MapMesh_3gtsd"]
-[node name="MapView" type="Node3D" node_paths=PackedStringArray("_camera", "_map_mesh_instance")]
+[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_irk50"]
+albedo_color = Color(0, 0, 0, 1)
+
+[sub_resource type="PlaneMesh" id="PlaneMesh_fnhgl"]
+material = SubResource("StandardMaterial3D_irk50")
+size = Vector2(6, 2)
+
+[node name="MapView" type="Node3D" node_paths=PackedStringArray("_camera", "_map_mesh_instance", "_map_background_instance")]
editor_description = "SS-73"
script = ExtResource("1_exccw")
_camera = NodePath("MapCamera")
_map_mesh_instance = NodePath("MapMeshInstance")
+_map_background_instance = NodePath("MapBackgroundInstance")
[node name="MapCamera" type="Camera3D" parent="."]
transform = Transform3D(1, 0, 0, 0, 0.707107, 0.707107, 0, -0.707107, 0.707107, 0.25, 1.5, -2.75)
@@ -31,3 +39,7 @@ editor_description = "FS-343"
transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, 0, 0)
material_override = SubResource("ShaderMaterial_tayeg")
mesh = SubResource("MapMesh_3gtsd")
+
+[node name="MapBackgroundInstance" type="MeshInstance3D" parent="."]
+transform = Transform3D(10, 0, 0, 0, 10, 0, 0, 0, 10, 0, -1, 0)
+mesh = SubResource("PlaneMesh_fnhgl")