Page 1 of 1
Issue with SE_MsgBox
Posted: Fri Feb 10, 2023 5:26 pm
by vonotha
I'm not certain whether this should be posted as a suggestion or an error.
Please add some way to set the form of the message window displayed by SE_MsgBox.
Occassionally, the current message box has problems displaying even a relatively short text:

- msgbox.jpg (11.67 KiB) Viewed 1561 times
Code used to display this window:
Code: Select all
message = 'Event: '.. event_description.. '\nUnit ['.. unit.name.. '] - '.. unit.type.. ', '.. unit.classname.. '\n'.. 'IFF= '..iff.. '\n'.. unit.guid
ScenEdit_MsgBox( message, 0 )
Sometimes, the message box works as expected. Even if message contains more empty lines:

- msgbox2.jpg (14.04 KiB) Viewed 1561 times
Re: Issue with SE_MsgBox
Posted: Fri Feb 10, 2023 6:13 pm
by KnightHawk75
use padding to get the size\layout you want, least that used to work in 1147.x (though probably always depending on someones resolution anyway) does it not anymore?
Re: Issue with SE_MsgBox
Posted: Sun Feb 12, 2023 11:58 pm
by vonotha
KnightHawk75 wrote: Fri Feb 10, 2023 6:13 pm
use padding to get the size\layout you want, least that used to work in 1147.x (though probably always depending on someones resolution anyway) does it not anymore?
I'm not familiar with padding in this case. Can you explain, please?
As for the resolution, I'm using 4K.
Re: Issue with SE_MsgBox
Posted: Mon Feb 13, 2023 1:12 pm
by KnightHawk75
padding... adding blank chars to above,below,left,right such that it results in the display appearing more like you want.
Re: Issue with SE_MsgBox
Posted: Mon Feb 13, 2023 3:02 pm
by vonotha
KnightHawk75 wrote: Mon Feb 13, 2023 1:12 pm
padding... adding blank chars to above,below,left,right such that it results in the display appearing more like you want.
Thank you very much for the suggestion. I've added additional spaces where possible, but it failed

- padding_test2.jpg (11.85 KiB) Viewed 1511 times
The code I'm using:
Code: Select all
-- action: present event triggering unit
ScenEdit_UseAttachment('Lua script: common.lua')
unit = ScenEdit_UnitX()
event_description = 'UNKNOWN EVENT'
event = EventX()
if event ~= nil then
event_description = tostring( event.description )
end
if (unit ~= nil) and (unit.guid ~= nil) then
iff = GetUnitIFF( unit )
message = ' Event: '.. event_description.. ' \nUnit [ '.. unit.name.. ' ] - '.. unit.type.. ' , '.. unit.classname.. ' \n '.. 'IFF= '..iff.. ' \n '.. unit.guid.. ' '
ScenEdit_MsgBox( message, 0 )
unit = nil
else
print('ERROR: unit not recognized')
end
I've added blank chars (spaces) at the begining and at the end of every text element, as well as at the end of the message.
Did I miss something?
Re: Issue with SE_MsgBox
Posted: Tue Feb 14, 2023 3:05 pm
by KnightHawk75
The following runs consistently for me on my setup, it's not clear if you wanted empty lines between them or not so I showed both.
Code: Select all
local function testme(a)
if a == nil then a = false; end
local unit = ScenEdit_GetUnit({name='3MN-1 Bison B [Bomber]', guid='4FH7PU-0HMOEHD2GN2HM'});
local event_description = 'UNKNOWN EVENT';
local iff = 'SIGMA';
local fmt;
if a then
fmt = 'Event: %s\r\n\r\nUnit: [%s] - %s , %s\r\n\r\nIFF: %s\r\n\r\nGUID: %s\r\n\r\nAlt: %s\r\n\r\nSpeed: %s\r\n'
else
fmt = 'Event: %s\r\nUnit: [%s] - %s , %s\r\nIFF: %s\r\nGUID: %s\r\nAlt: %s\r\nSpeed: %s\r\n'
end
local msg = string.format(fmt,event_description,unit.name,unit.type,unit.classname,iff,unit.guid,unit.altitude,unit.speed);
return msg
end
ScenEdit_MsgBox(testme(true),0);
ScenEdit_MsgBox(testme(false),0);
ScenEdit_InputBox(testme(true));
ScenEdit_InputBox(testme(false));
produces:

- cmo_msgbox.jpg (30.15 KiB) Viewed 1494 times

- cmo_msgbox_noempty.jpg (28.86 KiB) Viewed 1494 times

- cmo_inputbox.jpg (33.04 KiB) Viewed 1494 times

- cmo_inputbox_noempty.jpg (32.04 KiB) Viewed 1494 times
At present there is no getting around the annoying forced wrapping that happens anywhere between char's 32-xx depending on char codes used, though most a-z-0-9 + space and standard symbols combos will break between 34-48 depending on spacing and actual space used by each char. If you want flexibility use SpecialMessage, of course you can't get any player input from them. Also, msgbox's inside events aren't a great idea unless you really need to halt execution and have the player decide something with a yes\no\cancel sort of response, or are just debugging.
Your code with double spacing, and correct var declarations (remove a set of \r \n to remove empty lines):
Code: Select all
-- action: present event triggering unit
ScenEdit_UseAttachment('Lua script: common.lua') --if so common why are they not global already and loaded at scene load?
local unit = ScenEdit_UnitX();
local event_description = 'UNKNOWN EVENT';
local event = EventX();
if event ~= nil then
event_description = tostring( event.description );
end
if (unit ~= nil) and (unit.guid ~= nil) then
local iff = GetUnitIFF(unit);
local message = string.format('Event: %s\r\n\r\nUnit: [ %s ] - %s, %s\r\n\r\nIFF: %s\r\n\r\nguid: %s\n\r',event_description,unit.name,unit.type,unit.classname,iff,unit.guid);
ScenEdit_MsgBox( message, 0 );
unit = nil
else
print('ERROR: unit not recognized');
end
Re: Issue with SE_MsgBox
Posted: Tue Feb 14, 2023 3:24 pm
by vonotha
KnightHawk75 wrote: Tue Feb 14, 2023 3:05 pm
The following runs consistently for me on my setup...
Thank you very much for detailed information. I'm going to try all you suggestions as soon as possible.
Re: Issue with SE_MsgBox
Posted: Sun Sep 03, 2023 1:12 pm
by Parel803
Good afternoon,
on 1328.9
I tried the message box with the first KH text but do not get the same result. Is the box a fixed size? Or can it adjust?
Same for the inputBox. Not important have to keep text small but curious.
regards GJ

- 1.jpg (10.16 KiB) Viewed 1379 times

- 2.jpg (12.89 KiB) Viewed 1379 times
Re: Issue with SE_MsgBox
Posted: Sun Sep 17, 2023 9:35 am
by KnightHawk75
@parel803
I couldn't tell you as it relates to x64 builds (132x.x), just x32 1307.19 and prior with regard to where to seems to wrap etc.
Re: Issue with SE_MsgBox
Posted: Sun Sep 17, 2023 1:41 pm
by Parel803
KH,
Thank you for your time and answer.
regards GJ