| 1 | /* |
| 2 | * LegacyClonk |
| 3 | * |
| 4 | * Copyright (c) RedWolf Design |
| 5 | * Copyright (c) 2001, Sven2 |
| 6 | * Copyright (c) 2017-2023, The LegacyClonk Team and contributors |
| 7 | * |
| 8 | * Distributed under the terms of the ISC license; see accompanying file |
| 9 | * "COPYING" for details. |
| 10 | * |
| 11 | * "Clonk" is a registered trademark of Matthes Bender, used with permission. |
| 12 | * See accompanying file "TRADEMARK" for details. |
| 13 | * |
| 14 | * To redistribute this file separately, substitute the full license texts |
| 15 | * for the above references. |
| 16 | */ |
| 17 | |
| 18 | #pragma once |
| 19 | |
| 20 | #include "C4Gui.h" |
| 21 | #include "C4Surface.h" |
| 22 | |
| 23 | namespace C4GUI |
| 24 | { |
| 25 | // graphical resources |
| 26 | class Resource |
| 27 | { |
| 28 | private: |
| 29 | static Resource *pRes; // current GUI resources |
| 30 | |
| 31 | protected: |
| 32 | C4Surface sfcCaption, sfcButton, sfcButtonD; |
| 33 | C4Surface sfcScroll, sfcContext; |
| 34 | int32_t idSfcCaption, idSfcButton, idSfcButtonD, idSfcScroll, idSfcContext; |
| 35 | |
| 36 | public: |
| 37 | DynBarFacet barCaption, barButton, barButtonD; |
| 38 | C4FacetExID fctButtonHighlight; |
| 39 | C4FacetExID fctIcons, fctIconsEx; |
| 40 | C4FacetExID ; |
| 41 | C4FacetExID fctCheckbox; |
| 42 | C4FacetExID fctBigArrows; |
| 43 | C4FacetExID fctProgressBar; |
| 44 | C4FacetExID fctSpinBoxArrow; |
| 45 | ScrollBarFacets sfctScroll; |
| 46 | C4Facet fctContext; |
| 47 | |
| 48 | CStdFont &CaptionFont; // small, bold font |
| 49 | CStdFont &TitleFont; // large, bold font |
| 50 | CStdFont &TextFont; // font for normal text |
| 51 | CStdFont &MiniFont; // tiny font (logfont) |
| 52 | CStdFont &TooltipFont; // same as BookFont |
| 53 | |
| 54 | public: |
| 55 | Resource(CStdFont &rCaptionFont, CStdFont &rTitleFont, CStdFont &rTextFont, CStdFont &rMiniFont, CStdFont &rTooltipFont) |
| 56 | : idSfcCaption(0), idSfcButton(0), idSfcButtonD(0), idSfcScroll(0), idSfcContext(0), |
| 57 | CaptionFont(rCaptionFont), TitleFont(rTitleFont), TextFont(rTextFont), MiniFont(rMiniFont), TooltipFont(rTooltipFont) {} |
| 58 | ~Resource() { Clear(); } |
| 59 | |
| 60 | bool Load(C4GroupSet &rFromGroup); // load resources |
| 61 | void Clear(); // clear data |
| 62 | |
| 63 | public: |
| 64 | static Resource *Get() { return pRes; } // get res ptr - only set if successfully loaded |
| 65 | static void Unload() { delete pRes; } // unload any GUI resources |
| 66 | |
| 67 | CStdFont &GetFontByHeight(int32_t iHgt, float *pfZoom = nullptr); // get optimal font for given control size |
| 68 | }; |
| 69 | |
| 70 | // shortcut for GUI resource gfx |
| 71 | inline Resource *GetRes() { return Resource::Get(); } |
| 72 | inline bool IsResLoaded() { return Resource::Get() != nullptr; } |
| 73 | } |
| 74 | |