Skip to content

Make dialog box width a function of screen width

cmk24cmk24 Member Posts: 605
Does any know how I could go about making the width of the dialog box a fixed percentage of the screen width (e.g. width=70%) instead of a fixed pixel width like it is now? All I need is the current game screen's resolution, but I am unfamiliar with lua and don't know how to go about getting it.

Comments

  • moody_magemoody_mage Member Posts: 2,054
    I think it would be better if you could drag the width of the box to your preferred width, much like you can with the top of the box.
  • cmk24cmk24 Member Posts: 605
    decado said:

    I think it would be better if you could drag the width of the box to your preferred width, much like you can with the top of the box.

    Agreed, that would be nice and I could look into that. The only issue I see with that solution is the pixel coordinate system is defined with 0 at the left edge of the box and the system automatically centers it. If you change the width via click and drag that left edge of the box is no longer at "0" and the box will not be centered the next time the game starts up (when the coordinate system is redefined with 0 on the left edge again). You would need a way to refresh the internal coordinate system after the resize is done for the centering to not mess up.

    Also they normal dialog box and the conversation box are two separate bits in the UI code, so changes to one would not directly effect the other without a bit a scripting magic (could be done, but not the easiest thing in the world).
  • lefreutlefreut Member Posts: 1,462
    edited November 2019
    ***
    Post edited by lefreut on
  • cmk24cmk24 Member Posts: 605
    OK, I am getting a bit closer on this one. I made a new function to adjust the size of the WORLD_MESSAGES group:

    function setDialogWidth(widthFraction)
    local screenWidth, screenHeight = Infinity_GetScreenSize()
    local x,y,w,h = Infinity_GetArea('messagesRect')
    local deltaWidth = screenWidth * widthFraction - w
    adjustItemGroup({"messagesRect", "worldMessageBox", "messagesHandleY"},0,0,deltaWidth,0)
    end
    and added

    setDialogWidth(0.7)
    to the top of the 'onOpen' of WORLD_MESSAGES. This adjusts the width the way I want, but the dialog box is no longer centered on the screen. Any ideas how I can keep everything centered aligned?
  • lroumenlroumen Member Posts: 2,508
    You can calculate the x-offset as well using the WidthFraction and instead of the {0,0,deltaWidth,0} part of the code, you get {XOffset,0,deltaWidth,0}... I guess in this scaling example the value is negative.
  • BillyYankBillyYank Member Posts: 2,768
    @lefreut , where do you find information on these functions?
  • cmk24cmk24 Member Posts: 605
    lroumen said:

    You can calculate the x-offset as well using the WidthFraction and instead of the {0,0,deltaWidth,0} part of the code, you get {XOffset,0,deltaWidth,0}... I guess in this scaling example the value is negative.

    That is exactly what I thought of 10 mins after making my post. The x offset would be -(deltaWidth)/2. The bit that confused me was if I change the area values by hand the dialog window will auto-center without changing the offset, but if I change it using a function I have to add the offset in. I guess the centering code only looks at the initial values for the area, not the current values.

    Also does anyone know how I can trigger the UI to refresh on a change of window size? If I resize the game window the dialog width does not change with it until I refresh with F5.
  • lefreutlefreut Member Posts: 1,462
    edited November 2019
    ***
    Post edited by lefreut on
  • kaldgordkaldgord Member Posts: 29
    Is there any way to enlarge the actual size of the messages box outside of dialogues ? For now i see it as a one line smaller, and i was wondering if its possible to make it larger. Sorry if its the wrong section.
  • cmk24cmk24 Member Posts: 605
    kaldgord said:

    Is there any way to enlarge the actual size of the messages box outside of dialogues ? For now i see it as a one line smaller, and i was wondering if its possible to make it larger. Sorry if its the wrong section.

    I not sure I understand what you are asking, do you mean the vertical size? If so that can be changed in-game by clicking and dragging the top of the dialog window (no need for a mod). The size of the box in a conversation is set by the length of the conversation so the full text can be seen on the screen without a scroll bar.
  • Axl_KrowAxl_Krow Member Posts: 69
    I just wish I could scroll through it by clicking again.
Sign In or Register to comment.