Skip to content

Commit

Permalink
Merge pull request AsherGlick#242 from Masgalor/dynamic-minimap-scale
Browse files Browse the repository at this point in the history
Dynamic minimap scale depending on ui-scale
  • Loading branch information
AsherGlick authored Nov 29, 2023
2 parents 55b2aeb + 5899c48 commit 4185432
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ const button_margin = {
2: {"left": 361, "right": 394}, # large
3: {"left": 395, "right": 431} # larger
}
const minimap_scale = {
0: {"offset": 32, "factor": 0.9}, # small
1: {"offset": 36, "factor": 1}, # normal
2: {"offset": 40, "factor": 1.11}, # large
3: {"offset": 44, "factor": 1.22} # larger
}

# Called when the node enters the scene tree for the first time.
func _ready():
Expand Down Expand Up @@ -258,7 +264,7 @@ func decode_frame_packet(spb: StreamPeerBuffer):
if (!map_is_open):
map_size = Vector2(compass_width, compass_height)
if !compass_is_top_right:
map_corner = get_viewport().size - Vector2(compass_width, compass_height + 36)
map_corner = get_viewport().size - Vector2(compass_width, compass_height + self.minimap_scale[self.ui_size]["offset"])
else:
map_corner = Vector2(get_viewport().size.x - compass_width, 0)

Expand Down Expand Up @@ -341,6 +347,9 @@ func decode_context_packet(spb: StreamPeerBuffer):
if !is_any_dialog_visible():
set_minimal_mouse_block()

compass_width = compass_width * self.minimap_scale[self.ui_size]["factor"]
compass_height = compass_height * self.minimap_scale[self.ui_size]["factor"]

if self.map_id != old_map_id:
print("New Map")

Expand Down Expand Up @@ -372,7 +381,7 @@ func reset_minimap_masks():
compass_corner1 = Vector2(0, 0)
compass_corner2 = viewport_size
if !map_is_open && !compass_is_top_right:
compass_corner1 = Vector2(viewport_size.x-compass_width, 36)
compass_corner1 = Vector2(viewport_size.x-compass_width, self.minimap_scale[self.ui_size]["offset"])
compass_corner2 = compass_corner1 + Vector2(compass_width, compass_height)
elif !map_is_open && compass_is_top_right:
compass_corner1 = viewport_size - Vector2(compass_width, compass_height)
Expand Down

0 comments on commit 4185432

Please sign in to comment.