Tree @upstream/1.11 (Download .tar.gz)
- ..
- .vscode
- api
- Animation.cpp
- Animation.h
- AnimationManager.cpp
- AnimationManager.h
- AnimationSet.cpp
- AnimationSet.h
- AStarContainer.cpp
- AStarContainer.h
- AStarNode.cpp
- AStarNode.h
- Avatar.cpp
- Avatar.h
- BehaviorAlly.cpp
- BehaviorAlly.h
- BehaviorStandard.cpp
- BehaviorStandard.h
- CampaignManager.cpp
- CampaignManager.h
- CombatText.cpp
- CombatText.h
- CommonIncludes.h
- CursorManager.cpp
- CursorManager.h
- DeviceList.cpp
- DeviceList.h
- EffectManager.cpp
- EffectManager.h
- Enemy.cpp
- Enemy.h
- EnemyBehavior.cpp
- EnemyBehavior.h
- EnemyGroupManager.cpp
- EnemyGroupManager.h
- EnemyManager.cpp
- EnemyManager.h
- EngineSettings.cpp
- EngineSettings.h
- Entity.cpp
- Entity.h
- EventManager.cpp
- EventManager.h
- FileParser.cpp
- FileParser.h
- Flare.rc
- FontEngine.cpp
- FontEngine.h
- GameSlotPreview.cpp
- GameSlotPreview.h
- GameState.cpp
- GameState.h
- GameStateConfig.cpp
- GameStateConfig.h
- GameStateCutscene.cpp
- GameStateCutscene.h
- GameStateLoad.cpp
- GameStateLoad.h
- GameStateNew.cpp
- GameStateNew.h
- GameStatePlay.cpp
- GameStatePlay.h
- GameStateTitle.cpp
- GameStateTitle.h
- GameSwitcher.cpp
- GameSwitcher.h
- GetText.cpp
- GetText.h
- Hazard.cpp
- Hazard.h
- HazardManager.cpp
- HazardManager.h
- IconManager.cpp
- IconManager.h
- InputState.cpp
- InputState.h
- ItemManager.cpp
- ItemManager.h
- ItemStorage.cpp
- ItemStorage.h
- Loot.cpp
- Loot.h
- LootManager.cpp
- LootManager.h
- main.cpp
- Map.cpp
- Map.h
- MapCollision.cpp
- MapCollision.h
- MapParallax.cpp
- MapParallax.h
- MapRenderer.cpp
- MapRenderer.h
- Menu.cpp
- Menu.h
- MenuActionBar.cpp
- MenuActionBar.h
- MenuActiveEffects.cpp
- MenuActiveEffects.h
- MenuBook.cpp
- MenuBook.h
- MenuCharacter.cpp
- MenuCharacter.h
- MenuConfig.cpp
- MenuConfig.h
- MenuConfirm.cpp
- MenuConfirm.h
- MenuDevConsole.cpp
- MenuDevConsole.h
- MenuEnemy.cpp
- MenuEnemy.h
- MenuExit.cpp
- MenuExit.h
- MenuHUDLog.cpp
- MenuHUDLog.h
- MenuInventory.cpp
- MenuInventory.h
- MenuItemStorage.cpp
- MenuItemStorage.h
- MenuLog.cpp
- MenuLog.h
- MenuManager.cpp
- MenuManager.h
- MenuMiniMap.cpp
- MenuMiniMap.h
- MenuNumPicker.cpp
- MenuNumPicker.h
- MenuPowers.cpp
- MenuPowers.h
- MenuStash.cpp
- MenuStash.h
- MenuStatBar.cpp
- MenuStatBar.h
- MenuTalker.cpp
- MenuTalker.h
- MenuTouchControls.cpp
- MenuTouchControls.h
- MenuVendor.cpp
- MenuVendor.h
- MessageEngine.cpp
- MessageEngine.h
- ModManager.cpp
- ModManager.h
- NPC.cpp
- NPC.h
- NPCManager.cpp
- NPCManager.h
- Platform.h
- PlatformAndroid.cpp
- PlatformEmscripten.cpp
- PlatformGCW0.cpp
- PlatformIPhoneOS.cpp
- PlatformLinux.cpp
- PlatformWin32.cpp
- PowerManager.cpp
- PowerManager.h
- QuestLog.cpp
- QuestLog.h
- RenderDevice.cpp
- RenderDevice.h
- resource.h
- SaveLoad.cpp
- SaveLoad.h
- SDLFontEngine.cpp
- SDLFontEngine.h
- SDLHardwareRenderDevice.cpp
- SDLHardwareRenderDevice.h
- SDLInputState.cpp
- SDLInputState.h
- SDLSoftwareRenderDevice.cpp
- SDLSoftwareRenderDevice.h
- SDLSoundManager.cpp
- SDLSoundManager.h
- Settings.cpp
- Settings.h
- SharedGameResources.cpp
- SharedGameResources.h
- SharedResources.cpp
- SharedResources.h
- SoundManager.cpp
- SoundManager.h
- StatBlock.cpp
- StatBlock.h
- Stats.cpp
- Stats.h
- Subtitles.cpp
- Subtitles.h
- TileSet.cpp
- TileSet.h
- TooltipData.cpp
- TooltipData.h
- TooltipManager.cpp
- TooltipManager.h
- Utils.cpp
- Utils.h
- UtilsDebug.cpp
- UtilsDebug.h
- UtilsFileSystem.cpp
- UtilsFileSystem.h
- UtilsMath.h
- UtilsParsing.cpp
- UtilsParsing.h
- Version.cpp
- Version.h
- Widget.cpp
- Widget.h
- WidgetButton.cpp
- WidgetButton.h
- WidgetCheckBox.cpp
- WidgetCheckBox.h
- WidgetHorizontalList.cpp
- WidgetHorizontalList.h
- WidgetInput.cpp
- WidgetInput.h
- WidgetLabel.cpp
- WidgetLabel.h
- WidgetListBox.cpp
- WidgetListBox.h
- WidgetLog.cpp
- WidgetLog.h
- WidgetScrollBar.cpp
- WidgetScrollBar.h
- WidgetScrollBox.cpp
- WidgetScrollBox.h
- WidgetSlider.cpp
- WidgetSlider.h
- WidgetSlot.cpp
- WidgetSlot.h
- WidgetTabControl.cpp
- WidgetTabControl.h
- WidgetTooltip.cpp
- WidgetTooltip.h
Utils.h @upstream/1.11 — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 | /* Copyright © 2011-2012 Clint Bellanger Copyright © 2012 Stefan Beller Copyright © 2013 Henrik Andersson Copyright © 2013 Kurt Rinnert Copyright © 2012-2016 Justin Jacobs This file is part of FLARE. FLARE is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. FLARE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with FLARE. If not, see http://www.gnu.org/licenses/ */ /** * Utils * * Various utility structures, enums, function */ #ifndef UTILS_H #define UTILS_H #include <SDL.h> #include <stdint.h> #include <string> #include <queue> typedef unsigned long SoundID; typedef unsigned long StatusID; class Avatar; class FPoint; // needed for Point -> FPoint constructor class Point { public: int x, y; Point(); Point(int _x, int _y); explicit Point(const FPoint& _fp); }; class FPoint { public: float x, y; FPoint(); FPoint(float _x, float _y); explicit FPoint(Point _p); void align(); }; class Rect { public: int x, y, w, h; Rect(); Rect(int _x, int _y, int _w, int _h); explicit Rect(const SDL_Rect& _r); operator SDL_Rect() const; }; class Color { public: Uint8 r, g, b, a; Color(); Color(Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a = 255); operator SDL_Color() const; bool operator ==(const Color &other); bool operator !=(const Color &other); }; class Timer { private: unsigned current; unsigned duration; public: enum { END = 0, BEGIN = 1 }; Timer(unsigned _duration = 0); unsigned getCurrent(); unsigned getDuration(); void setCurrent(unsigned val); void setDuration(unsigned val); bool tick(); bool isEnd(); bool isBegin(); void reset(int type); }; namespace Utils { // Alignment: For aligning objects relative to the screen enum { ALIGN_TOPLEFT = 0, ALIGN_TOP = 1, ALIGN_TOPRIGHT = 2, ALIGN_LEFT = 3, ALIGN_CENTER = 4, ALIGN_RIGHT = 5, ALIGN_BOTTOMLEFT = 6, ALIGN_BOTTOM = 7, ALIGN_BOTTOMRIGHT = 8 }; extern int LOCK_INDEX; extern bool LOG_FILE_INIT; extern bool LOG_FILE_CREATED; extern std::string LOG_PATH; extern std::queue<std::pair<SDL_LogPriority, std::string> > LOG_MSG; FPoint screenToMap(int x, int y, float camx, float camy); Point mapToScreen(float x, float y, float camx, float camy); FPoint calcVector(const FPoint& pos, int direction, float dist); float calcDist(const FPoint& p1, const FPoint& p2); float calcTheta(float x1, float y1, float x2, float y2); unsigned char calcDirection(float x0, float y0, float x1, float y1); bool isWithinRadius(const FPoint& center, float radius, const FPoint& target); bool isWithinRect(const Rect& r, const Point& target); std::string abbreviateKilo(int amount); void alignToScreenEdge(int alignment, Rect *r); void logInfo(const char* format, ...); void logError(const char* format, ...); void logErrorDialog(const char* dialog_text, ...); void createLogFile(); void Exit(int code); void createSaveDir(int slot); void removeSaveDir(int slot); Rect resizeToScreen(int w, int h, bool crop, int align); size_t stringFindCaseInsensitive(const std::string &_a, const std::string &_b); std::string floatToString(const float value, size_t precision); std::string getDurationString(const int duration, size_t precision); std::string substituteVarsInString(const std::string &_s, Avatar* avatar); FPoint clampDistance(float range, const FPoint& src, const FPoint& target); bool rectsOverlap(const Rect &a, const Rect &b); int rotateDirection(int direction, int val); std::string getTimeString(const unsigned long time); unsigned long hashString(const std::string& str); char* strdup(const std::string& str); void lockFileRead(); void lockFileWrite(int increment); void lockFileCheck(); } #endif |