| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) 1998-2000, Matthes Bender (RedWolf Design) |
| 5 | * Copyright (c) 2017-2020, The LegacyClonk Team and contributors |
| 6 | * |
| 7 | * Distributed under the terms of the ISC license; see accompanying file |
| 8 | * "COPYING" for details. |
| 9 | * |
| 10 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 11 | * See accompanying file "TRADEMARK" for details. |
| 12 | * |
| 13 | * To redistribute this file separately, substitute the full license texts |
| 14 | * for the above references. |
| 15 | */ |
| 16 | |
| 17 | /* Loads all standard graphics from Graphics.c4g */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include <C4Group.h> |
| 22 | #include <C4GroupSet.h> |
| 23 | #include <C4Surface.h> |
| 24 | #include <C4FacetEx.h> |
| 25 | #include "StdFont.h" |
| 26 | |
| 27 | namespace C4GUI { class Resource; } |
| 28 | |
| 29 | class C4GraphicsResource |
| 30 | { |
| 31 | private: |
| 32 | bool fInitialized; |
| 33 | |
| 34 | public: |
| 35 | C4GraphicsResource(); |
| 36 | ~C4GraphicsResource(); |
| 37 | |
| 38 | protected: |
| 39 | C4Surface sfcControl; |
| 40 | int32_t idSfcControl; // id of source group of control surface |
| 41 | int32_t idPalGrp; // if of source group of pal file |
| 42 | // ID of last group in main group set that was already registered into the Files-set |
| 43 | // used to avoid doubled entries by subsequent calls to RegisterMainGroups |
| 44 | int32_t idRegisteredMainGroupSetFiles; |
| 45 | |
| 46 | public: |
| 47 | C4GroupSet Files; |
| 48 | uint8_t GamePalette[256 * 3]; |
| 49 | uint8_t AlphaPalette[256 * 3]; |
| 50 | C4FacetExID fctPlayer; |
| 51 | C4FacetExID fctFlag; |
| 52 | C4FacetExID fctCrew; |
| 53 | C4FacetExID fctScore; |
| 54 | C4FacetExID fctWealth; |
| 55 | C4FacetExID fctRank; |
| 56 | int32_t iNumRanks; |
| 57 | C4FacetExID fctFire; |
| 58 | C4FacetExID fctBackground; |
| 59 | C4Surface sfcLiquidAnimation; int32_t idSfcLiquidAnimation; |
| 60 | C4FacetExID fctCaptain; |
| 61 | C4FacetExID fctMouseCursor; |
| 62 | C4FacetExID fctCursors[8]; |
| 63 | bool fOldStyleCursor; // if set, offsets need to be applied to some cursor facets |
| 64 | C4FacetExID fctSelectMark; |
| 65 | C4FacetExID fctOptions; |
| 66 | C4FacetExID ; |
| 67 | C4FacetExID fctUpperBoard; |
| 68 | C4FacetExID fctLogo; |
| 69 | C4FacetExID fctConstruction; |
| 70 | C4FacetExID fctEnergy; |
| 71 | C4FacetExID fctMagic; |
| 72 | C4FacetExID fctArrow; |
| 73 | C4FacetExID fctExit; |
| 74 | C4FacetExID fctHand; |
| 75 | C4FacetExID fctGamepad; |
| 76 | C4FacetExID fctBuild; |
| 77 | C4FacetExID fctEnergyBars; |
| 78 | C4Facet fctCursor; |
| 79 | C4Facet fctDropTarget; |
| 80 | C4Facet fctInsideSymbol; |
| 81 | C4Facet fctKeyboard; |
| 82 | C4Facet fctMouse; |
| 83 | C4Facet fctCommand; |
| 84 | C4Facet fctKey; |
| 85 | C4Facet fctOKCancel; |
| 86 | C4FacetExID fctCrewClr; // ColorByOwner-surface of fctCrew |
| 87 | C4FacetExID fctFlagClr; // ColorByOwner-surface of fctFlag |
| 88 | C4FacetExID fctPlayerClr; // ColorByOwner-surface of fctPlayer |
| 89 | C4FacetExID fctPlayerGray; // grayed out version of fctPlayer |
| 90 | |
| 91 | // fonts |
| 92 | CStdFont FontTiny; // used for logs |
| 93 | CStdFont FontRegular; // normal font - just refed from graphics system |
| 94 | CStdFont FontCaption; // used for title bars |
| 95 | CStdFont FontTitle; // huge font for titles |
| 96 | CStdFont FontTooltip; // normal, non-shadowed font (same as BookFont) |
| 97 | |
| 98 | public: |
| 99 | void Default(); |
| 100 | void Clear(); |
| 101 | bool InitFonts(); // init fonts only (early init done by loader screen) |
| 102 | bool Init(); |
| 103 | |
| 104 | bool IsInitialized() { return fInitialized; } // return whether any gfx are loaded (so dlgs can be shown) |
| 105 | |
| 106 | bool RegisterGlobalGraphics(); // register global Graphics.c4g into own group set |
| 107 | bool RegisterMainGroups(); // register new groups of Game.GroupSet into own group set |
| 108 | void CloseFiles(); // free group set |
| 109 | |
| 110 | bool ReloadResolutionDependentFiles(); // reload any files that depend on the current resolution |
| 111 | |
| 112 | protected: |
| 113 | bool LoadFile(C4FacetExID &fct, const char *szName, C4GroupSet &rGfxSet, int32_t iWdt = C4FCT_Full, int32_t iHgt = C4FCT_Full, bool fNoWarnIfNotFound = false); |
| 114 | bool LoadFile(C4Surface &sfc, const char *szName, C4GroupSet &rGfxSet, int32_t &ridCurrSfc); |
| 115 | bool LoadCursorGfx(); |
| 116 | void ApplyCursorGfx(); |
| 117 | |
| 118 | friend class C4GUI::Resource; |
| 119 | friend class C4StartupGraphics; |
| 120 | }; |
| 121 | |