nguiskin.h
Go to the documentation of this file.00001 #ifndef N_GUISKIN_H 00002 #define N_GUISKIN_H 00003 //------------------------------------------------------------------------------ 00015 #include "kernel/nroot.h" 00016 #include "util/narray.h" 00017 #include "mathlib/rectangle.h" 00018 #include "util/nfixedarray.h" 00019 00020 class nGuiResource; 00021 class nSound3; 00022 00023 //------------------------------------------------------------------------------ 00024 class nGuiSkin : public nRoot 00025 { 00026 public: 00028 nGuiSkin(); 00030 virtual ~nGuiSkin(); 00032 void UnloadUntouchedGuiResources(); 00034 void SetTexturePrefix(const char* prefix); 00036 const char* GetTexturePrefix() const; 00038 void SetTexturePostfix(const char* postfix); 00040 const char* GetTexturePostfix() const; 00042 void SetActiveWindowColor(const vector4& c); 00044 const vector4& GetActiveWindowColor() const; 00046 void SetInactiveWindowColor(const vector4& c); 00048 const vector4& GetInactiveWindowColor() const; 00050 void SetTextColor(const vector4& c); 00052 const vector4& GetTextColor() const; 00054 void SetButtonTextColor(const vector4& c); 00056 const vector4& GetButtonTextColor() const; 00058 void SetTitleTextColor(const vector4& c); 00060 const vector4& GetTitleTextColor() const; 00062 void SetLabelTextColor(const vector4& c); 00064 const vector4& GetLabelTextColor() const; 00066 void SetEntryTextColor(const vector4& c); 00068 const vector4& GetEntryTextColor() const; 00070 void SetMenuTextColor(const vector4& c); 00072 const vector4& GetMenuTextColor() const; 00074 void SetWindowBorder(const rectangle& v); 00076 const rectangle& GetWindowBorder() const; 00078 void SetWindowFont(const char* fnt); 00080 const char* GetWindowFont() const; 00082 void SetButtonFont(const char* fnt); 00084 const char* GetButtonFont() const; 00086 void SetLabelFont(const char* fnt); 00088 const char* GetLabelFont() const; 00090 void BeginBrushes(); 00092 void AddBrush(const char* name, const char* tex, const vector2& uvPos, const vector2& uvSize, const vector4& color); 00094 void AddDynamicBrush(const char* name, int width, int height); 00096 void EndBrushes(); 00098 nGuiResource* FindBrush(const char* name); 00100 void AddSoundObject(const char* name, const char* filename); 00102 nSound3* GetSoundObject(const char* name); 00104 const char* GetSound(const char* name) const; 00106 void SetSoundVolume(const char* name, float volume); 00108 float GetSoundVolume(const char* name); 00109 00110 private: 00112 void ValidateBrush(nGuiResource* res); 00113 00114 nArray<nGuiResource> brushes; 00115 nString texPrefix; 00116 nString texPostfix; 00117 vector4 activeWindowColor; 00118 vector4 inactiveWindowColor; 00119 vector4 titleTextColor; 00120 vector4 buttonTextColor; 00121 vector4 labelTextColor; 00122 vector4 entryTextColor; 00123 vector4 textColor; 00124 vector4 menuTextColor; 00125 rectangle windowBorder; 00126 00127 nString windowFont; 00128 nString buttonFont; 00129 nString labelFont; 00130 00131 nArray<nString> soundNames; 00132 nArray<nRef<nSound3> > sounds; 00133 }; 00134 00135 00136 //------------------------------------------------------------------------------ 00139 inline 00140 void 00141 nGuiSkin::SetEntryTextColor(const vector4& c) 00142 { 00143 this->entryTextColor = c; 00144 } 00145 00146 //------------------------------------------------------------------------------ 00149 inline 00150 const vector4& 00151 nGuiSkin::GetEntryTextColor() const 00152 { 00153 return this->entryTextColor; 00154 } 00155 00156 //------------------------------------------------------------------------------ 00159 inline 00160 void 00161 nGuiSkin::SetLabelTextColor(const vector4& c) 00162 { 00163 this->labelTextColor = c; 00164 } 00165 00166 //------------------------------------------------------------------------------ 00169 inline 00170 const vector4& 00171 nGuiSkin::GetLabelTextColor() const 00172 { 00173 return this->labelTextColor; 00174 } 00175 00176 //------------------------------------------------------------------------------ 00179 inline 00180 void 00181 nGuiSkin::SetTitleTextColor(const vector4& c) 00182 { 00183 this->titleTextColor = c; 00184 } 00185 00186 //------------------------------------------------------------------------------ 00189 inline 00190 const vector4& 00191 nGuiSkin::GetTitleTextColor() const 00192 { 00193 return this->titleTextColor; 00194 } 00195 00196 //------------------------------------------------------------------------------ 00199 inline 00200 void 00201 nGuiSkin::SetButtonTextColor(const vector4& c) 00202 { 00203 this->buttonTextColor = c; 00204 } 00205 00206 //------------------------------------------------------------------------------ 00209 inline 00210 const vector4& 00211 nGuiSkin::GetButtonTextColor() const 00212 { 00213 return this->buttonTextColor; 00214 } 00215 00216 //------------------------------------------------------------------------------ 00219 inline 00220 void 00221 nGuiSkin::SetTextColor(const vector4& c) 00222 { 00223 this->textColor = c; 00224 } 00225 00226 //------------------------------------------------------------------------------ 00229 inline 00230 const vector4& 00231 nGuiSkin::GetTextColor() const 00232 { 00233 return this->textColor; 00234 } 00235 00236 //------------------------------------------------------------------------------ 00239 inline 00240 void 00241 nGuiSkin::SetMenuTextColor(const vector4& c) 00242 { 00243 this->menuTextColor = c; 00244 } 00245 00246 //------------------------------------------------------------------------------ 00249 inline 00250 const vector4& 00251 nGuiSkin::GetMenuTextColor() const 00252 { 00253 return this->menuTextColor; 00254 } 00255 00256 //------------------------------------------------------------------------------ 00259 inline 00260 void 00261 nGuiSkin::SetWindowBorder(const rectangle& r) 00262 { 00263 this->windowBorder = r; 00264 } 00265 00266 //------------------------------------------------------------------------------ 00269 inline 00270 const rectangle& 00271 nGuiSkin::GetWindowBorder() const 00272 { 00273 return this->windowBorder; 00274 } 00275 00276 //------------------------------------------------------------------------------ 00279 inline 00280 void 00281 nGuiSkin::SetTexturePrefix(const char* prefix) 00282 { 00283 this->texPrefix = prefix; 00284 } 00285 00286 //------------------------------------------------------------------------------ 00289 inline 00290 const char* 00291 nGuiSkin::GetTexturePrefix() const 00292 { 00293 return this->texPrefix.Get(); 00294 } 00295 00296 //------------------------------------------------------------------------------ 00299 inline 00300 void 00301 nGuiSkin::SetTexturePostfix(const char* postfix) 00302 { 00303 this->texPostfix = postfix; 00304 } 00305 00306 //------------------------------------------------------------------------------ 00309 inline 00310 const char* 00311 nGuiSkin::GetTexturePostfix() const 00312 { 00313 return this->texPostfix.Get(); 00314 } 00315 00316 //------------------------------------------------------------------------------ 00319 inline 00320 void 00321 nGuiSkin::SetActiveWindowColor(const vector4& c) 00322 { 00323 this->activeWindowColor = c; 00324 } 00325 00326 //------------------------------------------------------------------------------ 00329 inline 00330 const vector4& 00331 nGuiSkin::GetActiveWindowColor() const 00332 { 00333 return this->activeWindowColor; 00334 } 00335 00336 //------------------------------------------------------------------------------ 00339 inline 00340 void 00341 nGuiSkin::SetInactiveWindowColor(const vector4& c) 00342 { 00343 this->inactiveWindowColor = c; 00344 } 00345 00346 //------------------------------------------------------------------------------ 00349 inline 00350 const vector4& 00351 nGuiSkin::GetInactiveWindowColor() const 00352 { 00353 return this->inactiveWindowColor; 00354 } 00355 00356 //------------------------------------------------------------------------------ 00359 inline 00360 void 00361 nGuiSkin::SetWindowFont(const char* fnt) 00362 { 00363 n_assert(fnt); 00364 this->windowFont = fnt; 00365 } 00366 00367 //------------------------------------------------------------------------------ 00370 inline 00371 const char* 00372 nGuiSkin::GetWindowFont() const 00373 { 00374 return this->windowFont.Get(); 00375 } 00376 00377 //------------------------------------------------------------------------------ 00380 inline 00381 void 00382 nGuiSkin::SetButtonFont(const char* fnt) 00383 { 00384 n_assert(fnt); 00385 this->buttonFont = fnt; 00386 } 00387 00388 //------------------------------------------------------------------------------ 00391 inline 00392 const char* 00393 nGuiSkin::GetButtonFont() const 00394 { 00395 return this->buttonFont.Get(); 00396 } 00397 00398 //------------------------------------------------------------------------------ 00401 inline 00402 void 00403 nGuiSkin::SetLabelFont(const char* fnt) 00404 { 00405 n_assert(fnt); 00406 this->labelFont = fnt; 00407 } 00408 00409 //------------------------------------------------------------------------------ 00412 inline 00413 const char* 00414 nGuiSkin::GetLabelFont() const 00415 { 00416 return this->labelFont.Get(); 00417 } 00418 00419 //------------------------------------------------------------------------------ 00420 #endif 00421