]> git.xonotic.org Git - xonotic/netradiant.git/blob - contrib/meshtex/PluginUI.cpp
* added MeshTex plugin src to project (can't compile)
[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    // Instantiate and register the Set S/T Scale dialog. We need a non-generic
40    // handle on this one too, because it will be used as input to the Get Info
41    // dialog constructor below.
42    SmartPointer<SetScaleDialog> setScaleDialog(
43       new SetScaleDialog("SetScale"));
44    SmartPointer<GenericDialog> setScaleDialogGeneric(setScaleDialog);
45    RegisterDialog(setScaleDialogGeneric);
46    // Instantiate and register the Get Info dialog. Constructor needs a handle
47    // on the Set S/T Scale dialog (since it may need to send texture info to
48    // it).
49    SmartPointer<GenericDialog> getInfoDialogGeneric(
50       new GetInfoDialog("GetInfo", setScaleDialog));
51    RegisterDialog(getInfoDialogGeneric);
52    // Instantiate and register the General Function dialog.
53    SmartPointer<GenericDialog> genFuncDialogGeneric(
54       new GeneralFunctionDialog("GeneralFunction"));
55    RegisterDialog(genFuncDialogGeneric);
56    // Instantiate and register the main menu. Constructor needs generic
57    // handles on all dialogs (since it may need to raise them).
58    SmartPointer<GenericMainMenu> mainMenuGeneric(
59       new ::MainMenu(setScaleDialogGeneric,
60                      getInfoDialogGeneric,
61                      genFuncDialogGeneric));
62    RegisterMainMenu(mainMenuGeneric);
63 }
64
65 /**
66  * Destructor.
67  */
68 PluginUI::~PluginUI()
69 {
70 }
71
72 /**
73  * Get the singleton instance of the UI manager. Note that callers should
74  * almost certainly invoke the UIInstance global function instead of using
75  * this method.
76  *
77  * @return Handle to the UI manager instance.
78  */
79 PluginUI&
80 PluginUI::Instance()
81 {
82    static PluginUI singleton;
83    return singleton;
84 }
85
86 /**
87  * Get the singleton instance of the UI manager.
88  *
89  * @return Reference to a singleton that implements GenericPluginUI.
90  */
91 GenericPluginUI& UIInstance()
92 {
93    return PluginUI::Instance();
94 }