61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			1.5 KiB
		
	
	
	
		
			C
		
	
	
	
|  | #pragma once
 | ||
|  | #include <switch.h>
 | ||
|  | #include <stdio.h>
 | ||
|  | #include <string>
 | ||
|  | #include <dirent.h>
 | ||
|  | #include <SDL.h>
 | ||
|  | #include <map>
 | ||
|  | 
 | ||
|  | #include "Tool/Ifstream_PVF.h"
 | ||
|  | 
 | ||
|  | class Asset_Script : public Ifstream_PVF | ||
|  | { | ||
|  | public: | ||
|  |     struct PvfFileInfo | ||
|  |     { | ||
|  |         int ROffset; | ||
|  |         int Cr32; | ||
|  |         int Length; | ||
|  |         bool DecodeFlag = false; | ||
|  |     }; | ||
|  | 
 | ||
|  | private: | ||
|  |     Asset_Script(const std::string filename = "Script.pvf") : Ifstream_PVF(filename) {}; | ||
|  |     ~Asset_Script() = default; | ||
|  | 
 | ||
|  |     int StartPos = 0; | ||
|  |     std::map<std::string, PvfFileInfo> FileInfo; | ||
|  |     std::map<int, std::string> BinStringM; | ||
|  |     std::map<std::string, std::map<std::string, std::string>> LoadStringM; | ||
|  | 
 | ||
|  | public: | ||
|  |     Asset_Script(const Asset_Script &) = delete; | ||
|  |     Asset_Script &operator=(const Asset_Script &) = delete; | ||
|  |     Asset_Script(Asset_Script &&) = delete; | ||
|  |     Asset_Script &operator=(Asset_Script &&) = delete; | ||
|  |     // 全局访问点
 | ||
|  |     static Asset_Script &GetInstance() | ||
|  |     { | ||
|  |         static Asset_Script instance; // 局部静态变量,保证只初始化一次
 | ||
|  |         return instance; | ||
|  |     } | ||
|  | 
 | ||
|  | public: | ||
|  |     void Init(); | ||
|  |     void InitHeader(); | ||
|  |     void InitBin(); | ||
|  |     void InitLoadString(); | ||
|  |     void Clear(); | ||
|  | 
 | ||
|  | public: | ||
|  |     std::string | ||
|  |     GetBinString(int Key); | ||
|  |     std::string GetLoadString(std::string Type, std::string Key); | ||
|  |     PvfFileInfo *GetFileInfo(std::string path); | ||
|  | 
 | ||
|  |     std::string GetFileContent(std::string path);           // 获取文件内容
 | ||
|  |     std::vector<BYTE> GetFileContentByte(std::string path); // 获取文件内容
 | ||
|  | 
 | ||
|  |     bool InitFlag = false; | ||
|  | }; |