kovvalsky 13 Posted September 29, 2014 Hi, im trying to do a messageBox Dialog control. I have one dialog called "FirstDialog" and i need to ask something to the player inside "FirstDialog".. so i make another dialog called "MsgBox_Dialog". (maybe this is the problem.. dont know) Both are defined in description.ext like class "FirstDialog" { class controls { blah, blah }; }; class MsgBox_Dialog { idd = 5000; duration = 7200; onLoad = ""; controls[]= { DMLS_MsgBox_Frame, DMLS_MsgBox_Fondo, DMLS_MsgBox_Pregunta, DMLS_MsgBox_Btn0, DMLS_MsgBox_Btn1, DMLS_MsgBox_Btn2 }; class DMLS_MsgBox_Frame: IGUIBack { idc = 5010; x = 0.293752 * safezoneW + safezoneX; y = 0.357047 * safezoneH + safezoneY; w = 0.412495 * safezoneW; h = 0.263914 * safezoneH; }; class DMLS_MsgBox_Fondo: RscFrame { idc = 5011; x = 0.293752 * safezoneW + safezoneX; y = 0.357047 * safezoneH + safezoneY; w = 0.412495 * safezoneW; h = 0.263914 * safezoneH; }; class DMLS_MsgBox_Pregunta: RscStructuredText { idc = 5001; x = 0.304065 * safezoneW + safezoneX; y = 0.37904 * safezoneH + safezoneY; w = 0.39187 * safezoneW; h = 0.175943 * safezoneH; }; class DMLS_MsgBox_Btn0: RscButton { idc = 5020; x = 0.613436 * safezoneW + safezoneX; y = 0.565978 * safezoneH + safezoneY; w = 0.082499 * safezoneW; h = 0.0439856 * safezoneH; }; class DMLS_MsgBox_Btn1: RscButton { idc = 5021; x = 0.510312 * safezoneW + safezoneX; y = 0.565978 * safezoneH + safezoneY; w = 0.082499 * safezoneW; h = 0.0439856 * safezoneH; }; class DMLS_MsgBox_Btn2: RscButton { idc = 5022; x = 0.304065 * safezoneW + safezoneX; y = 0.565978 * safezoneH + safezoneY; w = 0.185623 * safezoneW; h = 0.0439856 * safezoneH; }; }; i make a function to call it: class CfgFunctions { class CAOE { class logic { class MsgBox {}; }; }; }; CAOE_fnc_MsgBox.sqf /* ------------------------------------------------------------------------------ FUNCION: CAOE_fnc_MsgBox ------------------------------------------------------------------------------ DESCRIPCION: Crea un msgBox ------------------------------------------------------------------------------ PARAMETROS: 0: [sTRING] structured text - question 1: [sTRING] Button 1 2: [sTRING] (Optional) Button 2 3: [sTRING] (Optional) Button 3 ------------------------------------------------------------------------------ RETURN: [sTRING] Button selected ------------------------------------------------------------------------------- EXAMPLE: _Msg = "<t size='2' color='#FF0000' align='center' underline='true'>ATENTION</t><br/><t size='1.25' color='#FFFFFF'>You are a code master?</t>"; _Return = [_Msg,"Yes","No"] call CAOE_fnc_MsgBox; ------------------------------------------------------------------------------ */ private["_Contenido","_Btn0","_Btn1","_Btn2","_Retorna"]; _Contenido =[_this,0,"",[""]] call BIS_fnc_param; _Btn0 = [_this,1,"",[""]] call BIS_fnc_param; _Btn1 = [_this,2,"",[""]] call BIS_fnc_param; _Btn2 = [_this,3,"",[""]] call BIS_fnc_param; _msgBoxDialog = createDialog "MsgBox_Dialog"; waitUntil {_msgBoxDialog}; _TextCtrl = (findDisplay 5000 displayCtrl 5001); _Btn0Ctrl = (findDisplay 5000 displayCtrl 5020); _Btn1Ctrl = (findDisplay 5000 displayCtrl 5021); _Btn2Ctrl = (findDisplay 5000 displayCtrl 5022); _TextCtrl ctrlSetStructuredText parseText _Contenido; uiNamespace setVariable ["msgBox","-1"]; switch (true) Do { case (_Btn0 != "" && _Btn1 == "" && _Btn2 == ""): { _Btn0Ctrl ctrlSetText _Btn0; _Btn0Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn0]}]; //TODO: I need to close dialog when choose an option _Btn1Ctrl ctrlShow false; _Btn2Ctrl ctrlShow false; }; case (_Btn0 != "" && _Btn1 != "" && _Btn2 == ""): { _Btn0Ctrl ctrlSetText _Btn0; _Btn0Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn0]}]; //TODO: I need to close the dialog when choose an option _Btn1Ctrl ctrlSetText _Btn1; _Btn1Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn1]}]; //TODO: I need to close the dialog when choose an option _Btn2Ctrl ctrlShow false; }; case (_Btn0 != "" && _Btn1 != "" && _Btn2 != ""): { _Btn0Ctrl ctrlSetText _Btn0; _Btn0Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn0]}]; //TODO: I need to close the dialog when choose an option _Btn1Ctrl ctrlSetText _Btn1; _Btn1Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn1]}]; //TODO: I need to close the dialog when choose an option _Btn2Ctrl ctrlSetText _Btn2; _Btn2Ctrl ctrlAddEventHandler ["onMouseButtonClick",{uiNamespace setVariable ["msgBox",_Btn2]}]; //TODO: I need to close the dialog when choose an option }; }; waitUntil {!dialog}; //ERROR ON THIS LINE _Retorna = uiNamespace getVariable ("msgBox"); _Retorna; and finally i call the function: _Msg = "<t size='2' color='#FF0000' align='center' underline='true'>ATENTION</t><br/><t size='1.25' color='#FFFFFF'>You are a code master?</t>"; _return = [_Msg,"Yes","No"] call CAOE_fnc_MsgBox; if (_return == "Yes") then { hint str("I'm a codemaster"); } else { hint str("I need help"); }; The problem is the waitUntil command at the end of CAOE_fnc_MsgBox.sqf.. doesn't work and i don't know why. Is there any way to do this? or any template to use? or something? thanks!! Share this post Link to post Share on other sites
dreadedentity 278 Posted September 29, 2014 (edited) What is the error? I'm assuming that GUI's are a non-scheduled environment (Cannot use sleep, uiSleep, or waitUntil since the suspend script operation). A very informative explanation of scheduled & non-scheduled can be found on the documentation page for call (scroll down to Notes) One last thing, duration and onLoad are not required parameters, but you may want to add movingenabled = false;. If you don't need them, just take them out. Also, you didn't have to make custom functions, a simple createDialog would suffice, unless you need to pass parameters to the dialog. Edited September 29, 2014 by DreadedEntity Share this post Link to post Share on other sites
kovvalsky 13 Posted September 29, 2014 (edited) thanks DreadedEntity. i take look to that.. but when i call "FirstDialog" i use this: pasedTo_AddActionScript.sqf createDialog "FirstDialog"; waitUntil {dialog}; 0 = [] spawn { private ["_comboCtrl","_listCtrl","_treeCtrl"]; disableSerialization; _comboCtrl = (findDisplay 4000 displayCtrl 4001); _listCtrl = (findDisplay 4000 displayCtrl 4002); _treeCtrl = (findDisplay 4000 displayCtrl 4021); ... ... }; inside _listCtrl i have a onLBDblClick = "[_this] call CAOE_fnc_ConfigureThings;" ctrlEventHandler. And inside fn_ConfigureThings.sqf i call the msgBox with another call structure: [font=Courier New] pasedTo_AddActionScript.sqf [color="#008000"]* First call using Spawn[/color] 0 = Spawn [ [color="#008000"] * 2ond call using CtrlEventHandler (function called is defined in description.ext)[/color] call CAOE_fnc_ConfigureThings [ [color="#008000"] * 3th call using a function defined in desc.ext too[/color] call CAOE_fnc_MsgBox [ [color="#FF0000"]waitUntil Error[/color] ] } ] [/font] is a scheduled env? Edited September 29, 2014 by KoVValsky Share this post Link to post Share on other sites
kovvalsky 13 Posted September 29, 2014 Aargh .. I have not found the solution yet I will use "BIS_fnc_guiMessage" instead.. Share this post Link to post Share on other sites
iceman77 18 Posted September 29, 2014 (edited) I'm not entirely sure what you're trying to do. Aside from displaying a hint (after clicking a button?) and changing text. Anyhow, I've written and simplified a yes/no message box based on what you've posted. Edited September 29, 2014 by Iceman77 Share this post Link to post Share on other sites
kovvalsky 13 Posted September 30, 2014 hi Iceman77, thankyou very much! i try to explain it. I have a UI Dialog (shop) with two lists. When you buy a item, i need to ask to the player something using a Yes/No dialog, but in some cases i need more options to ask (Yes/No/Add to...) so i try to make a custom msgBox dialog with no success.. Anyway i will send my mission as soon as possible Share this post Link to post Share on other sites