代码拉取完成,页面将自动刷新
同步操作将从 gite-hub/ggesoeasy 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <windows.h>
#include <time.h>
#include <fstream>
#include <sstream>
#include "libind/bind.h"
#include "gge.h"
#pragma comment(lib, "galaxy2d")
using namespace gge;
lua_State *L;
// CRITICAL_SECTION s_criticalSection;
// ccc_bind_declspec void cc_exit(int code) { PostQuitMessage(code); }
ccc_bind_declspec void cc_msgbox(const char* title, const char* text) { MessageBox(nullptr, Variant_Utf82Asc(text), Variant_Utf82Asc(title), MB_CANCELTRYCONTINUE); }
ccc_bind_declspec void cc_printf(const char* text) { printf("%s\n", Variant_Utf82Asc(text)); }
void registerMain(lua_State* ccc_register_state)
{
// ccc_register_func(cc_exit);
ccc_register_func(cc_msgbox);
ccc_register_func(cc_printf);
}
#if ccc_use_traceback
int traceback_index;
static bool errored = false;
int traceback(lua_State *state)
{
if (errored)
{
return 0;
}
errored = true;
const char *msg = nullptr;
if (lua_isstring(state, -1))
{
msg = lua_tostring(state, -1);
lua_pop(state, 1);
}
luaL_traceback(state, state, msg, 1);
if (lua_isstring(state, -1))
{
msg = lua_tostring(state, -1);
lua_pop(state, 1);
}
if (msg != nullptr)
{
cc_printf(msg);
cc_msgbox(__FUNCTION__, msg);
}
return 0;
}
#endif
HINSTANCE g_hInstance;
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int)
{
std::string scriptPath = "script/", mainlua;
if (__argc > 1)
{
scriptPath = __argv[1];
}
if (__argc > 2)
{
mainlua = scriptPath + __argv[2];
if (mainlua.find(".lua") == std::string::npos)
{
mainlua += ".lua";
}
std::ifstream ifile(mainlua, std::ios::binary);
if (ifile.is_open())
{
ifile.close();
}
else
{
mainlua.clear();
}
}
if (mainlua.empty())
{
mainlua = scriptPath + "bind/gmain.lua";
}
g_hInstance = hInst;
srand(time(nullptr));
gge::Random_Seed(time(nullptr));
// InitializeCriticalSection(&s_criticalSection);
L = ELuna::openLua();
registerGGE(L);
registerChild(L);
registerScheduler(L);
registerMain(L);
bool isConsole = AttachConsole(ATTACH_PARENT_PROCESS);
#ifdef _DEBUG
isConsole = isConsole || AllocConsole();
#endif
if(isConsole)
{
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
ccc_en_lock;
#if ccc_use_traceback
lua_pushcfunction(L, traceback);
traceback_index = lua_gettop(L);
#endif
lua_newtable(L);
lua_pushboolean(L, isConsole);
lua_setfield(L, -2, "console");
#if _DEBUG
lua_pushboolean(L, true);
#else
lua_pushboolean(L, false);
#endif
lua_setfield(L, -2, "debug");
lua_pushstring(L, scriptPath.c_str());
lua_setfield(L, -2, "scriptpath");
// lua_settable(L, -3);
lua_setglobal(L, "__easy");
#if ccc_use_traceback
auto r = luaL_loadfile(L, mainlua.c_str());
if (r == LUA_OK)
{
if (lua_pcall(L, 0, LUA_MULTRET, traceback_index) != LUA_OK)
{
auto msg = lua_tostring(L, -1);
if (msg != nullptr)
{
std::ostringstream ss;
ss << "top " << lua_gettop(L);
cc_msgbox(ss.str().c_str(), msg);
}
lua_pop(L, 1);
}
}
#else
luaL_dofile(L, mainlua.c_str());
#endif
ccc_un_lock;
gge::System_Start();
ELuna::closeLua(L);
gge::Engine_Release();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。