Description
GUI elements anchored (attached) to one of the sides (left/right/top/bottom) of game's built-in windows. This is helpful for providing context-dependent buttons to player for some of the operations.However, when such GUI elements are anchored to the bottom of windows that occupy most of the vertical height of game window, the GUI elements become either invisible, or cannot be clicked upon (either entirely or partially).
Reproduction steps
- Set-up a new mod with the following control script (this will be used to create the GUI elements and anchor them around):
Code: Select all
--- Creates two buttons attached to train/spidertron windows. -- function create_buttons() local player = game.players[1] if global.train_button then global.train_button.destroy() end if global.spidertron_button then global.spidertron_button.destroy() end global.train_button = player.gui.relative.add{ type = "sprite-button", name = "train_button", style = "shortcut_bar_button_blue", sprite = "item/locomotive", anchor = { gui = defines.relative_gui_type.train_gui, position = defines.relative_gui_position.left } } global.spidertron_button = player.gui.relative.add{ type = "sprite-button", name = "spidertron_button", style = "shortcut_bar_button_blue", sprite = "item/spidertron", anchor = { gui = defines.relative_gui_type.spider_vehicle_gui, position = defines.relative_gui_position.left } } -- Extend spidertron button height to demonstrate the button is -- only partially clickable when anchored to bottom of the window. global.spidertron_button.style.height = 200 end --- Command for creating the buttons. -- commands.add_command( "create_buttons", nil, function(command) create_buttons() end ) --- Command for anchoring buttons to passed-in position of their respective windows. commands.add_command( "anchor_buttons", nil, function(command) local position = defines.relative_gui_position[command.parameter] or defines.relative_gui_position.left global.train_button.anchor = { gui = global.train_button.anchor.gui, position = position } global.spidertron_button.anchor = { gui = global.spidertron_button.anchor.gui, position = position } end )
- Launch game in fullscreen resolution of 1920x1080. Set UI scale to 100%.
- Start a new game, and place down:
- One locomotive
- One spidertron
- Create buttons that are anchored to train and spidertron windows using console command /create_buttons.
- Open the locomotive window and click on the button in upper left position of the window.
- Open the spidertron window and click on the button in upper left position of the window.
- Anchor buttons to bottom of their respective windows using console command /anchor_buttons_to bottom.
- Open the locomotive window and click on the button in bottom left position of the window.
- Open the spidertron window and click on the button in bottom left position of the window.
Expected results
- In step (5), the button is visible and clicks are registered by the game.
- In step (6), the button is visible and clicks are registered by the game.
- In step (8), the button is visible and clicks are registered by the game.
- In step (9), the button is visible and clicks are registered by the game.
Actual results
- In step (5), the button is visible and clicks are registered by the game.
- In step (6), the button is visible and clicks are registered by the game.
- In step (8), the button is not visible at all.
- In step (9), the button is visible, but clicks are registered by the game only in the upper half of the button.
Additional information
From what I can tell, this seems to be mainly related to relative height of the window as compared to the game window. For example, if you zoom in a couple of levels with the spidetron window open while the button is anchored to the bottom, it will become invisible once you get past certain threshold. And as you zoom in, more of the button surface (vertically) will become unclickable. In case of train window it's easier to spot this issue because that window is always kept a certain size relative to the game screen (mostly entire screen).Another thing of interest is that if you insert a personal roboport in the spidertron's equipment grid, its window height will grow, which would again make smaller part of the (bottom-anchored) button clickable. Even moving the window upwards does not seem to increase the surface of the button that can be clicked (in case of button bottom-anchored to spidetron window).
I have ran into these issues in particular while working on the Equipment Grid Templates mod.