[1.1.76] Anchored GUI elements not visible or clickable depending on window height/GUI scale

This subforum contains all the issues which we already resolved.
Post Reply
azaghal
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sat Jun 27, 2020 11:13 am
Contact:

[1.1.76] Anchored GUI elements not visible or clickable depending on window height/GUI scale

Post by azaghal »

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
  1. 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
    )
    
  2. Launch game in fullscreen resolution of 1920x1080. Set UI scale to 100%.
  3. Start a new game, and place down:
    • One locomotive
    • One spidertron
  4. Create buttons that are anchored to train and spidertron windows using console command /create_buttons.
  5. Open the locomotive window and click on the button in upper left position of the window.
  6. Open the spidertron window and click on the button in upper left position of the window.
  7. Anchor buttons to bottom of their respective windows using console command /anchor_buttons_to bottom.
  8. Open the locomotive window and click on the button in bottom left position of the window.
  9. 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.

Amarula
Filter Inserter
Filter Inserter
Posts: 511
Joined: Fri Apr 27, 2018 1:29 pm
Contact:

Re: [1.1.76] Anchored GUI elements not visible or clickable depending on window height/GUI scale

Post by Amarula »

I am finding the same issue creating blueprints - the save blueprint button is anchored to the bottom and disappears for larger blueprints a) since I had my eye surgery and went to a larger font and b) when I am in windowed mode not full screen.
Screenshot from 2023-03-26 09-55-26.png
Screenshot from 2023-03-26 09-55-26.png (1 MiB) Viewed 967 times
My own personal Factorio super-power - running out of power.

User avatar
raiguard
Factorio Staff
Factorio Staff
Posts: 451
Joined: Wed Dec 13, 2017 8:29 pm
Contact:

Re: [1.1.76] Anchored GUI elements not visible or clickable depending on window height/GUI scale

Post by raiguard »

1.1.77.png
1.1.77.png (549.84 KiB) Viewed 879 times
This was fixed in 1.1.77 experimental.

@Amarula Your issue is not related to this one. That is happening because your UI scale is simply too large for that resolution. GUIs will always break if you make the scale extremely large. Feel free to open a separate bug report if you wish, but I can't guarantee that it will be fixed.
Don't forget, you're here forever.

azaghal
Burner Inserter
Burner Inserter
Posts: 18
Joined: Sat Jun 27, 2020 11:13 am
Contact:

Re: [1.1.76] Anchored GUI elements not visible or clickable depending on window height/GUI scale

Post by azaghal »

raiguard wrote:
Sat Apr 08, 2023 5:25 am
This was fixed in 1.1.77 experimental.
Ah, thanks for letting me know - I was browsing through the version history listing and this seemed somewhat related, but never got around to testing with the experimental version (probably should have done that, truth be told - lesson learned fro the future :) ).

I'll give it another try with latest experimental.

Post Reply

Return to “Resolved Problems and Bugs”