]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/menu/item/modalcontroller.qh
menu: #undef IMPLEMENTATION
[xonotic/xonotic-data.pk3dir.git] / qcsrc / menu / item / modalcontroller.qh
1 #pragma once
2
3 // modal dialog controller
4 // handles a stack of dialog elements
5 // each element can have one of the following states:
6 //   0: hidden (fading out)
7 //   1: visible (zooming in)
8 //   2: greyed out (inactive)
9 // While an animation is running, no item has focus. When an animation is done,
10 // the topmost item gets focus.
11 // The items are assumed to be added in overlapping order, that is, the lowest
12 // window must get added first.
13 //
14 // Possible uses:
15 // - to control a modal dialog:
16 //   - show modal dialog: me.showChild(me, childItem, buttonAbsOrigin, buttonAbsSize, 0) // childItem also gets focus
17 //   - dismiss modal dialog: me.hideChild(me, childItem, 0) // childItem fades out and relinquishes focus
18 //   - show first screen in m_show: me.hideAll(me, 1); me.showChild(me, me.firstChild, '0 0 0', '0 0 0', 1);
19 // - to show a temporary dialog instead of the menu (teamselect): me.hideAll(me, 1); me.showChild(me, teamSelectDialog, '0 0 0', '0 0 0', 1);
20 // - as a tabbed dialog control:
21 //   - to initialize: me.hideAll(me, 1); me.showChild(me, me.firstChild, '0 0 0', '0 0 0', 1);
22 //   - to show a tab: me.hideChild(me, currentTab, 0); me.showChild(me, newTab, buttonAbsOrigin, buttonAbsSize, 0);
23
24 #include "container.qh"
25 CLASS(ModalController, Container)
26         METHOD(ModalController, resizeNotify, void(entity, vector, vector, vector, vector));
27         METHOD(ModalController, draw, void(entity));
28         METHOD(ModalController, showChild, void(entity, entity, vector, vector, float));
29         METHOD(ModalController, hideChild, void(entity, entity, float));
30         METHOD(ModalController, hideAll, void(entity, float));
31         METHOD(ModalController, addItem, void(entity, entity, vector, vector, float));
32         METHOD(ModalController, addTab, void(entity, entity, entity));
33
34         METHOD(ModalController, initializeDialog, void(entity, entity));
35
36         METHOD(ModalController, switchState, void(entity, entity, float, float));
37         ATTRIB(ModalController, origin, vector, '0 0 0')
38         ATTRIB(ModalController, size, vector, '0 0 0')
39         ATTRIB(ModalController, previousButton, entity, NULL)
40         ATTRIB(ModalController, fadedAlpha, float, 0.3)
41 ENDCLASS(ModalController)
42
43 .float ModalController_state;
44 .entity tabSelectingButton;
45 .vector origin;
46 .vector size;
47 void TabButton_Click(entity button, entity tab);         // assumes a button has set the above fields to its own absolute origin, its size, and the tab to activate
48 void DialogOpenButton_Click(entity button, entity tab);  // assumes a button has set the above fields to its own absolute origin, its size, and the tab to activate
49 void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize);
50 void DialogCloseButton_Click(entity button, entity tab); // assumes a button has set the above fields to the tab to close