ArcdpsExtension
 
Loading...
Searching...
No Matches
ArcdpsExtension::IconLoader Class Referencefinal

#include <IconLoader.h>

Inheritance diagram for ArcdpsExtension::IconLoader:
Collaboration diagram for ArcdpsExtension::IconLoader:

Public Member Functions

 IconLoader (HMODULE pDll, ID3D11Device *pD11Device)
 
 ~IconLoader () override
 
void RegisterFile (IconLoaderKey auto pName, const std::filesystem::path &pFilepath)
 
void RegisterUrl (IconLoaderKey auto pName, const std::string &pUrl)
 
void RegisterGw2Dat (IconLoaderKey auto pName, const std::string &pId)
 
void RegisterResource (IconLoaderKey auto pName, UINT pId)
 
ID3D11ShaderResourceView * Draw (IconLoaderKey auto pName)
 
- Public Member Functions inherited from ArcdpsExtension::Singleton< IconLoader >
 ~Singleton () override
 
- Public Member Functions inherited from ArcdpsExtension::BaseSingleton
virtual ~BaseSingleton ()=default
 

Additional Inherited Members

- Static Public Member Functions inherited from ArcdpsExtension::Singleton< IconLoader >
static T2 & instance ()
 
static T2 & init (Args &&... args)
 
static void f (std::function< void(T2 &)> action)
 
static void f (std::function< void(IconLoader &)> action)
 
static void reset ()
 
- Static Protected Member Functions inherited from ArcdpsExtension::BaseSingleton
static BaseSingletonStore (std::unique_ptr< BaseSingleton > &&ptr)
 
static void Clear (BaseSingleton *ptr)
 

Detailed Description

Load icons in a separate thread.
Always have an enum or any other list of numbers as unique ID.
Make sure to call IconLoader::init(HMODULE, ID3D11Device*) before you use this class. If instance() is called without init(), an exception is thrown.

Class-Internal flow:

MainThread::Register()
↳ lock mThreadMutex
↳ mThreadQueue
IconLoaderThread::runner()
↳ Load()
↳ lock mLoadQueueMutex
↳ mLoadQueue
MainThread::Draw()
↳ lock mLoadQueueMutex
↳ extract from mLoadQueue
↳ mIcons
ID3D11ShaderResourceView * Draw(IconLoaderKey auto pName)
Definition IconLoader.h:201

Constructor & Destructor Documentation

◆ IconLoader()

ArcdpsExtension::IconLoader::IconLoader ( HMODULE  pDll,
ID3D11Device *  pD11Device 
)

Call IconLoader::init(HMODULE, ID3D11Device*) in mod_init(). If this is not called properly, it will crash when icons are loaded.

Parameters
pDllThe DLL of this module (the one to load resources from)
pD11DeviceThe D3D11 device

◆ ~IconLoader()

ArcdpsExtension::IconLoader::~IconLoader ( )
override

Member Function Documentation

◆ Draw()

ID3D11ShaderResourceView * ArcdpsExtension::IconLoader::Draw ( IconLoaderKey auto  pName)

Get the ResourceView* from a previously Registered Icon.

Parameters
pNameUID of the Icon (will be casted to IconLoaderKeyType)
Returns
either the ResourceView* or nullptr if loading failed or is in progress.

◆ RegisterFile()

void ArcdpsExtension::IconLoader::RegisterFile ( IconLoaderKey auto  pName,
const std::filesystem::path &  pFilepath 
)

Register an Icon that will be loaded from a file.

Parameters
pNameUID of the Icon (will be casted to IconLoaderKeyType)
pFilepathThe Path to the file that will be loaded (has to exist, else nothing happens)

◆ RegisterGw2Dat()

void ArcdpsExtension::IconLoader::RegisterGw2Dat ( IconLoaderKey auto  pName,
const std::string &  pId 
)

Register an Icon that will be downloaded from gw2dat.com. It will cache files in the Temp Dir.

Parameters
pNameUID of the Icon (will be casted to IconLoaderKeyType)
pIdThe ID to download from gw2dat.com (.png will be added to the id)

◆ RegisterResource()

void ArcdpsExtension::IconLoader::RegisterResource ( IconLoaderKey auto  pName,
UINT  pId 
)

Register an Icon that will be loaded from the Resource of the module defined in Setup().

Parameters
pNameUID of the Icon (will be casted to IconLoaderKeyType)
pIdThe ID of the resource to load (normally defined in resource.h)

◆ RegisterUrl()

void ArcdpsExtension::IconLoader::RegisterUrl ( IconLoaderKey auto  pName,
const std::string &  pUrl 
)

Register an Icon that will be downloaded and then loaded. It will cache files in the Temp Dir.

Parameters
pNameUID of the Icon (will be casted to IconLoaderKeyType)
pUrlThe URL to download (has to be a full link, like https://wiki.guildwars2.com/images/4/4c/Alacrity.png)

The documentation for this class was generated from the following files: