ScummVM API documentation
Gui.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * Copyright (C) 2006-2010 - Frictional Games
24  *
25  * This file is part of HPL1 Engine.
26  */
27 
28 #ifndef HPL_GUI_H
29 #define HPL_GUI_H
30 
31 #include "hpl1/engine/game/Updateable.h"
32 
33 #include "hpl1/engine/gui/GuiTypes.h"
34 #include "hpl1/engine/system/SystemTypes.h"
35 #include "common/stablemap.h"
36 
37 namespace hpl {
38 
39 class cResources;
40 class cGraphics;
41 class cSound;
42 class cScene;
43 
44 class cGuiSet;
45 class cGuiSkin;
46 class cGuiGfxElement;
47 
48 class iGuiMaterial;
49 
50 //------------------------------------------------
51 
52 typedef Common::StableMap<tString, cGuiSet *> tGuiSetMap;
53 typedef tGuiSetMap::iterator tGuiSetMapIt;
54 
55 //-------------------------------------
56 
57 typedef Common::StableMap<tString, cGuiSkin *> tGuiSkinMap;
58 typedef tGuiSkinMap::iterator tGuiSkinMapIt;
59 
60 //-------------------------------------
61 
62 typedef Common::StableMap<tString, eGuiSkinGfx> tGuiSkinGfxMap;
63 typedef tGuiSkinGfxMap::iterator tGuiSkinGfxMapIt;
64 
65 typedef Common::StableMap<tString, eGuiSkinFont> tGuiSkinFontMap;
66 typedef tGuiSkinFontMap::iterator tGuiSkinFontMapIt;
67 
68 typedef Common::StableMap<tString, eGuiSkinAttribute> tGuiSkinAttributeMap;
69 typedef tGuiSkinAttributeMap::iterator tGuiSkinAttributeMapIt;
70 
71 //------------------------------------------------
72 
73 class cGui : public iUpdateable {
74 public:
75  cGui();
76  ~cGui();
77 
79  // General
80 
81  void Init(cResources *apResources, cGraphics *apGraphics,
82  cSound *apSound, cScene *apScene);
83 
84  void Update(float afTimeStep);
85 
86  void OnPostSceneDraw();
87  void OnPostGUIDraw();
88 
89  iGuiMaterial *GetMaterial(eGuiMaterial aType);
90 
92  // Skins
93  cGuiSkin *CreateSkin(const tString &asFile);
94 
95  eGuiSkinGfx GetSkinGfxFromString(const tString &asType);
96  eGuiSkinFont GetSkinFontFromString(const tString &asType);
97  eGuiSkinAttribute GetSkinAttributeFromString(const tString &asType);
98 
100  // Sets
101  cGuiSet *CreateSet(const tString &asName, cGuiSkin *apSkin);
102  cGuiSet *GetSetFromName(const tString &asName);
103  void SetFocus(cGuiSet *apSet);
104  void SetFocusByName(const tString &asSetName);
105  cGuiSet *GetFocusedSet() { return mpSetInFocus; }
106  void DestroySet(cGuiSet *apSet);
107 
109  // Graphics creation
110  cGuiGfxElement *CreateGfxFilledRect(const cColor &aColor, eGuiMaterial aMaterial, bool abAddToList = true);
111  cGuiGfxElement *CreateGfxImage(const tString &asFile, eGuiMaterial aMaterial,
112  const cColor &aColor = cColor(1, 1), bool abAddToList = true);
113  cGuiGfxElement *CreateGfxTexture(const tString &asFile, eGuiMaterial aMaterial,
114  const cColor &aColor = cColor(1, 1), bool abMipMaps = false,
115  bool abAddToList = true);
116  // Loads several images asFile+00, etc. Used for animations.
117  // Must have extension!
118  cGuiGfxElement *CreateGfxImageBuffer(const tString &asFile, eGuiMaterial aMaterial,
119  bool abCreateAnimation = true,
120  const cColor &aColor = cColor(1, 1), bool abAddToList = true);
121 
122  void DestroyGfx(cGuiGfxElement *apGfx);
123 
125  // Input sending
126  bool SendMousePos(const cVector2f &avPos, const cVector2f &avRel);
127  bool SendMouseClickDown(eGuiMouseButton aButton);
128  bool SendMouseClickUp(eGuiMouseButton aButton);
129  bool SendMouseDoubleClick(eGuiMouseButton aButton);
130 
131  bool SendKeyPress(Common::KeyState keyPress);
132 
133  // bool SentArrowKey(eGuiArrowKey aDir);
134 
136  // Properties
137  cResources *GetResources() { return mpResources; }
138 
139 private:
140  void GenerateSkinTypeStrings();
141 
142  cResources *mpResources;
143  cGraphics *mpGraphics;
144  cSound *mpSound;
145  cScene *mpScene;
146 
147  cGuiSet *mpSetInFocus;
148 
149  tGuiSetMap m_mapSets;
150  tGuiSkinMap m_mapSkins;
151 
152  iGuiMaterial *mvMaterials[eGuiMaterial_LastEnum];
153 
154  tGuiGfxElementList mlstGfxElements;
155 
156  tGuiSkinGfxMap m_mapSkinGfxStrings;
157  tGuiSkinFontMap m_mapSkinFontStrings;
158  tGuiSkinAttributeMap m_mapSkinAttributeStrings;
159 
160  unsigned long mlLastRenderTime;
161 };
162 
163 } // namespace hpl
164 
165 #endif // HPL_GUI_H
Definition: AI.h:36
Definition: Gui.h:73
Definition: GuiGfxElement.h:72
Definition: str.h:59
Definition: list.h:44
typename TreeT::BasicIterator iterator
Definition: stablemap.h:48
Definition: Sound.h:40
Definition: GuiSet.h:112
Definition: Updateable.h:35
Definition: GuiSkin.h:59
Definition: Resources.h:160
Definition: keyboard.h:294
Definition: Color.h:37
Definition: Scene.h:61
Definition: GuiMaterial.h:36
Definition: Graphics.h:46