| 1 | /** |
| 2 | * Copyright (c) 2006-2023 LOVE Development Team |
| 3 | * |
| 4 | * This software is provided 'as-is', without any express or implied |
| 5 | * warranty. In no event will the authors be held liable for any damages |
| 6 | * arising from the use of this software. |
| 7 | * |
| 8 | * Permission is granted to anyone to use this software for any purpose, |
| 9 | * including commercial applications, and to alter it and redistribute it |
| 10 | * freely, subject to the following restrictions: |
| 11 | * |
| 12 | * 1. The origin of this software must not be misrepresented; you must not |
| 13 | * claim that you wrote the original software. If you use this software |
| 14 | * in a product, an acknowledgment in the product documentation would be |
| 15 | * appreciated but is not required. |
| 16 | * 2. Altered source versions must be plainly marked as such, and must not be |
| 17 | * misrepresented as being the original software. |
| 18 | * 3. This notice may not be removed or altered from any source distribution. |
| 19 | **/ |
| 20 | |
| 21 | #ifndef LOVE_GRAPHICS_VOLATILE_H |
| 22 | #define LOVE_GRAPHICS_VOLATILE_H |
| 23 | |
| 24 | // STL |
| 25 | #include <list> |
| 26 | |
| 27 | namespace love |
| 28 | { |
| 29 | namespace graphics |
| 30 | { |
| 31 | |
| 32 | /** |
| 33 | * This class is the superclass of all objects which must completely or |
| 34 | * partially reload when the user changes the display resolution. All |
| 35 | * volatile objects will be notified when the display mode changes. |
| 36 | * |
| 37 | * @author Anders Ruud |
| 38 | **/ |
| 39 | class Volatile |
| 40 | { |
| 41 | private: |
| 42 | |
| 43 | // A list of all Volatile object currently alive. |
| 44 | static std::list<Volatile *> all; |
| 45 | |
| 46 | public: |
| 47 | |
| 48 | /** |
| 49 | * Constructor. Automatically adds \c this into the list |
| 50 | * of volatile objects. |
| 51 | **/ |
| 52 | Volatile(); |
| 53 | |
| 54 | /** |
| 55 | * Destructor. Removes \c this from the list of volatile |
| 56 | * objects. |
| 57 | **/ |
| 58 | virtual ~Volatile(); |
| 59 | |
| 60 | /** |
| 61 | * Loads the part(s) of the object which is destroyed when |
| 62 | * the display mode is changed. |
| 63 | * |
| 64 | * @return True if successful, false on errors. |
| 65 | **/ |
| 66 | virtual bool loadVolatile() = 0; |
| 67 | |
| 68 | /** |
| 69 | * Unloads the part(s) of the objects which would be destroyed |
| 70 | * anyway when the display mode is changed. |
| 71 | **/ |
| 72 | virtual void unloadVolatile() = 0; |
| 73 | |
| 74 | // Static: |
| 75 | |
| 76 | /** |
| 77 | * Calls \c loadVolatile() on each element in the list of volatiles. |
| 78 | * |
| 79 | * @return True if all elements succeeded, false if one or more failed. |
| 80 | **/ |
| 81 | static bool loadAll(); |
| 82 | |
| 83 | /** |
| 84 | * Calls \c unloadVolatile() on each element in the list of volatiles. |
| 85 | **/ |
| 86 | static void unloadAll(); |
| 87 | |
| 88 | }; // Volatile |
| 89 | |
| 90 | } // graphics |
| 91 | } // love |
| 92 | |
| 93 | #endif // LOVE_GRAPHICS_VOLATILE_H |
| 94 | |