$treeview $search $mathjax
Stratagus
2.2.7
$projectbrief
|
$projectbrief
|
$searchbox |
_________ __ __ / _____// |_____________ _/ |______ ____ __ __ ______ \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ \ /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > \/ \/ \//_____/ \/ ______________________ ______________________ T H E W A R B E G I N S Stratagus - A free fantasy real time strategy game engine
00001 // _________ __ __ 00002 // / _____// |_____________ _/ |______ ____ __ __ ______ 00003 // \_____ \\ __\_ __ \__ \\ __\__ \ / ___\| | \/ ___/ 00004 // / \| | | | \// __ \| | / __ \_/ /_/ > | /\___ | 00005 // /_______ /|__| |__| (____ /__| (____ /\___ /|____//____ > 00006 // \/ \/ \//_____/ \/ 00007 // ______________________ ______________________ 00008 // T H E W A R B E G I N S 00009 // Stratagus - A free fantasy real time strategy game engine 00010 // 00012 // 00013 // (c) Copyright 1999-2007 by Lutz Sammer and Jimmy Salmon 00014 // 00015 // This program is free software; you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation; only version 2 of the License. 00018 // 00019 // This program is distributed in the hope that it will be useful, 00020 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00021 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00022 // GNU General Public License for more details. 00023 // 00024 // You should have received a copy of the GNU General Public License 00025 // along with this program; if not, write to the Free Software 00026 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 00027 // 02111-1307, USA. 00028 // 00029 00030 #ifndef __UI_H__ 00031 #define __UI_H__ 00032 00034 00037 00038 /*---------------------------------------------------------------------------- 00039 -- Includes 00040 ----------------------------------------------------------------------------*/ 00041 00042 #include <vector> 00043 #include <string> 00044 #include <map> 00045 00046 #include "SDL.h" 00047 00048 #ifndef __UPGRADE_STRUCTS_H__ 00049 #include "upgrade_structs.h" 00050 #endif 00051 #ifndef __CURSOR_H__ 00052 #include "cursor.h" 00053 #endif 00054 #ifndef __INTERFACE_H__ 00055 #include "interface.h" 00056 #endif 00057 #ifndef __SCRIPT_H__ 00058 #include "script.h" 00059 #endif 00060 #ifndef __MINIMAP_H__ 00061 #include "minimap.h" 00062 #endif 00063 00064 #include "video.h" 00065 #include "viewport.h" 00066 00067 /*---------------------------------------------------------------------------- 00068 -- Declarations 00069 ----------------------------------------------------------------------------*/ 00070 00071 class CUnit; 00072 class CFile; 00073 class CFont; 00074 class LuaActionListener; 00075 class CPopup; 00076 00077 /*---------------------------------------------------------------------------- 00078 -- Definitions 00079 ----------------------------------------------------------------------------*/ 00080 00081 enum TextAlignment { 00082 TextAlignUndefined, 00083 TextAlignCenter, 00084 TextAlignLeft, 00085 TextAlignRight 00086 }; 00087 00088 class ButtonStyleProperties 00089 { 00090 public: 00091 ButtonStyleProperties() : Sprite(NULL), Frame(0), BorderColor(0), 00092 BorderSize(0), TextAlign(TextAlignUndefined), 00093 TextPos(0, 0) { 00094 BorderColorRGB.r = BorderColorRGB.g = BorderColorRGB.b = 0; 00095 } 00096 00097 CGraphic *Sprite; 00098 int Frame; 00099 SDL_Color BorderColorRGB; 00100 Uint32 BorderColor; 00101 int BorderSize; 00102 TextAlignment TextAlign; 00103 PixelPos TextPos; 00104 std::string TextNormalColor; 00105 std::string TextReverseColor; 00106 }; 00107 00108 class ButtonStyle 00109 { 00110 public: 00111 ButtonStyle() : Width(0), Height(0), Font(0), 00112 TextAlign(TextAlignUndefined), TextX(0), TextY(0) {} 00113 00114 int Width; 00115 int Height; 00116 CFont *Font; 00117 std::string TextNormalColor; 00118 std::string TextReverseColor; 00119 TextAlignment TextAlign; 00120 int TextX; 00121 int TextY; 00122 ButtonStyleProperties Default; 00123 ButtonStyleProperties Hover; 00124 ButtonStyleProperties Clicked; 00125 }; 00126 00128 class CUIButton 00129 { 00130 public: 00131 CUIButton() : X(0), Y(0), Style(NULL), Callback(NULL) {} 00132 ~CUIButton() {} 00133 00134 bool Contains(const PixelPos &screenPos) const; 00135 00136 public: 00137 int X; 00138 int Y; 00139 std::string Text; 00140 ButtonStyle *Style; 00141 LuaActionListener *Callback; 00142 }; 00143 00144 #define MAX_NUM_VIEWPORTS 8 00145 00146 00151 enum ViewportModeType { 00152 VIEWPORT_SINGLE = 0, 00153 VIEWPORT_SPLIT_HORIZ, 00154 VIEWPORT_SPLIT_HORIZ3, 00155 VIEWPORT_SPLIT_VERT, 00156 VIEWPORT_QUAD, 00157 NUM_VIEWPORT_MODES 00158 }; 00159 00160 class CMapArea 00161 { 00162 public: 00163 CMapArea() : X(0), Y(0), EndX(0), EndY(0), 00164 ScrollPaddingLeft(0), ScrollPaddingRight(0), 00165 ScrollPaddingTop(0), ScrollPaddingBottom(0) {} 00166 00167 bool Contains(const PixelPos &screenPos) const; 00168 00169 public: 00170 int X; 00171 int Y; 00172 int EndX; 00173 int EndY; 00174 int ScrollPaddingLeft; 00175 int ScrollPaddingRight; 00176 int ScrollPaddingTop; 00177 int ScrollPaddingBottom; 00178 }; 00179 00183 class ConditionPanel 00184 { 00185 public: 00186 ConditionPanel() : ShowOnlySelected(false), HideNeutral(false), 00187 HideAllied(false), ShowOpponent(false), BoolFlags(NULL), 00188 Variables(NULL) {} 00189 ~ConditionPanel() { 00190 delete[] BoolFlags; 00191 delete[] Variables; 00192 } 00193 00194 bool ShowOnlySelected; 00195 00196 bool HideNeutral; 00197 bool HideAllied; 00198 bool ShowOpponent; 00199 00200 char *BoolFlags; 00201 char *Variables; 00202 }; 00203 00207 class CContentType 00208 { 00209 public: 00210 CContentType() : PosX(0), PosY(0), Condition(NULL) {} 00211 virtual ~CContentType() { delete Condition; } 00212 00214 virtual void Draw(const CUnit &unit, CFont *defaultfont) const = 0; 00215 00216 int PosX; 00217 int PosY; 00218 00219 ConditionPanel *Condition; 00220 }; 00221 00225 class CContentTypeText : public CContentType 00226 { 00227 public: 00228 CContentTypeText() : Text(NULL), Font(NULL), Centered(0), Index(-1), 00229 Component(VariableValue), ShowName(0), Stat(0) {} 00230 virtual ~CContentTypeText() { 00231 FreeStringDesc(Text); 00232 delete Text; 00233 } 00234 00235 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00236 00237 StringDesc *Text; 00238 CFont *Font; 00239 char Centered; 00240 int Index; 00241 EnumVariable Component; 00242 char ShowName; 00243 char Stat; 00244 }; 00245 00249 class CContentTypeFormattedText : public CContentType 00250 { 00251 public: 00252 CContentTypeFormattedText() : Font(NULL), Centered(false), 00253 Index(-1), Component(VariableValue) {} 00254 virtual ~CContentTypeFormattedText() {} 00255 00256 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00257 00258 std::string Format; 00259 CFont *Font; 00260 bool Centered; 00261 int Index; 00262 EnumVariable Component; 00263 }; 00264 00268 class CContentTypeFormattedText2 : public CContentType 00269 { 00270 public: 00271 CContentTypeFormattedText2() : Font(NULL), Centered(false), 00272 Index1(-1), Component1(VariableValue), Index2(-1), Component2(VariableValue) {} 00273 virtual ~CContentTypeFormattedText2() {} 00274 00275 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00276 00277 std::string Format; 00278 CFont *Font; 00279 bool Centered; 00280 int Index1; 00281 EnumVariable Component1; 00282 int Index2; 00283 EnumVariable Component2; 00284 }; 00285 00289 class CContentTypeIcon : public CContentType 00290 { 00291 public: 00292 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00293 00294 EnumUnit UnitRef; 00295 }; 00296 00300 class CContentTypeLifeBar : public CContentType 00301 { 00302 public: 00303 CContentTypeLifeBar() : Index(-1), Width(0), Height(0) {} 00304 00305 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00306 00307 int Index; 00308 int Width; 00309 int Height; 00310 #if 0 // FIXME : something for color and value parametrisation (not implemented) 00311 Color *colors; 00312 int *values; 00313 #endif 00314 }; 00315 00319 class CContentTypeCompleteBar : public CContentType 00320 { 00321 public: 00322 CContentTypeCompleteBar() : Index(-1), Width(0), Height(0), Border(0), Color(0) {} 00323 00324 virtual void Draw(const CUnit &unit, CFont *defaultfont) const; 00325 00326 int Index; 00327 int Width; 00328 int Height; 00329 char Border; 00330 char Color; 00331 }; 00332 00336 class CUnitInfoPanel 00337 { 00338 public: 00339 CUnitInfoPanel() : PosX(0), PosY(0), DefaultFont(0), 00340 Contents(), Condition(NULL) {} 00341 ~CUnitInfoPanel() { 00342 for (std::vector<CContentType *>::iterator content = Contents.begin(); 00343 content != Contents.end(); ++content) { 00344 delete *content; 00345 } 00346 delete Condition; 00347 } 00348 00349 00350 std::string Name; 00351 int PosX; 00352 int PosY; 00353 CFont *DefaultFont; 00354 00355 std::vector<CContentType *>Contents; 00356 00357 ConditionPanel *Condition; 00358 }; 00359 00360 00361 class CFiller 00362 { 00363 struct bits_map { 00364 bits_map() : Width(0), Height(0), bstore(NULL) {} 00365 ~bits_map(); 00366 00367 void Init(CGraphic *g); 00368 00369 bool TransparentPixel(int x, int y) { 00370 if (bstore) { 00371 const unsigned int x_index = x / 32; 00372 y *= Width; 00373 y /= 32; 00374 x -= (x_index * 32); 00375 return ((bstore[y + x_index] & (1 << x)) == 0); 00376 } 00377 return false; 00378 }; 00379 00380 int Width; 00381 int Height; 00382 unsigned int *bstore; 00383 }; 00384 00385 bits_map map; 00386 public: 00387 CFiller() : G(NULL), X(0), Y(0) {} 00388 00389 void Load(); 00390 00391 bool OnGraphic(int x, int y) { 00392 x -= X; 00393 y -= Y; 00394 if (x >= 0 && y >= 0 && x < map.Width && y < map.Height) { 00395 return !map.TransparentPixel(x, y); 00396 } 00397 return false; 00398 } 00399 CGraphic *G; 00400 int X; 00401 int Y; 00402 }; 00403 00404 class CButtonPanel 00405 { 00406 public: 00407 CButtonPanel() : G(NULL), X(0), Y(0), ShowCommandKey(true) { 00408 AutoCastBorderColorRGB.r = 0; 00409 AutoCastBorderColorRGB.g = 0; 00410 AutoCastBorderColorRGB.b = 0; 00411 } 00412 00413 void Draw(); 00414 void Update(); 00415 void DoClicked(int button); 00416 int DoKey(int key); 00417 00418 CGraphic *G; 00419 int X; 00420 int Y; 00421 std::vector<CUIButton> Buttons; 00422 SDL_Color AutoCastBorderColorRGB; 00423 bool ShowCommandKey; 00424 }; 00425 00426 class CPieMenu 00427 { 00428 public: 00429 CPieMenu() : G(NULL), MouseButton(NoButton) { 00430 memset(this->X, 0, sizeof(this->X)); 00431 memset(this->Y, 0, sizeof(this->Y)); 00432 } 00433 00434 CGraphic *G; 00435 int MouseButton; 00436 int X[8]; 00437 int Y[8]; 00438 00439 void SetRadius(int radius) { 00440 const int coeffX[] = { 0, 193, 256, 193, 0, -193, -256, -193}; 00441 const int coeffY[] = { -256, -193, 0, 193, 256, 193, 0, -193}; 00442 for (int i = 0; i < 8; ++i) { 00443 this->X[i] = (coeffX[i] * radius) >> 8; 00444 this->Y[i] = (coeffY[i] * radius) >> 8; 00445 } 00446 } 00447 }; 00448 00450 00451 #define MARGIN_X 4 00452 #define MARGIN_Y 2 00453 00454 class PopupConditionPanel 00455 { 00456 public: 00457 PopupConditionPanel() : HasHint(false), HasDescription(false), BoolFlags(NULL), Variables(NULL) {} 00458 ~PopupConditionPanel() { 00459 delete[] BoolFlags; 00460 delete[] Variables; 00461 } 00462 00463 bool HasHint; 00464 bool HasDescription; 00465 00466 char *BoolFlags; 00467 char *Variables; 00468 }; 00469 00470 class CPopupContentType 00471 { 00472 public: 00473 CPopupContentType() : PosX(0), PosY(0), 00474 MarginX(MARGIN_X), MarginY(MARGIN_Y), MinWidth(0), MinHeight(0), 00475 Wrap(true), Condition(NULL) {} 00476 virtual ~CPopupContentType() { delete Condition; } 00477 00479 virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const = 0; 00481 virtual int GetWidth(const ButtonAction &button, int *Costs) const = 0; 00483 virtual int GetHeight(const ButtonAction &button, int *Costs) const = 0; 00484 00485 int PosX; 00486 int PosY; 00487 int MarginX; 00488 int MarginY; 00489 int MinWidth; 00490 int MinHeight; 00491 bool Wrap; 00492 00493 PopupConditionPanel *Condition; 00494 }; 00495 00496 enum PopupButtonInfo_Types { 00497 PopupButtonInfo_Hint, 00498 PopupButtonInfo_Description 00499 }; 00500 00501 class CPopupContentTypeButtonInfo : public CPopupContentType 00502 { 00503 public: 00504 CPopupContentTypeButtonInfo() : InfoType(0), MaxWidth(0), Font(NULL), Centered(0) {} 00505 virtual ~CPopupContentTypeButtonInfo() {} 00506 00507 virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const; 00508 00509 virtual int GetWidth(const ButtonAction &button, int *Costs) const; 00510 virtual int GetHeight(const ButtonAction &button, int *Costs) const; 00511 00512 int InfoType; 00513 unsigned int MaxWidth; 00514 CFont *Font; 00515 char Centered; 00516 }; 00517 00518 class CPopupContentTypeCosts : public CPopupContentType 00519 { 00520 public: 00521 CPopupContentTypeCosts() : Font(NULL), Centered(0) {} 00522 virtual ~CPopupContentTypeCosts() {} 00523 00524 virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const; 00525 00526 virtual int GetWidth(const ButtonAction &button, int *Costs) const; 00527 virtual int GetHeight(const ButtonAction &button, int *Costs) const; 00528 00529 CFont *Font; 00530 char Centered; 00531 }; 00532 00533 class CPopupContentTypeLine : public CPopupContentType 00534 { 00535 public: 00536 CPopupContentTypeLine() : Color(ColorWhite), Width(0), Height(1) {} 00537 virtual ~CPopupContentTypeLine() {} 00538 00539 virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const; 00540 00541 virtual int GetWidth(const ButtonAction &button, int *Costs) const; 00542 virtual int GetHeight(const ButtonAction &button, int *Costs) const; 00543 00544 Uint32 Color; 00545 unsigned int Width; 00546 unsigned int Height; 00547 }; 00548 00549 class CPopupContentTypeVariable : public CPopupContentType 00550 { 00551 public: 00552 CPopupContentTypeVariable() : Text(NULL), Font(NULL), Centered(0), Index(-1) {} 00553 virtual ~CPopupContentTypeVariable() { 00554 FreeStringDesc(Text); 00555 delete Text; 00556 } 00557 00558 virtual void Draw(int x, int y, const CPopup *popup, const unsigned int popupWidth, const ButtonAction &button, int *Costs) const; 00559 00560 virtual int GetWidth(const ButtonAction &button, int *Costs) const; 00561 virtual int GetHeight(const ButtonAction &button, int *Costs) const; 00562 00563 StringDesc *Text; 00564 CFont *Font; 00565 char Centered; 00566 int Index; 00567 }; 00568 00569 class CPopup 00570 { 00571 public: 00572 CPopup() : Contents(), MarginX(MARGIN_X), MarginY(MARGIN_Y), MinWidth(0), MinHeight(0), 00573 DefaultFont(NULL), BackgroundColor(ColorBlue), BorderColor(ColorWhite) {} 00574 ~CPopup() { 00575 for (std::vector<CPopupContentType *>::iterator content = Contents.begin(); 00576 content != Contents.end(); ++content) { 00577 delete *content; 00578 } 00579 } 00580 00581 std::vector<CPopupContentType *> Contents; 00582 std::string Ident; 00583 int MarginX; 00584 int MarginY; 00585 int MinWidth; 00586 int MinHeight; 00587 CFont *DefaultFont; 00588 Uint32 BackgroundColor; 00589 Uint32 BorderColor; 00590 }; 00591 00592 class CResourceInfo 00593 { 00594 public: 00595 CResourceInfo() : G(NULL), IconFrame(0), IconX(0), IconY(0), IconWidth(-1), 00596 TextX(-1), TextY(-1) {} 00597 00598 CGraphic *G; 00599 int IconFrame; 00600 int IconX; 00601 int IconY; 00602 int IconWidth; 00603 int TextX; 00604 int TextY; 00605 }; 00606 #define MaxResourceInfo MaxCosts + 3 00607 00608 class CInfoPanel 00609 { 00610 public: 00611 CInfoPanel() : G(NULL), X(0), Y(0) {} 00612 00613 void Draw(); 00614 00615 CGraphic *G; 00616 int X; 00617 int Y; 00618 }; 00619 00620 class CStatusLine 00621 { 00622 public: 00623 CStatusLine() : Width(0), TextX(0), TextY(0), Font(0) {} 00624 00625 void Draw(); 00626 void Set(const std::string &status); 00627 inline const std::string &Get() { return this->StatusLine; } 00628 void Clear(); 00629 00630 int Width; 00631 int TextX; 00632 int TextY; 00633 CFont *Font; 00634 00635 private: 00636 std::string StatusLine; 00637 }; 00638 00639 class CUITimer 00640 { 00641 public: 00642 CUITimer() : X(0), Y(0), Font(NULL) {} 00643 00644 int X; 00645 int Y; 00646 CFont *Font; 00647 }; 00648 00649 00653 class CUserInterface 00654 { 00655 public: 00656 CUserInterface(); 00657 ~CUserInterface(); 00658 00659 void Load(); 00660 00661 00662 bool MouseScroll; 00663 bool KeyScroll; 00664 00665 int MouseScrollSpeed; 00667 int MouseScrollSpeedDefault; 00669 int MouseScrollSpeedControl; 00670 00671 PixelPos MouseWarpPos; 00672 00673 std::string NormalFontColor; 00674 std::string ReverseFontColor; 00675 00676 std::vector<CFiller> Fillers; 00677 00678 CResourceInfo Resources[MaxResourceInfo]; 00679 00680 CInfoPanel InfoPanel; 00681 std::vector<CUnitInfoPanel *> InfoPanelContents; 00682 00683 std::vector<CPopup *> ButtonPopups; 00684 00685 CUIButton *SingleSelectedButton; 00686 00687 std::vector<CUIButton> SelectedButtons; 00688 CFont *MaxSelectedFont; 00689 int MaxSelectedTextX; 00690 int MaxSelectedTextY; 00691 00692 CUIButton *SingleTrainingButton; 00693 std::string SingleTrainingText; 00694 CFont *SingleTrainingFont; 00695 int SingleTrainingTextX; 00696 int SingleTrainingTextY; 00697 00698 std::vector<CUIButton> TrainingButtons; 00699 std::string TrainingText; 00700 CFont *TrainingFont; 00701 int TrainingTextX; 00702 int TrainingTextY; 00703 00704 CUIButton *UpgradingButton; 00705 00706 CUIButton *ResearchingButton; 00707 00708 std::vector<CUIButton> TransportingButtons; 00709 00710 // Completed bar 00711 SDL_Color CompletedBarColorRGB; 00712 Uint32 CompletedBarColor; 00713 bool CompletedBarShadow; 00714 00715 // Button panel 00716 CButtonPanel ButtonPanel; 00717 00718 // Pie Menu 00719 CPieMenu PieMenu; 00720 00721 // Map area 00722 ViewportModeType ViewportMode; 00723 CViewport *MouseViewport; 00724 CViewport *SelectedViewport; 00725 int NumViewports; 00726 CViewport Viewports[MAX_NUM_VIEWPORTS]; 00727 CMapArea MapArea; 00728 CFont *MessageFont; 00729 int MessageScrollSpeed; 00730 00731 // Menu buttons 00732 CUIButton MenuButton; 00733 CUIButton NetworkMenuButton; 00734 CUIButton NetworkDiplomacyButton; 00735 00736 // The minimap 00737 CMinimap Minimap; 00738 Uint32 ViewportCursorColor; 00739 00740 // The status line 00741 CStatusLine StatusLine; 00742 00743 // Game timer 00744 CUITimer Timer; 00745 00746 // Offsets for 640x480 center used by menus 00747 int Offset640X; 00748 int Offset480Y; 00749 00750 // 00751 // Cursors used. 00752 // 00753 CursorConfig Point; 00754 CursorConfig Glass; 00755 CursorConfig Cross; 00756 CursorConfig YellowHair; 00757 CursorConfig GreenHair; 00758 CursorConfig RedHair; 00759 CursorConfig Scroll; 00760 00761 CursorConfig ArrowE; 00762 CursorConfig ArrowNE; 00763 CursorConfig ArrowN; 00764 CursorConfig ArrowNW; 00765 CursorConfig ArrowW; 00766 CursorConfig ArrowSW; 00767 CursorConfig ArrowS; 00768 CursorConfig ArrowSE; 00769 00775 00776 CGraphic *VictoryBackgroundG; 00777 CGraphic *DefeatBackgroundG; 00778 }; 00779 00780 /* 00781 * Basic Shared Pointer for Current Selected Buttons 00782 * parallel drawing problems. 00783 */ 00784 class ButtonActionProxy 00785 { 00786 ButtonAction *ptr; // pointer to the ButtonAction array 00787 int *count; // shared number of owners 00788 00789 void dispose() { 00790 if (count == NULL || --*count == 0) { 00791 delete count; 00792 delete[] ptr; 00793 } 00794 } 00795 00796 ButtonActionProxy &operator= (ButtonAction *p) { 00797 if (this->ptr != p) { 00798 if (count == NULL || --*count == 0) { 00799 delete[] ptr; 00800 if (count) { 00801 *count = 1; 00802 } 00803 } 00804 ptr = p; 00805 } 00806 return *this; 00807 } 00808 00809 friend void CButtonPanel::Update(); 00810 public: 00811 00812 ButtonActionProxy(): ptr(0), count(0) {} 00813 00814 ButtonActionProxy(const ButtonActionProxy &p) 00815 : ptr(p.ptr), count(p.count) { 00816 if (!count) { 00817 count = new int(1); 00818 *count = 1; 00819 } 00820 ++*count; 00821 } 00822 00823 ~ButtonActionProxy() { 00824 dispose(); 00825 } 00826 00827 void Reset() { 00828 dispose(); 00829 count = NULL; 00830 ptr = NULL; 00831 } 00832 00833 ButtonAction &operator[](unsigned int index) { 00834 return ptr[index]; 00835 } 00836 00837 bool IsValid() { 00838 return ptr != NULL; 00839 } 00840 00841 }; 00842 00843 extern ButtonActionProxy CurrentButtons; 00844 00845 /*---------------------------------------------------------------------------- 00846 -- Variables 00847 ----------------------------------------------------------------------------*/ 00848 00849 extern CUserInterface UI; 00850 00851 extern std::string ClickMissile; 00852 extern std::string DamageMissile; 00853 00854 00856 extern std::map<std::string, ButtonStyle *> ButtonStyleHash; 00857 00858 extern bool RightButtonAttacks; 00859 00860 extern const char DefaultGroupKeys[]; 00861 extern std::string UiGroupKeys; 00862 00863 extern bool FancyBuildings; 00864 00865 // only exported to save them 00866 00867 /*---------------------------------------------------------------------------- 00868 -- Functions 00869 ----------------------------------------------------------------------------*/ 00870 00872 extern void InitUserInterface(); 00874 extern void SaveUserInterface(CFile &file); 00876 extern void CleanUserInterface(); 00877 #ifdef DEBUG 00878 extern void FreeButtonStyles(); 00879 #endif 00881 extern void UserInterfaceCclRegister(); 00882 00884 extern CPopup *PopupByIdent(const std::string &ident); 00885 00887 extern ButtonStyle *FindButtonStyle(const std::string &style); 00888 00890 extern void UIHandleMouseMove(const PixelPos &pos); 00892 extern void UIHandleButtonDown(unsigned button); 00894 extern void UIHandleButtonUp(unsigned button); 00895 00897 extern void RestrictCursorToViewport(); 00899 extern void RestrictCursorToMinimap(); 00900 00902 extern CViewport *GetViewport(const PixelPos &screenPos); 00904 extern void CycleViewportMode(int); 00906 extern void SetViewportMode(ViewportModeType mode); 00907 extern void CheckViewportMode(); 00908 00910 extern void MouseScrollMap(int x, int y); 00912 extern bool GetMouseScroll(); 00914 extern void SetMouseScroll(bool enabled); 00916 extern bool GetKeyScroll(); 00918 extern void SetKeyScroll(bool enabled); 00920 extern bool GetGrabMouse(); 00922 extern void SetGrabMouse(bool enabled); 00924 extern bool GetLeaveStops(); 00926 extern void SetLeaveStops(bool enabled); 00927 00928 extern int AddHandler(lua_State *l); 00929 extern void CallHandler(unsigned int handle, int value); 00930 00932 extern void ShowLoadProgress(const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(1, 2); 00933 00935 00936 #endif // !__UI_H__