/
igui.h
83 lines (65 loc) · 1.95 KB
/
igui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#pragma once
#include <vector>
#include <string>
#include "imodule.h"
namespace gui
{
class Gui;
typedef std::shared_ptr<Gui> GuiPtr;
enum GuiType
{
NOT_LOADED_YET, // no attempt to load the GUI has been made
UNDETERMINED, // not checked yet for type
ONE_SIDED_READABLE, // 1-sided
TWO_SIDED_READABLE, // 2-sided
NO_READABLE, // not a readable
IMPORT_FAILURE, // failed to load
FILE_NOT_FOUND, // file doesn't exist
};
/**
* greebo: Interface managing the idTech4 GUI files,
* keeping track of all the loaded GUIs,
* parsing the .gui files on demand.
*/
class IGuiManager :
public RegisterableModule
{
public:
typedef std::vector<std::string> StringList;
// A visitor class used to traverse all known GUIs by path
class Visitor
{
public:
virtual ~Visitor() {}
virtual void visit(const std::string& guiPath, const GuiType& guiType) = 0;
};
public:
virtual ~IGuiManager() {}
// Gets a GUI from the given VFS path, parsing it on demand
// Returns NULL if the GUI couldn't be found or loaded.
virtual GuiPtr getGui(const std::string& guiPath) = 0;
// Returns the number of known GUIs (or GUI paths)
virtual std::size_t getNumGuis() = 0;
// Traverse all known GUIs using the given Visitor
virtual void foreachGui(Visitor& visitor) = 0;
// Returns the GUI appearance type for the given GUI path
virtual GuiType getGuiType(const std::string& guiPath) = 0;
// Reload the gui
virtual void reloadGui(const std::string& guiPath) = 0;
// Returns the _errorList for use in a GUI.
virtual const StringList& getErrorList() = 0;
// Clears out the GUIs and reloads them
virtual void reloadGuis() = 0;
};
}
const char* const MODULE_GUIMANAGER("GuiManager");
// Application-wide Accessor to the global GUI manager
inline gui::IGuiManager& GlobalGuiManager()
{
// Cache the reference locally
static gui::IGuiManager& _manager(
*std::static_pointer_cast<gui::IGuiManager>(
module::GlobalModuleRegistry().getModule(MODULE_GUIMANAGER))
);
return _manager;
}