$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 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 #include "unitsound.h" 00043 #include "vec2i.h" 00044 #include <vector> 00045 00046 /*---------------------------------------------------------------------------- 00047 -- Declarations 00048 ----------------------------------------------------------------------------*/ 00049 00050 class CUnit; 00051 struct EventCallback; 00052 00053 /*---------------------------------------------------------------------------- 00054 -- Definitons 00055 ----------------------------------------------------------------------------*/ 00056 00058 enum ButtonCmd { 00059 ButtonMove, 00060 ButtonAttack, 00061 ButtonRepair, 00062 ButtonHarvest, 00063 ButtonBuild, 00064 ButtonPatrol, 00065 ButtonAttackGround, 00066 ButtonSpellCast, 00067 ButtonUnload, 00068 ButtonStop, 00069 ButtonButton, 00070 ButtonTrain, 00071 ButtonStandGround, 00072 ButtonReturn, 00073 ButtonResearch, 00074 ButtonUpgradeTo, 00075 ButtonCancel, 00076 ButtonCancelUpgrade, 00077 ButtonCancelTrain, 00078 ButtonCancelBuild 00079 }; 00080 00081 class ButtonAction; 00082 typedef bool (*ButtonCheckFunc)(const CUnit &, const ButtonAction &); 00083 00085 class ButtonAction 00086 { 00087 public: 00088 ButtonAction() : Pos(0), Level(0), Action(ButtonMove), Value(0), 00089 Allowed(NULL), Key(0) {} 00090 00091 int Pos; 00092 int Level; 00093 ButtonCmd Action; 00094 int Value; 00095 std::string ValueStr; 00096 00097 ButtonCheckFunc Allowed; 00098 std::string AllowStr; 00099 std::string UnitMask; 00100 IconConfig Icon; 00101 int Key; 00102 std::string Hint; 00103 std::string Description; 00104 SoundConfig CommentSound; 00105 std::string ButtonCursor; 00106 std::string Popup; 00107 }; 00108 00110 enum _button_area_ { 00111 ButtonAreaSelected, 00112 ButtonAreaTraining, 00113 ButtonAreaUpgrading, 00114 ButtonAreaResearching, 00115 ButtonAreaTransporting, 00116 ButtonAreaButton, 00117 ButtonAreaMenu 00118 }; 00119 00121 enum _menu_button_under_ { 00122 ButtonUnderMenu, 00123 ButtonUnderNetworkMenu, 00124 ButtonUnderNetworkDiplomacy 00125 }; 00126 00128 enum _iface_state_ { 00129 IfaceStateNormal, 00130 IfaceStateMenu 00131 }; 00132 00134 enum _key_state_ { 00135 KeyStateCommand = 0, 00136 KeyStateInput 00137 }; 00138 00140 #define ModifierShift 1 00141 #define ModifierControl 2 00142 #define ModifierAlt 4 00143 #define ModifierSuper 8 00144 #define ModifierDoublePress 16 00145 00146 #define MouseDoubleShift 8 00147 #define MouseDragShift 16 00148 #define MouseHoldShift 24 00149 00151 #define NoButton 0 00152 #define LeftButton 2 00153 #define MiddleButton 4 00154 #define RightButton 8 00155 00156 #define UpButton 16 00157 #define DownButton 32 00158 00159 #define LeftAndMiddleButton (LeftButton | MiddleButton) 00160 #define LeftAndRightButton (LeftButton | RightButton) 00161 #define MiddleAndRightButton (MiddleButton | RightButton) 00162 00164 enum _cursor_on_ { 00165 CursorOnUnknown = -1, 00166 CursorOnMinimap, 00167 CursorOnButton, 00168 CursorOnMap, 00169 CursorOnScrollUp, 00170 CursorOnScrollDown, 00171 CursorOnScrollLeft, 00172 CursorOnScrollRight, 00173 CursorOnScrollLeftUp, 00174 CursorOnScrollLeftDown, 00175 CursorOnScrollRightUp, 00176 CursorOnScrollRightDown 00177 }; 00178 00180 #define ScrollNone 0 00181 #define ScrollUp 1 00182 #define ScrollDown 2 00183 #define ScrollLeft 4 00184 #define ScrollRight 8 00185 #define ScrollLeftUp 5 00186 #define ScrollLeftDown 6 00187 #define ScrollRightUp 9 00188 #define ScrollRightDown 10 00189 00190 /*---------------------------------------------------------------------------- 00191 -- Variables 00192 ----------------------------------------------------------------------------*/ 00193 extern std::vector<ButtonAction *> UnitButtonTable; 00194 00196 extern bool GameRunning; 00198 extern bool GamePaused; 00200 extern bool GameObserve; 00202 extern char SkipGameCycle; 00204 extern bool GodMode; 00206 extern char BigMapMode; 00208 extern bool IsSDLWindowVisible; 00209 00211 extern int MouseButtons; 00213 extern int KeyModifiers; 00215 extern enum _iface_state_ InterfaceState; 00217 extern int KeyScrollState; 00219 extern int MouseScrollState; 00221 extern enum _key_state_ KeyState; 00223 extern CUnit *UnitUnderCursor; 00225 extern int ButtonAreaUnderCursor; 00227 extern int ButtonUnderCursor; 00229 extern bool GameMenuButtonClicked; 00231 extern bool GameDiplomacyButtonClicked; 00233 extern bool LeaveStops; 00235 extern enum _cursor_on_ CursorOn; 00236 00238 extern int CurrentButtonLevel; 00239 00241 extern int DoubleClickDelay; 00243 extern int HoldClickDelay; 00244 00245 /*---------------------------------------------------------------------------- 00246 -- Functions 00247 ----------------------------------------------------------------------------*/ 00248 00249 extern CUnit *GetUnitUnderCursor(); 00250 00251 // 00252 // in botpanel.cpp 00253 // 00255 extern void InitButtons(); 00257 extern void CleanButtons(); 00259 extern int AddButton(int pos, int level, const std::string &IconIdent, 00260 ButtonCmd action, const std::string &value, const ButtonCheckFunc func, 00261 const std::string &arg, const std::string &hint, const std::string &descr, 00262 const std::string &sound, const std::string &cursor, const std::string &umask, 00263 const std::string &popup); 00264 00265 // 00266 // in mouse.cpp 00267 // 00269 extern void HandleButtonDown(unsigned button); 00271 extern void HandleButtonUp(unsigned button); 00273 extern void HandleCursorMove(int *x, int *y); 00275 extern void HandleMouseMove(const PixelPos &pos); 00277 extern void HandleMouseExit(); 00278 00280 extern int HandleKeyModifiersDown(unsigned keycode, unsigned keychar); 00282 extern int HandleKeyModifiersUp(unsigned keycode, unsigned keychar); 00283 00285 extern void HandleKeyDown(unsigned keycode, unsigned keychar); 00287 extern void HandleKeyUp(unsigned keycode, unsigned keychar); 00289 extern void HandleKeyRepeat(unsigned keycode, unsigned keychar); 00290 00291 // 00292 // in interface.c (for link between video and mouse.c) 00293 // 00295 extern void InputMouseButtonPress(const EventCallback &callbacks, unsigned ticks, unsigned button); 00297 extern void InputMouseButtonRelease(const EventCallback &callbacks, unsigned ticks, unsigned button); 00299 extern void InputMouseMove(const EventCallback &callbacks, unsigned ticks, int x, int y); 00301 extern void InputMouseExit(const EventCallback &callbacks, unsigned ticks); 00303 extern void InputMouseTimeout(const EventCallback &callbacks, unsigned ticks); 00304 00306 extern void InputKeyButtonPress(const EventCallback &callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar); 00308 extern void InputKeyButtonRelease(const EventCallback &callbacks, unsigned ticks, unsigned ikey, unsigned ikeychar); 00310 extern void InputKeyTimeout(const EventCallback &callbacks, unsigned ticks); 00311 00313 extern int GetDoubleClickDelay(); 00315 extern void SetDoubleClickDelay(int delay); 00317 extern int GetHoldClickDelay(); 00319 extern void SetHoldClickDelay(int delay); 00320 00322 extern void UiTogglePause(); 00324 extern void UiToggleBigMap(); 00326 extern int HandleCheats(const std::string &input); 00327 00329 bool HandleCommandKey(int key); 00330 00331 // 00332 // Chaos pur. 00333 // 00335 extern void CancelBuildingMode(); 00336 00338 extern void DrawMenuButtonArea(); 00340 extern void UpdateMessages(); 00342 extern void DrawMessages(); 00344 extern void DrawResources(); 00346 extern void SetMessage(const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(1, 2); 00348 extern void SetMessageEvent(const Vec2i &pos, const char *fmt, ...) PRINTF_VAARG_ATTRIBUTE(2, 3); 00350 extern void CenterOnMessage(); 00352 extern void CleanMessages(); 00354 extern void ToggleShowMessages(); 00355 00357 extern void DrawCosts(); 00359 extern void SetCosts(int mana, int food, const int *costs); 00361 extern void ClearCosts(); 00362 00364 extern void DrawTimer(); 00366 extern void UpdateTimer(); 00368 extern void UpdateStatusLineForButton(const ButtonAction &button); 00370 extern void DrawPieMenu(); 00371 00373 extern bool HandleMouseScrollArea(const PixelPos &mousePos); 00374 00375 // 00376 // in button_checks.cpp 00377 // 00379 extern bool ButtonCheckTrue(const CUnit &unit, const ButtonAction &button); 00381 extern bool ButtonCheckFalse(const CUnit &unit, const ButtonAction &button); 00383 extern bool ButtonCheckUpgrade(const CUnit &unit, const ButtonAction &button); 00385 extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction &button); 00387 extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button); 00389 extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction &button); 00391 extern bool ButtonCheckNoNetwork(const CUnit &unit, const ButtonAction &button); 00393 extern bool ButtonCheckNoWork(const CUnit &unit, const ButtonAction &button); 00395 extern bool ButtonCheckNoResearch(const CUnit &unit, const ButtonAction &button); 00397 extern bool ButtonCheckAttack(const CUnit &unit, const ButtonAction &button); 00399 extern bool ButtonCheckUpgradeTo(const CUnit &unit, const ButtonAction &button); 00401 extern bool ButtonCheckResearch(const CUnit &unit, const ButtonAction &button); 00403 extern bool ButtonCheckSingleResearch(const CUnit &unit, const ButtonAction &button); 00404 00405 // 00406 // in ccl_ui.c 00407 // 00409 extern void SelectionChanged(); 00411 extern void SelectedUnitChanged(); 00412 00413 // 00414 // in game.cpp 00415 // 00417 extern void SetGamePaused(bool paused); 00419 extern bool GetGamePaused(); 00421 extern void SetGameSpeed(int speed); 00423 extern int GetGameSpeed(); 00424 00426 00427 #endif // !__INTERFACE_H__