Page 1 of 1

[0.17.2] word_wrap in LuaGuiElements wrapping aggressively and inconsistently

Posted: Wed Feb 27, 2019 10:42 pm
by project6
word_wrap seems to be acting in an inconsistent and unexpected manner. It is wrapping things far too short, but the wrapping behaviour changes when the string is being changed in vivo. Further, the wrapping behaviour reverts to being aggressive when you change away from it.

Initial wrapping is aggressive:
Image

While editing it wraps as expected:
Image

When changing tabs back and forth the aggressive wrapping returns:
Image

Code: Select all

{
    tab_button = function(parent)
        local button = parent.add {type = 'button', name = tab_button_name, caption = "What's New"}
        return button
    end,
    content = function(parent, player)
        local read_only = not player.admin

        header_label(parent, 'New Features')

        local new_info_flow = parent.add {name = 'whatsNew_new_info_flow',type = 'flow'}
        new_info_flow.style.horizontal_align = 'center'

        local new_info_textbox =
            new_info_flow.add {
            type = 'text-box',
            name = editable_textbox_name,
            text = editable_info[new_info_key]
        }
        new_info_textbox.read_only = read_only

        new_info_textbox.word_wrap = true

        local new_info_textbox_style = new_info_textbox.style
        new_info_textbox_style.width = 590
        new_info_textbox_style.height = 300

        Gui.set_data(new_info_textbox, new_info_key)
    end
}

Re: [0.17.2] word_wrap in LuaGuiElements wrapping aggressively and inconsistently

Posted: Thu Feb 28, 2019 5:00 am
by Rseding91
Thanks for the report. Can you please give a save file and mod(s) you're using that reproduces this issue.

Re: [0.17.2] word_wrap in LuaGuiElements wrapping aggressively and inconsistently

Posted: Thu Feb 28, 2019 8:50 am
by project6
The pic was taken with the redmew scenario which is quite large, and has a lot of framework which would make pinpointing the issue a chore. I'll upload a save with the barest code to clearly demonstrate the majority of the issue, and a save with the full redmew scenario for completion.

In the redmew scenario you can open the info screen by clicking the question mark top left, then "Map info" and "What's new" will both contain elements which have word_wrap enabled.

In both cases no mods are used.

Re: [0.17.2] word_wrap in LuaGuiElements wrapping aggressively and inconsistently

Posted: Thu Feb 28, 2019 1:27 pm
by SimonFlapse
Adding to this.
It seems that the wrapping happens as if the textbox's width was 250px:

The top textbox is 230px wide and the bottom one is 312px wide. It's clear that the wrapping happens around 250px
Image


The 250px seems to be inherited from the textbox style
Image

Re: [0.17.2] word_wrap in LuaGuiElements wrapping aggressively and inconsistently

Posted: Fri Mar 15, 2019 12:27 am
by Rseding91
This should be fixed for the next version of 0.17.