Steps:
1. Add a mod with the following code
Code: Select all
script.on_event(defines.events.on_player_joined_game, function (event)
local player = game.get_player(event.player_index)
local top_left = player.gui.screen.add{
type = "empty-widget",
name = "top_left_overlay",
raise_hover_events = true,
}
top_left.style.width = 200
top_left.style.height = 200
local bottom_right = player.gui.screen.add{
type = "empty-widget",
name = "bottom_right_overlay",
raise_hover_events = true,
}
bottom_right.style.width = 200
bottom_right.style.height = 200
end)
local function update_hover_overlays_location(player_index)
local player = game.get_player(player_index)
local top_left = player.gui.screen["top_left_overlay"]
top_left.location = { 0, 0 }
local bottom_right = player.gui.screen["bottom_right_overlay"]
bottom_right.location = {
player.display_resolution.width - 200 * player.display_scale,
player.display_resolution.height - 200 * player.display_scale
}
end
script.on_event(defines.events.on_player_display_resolution_changed, function(event)
update_hover_overlays_location(event.player_index)
end)
script.on_event(defines.events.on_player_display_scale_changed, function(event)
update_hover_overlays_location(event.player_index)
end)
script.on_event(defines.events.on_gui_hover, function(event)
game.print("on_gui_hover: "..event.element.name)
end)
2. Make sure Factorio is launched in full screen.
3. Start a new Freeplay game.
4. Move cursor to top-left corner. Actual: "on_gui_hover: top_left_overlay" printed in chat. As expected.
5. Move cursor to bottom-right corner of the screen. Actual: "on_gui_hover: bottom_right_overlay" printed in chat. As expected.
6. From initial position at the bottom-right corner, move cursor slightly to the left and slightly to the top. I.e. hover bottom_right_overlay.
Actual: both printed in chat:
Expected: only "on_gui_hover: bottom_right_overlay" printed in chat.on_gui_hover: top_left_overlay
on_gui_hover: bottom_right_overlay
Notes:
- display_resolution = 2160x3840
- display_scale = 2
- display_density_scale = 3
- Graphics settings -> Full screen = true
- See related bug: viewtopic.php?t=133479 - if it gets fixed, steps here might become outdated/impossible.
UPD:
Another way to reproduce:
7. While game is not paused and cursor is outside top-left element bounds, alt+tab from the game, then alt+tab back into the game. Actual: "on_gui_hover: top_left_overlay" printed in chat.
