Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[map.lic] v1.3.2 WSL fixes (attempt2) #1583

Merged
merged 5 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ group :development do
gem "webmock"
gem "rack"
gem 'rubocop'
gem 'rexml', "3.3.1"
end
34 changes: 25 additions & 9 deletions scripts/map.lic
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ Tracks your current room on visual maps
game: Gemstone
tags: core, movement, mapping
required: Lich > 5.0.1
version: 1.3.1
version: 1.3.2

changelog:
v1.3.2 (2024-07-12)
* Additional fixes for WSL and responsiveness
v1.3.1 (2024-06-29)
* fix popup menu crash under WSL
* fix pointer click offset issues in WSL
Expand Down Expand Up @@ -318,7 +320,12 @@ menu_scale_list = nil
menu_tags_list = nil
current_tag = nil
scale_list = [10, 25, 33, 50, 66, 75, 90, 100, 110, 125, 133, 150, 166, 175, 190, 200]
opacity_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
opacity_list = [10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
begin
using_wsl = !File.readlines(File.join('/proc/version')).grep(/microsoft/i).empty?
rescue Errno::ENOENT
using_wsl = false
end

map_dir = get_map_dir(dark_mode)
used_maps = Set.new
Expand Down Expand Up @@ -505,14 +512,23 @@ Gtk.queue {
window.title = "Map: #{Char.name}"
window.set_icon(@default_icon)
window.signal_connect('delete_event') { narost_exit = true }
window.signal_connect("size-allocate") do |_widget, allocation|
window.signal_connect("size-allocate") do
window_resized = true
# on windows (at least through WSL) an unaccounted for border and titlebar are included in the
# pointer position, so we must offset by them
window_offset_x = (allocation.width - window_width) / 2 # effectively the resize border width
window_offset_y = (allocation.height - window_height) - window_offset_x # titlebar height
window_offset_x *= 1 / (scale ? scale : (global_scale ? global_scale : 1.0))
window_offset_y *= 1 / (scale ? scale : (global_scale ? global_scale : 1.0))
if using_wsl
# on windows (at least through WSL) an unaccounted for border and titlebar are included in the
# pointer position, so we must offset by them
frame_extents = window.window.frame_extents
outer_width = frame_extents.width
outer_height = frame_extents.height
inner_width, inner_height = window.size
window_offset_x = (outer_width - inner_width) / 2
window_offset_y = (outer_height - inner_height) - window_offset_x
window_offset_x *= 1 / (scale ? scale : (global_scale ? global_scale : 1.0))
window_offset_y *= 1 / (scale ? scale : (global_scale ? global_scale : 1.0))
# echo "outer_width: #{outer_width} outer_height: #{outer_height}"
# echo "inner_width: #{inner_width} inner_height: #{inner_height}"
# echo "offsetx: #{window_offset_x} offsety: #{window_offset_y}"
end
end
scroller = Gtk::ScrolledWindow.new
scroller.border_width = 0
Expand Down