$treeview $search $mathjax
Stratagus
2.2.6
$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 1998-2006 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 __INTERFACE_H__ 00031 #define __INTERFACE_H__ 00032 00034 00035 /*---------------------------------------------------------------------------- 00036 -- Declarations 00037 ----------------------------------------------------------------------------*/ 00038 #ifndef __ICONS_H__ 00039 #include "icons.h" 00040 #endif 00041 00042 #ifndef __UNIT_H__ 00043 #include "unit.h" 00044 #endif 00045 00046 /*---------------------------------------------------------------------------- 00047 -- Declarations 00048 ----------------------------------------------------------------------------*/ 00049 00050 struct _event_callback_; 00051 00052 /*---------------------------------------------------------------------------- 00053 -- Definitons 00054 ----------------------------------------------------------------------------*/ 00055 00057 enum ButtonCmd { 00058 ButtonMove, 00059 ButtonAttack, 00060 ButtonRepair, 00061 ButtonHarvest, 00062 ButtonBuild, 00063 ButtonPatrol, 00064 ButtonAttackGround, 00065 ButtonSpellCast, 00066 ButtonUnload, 00067 ButtonStop, 00068 ButtonButton, 00069 ButtonTrain, 00070 ButtonStandGround, 00071 ButtonReturn, 00072 ButtonResearch, 00073 ButtonUpgradeTo, 00074 ButtonCancel, 00075 ButtonCancelUpgrade, 00076 ButtonCancelTrain, 00077 ButtonCancelBuild 00078 }; 00079 00080 class ButtonAction; 00081 typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction *); 00082 00084 class ButtonAction { 00085 public: 00086 ButtonAction() : Pos(0), Level(0), Action(ButtonMove), Value(0), 00087 Allowed(NULL), Key(0) {} 00088 00089 int Pos; 00090 int Level; 00091 ButtonCmd Action; 00092 int Value; 00093 std::string ValueStr; 00094 00095 ButtonCheckFunc Allowed; 00096 std::string AllowStr; 00097 std::string UnitMask; 00098 IconConfig Icon; 00099 int Key; 00100 std::string Hint; 00101 std::string Description; 00102 SoundConfig CommentSound; 00103 std::string ButtonCursor; 00104 }; 00105 00107 enum _button_area_ { 00108 ButtonAreaSelected, 00109 ButtonAreaTraining, 00110 ButtonAreaUpgrading, 00111 ButtonAreaResearching, 00112 ButtonAreaTransporting, 00113 ButtonAreaButton, 00114 ButtonAreaMenu 00115 }; 00116 00118 enum _menu_button_under_ { 00119 ButtonUnderMenu, 00120 ButtonUnderNetworkMenu, 00121 ButtonUnderNetworkDiplomacy 00122 }; 00123 00125 enum _iface_state_ { 00126 IfaceStateNormal, 00127 IfaceStateMenu 00128 }; 00129 00131 enum _key_state_ { 00132 KeyStateCommand = 0, 00133 KeyStateInput 00134 }; 00135 00137 #define ModifierShift 1 00138 #define ModifierControl 2 00139 #define ModifierAlt 4 00140 #define ModifierSuper 8 00141 #define ModifierDoublePress 16 00142 00143 #define MouseDoubleShift 8 00144 #define MouseDragShift 16 00145 #define MouseHoldShift 24 00146 00148 #define NoButton 0 00149 #define LeftButton 2 00150 #define MiddleButton 4 00151 #define RightButton 8 00152 00153 #define UpButton 16 00154 #define DownButton 32 00155 00156 #define LeftAndMiddleButton (LeftButton | MiddleButton) 00157 #define LeftAndRightButton (LeftButton | RightButton) 00158 #define MiddleAndRightButton (MiddleButton | RightButton) 00159 00161 enum _cursor_on_ { 00162 CursorOnUnknown = -1, 00163 CursorOnMinimap, 00164 CursorOnButton, 00165 CursorOnMap, 00166 CursorOnScrollUp, 00167 CursorOnScrollDown, 00168 CursorOnScrollLeft, 00169 CursorOnScrollRight, 00170 CursorOnScrollLeftUp, 00171 CursorOnScrollLeftDown, 00172 CursorOnScrollRightUp, 00173 CursorOnScrollRightDown 00174 }; 00175 00177 #define ScrollNone 0 00178 #define ScrollUp 1 00179 #define ScrollDown 2 00180 #define ScrollLeft 4 00181 #define ScrollRight 8 00182 #define ScrollLeftUp 5 00183 #define ScrollLeftDown 6 00184 #define ScrollRightUp 9 00185 #define ScrollRightDown 10 00186 00187 /*---------------------------------------------------------------------------- 00188 -- Variables 00189 ----------------------------------------------------------------------------*/ 00190 extern std::vector<ButtonAction *> UnitButtonTable; 00191 00193 extern bool GameRunning; 00195 extern bool GamePaused; 00197 extern bool GameObserve; 00199 extern char SkipGameCycle; 00201 extern bool GodMode; 00203 extern char BigMapMode; 00205 extern bool IsSDLWindowVisible; 00206 00208 extern int MouseButtons; 00210 extern int KeyModifiers; 00212 extern enum _iface_state_ InterfaceState; 00214 extern int KeyScrollState; 00216 extern int MouseScrollState; 00218 extern enum _key_state_ KeyState; 00220 extern CUnitPtr UnitUnderCursor; 00222 extern int ButtonAreaUnderCursor; 00224 extern int ButtonUnderCursor; 00226 extern bool GameMenuButtonClicked; 00228 extern bool GameDiplomacyButtonClicked; 00230 extern bool LeaveStops; 00232 extern enum _cursor_on_ CursorOn; 00233 00235 extern int CurrentButtonLevel; 00236 00238 extern int DoubleClickDelay; 00240 extern int HoldClickDelay; 00241 00242 /*---------------------------------------------------------------------------- 00243 -- Functions 00244 ----------------------------------------------------------------------------*/ 00245 00246 extern CUnit *GetUnitUnderCursor(); 00247 00248 // 00249 // in botpanel.cpp 00250 // 00252 extern void InitButtons(); 00254 extern void CleanButtons(); 00256 extern int AddButton(int pos, int level, const std::string &IconIdent, 00257 ButtonCmd action, const std::string &value, const ButtonCheckFunc func, 00258 const std::string &arg, const std::string &hint, const std::string &descr, 00259 const std::string &sound, const std::string &cursor, const std::string &umask); 00260 00261 // 00262 // in mouse.cpp 00263 // 00265 extern void HandleButtonDown(unsigned button); 00267 extern void HandleButtonUp(unsigned button); 00269 extern void HandleCursorMove(int *x, int *y); 00271 extern void HandleMouseMove(int x, int y); 00273 extern void HandleMouseExit(); 00274 00276 extern int HandleKeyModifiersDown(unsigned keycode, unsigned keychar); 00278 extern int HandleKeyModifiersUp(unsigned keycode, unsigned keychar); 00279 00281 extern void HandleKeyDown(unsigned keycode, unsigned keychar); 00283 extern void HandleKeyUp(unsigned keycode, unsigned keychar); 00285 extern void HandleKeyRepeat(unsigned keycode, unsigned keychar); 00286 00287 // 00288 // in interface.c (for link between video and mouse.c) 00289 // 00291 extern void InputMouseButtonPress(const struct _event_callback_ *callbacks, 00292 unsigned ticks, unsigned button); 00294 extern void InputMouseButtonRelease(const struct _event_callback_ *callbacks, 00295 unsigned ticks, unsigned button); 00297 extern void InputMouseMove(const struct _event_callback_ *callbacks, 00298 unsigned ticks, int x, int y); 00300 extern void InputMouseExit(const struct _event_callback_ *callbacks, 00301 unsigned ticks); 00303 extern void InputMouseTimeout(const struct _event_callback_ *callbacks, 00304 unsigned ticks); 00305 00307 extern void InputKeyButtonPress(const struct _event_callback_ *callbacks, 00308 unsigned ticks, unsigned ikey, unsigned ikeychar); 00310 extern void InputKeyButtonRelease(const struct _event_callback_ *callbacks, 00311 unsigned ticks, unsigned ikey, unsigned ikeychar); 00313 extern void InputKeyTimeout(const struct _event_callback_ *callbacks, 00314 unsigned ticks); 00315 00317 extern int GetDoubleClickDelay(); 00319 extern void SetDoubleClickDelay(int delay); 00321 extern int GetHoldClickDelay(); 00323 extern void SetHoldClickDelay(int delay); 00324 00326 extern void UiTogglePause(); 00328 extern void UiToggleBigMap(); 00330 extern int HandleCheats(const std::string &input); 00331 00333 bool HandleCommandKey(int key); 00334 00335 // 00336 // Chaos pur. 00337 // 00339 extern void DoRightButton(int tx, int ty); 00341 extern void CancelBuildingMode(); 00342 00344 extern void DrawMenuButtonArea(); 00346 extern void UpdateMessages(); 00348 extern void DrawMessages(); 00350 extern void DrawResources(); 00352 extern void SetMessage(const char *fmt, ...); 00354 extern void SetMessageEvent(int x, int y, const char *fmt, ...); 00356 extern void CenterOnMessage(); 00358 extern void CleanMessages(); 00360 extern void ToggleShowMessages(); 00361 00363 extern void DrawCosts(); 00365 extern void SetCosts(int mana, int food, const int *costs); 00367 extern void ClearCosts(); 00368 00370 extern void DrawTimer(); 00372 extern void UpdateTimer(); 00374 extern void UpdateStatusLineForButton(const ButtonAction *button); 00376 extern void DrawPieMenu(); 00377 00379 extern int HandleMouseScrollArea(int x, int y); 00380 00381 // 00382 // in button_checks.cpp 00383 // 00385 extern bool ButtonCheckTrue(const CUnit &unit, const ButtonAction *button); 00387 extern bool ButtonCheckFalse(const CUnit &unit, const ButtonAction *button); 00389 extern bool ButtonCheckUpgrade(const CUnit &unit, const ButtonAction *button); 00391 extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction *button); 00393 extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction *button); 00395 extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction *button); 00397 extern bool ButtonCheckNoNetwork(const CUnit &unit, const ButtonAction *button); 00399 extern bool ButtonCheckNoWork(const CUnit &unit, const ButtonAction *button); 00401 extern bool ButtonCheckNoResearch(const CUnit &unit, const ButtonAction *button); 00403 extern bool ButtonCheckAttack(const CUnit &unit, const ButtonAction *button); 00405 extern bool ButtonCheckUpgradeTo(const CUnit &unit, const ButtonAction *button); 00407 extern bool ButtonCheckResearch(const CUnit &unit, const ButtonAction *button); 00409 extern bool ButtonCheckSingleResearch(const CUnit &unit, const ButtonAction *button); 00410 00411 // 00412 // in ccl_ui.c 00413 // 00415 extern void SelectionChanged(); 00417 extern void SelectedUnitChanged(); 00418 00419 // 00420 // in game.cpp 00421 // 00423 extern void SetGamePaused(bool paused); 00425 extern bool GetGamePaused(); 00427 extern void SetGameSpeed(int speed); 00429 extern int GetGameSpeed(); 00430 00432 00433 #endif // !__INTERFACE_H__