WIP port 4-d quest dialogue modules
This commit is contained in:
@@ -36,21 +36,7 @@
|
||||
|
||||
// 40250 UserInterface/PythonBackgroundModule.cpp
|
||||
// 40250 UserInterface/PythonEventManagerMoudle.cpp
|
||||
void AddStubConstants_event(PyObject* poModule)
|
||||
{
|
||||
(void) poModule;
|
||||
PyModule_AddIntConstant(poModule, "BOX_VISIBLE_LINE_COUNT", CPythonEventManager::BOX_VISIBLE_LINE_COUNT);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_NEXT", CPythonEventManager::BUTTON_TYPE_NEXT);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_DONE", CPythonEventManager::BUTTON_TYPE_DONE);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_CANCEL", CPythonEventManager::BUTTON_TYPE_CANCEL);
|
||||
}
|
||||
|
||||
// 40250 UserInterface/PythonGameEventManagerModule.cpp
|
||||
void AddStubConstants_eventMgr(PyObject* poModule)
|
||||
{
|
||||
(void) poModule;
|
||||
}
|
||||
|
||||
// 40250 UserInterface/PythonGuild.cpp
|
||||
void AddStubConstants_guild(PyObject* poModule)
|
||||
{
|
||||
@@ -76,12 +62,6 @@ void AddStubConstants_profiler(PyObject* poModule)
|
||||
}
|
||||
|
||||
// 40250 UserInterface/PythonQuest.cpp
|
||||
void AddStubConstants_quest(PyObject* poModule)
|
||||
{
|
||||
(void) poModule;
|
||||
PyModule_AddIntConstant(poModule, "QUEST_MAX_NUM", 5);
|
||||
}
|
||||
|
||||
// 40250 UserInterface/PythonSafeBox.cpp
|
||||
void AddStubConstants_safebox(PyObject* poModule)
|
||||
{
|
||||
|
||||
@@ -5,12 +5,9 @@
|
||||
#include "../EterLib/UIRenderCommands.h"
|
||||
|
||||
// GameplayModuleConstants.cpp: each module's 40250 constants.
|
||||
void AddStubConstants_event(PyObject* poModule);
|
||||
void AddStubConstants_eventMgr(PyObject* poModule);
|
||||
void AddStubConstants_guild(PyObject* poModule);
|
||||
void AddStubConstants_messenger(PyObject* poModule);
|
||||
void AddStubConstants_profiler(PyObject* poModule);
|
||||
void AddStubConstants_quest(PyObject* poModule);
|
||||
void AddStubConstants_safebox(PyObject* poModule);
|
||||
void AddStubConstants_snd(PyObject* poModule);
|
||||
void AddStubConstants_systemSetting(PyObject* poModule);
|
||||
@@ -24,62 +21,6 @@ PyObject* stub_call_named(const char* name, PyObject* result = nullptr) {
|
||||
return result ? result : Py_BuildValue("i", 0);
|
||||
}
|
||||
|
||||
// 40250 UserInterface/PythonEventManagerMoudle.cpp: event export names.
|
||||
PyObject* stub_event_RegisterEventSet(PyObject*, PyObject*) { return stub_call_named("event.RegisterEventSet", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_RegisterEventSetFromString(PyObject*, PyObject*) { return stub_call_named("event.RegisterEventSetFromString", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_ClearEventSet(PyObject*, PyObject*) { return stub_call_named("event.ClearEventSet", Py_BuildNone()); }
|
||||
PyObject* stub_event_SetRestrictedCount(PyObject*, PyObject*) { return stub_call_named("event.SetRestrictedCount", Py_BuildNone()); }
|
||||
PyObject* stub_event_GetEventSetLocalYPosition(PyObject*, PyObject*) { return stub_call_named("event.GetEventSetLocalYPosition", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_AddEventSetLocalYPosition(PyObject*, PyObject*) { return stub_call_named("event.AddEventSetLocalYPosition", Py_BuildNone()); }
|
||||
PyObject* stub_event_InsertText(PyObject*, PyObject*) { return stub_call_named("event.InsertText", Py_BuildNone()); }
|
||||
PyObject* stub_event_InsertTextInline(PyObject*, PyObject*) { return stub_call_named("event.InsertTextInline", Py_BuildNone()); }
|
||||
PyObject* stub_event_UpdateEventSet(PyObject*, PyObject*) { return stub_call_named("event.UpdateEventSet", Py_BuildNone()); }
|
||||
PyObject* stub_event_RenderEventSet(PyObject*, PyObject*) { return stub_call_named("event.RenderEventSet", Py_BuildNone()); }
|
||||
PyObject* stub_event_SetEventSetWidth(PyObject*, PyObject*) { return stub_call_named("event.SetEventSetWidth", Py_BuildNone()); }
|
||||
PyObject* stub_event_Skip(PyObject*, PyObject*) { return stub_call_named("event.Skip", Py_BuildNone()); }
|
||||
PyObject* stub_event_IsWait(PyObject*, PyObject*) { return stub_call_named("event.IsWait", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_EndEventProcess(PyObject*, PyObject*) { return stub_call_named("event.EndEventProcess", Py_BuildNone()); }
|
||||
PyObject* stub_event_SelectAnswer(PyObject*, PyObject*) { return stub_call_named("event.SelectAnswer", Py_BuildNone()); }
|
||||
PyObject* stub_event_GetLineCount(PyObject*, PyObject*) { return stub_call_named("event.GetLineCount", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_SetVisibleStartLine(PyObject*, PyObject*) { return stub_call_named("event.SetVisibleStartLine", Py_BuildNone()); }
|
||||
PyObject* stub_event_GetVisibleStartLine(PyObject*, PyObject*) { return stub_call_named("event.GetVisibleStartLine", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_event_SetEventHandler(PyObject*, PyObject*) { return stub_call_named("event.SetEventHandler", Py_BuildNone()); }
|
||||
PyObject* stub_event_SetInterfaceWindow(PyObject*, PyObject*) { return stub_call_named("event.SetInterfaceWindow", Py_BuildNone()); }
|
||||
PyObject* stub_event_SetLeftTimeString(PyObject*, PyObject*) { return stub_call_named("event.SetLeftTimeString", Py_BuildNone()); }
|
||||
PyObject* stub_event_QuestButtonClick(PyObject*, PyObject*) { return stub_call_named("event.QuestButtonClick", Py_BuildNone()); }
|
||||
PyObject* stub_event_Destroy(PyObject*, PyObject*) { return stub_call_named("event.Destroy", Py_BuildNone()); }
|
||||
PyMethodDef methods_event[] = {
|
||||
{ "RegisterEventSet", stub_event_RegisterEventSet, METH_VARARGS },
|
||||
{ "RegisterEventSetFromString", stub_event_RegisterEventSetFromString, METH_VARARGS },
|
||||
{ "ClearEventSet", stub_event_ClearEventSet, METH_VARARGS },
|
||||
{ "SetRestrictedCount", stub_event_SetRestrictedCount, METH_VARARGS },
|
||||
{ "GetEventSetLocalYPosition", stub_event_GetEventSetLocalYPosition, METH_VARARGS },
|
||||
{ "AddEventSetLocalYPosition", stub_event_AddEventSetLocalYPosition, METH_VARARGS },
|
||||
{ "InsertText", stub_event_InsertText, METH_VARARGS },
|
||||
{ "InsertTextInline", stub_event_InsertTextInline, METH_VARARGS },
|
||||
{ "UpdateEventSet", stub_event_UpdateEventSet, METH_VARARGS },
|
||||
{ "RenderEventSet", stub_event_RenderEventSet, METH_VARARGS },
|
||||
{ "SetEventSetWidth", stub_event_SetEventSetWidth, METH_VARARGS },
|
||||
{ "Skip", stub_event_Skip, METH_VARARGS },
|
||||
{ "IsWait", stub_event_IsWait, METH_VARARGS },
|
||||
{ "EndEventProcess", stub_event_EndEventProcess, METH_VARARGS },
|
||||
{ "SelectAnswer", stub_event_SelectAnswer, METH_VARARGS },
|
||||
{ "GetLineCount", stub_event_GetLineCount, METH_VARARGS },
|
||||
{ "SetVisibleStartLine", stub_event_SetVisibleStartLine, METH_VARARGS },
|
||||
{ "GetVisibleStartLine", stub_event_GetVisibleStartLine, METH_VARARGS },
|
||||
{ "SetEventHandler", stub_event_SetEventHandler, METH_VARARGS },
|
||||
{ "SetInterfaceWindow", stub_event_SetInterfaceWindow, METH_VARARGS },
|
||||
{ "SetLeftTimeString", stub_event_SetLeftTimeString, METH_VARARGS },
|
||||
{ "QuestButtonClick", stub_event_QuestButtonClick, METH_VARARGS },
|
||||
{ "Destroy", stub_event_Destroy, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
// 40250 UserInterface/PythonGameEventManagerModule.cpp: eventMgr export names.
|
||||
PyObject* stub_eventMgr_Update(PyObject*, PyObject*) { return stub_call_named("eventMgr.Update", Py_BuildNone()); }
|
||||
PyMethodDef methods_eventMgr[] = {
|
||||
{ "Update", stub_eventMgr_Update, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
// 40250 UserInterface/PythonGuild.cpp: guild export names.
|
||||
PyObject* stub_guild_IsGuildEnable(PyObject*, PyObject*) { return stub_call_named("guild.IsGuildEnable", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_guild_GuildIDToMarkID(PyObject*, PyObject*) { return stub_call_named("guild.GuildIDToMarkID", Py_BuildValue("i", 0)); }
|
||||
@@ -174,20 +115,6 @@ PyMethodDef methods_profiler[] = {
|
||||
{ "Pop", stub_profiler_Pop, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
// 40250 UserInterface/PythonQuest.cpp: quest export names.
|
||||
PyObject* stub_quest_GetQuestCount(PyObject*, PyObject*) { return stub_call_named("quest.GetQuestCount", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_quest_GetQuestData(PyObject*, PyObject*) { return stub_call_named("quest.GetQuestData", Py_BuildValue("sisi", "", 0, "", 0)); }
|
||||
PyObject* stub_quest_GetQuestIndex(PyObject*, PyObject*) { return stub_call_named("quest.GetQuestIndex", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_quest_GetQuestLastTime(PyObject*, PyObject*) { return stub_call_named("quest.GetQuestLastTime", Py_BuildValue("si", "", 0)); }
|
||||
PyObject* stub_quest_Clear(PyObject*, PyObject*) { return stub_call_named("quest.Clear", Py_BuildNone()); }
|
||||
PyMethodDef methods_quest[] = {
|
||||
{ "GetQuestCount", stub_quest_GetQuestCount, METH_VARARGS },
|
||||
{ "GetQuestData", stub_quest_GetQuestData, METH_VARARGS },
|
||||
{ "GetQuestIndex", stub_quest_GetQuestIndex, METH_VARARGS },
|
||||
{ "GetQuestLastTime", stub_quest_GetQuestLastTime, METH_VARARGS },
|
||||
{ "Clear", stub_quest_Clear, METH_VARARGS },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
// 40250 UserInterface/PythonSafeBox.cpp: safebox export names.
|
||||
PyObject* stub_safebox_GetCurrentSafeboxSize(PyObject*, PyObject*) { return stub_call_named("safebox.GetCurrentSafeboxSize", Py_BuildValue("i", 0)); }
|
||||
PyObject* stub_safebox_GetItemID(PyObject*, PyObject*) { return stub_call_named("safebox.GetItemID", Py_BuildValue("i", 0)); }
|
||||
@@ -344,16 +271,6 @@ PyMethodDef methods_udp[] = {
|
||||
} // namespace
|
||||
|
||||
void init_2v0_gameplay_stubs() {
|
||||
{
|
||||
PyObject* module = Py_InitModule("event", methods_event);
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
AddStubConstants_event(module);
|
||||
}
|
||||
{
|
||||
PyObject* module = Py_InitModule("eventMgr", methods_eventMgr);
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
AddStubConstants_eventMgr(module);
|
||||
}
|
||||
{
|
||||
PyObject* module = Py_InitModule("guild", methods_guild);
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
@@ -369,11 +286,6 @@ void init_2v0_gameplay_stubs() {
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
AddStubConstants_profiler(module);
|
||||
}
|
||||
{
|
||||
PyObject* module = Py_InitModule("quest", methods_quest);
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
AddStubConstants_quest(module);
|
||||
}
|
||||
{
|
||||
PyObject* module = Py_InitModule("safebox", methods_safebox);
|
||||
PyModule_AddIntConstant(module, "__port_stub__", 1);
|
||||
|
||||
@@ -400,10 +400,13 @@ bool run_main_script_body(const char* lpCmdLine, std::string* error)
|
||||
initTextTail();
|
||||
initnet();
|
||||
initMiniMap();
|
||||
initEvent();
|
||||
initeffect();
|
||||
initfly();
|
||||
initeventmgr();
|
||||
initshop();
|
||||
initskill();
|
||||
initquest();
|
||||
initBackground();
|
||||
initServerStateChecker();
|
||||
init_2v0_gameplay_stubs();
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
// Stand-in for the 40250 logic unit UserInterface/PythonEventManager.cpp, not ported yet: the members the ported units
|
||||
// reference, as platform_stub.py stubs. Delete this file in the commit that ports the unit into port/
|
||||
// (docs/PORT-PLAN.md).
|
||||
#include "UserInterface/StdAfx.h"
|
||||
#include "UserInterface/PythonEventManager.h"
|
||||
|
||||
#include "../../PlatformStub.h"
|
||||
|
||||
CPythonEventManager::CPythonEventManager()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CPythonEventManager::~CPythonEventManager()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonEventManager::RegisterEventSetFromString(const std::string &) -> int
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<int>();
|
||||
}
|
||||
|
||||
auto CPythonEventManager::SetVisibleLineCount(int, int) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
// Stand-in for the 40250 logic unit UserInterface/PythonQuest.cpp, not ported yet: the members the ported units
|
||||
// reference, as platform_stub.py stubs. Delete this file in the commit that ports the unit into port/
|
||||
// (docs/PORT-PLAN.md).
|
||||
#include "UserInterface/StdAfx.h"
|
||||
#include "UserInterface/PythonQuest.h"
|
||||
|
||||
#include "../../PlatformStub.h"
|
||||
|
||||
CPythonQuest::CPythonQuest()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
CPythonQuest::~CPythonQuest()
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::RegisterQuestInstance(const SQuestInstance &) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::DeleteQuestInstance(DWORD) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::IsQuest(DWORD) -> bool
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
return mt_platform_stub_return<bool>();
|
||||
}
|
||||
|
||||
auto CPythonQuest::MakeQuest(DWORD) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestTitle(DWORD, const char *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestClockName(DWORD, const char *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestCounterName(DWORD, const char *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestClockValue(DWORD, int) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestCounterValue(DWORD, int) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
|
||||
auto CPythonQuest::SetQuestIconFileName(DWORD, const char *) -> void
|
||||
{
|
||||
MT_PLATFORM_STUB();
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
#include "StdAfx.h"
|
||||
#include "parser.h"
|
||||
|
||||
using namespace script;
|
||||
|
||||
#define ishan(ch) (((ch) & 0xE0) > 0x90)
|
||||
#define isnhspace(ch) (!ishan(ch) && isspace(ch))
|
||||
|
||||
|
||||
extern DWORD GetDefaultCodePage();
|
||||
|
||||
const char* LocaleString_FindChar(const char* base, int len, char test)
|
||||
{
|
||||
if (!base)
|
||||
return NULL;
|
||||
|
||||
DWORD codePage = GetDefaultCodePage();
|
||||
|
||||
int pos = 0;
|
||||
while (pos < len)
|
||||
{
|
||||
const char* cur = base + pos;
|
||||
const char* next = CharNextExA(codePage, cur, 0);
|
||||
int cur_len = next - cur;
|
||||
if (cur_len > 1)
|
||||
{
|
||||
pos += cur_len;
|
||||
}
|
||||
else if (1 == cur_len)
|
||||
{
|
||||
if (*cur == test)
|
||||
return cur;
|
||||
|
||||
++pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int LocaleString_RightTrim(char* base, int len)
|
||||
{
|
||||
DWORD codePage = GetDefaultCodePage();
|
||||
|
||||
int pos = len;
|
||||
|
||||
while (pos > 0)
|
||||
{
|
||||
char* cur = base + pos;
|
||||
char* prev = CharPrevExA(codePage, base, cur , 0);
|
||||
|
||||
int prev_len = cur - prev;
|
||||
if (prev_len != 1)
|
||||
break;
|
||||
|
||||
if (!isspace((unsigned char) *prev) && *prev != '\n' && *prev != '\r')
|
||||
break;
|
||||
|
||||
*prev = '\0';
|
||||
|
||||
pos -= prev_len;
|
||||
}
|
||||
|
||||
if (pos > 0)
|
||||
return pos;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void LocaleString_RightTrim(char* base)
|
||||
{
|
||||
LocaleString_RightTrim(base, strlen(base));
|
||||
}
|
||||
|
||||
void OLD_rtrim(char* base)
|
||||
{
|
||||
if (!base)
|
||||
return;
|
||||
|
||||
DWORD codePage = GetDefaultCodePage();
|
||||
|
||||
if (949 == codePage || 936 == codePage)
|
||||
{
|
||||
char* end = base + strlen(base) - 1;
|
||||
|
||||
while (end != base)
|
||||
{
|
||||
if (!isnhspace((unsigned char) *end) && *end != '\n' && *end != '\r' || (end!=base && *((unsigned char*)end-1)>0xa0))
|
||||
break;
|
||||
|
||||
*end = '\0';
|
||||
|
||||
end = CharPrevExA(codePage, base, end, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
char* end = base + strlen(base);
|
||||
|
||||
while (end != base)
|
||||
{
|
||||
char* prev = CharPrevExA(codePage, base, end, 0);
|
||||
|
||||
int prev_len = end - prev;
|
||||
if (prev_len != 1)
|
||||
break;
|
||||
|
||||
if (!isspace((unsigned char) *prev) && *prev != '\n' && *prev != '\r')
|
||||
break;
|
||||
|
||||
*prev = '\0';
|
||||
|
||||
end = prev;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* LocaleString_Skip(DWORD codePage, const char* cur)
|
||||
{
|
||||
int loopCount = 0;
|
||||
|
||||
while (*cur)
|
||||
{
|
||||
if (++loopCount > 9216)
|
||||
{
|
||||
TraceError("Infinite loop in LocaleString_Skip [%s]", cur);
|
||||
break;
|
||||
}
|
||||
|
||||
const char* next = CharNextExA(codePage, cur, 0);
|
||||
int cur_len = next - cur;
|
||||
if (cur_len > 1)
|
||||
{
|
||||
cur = next;
|
||||
}
|
||||
else if (1 == cur_len)
|
||||
{
|
||||
if (!isspace((unsigned char) *cur) && *cur != '\n' && *cur != '\r')
|
||||
return cur;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cur;
|
||||
}
|
||||
|
||||
bool Group::GetArg(const char *c_arg_base, int arg_len, TArgList & argList)
|
||||
{
|
||||
char szName[32 + 1];
|
||||
char szValue[64 + 1];
|
||||
|
||||
int iNameLen = 0;
|
||||
int iValueLen = 0;
|
||||
int iCharLen = 0;
|
||||
|
||||
int pos = 0;
|
||||
|
||||
bool isValue = false;
|
||||
|
||||
DWORD codePage = GetDefaultCodePage();
|
||||
|
||||
while (pos < arg_len)
|
||||
{
|
||||
const char* cur = c_arg_base + pos;
|
||||
const char* next = CharNextExA(codePage, cur, 0);
|
||||
iCharLen = next - cur;
|
||||
|
||||
if (iCharLen > 1)
|
||||
{
|
||||
if (isValue)
|
||||
{
|
||||
if (iValueLen >= 64)
|
||||
{
|
||||
TraceError("argument value overflow: must be shorter than 64 letters");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(szValue+iValueLen, cur, iCharLen);
|
||||
iValueLen += iCharLen;
|
||||
szValue[iValueLen] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iNameLen >= 32)
|
||||
{
|
||||
TraceError("argument name overflow: must be shorter than 32 letters");
|
||||
return false;
|
||||
}
|
||||
memcpy(szName+iNameLen, cur, iCharLen);
|
||||
iNameLen += iCharLen;
|
||||
szName[iNameLen] = '\0';
|
||||
}
|
||||
}
|
||||
else if (iCharLen == 1)
|
||||
{
|
||||
const char c = *cur;
|
||||
if (c == '|')
|
||||
{
|
||||
if (iNameLen == 0)
|
||||
{
|
||||
TraceError("no argument name");
|
||||
return false;
|
||||
}
|
||||
|
||||
isValue = false;
|
||||
|
||||
iNameLen = LocaleString_RightTrim(szName, iNameLen);
|
||||
iValueLen = LocaleString_RightTrim(szValue, iValueLen);
|
||||
argList.push_back(TArg(szName, szValue));
|
||||
|
||||
iNameLen = 0;
|
||||
iValueLen = 0;
|
||||
}
|
||||
else if (c == ';')
|
||||
{
|
||||
isValue = true;
|
||||
}
|
||||
// 값이 아니고, 이름이 시작되지 않았을 경우 빈칸은 건너 뛴다.
|
||||
else if (!isValue && iNameLen == 0 && isspace((unsigned char) c))
|
||||
{
|
||||
}
|
||||
// 엔터는 건너 뛴다
|
||||
else if (c == '\r' || c == '\n')
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isValue)
|
||||
{
|
||||
if (iValueLen >= 64)
|
||||
{
|
||||
TraceError("argument value overflow: must be shorter than 64 letters");
|
||||
return false;
|
||||
}
|
||||
|
||||
memcpy(szValue+iValueLen, cur, iCharLen);
|
||||
iValueLen += iCharLen;
|
||||
szValue[iValueLen] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
if (iNameLen >= 32)
|
||||
{
|
||||
TraceError("argument name overflow: must be shorter than 32 letters");
|
||||
return false;
|
||||
}
|
||||
memcpy(szName+iNameLen, cur, iCharLen);
|
||||
iNameLen += iCharLen;
|
||||
szName[iNameLen] = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
pos += iCharLen;
|
||||
}
|
||||
|
||||
if (iNameLen != 0 && iValueLen != 0)
|
||||
{
|
||||
iNameLen = LocaleString_RightTrim(szName, iNameLen);
|
||||
iValueLen = LocaleString_RightTrim(szValue, iValueLen);
|
||||
argList.push_back(TArg(szName, szValue));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Group::Create(const std::string & stSource)
|
||||
{
|
||||
m_cmdList.clear();
|
||||
|
||||
if (stSource.empty())
|
||||
return false;
|
||||
|
||||
const char *str_base = stSource.c_str();
|
||||
if (!str_base || !*str_base)
|
||||
{
|
||||
TraceError("Source file has no content");
|
||||
return false;
|
||||
}
|
||||
int str_len = stSource.length();
|
||||
int str_pos = 0;
|
||||
|
||||
DWORD codePage = GetDefaultCodePage();
|
||||
|
||||
char box_data[1024 + 1];
|
||||
|
||||
static std::string stLetter;
|
||||
|
||||
while (str_pos < str_len)
|
||||
{
|
||||
TCmd cmd;
|
||||
|
||||
const char* word = str_base + str_pos;
|
||||
const char* word_next = CharNextExA(codePage, word, 0);
|
||||
|
||||
int word_len = word_next - word;
|
||||
|
||||
if (word_len > 1)
|
||||
{
|
||||
str_pos += word_len;
|
||||
|
||||
{
|
||||
stLetter.assign(word, word_next);
|
||||
|
||||
cmd.name.assign("LETTER");
|
||||
cmd.argList.push_back(TArg("value", stLetter));
|
||||
|
||||
m_cmdList.push_back(cmd);
|
||||
}
|
||||
|
||||
}
|
||||
else if (word_len == 1)
|
||||
{
|
||||
const char cur = *word;
|
||||
|
||||
if ('[' == cur)
|
||||
{
|
||||
++str_pos;
|
||||
|
||||
const char* box_begin = str_base + str_pos;
|
||||
const char* box_end = LocaleString_FindChar(box_begin, str_len - str_pos, ']');
|
||||
if (!box_end)
|
||||
{
|
||||
TraceError(" !! PARSING ERROR - Syntax Error : %s\n", box_begin);
|
||||
return false;
|
||||
}
|
||||
str_pos += box_end - box_begin + 1;
|
||||
|
||||
|
||||
int data_len = 0;
|
||||
{
|
||||
const char* data_begin = LocaleString_Skip(codePage, box_begin);
|
||||
const char* data_end = box_end;
|
||||
data_len = data_end - data_begin;
|
||||
if (data_len >= 1024)
|
||||
{
|
||||
TraceError(" !! PARSING ERROR - Buffer Overflow : %d, %s\n", data_len, str_base);
|
||||
return false;
|
||||
}
|
||||
memcpy(box_data, data_begin, data_len);
|
||||
box_data[data_len] = '\0';
|
||||
|
||||
data_len = LocaleString_RightTrim(box_data, data_len); // 오른쪽 빈칸 자르기
|
||||
}
|
||||
|
||||
{
|
||||
const char* space = LocaleString_FindChar(box_data, data_len, ' ');
|
||||
if (space) // 인자가 있음
|
||||
{
|
||||
int name_len = space - box_data;
|
||||
cmd.name.assign(box_data, name_len);
|
||||
|
||||
const char* space_next = CharNextExA(codePage, space, 0);
|
||||
const char* arg = LocaleString_Skip(codePage, space_next);
|
||||
|
||||
int arg_len = data_len - (arg - box_data);
|
||||
|
||||
if (!GetArg(arg, arg_len, cmd.argList))
|
||||
{
|
||||
TraceError(" !! PARSING ERROR - Unknown Arguments : %d, %s\n", arg_len, arg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else // 인자가 없으므로 모든 스트링이 명령어다.
|
||||
{
|
||||
cmd.name.assign(box_data);
|
||||
cmd.argList.clear();
|
||||
}
|
||||
|
||||
m_cmdList.push_back(cmd);
|
||||
}
|
||||
}
|
||||
else if (cur == '\r' || cur == '\n')
|
||||
{
|
||||
++str_pos;
|
||||
}
|
||||
else
|
||||
{
|
||||
++str_pos;
|
||||
|
||||
{
|
||||
stLetter.assign(1, cur);
|
||||
cmd.name.assign("LETTER");
|
||||
cmd.argList.push_back(TArg("value", stLetter));
|
||||
m_cmdList.push_back(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::GetCmd(TCmd & cmd)
|
||||
{
|
||||
if (m_cmdList.empty())
|
||||
return false;
|
||||
|
||||
cmd = m_cmdList.front();
|
||||
m_cmdList.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Group::ReadCmd(TCmd & cmd)
|
||||
{
|
||||
if (m_cmdList.empty())
|
||||
return false;
|
||||
|
||||
cmd = m_cmdList.front();
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string & Group::GetError()
|
||||
{
|
||||
return m_stError;
|
||||
}
|
||||
|
||||
void Group::SetError(const char * c_pszError)
|
||||
{
|
||||
m_stError.assign(c_pszError);
|
||||
}
|
||||
|
||||
Group::Group()
|
||||
{
|
||||
}
|
||||
|
||||
Group::~Group()
|
||||
{
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,315 @@
|
||||
#include "StdAfx.h"
|
||||
#include "PythonEventManager.h"
|
||||
#include "PythonNetworkStream.h"
|
||||
|
||||
PyObject * eventRegisterEventSet(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
char * szFileName;
|
||||
if (!PyTuple_GetString(poArgs, 0, &szFileName))
|
||||
return Py_BuildException();
|
||||
|
||||
int iEventIndex = CPythonEventManager::Instance().RegisterEventSet(szFileName);
|
||||
return Py_BuildValue("i", iEventIndex);
|
||||
}
|
||||
|
||||
PyObject * eventRegisterEventSetFromString(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
char * szEventString;
|
||||
if (!PyTuple_GetString(poArgs, 0, &szEventString))
|
||||
return Py_BuildException();
|
||||
|
||||
int iEventIndex = CPythonEventManager::Instance().RegisterEventSetFromString(szEventString);
|
||||
return Py_BuildValue("i", iEventIndex);
|
||||
}
|
||||
|
||||
PyObject * eventClearEventSet(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().ClearEventSeti(iIndex);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSetRestrictedCount(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
int iCount;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iCount))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().SetRestrictedCount(iIndex, iCount);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventGetEventSetLocalYPosition(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
return Py_BuildValue("i", CPythonEventManager::Instance().GetEventSetLocalYPosition(iIndex));
|
||||
}
|
||||
|
||||
PyObject * eventAddEventSetLocalYPosition(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
int iPos;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iPos))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().AddEventSetLocalYPosition(iIndex, iPos);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventInsertText(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
char * szText;
|
||||
if (!PyTuple_GetString(poArgs, 1, &szText))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().InsertText(iIndex, szText);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventInsertTextInline(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
char * szText;
|
||||
if (!PyTuple_GetString(poArgs, 1, &szText))
|
||||
return Py_BuildException();
|
||||
int iXIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 2, &iXIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().InsertText(iIndex, szText,iXIndex);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventUpdateEventSet(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
int ix;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &ix))
|
||||
return Py_BuildException();
|
||||
|
||||
int iy;
|
||||
if (!PyTuple_GetInteger(poArgs, 2, &iy))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().UpdateEventSet(iIndex, ix, -iy);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventRenderEventSet(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().RenderEventSet(iIndex);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSetEventSetWidth(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
int iWidth;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iWidth))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().SetEventSetWidth(iIndex, iWidth);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSkip(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().Skip(iIndex);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventIsWait(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
return Py_BuildValue("i", CPythonEventManager::Instance().IsWait(iIndex) == true ? 1 : 0);
|
||||
}
|
||||
|
||||
PyObject * eventEndEventProcess(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().EndEventProcess(iIndex);
|
||||
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSetEventHandler(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
PyObject * poEventHandler;
|
||||
if (!PyTuple_GetObject(poArgs, 1, &poEventHandler))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().SetEventHandler(iIndex, poEventHandler);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSelectAnswer(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
int iAnswer;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iAnswer))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().SelectAnswer(iIndex, iAnswer);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventGetLineCount(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
int iLineCount = CPythonEventManager::Instance().GetLineCount(iIndex);
|
||||
return Py_BuildValue("i", iLineCount);
|
||||
}
|
||||
|
||||
PyObject * eventSetVisibleStartLine(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
int iStartLine;
|
||||
if (!PyTuple_GetInteger(poArgs, 1, &iStartLine))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager::Instance().SetVisibleStartLine(iIndex, iStartLine);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventGetVisibleStartLine(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
return Py_BuildValue("i", CPythonEventManager::Instance().GetVisibleStartLine(iIndex));
|
||||
}
|
||||
|
||||
PyObject * eventQuestButtonClick(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonNetworkStream::Instance().SendScriptButtonPacket(iIndex);
|
||||
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSetInterfaceWindow(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
PyObject * pyHandle;
|
||||
if (!PyTuple_GetObject(poArgs, 0, &pyHandle))
|
||||
return Py_BadArgument();
|
||||
|
||||
CPythonEventManager & rpem = CPythonEventManager::Instance();
|
||||
rpem.SetInterfaceWindow(pyHandle);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventSetLeftTimeString(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
char * szText;
|
||||
if (!PyTuple_GetString(poArgs, 0, &szText))
|
||||
return Py_BuildException();
|
||||
|
||||
CPythonEventManager & rpem = CPythonEventManager::Instance();
|
||||
rpem.SetLeftTimeString(szText);
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
PyObject * eventDestroy(PyObject* poSelf, PyObject* poArgs)
|
||||
{
|
||||
CPythonEventManager & rpem = CPythonEventManager::Instance();
|
||||
rpem.Destroy();
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
void initEvent()
|
||||
{
|
||||
static PyMethodDef s_methods[] =
|
||||
{
|
||||
{ "RegisterEventSet", eventRegisterEventSet, METH_VARARGS },
|
||||
{ "RegisterEventSetFromString", eventRegisterEventSetFromString, METH_VARARGS },
|
||||
{ "ClearEventSet", eventClearEventSet, METH_VARARGS },
|
||||
|
||||
{ "SetRestrictedCount", eventSetRestrictedCount, METH_VARARGS },
|
||||
|
||||
{ "GetEventSetLocalYPosition", eventGetEventSetLocalYPosition, METH_VARARGS },
|
||||
{ "AddEventSetLocalYPosition", eventAddEventSetLocalYPosition, METH_VARARGS },
|
||||
{ "InsertText", eventInsertText, METH_VARARGS },
|
||||
{ "InsertTextInline", eventInsertTextInline, METH_VARARGS },
|
||||
|
||||
{ "UpdateEventSet", eventUpdateEventSet, METH_VARARGS },
|
||||
{ "RenderEventSet", eventRenderEventSet, METH_VARARGS },
|
||||
{ "SetEventSetWidth", eventSetEventSetWidth, METH_VARARGS },
|
||||
|
||||
{ "Skip", eventSkip, METH_VARARGS },
|
||||
{ "IsWait", eventIsWait, METH_VARARGS },
|
||||
{ "EndEventProcess", eventEndEventProcess, METH_VARARGS },
|
||||
|
||||
{ "SelectAnswer", eventSelectAnswer, METH_VARARGS },
|
||||
{ "GetLineCount", eventGetLineCount, METH_VARARGS },
|
||||
{ "SetVisibleStartLine", eventSetVisibleStartLine, METH_VARARGS },
|
||||
{ "GetVisibleStartLine", eventGetVisibleStartLine, METH_VARARGS },
|
||||
|
||||
{ "SetEventHandler", eventSetEventHandler, METH_VARARGS },
|
||||
{ "SetInterfaceWindow", eventSetInterfaceWindow, METH_VARARGS },
|
||||
{ "SetLeftTimeString", eventSetLeftTimeString, METH_VARARGS },
|
||||
|
||||
{ "QuestButtonClick", eventQuestButtonClick, METH_VARARGS },
|
||||
{ "Destroy", eventDestroy, METH_VARARGS },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
PyObject * poModule = Py_InitModule("event", s_methods);
|
||||
|
||||
PyModule_AddIntConstant(poModule, "BOX_VISIBLE_LINE_COUNT", CPythonEventManager::BOX_VISIBLE_LINE_COUNT);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_NEXT", CPythonEventManager::BUTTON_TYPE_NEXT);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_DONE", CPythonEventManager::BUTTON_TYPE_DONE);
|
||||
PyModule_AddIntConstant(poModule, "BUTTON_TYPE_CANCEL", CPythonEventManager::BUTTON_TYPE_CANCEL);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
#include "StdAfx.h"
|
||||
#include "../gamelib/GameEventManager.h"
|
||||
|
||||
PyObject * eventMgrUpdate(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
float fx;
|
||||
if (!PyTuple_GetFloat(poArgs, 0, &fx))
|
||||
return Py_BuildException();
|
||||
float fy;
|
||||
if (!PyTuple_GetFloat(poArgs, 1, &fy))
|
||||
return Py_BuildException();
|
||||
float fz;
|
||||
if (!PyTuple_GetFloat(poArgs, 2, &fz))
|
||||
return Py_BuildException();
|
||||
|
||||
CGameEventManager::Instance().SetCenterPosition(fx, fy, fz);
|
||||
CGameEventManager::Instance().Update();
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
void initeventmgr()
|
||||
{
|
||||
static PyMethodDef s_methods[] =
|
||||
{
|
||||
{ "Update", eventMgrUpdate, METH_VARARGS },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
Py_InitModule("eventMgr", s_methods);
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
#include "StdAfx.h"
|
||||
#include "PythonQuest.h"
|
||||
|
||||
void CPythonQuest::RegisterQuestInstance(const SQuestInstance & c_rQuestInstance)
|
||||
{
|
||||
DeleteQuestInstance(c_rQuestInstance.dwIndex);
|
||||
m_QuestInstanceContainer.push_back(c_rQuestInstance);
|
||||
|
||||
/////
|
||||
|
||||
SQuestInstance & rQuestInstance = *m_QuestInstanceContainer.rbegin();
|
||||
rQuestInstance.iStartTime = int(CTimer::Instance().GetCurrentSecond());
|
||||
}
|
||||
|
||||
struct FQuestInstanceCompare
|
||||
{
|
||||
DWORD dwSearchIndex;
|
||||
FQuestInstanceCompare(DWORD dwIndex) : dwSearchIndex(dwIndex) {}
|
||||
bool operator () (const CPythonQuest::SQuestInstance & rQuestInstance)
|
||||
{
|
||||
return dwSearchIndex == rQuestInstance.dwIndex;
|
||||
}
|
||||
};
|
||||
|
||||
void CPythonQuest::DeleteQuestInstance(DWORD dwIndex)
|
||||
{
|
||||
TQuestInstanceContainer::iterator itor = std::find_if(m_QuestInstanceContainer.begin(), m_QuestInstanceContainer.end(), FQuestInstanceCompare(dwIndex));
|
||||
if (itor == m_QuestInstanceContainer.end())
|
||||
return;
|
||||
|
||||
m_QuestInstanceContainer.erase(itor);
|
||||
}
|
||||
|
||||
bool CPythonQuest::IsQuest(DWORD dwIndex)
|
||||
{
|
||||
TQuestInstanceContainer::iterator itor = std::find_if(m_QuestInstanceContainer.begin(), m_QuestInstanceContainer.end(), FQuestInstanceCompare(dwIndex));
|
||||
return itor != m_QuestInstanceContainer.end();
|
||||
}
|
||||
|
||||
void CPythonQuest::MakeQuest(DWORD dwIndex)
|
||||
{
|
||||
DeleteQuestInstance(dwIndex);
|
||||
m_QuestInstanceContainer.push_back(SQuestInstance());
|
||||
|
||||
/////
|
||||
|
||||
SQuestInstance & rQuestInstance = *m_QuestInstanceContainer.rbegin();
|
||||
rQuestInstance.dwIndex = dwIndex;
|
||||
rQuestInstance.iStartTime = int(CTimer::Instance().GetCurrentSecond());
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestTitle(DWORD dwIndex, const char * c_szTitle)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->strTitle = c_szTitle;
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestClockName(DWORD dwIndex, const char * c_szClockName)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->strClockName = c_szClockName;
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestCounterName(DWORD dwIndex, const char * c_szCounterName)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->strCounterName = c_szCounterName;
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestClockValue(DWORD dwIndex, int iClockValue)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->iClockValue = iClockValue;
|
||||
pQuestInstance->iStartTime = int(CTimer::Instance().GetCurrentSecond());
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestCounterValue(DWORD dwIndex, int iCounterValue)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->iCounterValue = iCounterValue;
|
||||
}
|
||||
|
||||
void CPythonQuest::SetQuestIconFileName(DWORD dwIndex, const char * c_szIconFileName)
|
||||
{
|
||||
SQuestInstance * pQuestInstance;
|
||||
if (!__GetQuestInstancePtr(dwIndex, &pQuestInstance))
|
||||
return;
|
||||
|
||||
pQuestInstance->strIconFileName = c_szIconFileName;
|
||||
}
|
||||
|
||||
int CPythonQuest::GetQuestCount()
|
||||
{
|
||||
return m_QuestInstanceContainer.size();
|
||||
}
|
||||
|
||||
bool CPythonQuest::GetQuestInstancePtr(DWORD dwArrayIndex, SQuestInstance ** ppQuestInstance)
|
||||
{
|
||||
if (dwArrayIndex >= m_QuestInstanceContainer.size())
|
||||
return false;
|
||||
|
||||
*ppQuestInstance = &m_QuestInstanceContainer[dwArrayIndex];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CPythonQuest::__GetQuestInstancePtr(DWORD dwQuestIndex, SQuestInstance ** ppQuestInstance)
|
||||
{
|
||||
TQuestInstanceContainer::iterator itor = std::find_if(m_QuestInstanceContainer.begin(), m_QuestInstanceContainer.end(), FQuestInstanceCompare(dwQuestIndex));
|
||||
if (itor == m_QuestInstanceContainer.end())
|
||||
return false;
|
||||
|
||||
*ppQuestInstance = &(*itor);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CPythonQuest::__Initialize()
|
||||
{
|
||||
/*
|
||||
#ifdef _DEBUG
|
||||
for (int i = 0; i < 7; ++i)
|
||||
{
|
||||
SQuestInstance test;
|
||||
test.dwIndex = i;
|
||||
test.strIconFileName = "";
|
||||
test.strTitle = _getf("test%d", i);
|
||||
test.strClockName = "남은 시간";
|
||||
test.strCounterName = "남은 마리수";
|
||||
test.iClockValue = 1000;
|
||||
test.iCounterValue = 1000;
|
||||
test.iStartTime = 0;
|
||||
RegisterQuestInstance(test);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
void CPythonQuest::Clear()
|
||||
{
|
||||
m_QuestInstanceContainer.clear();
|
||||
}
|
||||
|
||||
CPythonQuest::CPythonQuest()
|
||||
{
|
||||
__Initialize();
|
||||
}
|
||||
|
||||
CPythonQuest::~CPythonQuest()
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PyObject * questGetQuestCount(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
return Py_BuildValue("i", CPythonQuest::Instance().GetQuestCount());
|
||||
}
|
||||
|
||||
PyObject * questGetQuestData(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BadArgument();
|
||||
|
||||
CPythonQuest::SQuestInstance * pQuestInstance;
|
||||
if (!CPythonQuest::Instance().GetQuestInstancePtr(iIndex, &pQuestInstance))
|
||||
return Py_BuildException("Failed to find quest by index %d", iIndex);
|
||||
|
||||
CGraphicImage * pImage = NULL;
|
||||
if (!pQuestInstance->strIconFileName.empty())
|
||||
{
|
||||
std::string strIconFileName;
|
||||
strIconFileName = "d:/ymir work/ui/game/quest/questicon/";
|
||||
strIconFileName += pQuestInstance->strIconFileName.c_str();
|
||||
pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strIconFileName.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
// 비어있을 경우 디폴트 이미지를 넣는다.
|
||||
std::string strIconFileName = "season1/icon/scroll_open.tga";
|
||||
pImage = (CGraphicImage *)CResourceManager::Instance().GetResourcePointer(strIconFileName.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
return Py_BuildValue("sisi", pQuestInstance->strTitle.c_str(),
|
||||
pImage,
|
||||
pQuestInstance->strCounterName.c_str(),
|
||||
pQuestInstance->iCounterValue);
|
||||
}
|
||||
|
||||
PyObject * questGetQuestIndex(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BadArgument();
|
||||
|
||||
CPythonQuest::SQuestInstance * pQuestInstance;
|
||||
if (!CPythonQuest::Instance().GetQuestInstancePtr(iIndex, &pQuestInstance))
|
||||
return Py_BuildException("Failed to find quest by index %d", iIndex);
|
||||
|
||||
return Py_BuildValue("i", pQuestInstance->dwIndex);
|
||||
}
|
||||
|
||||
PyObject * questGetQuestLastTime(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
int iIndex;
|
||||
if (!PyTuple_GetInteger(poArgs, 0, &iIndex))
|
||||
return Py_BadArgument();
|
||||
|
||||
CPythonQuest::SQuestInstance * pQuestInstance;
|
||||
if (!CPythonQuest::Instance().GetQuestInstancePtr(iIndex, &pQuestInstance))
|
||||
return Py_BuildException("Failed to find quest by index %d", iIndex);
|
||||
|
||||
int iLastTime = 0;
|
||||
|
||||
if (pQuestInstance->iClockValue >= 0)
|
||||
{
|
||||
iLastTime = (pQuestInstance->iStartTime + pQuestInstance->iClockValue) - int(CTimer::Instance().GetCurrentSecond());
|
||||
}
|
||||
|
||||
// 시간 증가 처리 코드
|
||||
// else
|
||||
// {
|
||||
// iLastTime = int(CTimer::Instance().GetCurrentSecond()) - pQuestInstance->iStartTime;
|
||||
// }
|
||||
|
||||
return Py_BuildValue("si", pQuestInstance->strClockName.c_str(), iLastTime);
|
||||
}
|
||||
|
||||
PyObject * questClear(PyObject * poSelf, PyObject * poArgs)
|
||||
{
|
||||
CPythonQuest::Instance().Clear();
|
||||
return Py_BuildNone();
|
||||
}
|
||||
|
||||
void initquest()
|
||||
{
|
||||
static PyMethodDef s_methods[] =
|
||||
{
|
||||
{ "GetQuestCount", questGetQuestCount, METH_VARARGS },
|
||||
{ "GetQuestData", questGetQuestData, METH_VARARGS },
|
||||
{ "GetQuestIndex", questGetQuestIndex, METH_VARARGS },
|
||||
{ "GetQuestLastTime", questGetQuestLastTime, METH_VARARGS },
|
||||
{ "Clear", questClear, METH_VARARGS },
|
||||
{ NULL, NULL, NULL },
|
||||
};
|
||||
|
||||
PyObject * poModule = Py_InitModule("quest", s_methods);
|
||||
PyModule_AddIntConstant(poModule, "QUEST_MAX_NUM", 5);
|
||||
}
|
||||
@@ -46,6 +46,9 @@ enum
|
||||
void initpack();
|
||||
void initime();
|
||||
void initshop();
|
||||
void initquest();
|
||||
void initEvent();
|
||||
void initeventmgr();
|
||||
void initapp();
|
||||
void initchr();
|
||||
void initchrmgr();
|
||||
|
||||
@@ -391,4 +391,35 @@ int WideCharToMultiByte(UINT CodePage, DWORD, LPCWSTR lpWideCharStr, int cchWide
|
||||
return int(bytes.size());
|
||||
}
|
||||
|
||||
BOOL IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar)
|
||||
{
|
||||
switch (CodePage) {
|
||||
case 932: return (TestChar >= 0x81 && TestChar <= 0x9F) || (TestChar >= 0xE0 && TestChar <= 0xFC);
|
||||
case 936:
|
||||
case 949:
|
||||
case 950: return TestChar >= 0x81 && TestChar <= 0xFE;
|
||||
default: return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
LPSTR CharNextExA(WORD CodePage, LPCSTR lpCurrentChar, DWORD)
|
||||
{
|
||||
if (!*lpCurrentChar) return const_cast<LPSTR>(lpCurrentChar);
|
||||
if (IsDBCSLeadByteEx(CodePage, BYTE(*lpCurrentChar)) && lpCurrentChar[1]) return const_cast<LPSTR>(lpCurrentChar + 2);
|
||||
return const_cast<LPSTR>(lpCurrentChar + 1);
|
||||
}
|
||||
|
||||
LPSTR CharPrevExA(WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags)
|
||||
{
|
||||
// Walk forward from lpStart so a trail byte is never taken for a lead byte.
|
||||
LPCSTR prev = lpStart;
|
||||
for (LPCSTR p = lpStart; p < lpCurrentChar;) {
|
||||
prev = p;
|
||||
LPCSTR next = CharNextExA(CodePage, p, dwFlags);
|
||||
if (next == p) break;
|
||||
p = next;
|
||||
}
|
||||
return const_cast<LPSTR>(prev);
|
||||
}
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
@@ -101,4 +101,10 @@ int MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int
|
||||
int WideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar,
|
||||
LPSTR lpMultiByteStr, int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);
|
||||
|
||||
// winnls.h / winuser.h DBCS stepping. Lead bytes follow the double-byte code pages 932, 936, 949 and 950;
|
||||
// every other code page (1252, UTF-8, ...) steps one byte at a time, as Windows does for single-byte pages.
|
||||
BOOL IsDBCSLeadByteEx(UINT CodePage, BYTE TestChar);
|
||||
LPSTR CharNextExA(WORD CodePage, LPCSTR lpCurrentChar, DWORD dwFlags);
|
||||
LPSTR CharPrevExA(WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags);
|
||||
|
||||
#endif // !_WIN32
|
||||
|
||||
Reference in New Issue
Block a user