-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIconTextureCache.h
More file actions
45 lines (32 loc) · 1.32 KB
/
IconTextureCache.h
File metadata and controls
45 lines (32 loc) · 1.32 KB
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
#pragma once
#include "BuildOrderTypes.h"
#include <filesystem>
#include <string>
#include <unordered_map>
#include <vector>
#include <d3d9.h>
#include "imgui.h"
class IconTextureCache
{
public:
void SetDevice(IDirect3DDevice9* pDevice) { m_pDevice = pDevice; }
void SetBaseDirectory(std::filesystem::path exeDirectory);
void InvalidateAll();
ImTextureID GetIconTexture(BuildRace eRace, const std::string& sIconId);
/** Loads only `data/icons/common/<race>.png` (exact filenames, no *_terran suffix scans). Use for HUD race picker. */
ImTextureID GetRaceFilterTexture(BuildRace eRace);
ImTextureID GetUiIconTexture(const std::string& sName);
ImTextureID GetUnknownTexture();
private:
IDirect3DDevice9* m_pDevice = nullptr;
std::filesystem::path m_exeDir;
std::vector<std::filesystem::path> m_vSearchRoots;
IDirect3DTexture9* m_pUnknownTint = nullptr;
std::unordered_map<std::string, IDirect3DTexture9*> m_loadedByKey;
static std::string MakeKey(BuildRace eRace, const std::string& sIconId);
static const char* RaceSubdir(BuildRace eRace);
IDirect3DTexture9* LoadPngFile(const std::filesystem::path& path);
void RebuildSearchRoots();
static IDirect3DTexture9* CreateSolidTexture(IDirect3DDevice9* pDevice, int iW, int iH, D3DCOLOR color);
bool EnsureUnknownTint();
};