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
23namespace C4GUI
24{
25// graphical resources
26class Resource
27{
28private:
29 static Resource *pRes; // current GUI resources
30
31protected:
32 C4Surface sfcCaption, sfcButton, sfcButtonD;
33 C4Surface sfcScroll, sfcContext;
34 int32_t idSfcCaption, idSfcButton, idSfcButtonD, idSfcScroll, idSfcContext;
35
36public:
37 DynBarFacet barCaption, barButton, barButtonD;
38 C4FacetExID fctButtonHighlight;
39 C4FacetExID fctIcons, fctIconsEx;
40 C4FacetExID fctSubmenu;
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
54public:
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
63public:
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
71inline Resource *GetRes() { return Resource::Get(); }
72inline bool IsResLoaded() { return Resource::Get() != nullptr; }
73}
74