Skip to content

Commit

Permalink
Merge branch 'xml_converter' of https://github.com/klingbolt/Burrito
Browse files Browse the repository at this point in the history
…into xml_converter
  • Loading branch information
klingbolt committed Sep 25, 2024
2 parents bb8abbd + fc56dc5 commit cac9c82
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 157 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ Roadmap

Known Bug Workarounds
=====================
* Burrito launches off-center or on the wrong monitor
* This seems to be WM dependant. on Gnome it can be solved by holding down the super key and dragging burrito to the right position.
* Burrito launches off-center or on the wrong monitor (This seems to be WM dependant.)
* On Gnome and KDE it can be solved by holding down the super key and dragging burrito to the right position.
* On KDE it is also possible to use [window-rules](https://docs.kde.org/stable5/en/kwin/kcontrol/windowspecific/examples.html) to set the position or a target monitor automatically by adding a new rule to `System Settings → Window Behavior → Window Rules` and setting `window class (application)` to `burrito`.
49 changes: 42 additions & 7 deletions Spatial.gd
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,23 @@ var taco_parser: TacoParser
var x11_window_id_burrito: int
var is_transient:bool = false

# Variables that store informations about ui scaling
# The ui-size as read from the link can have the values [0=small; 1=normal; 2=large; 3=larger]
var ui_size: int = 1
# This dictionary holds the left and right margin for the main button for every ui-scale
const button_margin = {
0: {"left": 292, "right": 318}, # small
1: {"left": 323, "right": 352}, # normal
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
}

# Scenes used throughout this scene
const trail3d_scene = preload("res://Trail3D.tscn")
const icon_scene = preload("res://Icon.tscn")
Expand All @@ -66,7 +83,6 @@ onready var markers_ui := $Control/Dialogs/CategoriesDialog/MarkersUI as Tree
onready var markers_3d := $Markers3D as Spatial
onready var markers_2d := $Control/Markers2D as Node2D


# Called when the node enters the scene tree for the first time.
func _ready():
self.markers_ui.set_column_expand(1, false)
Expand Down Expand Up @@ -269,7 +285,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 +357,20 @@ func decode_context_packet(spb: StreamPeerBuffer):
# vs radians. 70deg = 1.22173rad and 25deg = 0.4363323rad. We should redo
# this to just be a radian to degree conversion.

# Calculations to dynamically place the main icon/button
self.ui_size = int(identity["uisz"])
# If the value is not part of the dictionary use the "normal" size.
if !self.button_margin.has(self.ui_size):
self.ui_size = 1

$Control/GlobalMenuButton.margin_left = self.button_margin[self.ui_size]["left"]
$Control/GlobalMenuButton.margin_right = self.button_margin[self.ui_size]["right"]
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")
var old_texture_path: String = ""
Expand Down Expand Up @@ -371,8 +401,8 @@ func reset_minimap_masks(reset_3d: bool = true):
var compass_corner1 = Vector2(0, 0)
var compass_corner2 = viewport_size
if !map_is_open && !compass_is_top_right:
compass_corner1 = Vector2(viewport_size.x-self.compass_width, 36)
compass_corner2 = compass_corner1 + Vector2(self.compass_width, self.compass_height)
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(self.compass_width, self.compass_height)
compass_corner2 = compass_corner1 + Vector2(self.compass_width, self.compass_height)
Expand Down Expand Up @@ -910,11 +940,16 @@ func _on_main_menu_toggle_pressed():
$Control/Dialogs/MainMenu.show()
set_maximal_mouse_block()

func _on_Dialog_hide():
func is_any_dialog_visible():
for dialog in $Control/Dialogs.get_children():
if dialog.visible:
return
set_minimal_mouse_block()
return true
return false


func _on_Dialog_hide():
if !is_any_dialog_visible():
set_minimal_mouse_block()


func _on_LoadTrail_pressed():
Expand Down
2 changes: 1 addition & 1 deletion burrito_link/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ target_link_libraries(${DX11LIB} PRIVATE "ws2_32")
set_target_properties(${DX11LIB} PROPERTIES
PREFIX ""
SUFFIX ""
LINK_FLAGS "../deffile.def -Wl,--allow-shlib-undefined -Wl,-O1 -shared -static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096 -lm -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32"
LINK_FLAGS "../deffile.def -Wl,--allow-shlib-undefined,--no-insert-timestamp -Wl,-O1 -shared -static -static-libgcc -static-libstdc++ -Wl,--file-alignment=4096 -lm -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32"
)
Loading

0 comments on commit cac9c82

Please sign in to comment.