初次转移

This commit is contained in:
Lenheart 2024-05-04 18:30:32 +08:00
commit 9a250a816c
76 changed files with 35804 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.vs/

1
BaseRead.cpp Normal file
View File

@ -0,0 +1 @@
#include "BaseRead.h"

93
BaseRead.h Normal file
View File

@ -0,0 +1,93 @@
#pragma once
#include <fstream>
#include <Windows.h>
#include <iostream>
class BaseRead :public std::fstream
{
private:
const BYTE Key[256] = { 112,117,99,104,105,107,111,110,64,110,101,111,112,108,101,32,100,117,110,103,101,111,110,32,97,110,100,32,102,105,103,104,116,101,114,32,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,0 };
public:
//char* 转整数
int CharToInt(char* Str)
{
return *(int*)Str;
}
//char* 转Long
long CharToLong(char* Str)
{
return *(long long*)Str;
}
//读整数
int ReadInt()
{
char* CountBuffer = new char[4];
for (int i = 0; i < 4; i++)
{
this->get(CountBuffer[i]);
}
int Count = CharToInt(CountBuffer);
delete[]CountBuffer;
return Count;
}
//读字符串
std::string ReadString()
{
char* CharBuffer = new char[1024];
this->get(CharBuffer, 1024, '\0');
std::string Str = CharBuffer;
delete[]CharBuffer;
this->seekg(1, std::ios::cur);
return Str;
}
//读取NPK信息
std::string ReadInfo()
{
char* CharBuffer = new char[256];
char var;
int i = 0;
while (i < 256)
{
this->get(var);
CharBuffer[i] = var ^ Key[i];
++i;
}
std::string Str = CharBuffer;
delete[] CharBuffer;
return Str;
}
//读LONG
int ReadLong()
{
char* CountBuffer = new char[8];
for (int i = 0; i < 8; i++)
{
this->get(CountBuffer[i]);
}
long Count = CharToLong(CountBuffer);
delete[]CountBuffer;
return Count;
}
//读指定长度数据
BYTE* ReadCustomSize(int Size)
{
BYTE* CharBuffer = new BYTE[Size];
for (int j = 0; j < Size; j++)
{
char var;
this->get(var);
CharBuffer[j] = var;
}
return CharBuffer;
}
};

159
ButtonActorRegister.h Normal file
View File

