ZNorQ 0 Posted December 19, 2011 I'm creating a few dialogs for some missions, and often I need to have a common handle for the IDD / IDC that works both in the description.ext and for the script files (sqf). The way I do it now, is to define the IDD in the stringTable (xml); <Key ID="NSF4_DLG_GAMEMASTER"><English>1000</English></Key> <Key ID="NSF4_DLG_HACKER"><English>2000</English></Key> ..etc.. ... and the same for their IDCs; <Key ID="NSF4_DLG_GAMEMASTER_QUIT"><English>1</English></Key> <Key ID="NSF4_DLG_GAMEMASTER_APPLY"><English>2</English></Key> ..etc. In the description.ext, the idd/idc contain the following code; idd = __EVAL(parseNumber localize "NSF4_DLG_GAMEMASTER";); idc = __EVAL(parseNumber localize "NSF4_DLG_GAMEMASTER" + parseNumber localize "NSF4_DLG_GAMEMASTER_QUIT"; ); The scripts (sqf) would then use basically the same code as in the "idc=" section to manipulate/handle control elements; ctrlSetText[(parseNumber localize "NSF4_DLG_GAMEMASTER" + parseNumber localize "NSF4_DLG_GAMEMASTER_QUIT"), "The title changed!"]; I use this method to have a common handle, and I only update the actual IDD/IDC values in one place - the stringTable.. By the way, I use macroes (#define) to reduse the code lengths, often the macro function - ie. #define getIDC(parIDD, parIDC) (parseNumber localize #parIDD + parseNumber localize #parIDC) Is this a good way to do it, or could it be done in an even easier/better way? ZNorQ PS! I've searched for answers before I posted this message, so, if your answer is "this been discussed <insert number here> before", please don't bother answering at all... Share this post Link to post Share on other sites
nuxil 2 Posted December 19, 2011 heh this is a new variant of defining idd/idc's i would just put them in a hpp or a sqf file instead and include them in the scripts which needs them. or make them global vars. you could put them in a in a sqf file which sets them as global vars. example "my_dlg_def.sqf" Dlg1_idd=1000; Dlg2_idd=1001; Dlg3_idd=1002; Dlg_mytextbox1_idc = 2000; Dlg_mytextbox2_idc = 2001; then in init or some other script #include "my_dlg_def.sqf" if your only going to use one language i wount even bother using the stringTable file for this. it also looks verry weird. and it not really meant to for this. altho nothing wrong with doing it. except it its a weird methode. i would probealy even not define the idd's but have them static in the dialog file. but thats a matter of choice. ctrlSetText [NSF4_DLG_GAMEMASTER, "Hello world"]; vs ctrlSetText[parseNumber localize "NSF4_DLG_GAMEMASTER", "Hello World"]; you pic the easyest one :) Share this post Link to post Share on other sites
xeno 234 Posted December 19, 2011 Instead of idd use uiNamespace setVariable for your dialog references in the onLoad event of a dialog. Example: idd=-1; onLoad="uiNamespace setVariable ['ZNorQ_Somedialog', _this select 0]"; onUnLoad="uiNamespace setVariable ['ZNorQ_Somedialog', nil]"; Now you can access the dialog reference in a script with _znorqdialog = uiNamespace getVariable "ZNorQ_Somedialog"; (_znorqdialog displayCtrl someidc) ctrlSetText "bla"; Xeno Share this post Link to post Share on other sites
ZNorQ 0 Posted December 19, 2011 Thanks for the feedback nuxil. The last time I worked with dialogs, was for the OFP engine, so I guess I'm dragging all my bad habits (and the lack of functionality in OFP) over to A2OA.. :p What I'm trying to avoid is having to code/"synchronize" 2 sets of declarations - one for sqf and one for ext; that's why I chose that method. By the way, I know string-tables are used for multilingual support. :) If I understand you correctly, I could use 1 #include file (which contain a common handle for each IDD/IDC element) both in the ext and sqf files? If that is so, I can see that my method would appear pretty strange.. Oo And yes, I'm avoiding using IDD - I don't see any use for it, other than making sure the IDC are unique (again, I'm basing my assumptions on OFP engine, so the question is really if the IDC don't have to be unique for the A2:OA engine?) ---------- Post added at 01:49 PM ---------- Previous post was at 01:44 PM ---------- Instead of idd use uiNamespace setVariable for your dialog references in the onLoad event of a dialog.Example: idd=-1; onLoad="uiNamespace setVariable ['ZNorQ_Somedialog', _this select 0]"; onUnLoad="uiNamespace setVariable ['ZNorQ_Somedialog', nil]"; Now you can access the dialog reference in a script with _znorqdialog = uiNamespace getVariable "ZNorQ_Somedialog"; (_znorqdialog displayCtrl someidc) ctrlSetText "bla"; Xeno Hi xeno, Thanks for the feedback, interesting way to do it - will implemend! But still, you have to give reference to the "someidc", which I'm guessing is a constant number? Another thing, can you have duplicate IDCs now over different dialogs? ZNorQ Share this post Link to post Share on other sites
xeno 234 Posted December 19, 2011 (edited) so the question is really if the IDC don't have to be unique for the A2:OA engine?) IDCs don't have to be unique. You can use the same idcs in different dialogs. Which numbers you'll use depends only on your current mood :D (ofc they have to be different in the same dialog). IDDs on the other hand have to be different for each dialog (that's where uiNamespace helps). Xeno Edited December 19, 2011 by Xeno Share this post Link to post Share on other sites
ZNorQ 0 Posted December 19, 2011 IDCs don't have to be unique. You can use the same idcs in different dialogs. Which numbers you'll use depends only on your current mood :DIDDs on the other hand have to be different for each dialog (that's when uiNamespace helps). Xeno IDC != unique; Hehe, gotcha ;) However, in your example, you set IDD = -1, which means that the engine just assigns the next available number then, and you don't have to worry about it...? ZNorQ Share this post Link to post Share on other sites
xeno 234 Posted December 19, 2011 However, in your example, you set IDD = -1, which means that the engine just assigns the next available number then, and you don't have to worry about it...? IDD = -1 just means, no unique ID for the resource. As we do access the dialog with the uiNamespace handle there's no need for it (and therefore you can't get into troubles when another dialog uses the same IDD, for example another addon or another script suite). Xeno Share this post Link to post Share on other sites
ZNorQ 0 Posted December 19, 2011 IDD = -1 just means, no unique ID for the resource. As we do access the dialog with the uiNamespace handle there's no need for it (and therefore you can't get into troubles when another dialog uses the same IDD, for example another addon or another script suite).Xeno Sure is better implementation of dialogs than it was for OFP. But, there is still the issue of IDCs then.. If I'm to manipulate controls in a dialog, I would still have to access the IDC - if I understand you correctly. This means that I would love to have ONE handle - both in sqf and ext. I will try out nuxil's idea, but I'm pretty sure I've tried out that some time ago - and failed... Thanks to both of you guys.. ZNorQ Share this post Link to post Share on other sites
ZNorQ 0 Posted December 27, 2011 I've implemended Xeno's proposal on a combo (idc 127) control, but I'm having great difficulties using the lbSetCurSel function. I'm using the following statement; (_myDialogOpened displayCtrl 127) lbSetCurSel 5; ... But doesn't work.. What might I be doing wrong? ZNorQ Share this post Link to post Share on other sites
ZNorQ 0 Posted December 27, 2011 Forget the request; I'm still learning the scope of local variables... :P (meaning; it works!) Share this post Link to post Share on other sites