The server tree of https://code.moenext.com/nanahira/ygopro.git, branch server, commit 52c868ce071ea0f2fcb0cf39bf2fb4151d12b90c, stock: gframe/, premake5.lua, .ci/, LICENSE, and gframe/ygopro.rc + .ico (upstream keeps them in resource/ and copies them in before building). No game assets, no scripts, no ocgcore submodule: the core is ../core. The third-party sources upstream's Windows CI downloads are vendored here at the positions its premake expects, each with its premake fragment from upstream's premake/ folder inside it: lua 5.4.8, sqlite 3.53.3, libevent 2.1.13-stable (tests, samples and autotools helpers left out; the files its Windows prebuild copies into include/ left out), zlib 1.3.2 (contrib and examples left out), xz 5.8.3 (src/liblzma + src/common only), and irrlicht 1.9 from mycard at 20f86d25: include/ plus the source/Irrlicht headers and the 11 .cpp files the server's zip reader project compiles. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
103 lines
3.8 KiB
C++
103 lines
3.8 KiB
C++
#ifndef IMAGEMANAGER_H
|
|
#define IMAGEMANAGER_H
|
|
|
|
#include "config.h"
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <queue>
|
|
#include <mutex>
|
|
|
|
namespace ygo {
|
|
|
|
class ImageManager {
|
|
private:
|
|
irr::video::ITexture* addTexture(const char* name, irr::video::IImage* srcimg, irr::s32 width, irr::s32 height);
|
|
|
|
// Internal implementation using void* for type erasure
|
|
void* LoadFromSearchPathsImpl(int code, const char* subpath, const std::vector<const char*>& extensions, void* (*callback)(void*, const char*), void* userdata);
|
|
|
|
// Load file from search paths (expansions, locale, default) with callback
|
|
template<typename Func>
|
|
auto LoadFromSearchPaths(int code, const char* subpath, const std::vector<const char*>& extensions, Func callback) -> decltype(callback("")) {
|
|
using RetType = decltype(callback(""));
|
|
auto wrapper = [](void* userdata, const char* file) -> void* {
|
|
auto& func = *static_cast<Func*>(userdata);
|
|
return static_cast<void*>(func(file));
|
|
};
|
|
return static_cast<RetType>(LoadFromSearchPathsImpl(code, subpath, extensions, wrapper, &callback));
|
|
}
|
|
public:
|
|
std::vector<std::wstring> ImageList[7];
|
|
int saved_image_id[7];
|
|
bool Initial();
|
|
//random image
|
|
irr::video::ITexture* GetRandomImage(int image_type);
|
|
irr::video::ITexture* GetRandomImage(int image_type, irr::s32 width, irr::s32 height);
|
|
void RefreshRandomImageList();
|
|
void RefreshImageDir(std::wstring path, int image_type);
|
|
void SetDevice(irr::IrrlichtDevice* dev);
|
|
void ClearTexture();
|
|
void ResizeTexture();
|
|
irr::video::ITexture* GetTextureFromFile(const char* file, irr::s32 width, irr::s32 height);
|
|
irr::video::IImage* GetImage(int code, irr::s32 targetWidth = 0, irr::s32 targetHeight = 0);
|
|
irr::video::ITexture* GetTexture(int code, irr::s32 width, irr::s32 height);
|
|
irr::video::ITexture* GetTexture(int code, bool fit = false);
|
|
irr::video::ITexture* GetBigPicture(int code, float zoom);
|
|
irr::video::ITexture* GetTextureThumb(int code);
|
|
irr::video::ITexture* GetTextureField(int code);
|
|
irr::video::ITexture* GetTextureButton(int code, bool defense = false);
|
|
static void LoadThumbThread();
|
|
|
|
std::unordered_map<int, irr::video::ITexture*> tMap[2];
|
|
std::unordered_map<int, irr::video::ITexture*> tThumb;
|
|
std::unordered_map<int, irr::video::ITexture*> tFields;
|
|
std::unordered_map<int, irr::video::ITexture*> tButton;
|
|
std::unordered_map<int, irr::video::ITexture*> tButtonDefense;
|
|
std::unordered_map<int, irr::video::IImage*> tThumbLoading;
|
|
std::queue<int> tThumbLoadingCodes;
|
|
std::mutex tThumbLoadingMutex;
|
|
bool tThumbLoadingThreadRunning;
|
|
irr::IrrlichtDevice* device;
|
|
irr::video::IVideoDriver* driver;
|
|
irr::io::IFileSystem* irrFileSystem;
|
|
irr::video::ITexture* tCover[2];
|
|
irr::video::ITexture* tButtonFacedown[2];
|
|
irr::video::ITexture* tButtonFacedownDefense[2];
|
|
irr::video::ITexture* tUnknown;
|
|
irr::video::ITexture* tUnknownFit;
|
|
irr::video::ITexture* tUnknownThumb;
|
|
irr::video::ITexture* tBigPicture;
|
|
irr::video::ITexture* tLoading;
|
|
irr::video::ITexture* tAct;
|
|
irr::video::ITexture* tAttack;
|
|
irr::video::ITexture* tNegated;
|
|
irr::video::ITexture* tChain;
|
|
irr::video::ITexture* tNumber;
|
|
irr::video::ITexture* tLPFrame;
|
|
irr::video::ITexture* tLPBar;
|
|
irr::video::ITexture* tMask;
|
|
irr::video::ITexture* tEquip;
|
|
irr::video::ITexture* tTarget;
|
|
irr::video::ITexture* tChainTarget;
|
|
irr::video::ITexture* tLim;
|
|
irr::video::ITexture* tLimCredit;
|
|
irr::video::ITexture* tOT;
|
|
irr::video::ITexture* tHand[3];
|
|
irr::video::ITexture* tBackGround;
|
|
irr::video::ITexture* tBackGround_menu;
|
|
irr::video::ITexture* tBackGround_deck;
|
|
irr::video::ITexture* tCardType;
|
|
irr::video::ITexture* tField[2];
|
|
irr::video::ITexture* tFieldTransparent[2];
|
|
irr::video::ITexture* tRScale[14];
|
|
irr::video::ITexture* tLScale[14];
|
|
irr::video::ITexture* tClock;
|
|
};
|
|
|
|
extern ImageManager imageManager;
|
|
|
|
}
|
|
|
|
#endif // IMAGEMANAGER_H
|