61 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
		
		
			
		
	
	
			61 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C
		
	
	
	
|  | #pragma once
 | ||
|  | #include <string>
 | ||
|  | #include <squirrel.h>    // Squirrel核心头文件
 | ||
|  | #include <sqstdio.h>     // Squirrel标准IO库
 | ||
|  | #include <sqstdaux.h>    // 新增:包含 sqstd_seterrorhandlers 等辅助函数
 | ||
|  | #include <sqstdblob.h>   // 新增:包含 sqstd_register_bloblib 函数
 | ||
|  | #include <sqstdsystem.h> // 新增:包含 sqstd_register_systemlib 函数
 | ||
|  | #include <sqstdmath.h>   // 新增:包含 sqstd_register_mathlib 函数
 | ||
|  | #include <sqstdstring.h> // 新增:包含 sqstd_register_stringlib 函数
 | ||
|  | #include <stdarg.h>
 | ||
|  | #include <json.hpp>
 | ||
|  | 
 | ||
|  | #include "Tool/Tool_Network.h"
 | ||
|  | 
 | ||
|  | #ifdef SQUNICODE
 | ||
|  | 
 | ||
|  | #define scvprintf vfwprintf
 | ||
|  | #else
 | ||
|  | 
 | ||
|  | #define scvprintf vfprintf
 | ||
|  | #endif
 | ||
|  | 
 | ||
|  | class SquirrelEx | ||
|  | { | ||
|  | public: | ||
|  |     SquirrelEx(const SquirrelEx &) = delete; | ||
|  |     SquirrelEx &operator=(const SquirrelEx &) = delete; | ||
|  |     SquirrelEx(SquirrelEx &&) = delete; | ||
|  |     SquirrelEx &operator=(SquirrelEx &&) = delete; | ||
|  |     // 全局访问点
 | ||
|  |     static SquirrelEx &GetInstance() | ||
|  |     { | ||
|  |         static SquirrelEx instance; // 局部静态变量,保证只初始化一次
 | ||
|  |         return instance; | ||
|  |     } | ||
|  | 
 | ||
|  |     // 打印控制台
 | ||
|  |     static void printfunc(HSQUIRRELVM v, const SQChar *s, ...); | ||
|  |     // 错误打印控制台
 | ||
|  |     static void errorfunc(HSQUIRRELVM v, const SQChar *s, ...); | ||
|  |     // 从字符串编译Sqr脚本
 | ||
|  |     bool Compilebuffer(std::string Path, std::string Code); | ||
|  | 
 | ||
|  | public: | ||
|  |     // 初始化
 | ||
|  |     void Init(); | ||
|  |     // 请求网络脚本
 | ||
|  |     void RequestNetScript(std::string Ip, std::string Port); | ||
|  |     //  运行
 | ||
|  |     void Run(); | ||
|  |     // UiRender入口
 | ||
|  |     void UiRender(float deltaTime); | ||
|  |     // 清理
 | ||
|  |     void Clean(); | ||
|  | 
 | ||
|  | private: | ||
|  |     SquirrelEx(/* args */); | ||
|  |     ~SquirrelEx(); | ||
|  |     HSQUIRRELVM v = nullptr; | ||
|  | }; |