]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/meshtex/PluginUI.cpp
Radiant:
[xonotic/netradiant.git] / contrib / meshtex / PluginUI.cpp
1 /**
2  * @file PluginUI.cpp
3  * Implements the PluginUI class.
4  * @ingroup meshtex-ui
5  */
6
7 /*
8  * Copyright 2012 Joel Baxter
9  *
10  * This file is part of MeshTex.
11  *
12  * MeshTex is free software: you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation, either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * MeshTex is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with MeshTex.  If not, see <http://www.gnu.org/licenses/>.
24  */
25
26 #include "PluginUI.h"
27 #include "SetScaleDialog.h"
28 #include "GetInfoDialog.h"
29 #include "GeneralFunctionDialog.h"
30 #include "MainMenu.h"
31
32
33 /**
34  * Default constructor. Instantiate and register the UI elements (main menu
35  * and dialogs)
36  */
37 PluginUI::PluginUI()
38 {
39         PluginUI::singleton = this;
40    // Instantiate and register the Set S/T Scale dialog. We need a non-generic
41    // handle on this one too, because it will be used as input to the Get Info
42    // dialog constructor below.
43    SmartPointer<SetScaleDialog> setScaleDialog(
44       new SetScaleDialog("SetScale"));
45    SmartPointer<GenericDialog> setScaleDialogGeneric(setScaleDialog);
46    RegisterDialog(setScaleDialogGeneric);
47    // Instantiate and register the Get Info dialog. Constructor needs a handle
48    // on the Set S/T Scale dialog (since it may need to send texture info to
49    // it).
50    SmartPointer<GenericDialog> getInfoDialogGeneric(
51       new GetInfoDialog("GetInfo", setScaleDialog));
52    RegisterDialog(getInfoDialogGeneric);
53    // Instantiate and register the General Function dialog.
54    SmartPointer<GenericDialog> genFuncDialogGeneric(
55       new GeneralFunctionDialog("GeneralFunction"));
56    RegisterDialog(genFuncDialogGeneric);
57    // Instantiate and register the main menu. Constructor needs generic
58    // handles on all dialogs (since it may need to raise them).
59    SmartPointer<GenericMainMenu> mainMenuGeneric(
60       new ::MainMenu(setScaleDialogGeneric,
61                      getInfoDialogGeneric,
62                      genFuncDialogGeneric));
63    RegisterMainMenu(mainMenuGeneric);
64 }
65
66 /**
67  * Destructor.
68  */
69 PluginUI::~PluginUI()
70 {
71 }
72
73 PluginUI* PluginUI::singleton = 0;
74 /**
75  * Get the singleton instance of the UI manager. Note that callers should
76  * almost certainly invoke the UIInstance global function instead of using
77  * this method.
78  *
79  * @return Handle to the UI manager instance.
80  */
81 PluginUI&
82 PluginUI::Instance()
83 {
84    //static PluginUI singleton;
85    //return singleton;
86     if(!singleton)
87             singleton = new PluginUI();
88         return *singleton;
89 }
90
91 /**
92  * Get the singleton instance of the UI manager.
93  *
94  * @return Reference to a singleton that implements GenericPluginUI.
95  */
96 GenericPluginUI& UIInstance()
97 {
98    return PluginUI::Instance();
99 }