Home   Help Search Login Register  

Author Topic: ION_DialogShowModal  (Read 6090 times)

0 Members and 2 Guests are viewing this topic.

Offline i0n0s

  • Moderator
  • *****
ION_DialogShowModal
« 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:
  • Merge all controls into one display.
  • Give all controls a different IDC.
  • include the 'ION_DialogShowModal.h' in the controls and in the dialog section.
  • Initialize DSM:
Code: [Select]
call compile preprocessFileLineNumbers "ION_DialogShowModal.sqf";
  • Register the display:
Code: [Select]
100 call ION_DSM2_RegisterDisplay;
  • Register all dialogs:
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.
  • To open a subdialog:
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.
  • To close the current open subdialog:
Code: [Select]
true call ION_DSM2_ModalResult
    where true/false is the result of the opened subdialog. If not required use false.

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
« Last Edit: 10 May 2009, 19:43:40 by i0n0s »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: ION_DialogShowModal
« Reply #1 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.
« Last Edit: 10 Jan 2009, 01:07:03 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline i0n0s

  • Moderator
  • *****
Re: ION_DialogShowModal
« Reply #2 on: 23 Jan 2009, 01:00:23 »
Updated to 1.1b:
  • Added ION_DSM_isActive to check if a subdisplay is currently open and active.
  • Added ION_DSM_MakeDraggable which allows to make a subdisplay draggable.
    Example:
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.
    • Added ION_DSM_MoveDialog to move a subdialog to a specific position.
    • Changed parameter of ION_DSM_RegisterDisplay. Instead of [IDD, name] you can now only pass IDD, at least when using a display from an addon. This don't work when having the display in description.ext!
    • Changed parameter of ION_DSM_RegisterDialog: Instead of [IDC] you can now pass [[Background IDC], [Foreground IDC]].
      [Foreground IDC] are the controls which would be in the controls[] section, [Background IDC] are the controls which would be in the controlsBackground[] section. An eventhandler will be added to ensure that the background controls can't gain focus.
    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]

    Offline kju

    • Members
    • *
      • PvPScene - The ArmA II multiplayer community
    Re: ION_DialogShowModal
    « Reply #3 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:

    Offline Mandoble

    • Former Staff
    • ****
      • Grunt ONE and MandoMissile suite
    Re: ION_DialogShowModal
    « Reply #4 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
    « Last Edit: 23 Jan 2009, 21:53:33 by Mandoble »

    Offline i0n0s

    • Moderator
    • *****
    Re: ION_DialogShowModal
    « Reply #5 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".

    Offline Mandoble

    • Former Staff
    • ****
      • Grunt ONE and MandoMissile suite
    Re: ION_DialogShowModal
    « Reply #6 on: 08 Feb 2009, 11:09:47 »
    Should we consider this as "ready" for submission or are you planning some updates?

    Offline i0n0s

    • Moderator
    • *****
    Re: ION_DialogShowModal
    « Reply #7 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.

    Offline Mandoble

    • Former Staff
    • ****
      • Grunt ONE and MandoMissile suite
    Re: ION_DialogShowModal
    « Reply #8 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.

    Offline i0n0s

    • Moderator
    • *****
    Re: ION_DialogShowModal
    « Reply #9 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.

    Offline i0n0s

    • Moderator
    • *****
    Re: ION_DialogShowModal
    « Reply #10 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.

    Offline Kremator

    • Members
    • *
    Re: ION_DialogShowModal
    « Reply #11 on: 25 Feb 2009, 23:18:24 »
    File is corrupt.  Could you re-up so that I can test ?

    Thanks

    [TAO] Kremator

    Offline Worldeater

    • Former Staff
    • ****
    • Suum cuique
    Re: ION_DialogShowModal
    « Reply #12 on: 25 Feb 2009, 23:25:50 »
    Hmmm, I could not reproduce the problem. IZArc 3.81 extracts the archive just fine.
    try { return true; } finally { return false; }

    Offline i0n0s

    • Moderator
    • *****
    Re: ION_DialogShowModal
    « Reply #13 on: 25 Feb 2009, 23:45:06 »
    File works for me too. Which packer do you use?

    Offline Kremator

    • Members
    • *
    Re: ION_DialogShowModal
    « Reply #14 on: 26 Feb 2009, 01:23:44 »
    Prolly my system.  Even though it said corrupt file it works fine as a file.

    [TAO] Kremator