@ -0,0 +1,159 @@
#pragma once
//创建按钮
static SQInteger Create_Button(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SquirrelButtonPtr Button = new SquirrelButton();
//获取对象的唯一ID
uint64_t UUID = Button->GetObjectID();
//将按钮对象存入Map管理
ActorPtrMapObject[UUID] = Button;
sq_pushinteger(v, UUID);
return 1;
}
//设置按钮状态纹理
static SQInteger Button_Load_Texture(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
const SQChar* Path;
sq_getstring(v, 3, &Path);
SQInteger Frame;
sq_getinteger(v, 4, &Frame);
if (ActorPtrMapObject.count(ActorUUID)) {
SquirrelButtonPtr Button = dynamic_cast<SquirrelButton*>(ActorPtrMapObject[ActorUUID].Get());
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg((char*)Path, Frame);
Button->SetFrame(t);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//初始化按钮
static SQInteger Button_Init(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
if (ActorPtrMapObject.count(ActorUUID)) {
SquirrelButtonPtr Button = dynamic_cast<SquirrelButton*>(ActorPtrMapObject[ActorUUID].Get());
Button->Init();
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//判断按钮是否被点击
static SQInteger Button_IsPress(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger Type;
sq_getinteger(v, 3, &Type);
if (ActorPtrMapObject.count(ActorUUID)) {
SquirrelButtonPtr Button = dynamic_cast<SquirrelButton*>(ActorPtrMapObject[ActorUUID].Get());
sq_pushbool(v, Button->IsPress(Type));
}
else {
sq_pushnull(v);
}
return 1;
}
//判断按钮是否悬停
static SQInteger Button_IsHover(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
if (ActorPtrMapObject.count(ActorUUID)) {
SquirrelButtonPtr Button = dynamic_cast<SquirrelButton*>(ActorPtrMapObject[ActorUUID].Get());
sq_pushbool(v, Button->IsHover());
}
else {
sq_pushnull(v);
}
return 1;
}
//移除自己的Z轴序列
static SQInteger Button_RemoveZorder(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
if (ActorPtrMapObject.count(ActorUUID)) {
SquirrelButtonPtr Button = dynamic_cast<SquirrelButton*>(ActorPtrMapObject[ActorUUID].Get());
Button->RemoveZorder();
sq_pushbool(v, true);
}
else {
sq_pushnull(v);
}
return 1;
}

218
CanvasActorRegister.h Normal file
View File

@ -0,0 +1,218 @@
#pragma once
//演员对象智能指针Map
extern std::map<uint64_t, ActorPtr>ActorPtrMapObject;
//创建画布
static SQInteger Create_Canvas(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQFloat X;
sq_getfloat(v, 2, &X);
SQFloat Y;
sq_getfloat(v, 3, &Y);
CanvasPtr _Canvas = new Canvas(PixelSize(X, Y));
//获取对象的唯一ID
uint64_t UUID = _Canvas->GetObjectID();
//将画布对象存入Map管理
ActorPtrMapObject[UUID] = _Canvas;
sq_pushinteger(v, UUID);
return 1;
}
//画布开始渲染
static SQInteger Canvas_BeginDraw(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
if (ActorPtrMapObject.count(ActorUUID)) {
CanvasPtr _Canvas = dynamic_cast<Canvas*>(ActorPtrMapObject[ActorUUID].Get());
CanvasRenderContextPtr _CanvasRenderContextPtr = _Canvas->GetContext2D();
_CanvasRenderContextPtr->SetTextAntialiasMode(TextAntialiasMode::None);
_CanvasRenderContextPtr->BeginDraw();
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//画布结束渲染
static SQInteger Canvas_EndDraw(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
if (ActorPtrMapObject.count(ActorUUID)) {
CanvasPtr _Canvas = dynamic_cast<Canvas*>(ActorPtrMapObject[ActorUUID].Get());
CanvasRenderContextPtr _CanvasRenderContextPtr = _Canvas->GetContext2D();
_CanvasRenderContextPtr->EndDraw();
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//画布绘制纹理
static SQInteger Canvas_DrawTexture(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
const SQChar* OutPutBuffer;
sq_getstring(v, 3, &OutPutBuffer);
SQInteger gFrame;
sq_getinteger(v, 4, &gFrame);
SQFloat X;
sq_getfloat(v, 5, &X);
SQFloat Y;
sq_getfloat(v, 6, &Y);
if (ActorPtrMapObject.count(ActorUUID)) {
CanvasPtr _Canvas = dynamic_cast<Canvas*>(ActorPtrMapObject[ActorUUID].Get());
CanvasRenderContextPtr _CanvasRenderContextPtr = _Canvas->GetContext2D();
//只有坐标参数
if (Top == 6) {
Vec2 POS = Vec2(X, Y);
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg((char*)OutPutBuffer, gFrame);
_CanvasRenderContextPtr->DrawTexture(t, POS);
}
else if (Top == 8) {
SQFloat XSize;
sq_getfloat(v, 7, &XSize);
SQFloat YSize;
sq_getfloat(v, 8, &YSize);
Vec2 POS = Vec2(X, Y);
Vec2 Size = Vec2(X + XSize, Y + YSize);
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg((char*)OutPutBuffer, gFrame);
_CanvasRenderContextPtr->DrawTexture(t, POS, Size);
}
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//画布绘制文字
static SQInteger Canvas_DrawText(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
//得到Squirrel字符串 字体路径Key
const SQChar* OutPutBuffer;
sq_getstring(v, 3, &OutPutBuffer);
//此操作会New出一个字符串需要手动销毁
char* OutPutTextbuf = SquirrelClassEx::SquirrelU2W((char*)OutPutBuffer);
std::string OutPutText = OutPutTextbuf;
//销毁New出来的字符串
delete[]OutPutTextbuf;
//通过字体创建文本样式
if (Top == 7) {
//得到Squirrel字符串 文字内容
const SQChar* TextStringBuffer;
sq_getstring(v, 4, &TextStringBuffer);
//此操作会New出一个字符串需要手动销毁
char* TextStringbuf = SquirrelClassEx::SquirrelU2W((char*)TextStringBuffer);
//需要绘制的文字内容
std::string TextString = TextStringbuf;
//销毁New出来的字符串
delete[]TextStringbuf;
SQInteger FontColor;
sq_getinteger(v, 5, &FontColor);
SQFloat Xpos;
sq_getfloat(v, 6, &Xpos);
SQFloat Ypos;
sq_getfloat(v, 7, &Ypos);
//从全局Map中获取画布对象
if (ActorPtrMapObject.count(ActorUUID)) {
CanvasPtr _Canvas = dynamic_cast<Canvas*>(ActorPtrMapObject[ActorUUID].Get());
CanvasRenderContextPtr _CanvasRenderContextPtr = _Canvas->GetContext2D();
TextStyle TsP = TextStyle(FontRecObject[OutPutText]);
TsP.alignment = TextAlign::Center;
/*
// 创建线性渐变样式
LinearGradientStyle fill_style = LinearGradientStyle(
Point(_Canvas->GetWidth() / 3, 0.0f), // 线性样式起点
Point(_Canvas->GetWidth() * 2 / 3, _Canvas->GetHeight()), // 线性样式终点
{ GradientStop(0.0f, Color::Yellow), GradientStop(1.0f, Color::Green) }
);
*/
BrushPtr fill_brush = new Brush(FontColor);
_CanvasRenderContextPtr->SetFillBrush(fill_brush);
_CanvasRenderContextPtr->DrawTextLayout(TextString, TsP, Point(Xpos, Ypos));
sq_pushbool(v, true);
}
}
else {
sq_pushbool(v, false);
}
return 1;
}

55
Cursor.cpp Normal file
View File

@ -0,0 +1,55 @@
#include "Cursor.h"
#include "SquirrelClassEx.h"
//譜崔報炎貸辞
void SetCursorGameLogic() {
WindowPtr window = Application::GetInstance().GetWindow();
int X = window->GetPosX();
int MaxX = window->GetWidth() + X;
int Y = window->GetPosY();
int MaxY = window->GetHeight() + Y;
POINT pt = { 0, 0 };
GetCursorPos(&pt);
if (pt.x >= X && pt.x <= MaxX && pt.y >= Y && pt.y <= MaxY /*&& GetForegroundWindow() == window->GetHandle()*/) {
ShowCursor(FALSE);
}
}
Cursor::Cursor()
{
this->SetName("GameCursorObject");
this->Retain();
}
void Cursor::OnUpdate(Duration dt)
{
static bool Init = false;
if (!Init) {
TexturePtr ImageBuf = SquirrelClassEx::GetTexturePtrByImg("sprite/interface/cursor.img",0);
this->SetFrame(ImageBuf);
Init = true;
}
////資函補秘
Input& input = Input::GetInstance();
////譜崔"報炎"斤<>恫炎吉噐報炎恫炎
this->SetPosition(input.GetMousePos());
//std::cout << (int)GetCursor() << std::endl;
//譜崔報炎<E5A0B1>払議貸辞
if ((int)GetCursor() == 65541) {
SetCursorGameLogic();
this->SetVisible(true);
}
else {
this->SetVisible(false);
}
}

12
Cursor.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
class Cursor :public Sprite
{
public:
Cursor();
void OnUpdate(Duration dt) override;
};

191
GameState.cpp Normal file
View File

@ -0,0 +1,191 @@
#include "GameState.h"
#include "SquirrelActor.h"
extern SquirrelClassEx* TObject;
extern NPK_M* npk;
std::map<std::string, Sound*>SoundRecObject;
std::unordered_map<std::string, std::map<int,TexturePtr>>ImageRecObject;
std::map<std::string, FontPtr>FontRecObject;
WThreadPool threadPool;
Cursor* Mouse_Object = new Cursor();
void InitSound(const TCHAR* directory)
{
WIN32_FIND_DATA fileInfo;
TCHAR buffer[MAX_PATH];
// 构建搜索路径
_tcscpy_s(buffer, directory);
_tcscat_s(buffer, _T("\\*.*"));
// 查找第一个文件/目录
HANDLE hFind = FindFirstFile(buffer, &fileInfo);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
// 排除 "." 和 ".."
if (_tcscmp(fileInfo.cFileName, _T(".")) != 0 && _tcscmp(fileInfo.cFileName, _T("..")) != 0)
{
// 如果是目录,则递归遍历子目录
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
_tcscpy_s(buffer, directory);
_tcscat_s(buffer, _T("\\"));
_tcscat_s(buffer, fileInfo.cFileName);
InitSound(buffer);
}
else {
// 输出文件名
//_tprintf(_T("%s\\%s\n"), directory, fileInfo.cFileName);
char output[1024];
sprintf(output, "%ws\\%ws", directory,fileInfo.cFileName);
std::string path = output;
std::replace(path.begin(), path.end(), '\\', '/');
Sound* sou = new Sound(path);
//sou->Preload(path);
SoundRecObject[path] = sou;
//std::cout << "音频资源___" << path << "____已加载" << std::endl;
}
}
} while (FindNextFile(hFind, &fileInfo));
FindClose(hFind);
}
}
void InitFont(const TCHAR* directory)
{
WIN32_FIND_DATA fileInfo;
TCHAR buffer[MAX_PATH];
// 构建搜索路径
_tcscpy_s(buffer, directory);
_tcscat_s(buffer, _T("\\*.*"));
// 查找第一个文件/目录
HANDLE hFind = FindFirstFile(buffer, &fileInfo);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
// 排除 "." 和 ".."
if (_tcscmp(fileInfo.cFileName, _T(".")) != 0 && _tcscmp(fileInfo.cFileName, _T("..")) != 0)
{
// 如果是目录,则递归遍历子目录
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
_tcscpy_s(buffer, directory);
_tcscat_s(buffer, _T("\\"));
_tcscat_s(buffer, fileInfo.cFileName);
InitFont(buffer);
}
else {
// 输出文件名
//_tprintf(_T("%s\\%s\n"), directory, fileInfo.cFileName);
char output[1024];
sprintf(output, "%ws\\%ws", directory, fileInfo.cFileName);
std::string path = output;
std::replace(path.begin(), path.end(), '\\', '/');
FontPtr FontBuf = new Font();
FontBuf->Preload(path);
FontRecObject[path] = FontBuf;
}
}
} while (FindNextFile(hFind, &fileInfo));
FindClose(hFind);
}
}
void LoadingScene_Success()
{
KGE_DEBUG_LOG("资源加载完成");
Stage* P_Stage = Director::GetInstance().GetCurrentStage().Get();
SquirrelStage* Push_Stage = (SquirrelStage*)P_Stage;
TObject->RunSceneScript("LoadingGame_Stage_Func", Push_Stage);
}
void InitGameRecFunc() {
//加载List
SquirrelClassEx::LoadingListScript();
//Sleep(4000);
//加载音频资源
InitSound(L"SoundPacks2/music");
//加载字体资源
InitFont(L"Font");
//预加载一下选择角色那个背景不然有点卡
for (size_t i = 0; i < 17; i++)
{
SquirrelClassEx::GetTexturePtrByImg("sprite/selectcharacter/background.img", i);
}
IMG* img = npk->ReadNpkTable("sprite/selectcharacter/background.img");
npk->ReleaseNpkTable(img);
Application::GetInstance().PerformInMainThread(LoadingScene_Success);
}
//#include <irrKlang.h>
//KGE_DECLARE_SMART_PTR(ISound);
void Setup()
{
//线程池初始化
threadPool.setMaxThreadNum(10);
//打开输入法
WindowPtr window = Application::GetInstance().GetWindow();
window->SetImmEnabled(true);
//New一个新线程去加载游戏所需资源
threadPool.concurrentRun(InitGameRecFunc);
//打开渲染模式
Director::GetInstance().SetRenderBorderEnabled(true);
//irrklang::ISoundEngine* engine = irrklang::createIrrKlangDevice();
/*SoundPtr SP = new Sound();
SP*/
/*loader.Load(fileData.get(), "ogg", memory.buffer);*/
//Renderer::GetInstance().GetContext().SetTextAntialiasMode(TextAntialiasMode::None);
}
void GameState::Run()
{
// 游戏设置
Settings s;
s.window.title = "Yosin - DOF"; // 窗口标题
s.window.width = 1600; // 窗口宽度
s.window.height = 900; // 窗口高度
// 取消垂直同步
s.vsync_enabled = false;
// 设置帧间隔时间
s.frame_interval = 1_sec / 10000;
s.debug_mode = true;
// 开启日志系统
//Logger::GetInstance().Enable();
//Application::GetInstance().Use(ImGuiModule::GetInstance());
Application::GetInstance().Use(AudioModule::GetInstance());
// 启动应用
Application::GetInstance().Run(s, Setup);
}

12
GameState.h Normal file
View File

@ -0,0 +1,12 @@
#pragma once
#include "SquirrelClassEx.h"
#include <map>
class GameState
{
public:
void Run();
};

194
ImguiLayerActorRegister.h Normal file
View File

@ -0,0 +1,194 @@
//#pragma once
////演员对象智能指针Map
//extern std::map<uint64_t, ActorPtr>ActorPtrMapObject;
//
//std::string UTF8toString(const std::string& strSrc)
//{
// int nwLen = MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), -1, NULL, 0);
//
// wchar_t* pwBuf = new wchar_t[nwLen + 1];//一定要加1不然会出现尾巴
// memset(pwBuf, 0, nwLen * 2 + 2);
//
// MultiByteToWideChar(CP_UTF8, 0, strSrc.c_str(), strSrc.length(), pwBuf, nwLen);
//
// int nLen = WideCharToMultiByte(CP_ACP, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
//
// char* pBuf = new char[nLen + 1];
// memset(pBuf, 0, nLen + 1);
//
// WideCharToMultiByte(CP_ACP, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
//
// std::string retStr = pBuf;
//
// delete[]pBuf;
// delete[]pwBuf;
//
// pBuf = NULL;
// pwBuf = NULL;
//
// return retStr;
//
//}
//
//std::string string_To_UTF8(const std::string& strSrc)
//{
// int nwLen = ::MultiByteToWideChar(CP_ACP, 0, strSrc.c_str(), -1, NULL, 0);
//
// wchar_t* pwBuf = new wchar_t[nwLen + 1];//一定要加1不然会出现尾巴
// ZeroMemory(pwBuf, nwLen * 2 + 2);
//
// ::MultiByteToWideChar(CP_ACP, 0, strSrc.c_str(), strSrc.length(), pwBuf, nwLen);
//
// int nLen = ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, -1, NULL, NULL, NULL, NULL);
//
// char* pBuf = new char[nLen + 1];
// ZeroMemory(pBuf, nLen + 1);
//
// ::WideCharToMultiByte(CP_UTF8, 0, pwBuf, nwLen, pBuf, nLen, NULL, NULL);
//
// std::string retStr(pBuf);
//
// delete[]pwBuf;
// delete[]pBuf;
//
// pwBuf = NULL;
// pBuf = NULL;
//
// return retStr;
//}
//
//void ControlPanel(const SQChar* Name)
//{
// ImGui::Begin(u8"测试窗口", 0, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove);
//
// sq_pushroottable(v);
// sq_pushstring(v, Name, -1);
// sq_get(v, -2);
// sq_pushroottable(v);
// sq_pushstring(v, _SST("Lenheart"), -1);
// sq_call(v, 2, 0, 1);
// sq_pop(v, 2);
//
//
// ImGui::End();
//}
//
//
//
////创建Imgui图层
//static SQInteger Create_ImguiLayer(HSQUIRRELVM v)
//{
// SQInteger Top = sq_gettop(v);
// if (Top <= 0)
// {
// sq_throwerror(v, _SST("Incorrect function argument"));
// return 0;
// }
//
// const SQChar* ImguiName;
// sq_getstring(v, 2, &ImguiName);
//
//
// auto f1 = std::bind(&ControlPanel, ImguiName);
//
// // 创建 ImGui 图层
// ImGuiLayerPtr layer = new ImGuiLayer((char*)ImguiName, f1);
//
// //获取对象的唯一ID
// uint64_t UUID = layer->GetObjectID();
//
// //将画布对象存入Map管理
// ActorPtrMapObject[UUID] = layer;
//
// sq_pushinteger(v, UUID);
//
// return 1;
//}
//
//
////创建Imgui文字
//static SQInteger Imgui_Text(HSQUIRRELVM v)
//{
// SQInteger Top = sq_gettop(v);
// if (Top <= 0)
// {
// sq_throwerror(v, _SST("Incorrect function argument"));
// return 0;
// }
//
// const SQChar* ImguiName;
// sq_getstring(v, 2, &ImguiName);
//
// ImGui::Text((char*)ImguiName);
//
// return 0;
//}
//
////设置窗口大小
//static SQInteger Imgui_SetWindowSize(HSQUIRRELVM v)
//{
// SQInteger Top = sq_gettop(v);
// if (Top <= 0)
// {
// sq_throwerror(v, _SST("Incorrect function argument"));
// return 0;
// }
//
// SQInteger X;
// SQInteger Y;
// sq_getinteger(v, 2, &X);
// sq_getinteger(v, 3, &Y);
//
// ImGui::SetWindowSize(ImVec2(X, Y));
// return 0;
//}
//
////设置窗口坐标
//static SQInteger Imgui_SetWindowPos(HSQUIRRELVM v)
//{
// SQInteger Top = sq_gettop(v);
// if (Top <= 0)
// {
// sq_throwerror(v, _SST("Incorrect function argument"));
// return 0;
// }
//
// SQInteger X;
// SQInteger Y;
// sq_getinteger(v, 2, &X);
// sq_getinteger(v, 3, &Y);
//
// ImGui::SetWindowPos(ImVec2(X, Y));
// return 0;
//}
//
//
////创建Imgui输入框
//static SQInteger Imgui_InputText(HSQUIRRELVM v)
//{
// SQInteger Top = sq_gettop(v);
// if (Top <= 0)
// {
// sq_throwerror(v, _SST("Incorrect function argument"));
// return 0;
// }
//
// const SQChar* InPutName;
// sq_getstring(v, 2, &InPutName);
//
// ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 255));
// static char buf[25] = u8"";
// ImGui::InputText("##", buf, IM_ARRAYSIZE(buf));
// ImGui::PopStyleColor();
//
//
//
// sq_pushroottable(v);
// sq_pushstring(v, InPutName, -1);
// sq_get(v, -2);
// sq_pushroottable(v);
// sq_pushstring(v, _SST(buf), -1);
// sq_call(v, 2, 0, 1);
// sq_pop(v, 2);
// return 0;
//}

90
LockQueue.hpp Normal file
View File

@ -0,0 +1,90 @@
#pragma once
#include <mutex>
#include <iostream>
template <typename T>
class LockQueue
{
public:
LockQueue()
{
QueueNode *node = new QueueNode();
node->next = nullptr;
// head->next is the first node, _tail point to last node, not _tail->next
_head = node;
_tail = _head;
};
virtual ~LockQueue()
{
clear();
delete _head;
_head = nullptr;
_tail = nullptr;
};
struct QueueNode
{
T value;
QueueNode *next;
};
bool enQueue(T data)
{
QueueNode *node = new (std::nothrow) QueueNode();
if (!node)
{
return false;
}
node->value = data;
node->next = nullptr;
std::unique_lock<std::mutex> locker(_mutex);
_tail->next = node;
_tail = node;
_queueSize++;
return true;
}
bool deQueue(T &data)
{
std::unique_lock<std::mutex> locker(_mutex);
QueueNode *currentFirstNode = _head->next;
if (!currentFirstNode)
{
return false;
}
_head->next = currentFirstNode->next;
data = currentFirstNode->value;
delete currentFirstNode;
_queueSize--;
if (_queueSize == 0)
{
_tail = _head;
}
return true;
}
int64_t size()
{
return _queueSize;
}
void clear()
{
T data;
while(deQueue(data));
}
bool empty()
{
return (_queueSize <= 0);
}
private:
QueueNode *_head;
QueueNode *_tail;
int64_t _queueSize = 0;
std::mutex _mutex;
};

394
Npk.cpp Normal file
View File

@ -0,0 +1,394 @@
#include "Npk.h"
#include <fstream>
#include <mutex>
std::mutex Npk_ImgMutex;
std::mutex Npk_PngMutex;
class ReadNpk :public std::ifstream
{
const BYTE Key[256] = { 112,117,99,104,105,107,111,110,64,110,101,111,112,108,101,32,100,117,110,103,101,111,110,32,97,110,100,32,102,105,103,104,116,101,114,32,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,68,78,70,0 };
public:
//char* 转整数
int CharToInt(char* Str)
{
return *(int*)Str;
}
//char* 转Long
long CharToLong(char* Str)
{
return *(long long*)Str;
}
//读整数
int ReadInt()
{
char* CountBuffer = new char[4];
for (int i = 0; i < 4; i++)
{
this->get(CountBuffer[i]);
}
int Count = CharToInt(CountBuffer);
delete[]CountBuffer;
return Count;
}
//读字符串
std::string ReadString()
{
char* CharBuffer = new char[1024];
this->get(CharBuffer, 1024, '\0');
std::string Str = CharBuffer;
delete[]CharBuffer;
this->seekg(1, std::ios::cur);
return Str;
}
//读取信息
std::string ReadInfo()
{
char* CharBuffer = new char[256];
char var;
int i = 0;
while (i < 256)
{
this->get(var);
CharBuffer[i] = var ^ Key[i];
++i;
}
std::string Str = CharBuffer;
delete[] CharBuffer;
return Str;
}
//读LONG
int ReadLong()
{
char* CountBuffer = new char[8];
for (int i = 0; i < 8; i++)
{
this->get(CountBuffer[i]);
}
long Count = CharToLong(CountBuffer);
delete[]CountBuffer;
return Count;
}
//读指定长度数据
BYTE* ReadCustomSize(int Size)
{
BYTE* CharBuffer = new BYTE[Size];
for (int j = 0; j < Size; j++)
{
char var;
this->get(var);
CharBuffer[j] = var;
}
return CharBuffer;
}
};
void ReadColor(BYTE* Tab, int Type, BYTE* SaveByte, int Offset)
{
BYTE a = 0;
BYTE r = 0;
BYTE g = 0;
BYTE b = 0;
switch (Type)
{
case 0x0e:
a = (byte)(Tab[1] >> 7);
r = (byte)((Tab[1] >> 2) & 0x1f);
g = (byte)((Tab[0] >> 5) | ((Tab[1] & 3) << 3));
b = (byte)(Tab[0] & 0x1f);
a = (byte)(a * 0xff);
r = (byte)((r << 3) | (r >> 2));
g = (byte)((g << 3) | (g >> 2));
b = (byte)((b << 3) | (b >> 2));
break;
case 0x0f:
a = (byte)(Tab[1] & 0xf0);
r = (byte)((Tab[1] & 0xf) << 4);
g = (byte)(Tab[0] & 0xf0);
b = (byte)((Tab[0] & 0xf) << 4);
break;
}
SaveByte[Offset + 0] = b;
SaveByte[Offset + 1] = g;
SaveByte[Offset + 2] = r;
SaveByte[Offset + 3] = a;
}
NPK_M::NPK_M()
{
}
void NPK_M::init()
{
WIN32_FIND_DATAA lpdata;
DWORD read;
HANDLE hFindFile = FindFirstFileA("ImagePacks2\\*.npk", &lpdata);
do {
//拼接完整路径
char cat[256] = "ImagePacks2\\";
strcat(cat, lpdata.cFileName);
ReadNpk Fs;
Fs.open(cat, std::ios::in | std::ios::binary);
if (Fs)
{
std::string Header = Fs.ReadString();
//如果是NPK
if (Header._Equal("NeoplePack_Bill"))
{
//读取img数量
int ImageCount = Fs.ReadInt();
//读取头
NpkInfo* ImgList = new NpkInfo[ImageCount];
for (size_t i = 0; i < ImageCount; i++)
{
ImgList[i].Offset = Fs.ReadInt();
ImgList[i].Length = Fs.ReadInt();
ImgList[i].Path = Fs.ReadInfo();
}
for (int i = 0; i < ImageCount; i++)
{
IMG img;
img.imgOffset = ImgList[i].Offset;
img.imgSize = ImgList[i].Length;
img.img_index = i;
img.lpBelongsFile = lpdata.cFileName;
img.lpImgName = ImgList[i].Path;
img.lp_lplist = NULL;
img.png_sum = 0;
map_npk.insert(make_pair(img.lpImgName, img));
}
//销毁
delete[]ImgList;
}
}
Fs.close();
} while (FindNextFileA(hFindFile, &lpdata));
FindClose(hFindFile);
ReadNpkTable("sprite/interface2/event/chn_event_2016/160927_joustmatches/knight0.img");
return;
}
LPDWORD NPK_M::LoadImgToMem(IMG* p)
{
//拼接NPK名称
char dirname[256] = "ImagePacks2\\";
strcat(dirname, p->lpBelongsFile.c_str());
ReadNpk Fs;
Fs.open(dirname, std::ios::in | std::ios::binary);
if (Fs)
{
Fs.seekg(p->imgOffset);
std::string Flag = Fs.ReadString();
if (Flag._Equal("Neople Img File"))
{
//索引表大小
long TableLength = Fs.ReadLong();
//img 版本 4字节
int ver = Fs.ReadInt();
//img 帧数
int IndexCount = Fs.ReadInt();
Npk_PngMutex.lock();
//图片数量赋值
p->png_sum = IndexCount;
Npk_PngMutex.unlock();
//new出 Png数量的 结构体
ImgInfo* PngList = new ImgInfo[IndexCount];
for (size_t i = 0; i < IndexCount; i++)
{
PngList[i].Type = Fs.ReadInt();
if (PngList[i].Type == 17)
{
//引用贴图
int frbuf = Fs.ReadInt();
continue;
}
//压缩类型
PngList[i].CmpType = Fs.ReadInt();
//宽度
PngList[i].Width = Fs.ReadInt();
//高度
PngList[i].Height = Fs.ReadInt();
//大小
PngList[i].Size = Fs.ReadInt();
//Xpos
PngList[i].Xpos = Fs.ReadInt();
//Ypos
PngList[i].Ypos = Fs.ReadInt();
//帧域X
PngList[i].FrameXpos = Fs.ReadInt();
//帧域Y
PngList[i].FrameYpos = Fs.ReadInt();
//计算偏移
if (i == 0)PngList[i].Offset = 0 + p->imgOffset + TableLength + 32;
else PngList[i].Offset = PngList[i - 1].Offset + PngList[i - 1].Size;
}
for (size_t i = 0; i < IndexCount; i++)
{
Fs.seekg(PngList[i].Offset);
BYTE* PngData = Fs.ReadCustomSize(PngList[i].Size);
int DeSize = PngList[i].Width * PngList[i].Height * 4;
BYTE* bByte = new BYTE[DeSize];
ULONG RealSize = DeSize;
int a = uncompress(bByte, &RealSize, PngData, (ULONG)PngList[i].Size);
delete[]PngData;
if (PngList[i].Type != 16)
{
int PngByteSize = DeSize * 2;
PngList[i].PNGdata = new BYTE[PngByteSize];
for (int e = 0; e < PngByteSize; e += 4)
{
BYTE NeedData[2];
memset(NeedData, 0, 2);
memcpy(NeedData, bByte + (e / 4) * 2, 2);
ReadColor(NeedData, PngList[i].Type, PngList[i].PNGdata, e);
}
delete[]bByte;
}
else {
PngList[i].PNGdata = bByte;
}
}
Npk_PngMutex.lock();
p->lp_lplist = PngList;
Npk_PngMutex.unlock();
}
}
Fs.close();
return 0;
}
IMG* NPK_M::ReadNpkTable(const std::string imgpath)
{
std::cout << imgpath << std::endl;
IMG* img = NULL;
Npk_ImgMutex.lock();
std::map<std::string, IMG>::iterator itr;
itr = map_npk.find(imgpath);
if (itr == map_npk.end()) {
std::string mes = "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!调用了不存在的Img : " + imgpath;
//MessageBoxA(0, mes.c_str(), 0, 0);
img = &map_npk["sprite/interface/base.img"];
}
else {
img = &itr->second;
}
Npk_ImgMutex.unlock();
//如果图片数组不存在 或者 图片数据不存在都要重读
if (!img->lp_lplist || !img->lp_lplist->PNGdata) {
LoadImgToMem(img);
}
return img;
}
void NPK_M::ReleaseNpkTable(IMG* p)
{
for (int i = 0; i < p->png_sum; i++) {
if (p->lp_lplist[i].PNGdata) {
delete p->lp_lplist[i].PNGdata;
p->lp_lplist[i].PNGdata = 0;
}
else {
int a = 0;
}
}
//delete[] p->lp_lplist;
//p->lp_lplist = NULL;
}
int Translate24Bto32B_cpp(char* des, char* src, int num)
{
for (int i = 0; i < (num / 4); i++) {
unsigned short aword = *(unsigned short*)src;
unsigned short A = aword >> 12;
unsigned short R = 15 & aword >> 8;
unsigned short G = 15 & aword >> 4;
unsigned short B = 15 & aword >> 0;
A = (A * 255) / 15;
B = (B * 255) / 15;
G = (G * 255) / 15;
R = (R * 255) / 15;
unsigned int aDword = 0;
aDword |= A;
aDword <<= 8;
aDword |= R;
aDword <<= 8;
aDword |= G;
aDword <<= 8;
aDword |= B;
*(unsigned int*)des = aDword;
src += 2;
des += 4;
}
return 0;
}
int Translate16Bto32B_cpp(char* des, char* src, int num)
{
for (int i = 0; i < (num / 4); i++) {
unsigned short aword = *(unsigned short*)src;
unsigned short A = aword >> 15;
unsigned short R = 31 & aword >> 10;
unsigned short G = 31 & aword >> 5;
unsigned short B = 31 & aword >> 0;
A = A * 255;
B = (B * 255) / 31;
G = (G * 255) / 31;
R = (R * 255) / 31;
unsigned int aDword = 0;
aDword |= A;
aDword <<= 8;
aDword |= R;
aDword <<= 8;
aDword |= G;
aDword <<= 8;
aDword |= B;
*(unsigned int*)des = aDword;
src += 2;
des += 4;
}
return 0;
}
NPK_M::~NPK_M()
{
map_npk.clear();
}

65
Npk.h Normal file
View File

@ -0,0 +1,65 @@
#pragma once
#include <map>
#include <string>
#include <windows.h>
#include <iostream>
#include <zlib.h>
#define NPK_R_FLAG(b){if(!b)continue;}
//PNG结构体
struct ImgInfo
{
//图片格式
int Type;
//压缩类型
int CmpType;
//宽度
int Width;
//高度
int Height;
//大小
int Size;
//Xpos
int Xpos;
//Ypos
int Ypos;
//帧域X
int FrameXpos;
//帧域Y
int FrameYpos;
//偏移
int Offset;
//Png位图数据
BYTE* PNGdata;
};
struct NpkInfo
{
int Offset;
int Length;
std::string Path;
};
struct IMG //npk的img的结构体
{
std::string lpImgName; //img文件的路径
int img_index; //img文件在npk文件里的序号
unsigned imgOffset;
unsigned imgSize;
std::string lpBelongsFile; //这个img属于哪个npk文件
int png_sum; //这个img文件有多少个 图片
ImgInfo* lp_lplist; //图片的数组..
};
class NPK_M {
private:
std::map <std::string, IMG> map_npk;
public:
NPK_M();
void init();
LPDWORD LoadImgToMem(IMG* p);
IMG* ReadNpkTable(const std::string imgname);
void ReleaseNpkTable(IMG* p);
~NPK_M();
};

207
SoundActorRegister.h Normal file
View File

@ -0,0 +1,207 @@
#pragma once
#include "SoundManager.h"
//音频对象智能指针Map
extern std::map<size_t, SoundPtr>SoundActorPtrMapObject;
//音频资源Map
extern std::map<std::string, Sound*>SoundRecObject;
//音频管理器
static SoundManagerPtr SoundEffectObject = new SoundManager();
//Sound 创建音频对象
static SQInteger Create_Sound(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
const SQChar* OutPutBuffer;
sq_getstring(v, 2, &OutPutBuffer);
size_t Id = SoundEffectObject->Save_Load((char*)OutPutBuffer);
sq_pushinteger(v, Id);
//if (SoundRecObject.count((char*)OutPutBuffer)) {
// sq_pushuserpointer(v, SoundRecObject[(char*)OutPutBuffer]);
//}
//else {
// Sound* Sound_Obj = new Sound();
// Sound_Obj->Load((char*)OutPutBuffer);
// sq_pushuserpointer(v, Sound_Obj);
//}
return 1;
}
//Sound 设置音频工作
static SQInteger Set_Sound_Task(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger SoundId;
sq_getinteger(v, 2, &SoundId);
SQInteger Type;
sq_getinteger(v, 3, &Type);
//播放
if (Type == 0) {
//获取播放次数 -1 为无限循环
SQInteger Count;
sq_getinteger(v, 4, &Count);
SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
Sound_Obj->Play(Count);
}
//暂停
else if (Type == 1) {
SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
Sound_Obj->Pause();
}
//继续
else if (Type == 2) {
SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
Sound_Obj->Resume();
}
//关闭
else if (Type == 3) {
SoundEffectObject->ReleaseSaveSoundByIndex(SoundId);
//SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
//Sound_Obj->Close();
}
return 0;
}
//Sound 获取音频音量
static SQInteger Get_Sound_Volume(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger SoundId;
sq_getinteger(v, 2, &SoundId);
SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
sq_pushfloat(v, Sound_Obj->GetVolume());
return 1;
}
//Sound 设置音频音量
static SQInteger Set_Sound_Volume(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger SoundId;
sq_getinteger(v, 2, &SoundId);
SoundPtr Sound_Obj = SoundEffectObject->GetSaveSound(SoundId);
SQFloat VolumeCalue;
sq_getfloat(v, 3, &VolumeCalue);
Sound_Obj->SetVolume(VolumeCalue);
return 0;
}
//Sound 临时播放音效
static SQInteger Squirrel_PlaySoundEffect(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
const SQChar* Name;
sq_getstring(v, 2, &Name);
//此操作会New出一个字符串需要手动销毁
char* Namebuf = SquirrelClassEx::SquirrelU2W((char*)Name);
//需要绘制的文字内容
std::string SoundName = Namebuf;
//销毁New出来的字符串
delete[]Namebuf;
if (SoundName.find(".ogg") != std::string::npos || SoundName.find(".mp3") != std::string::npos) {
size_t Id = SoundEffectObject->Load(SoundName);
SoundEffectObject->Play(Id, 0);
}
else {
if (GameAudioList.count(SoundName)) {
size_t Id = SoundEffectObject->Load(GameAudioList[SoundName]);
SoundEffectObject->Play(Id, 0);
}
}
/*
SoundPtr Sound_Obj = new Sound();
Sound_Obj->Load(SoundName);
if (Top == 3) {
SQFloat Volume;
sq_getfloat(v, 3, &Volume);
Sound_Obj->SetVolume(Volume);
}
Sound_Obj->Play();
SoundEffectMap[Sound_Obj->GetObjectID()] = Sound_Obj;
*/
return 0;
}
//Sound 释放临时音效
static SQInteger Squirrel_ReleseSoundEffect(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//新架构自动调用析构函数
//Map<size_t, SoundPtr> S_M = SoundEffectObject->GetAllSound();
//for (auto it = SoundEffectVector.begin(); it != SoundEffectVector.end(); ++it) {
// size_t id = *it;
// if (!SoundEffectObject->IsPlaying(id)) {
// //SoundPtr Sound_Obj = SoundEffectObject->GetSound(id);
// //Sound_Obj->Close();
// }
//}
//SoundEffectObject->ClearCache();
return 0;
}

210
SoundManager.cpp Normal file
View File

@ -0,0 +1,210 @@
#include "SoundManager.h"
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
namespace kiwano
{
namespace audio
{
SoundManager::SoundManager()
: volume_rate(1.f)
{
}
SoundManager::~SoundManager()
{
ClearCache();
}
size_t SoundManager::GetId(const String& file_path) const
{
return std::hash<String>()(file_path);
}
size_t SoundManager::GetId(const Resource& res) const
{
return static_cast<size_t>(res.GetId());
}
size_t SoundManager::Load(const String& file_path)
{
size_t id = GetId(file_path);
if (sound_cache_.end() != sound_cache_.find(id))
return id;
SoundPtr sound = MakePtr<Sound>(file_path);
if (sound)
{
sound->SetVolume(volume_rate * 1.0);
sound_cache_.insert(std::make_pair(id, sound));
return id;
}
return 0;
}
size_t SoundManager::Save_Load(const String& file_path)
{
size_t id = GetId(file_path);
if (sound_save_.end() != sound_save_.find(id))
return id;
SoundPtr sound = MakePtr<Sound>(file_path);
if (sound)
{
sound->SetVolume(volume_rate * 1.0);
sound_save_.insert(std::make_pair(id, sound));
return id;
}
return 0;
}
size_t SoundManager::Load(const Resource& res)
{
size_t id = GetId(res);
if (sound_cache_.end() != sound_cache_.find(id))
return id;
SoundPtr sound = MakePtr<Sound>(res);
if (sound)
{
sound->SetVolume(volume_rate * 1.0);
sound_cache_.insert(std::make_pair(id, sound));
return id;
}
return 0;
}
void SoundManager::Play(size_t id, int loop_count)
{
if (auto sound = GetSound(id))
sound->Play(loop_count);
}
void SoundManager::Pause(size_t id)
{
if (auto sound = GetSound(id))
sound->Pause();
}
void SoundManager::Resume(size_t id)
{
if (auto sound = GetSound(id))
sound->Resume();
}
void SoundManager::Stop(size_t id)
{
if (auto sound = GetSound(id))
sound->Stop();
}
bool SoundManager::IsPlaying(size_t id)
{
if (auto sound = GetSound(id))
return sound->IsPlaying();
return false;
}
float SoundManager::GetVolumeRate() const
{
return volume_rate;
}
void SoundManager::SetVolumeRate(float volume)
{
volume_rate = std::min(std::max(volume, -224.f), 224.f);
for (auto& pair : sound_cache_)
{
pair.second->SetVolume(volume_rate);
}
}
SoundPtr SoundManager::GetSound(size_t id) const
{
auto iter = sound_cache_.find(id);
if (iter != sound_cache_.end())
return iter->second;
return SoundPtr();
}
SoundPtr SoundManager::GetSaveSound(size_t id) const
{
auto iter = sound_save_.find(id);
if (iter != sound_save_.end())
return iter->second;
return SoundPtr();
}
void SoundManager::PauseAll()
{
for (auto& pair : sound_cache_)
{
pair.second->Pause();
}
}
void SoundManager::ResumeAll()
{
for (auto& pair : sound_cache_)
{
pair.second->Resume();
}
}
void SoundManager::StopAll()
{
for (auto& pair : sound_cache_)
{
pair.second->Stop();
}
}
void SoundManager::ClearCache()
{
sound_cache_.clear();
}
void SoundManager::ReleaseSoundByIndex(const size_t Id)
{
auto iter = sound_cache_.find(Id);
if (iter != sound_cache_.end()) {
iter->second->Close();
sound_cache_.erase(Id);
}
}
void SoundManager::ReleaseSaveSoundByIndex(const size_t Id)
{
auto iter = sound_save_.find(Id);
if (iter != sound_save_.end()) {
iter->second->Close();
sound_save_.erase(Id);
}
}
Map<size_t, SoundPtr> SoundManager::GetAllSound()
{
Map<size_t, SoundPtr> Buf;
Buf.insert(sound_cache_.begin(), sound_cache_.end());
return Buf;
}
} // namespace audio
} // namespace kiwano

162
SoundManager.h Normal file
View File

@ -0,0 +1,162 @@
// Copyright (c) 2016-2018 Kiwano - Nomango
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma once
#include <kiwano-audio/Sound.h>
#include <kiwano/base/ObjectBase.h>
namespace kiwano
{
namespace audio
{
KGE_DECLARE_SMART_PTR(SoundManager);
/**
* \addtogroup Audio
* @{
*/
/**
* \~chinese
* @brief
*/
class KGE_API SoundManager : public ObjectBase
{
public:
SoundManager();
~SoundManager();
/// \~chinese
/// @brief 加载本地音频文件
/// @param file_path 本地音频文件路径
/// @return 音频标识符
size_t Load(const String& file_path);
/// \~chinese
/// @brief 加载本地音频文件
/// @param file_path 本地音频文件路径
/// @return 音频标识符
size_t Save_Load(const String& file_path);
/// \~chinese
/// @brief 加载音频资源
/// @param res 音频资源
/// @return 音频标识符
size_t Load(const Resource& res);
/// \~chinese
/// @brief 播放音频
/// @param id 音频标识符
/// @param loop_count 播放循环次数,设置 -1 为循环播放
void Play(size_t id, int loop_count = 0);
/// \~chinese
/// @brief 暂停音频
/// @param id 音频标识符
void Pause(size_t id);
/// \~chinese
/// @brief 继续播放音频
/// @param id 音频标识符
void Resume(size_t id);
/// \~chinese
/// @brief 停止音频
/// @param id 音频标识符
void Stop(size_t id);
/// \~chinese
/// @brief 获取音频播放状态
/// @param id 音频标识符
bool IsPlaying(size_t id);
/// \~chinese
/// @brief 获取音量倍率
float GetVolumeRate() const;
/// \~chinese
/// @brief 设置音量
/// @param volume 音量大小1.0 为原始音量, 大于 1 为放大音量, 0 为最小音量
void SetVolumeRate(float volume);
/// \~chinese
/// @brief 获取本地音频文件id
/// @param file_path 本地音频文件路径
/// @return 音频标识符
size_t GetId(const String& file_path) const;
/// \~chinese
/// @brief 获取音频资源id
/// @param res 音频资源
/// @return 音频标识符
size_t GetId(const Resource& res) const;
/// \~chinese
/// @brief 获取音乐对象
/// @param id 音频标识符
SoundPtr GetSound(size_t id) const;
/// \~chinese
/// @brief 获取音乐对象
/// @param id 音频标识符
SoundPtr GetSaveSound(size_t id) const;
/// \~chinese
/// @brief 暂停所有音频
void PauseAll();
/// \~chinese
/// @brief 继续播放所有音频
void ResumeAll();
/// \~chinese
/// @brief 停止所有音频
void StopAll();
/// \~chinese
/// @brief 清除缓存
void ClearCache();
/// \~chinese
/// @brief 释放音乐对象
/// @param id 音频标识符
void ReleaseSoundByIndex(const size_t Id);
/// \~chinese
/// @brief 释放音乐对象
/// @param id 音频标识符
void ReleaseSaveSoundByIndex(const size_t Id);
/// \~chinese
/// @brief 获取所有音乐对象
Map<size_t, SoundPtr> GetAllSound();
private:
float volume_rate;
using SoundMap = Map<size_t, SoundPtr>;
SoundMap sound_cache_;
SoundMap sound_save_;
};
/** @} */
} // namespace audio
} // namespace kiwano

373
SpriteActorRegister.h Normal file
View File

@ -0,0 +1,373 @@
#pragma once
//演员对象智能指针Map
extern std::map<uint64_t, ActorPtr>ActorPtrMapObject;
extern NPK_M* npk;
//创建图像精灵
static SQInteger Create_Image(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
const SQChar* gOutPutBuffer;
sq_getstring(v, 2, &gOutPutBuffer);
SQInteger gFrame;
sq_getinteger(v, 3, &gFrame);
//转化img名称
std::string TextureName = (char*)gOutPutBuffer;
//构造纹理
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg(TextureName, gFrame);
//构造对象
SpritePtr Png = new Sprite(t);
//获取对象的唯一ID
uint64_t UUID = Png->GetObjectID();
//将精灵对象存入Map管理
ActorPtrMapObject[UUID] = Png;
sq_pushinteger(v, UUID);
return 1;
}
//创建高级图像精灵
static SQInteger Create_ImageEx(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//赋予了初始纹理
if (Top == 3) {
const SQChar* gOutPutBuffer;
sq_getstring(v, 2, &gOutPutBuffer);
SQInteger gFrame;
sq_getinteger(v, 3, &gFrame);
std::string TextureName = (char*)gOutPutBuffer;
SpriteExPtr Png = new SpriteEx();
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg(TextureName, gFrame);
Png->SetFrame(t);
//获取对象的唯一ID
uint64_t UUID = Png->GetObjectID();
//将高级精灵对象存入Map管理
ActorPtrMapObject[UUID] = Png;
sq_pushinteger(v, UUID);
}
//空纹理
else if (Top == 1) {
SpriteExPtr Png = new SpriteEx();
//获取对象的唯一ID
uint64_t UUID = Png->GetObjectID();
//将高级精灵对象存入Map管理
ActorPtrMapObject[UUID] = Png;
sq_pushinteger(v, UUID);
}
return 1;
}
//设置高级图像精灵混合模式
static SQInteger Set_ImageEx_Mode(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger gType;
sq_getinteger(v, 3, &gType);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetMode(gType);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级图像精灵帧
static SQInteger Set_ImageEx_Frame(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
const SQChar* gOutPutBuffer;
sq_getstring(v, 3, &gOutPutBuffer);
SQInteger gFrame;
sq_getinteger(v, 4, &gFrame);
std::string TextureName = (char*)gOutPutBuffer;
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
TexturePtr t = SquirrelClassEx::GetTexturePtrByImg(TextureName, gFrame);
Png->SetFrame(t);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级精灵图像透明度
static SQInteger Set_ImageEx_Alpha(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQFloat Alpha;
sq_getfloat(v, 3, &Alpha);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetOpacity(Alpha);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级精灵图像帧信息
static SQInteger Set_ImageEx_FrameInfo(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
std::vector<int> FrameDelay;
sq_pushnull(v); // null iterator
while (SQ_SUCCEEDED(sq_next(v, 3)))
{
SQInteger gDelay;
sq_getinteger(v, -1, &gDelay);
FrameDelay.push_back(gDelay);
//这里-1是值-2是键
sq_pop(v, 2); //在下一次迭代之前弹出键和值
}
sq_pop(v, 1);
SQInteger Loop;
sq_getinteger(v, 4, &Loop);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetFrameInfo(FrameDelay, Loop);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级精灵图像播放动画
static SQInteger Set_ImageEx_PlayAnimotion(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQBool Type;
sq_getbool(v, 3, &Type);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetAnimotionPlay(Type);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级精灵Ani帧
static SQInteger Set_ImageEx_Animotion_Frame(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger Frame;
sq_getinteger(v, 3, &Frame);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetAnimotionFrame(Frame);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置高级精灵阴影
static SQInteger Set_ImageEx_Shadow(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
//SQInteger Frame;
//sq_getinteger(v, 3, &Frame);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpriteExPtr Png = dynamic_cast<SpriteEx*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetShadow();
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置裁切精灵
static SQInteger Set_Image_CropRect(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQFloat L;
sq_getfloat(v, 3, &L);
SQFloat U;
sq_getfloat(v, 4, &U);
SQFloat R;
sq_getfloat(v, 5, &R);
SQFloat D;
sq_getfloat(v, 6, &D);
//从全局Map中获取高级精灵角色
if (ActorPtrMapObject.count(ActorUUID)) {
SpritePtr Png = dynamic_cast<Sprite*>(ActorPtrMapObject[ActorUUID].Get());
Png->SetCropRect(Rect(Point(L,U), Point(R, D)));
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}

187
SpriteEx.cpp Normal file
View File

@ -0,0 +1,187 @@
#include "SpriteEx.h"
#include "SquirrelClassEx.h"
//#include "kiwano/render/DirectX/D3DDeviceResources.h"
//#include "kiwano/render/DirectX/NativePtr.h"
//#include "d2d1effects_2.h"
std::unordered_map<int, TexturePtr>ImageRecShadowObject;
#pragma comment(lib, "d2d1.lib")
#pragma comment(lib, "dxguid.lib")
extern NPK_M* npk;
SpriteEx::SpriteEx(const std::string imgpath, const int frame)
{
SetFrame(SquirrelClassEx::GetTexturePtrByImg(imgpath, frame));
}
void SpriteEx::SetPosition(const Point& point)
{
TexturePtr t = GetTexture();
ImgInfo Img = *(ImgInfo*)t->GetUserData();
Actor::SetPosition(Point((point.x + Img.Xpos), (point.y + Img.Ypos) * GetScale().y));
}
void SpriteEx::SetScale(const Point& point)
{
//if (ShadowObject) {
// ShadowObject->GetTransform().skew = Vec2((-20.0) * (GetParent()->GetScale().x), 0.0);
//}
Sprite::SetScale(point);
}
void SpriteEx::OnRender(RenderContext& ctx)
{
//if (INTERPOLATION_MODE != D2D1_INTERPOLATION_MODE_FORCE_DWORD && COMPOSITE_MODE != D2D1_COMPOSITE_MODE_FORCE_DWORD)
//{
// auto bitmap = NativePtr::Get<ID2D1Bitmap>(GetFrame().GetTexture());
// auto d2d_res = graphics::directx::GetD2DDeviceResources();
// d2d_res->GetDeviceContext()->DrawImage(
// bitmap.Get(),
// INTERPOLATION_MODE,
// COMPOSITE_MODE
// );
// //auto bitmap = NativePtr::Get<ID2D1Bitmap>(GetFrame().GetTexture());
// //auto m_d2dContext = graphics::directx::GetD2DDeviceResources()->GetDeviceContext();
// //ComPtr<ID2D1Effect> chromakeyEffect;
// //m_d2dContext->CreateEffect(CLSID_D2D1Emboss, &chromakeyEffect);
// //
// //chromakeyEffect->SetInput(0, bitmap.Get());
// ////chromakeyEffect->SetValue(D2D1_CHROMAKEY_PROP_COLOR, Color{ 1.0f, 1.0f, 1.0f, 1.0f });
// ////chromakeyEffect->SetValue(D2D1_CHROMAKEY_PROP_TOLERANCE, 0.2f);
// ////chromakeyEffect->SetValue(D2D1_CHROMAKEY_PROP_INVERT_ALPHA, true);
// //chromakeyEffect->SetValue(D2D1_EMBOSS_PROP_HEIGHT, 1.0f);
// //chromakeyEffect->SetValue(D2D1_EMBOSS_PROP_DIRECTION, 0.0f);
// //m_d2dContext->DrawImage(chromakeyEffect.Get());
//}
//else {
// this->Sprite::OnRender(ctx);
//}
switch (MyModel)
{
case -1: //-1原始模式
ctx.SetBlendMode(BlendMode::SourceOver);
break;
case 0: //0线性减淡
ctx.SetBlendMode(BlendMode::Add);
break;
default:
ctx.SetBlendMode(BlendMode::SourceOver);
break;
}
this->Sprite::OnRender(ctx);
}
//void SpriteEx::OnUpdate(Duration dt) {
// //当处于播放状态
// if (is_Animotion_Play) {
// //当前帧小于总帧时执行逻辑
// if (NowFrameIndex < MaxFrameCount) {
// if (OffsetTime == 0)OffsetTime = clock();
// if ((clock() - OffsetTime) >= MyDelay[NowFrameIndex]) {
// OffsetTime = clock();
// NowFrameIndex++;
// SquirrelClassEx::RunUpdateScript("AnimotionUpdateCallBack", this->GetObjectID(), NowFrameIndex);
// }
// }
// //否则重置时间 重置当前帧
// else {
// OffsetTime = 0;
// NowFrameIndex = 0;
// MyLoop--;
// if (MyLoop != 0) {
// SquirrelClassEx::RunUpdateScript("AnimotionUpdateCallBack", this->GetObjectID(), NowFrameIndex);
// }
// else {
// is_Animotion_Play = false;
// }
// }
// }
//}
void SpriteEx::SetFrameInfo(std::vector<int> FrameDaley , const int Loop)
{
MyDelay = FrameDaley;
MaxFrameCount = FrameDaley.size();
MyLoop = Loop;
}
void SpriteEx::SetAnimotionPlay(bool Type)
{
is_Animotion_Play = Type;
//开始播放以后 第一次先传入第0帧
SquirrelClassEx::RunUpdateScript("AnimotionUpdateCallBack", this->GetObjectID(), NowFrameIndex);
}
void SpriteEx::SetAnimotionFrame(const int gFrame)
{
this->NowFrameIndex = gFrame;
}
void SpriteEx::SetShadow()
{
TexturePtr t;
ImgInfo Img = *(ImgInfo*)GetTexture()->GetUserData();
if (ImageRecShadowObject.count(GetTexture()->GetObjectID())) {
t = ImageRecShadowObject[GetTexture()->GetObjectID()];
}
else {
BYTE* Data = Img.PNGdata;
BYTE* NewData = new BYTE[Img.Height * Img.Width * 4];
for (size_t i = 0; i < Img.Height * Img.Width * 4; i++)
{
if ((i + 1) % 4 == 0)
NewData[i] = Data[i];
else
NewData[i] = 0;
}
BinaryData data = { ((void*)NewData) ,(uint32_t)(Img.Height * Img.Width * 4) };
t = new Texture();
t->Load(PixelSize(Img.Width, Img.Height), data, PixelFormat::Bpp32BGRA);
t->SetUserData(&Img);
ImageRecShadowObject[GetTexture()->GetObjectID()] = t;
}
if (ShadowObject) {
ShadowObject->SetFrame(t);
}
else {
ShadowObject = new SpriteEx(t);
ShadowObject->SetAnchor(1, 1);
ShadowObject->SetOpacity(0.4);
ShadowObject->SetZOrder(-1);
AddChild(ShadowObject);
//GetParent()->GetParent()->AddChild(ShadowObject);
}
Transform B;
B.scale = Vec2(1.0, 0.29);
B.position = Point(GetWidth(), GetHeight() - 5);
B.skew = Vec2((-20.0) * (GetParent()->GetScale().x), 0.0);
ShadowObject->SetTransform(B);
}

72
SpriteEx.h Normal file
View File

@ -0,0 +1,72 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
//#include "kiwano/render/DirectX/NativePtr.h"
KGE_DECLARE_SMART_PTR(SpriteEx);
class SpriteEx : public Sprite
{
private:
//D2D1_INTERPOLATION_MODE INTERPOLATION_MODE = D2D1_INTERPOLATION_MODE_FORCE_DWORD;
//D2D1_COMPOSITE_MODE COMPOSITE_MODE = D2D1_COMPOSITE_MODE_FORCE_DWORD;
int MyModel = -1;
std::string TexturePtrName;
//阴影对象
SpriteExPtr ShadowObject = nullptr;
//播放动画的时间
int OffsetTime = 0;
//延迟集合
std::vector<int> MyDelay;
//是否是播放动画
bool is_Animotion_Play = false;
//当前帧数
int NowFrameIndex = 0;
//总帧数
int MaxFrameCount = 0;
//是否循环播放
int MyLoop = -1;
public:
SpriteEx()
{
}
SpriteEx(TexturePtr texture)
{
SetFrame(SpriteFrame(texture));
}
SpriteEx(const std::string Path)
{
Load(Path);
}
SpriteEx(const std::string imgpath, const int frame);
//带有NPK坐标变化的设置坐标
void SetPosition(const Point& point)override;
//要改变阴影朝向
void SetScale(const Point& point)override;
void OnRender(RenderContext& ctx) override;
void SetMode(int Type) {
MyModel = Type;
}
//void OnUpdate(Duration dt) override;
void SetFrameInfo(std::vector<int> FrameDaley,const int Loop);
void SetAnimotionPlay(bool Type);
void SetAnimotionFrame(const int gFrame);
void SetShadow();
};

14
SquirrelActor.cpp Normal file
View File

@ -0,0 +1,14 @@
#include "SquirrelActor.h"
extern SquirrelClassEx* TObject;
SquirrelActor::SquirrelActor(std::string gActorName)
{
ActorName = gActorName;
}
void SquirrelActor::OnUpdate(Duration dt)
{
}

16
SquirrelActor.h Normal file
View File

@ -0,0 +1,16 @@
#pragma once
#include <string>
#include "SquirrelClassEx.h"
#include <kiwano/kiwano.h>
using namespace kiwano;
class SquirrelActor :public Actor
{
private:
std::string ActorName;
bool OnStartFrame = false;
public:
SquirrelActor(std::string gActorName);
void OnUpdate(Duration dt) override;
};

120
SquirrelButton.cpp Normal file
View File

@ -0,0 +1,120 @@
#include "SquirrelButton.h"
#include "SquirrelClassEx.h"
void SquirrelButton::OnClick(Event* evt) {
//必须是按下态才有点击判断 实际是判断悬停态
if (this->MyState != 3)return;
auto mouse_evt = dynamic_cast<MouseClickEvent*>(evt);
if (mouse_evt->button == MouseButton::Left)
{
SquirrelClassEx::RunUpdateScript("ButtonUpdateCallBack", this->GetObjectID(), 10);
}
else if (mouse_evt->button == MouseButton::Right)
{
SquirrelClassEx::RunUpdateScript("ButtonUpdateCallBack", this->GetObjectID(), 11);
}
else if (mouse_evt->button == MouseButton::Middle)
{
SquirrelClassEx::RunUpdateScript("ButtonUpdateCallBack", this->GetObjectID(), 12);
}
}
void SquirrelButton::OnHover() {
//必须处于普通态时才会调用悬停态方法
if (this->MyState == 0) {
SetState(2);
//this->_is_Hover = true;
}
}
void SquirrelButton::OnOut() {
if (this->MyState == 1)return;
//如果移出鼠标的时候处于按下态 那么也需要在调用一次OnUp
if (this->MyState == 3) {
SetState(2);
this->SetPositionY(this->GetPositionY() - 1);
}
SetState(0);
//this->_is_Hover = false;
}
void SquirrelButton::OnDown(Event* evt) {
if (this->MyState == 1)return;
if (this->MyState == 2) {
SetState(3);
this->SetPositionY(this->GetPositionY() + 1);
}
}
void SquirrelButton::OnUp(Event* evt) {
if (this->MyState == 1)return;
if (this->MyState == 3) {
SetState(2);
this->SetPositionY(this->GetPositionY() - 1);
}
}
bool SquirrelButton::IsPress(const int Type)
{
switch (Type)
{
case 0: {
if (this->_is_Left_Press) {
this->_is_Left_Press = false;
return true;
}
else {
return false;
}
}
break;
case 1: {
if (this->_is_Right_Press) {
this->_is_Right_Press = false;
return true;
}
else {
return false;
}
}
break;
case 2: {
if (this->_is_Middle_Press) {
this->_is_Middle_Press = false;
return true;
}
else {
return false;
}
}
break;
}
}
bool SquirrelButton::IsHover()
{
return this->_is_Hover;
}
void SquirrelButton::SetState(const int state)
{
this->MyState = state;
SquirrelClassEx::RunUpdateScript("ButtonUpdateCallBack", this->GetObjectID(), state);
}
void SquirrelButton::Init()
{
//必须先调用父类的Init 初始化方法才可以成功注册UI类
this->UiFrameWork::Init();
//监听器在父类的Init方法中已经装载 所以这里只需要新增监听信号的处理逻辑
AddListener<MouseClickEvent>(Closure(this, &SquirrelButton::OnClick));
AddListener<MouseDownEvent>(Closure(this, &SquirrelButton::OnDown));
AddListener<MouseUpEvent>(Closure(this, &SquirrelButton::OnUp));
}
void SquirrelButton::OnUpdate(Duration dt) {
//SquirrelClassEx::RunUpdateScript("ButtonUpdateCallBack", this->GetObjectID(), this->MyState);
}

49
SquirrelButton.h Normal file
View File

@ -0,0 +1,49 @@
#pragma once
#include "UiFrameWork.h"
KGE_DECLARE_SMART_PTR(SquirrelButton);
class SquirrelButton : public UiFrameWork
{
private:
//正常态纹理
std::string NORMAL = "ImagePacks2/Error/base.png";
//禁用态纹理
std::string DISABLE = "ImagePacks2/Error/base.png";
//悬停态纹理
std::string HOVER = "ImagePacks2/Error/base.png";
//按下态纹理
std::string PRESS = "ImagePacks2/Error/base.png";
//自身状态
int MyState = 0;
//是否左键点击
bool _is_Left_Press = false;
//是否右键点击
bool _is_Right_Press = false;
//是否中键点击
bool _is_Middle_Press = false;
//是否悬停
bool _is_Hover = false;
public:
SquirrelButton() {
Init();
}
void Init() override;
void OnClick(Event* evt);
void OnHover()override;
void OnOut()override;
void OnDown(Event* evt);
void OnUp(Event* evt);
bool IsPress(const int Type);
bool IsHover();
void SetState(const int state);
void OnUpdate(Duration dt) override;
};

7
SquirrelCamera.cpp Normal file
View File

@ -0,0 +1,7 @@
#include "SquirrelCamera.h"
#include "SquirrelClassEx.h"
void SquirrelCamera::OnUpdate(Duration dt)
{
SquirrelClassEx::RunUpdateScript("CameraUpdateCallBack", this->GetObjectID(),dt.GetMilliseconds());
}

14
SquirrelCamera.h Normal file
View File

@ -0,0 +1,14 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
KGE_DECLARE_SMART_PTR(SquirrelCamera);
class SquirrelCamera :
public Actor
{
public:
void OnUpdate(Duration dt) override;
};

2116
SquirrelClassEx.cpp Normal file

File diff suppressed because it is too large Load Diff

120
SquirrelClassEx.h Normal file
View File

@ -0,0 +1,120 @@
#pragma once
#include "include/squirrel.h"
#include "include/sqstdaux.h"
#include "include/sqstdblob.h"
#include "include/sqstdio.h"
#include "include/sqstdmath.h"
#include "include/sqstdstring.h"
#include "include/sqstdsystem.h"
#include <kiwano/kiwano.h>
using namespace kiwano;
#include <kiwano-audio/kiwano-audio.h>
using namespace kiwano::audio;
#include <kiwano-imgui/kiwano-imgui.h>
using namespace kiwano::imgui;
#include "WThreadPool.h"
#include "SquirrelStage.h"
#include "SquirrelTownStage.h"
#include "Cursor.h"
#include "SquirrelButton.h"
#include "SpriteEx.h"
#include "SquirrelCamera.h"
#include "Npk.h"
#include "json.hpp"
#include <iostream>
#include <map>
#include <unordered_map>
#include <string>
#include <vector>
#include <sstream>
#include <thread>
#include <tchar.h>
#include <fstream>
#include <sstream>
#ifdef SQUNICODE
#define scfprintf fwprintf
#define scfopen _wfopen
#define scvprintf vwprintf
#define _SST(a) (SQChar*)##a
#else
#define scfprintf fprintf
#define scfopen fopen
#define scvprintf vprintf
#endif
class SquirrelClassEx
{
public://输出拓展
static int Sout(HSQUIRRELVM v);//输出
static int Error(HSQUIRRELVM v);//输出
public://API类
//重载Nut脚本
static SQInteger ReloadingScript();
//退出游戏
static SQInteger Exit(HSQUIRRELVM v);
//执行Cmd
static SQInteger Cmd(HSQUIRRELVM v);
//调用脚本
static void RunSceneScript(std::string FuncName, SquirrelStagePtr scene);
static void RunSceneScript(std::string FuncName, SquirrelStagePtr scene,SQInteger dt);
static void RunSceneScript(std::string FuncName, SquirrelStagePtr scene, SQFloat dt);
static void RunSceneScript(std::string FuncName, SquirrelTownStagePtr scene);
static void RunUpdateScript(std::string FuncName, SQInteger ObjectIdx);
static void RunUpdateScript(std::string FuncName, std::string string);
static void RunUpdateScript(std::string FuncName, SQInteger ObjectIdx, SQInteger Buf);
static void RunUpdateScript(std::string FuncName, SQInteger ObjectIdx, SQInteger Buf , SQInteger Buf2);
static void RunUpdateScriptPlayer(std::string FuncName, SQInteger ObjectIdx, SQFloat Buf);
//Push图层对象至Map
static void PushLayerActorPtrToMap(LayerActorPtr Ptr);
//读取List
static void LoadingListScript();
public: //纹理类
static TexturePtr GetTexturePtrByImg(const std::string ImgPath , const int Frame);
static void ReleaseTextureByImg(const std::string ImgPath);
public://类扩展
//字符串类
static void Split(const std::string& src, std::vector<std::string>& dest, const std::string& separator);
static char* U8ToUnicode(const char* szU8);
static char* SquirrelU2W(const char* Str);
//文件类
//static int WriteFile(HSQUIRRELVM v);//文件写出
public://注册闭包函数
//新增nut接口funcName绑定C语言函数funcAddr
static void RegisterNutApi(const SQChar* funcName, void* funcAddr, HSQUIRRELVM v);
//注册接口
void R_Register_Nut(HSQUIRRELVM v);
public:
SquirrelClassEx();
//初始化
void Init();
//运行
void Run();
//关闭
void Close();
};
static SquirrelClassEx* Object;
static HSQUIRRELVM v;

127
SquirrelStage.cpp Normal file
View File

@ -0,0 +1,127 @@
#include "SquirrelStage.h"
#include "SquirrelClassEx.h"
extern SquirrelClassEx* TObject;
extern Cursor* Mouse_Object;
extern std::map<std::uint64_t, int>UI_HOVER_ZORDER;
extern std::map<std::uint64_t, UiFrameWork*>UI_HOVER_OBJECT;
void SquirrelStage::OnEvent(Event* evt) {
if (evt->IsType<KeyEvent>())
{
if (evt->IsType<KeyDownEvent>())
{
KeyCode key = dynamic_cast<KeyDownEvent*>(evt)->code;
SquirrelClassEx::RunUpdateScript("KeyDownEventCallBack", (int)key);
}
else if (evt->IsType<KeyUpEvent>())
{
KeyCode key = dynamic_cast<KeyUpEvent*>(evt)->code;
SquirrelClassEx::RunUpdateScript("KeyUpEventCallBack", (int)key);
}
else if (evt->IsType<KeyCharEvent>())
{
char ch = dynamic_cast<KeyCharEvent*>(evt)->value;
SquirrelClassEx::RunUpdateScript("KeyCharEventCallBack", (int)ch);
}
else if (evt->IsType<IMEInputEvent>())
{
const auto& str = dynamic_cast<IMEInputEvent*>(evt)->value;
const auto utf8_str = strings::WideToUTF8(strings::NarrowToWide(str));
SquirrelClassEx::RunUpdateScript("KeyIMEInputEventCallBack", utf8_str.c_str());
}
}
}
void SquirrelStage::InitKeyInPut()
{
AddListener<KeyDownEvent>(Closure(this, &SquirrelStage::OnEvent));
AddListener<KeyUpEvent>(Closure(this, &SquirrelStage::OnEvent));
AddListener<KeyCharEvent>(Closure(this, &SquirrelStage::OnEvent));
AddListener<IMEInputEvent>(Closure(this, &SquirrelStage::OnEvent));
}
void SquirrelStage::PushBaseUi()
{
//创建鼠标UI图层
LayerActorPtr MouseUiLayer = new LayerActor();
MouseUiLayer->SetName("Scene_Mouse_UI_Layer");
//设置鼠标图层层级最高
MouseUiLayer->SetZOrder(100000);
SquirrelClassEx::PushLayerActorPtrToMap(MouseUiLayer);
this->AddChild(MouseUiLayer);
//创建默认图层
LayerActorPtr DefaultLayer = new LayerActor();
DefaultLayer->SetName(this->GetName() + "_Default_Layer");
SquirrelClassEx::PushLayerActorPtrToMap(DefaultLayer);
this->AddChild(DefaultLayer);
}
void SquirrelStage::OnEnter()
{
//将鼠标对象从父场景移除
Mouse_Object->RemoveFromParent();
ActorPtr MouseUiLayer = this->GetChild("Scene_Mouse_UI_Layer");
//将鼠标对象设置为当前场景子对象
MouseUiLayer->AddChild(Mouse_Object);
//场景进入
if(this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Enter", this);
//全局进入
TObject->RunSceneScript("Game_Enter", this);
}
void SquirrelStage::OnExit()
{
//清空UI类Map
UI_HOVER_ZORDER.clear();
UI_HOVER_OBJECT.clear();
//将鼠标对象从父场景移除
Mouse_Object->RemoveFromParent();
//场景退出
if (this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Exit", this);
//全局退出
TObject->RunSceneScript("Game_Exit", this);
}
void SquirrelStage::OnUpdate(Duration dt)
{
static float TimeFlag = 0.0;
TimeFlag += dt.GetSeconds();
TObject->RunSceneScript("Game_Proc", this, dt.GetSeconds());
if (TimeFlag >= 0.00694) {
//场景Proc
if (this->GetName().find("GameMap") == std::string::npos)TObject->RunSceneScript(this->GetName() + "_Proc", this, TimeFlag);
if (Director::GetInstance().GetCurrentStage()->GetHashName() == this->GetHashName() && this->GetName().find("LoadingGame") == std::string::npos) {
//全局Proc
TObject->RunSceneScript("Game_Proc_144", this, TimeFlag);
//判断是否需要重载
if (FILE* file = fopen("Yosin_Game_Reloading.Sign", "r")) {
SquirrelClassEx::ReloadingScript();
//OnExit();
//OnEnter();
fclose(file);
remove("Yosin_Game_Reloading.Sign");
}
}
TimeFlag = 0.0;
}
}

41
SquirrelStage.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
KGE_DECLARE_SMART_PTR(SquirrelStage);
class SquirrelStage :
public Stage
{
private:
float Base_X = 0;
float Base_Y = 0;
public:
//构造函数必须有名字
SquirrelStage(std::string gName) {
this->SetName(gName);
InitKeyInPut();
PushBaseUi();
}
//创建按键事件回调
void InitKeyInPut();
//创建基础图层
void PushBaseUi();
//进入场景
void OnEnter() override;
//退出场景
void OnExit()override;
//渲染场景 Proc
void OnUpdate(Duration dt)override;
void OnEvent(Event* evt);
};

69
SquirrelTownStage.cpp Normal file
View File

@ -0,0 +1,69 @@
#include "SquirrelTownStage.h"
#include "SquirrelClassEx.h"
extern SquirrelClassEx* TObject;
extern Cursor* Mouse_Object;
extern std::map<std::uint64_t, int>UI_HOVER_ZORDER;
extern std::map<std::uint64_t, UiFrameWork*>UI_HOVER_OBJECT;
void SquirrelTownStage::PushBaseUi()
{
//创建鼠标UI图层
LayerActorPtr MouseUiLayer = new LayerActor();
MouseUiLayer->SetName("Scene_Mouse_UI_Layer");
//设置鼠标图层层级最高
MouseUiLayer->SetZOrder(100000);
SquirrelClassEx::PushLayerActorPtrToMap(MouseUiLayer);
this->AddChild(MouseUiLayer);
//创建默认图层
LayerActorPtr DefaultLayer = new LayerActor();
DefaultLayer->SetName(this->GetName() + "_Default_Layer");
SquirrelClassEx::PushLayerActorPtrToMap(DefaultLayer);
this->AddChild(DefaultLayer);
}
void SquirrelTownStage::OnEnter()
{
//将鼠标对象从父场景移除
Mouse_Object->RemoveFromParent();
ActorPtr MouseUiLayer = this->GetChild("Scene_Mouse_UI_Layer");
//将鼠标对象设置为当前场景子对象
MouseUiLayer->AddChild(Mouse_Object);
//场景进入
//TObject->RunSceneScript(this->GetName() + "_Enter", this);
//全局进入
TObject->RunSceneScript("Game_Enter", this);
}
void SquirrelTownStage::OnExit()
{
//清空UI类Map
UI_HOVER_ZORDER.clear();
UI_HOVER_OBJECT.clear();
//将鼠标对象从父场景移除
Mouse_Object->RemoveFromParent();
//全局退出
TObject->RunSceneScript("Game_Exit", this);
}
void SquirrelTownStage::OnUpdate(Duration dt)
{
if (Director::GetInstance().GetCurrentStage()->GetHashName() == this->GetHashName() && this->GetName().find("LoadingGame") == std::string::npos) {
//全局Proc
TObject->RunSceneScript("Game_Proc", this);
//判断是否需要重载
if (FILE* file = fopen("Yosin_Game_Reloading.Sign", "r")) {
SquirrelClassEx::ReloadingScript();
//OnExit();
//OnEnter();
fclose(file);
remove("Yosin_Game_Reloading.Sign");
}
}
}

31
SquirrelTownStage.h Normal file
View File

@ -0,0 +1,31 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
#include "SquirrelStage.h"
KGE_DECLARE_SMART_PTR(SquirrelTownStage);
class SquirrelTownStage :
public Stage
{
private:
float Base_X = 0;
float Base_Y = 0;
public:
//构造函数必须有名字
SquirrelTownStage(std::string gName) {
this->SetName(gName);
PushBaseUi();
}
//创建基础图层
void PushBaseUi();
//进入场景
void OnEnter() override;
//退出场景
void OnExit()override;
//渲染场景 Proc
void OnUpdate(Duration dt)override;
};

358
StageActorRegister.h Normal file
View File

@ -0,0 +1,358 @@
#pragma once
//演员对象智能指针Map
extern std::map<uint64_t, ActorPtr>ActorPtrMapObject;
//淡入淡出动画智能指针Map
std::map<uint32_t, FadeTransitionPtr>FadeTransitionPtrMapObject;
//场景管理Map
std::map<std::string, uint64_t>SquirrelStagePtrMapObject;
//重载场景
static SQInteger Reset_Scene(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入场景
SQInteger gscene;
sq_getinteger(v, 2, &gscene);
//获取传入场景
if (ActorPtrMapObject.count(gscene)) {
SquirrelStagePtr scene = dynamic_cast<SquirrelStage*>(ActorPtrMapObject[gscene].Get());
//移除场景所有子对象
scene->RemoveAllChildren();
//重新构造
scene->PushBaseUi();
//重新调用进入场景函数
scene->OnEnter();
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
//ActorPtr c = scene->GetChild("Scene_Default_Layer");
//c->RemoveAllChildren();
//ActorList ChildList = scene->GetAllChildren();
//for (auto& child : ChildList)
//{
// if (!child->IsName("Scene_Mouse_UI_Layer")) {
// child->RemoveAllChildren();
// }
//}
return 1;
}
//创建场景
static SQInteger Create_Scene(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入名字
const SQChar* StageName;
sq_getstring(v, 2, &StageName);
//此操作会New出一个字符串需要手动销毁
char* gStageName = SquirrelClassEx::SquirrelU2W((char*)StageName);
std::string RealStageName = gStageName;
//销毁New出来的字符串
delete[]gStageName;
//创建场景
SquirrelStagePtr scene = new SquirrelStage(RealStageName);
//获取对象的UUID
uint32_t UUID = scene->GetObjectID();
//将场景对象存入Map管理
ActorPtrMapObject[UUID] = scene;
SquirrelStagePtrMapObject[RealStageName] = UUID;
sq_pushinteger(v, UUID);
return 1;
}
//根据名字获取场景 如果不存在会自动创建
static SQInteger Get_SceneByName(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入名字
const SQChar* StageName;
sq_getstring(v, 2, &StageName);
//此操作会New出一个字符串需要手动销毁
char* gStageName = SquirrelClassEx::SquirrelU2W((char*)StageName);
std::string RealStageName = gStageName;
//销毁New出来的字符串
delete[]gStageName;
if (SquirrelStagePtrMapObject.count(RealStageName) && ActorPtrMapObject.count(SquirrelStagePtrMapObject[RealStageName])) {
sq_pushinteger(v, SquirrelStagePtrMapObject[RealStageName]);
}
else {
//创建场景
SquirrelStagePtr scene = new SquirrelStage(RealStageName);
//获取对象的UUID
uint32_t UUID = scene->GetObjectID();
//将场景对象存入Map管理
ActorPtrMapObject[UUID] = scene;
SquirrelStagePtrMapObject[RealStageName] = UUID;
sq_pushinteger(v, UUID);
}
return 1;
}
//根据名字获取城镇场景 如果不存在会自动创建
static SQInteger Get_TownSceneByName(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入名字
const SQChar* StageName;
sq_getstring(v, 2, &StageName);
//此操作会New出一个字符串需要手动销毁
char* gStageName = SquirrelClassEx::SquirrelU2W((char*)StageName);
std::string RealStageName = gStageName;
//销毁New出来的字符串
delete[]gStageName;
if (SquirrelStagePtrMapObject.count(RealStageName) && ActorPtrMapObject.count(SquirrelStagePtrMapObject[RealStageName])) {
sq_pushinteger(v, SquirrelStagePtrMapObject[RealStageName]);
}
else {
//创建场景
SquirrelTownStagePtr scene = new SquirrelTownStage(RealStageName);
//获取对象的UUID
uint32_t UUID = scene->GetObjectID();
//将场景对象存入Map管理
ActorPtrMapObject[UUID] = scene;
SquirrelStagePtrMapObject[RealStageName] = UUID;
sq_pushinteger(v, UUID);
}
return 1;
}
//导演切换场景
static SQInteger Director_EnterStage(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入场景
SQInteger gscene;
sq_getinteger(v, 2, &gscene);
//获取传入场景
if (ActorPtrMapObject.count(gscene)) {
SquirrelStagePtr scene = dynamic_cast<SquirrelStage*>(ActorPtrMapObject[gscene].Get());
if (Top == 2) {
Director::GetInstance().EnterStage(scene);
}
else if (Top == 3) {
SQInteger gTsn;
sq_getinteger(v, 3, &gTsn);
if (FadeTransitionPtrMapObject.count(gTsn)) {
FadeTransitionPtr Tsn = FadeTransitionPtrMapObject[gTsn];
Director::GetInstance().EnterStage(scene, Tsn);
}
else {
Director::GetInstance().EnterStage(scene);
}
}
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//导演切换场景
static SQInteger Director_PushStage(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入场景
SQInteger gscene;
sq_getinteger(v, 2, &gscene);
//获取传入场景
if (ActorPtrMapObject.count(gscene)) {
SquirrelStagePtr scene = dynamic_cast<SquirrelStage*>(ActorPtrMapObject[gscene].Get());
if (Top == 2) {
Director::GetInstance().PushStage(scene);
}
else if (Top == 3) {
SQInteger gTsn;
sq_getinteger(v, 3, &gTsn);
if (FadeTransitionPtrMapObject.count(gTsn)) {
FadeTransitionPtr Tsn = FadeTransitionPtrMapObject[gTsn];
Director::GetInstance().PushStage(scene, Tsn);
}
else {
Director::GetInstance().PushStage(scene);
}
}
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//导演切换场景
static SQInteger Director_PopStage(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//获取传入场景
SQInteger gscene;
sq_getinteger(v, 2, &gscene);
//获取传入场景
if (ActorPtrMapObject.count(gscene)) {
SquirrelStagePtr scene = dynamic_cast<SquirrelStage*>(ActorPtrMapObject[gscene].Get());
if (Top == 2) {
Director::GetInstance().PopStage();
}
else if (Top == 3) {
SQInteger gTsn;
sq_getinteger(v, 3, &gTsn);
if (FadeTransitionPtrMapObject.count(gTsn)) {
FadeTransitionPtr Tsn = FadeTransitionPtrMapObject[gTsn];
Director::GetInstance().PopStage(Tsn);
}
else {
Director::GetInstance().PopStage();
}
}
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//导演获取当前场景
static SQInteger Director_GetScene(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
uint32_t scene = Director::GetInstance().GetCurrentStage()->GetObjectID();
sq_pushinteger(v, scene);
return 1;
}
//导演退出当前场景并清空场景栈
static SQInteger Director_ClearStages(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
Director::GetInstance().ClearStages();
return 0;
}
//创建淡入淡出过渡动画
static SQInteger Creat_FadeTransition(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger gDuration;
SQBool gParallel;
sq_getinteger(v, 2, &gDuration);
sq_getbool(v, 3, &gParallel);
Duration Time = Duration(gDuration);
FadeTransitionPtr Tsn = new FadeTransition(Time, gParallel);
//获取对象的UUID
uint32_t UUID = Tsn->GetObjectID();
//将高级精灵对象存入Map管理
FadeTransitionPtrMapObject[UUID] = Tsn;
sq_pushinteger(v, UUID);
return 1;
}

427
TextActorRegister.h Normal file
View File

@ -0,0 +1,427 @@
#pragma once
extern std::map<uint64_t, ActorPtr>ActorPtrMapObject;
extern std::map<std::string, FontPtr>FontRecObject;
//创建文字对象
static SQInteger Squirrle_Create_Text_Object(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
// 创建一个文本角色
TextActorPtr text = new TextActor();
//获取文字对象的UUID
uint64_t UUID = text->GetObjectID();
//将文字对象存入Map管理
ActorPtrMapObject[UUID] = text;
//将HshName返回给虚拟机
sq_pushinteger(v, UUID);
return 1;
}
//设置文字对象文本
static SQInteger Squirrle_Set_Text_Object_Text(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
//得到Squirrel字符串
const SQChar* OutPutBuffer;
sq_getstring(v, 3, &OutPutBuffer);
//此操作会New出一个字符串需要手动销毁
char* OutPutText = SquirrelClassEx::SquirrelU2W((char*)OutPutBuffer);
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
text->SetText(OutPutText);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
//销毁New出来的字符串
delete[]OutPutText;
return 1;
}
//设置文字对象颜色
static SQInteger Squirrle_Set_Text_Object_Color(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger TextColor;
sq_getinteger(v, 3, &TextColor);
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
text->SetFillColor(TextColor);
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置文字对象字体样式
static SQInteger Squirrle_Set_Text_Object_TextStyle(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
//得到Squirrel字符串 字体路径Key
const SQChar* OutPutBuffer;
sq_getstring(v, 3, &OutPutBuffer);
//此操作会New出一个字符串需要手动销毁
char* OutPutText = SquirrelClassEx::SquirrelU2W((char*)OutPutBuffer);
std::string FontName = OutPutText;
//销毁New出来的字符串
delete[]OutPutText;
//通过字体创建文本样式
if (Top == 3) {
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
if (FontRecObject.count(FontName)) {
TextStyle TsP = TextStyle(FontRecObject[FontName]);
text->SetStyle(TsP);
}
sq_pushbool(v, true);
}
}
else if (Top == 8) {
//得到文字对其方式
SQInteger gTextAlign;
sq_getinteger(v, 4, &gTextAlign);
//得到文字自动换行宽度
SQFloat gwrap_width;
sq_getfloat(v, 5, &gwrap_width);
//得到文字行间距
SQFloat gline_spacing;
sq_getfloat(v, 6, &gline_spacing);
//得到文字显示下划线
SQBool gshow_underline;
sq_getbool(v, 7, &gshow_underline);
//得到文字显示删除线
SQBool gshow_strikethrough;
sq_getbool(v, 8, &gshow_strikethrough);
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
if (FontRecObject.count(FontName)) {
TextStyle TsP = TextStyle(FontRecObject[FontName]);
switch (gTextAlign)
{
case 0:
TsP.alignment = TextAlign::Left;
break;
case 1:
TsP.alignment = TextAlign::Right;
break;
case 2:
TsP.alignment = TextAlign::Center;
break;
case 3:
TsP.alignment = TextAlign::Justified;
break;
}
TsP.wrap_width = gwrap_width;
TsP.line_spacing = gline_spacing;
TsP.show_underline = gshow_underline;
TsP.show_strikethrough = gshow_strikethrough;
text->SetStyle(TsP);
}
sq_pushbool(v, true);
}
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置文字对其方式
static SQInteger Squirrle_Set_Text_Object_Alignment(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger TextAlignment;
sq_getinteger(v, 3, &TextAlignment);
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
switch (TextAlignment)
{
case 0:
text->SetAlignment(TextAlign::Left);
break;
case 1:
text->SetAlignment(TextAlign::Right);
break;
case 2:
text->SetAlignment(TextAlign::Center);
break;
case 3:
text->SetAlignment(TextAlign::Justified);
break;
}
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//设置文字描边
static SQInteger Squirrle_Set_Text_Object_Outline(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
SQInteger ActorUUID;
sq_getinteger(v, 2, &ActorUUID);
SQInteger OutlineStyle;
sq_getinteger(v, 3, &OutlineStyle);
SQInteger OutlineColor;
sq_getinteger(v, 4, &OutlineColor);
//从全局Map中获取文本角色
if (ActorPtrMapObject.count(ActorUUID)) {
TextActorPtr text = dynamic_cast<TextActor*>(ActorPtrMapObject[ActorUUID].Get());
StrokeStylePtr SSP = new StrokeStyle(2);
switch (OutlineStyle)
{
case 0 :
SSP->SetWidth(3.0);
//SSP->SetCapStyle(CapStyle::Flat);
//SSP->SetLineJoinStyle(LineJoinStyle::Miter);
break;
default:
break;
}
text->SetOutlineStrokeStyle(SSP);
text->SetOutlineColor(OutlineColor);
sq_pushbool(v, true);
//TextStyle OldT = text->GetStyle();
//std::string TString = text->GetText();
//TextActorPtr LeftUp = new TextActor(TString, OldT);
//LeftUp->SetPosition(-1.0, -1.0);
//LeftUp->SetFillColor(0xff000000);
//LeftUp->SetZOrder(-1);
//text->AddChild(LeftUp);
//
//TextActorPtr Left = new TextActor(TString, OldT);
//Left->SetPosition(-1.0, 0);
//Left->SetFillColor(0xff000000);
//Left->SetZOrder(-1);
//text->AddChild(Left);
//TextActorPtr LeftDown = new TextActor(TString, OldT);
//LeftDown->SetPosition(-1.0, 1.0);
//LeftDown->SetFillColor(0xff000000);
//LeftDown->SetZOrder(-1);
//text->AddChild(LeftDown);
//TextActorPtr Up = new TextActor(TString, OldT);
//Up->SetPosition(0.0, -1.0);
//Up->SetFillColor(0xff000000);
//Up->SetZOrder(-1);
//text->AddChild(Up);
//TextActorPtr Down = new TextActor(TString, OldT);
//Down->SetPosition(0.0, 1.0);
//Down->SetFillColor(0xff000000);
//Down->SetZOrder(-1);
//text->AddChild(Down);
//TextActorPtr RightUp = new TextActor(TString, OldT);
//RightUp->SetPosition(1.0, -1.0);
//RightUp->SetFillColor(0xff000000);
//RightUp->SetZOrder(-1);
//text->AddChild(RightUp);
//TextActorPtr Right = new TextActor(TString, OldT);
//Right->SetPosition(1.0, 0.0);
//Right->SetFillColor(0xff000000);
//Right->SetZOrder(-1);
//text->AddChild(Right);
//TextActorPtr RightDown = new TextActor(TString, OldT);
//RightDown->SetPosition(1.0, 1.0);
//RightDown->SetFillColor(0xff000000);
//RightDown->SetZOrder(-1);
//text->AddChild(RightDown);
//sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
//新建字体样式
static SQInteger Squirrle_Create_Font(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
//得到Squirrel字符串 字体路径Key
const SQChar* gFontName;
sq_getstring(v, 2, &gFontName);
//此操作会New出一个字符串需要手动销毁
char* FontNamebuf = SquirrelClassEx::SquirrelU2W((char*)gFontName);
std::string FontName = FontNamebuf;
delete[]FontNamebuf;
//如果字体不存在就去创建字体
if (!FontRecObject.count(FontName)) {
//得到Squirrel字符串 字体路径Key
const SQChar* OutPutBuffer;
sq_getstring(v, 3, &OutPutBuffer);
//此操作会New出一个字符串需要手动销毁
char* gFontPath = SquirrelClassEx::SquirrelU2W((char*)OutPutBuffer);
std::string FontPath = gFontPath;
delete[]gFontPath;
SQFloat gfont_size;
sq_getfloat(v, 4, &gfont_size);
FontPtr FontBuf = new Font(FontPath, gfont_size,400U,FontPosture::Normal,FontStretch::Normal);
FontRecObject[FontName] = FontBuf;
sq_pushbool(v, true);
}
else {
sq_pushbool(v, false);
}
return 1;
}
void R_Register_Nut_Text() {
//文字类
SquirrelClassEx::RegisterNutApi(_SST("sq_Create_Text_Object"), Squirrle_Create_Text_Object, v);//创建文字对象
SquirrelClassEx::RegisterNutApi(_SST("sq_Set_Text_Object_Text"), Squirrle_Set_Text_Object_Text, v);//设置文字对象文本
SquirrelClassEx::RegisterNutApi(_SST("sq_Set_Text_Object_Color"), Squirrle_Set_Text_Object_Color, v);//设置文字对象颜色
SquirrelClassEx::RegisterNutApi(_SST("sq_Set_Text_Object_TextStyle"), Squirrle_Set_Text_Object_TextStyle, v);//设置文字对象样式
SquirrelClassEx::RegisterNutApi(_SST("sq_Set_Text_Object_Alignment"), Squirrle_Set_Text_Object_Alignment, v);//设置文字对其方式
SquirrelClassEx::RegisterNutApi(_SST("sq_Set_Text_Object_Outline"), Squirrle_Set_Text_Object_Outline, v);//设置文字描边
SquirrelClassEx::RegisterNutApi(_SST("sq_Create_Font"), Squirrle_Create_Font, v);//创建字体
}

106
ThreadRegister.h Normal file
View File

@ -0,0 +1,106 @@
#pragma once
//纹理Map
extern std::unordered_map<std::string, std::map<int,TexturePtr>>ImageRecObject;
std::mutex ImageRecObjectmutex;
extern NPK_M* npk;
extern WThreadPool threadPool;
void ThreadPreloadImg_Success(std::string Name , SQInteger Scene)
{
//调用回调
sq_pushroottable(v);
sq_pushstring(v, _SST(Name.c_str()), -1);
sq_get(v, -2);
sq_pushroottable(v);
sq_pushinteger(v, Scene);
sq_call(v, 2, 0, 1);
sq_pop(v, 2);
}
void ThreadPreloadImgFunc(std::vector<std::string> ImgList, std::string Name , SQInteger Scene) {
//先遍历一次 把需要加载的img存下来
std::vector<std::string> RealImgList;
ImageRecObjectmutex.lock();
for (auto it = ImgList.begin(); it != ImgList.end(); ++it) {
std::string Iname = *it;
if (!ImageRecObject.count(Iname)) {
RealImgList.push_back(*it);
}
}
ImageRecObjectmutex.unlock();
//开始加载img 并存入临时map
std::map<std::string ,std::map<int,TexturePtr>> TexturePtrVL;
for (auto it = RealImgList.begin(); it != RealImgList.end(); ++it) {
std::string imgpath = *it;
IMG* img = npk->ReadNpkTable(imgpath);
for (int i = 0; i < img->png_sum; i++)
{
std::string RealTextureName = imgpath;
DWORD Height = img->lp_lplist[i].Height;
DWORD Width = img->lp_lplist[i].Width;
BYTE* Data = img->lp_lplist[i].PNGdata;
BinaryData data = { ((void*)Data) ,Height * Width * 4 };
TexturePtr t = new Texture;
t->Load(PixelSize(Width, Height), data, PixelFormat::Bpp32BGRA);
t->SetUserData(&img->lp_lplist[i]);
TexturePtrVL[RealTextureName][i] = t;
}
npk->ReleaseNpkTable(img);
}
//拿锁 赋值map
ImageRecObjectmutex.lock();
for (auto it = TexturePtrVL.begin(); it != TexturePtrVL.end(); it++) {
if (!ImageRecObject.count(it->first)) {
ImageRecObject[it->first] = it->second;
}
}
ImageRecObjectmutex.unlock();
auto f1 = std::bind(&ThreadPreloadImg_Success, Name , Scene);
Application::GetInstance().PerformInMainThread(f1);
}
//线程加载Img资源
static SQInteger ThreadPreloadImg(HSQUIRRELVM v)
{
SQInteger Top = sq_gettop(v);
if (Top <= 0)
{
sq_throwerror(v, _SST("Incorrect function argument"));
return 0;
}
std::vector<std::string> ImgList;
sq_pushnull(v); // null iterator
while (SQ_SUCCEEDED(sq_next(v, 2)))
{
const SQChar* path;
sq_getstring(v, -1, &path);
ImgList.push_back((char*)path);
//这里-1是值-2是键
sq_pop(v, 2); //在下一次迭代之前弹出键和值
}
sq_pop(v, 1);
const SQChar* Name;
sq_getstring(v, 3,&Name);
SQInteger SceneId;
sq_getinteger(v, 4, &SceneId);
auto f1 = std::bind(&ThreadPreloadImgFunc, ImgList, (char*)Name, SceneId);
threadPool.concurrentRun(f1);
return 1;
}

73
UiFrameWork.cpp Normal file
View File

@ -0,0 +1,73 @@
#include "UiFrameWork.h"
std::map<uint64_t , int>UI_HOVER_ZORDER;
std::map<uint64_t, UiFrameWork*>UI_HOVER_OBJECT;
void UiFrameWork::OnHoverEvent(Event* evt) {
//每当UI类被悬停时就会像Map 书写自身位置
UI_HOVER_ZORDER[this->GetObjectID()] = this->GetZOrder();
UI_HOVER_OBJECT[this->GetObjectID()] = this;
//取的Map的最大层的对象名称
auto MaxZorderMap = std::max_element(UI_HOVER_ZORDER.begin(), UI_HOVER_ZORDER.end(), [](std::pair<std::uint64_t, int> left, std::pair<std::uint64_t, int> right) { return left.second < right.second; });
std::map<uint64_t, UiFrameWork*>::reverse_iterator iter;
for (iter = UI_HOVER_OBJECT.rbegin(); iter != UI_HOVER_OBJECT.rend(); iter++) {
//如果是最大层那么调用悬停如果不是就调用移出悬停
if (iter->first == MaxZorderMap->first) {
iter->second->OnHover();
}
else {
iter->second->OnOut();
}
}
}
void UiFrameWork::OnOutEvent(Event* evt) {
//每当UI类不在被悬停时 就会从Map中 移除自身位置
UI_HOVER_ZORDER.erase(this->GetObjectID());
UI_HOVER_OBJECT.erase(this->GetObjectID());
this->OnOut();
//取的Map的最大层的对象名称
auto MaxZorderMap = std::max_element(UI_HOVER_ZORDER.begin(), UI_HOVER_ZORDER.end(), [](std::pair<std::uint64_t, int> left, std::pair<std::uint64_t, int> right) { return left.second < right.second; });
std::map<uint64_t, UiFrameWork*>::reverse_iterator iter;
for (iter = UI_HOVER_OBJECT.rbegin(); iter != UI_HOVER_OBJECT.rend(); iter++) {
//如果是最大层那么调用悬停如果不是就调用移出悬停
if (iter->first == MaxZorderMap->first) {
iter->second->OnHover();
}
else {
iter->second->OnOut();
}
}
}
void UiFrameWork::RemoveZorder()
{
UI_HOVER_ZORDER.erase(this->GetObjectID());
UI_HOVER_OBJECT.erase(this->GetObjectID());
}
void UiFrameWork::OnHover()
{
}
void UiFrameWork::OnOut()
{
}
void UiFrameWork::Init()
{
//UI类 都会增加鼠标监听
ComponentPtr comp = new MouseSensor;
AddComponent(0, comp);
//增加悬停和移出的响应事件
AddListener<MouseHoverEvent>(Closure(this, &UiFrameWork::OnHoverEvent));
AddListener<MouseOutEvent>(Closure(this, &UiFrameWork::OnOutEvent));
}

23
UiFrameWork.h Normal file
View File

@ -0,0 +1,23 @@
#pragma once
#include <kiwano/kiwano.h>
using namespace kiwano;
/*
UI层为80000 - 90000
*/
class UiFrameWork : public Sprite
{
private:
public:
virtual void Init();
//事件
void OnHoverEvent(Event* evt);
void OnOutEvent(Event* evt);
void RemoveZorder();
//用于子类重载的事件下级调用
virtual void OnHover();
virtual void OnOut();
};

267
WThreadPool.cpp Normal file
View File

@ -0,0 +1,267 @@
#include "WThreadPool.h"
using namespace std;
shared_ptr<WThreadPool> WThreadPool::s_threadPool;
std::mutex WThreadPool::s_globleMutex;
WThreadPool::WThreadPool()
{
_mgrThread = make_shared<thread>(&WThreadPool::managerThread, this);
}
WThreadPool::~WThreadPool()
{
stop();
}
WThreadPool *WThreadPool::globalInstance()
{
if (!s_threadPool.get())
{
unique_lock<mutex> locker(s_globleMutex);
if (!s_threadPool.get())
{
s_threadPool = make_shared<WThreadPool>();
}
}
return s_threadPool.get();
}
void WThreadPool::setMaxThreadNum(int maxNum)
{
if (maxNum > WPOOL_MAX_THREAD_NUM)
{
maxNum = WPOOL_MAX_THREAD_NUM;
}
else if (maxNum < WPOOL_MIN_THREAD_NUM)
{
maxNum = WPOOL_MIN_THREAD_NUM;
}
_maxThreadNum = maxNum;
}
bool WThreadPool::waitForDone(int waitMs)
{
int waitedMs = 0;
while(_busyThreadNum != 0 || !_eventQueue.empty())
{
this_thread::sleep_for(chrono::milliseconds(1));
waitedMs++;
if (waitMs > 0 && waitedMs >= waitMs)
{
return false;
}
}
return true;
}
void WThreadPool::enQueueEvent(EventFun fun)
{
bool res = _eventQueue.enQueue(fun);
assert(res);
}
EventFun WThreadPool::deQueueEvent()
{
EventFun fun;
if (_eventQueue.deQueue(fun))
{
return fun;
}
else
{
return nullptr;
}
return fun;
}
void WThreadPool::run()
{
{
unique_lock<mutex> locker(_threadIsRunMutex);
_threadIsRunMap[this_thread::get_id()] = true;
}
while (!_exitAllFlag)
{
{
unique_lock<mutex> locker(_workMutex);
if (_eventQueue.empty() && !_exitAllFlag)
{
_workCondVar.wait(locker);
}
if (_reduceThreadNum > 0)
{
_reduceThreadNum--;
break;
}
}
_busyThreadNum++;
while (!_exitAllFlag)
{
EventFun fun = deQueueEvent();
if (!fun)
{
break;
}
fun();
}
_busyThreadNum--;
}
{
unique_lock<mutex> locker(_threadIsRunMutex);
_threadIsRunMap[this_thread::get_id()] = false;
}
}
void WThreadPool::stop()
{
_exitAllFlag = true;
{
unique_lock<mutex> locker(_mgrMutex);
_mgrCondVar.notify_all();
}
if (_mgrThread->joinable())
{
_mgrThread->join();
}
}
void WThreadPool::managerThread()
{
startWorkThread();
while (!_exitAllFlag)
{
{
unique_lock<mutex> locker(_mgrMutex);
auto now = std::chrono::system_clock::now();
// if the number of threads reaches the maximum or the number of idle threads is enough to
// complete the task, sleep will be started
if (((int)_workThreadList.size() >= _maxThreadNum ||
_eventQueue.size() < ((int)_workThreadList.size() - _busyThreadNum - ADD_THREAD_BOUNDARY)) && !_exitAllFlag)
{
_mgrCondVar.wait_until(locker, now + chrono::seconds(WPOOL_MANAGE_SECONDS));
}
}
if (_exitAllFlag)
{
break;
}
adjustWorkThread();
// WThreadPool_log("get here to show work thread num:%d", _workThreadList.size());
}
stopWorkThread();
}
void WThreadPool::startWorkThread()
{
for (int i = 0; i < _minThreadNum; i++)
{
shared_ptr<thread> threadPtr = make_shared<thread>(&WThreadPool::run, this);
_workThreadList.emplace_back(threadPtr);
}
}
void WThreadPool::stopWorkThread()
{
{
unique_lock<mutex> locker(_mgrMutex);
_workCondVar.notify_all();
}
for (auto it = _workThreadList.begin(); it != _workThreadList.end(); it++)
{
if ((*it)->joinable())
{
(*it)->join();
}
}
_workThreadList.clear();
_threadIsRunMap.clear();
_eventQueue.clear();
}
void WThreadPool::adjustWorkThread()
{
int queueSize = _eventQueue.size();
int busyThreadNum = _busyThreadNum;
int liveThreadNum = _workThreadList.size();
int maxThreadNum = _maxThreadNum;
int stepThreadNum = _stepThreadNum;
int minThreadNum = _minThreadNum;
// if rest thread can not run all task concurrently, add the thread
if ((liveThreadNum < maxThreadNum) && (queueSize >= (liveThreadNum - busyThreadNum - ADD_THREAD_BOUNDARY)))
{
int restAllAddNum = maxThreadNum - liveThreadNum;
int addThreadNum = restAllAddNum > stepThreadNum ? stepThreadNum : restAllAddNum;
for (int i = 0; i < addThreadNum; i++)
{
shared_ptr<thread> threadPtr = make_shared<thread>(&WThreadPool::run, this);
_workThreadList.emplace_back(threadPtr);
}
}
else if ((liveThreadNum > minThreadNum) && (busyThreadNum*2 < liveThreadNum))
{
int resAllReduceNum = liveThreadNum - minThreadNum;
int reduceThreadNum = resAllReduceNum > stepThreadNum ? stepThreadNum : resAllReduceNum;
_reduceThreadNum = reduceThreadNum;
int findExitThreadNum = 0;
do
{
if (_exitAllFlag)
{
return;
}
for (int i = 0; i < (reduceThreadNum - findExitThreadNum); i++)
{
_workCondVar.notify_one();
}
this_thread::sleep_for(chrono::milliseconds(1));
{
unique_lock<mutex> locker(_threadIsRunMutex);
for (auto it = _workThreadList.begin(); it != _workThreadList.end();)
{
std::thread::id threadId = (*it)->get_id();
auto threadIdIt = _threadIsRunMap.find(threadId);
if ((threadIdIt != _threadIsRunMap.end()) && (_threadIsRunMap[threadId] == false))
{
findExitThreadNum++;
_threadIsRunMap.erase(threadIdIt);
(*it)->join();
_workThreadList.erase(it++);
}
else
{
it++;
}
}
}
if (findExitThreadNum < reduceThreadNum)
{
this_thread::sleep_for(chrono::milliseconds(1));
}
/*
WThreadPool_log("get here 3 to show findExitThreadNum:%d, reduceThreadNum:%d, _reduceThreadNum:%d", findExitThreadNum, reduceThreadNum, (int)_reduceThreadNum);
for (auto it = _workThreadList.begin(); it != _workThreadList.end(); it++)
{
WThreadPool_log("work thread pid:%lld", (*it)->get_id());
}
for (auto it = _threadIsRunMap.begin(); it != _threadIsRunMap.end(); it++)
{
WThreadPool_log("it->first:%lld, it->second:%d", it->first, it->second);
}
*/
} while(!(findExitThreadNum >= reduceThreadNum && _reduceThreadNum <= 0));
}
}

90
WThreadPool.h Normal file
View File

@ -0,0 +1,90 @@
#pragma once
#include <functional>
#include <mutex>
#include <list>
#include <thread>
#include <memory>
#include <atomic>
#include <stdio.h>
#include <map>
#include <sstream>
#include <condition_variable>
#include "LockQueue.hpp"
#include <assert.h>
#define WThreadPool_log(fmt, ...) {printf(fmt, ##__VA_ARGS__);printf("\n");fflush(stdout);}
#define WPOOL_MIN_THREAD_NUM 4
#define WPOOL_MAX_THREAD_NUM 256
#define WPOOL_MANAGE_SECONDS 20
#define ADD_THREAD_BOUNDARY 1
using EventFun = std::function<void ()>;
using int64 = long long int;
class WThreadPool
{
public:
WThreadPool();
virtual ~WThreadPool();
static WThreadPool * globalInstance();
void setMaxThreadNum(int maxNum);
bool waitForDone(int waitMs = -1);
template<typename Func, typename ...Arguments >
void concurrentRun(Func func, Arguments... args) {
EventFun queunFun = std::bind(func, args...);
enQueueEvent(queunFun);
if (((int)_workThreadList.size() < _maxThreadNum) &&
(_eventQueue.size() >= ((int)_workThreadList.size() - _busyThreadNum - ADD_THREAD_BOUNDARY)))
{
_mgrCondVar.notify_one();
}
_workCondVar.notify_one();
}
template<typename T> static int64_t threadIdToint64(T threadId)
{
std::string stid;
stid.resize(32);
snprintf((char *)stid.c_str(), 32, "%lld", threadId);
long long int tid = std::stoll(stid);
return tid;
}
private:
int _minThreadNum = WPOOL_MIN_THREAD_NUM;
int _maxThreadNum = 8;
std::atomic<int> _busyThreadNum = {0};
int _stepThreadNum = 4;
volatile bool _exitAllFlag = false;
std::atomic<int> _reduceThreadNum = {0};
std::shared_ptr<std::thread> _mgrThread;
LockQueue<EventFun> _eventQueue;
std::list<std::shared_ptr<std::thread>> _workThreadList;
std::mutex _threadIsRunMutex;
std::map<std::thread::id, bool> _threadIsRunMap;
std::condition_variable _workCondVar;
std::mutex _workMutex;
std::condition_variable _mgrCondVar;
std::mutex _mgrMutex;
static std::shared_ptr<WThreadPool> s_threadPool;
static std::mutex s_globleMutex;
void enQueueEvent(EventFun fun);
EventFun deQueueEvent();
void run();
void managerThread();
void stop();
void startWorkThread();
void stopWorkThread();
void adjustWorkThread();
};

BIN
Yosin_Game.aps Normal file

Binary file not shown.

187
Yosin_Game.sln Normal file
View File

@ -0,0 +1,187 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.4.33122.133
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Yosin_Game", "Yosin_Game.vcxproj", "{26A5FEB5-A40D-4902-845C-2CB0635445CC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano", "H:\kiwano\projects\kiwano\kiwano.vcxproj", "{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "kiwano-audio", "H:\kiwano\projects\kiwano-audio\kiwano-audio.vcxproj", "{1B97937D-8184-426C-BE71-29A163DC76C9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squirrel", "H:\squirrel_3_2_stable\squirrel3\squirrel\build\squirrel.vcxproj", "{35FBC183-03D6-307A-B4D7-3798A85056CD}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqstdlib", "H:\squirrel_3_2_stable\squirrel3\sqstdlib\build\sqstdlib.vcxproj", "{9F91073D-8955-376C-ACFA-90271B243628}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sqstdlib_static", "H:\squirrel_3_2_stable\squirrel3\sqstdlib\build\sqstdlib_static.vcxproj", "{9FDC0714-6D07-3637-88C1-10E3A32F5458}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "squirrel_static", "H:\squirrel_3_2_stable\squirrel3\squirrel\build\squirrel_static.vcxproj", "{22BF092A-60A8-3196-B83B-4F16BA095260}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libogg", "H:\kiwano\projects\3rd-party\libogg\libogg.vcxproj", "{D8A5E8EC-3983-4028-9BA9-B1E337E75917}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libvorbis", "H:\kiwano\projects\3rd-party\vorbis\libvorbis.vcxproj", "{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
MinSizeRel|x64 = MinSizeRel|x64
MinSizeRel|x86 = MinSizeRel|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
RelWithDebInfo|x64 = RelWithDebInfo|x64
RelWithDebInfo|x86 = RelWithDebInfo|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Debug|x64.ActiveCfg = Debug|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Debug|x64.Build.0 = Debug|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Debug|x86.ActiveCfg = Debug|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Debug|x86.Build.0 = Debug|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.MinSizeRel|x64.ActiveCfg = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.MinSizeRel|x64.Build.0 = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.MinSizeRel|x86.ActiveCfg = Release|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.MinSizeRel|x86.Build.0 = Release|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Release|x64.ActiveCfg = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Release|x64.Build.0 = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Release|x86.ActiveCfg = Release|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.Release|x86.Build.0 = Release|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.RelWithDebInfo|x64.Build.0 = Release|x64
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{26A5FEB5-A40D-4902-845C-2CB0635445CC}.RelWithDebInfo|x86.Build.0 = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|x64.ActiveCfg = Debug|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|x64.Build.0 = Debug|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|x86.ActiveCfg = Debug|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Debug|x86.Build.0 = Debug|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.MinSizeRel|x64.ActiveCfg = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.MinSizeRel|x64.Build.0 = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.MinSizeRel|x86.ActiveCfg = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.MinSizeRel|x86.Build.0 = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x64.ActiveCfg = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x64.Build.0 = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x86.ActiveCfg = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.Release|x86.Build.0 = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.RelWithDebInfo|x64.Build.0 = Release|x64
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{FF7F943D-A89C-4E6C-97CF-84F7D8FF8EDF}.RelWithDebInfo|x86.Build.0 = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|x64.ActiveCfg = Debug|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|x64.Build.0 = Debug|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|x86.ActiveCfg = Debug|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.Debug|x86.Build.0 = Debug|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.MinSizeRel|x64.ActiveCfg = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.MinSizeRel|x64.Build.0 = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.MinSizeRel|x86.ActiveCfg = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.MinSizeRel|x86.Build.0 = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|x64.ActiveCfg = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|x64.Build.0 = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|x86.ActiveCfg = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.Release|x86.Build.0 = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.RelWithDebInfo|x64.Build.0 = Release|x64
{1B97937D-8184-426C-BE71-29A163DC76C9}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{1B97937D-8184-426C-BE71-29A163DC76C9}.RelWithDebInfo|x86.Build.0 = Release|Win32
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Debug|x64.ActiveCfg = Debug|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Debug|x64.Build.0 = Debug|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Debug|x86.ActiveCfg = Debug|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Debug|x86.Build.0 = Debug|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.MinSizeRel|x86.Build.0 = MinSizeRel|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Release|x64.ActiveCfg = Release|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Release|x64.Build.0 = Release|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Release|x86.ActiveCfg = Release|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.Release|x86.Build.0 = Release|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{35FBC183-03D6-307A-B4D7-3798A85056CD}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Debug|x64.ActiveCfg = Debug|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Debug|x64.Build.0 = Debug|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Debug|x86.ActiveCfg = Debug|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Debug|x86.Build.0 = Debug|x64
{9F91073D-8955-376C-ACFA-90271B243628}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{9F91073D-8955-376C-ACFA-90271B243628}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{9F91073D-8955-376C-ACFA-90271B243628}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{9F91073D-8955-376C-ACFA-90271B243628}.MinSizeRel|x86.Build.0 = MinSizeRel|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Release|x64.ActiveCfg = Release|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Release|x64.Build.0 = Release|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Release|x86.ActiveCfg = Release|x64
{9F91073D-8955-376C-ACFA-90271B243628}.Release|x86.Build.0 = Release|x64
{9F91073D-8955-376C-ACFA-90271B243628}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{9F91073D-8955-376C-ACFA-90271B243628}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{9F91073D-8955-376C-ACFA-90271B243628}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{9F91073D-8955-376C-ACFA-90271B243628}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Debug|x64.ActiveCfg = Debug|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Debug|x64.Build.0 = Debug|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Debug|x86.ActiveCfg = Debug|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Debug|x86.Build.0 = Debug|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.MinSizeRel|x86.Build.0 = MinSizeRel|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Release|x64.ActiveCfg = Release|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Release|x64.Build.0 = Release|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Release|x86.ActiveCfg = Release|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.Release|x86.Build.0 = Release|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{9FDC0714-6D07-3637-88C1-10E3A32F5458}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Debug|x64.ActiveCfg = Debug|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Debug|x64.Build.0 = Debug|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Debug|x86.ActiveCfg = Debug|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Debug|x86.Build.0 = Debug|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.MinSizeRel|x64.ActiveCfg = MinSizeRel|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.MinSizeRel|x64.Build.0 = MinSizeRel|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.MinSizeRel|x86.ActiveCfg = MinSizeRel|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.MinSizeRel|x86.Build.0 = MinSizeRel|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Release|x64.ActiveCfg = Release|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Release|x64.Build.0 = Release|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Release|x86.ActiveCfg = Release|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.Release|x86.Build.0 = Release|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.RelWithDebInfo|x86.ActiveCfg = RelWithDebInfo|x64
{22BF092A-60A8-3196-B83B-4F16BA095260}.RelWithDebInfo|x86.Build.0 = RelWithDebInfo|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Debug|x64.ActiveCfg = Debug|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Debug|x64.Build.0 = Debug|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Debug|x86.ActiveCfg = Debug|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Debug|x86.Build.0 = Debug|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.MinSizeRel|x64.ActiveCfg = Debug|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.MinSizeRel|x64.Build.0 = Debug|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.MinSizeRel|x86.Build.0 = Debug|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Release|x64.ActiveCfg = Release|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Release|x64.Build.0 = Release|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Release|x86.ActiveCfg = Release|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.Release|x86.Build.0 = Release|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.RelWithDebInfo|x64.Build.0 = Release|x64
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{D8A5E8EC-3983-4028-9BA9-B1E337E75917}.RelWithDebInfo|x86.Build.0 = Release|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Debug|x64.ActiveCfg = Debug|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Debug|x64.Build.0 = Debug|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Debug|x86.ActiveCfg = Debug|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Debug|x86.Build.0 = Debug|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.MinSizeRel|x64.ActiveCfg = Debug|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.MinSizeRel|x64.Build.0 = Debug|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.MinSizeRel|x86.ActiveCfg = Debug|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.MinSizeRel|x86.Build.0 = Debug|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Release|x64.ActiveCfg = Release|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Release|x64.Build.0 = Release|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Release|x86.ActiveCfg = Release|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.Release|x86.Build.0 = Release|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.RelWithDebInfo|x64.ActiveCfg = Release|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.RelWithDebInfo|x64.Build.0 = Release|x64
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.RelWithDebInfo|x86.ActiveCfg = Release|Win32
{B62E3DE6-812D-4CE6-90D9-18FD4FEA8EB2}.RelWithDebInfo|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C4FDA2BA-AA6C-49FB-93F6-471AC5BE927A}
EndGlobalSection
EndGlobal

205
Yosin_Game.vcxproj Normal file
View File

@ -0,0 +1,205 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{26a5feb5-a40d-4902-845c-2cb0635445cc}</ProjectGuid>
<RootNamespace>YosinGame</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<IncludePath>I:\Yosin_Game\Yosin_Game\include;$(IncludePath)</IncludePath>
<OutDir>I:\YosinGame\</OutDir>
<LibraryPath>$(LibraryPath)</LibraryPath>
<ReferencePath>$(ReferencePath)</ReferencePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>TurnOffAllWarnings</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;NOMINMAX;_SQ64;SQUNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>H:\kiwano\src;H:\kiwano\src\3rd-party;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>sqstdlib.lib;squirrel.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>I:\Yosin_Game\Yosin_Game\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="BaseRead.cpp" />
<ClCompile Include="Cursor.cpp" />
<ClCompile Include="GameState.cpp" />
<ClCompile Include="Npk.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="SoundManager.cpp" />
<ClCompile Include="SpriteEx.cpp" />
<ClCompile Include="SquirrelActor.cpp" />
<ClCompile Include="SquirrelButton.cpp" />
<ClCompile Include="SquirrelCamera.cpp" />
<ClCompile Include="SquirrelClassEx.cpp" />
<ClCompile Include="SquirrelStage.cpp" />
<ClCompile Include="SquirrelTownStage.cpp" />
<ClCompile Include="UiFrameWork.cpp" />
<ClCompile Include="WThreadPool.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="BaseRead.h" />
<ClInclude Include="ButtonActorRegister.h" />
<ClInclude Include="CanvasActorRegister.h" />
<ClInclude Include="Cursor.h" />
<ClInclude Include="GameState.h" />
<ClInclude Include="ImguiLayerActorRegister.h" />
<ClInclude Include="include\json.hpp" />
<ClInclude Include="LockQueue.hpp" />
<ClInclude Include="Npk.h" />
<ClInclude Include="SoundActorRegister.h" />
<ClInclude Include="SoundManager.h" />
<ClInclude Include="SpriteActorRegister.h" />
<ClInclude Include="SpriteEx.h" />
<ClInclude Include="SquirrelActor.h" />
<ClInclude Include="SquirrelButton.h" />
<ClInclude Include="SquirrelCamera.h" />
<ClInclude Include="SquirrelClassEx.h" />
<ClInclude Include="SquirrelStage.h" />
<ClInclude Include="SquirrelTownStage.h" />
<ClInclude Include="StageActorRegister.h" />
<ClInclude Include="TextActorRegister.h" />
<ClInclude Include="ThreadRegister.h" />
<ClInclude Include="UiFrameWork.h" />
<ClInclude Include="WThreadPool.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="H:\kiwano\projects\3rd-party\libogg\libogg.vcxproj">
<Project>{d8a5e8ec-3983-4028-9ba9-b1e337e75917}</Project>
</ProjectReference>
<ProjectReference Include="H:\kiwano\projects\kiwano-audio\kiwano-audio.vcxproj">
<Project>{1b97937d-8184-426c-be71-29a163dc76c9}</Project>
</ProjectReference>
<ProjectReference Include="H:\kiwano\projects\kiwano\kiwano.vcxproj">
<Project>{ff7f943d-a89c-4e6c-97cf-84f7d8ff8edf}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\zlib-msvc14-x64.1.2.11.7795\build\native\zlib-msvc14-x64.targets" Condition="Exists('packages\zlib-msvc14-x64.1.2.11.7795\build\native\zlib-msvc14-x64.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\zlib-msvc14-x64.1.2.11.7795\build\native\zlib-msvc14-x64.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\zlib-msvc14-x64.1.2.11.7795\build\native\zlib-msvc14-x64.targets'))" />
</Target>
</Project>

159
Yosin_Game.vcxproj.filters Normal file
View File

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="源文件">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="头文件">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="资源文件">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="头文件\BaseToolClass">
<UniqueIdentifier>{0d071ac7-fac4-49ac-8710-9e288f776542}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\BaseToolClass">
<UniqueIdentifier>{d1c0efa4-8635-4763-8881-888e78127822}</UniqueIdentifier>
</Filter>
<Filter Include="头文件\SquirrelActorClass">
<UniqueIdentifier>{d55ea374-ebc7-4345-8e15-dfb18c8dc856}</UniqueIdentifier>
</Filter>
<Filter Include="源文件\SquirrelActorClass">
<UniqueIdentifier>{7c17ea16-1631-4176-a371-194092bc82e3}</UniqueIdentifier>
</Filter>
<Filter Include="头文件\SquirrelRegister">
<UniqueIdentifier>{8eaaa8e3-81bc-4b00-89f4-1c716f5639fa}</UniqueIdentifier>
</Filter>
<Filter Include="ogg">
<UniqueIdentifier>{53dcb392-061b-469f-957c-4af7c786f9dc}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="BaseRead.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="Npk.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="GameState.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SquirrelClassEx.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SquirrelActor.cpp">
<Filter>源文件\SquirrelActorClass</Filter>
</ClCompile>
<ClCompile Include="Cursor.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="SquirrelStage.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="SquirrelButton.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="SpriteEx.cpp">
<Filter>源文件\BaseToolClass</Filter>
</ClCompile>
<ClCompile Include="WThreadPool.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="SquirrelTownStage.cpp">
<Filter>源文件\SquirrelActorClass</Filter>
</ClCompile>
<ClCompile Include="UiFrameWork.cpp">
<Filter>源文件\SquirrelActorClass</Filter>
</ClCompile>
<ClCompile Include="SquirrelCamera.cpp">
<Filter>源文件\SquirrelActorClass</Filter>
</ClCompile>
<ClCompile Include="SoundManager.cpp">
<Filter>源文件\SquirrelActorClass</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="BaseRead.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="Npk.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="GameState.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SquirrelClassEx.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="SquirrelActor.h">
<Filter>头文件\SquirrelActorClass</Filter>
</ClInclude>
<ClInclude Include="Cursor.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="SquirrelStage.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="SquirrelButton.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="SpriteEx.h">
<Filter>头文件\BaseToolClass</Filter>
</ClInclude>
<ClInclude Include="TextActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="SpriteActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="SoundActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="StageActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="CanvasActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="ButtonActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="ImguiLayerActorRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="include\json.hpp">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="LockQueue.hpp">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="WThreadPool.h">
<Filter>头文件</Filter>
</ClInclude>
<ClInclude Include="ThreadRegister.h">
<Filter>头文件\SquirrelRegister</Filter>
</ClInclude>
<ClInclude Include="SquirrelCamera.h">
<Filter>头文件\SquirrelActorClass</Filter>
</ClInclude>
<ClInclude Include="SquirrelTownStage.h">
<Filter>头文件\SquirrelActorClass</Filter>
</ClInclude>
<ClInclude Include="UiFrameWork.h">
<Filter>头文件\SquirrelActorClass</Filter>
</ClInclude>
<ClInclude Include="SoundManager.h">
<Filter>头文件\SquirrelActorClass</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

7
Yosin_Game.vcxproj.user Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>I:\YosinGame</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>

10
imgui.ini Normal file
View File

@ -0,0 +1,10 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0
[Window][测试窗口]
Pos=398,335
Size=54,120
Collapsed=0

24596
include/json.hpp Normal file

File diff suppressed because it is too large Load Diff

146
include/sqconfig.h Normal file
View File

@ -0,0 +1,146 @@
#ifdef _SQ64
#ifdef _MSC_VER
typedef __int64 SQInteger;
typedef unsigned __int64 SQUnsignedInteger;
typedef unsigned __int64 SQHash; /*should be the same size of a pointer*/
#else
typedef long long SQInteger;
typedef unsigned long long SQUnsignedInteger;
typedef unsigned long long SQHash; /*should be the same size of a pointer*/
#endif
typedef int SQInt32;
typedef unsigned int SQUnsignedInteger32;
#else
typedef int SQInteger;
typedef int SQInt32; /*must be 32 bits(also on 64bits processors)*/
typedef unsigned int SQUnsignedInteger32; /*must be 32 bits(also on 64bits processors)*/
typedef unsigned int SQUnsignedInteger;
typedef unsigned int SQHash; /*should be the same size of a pointer*/
#endif
#ifdef SQUSEDOUBLE
typedef double SQFloat;
#else
typedef float SQFloat;
#endif
#if defined(SQUSEDOUBLE) && !defined(_SQ64) || !defined(SQUSEDOUBLE) && defined(_SQ64)
#ifdef _MSC_VER
typedef __int64 SQRawObjectVal; //must be 64bits
#else
typedef long long SQRawObjectVal; //must be 64bits
#endif
#define SQ_OBJECT_RAWINIT() { _unVal.raw = 0; }
#else
typedef SQUnsignedInteger SQRawObjectVal; //is 32 bits on 32 bits builds and 64 bits otherwise
#define SQ_OBJECT_RAWINIT()
#endif
#ifndef SQ_ALIGNMENT // SQ_ALIGNMENT shall be less than or equal to SQ_MALLOC alignments, and its value shall be power of 2.
#if defined(SQUSEDOUBLE) || defined(_SQ64)
#define SQ_ALIGNMENT 8
#else
#define SQ_ALIGNMENT 4
#endif
#endif
typedef void* SQUserPointer;
typedef SQUnsignedInteger SQBool;
typedef SQInteger SQRESULT;
#ifdef SQUNICODE
#include <wchar.h>
#include <wctype.h>
typedef wchar_t SQChar;
#define scstrcmp wcscmp
#ifdef _WIN32
#define scsprintf _snwprintf
#else
#define scsprintf swprintf
#endif
#define scstrlen wcslen
#define scstrtod wcstod
#ifdef _SQ64
#define scstrtol wcstoll
#else
#define scstrtol wcstol
#endif
#define scstrtoul wcstoul
#define scvsprintf vswprintf
#define scstrstr wcsstr
#define scprintf wprintf
#ifdef _WIN32
#define WCHAR_SIZE 2
#define WCHAR_SHIFT_MUL 1
#define MAX_CHAR 0xFFFF
#else
#define WCHAR_SIZE 4
#define WCHAR_SHIFT_MUL 2
#define MAX_CHAR 0xFFFFFFFF
#endif
#define _SC(a) L##a
#define scisspace iswspace
#define scisdigit iswdigit
#define scisprint iswprint
#define scisxdigit iswxdigit
#define scisalpha iswalpha
#define sciscntrl iswcntrl
#define scisalnum iswalnum
#define sq_rsl(l) ((l)<<WCHAR_SHIFT_MUL)
#else
typedef char SQChar;
#define _SC(a) a
#define scstrcmp strcmp
#ifdef _MSC_VER
#define scsprintf _snprintf
#else
#define scsprintf snprintf
#endif
#define scstrlen strlen
#define scstrtod strtod
#ifdef _SQ64
#ifdef _MSC_VER
#define scstrtol _strtoi64
#else
#define scstrtol strtoll
#endif
#else
#define scstrtol strtol
#endif
#define scstrtoul strtoul
#define scvsprintf vsnprintf
#define scstrstr strstr
#define scisspace isspace
#define scisdigit isdigit
#define scisprint isprint
#define scisxdigit isxdigit
#define sciscntrl iscntrl
#define scisalpha isalpha
#define scisalnum isalnum
#define scprintf printf
#define MAX_CHAR 0xFF
#define sq_rsl(l) (l)
#endif
#ifdef _SQ64
#define _PRINT_INT_PREC _SC("ll")
#define _PRINT_INT_FMT _SC("%lld")
#else
#define _PRINT_INT_FMT _SC("%d")
#endif

18
include/sqstdaux.h Normal file
View File

@ -0,0 +1,18 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_AUXLIB_H_
#define _SQSTD_AUXLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API void sqstd_seterrorhandlers(HSQUIRRELVM v);
SQUIRREL_API void sqstd_printcallstack(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sqstd_throwerrorf(HSQUIRRELVM v,const SQChar *err,...);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /* _SQSTD_AUXLIB_H_ */

20
include/sqstdblob.h Normal file
View File

@ -0,0 +1,20 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTDBLOB_H_
#define _SQSTDBLOB_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQUserPointer sqstd_createblob(HSQUIRRELVM v, SQInteger size);
SQUIRREL_API SQRESULT sqstd_getblob(HSQUIRRELVM v,SQInteger idx,SQUserPointer *ptr);
SQUIRREL_API SQInteger sqstd_getblobsize(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sqstd_register_bloblib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTDBLOB_H_*/

54
include/sqstdio.h Normal file
View File

@ -0,0 +1,54 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTDIO_H_
#define _SQSTDIO_H_
#ifdef __cplusplus
#define SQSTD_STREAM_TYPE_TAG 0x80000000
struct SQStream {
virtual ~SQStream() {}
virtual SQInteger Read(void *buffer, SQInteger size) = 0;
virtual SQInteger Write(void *buffer, SQInteger size) = 0;
virtual SQInteger Flush() = 0;
virtual SQInteger Tell() = 0;
virtual SQInteger Len() = 0;
virtual SQInteger Seek(SQInteger offset, SQInteger origin) = 0;
virtual bool IsValid() = 0;
virtual bool EOS() = 0;
};
extern "C" {
#endif
#define SQ_SEEK_CUR 0
#define SQ_SEEK_END 1
#define SQ_SEEK_SET 2
typedef void* SQFILE;
SQUIRREL_API SQFILE sqstd_fopen(const SQChar *,const SQChar *);
SQUIRREL_API SQInteger sqstd_fread(SQUserPointer, SQInteger, SQInteger, SQFILE);
SQUIRREL_API SQInteger sqstd_fwrite(const SQUserPointer, SQInteger, SQInteger, SQFILE);
SQUIRREL_API SQInteger sqstd_fseek(SQFILE , SQInteger , SQInteger);
SQUIRREL_API SQInteger sqstd_ftell(SQFILE);
SQUIRREL_API SQInteger sqstd_fflush(SQFILE);
SQUIRREL_API SQInteger sqstd_fclose(SQFILE);
SQUIRREL_API SQInteger sqstd_feof(SQFILE);
SQUIRREL_API SQRESULT sqstd_createfile(HSQUIRRELVM v, SQFILE file,SQBool own);
SQUIRREL_API SQRESULT sqstd_getfile(HSQUIRRELVM v, SQInteger idx, SQFILE *file);
//compiler helpers
SQUIRREL_API SQRESULT sqstd_loadfile(HSQUIRRELVM v,const SQChar *filename,SQBool printerror);
SQUIRREL_API SQRESULT sqstd_dofile(HSQUIRRELVM v,const SQChar *filename,SQBool retval,SQBool printerror);
SQUIRREL_API SQRESULT sqstd_writeclosuretofile(HSQUIRRELVM v,const SQChar *filename);
SQUIRREL_API SQRESULT sqstd_register_iolib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTDIO_H_*/

15
include/sqstdmath.h Normal file
View File

@ -0,0 +1,15 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_MATH_H_
#define _SQSTD_MATH_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQRESULT sqstd_register_mathlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTD_MATH_H_*/

35
include/sqstdstring.h Normal file
View File

@ -0,0 +1,35 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_STRING_H_
#define _SQSTD_STRING_H_
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int SQRexBool;
typedef struct SQRex SQRex;
typedef struct {
const SQChar *begin;
SQInteger len;
} SQRexMatch;
SQUIRREL_API SQRex *sqstd_rex_compile(const SQChar *pattern,const SQChar **error);
SQUIRREL_API void sqstd_rex_free(SQRex *exp);
SQUIRREL_API SQBool sqstd_rex_match(SQRex* exp,const SQChar* text);
SQUIRREL_API SQBool sqstd_rex_search(SQRex* exp,const SQChar* text, const SQChar** out_begin, const SQChar** out_end);
SQUIRREL_API SQBool sqstd_rex_searchrange(SQRex* exp,const SQChar* text_begin,const SQChar* text_end,const SQChar** out_begin, const SQChar** out_end);
SQUIRREL_API SQInteger sqstd_rex_getsubexpcount(SQRex* exp);
SQUIRREL_API SQBool sqstd_rex_getsubexp(SQRex* exp, SQInteger n, SQRexMatch *subexp);
SQUIRREL_API SQRESULT sqstd_format(HSQUIRRELVM v,SQInteger nformatstringidx,SQInteger *outlen,SQChar **output);
SQUIRREL_API void sqstd_pushstringf(HSQUIRRELVM v,const SQChar *s,...);
SQUIRREL_API SQRESULT sqstd_register_stringlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQSTD_STRING_H_*/

15
include/sqstdsystem.h Normal file
View File

@ -0,0 +1,15 @@
/* see copyright notice in squirrel.h */
#ifndef _SQSTD_SYSTEMLIB_H_
#define _SQSTD_SYSTEMLIB_H_
#ifdef __cplusplus
extern "C" {
#endif
SQUIRREL_API SQInteger sqstd_register_systemlib(HSQUIRRELVM v);
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /* _SQSTD_SYSTEMLIB_H_ */

411
include/squirrel.h Normal file
View File

@ -0,0 +1,411 @@
/*
Copyright (c) 2003-2022 Alberto Demichelis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _SQUIRREL_H_
#define _SQUIRREL_H_
#ifdef _SQ_CONFIG_INCLUDE
#include _SQ_CONFIG_INCLUDE
#endif
#ifdef __cplusplus
extern "C" {
#endif
#ifndef SQUIRREL_API
#define SQUIRREL_API extern
#endif
#if (defined(_WIN64) || defined(_LP64))
#ifndef _SQ64
#define _SQ64
#endif
#endif
#define SQTrue (1)
#define SQFalse (0)
struct SQVM;
struct SQTable;
struct SQArray;
struct SQString;
struct SQClosure;
struct SQGenerator;
struct SQNativeClosure;
struct SQUserData;
struct SQFunctionProto;
struct SQRefCounted;
struct SQClass;
struct SQInstance;
struct SQDelegable;
struct SQOuter;
#ifdef _UNICODE
#define SQUNICODE
#endif
#include "sqconfig.h"
#define SQUIRREL_VERSION _SC("Squirrel 3.2 stable")
#define SQUIRREL_COPYRIGHT _SC("Copyright (C) 2003-2022 Alberto Demichelis")
#define SQUIRREL_AUTHOR _SC("Alberto Demichelis")
#define SQUIRREL_VERSION_NUMBER 320
#define SQ_VMSTATE_IDLE 0
#define SQ_VMSTATE_RUNNING 1
#define SQ_VMSTATE_SUSPENDED 2
#define SQUIRREL_EOB 0
#define SQ_BYTECODE_STREAM_TAG 0xFAFA
#define SQOBJECT_REF_COUNTED 0x08000000
#define SQOBJECT_NUMERIC 0x04000000
#define SQOBJECT_DELEGABLE 0x02000000
#define SQOBJECT_CANBEFALSE 0x01000000
#define SQ_MATCHTYPEMASKSTRING (-99999)
#define _RT_MASK 0x00FFFFFF
#define _RAW_TYPE(type) (type&_RT_MASK)
#define _RT_NULL 0x00000001
#define _RT_INTEGER 0x00000002
#define _RT_FLOAT 0x00000004
#define _RT_BOOL 0x00000008
#define _RT_STRING 0x00000010
#define _RT_TABLE 0x00000020
#define _RT_ARRAY 0x00000040
#define _RT_USERDATA 0x00000080
#define _RT_CLOSURE 0x00000100
#define _RT_NATIVECLOSURE 0x00000200
#define _RT_GENERATOR 0x00000400
#define _RT_USERPOINTER 0x00000800
#define _RT_THREAD 0x00001000
#define _RT_FUNCPROTO 0x00002000
#define _RT_CLASS 0x00004000
#define _RT_INSTANCE 0x00008000
#define _RT_WEAKREF 0x00010000
#define _RT_OUTER 0x00020000
typedef enum tagSQObjectType{
OT_NULL = (_RT_NULL|SQOBJECT_CANBEFALSE),
OT_INTEGER = (_RT_INTEGER|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
OT_FLOAT = (_RT_FLOAT|SQOBJECT_NUMERIC|SQOBJECT_CANBEFALSE),
OT_BOOL = (_RT_BOOL|SQOBJECT_CANBEFALSE),
OT_STRING = (_RT_STRING|SQOBJECT_REF_COUNTED),
OT_TABLE = (_RT_TABLE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
OT_ARRAY = (_RT_ARRAY|SQOBJECT_REF_COUNTED),
OT_USERDATA = (_RT_USERDATA|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
OT_CLOSURE = (_RT_CLOSURE|SQOBJECT_REF_COUNTED),
OT_NATIVECLOSURE = (_RT_NATIVECLOSURE|SQOBJECT_REF_COUNTED),
OT_GENERATOR = (_RT_GENERATOR|SQOBJECT_REF_COUNTED),
OT_USERPOINTER = _RT_USERPOINTER,
OT_THREAD = (_RT_THREAD|SQOBJECT_REF_COUNTED) ,
OT_FUNCPROTO = (_RT_FUNCPROTO|SQOBJECT_REF_COUNTED), //internal usage only
OT_CLASS = (_RT_CLASS|SQOBJECT_REF_COUNTED),
OT_INSTANCE = (_RT_INSTANCE|SQOBJECT_REF_COUNTED|SQOBJECT_DELEGABLE),
OT_WEAKREF = (_RT_WEAKREF|SQOBJECT_REF_COUNTED),
OT_OUTER = (_RT_OUTER|SQOBJECT_REF_COUNTED) //internal usage only
}SQObjectType;
#define ISREFCOUNTED(t) (t&SQOBJECT_REF_COUNTED)
typedef union tagSQObjectValue
{
struct SQTable *pTable;
struct SQArray *pArray;
struct SQClosure *pClosure;
struct SQOuter *pOuter;
struct SQGenerator *pGenerator;
struct SQNativeClosure *pNativeClosure;
struct SQString *pString;
struct SQUserData *pUserData;
SQInteger nInteger;
SQFloat fFloat;
SQUserPointer pUserPointer;
struct SQFunctionProto *pFunctionProto;
struct SQRefCounted *pRefCounted;
struct SQDelegable *pDelegable;
struct SQVM *pThread;
struct SQClass *pClass;
struct SQInstance *pInstance;
struct SQWeakRef *pWeakRef;
SQRawObjectVal raw;
}SQObjectValue;
typedef struct tagSQObject
{
SQObjectType _type;
SQObjectValue _unVal;
}SQObject;
typedef struct tagSQMemberHandle{
SQBool _static;
SQInteger _index;
}SQMemberHandle;
typedef struct tagSQStackInfos{
const SQChar* funcname;
const SQChar* source;
SQInteger line;
}SQStackInfos;
typedef struct SQVM* HSQUIRRELVM;
typedef SQObject HSQOBJECT;
typedef SQMemberHandle HSQMEMBERHANDLE;
typedef SQInteger (*SQFUNCTION)(HSQUIRRELVM);
typedef SQInteger (*SQRELEASEHOOK)(SQUserPointer,SQInteger size);
typedef void (*SQCOMPILERERROR)(HSQUIRRELVM,const SQChar * /*desc*/,const SQChar * /*source*/,SQInteger /*line*/,SQInteger /*column*/);
typedef void (*SQPRINTFUNCTION)(HSQUIRRELVM,const SQChar * ,...);
typedef void (*SQDEBUGHOOK)(HSQUIRRELVM /*v*/, SQInteger /*type*/, const SQChar * /*sourcename*/, SQInteger /*line*/, const SQChar * /*funcname*/);
typedef SQInteger (*SQWRITEFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQREADFUNC)(SQUserPointer,SQUserPointer,SQInteger);
typedef SQInteger (*SQLEXREADFUNC)(SQUserPointer);
typedef struct tagSQRegFunction{
const SQChar *name;
SQFUNCTION f;
SQInteger nparamscheck;
const SQChar *typemask;
}SQRegFunction;
typedef struct tagSQFunctionInfo {
SQUserPointer funcid;
const SQChar *name;
const SQChar *source;
SQInteger line;
}SQFunctionInfo;
/*vm*/
SQUIRREL_API HSQUIRRELVM sq_open(SQInteger initialstacksize);
SQUIRREL_API HSQUIRRELVM sq_newthread(HSQUIRRELVM friendvm, SQInteger initialstacksize);
SQUIRREL_API void sq_seterrorhandler(HSQUIRRELVM v);
SQUIRREL_API void sq_close(HSQUIRRELVM v);
SQUIRREL_API void sq_setforeignptr(HSQUIRRELVM v,SQUserPointer p);
SQUIRREL_API SQUserPointer sq_getforeignptr(HSQUIRRELVM v);
SQUIRREL_API void sq_setsharedforeignptr(HSQUIRRELVM v,SQUserPointer p);
SQUIRREL_API SQUserPointer sq_getsharedforeignptr(HSQUIRRELVM v);
SQUIRREL_API void sq_setvmreleasehook(HSQUIRRELVM v,SQRELEASEHOOK hook);
SQUIRREL_API SQRELEASEHOOK sq_getvmreleasehook(HSQUIRRELVM v);
SQUIRREL_API void sq_setsharedreleasehook(HSQUIRRELVM v,SQRELEASEHOOK hook);
SQUIRREL_API SQRELEASEHOOK sq_getsharedreleasehook(HSQUIRRELVM v);
SQUIRREL_API void sq_setprintfunc(HSQUIRRELVM v, SQPRINTFUNCTION printfunc,SQPRINTFUNCTION errfunc);
SQUIRREL_API SQPRINTFUNCTION sq_getprintfunc(HSQUIRRELVM v);
SQUIRREL_API SQPRINTFUNCTION sq_geterrorfunc(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_suspendvm(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_wakeupvm(HSQUIRRELVM v,SQBool resumedret,SQBool retval,SQBool raiseerror,SQBool throwerror);
SQUIRREL_API SQInteger sq_getvmstate(HSQUIRRELVM v);
SQUIRREL_API SQInteger sq_getversion();
/*compiler*/
SQUIRREL_API SQRESULT sq_compile(HSQUIRRELVM v,SQLEXREADFUNC read,SQUserPointer p,const SQChar *sourcename,SQBool raiseerror);
SQUIRREL_API SQRESULT sq_compilebuffer(HSQUIRRELVM v,const SQChar *s,SQInteger size,const SQChar *sourcename,SQBool raiseerror);
SQUIRREL_API void sq_enabledebuginfo(HSQUIRRELVM v, SQBool enable);
SQUIRREL_API void sq_notifyallexceptions(HSQUIRRELVM v, SQBool enable);
SQUIRREL_API void sq_setcompilererrorhandler(HSQUIRRELVM v,SQCOMPILERERROR f);
/*stack operations*/
SQUIRREL_API void sq_push(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API void sq_pop(HSQUIRRELVM v,SQInteger nelemstopop);
SQUIRREL_API void sq_poptop(HSQUIRRELVM v);
SQUIRREL_API void sq_remove(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQInteger sq_gettop(HSQUIRRELVM v);
SQUIRREL_API void sq_settop(HSQUIRRELVM v,SQInteger newtop);
SQUIRREL_API SQRESULT sq_reservestack(HSQUIRRELVM v,SQInteger nsize);
SQUIRREL_API SQInteger sq_cmp(HSQUIRRELVM v);
SQUIRREL_API void sq_move(HSQUIRRELVM dest,HSQUIRRELVM src,SQInteger idx);
/*object creation handling*/
SQUIRREL_API SQUserPointer sq_newuserdata(HSQUIRRELVM v,SQUnsignedInteger size);
SQUIRREL_API void sq_newtable(HSQUIRRELVM v);
SQUIRREL_API void sq_newtableex(HSQUIRRELVM v,SQInteger initialcapacity);
SQUIRREL_API void sq_newarray(HSQUIRRELVM v,SQInteger size);
SQUIRREL_API void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
SQUIRREL_API SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
SQUIRREL_API SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_setclosureroot(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getclosureroot(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
SQUIRREL_API void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
SQUIRREL_API void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
SQUIRREL_API void sq_pushbool(HSQUIRRELVM v,SQBool b);
SQUIRREL_API void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
SQUIRREL_API void sq_pushnull(HSQUIRRELVM v);
SQUIRREL_API void sq_pushthread(HSQUIRRELVM v, HSQUIRRELVM thread);
SQUIRREL_API SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_typeof(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQInteger sq_getsize(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQHash sq_gethash(HSQUIRRELVM v, SQInteger idx);
SQUIRREL_API SQRESULT sq_getbase(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQBool sq_instanceof(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_tostring(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API void sq_tobool(HSQUIRRELVM v, SQInteger idx, SQBool *b);
SQUIRREL_API SQRESULT sq_getstringandsize(HSQUIRRELVM v,SQInteger idx,const SQChar **c,SQInteger *size);
SQUIRREL_API SQRESULT sq_getstring(HSQUIRRELVM v,SQInteger idx,const SQChar **c);
SQUIRREL_API SQRESULT sq_getinteger(HSQUIRRELVM v,SQInteger idx,SQInteger *i);
SQUIRREL_API SQRESULT sq_getfloat(HSQUIRRELVM v,SQInteger idx,SQFloat *f);
SQUIRREL_API SQRESULT sq_getbool(HSQUIRRELVM v,SQInteger idx,SQBool *b);
SQUIRREL_API SQRESULT sq_getthread(HSQUIRRELVM v,SQInteger idx,HSQUIRRELVM *thread);
SQUIRREL_API SQRESULT sq_getuserpointer(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p);
SQUIRREL_API SQRESULT sq_getuserdata(HSQUIRRELVM v,SQInteger idx,SQUserPointer *p,SQUserPointer *typetag);
SQUIRREL_API SQRESULT sq_settypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer typetag);
SQUIRREL_API SQRESULT sq_gettypetag(HSQUIRRELVM v,SQInteger idx,SQUserPointer *typetag);
SQUIRREL_API void sq_setreleasehook(HSQUIRRELVM v,SQInteger idx,SQRELEASEHOOK hook);
SQUIRREL_API SQRELEASEHOOK sq_getreleasehook(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQChar *sq_getscratchpad(HSQUIRRELVM v,SQInteger minsize);
SQUIRREL_API SQRESULT sq_getfunctioninfo(HSQUIRRELVM v,SQInteger level,SQFunctionInfo *fi);
SQUIRREL_API SQRESULT sq_getclosureinfo(HSQUIRRELVM v,SQInteger idx,SQInteger *nparams,SQInteger *nfreevars);
SQUIRREL_API SQRESULT sq_getclosurename(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_setnativeclosurename(HSQUIRRELVM v,SQInteger idx,const SQChar *name);
SQUIRREL_API SQRESULT sq_setinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer p);
SQUIRREL_API SQRESULT sq_getinstanceup(HSQUIRRELVM v, SQInteger idx, SQUserPointer *p,SQUserPointer typetag,SQBool throwerror);
SQUIRREL_API SQRESULT sq_setclassudsize(HSQUIRRELVM v, SQInteger idx, SQInteger udsize);
SQUIRREL_API SQRESULT sq_newclass(HSQUIRRELVM v,SQBool hasbase);
SQUIRREL_API SQRESULT sq_createinstance(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_setattributes(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getattributes(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getclass(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API void sq_weakref(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getdefaultdelegate(HSQUIRRELVM v,SQObjectType t);
SQUIRREL_API SQRESULT sq_getmemberhandle(HSQUIRRELVM v,SQInteger idx,HSQMEMBERHANDLE *handle);
SQUIRREL_API SQRESULT sq_getbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
SQUIRREL_API SQRESULT sq_setbyhandle(HSQUIRRELVM v,SQInteger idx,const HSQMEMBERHANDLE *handle);
/*object manipulation*/
SQUIRREL_API void sq_pushroottable(HSQUIRRELVM v);
SQUIRREL_API void sq_pushregistrytable(HSQUIRRELVM v);
SQUIRREL_API void sq_pushconsttable(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_setroottable(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_setconsttable(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_newslot(HSQUIRRELVM v, SQInteger idx, SQBool bstatic);
SQUIRREL_API SQRESULT sq_deleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQUIRREL_API SQRESULT sq_set(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_get(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_rawget(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_rawset(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_rawdeleteslot(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQUIRREL_API SQRESULT sq_newmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
SQUIRREL_API SQRESULT sq_rawnewmember(HSQUIRRELVM v,SQInteger idx,SQBool bstatic);
SQUIRREL_API SQRESULT sq_arrayappend(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_arraypop(HSQUIRRELVM v,SQInteger idx,SQBool pushval);
SQUIRREL_API SQRESULT sq_arrayresize(HSQUIRRELVM v,SQInteger idx,SQInteger newsize);
SQUIRREL_API SQRESULT sq_arrayreverse(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_arrayremove(HSQUIRRELVM v,SQInteger idx,SQInteger itemidx);
SQUIRREL_API SQRESULT sq_arrayinsert(HSQUIRRELVM v,SQInteger idx,SQInteger destpos);
SQUIRREL_API SQRESULT sq_setdelegate(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getdelegate(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_clone(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_setfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQUIRREL_API SQRESULT sq_next(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_getweakrefval(HSQUIRRELVM v,SQInteger idx);
SQUIRREL_API SQRESULT sq_clear(HSQUIRRELVM v,SQInteger idx);
/*calls*/
SQUIRREL_API SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror);
SQUIRREL_API SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
SQUIRREL_API const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
SQUIRREL_API SQRESULT sq_getcallee(HSQUIRRELVM v);
SQUIRREL_API const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
SQUIRREL_API SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err);
SQUIRREL_API SQRESULT sq_throwobject(HSQUIRRELVM v);
SQUIRREL_API void sq_reseterror(HSQUIRRELVM v);
SQUIRREL_API void sq_getlasterror(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_tailcall(HSQUIRRELVM v, SQInteger nparams);
/*raw object handling*/
SQUIRREL_API SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
SQUIRREL_API void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
SQUIRREL_API void sq_addref(HSQUIRRELVM v,HSQOBJECT *po);
SQUIRREL_API SQBool sq_release(HSQUIRRELVM v,HSQOBJECT *po);
SQUIRREL_API SQUnsignedInteger sq_getrefcount(HSQUIRRELVM v,HSQOBJECT *po);
SQUIRREL_API void sq_resetobject(HSQOBJECT *po);
SQUIRREL_API const SQChar *sq_objtostring(const HSQOBJECT *o);
SQUIRREL_API SQBool sq_objtobool(const HSQOBJECT *o);
SQUIRREL_API SQInteger sq_objtointeger(const HSQOBJECT *o);
SQUIRREL_API SQFloat sq_objtofloat(const HSQOBJECT *o);
SQUIRREL_API SQUserPointer sq_objtouserpointer(const HSQOBJECT *o);
SQUIRREL_API SQRESULT sq_getobjtypetag(const HSQOBJECT *o,SQUserPointer * typetag);
SQUIRREL_API SQUnsignedInteger sq_getvmrefcount(HSQUIRRELVM v, const HSQOBJECT *po);
/*GC*/
SQUIRREL_API SQInteger sq_collectgarbage(HSQUIRRELVM v);
SQUIRREL_API SQRESULT sq_resurrectunreachable(HSQUIRRELVM v);
/*serialization*/
SQUIRREL_API SQRESULT sq_writeclosure(HSQUIRRELVM vm,SQWRITEFUNC writef,SQUserPointer up);
SQUIRREL_API SQRESULT sq_readclosure(HSQUIRRELVM vm,SQREADFUNC readf,SQUserPointer up);
/*mem allocation*/
SQUIRREL_API void *sq_malloc(SQUnsignedInteger size);
SQUIRREL_API void *sq_realloc(void* p,SQUnsignedInteger oldsize,SQUnsignedInteger newsize);
SQUIRREL_API void sq_free(void *p,SQUnsignedInteger size);
/*debug*/
SQUIRREL_API SQRESULT sq_stackinfos(HSQUIRRELVM v,SQInteger level,SQStackInfos *si);
SQUIRREL_API void sq_setdebughook(HSQUIRRELVM v);
SQUIRREL_API void sq_setnativedebughook(HSQUIRRELVM v,SQDEBUGHOOK hook);
/*UTILITY MACRO*/
#define sq_isnumeric(o) ((o)._type&SQOBJECT_NUMERIC)
#define sq_istable(o) ((o)._type==OT_TABLE)
#define sq_isarray(o) ((o)._type==OT_ARRAY)
#define sq_isfunction(o) ((o)._type==OT_FUNCPROTO)
#define sq_isclosure(o) ((o)._type==OT_CLOSURE)
#define sq_isgenerator(o) ((o)._type==OT_GENERATOR)
#define sq_isnativeclosure(o) ((o)._type==OT_NATIVECLOSURE)
#define sq_isstring(o) ((o)._type==OT_STRING)
#define sq_isinteger(o) ((o)._type==OT_INTEGER)
#define sq_isfloat(o) ((o)._type==OT_FLOAT)
#define sq_isuserpointer(o) ((o)._type==OT_USERPOINTER)
#define sq_isuserdata(o) ((o)._type==OT_USERDATA)
#define sq_isthread(o) ((o)._type==OT_THREAD)
#define sq_isnull(o) ((o)._type==OT_NULL)
#define sq_isclass(o) ((o)._type==OT_CLASS)
#define sq_isinstance(o) ((o)._type==OT_INSTANCE)
#define sq_isbool(o) ((o)._type==OT_BOOL)
#define sq_isweakref(o) ((o)._type==OT_WEAKREF)
#define sq_type(o) ((o)._type)
/* deprecated */
#define sq_createslot(v,n) sq_newslot(v,n,SQFalse)
#define SQ_OK (0)
#define SQ_ERROR (-1)
#define SQ_FAILED(res) (res<0)
#define SQ_SUCCEEDED(res) (res>=0)
#ifdef __GNUC__
# define SQ_UNUSED_ARG(x) x __attribute__((__unused__))
#else
# define SQ_UNUSED_ARG(x) x
#endif
#ifdef __cplusplus
} /*extern "C"*/
#endif
#endif /*_SQUIRREL_H_*/

BIN
lib/irrKlang.lib Normal file

Binary file not shown.

BIN
lib/kiwano-imgui.lib Normal file

Binary file not shown.

BIN
lib/sqstdlib.lib Normal file

Binary file not shown.

BIN
lib/squirrel.lib Normal file

Binary file not shown.

36
main.cpp Normal file
View File

@ -0,0 +1,36 @@
#include "SquirrelClassEx.h"
#include "GameState.h"
//Èë¿Ú²ÎÊý
/*
1. Token
2. GameMode
*/
SquirrelClassEx* TObject;
NPK_M* npk;
#include <atlimage.h>
int main(int argc, char** argv)
{
if (argc < 2) {
}
npk = new NPK_M();
npk->init();
SquirrelClassEx* V = new SquirrelClassEx();
V->Init();
GameState* Game = new GameState();
Game->Run();
return 0;
}

4
packages.config Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="zlib-msvc14-x64" version="1.2.11.7795" targetFramework="native" />
</packages>

Binary file not shown.

368
packages/zlib-msvc14-x64.1.2.11.7795/FAQ vendored Normal file
View File

@ -0,0 +1,368 @@
Frequently Asked Questions about zlib
If your question is not there, please check the zlib home page
http://zlib.net/ which may have more recent information.
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant?
Yes. zlib doesn't handle dates.
2. Where can I get a Windows DLL version?
The zlib sources can be compiled without change to produce a DLL. See the
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
precompiled DLL are found in the zlib web site at http://zlib.net/ .
3. Where can I get a Visual Basic interface to zlib?
See
* http://marknelson.us/1997/01/01/zlib-engine/
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
Make sure that before the call of compress(), the length of the compressed
buffer is equal to the available size of the compressed buffer and not
zero. For Visual Basic, check that this parameter is passed by reference
("as any"), not by value ("as long").
5. deflate() or inflate() returns Z_BUF_ERROR.
Before making the call, make sure that avail_in and avail_out are not zero.
When setting the parameter flush equal to Z_FINISH, also make sure that
avail_out is big enough to allow processing all pending input. Note that a
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
made with more input or output space. A Z_BUF_ERROR may in fact be
unavoidable depending on how the functions are used, since it is not
possible to tell whether or not there is more output pending when
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
heavily annotated example.
6. Where's the zlib documentation (man pages, etc.)?
It's in zlib.h . Examples of zlib usage are in the files test/example.c
and test/minigzip.c, with more in examples/ .
7. Why don't you use GNU autoconf or libtool or ...?
Because we would like to keep zlib as a very small and simple package.
zlib is rather portable and doesn't need much configuration.
8. I found a bug in zlib.
Most of the time, such problems are due to an incorrect usage of zlib.
Please try to reproduce the problem with a small program and send the
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
data files without prior agreement.
9. Why do I get "undefined reference to gzputc"?
If "make test" produces something like
example.o(.text+0x154): undefined reference to `gzputc'
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
/usr/X11R6/lib. Remove any old versions, then do "make install".
10. I need a Delphi interface to zlib.
See the contrib/delphi directory in the zlib distribution.
11. Can zlib handle .zip archives?
Not by itself, no. See the directory contrib/minizip in the zlib
distribution.
12. Can zlib handle .Z files?
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
the code of uncompress on your own.
13. How can I make a Unix shared library?
By default a shared (and a static) library is built for Unix. So:
make distclean
./configure
make
14. How do I install a shared zlib library on Unix?
After the above, then:
make install
However, many flavors of Unix come with a shared zlib already installed.
Before going to the trouble of compiling a shared version of zlib and
trying to install it, you may want to check if it's already there! If you
can #include <zlib.h>, it's there. The -lz option will probably link to
it. You can check the version at the top of zlib.h or with the
ZLIB_VERSION symbol defined in zlib.h .
15. I have a question about OttoPDF.
We are not the authors of OttoPDF. The real author is on the OttoPDF web
site: Joel Hainley, jhainley@myndkryme.com.
16. Can zlib decode Flate data in an Adobe PDF file?
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
http://sourceforge.net/projects/acroformtool/ .
17. Why am I getting this "register_frame_info not found" error on Solaris?
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
generates an error such as:
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
symbol __register_frame_info: referenced symbol not found
The symbol __register_frame_info is not part of zlib, it is generated by
the C compiler (cc or gcc). You must recompile applications using zlib
which have this problem. This problem is specific to Solaris. See
http://www.sunfreeware.com for Solaris versions of zlib and applications
using zlib.
18. Why does gzip give an error on a file I make with compress/deflate?
The compress and deflate functions produce data in the zlib format, which
is different and incompatible with the gzip format. The gz* functions in
zlib on the other hand use the gzip format. Both the zlib and gzip formats
use the same compressed data format internally, but have different headers
and trailers around the compressed data.
19. Ok, so why are there two different formats?
The gzip format was designed to retain the directory information about a
single file, such as the name and last modification date. The zlib format
on the other hand was designed for in-memory and communication channel
applications, and has a much more compact header and trailer and uses a
faster integrity check than gzip.
20. Well that's nice, but how do I make a gzip file in memory?
You can request that deflate write the gzip format instead of the zlib
format using deflateInit2(). You can also request that inflate decode the
gzip format using inflateInit2(). Read zlib.h for more details.
21. Is zlib thread-safe?
Yes. However any library routines that zlib uses and any application-
provided memory allocation routines must also be thread-safe. zlib's gz*
functions use stdio library routines, and most of zlib's functions use the
library memory allocation routines by default. zlib's *Init* functions
allow for the application to provide custom memory allocation routines.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
22. Can I use zlib in my commercial application?
Yes. Please read the license in zlib.h.
23. Is zlib under the GNU license?
No. Please read the license in zlib.h.
24. The license says that altered source versions must be "plainly marked". So
what exactly do I need to do to meet that requirement?
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
particular, the final version number needs to be changed to "f", and an
identification string should be appended to ZLIB_VERSION. Version numbers
x.x.x.f are reserved for modifications to zlib by others than the zlib
maintainers. For example, if the version of the base zlib you are altering
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
update the version strings in deflate.c and inftrees.c.
For altered source distributions, you should also note the origin and
nature of the changes in zlib.h, as well as in ChangeLog and README, along
with the dates of the alterations. The origin should include at least your
name (or your company's name), and an email address to contact for help or
issues with the library.
Note that distributing a compiled zlib library along with zlib.h and
zconf.h is also a source distribution, and so you should change
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
in zlib.h as you would for a full source distribution.
25. Will zlib work on a big-endian or little-endian architecture, and can I
exchange compressed data between them?
Yes and yes.
26. Will zlib work on a 64-bit machine?
Yes. It has been tested on 64-bit machines, and has no dependence on any
data types being limited to 32-bits in length. If you have any
difficulties, please provide a complete problem report to zlib@gzip.org
27. Will zlib decompress data from the PKWare Data Compression Library?
No. The PKWare DCL uses a completely different compressed data format than
does PKZIP and zlib. However, you can look in zlib's contrib/blast
directory for a possible solution to your problem.
28. Can I access data randomly in a compressed stream?
No, not without some preparation. If when compressing you periodically use
Z_FULL_FLUSH, carefully write all the pending data at those points, and
keep an index of those locations, then you can start decompression at those
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
can significantly degrade compression. Alternatively, you can scan a
deflate stream once to generate an index, and then use that index for
random access. See examples/zran.c .
29. Does zlib work on MVS, OS/390, CICS, etc.?
It has in the past, but we have not heard of any recent evidence. There
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
If you know of recent, successful applications of zlib on these operating
systems, please let us know. Thanks.
30. Is there some simpler, easier to read version of inflate I can look at to
understand the deflate format?
First off, you should read RFC 1951. Second, yes. Look in zlib's
contrib/puff directory.
31. Does zlib infringe on any patents?
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
http://www.gzip.org/#faq11
32. Can zlib work with greater than 4 GB of data?
Yes. inflate() and deflate() will process any amount of data correctly.
Each call of inflate() or deflate() is limited to input and output chunks
of the maximum value that can be stored in the compiler's "unsigned int"
type, but there is no limit to the number of chunks. Note however that the
strm.total_in and strm_total_out counters may be limited to 4 GB. These
counters are provided as a convenience and are not used internally by
inflate() or deflate(). The application can easily set up its own counters
updated after each call of inflate() or deflate() to count beyond 4 GB.
compress() and uncompress() may be limited to 4 GB, since they operate in a
single call. gzseek() and gztell() may be limited to 4 GB depending on how
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
The word "may" appears several times above since there is a 4 GB limit only
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
64 bits, then the limit is 16 exabytes.
33. Does zlib have any security vulnerabilities?
The only one that we are aware of is potentially in gzprintf(). If zlib is
compiled to use sprintf() or vsprintf(), then there is no protection
against a buffer overflow of an 8K string space (or other value as set by
gzbuffer()), other than the caller of gzprintf() assuring that the output
will not exceed 8K. On the other hand, if zlib is compiled to use
snprintf() or vsnprintf(), which should normally be the case, then there is
no vulnerability. The ./configure script will display warnings if an
insecure variation of sprintf() will be used by gzprintf(). Also the
zlibCompileFlags() function will return information on what variant of
sprintf() is used by gzprintf().
If you don't have snprintf() or vsnprintf() and would like one, you can
find a portable implementation here:
http://www.ijs.si/software/snprintf/
Note that you should be using the most recent version of zlib. Versions
1.1.3 and before were subject to a double-free vulnerability, and versions
1.2.1 and 1.2.2 were subject to an access exception when decompressing
invalid compressed data.
34. Is there a Java version of zlib?
Probably what you want is to use zlib in Java. zlib is already included
as part of the Java SDK in the java.util.zip package. If you really want
a version of zlib written in the Java language, look on the zlib home
page for links: http://zlib.net/ .
35. I get this or that compiler or source-code scanner warning when I crank it
up to maximally-pedantic. Can't you guys write proper code?
Many years ago, we gave up attempting to avoid warnings on every compiler
in the universe. It just got to be a waste of time, and some compilers
were downright silly as well as contradicted each other. So now, we simply
make sure that the code always works.
36. Valgrind (or some similar memory access checker) says that deflate is
performing a conditional jump that depends on an uninitialized value.
Isn't that a bug?
No. That is intentional for performance reasons, and the output of deflate
is not affected. This only started showing up recently since zlib 1.2.x
uses malloc() by default for allocations, whereas earlier versions used
calloc(), which zeros out the allocated memory. Even though the code was
correct, versions 1.2.4 and later was changed to not stimulate these
checkers.
37. Will zlib read the (insert any ancient or arcane format here) compressed
data format?
Probably not. Look in the comp.compression FAQ for pointers to various
formats and associated software.
38. How can I encrypt/decrypt zip files with zlib?
zlib doesn't support encryption. The original PKZIP encryption is very
weak and can be broken with freely available programs. To get strong
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
compression. For PKZIP compatible "encryption", look at
http://www.info-zip.org/
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
"gzip" is the gzip format, and "deflate" is the zlib format. They should
probably have called the second one "zlib" instead to avoid confusion with
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
correctly points to the zlib specification in RFC 1950 for the "deflate"
transfer encoding, there have been reports of servers and browsers that
incorrectly produce or expect raw deflate data per the deflate
specification in RFC 1951, most notably Microsoft. So even though the
"deflate" transfer encoding using the zlib format would be the more
efficient approach (and in fact exactly what the zlib format was designed
for), using the "gzip" transfer encoding is probably more reliable due to
an unfortunate choice of name on the part of the HTTP 1.1 authors.
Bottom line: use the gzip format for HTTP 1.1 encoding.
40. Does zlib support the new "Deflate64" format introduced by PKWare?
No. PKWare has apparently decided to keep that format proprietary, since
they have not documented it as they have previous compression formats. In
any case, the compression improvements are so modest compared to other more
modern approaches, that it's not worth the effort to implement.
41. I'm having a problem with the zip functions in zlib, can you help?
There are no zip functions in zlib. You are probably using minizip by
Giles Vollant, which is found in the contrib directory of zlib. It is not
part of zlib. In fact none of the stuff in contrib is part of zlib. The
files in there are not supported by the zlib authors. You need to contact
the authors of the respective contribution for help.
42. The match.asm code in contrib is under the GNU General Public License.
Since it's part of zlib, doesn't that mean that all of zlib falls under the
GNU GPL?
No. The files in contrib are not part of zlib. They were contributed by
other authors and are provided as a convenience to the user within the zlib
distribution. Each item in contrib has its own license.
43. Is zlib subject to export controls? What is its ECCN?
zlib is not subject to export controls, and so is classified as EAR99.
44. Can you please sign these lengthy legal documents and fax them back to us
so that we can use your software in our product?
No. Go away. Shoo.

View File

@ -0,0 +1,115 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.2.11 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
rfc1952 (gzip format).
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
of the library is given in the file test/example.c which also tests that
the library is working correctly. Another example is given in the file
test/minigzip.c. The compression library itself is composed of all source
files in the root directory.
To compile all files and run the test program, follow the instructions given at
the top of Makefile.in. In short "./configure; make test", and if that goes
well, "make install" should work for most flavors of Unix. For Windows, use
one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use
make_vms.com.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
http://zlib.net/ . Before reporting a problem, please check this site to
verify that you have the latest version of zlib; otherwise get the latest
version and check whether the problem still exists or not.
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
http://marknelson.us/1997/01/01/zlib-engine/ .
The changes made in version 1.2.11 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
zlib is available in Java using the java.util.zip package, documented at
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
at CPAN (Comprehensive Perl Archive Network) sites, including
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
http://docs.python.org/library/zlib.html .
zlib is built into tcl: http://wiki.tcl.tk/4610 .
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
contrib/minizip directory of zlib.
Notes for some targets:
- For Windows DLL versions, please see win32/DLL_FAQ.txt
- For 64-bit Irix, deflate.c must be compiled without any optimization. With
-O, one libpng test fails. The test works in 32 bit mode (with the -n32
compiler flag). The compiler bug has been reported to SGI.
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
- gzdopen is not supported on RISCOS or BEOS.
- For PalmOs, see http://palmzlib.sourceforge.net/
Acknowledgments:
The deflate format used by zlib was defined by Phil Katz. The deflate and
zlib specifications were written by L. Peter Deutsch. Thanks to all the
people who reported problems and suggested various improvements in zlib; they
are too numerous to cite here.
Copyright notice:
(C) 1995-2017 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
If you use the zlib library in a product, we would appreciate *not* receiving
lengthy legal documents to sign. The sources are provided for free but without
warranty of any kind. The library has been entirely written by Jean-loup
Gailly and Mark Adler; it does not include third-party code.
If you redistribute modified sources, we would appreciate that you include in
the file ChangeLog history information documenting your changes. Please read
the FAQ for more information on the distribution of modified source versions.

View File

@ -0,0 +1,536 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
#ifndef ZCONF_H
#define ZCONF_H
/* #undef Z_PREFIX */
/* #undef Z_HAVE_UNISTD_H */
/*
* If you *really* need a unique prefix for all types and library functions,
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
* Even better than compiling with -DZ_PREFIX would be to use configure to set
* this permanently in zconf.h using "./configure --zprefix".
*/
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols and init macros */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
# define _tr_flush_bits z__tr_flush_bits
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
# define _tr_tally z__tr_tally
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
# define adler32_z z_adler32_z
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
# define crc32_z z_crc32_z
# define deflate z_deflate
# define deflateBound z_deflateBound
# define deflateCopy z_deflateCopy
# define deflateEnd z_deflateEnd
# define deflateGetDictionary z_deflateGetDictionary
# define deflateInit z_deflateInit
# define deflateInit2 z_deflateInit2
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset
# define deflateResetKeep z_deflateResetKeep
# define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table
# ifndef Z_SOLO
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzfread z_gzfread
# define gzfwrite z_gzfwrite
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# ifdef _WIN32
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzvprintf z_gzvprintf
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
# define inflateBackInit z_inflateBackInit
# define inflateBackInit_ z_inflateBackInit_
# define inflateCodesUsed z_inflateCodesUsed
# define inflateCopy z_inflateCopy
# define inflateEnd z_inflateEnd
# define inflateGetDictionary z_inflateGetDictionary
# define inflateGetHeader z_inflateGetHeader
# define inflateInit z_inflateInit
# define inflateInit2 z_inflateInit2
# define inflateInit2_ z_inflateInit2_
# define inflateInit_ z_inflateInit_
# define inflateMark z_inflateMark
# define inflatePrime z_inflatePrime
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateResetKeep z_inflateResetKeep
# define inflateSetDictionary z_inflateSetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
# define inflateValidate z_inflateValidate
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# ifndef Z_SOLO
# define uncompress z_uncompress
# define uncompress2 z_uncompress2
# endif
# define zError z_zError
# ifndef Z_SOLO
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
/* all zlib typedefs in zlib.h and zconf.h */
# define Byte z_Byte
# define Bytef z_Bytef
# define alloc_func z_alloc_func
# define charf z_charf
# define free_func z_free_func
# ifndef Z_SOLO
# define gzFile z_gzFile
# endif
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func
# define intf z_intf
# define out_func z_out_func
# define uInt z_uInt
# define uIntf z_uIntf
# define uLong z_uLong
# define uLongf z_uLongf
# define voidp z_voidp
# define voidpc z_voidpc
# define voidpf z_voidpf
/* all zlib structs in zlib.h and zconf.h */
# define gz_header_s z_gz_header_s
# define internal_state z_internal_state
#endif
#if defined(__MSDOS__) && !defined(MSDOS)
# define MSDOS
#endif
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
# define OS2
#endif
#if defined(_WINDOWS) && !defined(WINDOWS)
# define WINDOWS
#endif
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
# ifndef WIN32
# define WIN32
# endif
#endif
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
# ifndef SYS16BIT
# define SYS16BIT
# endif
# endif
#endif
/*
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
* than 64k bytes at a time (needed on systems with 16-bit int).
*/
#ifdef SYS16BIT
# define MAXSEG_64K
#endif
#ifdef MSDOS
# define UNALIGNED_OK
#endif
#ifdef __STDC_VERSION__
# ifndef STDC
# define STDC
# endif
# if __STDC_VERSION__ >= 199901L
# ifndef STDC99
# define STDC99
# endif
# endif
#endif
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
# define STDC
#endif
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
# define STDC
#endif
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
# define STDC
#endif
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
# define STDC
#endif
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
# define STDC
#endif
#ifndef STDC
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
# define const /* note: need a more gentle solution here */
# endif
#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
#else
# define z_const
#endif
#ifdef Z_SOLO
typedef unsigned long z_size_t;
#else
# define z_longlong long long
# if defined(NO_SIZE_T)
typedef unsigned NO_SIZE_T z_size_t;
# elif defined(STDC)
# include <stddef.h>
typedef size_t z_size_t;
# else
typedef unsigned long z_size_t;
# endif
# undef z_longlong
#endif
/* Maximum value for memLevel in deflateInit2 */
#ifndef MAX_MEM_LEVEL
# ifdef MAXSEG_64K
# define MAX_MEM_LEVEL 8
# else
# define MAX_MEM_LEVEL 9
# endif
#endif
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
* created by gzip. (Files created by minigzip can still be extracted by
* gzip.)
*/
#ifndef MAX_WBITS
# define MAX_WBITS 15 /* 32K LZ77 window */
#endif
/* The memory requirements for deflate are (in bytes):
(1 << (windowBits+2)) + (1 << (memLevel+9))
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
plus a few kilobytes for small objects. For example, if you want to reduce
the default memory requirements from 256K to 128K, compile with
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
Of course this will generally degrade compression (there's no free lunch).
The memory requirements for inflate are (in bytes) 1 << windowBits
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
for small objects.
*/
/* Type declarations */
#ifndef OF /* function prototypes */
# ifdef STDC
# define OF(args) args
# else
# define OF(args) ()
# endif
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define Z_ARG(args) args
# else
# define Z_ARG(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
*/
#ifdef SYS16BIT
# if defined(M_I86SM) || defined(M_I86MM)
/* MSC small or medium model */
# define SMALL_MEDIUM
# ifdef _MSC_VER
# define FAR _far
# else
# define FAR far
# endif
# endif
# if (defined(__SMALL__) || defined(__MEDIUM__))
/* Turbo C small or medium model */
# define SMALL_MEDIUM
# ifdef __BORLANDC__
# define FAR _far
# else
# define FAR far
# endif
# endif
#endif
#if defined(WINDOWS) || defined(WIN32)
/* If building or using zlib as a DLL, define ZLIB_DLL.
* This is not mandatory, but it offers a little performance increase.
*/
# ifdef ZLIB_DLL
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
# ifdef ZLIB_INTERNAL
# define ZEXTERN extern __declspec(dllexport)
# else
# define ZEXTERN extern __declspec(dllimport)
# endif
# endif
# endif /* ZLIB_DLL */
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
* define ZLIB_WINAPI.
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
*/
# ifdef ZLIB_WINAPI
# ifdef FAR
# undef FAR
# endif
# include <windows.h>
/* No need for _export, use ZLIB.DEF instead. */
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
# define ZEXPORT WINAPI
# ifdef WIN32
# define ZEXPORTVA WINAPIV
# else
# define ZEXPORTVA FAR CDECL
# endif
# endif
#endif
#if defined (__BEOS__)
# ifdef ZLIB_DLL
# ifdef ZLIB_INTERNAL
# define ZEXPORT __declspec(dllexport)
# define ZEXPORTVA __declspec(dllexport)
# else
# define ZEXPORT __declspec(dllimport)
# define ZEXPORTVA __declspec(dllimport)
# endif
# endif
#endif
#ifndef ZEXTERN
# define ZEXTERN extern
#endif
#ifndef ZEXPORT
# define ZEXPORT
#endif
#ifndef ZEXPORTVA
# define ZEXPORTVA
#endif
#ifndef FAR
# define FAR
#endif
#if !defined(__MACTYPES__)
typedef unsigned char Byte; /* 8 bits */
#endif
typedef unsigned int uInt; /* 16 bits or more */
typedef unsigned long uLong; /* 32 bits or more */
#ifdef SMALL_MEDIUM
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
# define Bytef Byte FAR
#else
typedef Byte FAR Bytef;
#endif
typedef char FAR charf;
typedef int FAR intf;
typedef uInt FAR uIntf;
typedef uLong FAR uLongf;
#ifdef STDC
typedef void const *voidpc;
typedef void FAR *voidpf;
typedef void *voidp;
#else
typedef Byte const *voidpc;
typedef Byte FAR *voidpf;
typedef Byte *voidp;
#endif
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
#endif
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
#endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC
# ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
# include <stdarg.h> /* for va_list */
# endif
#endif
#ifdef _WIN32
# ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */
# endif
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
* though the former does not conform to the LFS document), but considering
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
# define Z_HAVE_UNISTD_H
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
# endif
# endif
#endif
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# define Z_LFS64
#endif
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# define Z_LARGE64
#endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
# define Z_WANT64
#endif
#if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
#endif
#ifndef z_off_t
# define z_off_t long
#endif
#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#else
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */
#if defined(__MVS__)
#pragma map(deflateInit_,"DEIN")
#pragma map(deflateInit2_,"DEIN2")
#pragma map(deflateEnd,"DEEND")
#pragma map(deflateBound,"DEBND")
#pragma map(inflateInit_,"ININ")
#pragma map(inflateInit2_,"ININ2")
#pragma map(inflateEnd,"INEND")
#pragma map(inflateSync,"INSY")
#pragma map(inflateSetDictionary,"INSEDI")
#pragma map(compressBound,"CMBND")
#pragma map(inflate_table,"INTABL")
#pragma map(inflate_fast,"INFA")
#pragma map(inflate_copyright,"INCOPY")
#endif
#endif /* ZCONF_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,149 @@
.TH ZLIB 3 "15 Jan 2017"
.SH NAME
zlib \- compression/decompression library
.SH SYNOPSIS
[see
.I zlib.h
for full description]
.SH DESCRIPTION
The
.I zlib
library is a general purpose data compression library.
The code is thread safe, assuming that the standard library functions
used are thread safe, such as memory allocation routines.
It provides in-memory compression and decompression functions,
including integrity checks of the uncompressed data.
This version of the library supports only one compression method (deflation)
but other algorithms may be added later
with the same stream interface.
.LP
Compression can be done in a single step if the buffers are large enough
or can be done by repeated calls of the compression function.
In the latter case,
the application must provide more input and/or consume the output
(providing more output space) before each call.
.LP
The library also supports reading and writing files in
.IR gzip (1)
(.gz) format
with an interface similar to that of stdio.
.LP
The library does not install any signal handler.
The decoder checks the consistency of the compressed data,
so the library should never crash even in the case of corrupted input.
.LP
All functions of the compression library are documented in the file
.IR zlib.h .
The distribution source includes examples of use of the library
in the files
.I test/example.c
and
.IR test/minigzip.c,
as well as other examples in the
.IR examples/
directory.
.LP
Changes to this version are documented in the file
.I ChangeLog
that accompanies the source.
.LP
.I zlib
is built in to many languages and operating systems, including but not limited to
Java, Python, .NET, PHP, Perl, Ruby, Swift, and Go.
.LP
An experimental package to read and write files in the .zip format,
written on top of
.I zlib
by Gilles Vollant (info@winimage.com),
is available at:
.IP
http://www.winimage.com/zLibDll/minizip.html
and also in the
.I contrib/minizip
directory of the main
.I zlib
source distribution.
.SH "SEE ALSO"
The
.I zlib
web site can be found at:
.IP
http://zlib.net/
.LP
The data format used by the
.I zlib
library is described by RFC
(Request for Comments) 1950 to 1952 in the files:
.IP
http://tools.ietf.org/html/rfc1950 (for the zlib header and trailer format)
.br
http://tools.ietf.org/html/rfc1951 (for the deflate compressed data format)
.br
http://tools.ietf.org/html/rfc1952 (for the gzip header and trailer format)
.LP
Mark Nelson wrote an article about
.I zlib
for the Jan. 1997 issue of Dr. Dobb's Journal;
a copy of the article is available at:
.IP
http://marknelson.us/1997/01/01/zlib-engine/
.SH "REPORTING PROBLEMS"
Before reporting a problem,
please check the
.I zlib
web site to verify that you have the latest version of
.IR zlib ;
otherwise,
obtain the latest version and see if the problem still exists.
Please read the
.I zlib
FAQ at:
.IP
http://zlib.net/zlib_faq.html
.LP
before asking for help.
Send questions and/or comments to zlib@gzip.org,
or (for the Windows DLL version) to Gilles Vollant (info@winimage.com).
.SH AUTHORS AND LICENSE
Version 1.2.11
.LP
Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler
.LP
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
.LP
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
.LP
.nr step 1 1
.IP \n[step]. 3
The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
.IP \n+[step].
Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
.IP \n+[step].
This notice may not be removed or altered from any source distribution.
.LP
Jean-loup Gailly Mark Adler
.br
jloup@gzip.org madler@alumni.caltech.edu
.LP
The deflate format used by
.I zlib
was defined by Phil Katz.
The deflate and
.I zlib
specifications were written by L. Peter Deutsch.
Thanks to all the people who reported problems and suggested various
improvements in
.IR zlib ;
who are too numerous to cite here.
.LP
UNIX manual page by R. P. C. Rodgers,
U.S. National Library of Medicine (rodgers@nlm.nih.gov).
.\" end of man page

View File

@ -0,0 +1,13 @@
prefix=D:/GIT/zlib/build-nuget
exec_prefix=D:/GIT/zlib/build-nuget
libdir=D:/GIT/zlib/build-nuget/lib
sharedlibdir=D:/GIT/zlib/build-nuget/lib
includedir=D:/GIT/zlib/build-nuget/include
Name: zlib
Description: zlib compression library
Version: 1.2.11
Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemDefinitionGroup Label="Release and x64" Condition="( $(Configuration.ToLower().IndexOf('debug')) == -1 ) And '$(Platform.ToLower())' == 'x64'">
<ClCompile>
<PreprocessorDefinitions>HAS_zlib;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)../..//build/native/lib_release/zlibstatic.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Label="Debug and x64" Condition="( $(Configuration.ToLower().IndexOf('debug')) &gt; -1 ) And '$(Platform.ToLower())' == 'x64'">
<ClCompile>
<PreprocessorDefinitions>HAS_zlib;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ResourceCompile>
<AdditionalIncludeDirectories>$(MSBuildThisFileDirectory)../..//build/native/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile>
<Link>
<AdditionalDependencies>$(MSBuildThisFileDirectory)../..//build/native/lib_debug/zlibstaticd.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<Target Name="zlib-msvc">
</Target>
</Project>

BIN
sqstdlib.dll Normal file

Binary file not shown.

BIN
squirrel.dll Normal file

Binary file not shown.