2021-10-25 10:03:27 -04:00
|
|
|
#include <string>
|
|
|
|
#include <rw/rwcore.h>
|
|
|
|
#include "json.h"
|
2021-08-12 23:28:19 -04:00
|
|
|
#include "../depend/imgui/imgui.h"
|
|
|
|
#include "d3d9.h"
|
|
|
|
|
2021-12-24 05:36:07 -05:00
|
|
|
/*
|
|
|
|
Global resource handler class
|
|
|
|
Handles both image and json resources
|
|
|
|
*/
|
2021-08-12 23:28:19 -04:00
|
|
|
struct RwD3D9Raster
|
|
|
|
{
|
2021-10-25 10:03:27 -04:00
|
|
|
union
|
|
|
|
{
|
|
|
|
IDirect3DTexture9* texture;
|
|
|
|
IDirect3DSurface9* surface;
|
|
|
|
};
|
|
|
|
unsigned char* palette;
|
|
|
|
unsigned char alpha;
|
|
|
|
unsigned char cubeTextureFlags; /* 0x01 IS_CUBEMAP_TEX */
|
|
|
|
unsigned char textureFlags; /* 0x10 IS_COMPRESSED */
|
|
|
|
unsigned char lockedLevel;
|
|
|
|
IDirect3DSurface9* lockedSurface;
|
|
|
|
D3DLOCKED_RECT lockedRect;
|
|
|
|
D3DFORMAT format;
|
|
|
|
IDirect3DSwapChain9* swapChain;
|
|
|
|
HWND* hwnd;
|
2021-08-12 23:28:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RwRasterEx : public RwRaster
|
|
|
|
{
|
2021-10-25 10:03:27 -04:00
|
|
|
RwD3D9Raster *m_pRenderResource;
|
2021-08-12 23:28:19 -04:00
|
|
|
};
|
|
|
|
|
2021-08-27 23:12:20 -04:00
|
|
|
struct TextureResource
|
2021-08-12 23:28:19 -04:00
|
|
|
{
|
2021-10-25 10:03:27 -04:00
|
|
|
std::string m_FileName;
|
|
|
|
std::string m_CategoryName;
|
|
|
|
RwTexture *m_pRwTexture = nullptr;
|
|
|
|
void *m_pTexture = nullptr;
|
2021-08-12 23:28:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum eResourceType
|
|
|
|
{
|
2021-10-25 10:03:27 -04:00
|
|
|
TYPE_IMAGE,
|
|
|
|
TYPE_TEXT,
|
|
|
|
TYPE_BOTH,
|
2021-08-12 23:28:19 -04:00
|
|
|
};
|
|
|
|
|
2021-08-27 23:12:20 -04:00
|
|
|
using TextureResourceList = std::vector<std::unique_ptr<TextureResource>>;
|
2021-08-12 23:28:19 -04:00
|
|
|
class ResourceStore
|
|
|
|
{
|
|
|
|
private:
|
2021-10-25 10:03:27 -04:00
|
|
|
void LoadTextureResource(std::string&& path);
|
2021-08-12 23:28:19 -04:00
|
|
|
|
|
|
|
public:
|
2021-10-25 10:03:27 -04:00
|
|
|
ImGuiTextFilter m_Filter = "";
|
|
|
|
std::vector<std::string> m_Categories = {"All"};
|
|
|
|
std::string m_Selected = "All";
|
|
|
|
std::unique_ptr<CJson> m_pJson;
|
|
|
|
TextureResourceList m_ImagesList;
|
|
|
|
ImVec2 m_ImageSize;
|
|
|
|
bool m_bTexturesLoaded = false;
|
|
|
|
|
|
|
|
ResourceStore(const char* text, eResourceType type = TYPE_IMAGE, ImVec2 imageSize = ImVec2(64, 64));
|
2021-08-12 23:28:19 -04:00
|
|
|
};
|