OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Resources Beta Testing & Submission => Topic started by: i0n0s on 09 Jan 2009, 23:28:41

Title: ION_DialogShowModal
Post by: i0n0s on 09 Jan 2009, 23:28:41
ArmA does support multiple displays, but only the controls of the last item will get drawn.
ION_DialogShowModal (=DSM) is a work-around for this problems.

The controls of the display have to get merged into one display. Then DSM will make sure that only the controls of opened subdialogs (=set of controls) will get drawn and only the last opened subdialog will be active.

How to use DSM:
Code: [Select]
call compile preprocessFileLineNumbers "ION_DialogShowModal.sqf";
Code: [Select]
100 call ION_DSM2_RegisterDisplay;
Code: [Select]
[100, "YesNo", [[], [200, 201, 202, 203, 204, 205, 206], []]] call ION_DSM_RegisterDialog;where the first parameter is the display it belongs too, the second parameter is the identifier for the subdialog, the third parameter is an array of arrays of background, foreground IDCs and the idcs which should allow drag.
Code: [Select]
[100, "Dialog", [], ["nowait"]] call ION_DSM2_ShowModal;where the first parameter is the display, the second the subdialog and the third parameter which get passed to the onShow code.
Code: [Select]
true call ION_DSM2_ModalResult
The DSM will throw exceptions if something goes wrong.
To ensure that nothing goes wrong, please use only the functions from DSM and not createDialog or closeDialog.

Does it work?
Please take a look at the (simple and uncreative) example which is included in the attachment.

Updated to 2.0 Beta:
      Merged Draggable into RegisterDialog
      Changed parameter for RegisterDisplay
      ShowModal has "nowait" parameter for directly return after creating the dialog
      Show now adds a dialog to the open dialogs. The previous active dialogs are still active too.
      Added context menu :D
Updated to 1.2b:
      Fix: After closing a subdialog, only previous enabled controls will get enabled
      Added ION_DSM_GetActive
Updated in 1.1.1b:
      Fix: ION_DSM_Show: Waits until the  subdialog will get shown.
Updated in 1.1b:
      Added ION_DSM_isActive,
      ION_DSM_MakeDraggable,
      ION_DSM_MoveDialog
Title: Re: ION_DialogShowModal
Post by: Spooner on 10 Jan 2009, 00:59:17
Certainly a nice system for making one of the most common dialog workarounds a lot more simple!

Some suggestions (will require more work from the user, so perhaps not that useful for what you are building):
* Perhaps consider using a new term for an i0n0s dialog that is part of a larger BIS dialog. Currently, a dialog is a modal display. Perhaps "sub-dialog"?
* Add a method to allow a given sub-dialog to be draggable.
* Add a method to allow a given sub-dialog to be opened at the cursor position, centre of the screen, or a given XY position.
* Add a method to move a sub-dialog to a given XY position.
* Explain how to add a close button to a sub-dialog.
Title: Re: ION_DialogShowModal
Post by: i0n0s on 23 Jan 2009, 01:00:23
Updated to 1.1b:
Code: [Select]
[IDD, "subdialog", [IDC], {true}] call ION_DSM_MakeDraggable;IDD is the IDD of the display, "subdialog" the identifier of the subdialog, [IDC] an array with the elements, the user has to click to move the subdialog and {true} is an optional parameter to manipulate the clickable area. This is useful when for example only a circle area should be clickable.

Please note that it is recommended to have all controls in the controls[] section of the dialog. Otherwise a control of a disabled subdialog would be on top the background of the current active subdialog.
DSM 1.1 overwrites the following eventhandler handler from:
Background IDCs: OnSetFocus
Draggable IDCs: OnMouseButtonDown, OnMouseMoving, OnMouseButtonUp

Please notice: 1.1b still works with the syntax from 1.0. But this may change over time. But hey, this only interest people using it...[/list]
Title: Re: ION_DialogShowModal
Post by: kju on 23 Jan 2009, 19:00:01
Just started digging into dialogs and controls. So my projects are still too simple to make use of it.
That said great project and very useful.  :good:
Title: Re: ION_DialogShowModal
Post by: Mandoble on 23 Jan 2009, 21:49:58
After testing the example mission several times I got the following error in a tight loop (arma.RPT full of this error):

Error in expression <ON_DSM_Modal find _element > -1) then {
throw "Subdialog already shown";
};
priv>
  Error position: <throw "Subdialog already shown";
};
priv>
  Error
File C:\Users\Administrador\Documents\ArmA\missions\Example.Intro\ION_DialogShowModal.sqf, line 306


This happened to me only once, but it might be worth to have a look at it.

EDIT:
Forgot to add a small "issue", it might be better to have the example mission named ION_DialogShowModal.intro than just Example.intro
Title: Re: ION_DialogShowModal
Post by: i0n0s on 24 Jan 2009, 02:19:57
Hmm,
I didn't encountered that bug. I've only encountered a typo at line 372 which didn't allow to use "noescape".

A modified version with renamed example was added to the first post.
I also made the msgbox draggable. To start dragging simple click on "question".
Title: Re: ION_DialogShowModal
Post by: Mandoble on 08 Feb 2009, 11:09:47
Should we consider this as "ready" for submission or are you planning some updates?
Title: Re: ION_DialogShowModal
Post by: i0n0s on 08 Feb 2009, 11:41:46
Please keep it as beta. I will change it to ready when I release the next version of the RTE.
Title: Re: ION_DialogShowModal
Post by: Mandoble on 08 Feb 2009, 11:45:41
Ok. Is that RTE new version quite close in the time? I just added the latest one to the ED few hours ago understanding that more testing was no really needed.
Title: Re: ION_DialogShowModal
Post by: i0n0s on 08 Feb 2009, 13:22:36
I'm still in the alpha phase and haven't added all the ideas I have.
So it will take it's time.
Title: Re: ION_DialogShowModal
Post by: i0n0s on 25 Feb 2009, 20:58:00
Updated to 1.2b:
      Fix: After closing a subdialog, only previously enabled controls will get enabled
      Added ION_DSM_GetActive
Added in 1.1.1b:
      Fix: ION_DSM_Show: Waits until the subdialog will get shown.
Title: Re: ION_DialogShowModal
Post by: Kremator on 25 Feb 2009, 23:18:24
File is corrupt.  Could you re-up so that I can test ?

Thanks

[TAO] Kremator
Title: Re: ION_DialogShowModal
Post by: Worldeater on 25 Feb 2009, 23:25:50
Hmmm, I could not reproduce the problem. IZArc 3.81 extracts the archive just fine.
Title: Re: ION_DialogShowModal
Post by: i0n0s on 25 Feb 2009, 23:45:06
File works for me too. Which packer do you use?
Title: Re: ION_DialogShowModal
Post by: Kremator on 26 Feb 2009, 01:23:44
Prolly my system.  Even though it said corrupt file it works fine as a file.

[TAO] Kremator
Title: Re: ION_DialogShowModal
Post by: i0n0s on 10 May 2009, 19:52:59
New version:
   2.0 Beta

Changelog:
   Merged Draggable into RegisterDialog
   Changed parameter for RegisterDisplay
   ShowModal has "nowait" parameter for directly return after creating the dialog
   Show now adds a dialog to the open dialogs. The previous active dialogs are still active too.
   Added context menu :D

The parameters have changed. And I've added a context menu.
An example is not included, but here is example code from the RTE:
Code: [Select]
//structure of the context menu array:
_CM_Unit = ["UNIT", //menu identifier
["Edit unit", {
//code which runs after click on the entry
}
],
["Set unit position ...", ["UNIT_POS", //sub menu, structure stays the same
["Up", {}],
["Middle", {}],
["Down", {}],
["Auto", {}]
]],
["Revive unit", {ION_RTE_CM_Unit call ION_RTE_fRevive}],
["Switch to unit", {ION_RTE_CM_Unit call ION_RTE_pSwitchToPlayer}]
];

Code: [Select]
["Unit", _CM_Unit, {
if (_this select 0 == "UNIT") then { //only in main context menu, not in "UNIT_POS" sub menu
if (alive ION_RTE_CM_Unit) then {
(_this select 3) set [1, 2]; //Hide "Revive Unit"
} else {
(_this select 4) set [1, 1]; //Disable "Switch to Unit"
};
};
_this
}] call ION_DSM_CM_Register;