// Provenance: AVA2 UserInterface/PythonSystem.cpp and PythonSystemModule.cpp (see python_system.h). // Platform substitutions: D3D adapter modes -> SDL display modes, GetSystemMetrics(SM_C?FULLSCREEN) // -> SDL usable display bounds, CSoundManager -> ava2::SoundManager, stricmp -> SDL_strcasecmp. #include "python_system.h" #include "eter_sound/SoundManager.h" #include "shared/common/PythonUtils.h" #include #include #include #include #include #include namespace ava2 { int g_iLoadingDelayTime = 1; namespace { #define DEFAULT_VALUE_ALWAYS_SHOW_NAME true std::string& ConfigDirectory() { static std::string s_directory; return s_directory; } void PutInt32(unsigned char* p, int32_t value) { const uint32_t u = static_cast(value); for (int i = 0; i < 4; ++i) p[i] = static_cast(u >> (i * 8)); } int32_t GetInt32(const unsigned char* p) { uint32_t u = 0; for (int i = 0; i < 4; ++i) u |= uint32_t(p[i]) << (i * 8); return static_cast(u); } } // namespace CPythonSystem& CPythonSystem::Instance() { static CPythonSystem s_instance; return s_instance; } void CPythonSystem::SetConfigDirectory(const std::string& directory) { ConfigDirectory() = directory; } const std::string& CPythonSystem::GetConfigDirectory() { return ConfigDirectory(); } std::string CPythonSystem::__ConfigPath(const char* c_szFileName) const { const std::string& directory = ConfigDirectory(); if (directory.empty()) return c_szFileName; if (directory.back() == '/' || directory.back() == '\\') return directory + c_szFileName; return directory + "/" + c_szFileName; } void CPythonSystem::SetInterfaceHandler(PyObject* poHandler) { // NOTE: the reference count is not changed; the handler's __del__ clears it (levites). m_poInterfaceHandler = poHandler; } void CPythonSystem::DestroyInterfaceHandler() { m_poInterfaceHandler = nullptr; } void CPythonSystem::SaveWindowStatus(int iIndex, int iVisible, int iMinimized, int ix, int iy, int iHeight) { // Windows indexes m_WindowStatus unchecked; an out-of-range index is dropped here. if (iIndex < 0 || iIndex >= WINDOW_MAX_NUM) return; m_WindowStatus[iIndex].isVisible = iVisible; m_WindowStatus[iIndex].isMinimized = iMinimized; m_WindowStatus[iIndex].ixPosition = ix; m_WindowStatus[iIndex].iyPosition = iy; m_WindowStatus[iIndex].iHeight = iHeight; } void CPythonSystem::ClearDisplaySettings() { memset(m_ResolutionList, 0, sizeof(TResolution) * RESOLUTION_MAX_NUM); m_ResolutionCount = 0; } void CPythonSystem::AddDisplayMode(uint32_t width, uint32_t height, uint32_t bpp, uint32_t frequency) { // Only 800x600 and up. if (width < 800 || height < 600) return; // Only 16 and 32 bpp (D3DFMT_R5G6B5 / D3DFMT_X8R8G8B8). if (bpp != 16 && bpp != 32) return; for (int i = 0; i < m_ResolutionCount; ++i) { TResolution& r = m_ResolutionList[i]; if (r.bpp != bpp || r.width != width || r.height != height) continue; // Same resolution: only the frequency is new. for (int j = 0; j < r.frequency_count; ++j) if (r.frequency[j] == frequency) return; // Windows guards with FREQUENCY_MAX_NUM (30) against a 20-entry array; the array bound is used. if (r.frequency_count < int(sizeof(r.frequency) / sizeof(r.frequency[0]))) r.frequency[r.frequency_count++] = frequency; return; } if (m_ResolutionCount < RESOLUTION_MAX_NUM) { TResolution& r = m_ResolutionList[m_ResolutionCount]; r.width = width; r.height = height; r.bpp = bpp; r.frequency[0] = frequency; r.frequency_count = 1; ++m_ResolutionCount; } } void CPythonSystem::GetDisplaySettings() { ClearDisplaySettings(); if (!SDL_WasInit(SDL_INIT_VIDEO)) return; int count = 0; SDL_DisplayMode** modes = SDL_GetFullscreenDisplayModes(SDL_GetPrimaryDisplay(), &count); if (!modes) return; for (int i = 0; i < count; ++i) { const SDL_DisplayMode* mode = modes[i]; const uint32_t bpp = uint32_t(SDL_BYTESPERPIXEL(mode->format)) * 8; AddDisplayMode(uint32_t(mode->w), uint32_t(mode->h), bpp, uint32_t(std::lround(mode->refresh_rate))); } SDL_free(modes); } int CPythonSystem::GetResolutionCount() { return m_ResolutionCount; } int CPythonSystem::GetFrequencyCount(int index) { if (index >= m_ResolutionCount) return 0; return m_ResolutionList[index].frequency_count; } bool CPythonSystem::GetResolution(int index, uint32_t* width, uint32_t* height, uint32_t* bpp) { if (index >= m_ResolutionCount) return false; *width = m_ResolutionList[index].width; *height = m_ResolutionList[index].height; *bpp = m_ResolutionList[index].bpp; return true; } bool CPythonSystem::GetFrequency(int index, int freq_index, uint32_t* frequncy) { if (index >= m_ResolutionCount) return false; if (freq_index >= m_ResolutionList[index].frequency_count) return false; *frequncy = m_ResolutionList[index].frequency[freq_index]; return true; } int CPythonSystem::GetResolutionIndex(uint32_t width, uint32_t height, uint32_t bit) { uint32_t re_width, re_height, re_bit; int i = 0; while (GetResolution(i, &re_width, &re_height, &re_bit)) { if (re_width == width) if (re_height == height) if (re_bit == bit) return i; i++; } return 0; } int CPythonSystem::GetFrequencyIndex(int res_index, uint32_t frequency) { uint32_t re_frequency; int i = 0; while (GetFrequency(res_index, i, &re_frequency)) { if (re_frequency == frequency) return i; i++; } return 0; } uint32_t CPythonSystem::GetWidth() { return m_displayWidth ? m_displayWidth : m_Config.width; } uint32_t CPythonSystem::GetHeight() { return m_displayHeight ? m_displayHeight : m_Config.height; } void CPythonSystem::SetDisplaySizeOverride(uint32_t width, uint32_t height) { m_displayWidth = width; m_displayHeight = height; } uint32_t CPythonSystem::GetBPP() { return m_Config.bpp; } uint32_t CPythonSystem::GetFrequency() { return m_Config.frequency; } bool CPythonSystem::IsNoSoundCard() { return m_Config.bNoSoundCard; } bool CPythonSystem::IsSoftwareCursor() { return m_Config.is_software_cursor; } float CPythonSystem::GetMusicVolume() { return m_Config.music_volume; } int CPythonSystem::GetSoundVolume() { return m_Config.voice_volume; } void CPythonSystem::SetMusicVolume(float fVolume) { m_Config.music_volume = fVolume; } void CPythonSystem::SetSoundVolumef(float fVolume) { m_Config.voice_volume = uint8_t(int(5 * fVolume)); } int CPythonSystem::GetDistance() { return m_Config.iDistance; } int CPythonSystem::GetShadowLevel() { return m_Config.iShadowLevel; } void CPythonSystem::SetShadowLevel(unsigned int level) { m_Config.iShadowLevel = int(std::min(level, 5u)); // CPythonBackground::RefreshShadowLevel: no CPythonBackground in this port yet (PORT-PLAN pass 25). } int CPythonSystem::IsSaveID() { return m_Config.isSaveID; } const char* CPythonSystem::GetSaveID() { return m_Config.SaveID; } bool CPythonSystem::isViewCulling() { return m_Config.is_object_culling; } void CPythonSystem::SetSaveID(int iValue, const char* c_szSaveID) { if (iValue != 1) return; m_Config.isSaveID = iValue; strncpy(m_Config.SaveID, c_szSaveID, sizeof(m_Config.SaveID) - 1); } CPythonSystem::TConfig* CPythonSystem::GetConfig() { return &m_Config; } void CPythonSystem::SetConfig(TConfig* pNewConfig) { m_Config = *pNewConfig; } void CPythonSystem::SetDefaultConfig() { memset(&m_Config, 0, sizeof(m_Config)); m_Config.width = 1024; m_Config.height = 768; m_Config.bpp = 32; m_Config.bWindowed = false; m_Config.is_software_cursor = false; m_Config.is_object_culling = true; m_Config.iDistance = 3; m_Config.gamma = 3; m_Config.music_volume = 1.0f; m_Config.voice_volume = 5; m_Config.bDecompressDDS = 0; m_Config.bSoftwareTiling = 0; m_Config.iShadowLevel = 3; m_Config.bShowShadow = true; m_Config.bViewChat = true; m_Config.bAlwaysShowName = DEFAULT_VALUE_ALWAYS_SHOW_NAME; m_Config.bShowDamage = true; m_Config.bShowSalesText = true; m_Config.bShowMobAIFlag = true; m_Config.bShowMobLevel = true; m_Config.bSnowTexturesMode = false; m_Config.shopnames_range = 0; m_Config.questLetter = true; m_Config.countryFlag = true; m_Config.affectIcons = true; m_Config.iFOVLevel = 30.0f; m_Config.iEffectLevel = 0; m_Config.bPetStatus = true; m_Config.bMountStatus = true; m_Config.bNpcStatus = true; m_Config.bNightMode = false; m_Config.bMessage = true; m_Config.bDungeonTrack = false; m_Config.bBossTrack = false; m_Config.fobjectDist = 25600.0; } bool CPythonSystem::IsWindowed() { return m_Config.bWindowed; } bool CPythonSystem::IsViewChat() { return m_Config.bViewChat; } void CPythonSystem::SetViewChatFlag(int iFlag) { m_Config.bViewChat = iFlag == 1 ? true : false; } bool CPythonSystem::IsAlwaysShowName() { return m_Config.bAlwaysShowName; } void CPythonSystem::SetAlwaysShowNameFlag(int iFlag) { m_Config.bAlwaysShowName = iFlag == 1 ? true : false; } bool CPythonSystem::IsShowDamage() { return m_Config.bShowDamage; } void CPythonSystem::SetShowDamageFlag(int iFlag) { m_Config.bShowDamage = iFlag == 1 ? true : false; } bool CPythonSystem::IsShowSalesText() { return m_Config.bShowSalesText; } void CPythonSystem::SetShowSalesTextFlag(int iFlag) { m_Config.bShowSalesText = iFlag == 1 ? true : false; } bool CPythonSystem::IsShowMobAIFlag() { return m_Config.bShowMobAIFlag; } void CPythonSystem::SetShowMobAIFlagFlag(int iFlag) { m_Config.bShowMobAIFlag = iFlag == 1 ? true : false; } bool CPythonSystem::IsShowMobLevel() { return m_Config.bShowMobLevel; } void CPythonSystem::SetShowMobLevelFlag(int iFlag) { m_Config.bShowMobLevel = iFlag == 1 ? true : false; } bool CPythonSystem::IsSnowTexturesMode() { return m_Config.bSnowTexturesMode; } void CPythonSystem::SetSnowTexturesMode(int iFlag) { m_Config.bSnowTexturesMode = iFlag == 1 ? true : false; } bool CPythonSystem::IsAutoTiling() { if (m_Config.bSoftwareTiling == 0) return true; return false; } void CPythonSystem::SetSoftwareTiling(bool isEnable) { if (isEnable) m_Config.bSoftwareTiling = 1; else m_Config.bSoftwareTiling = 2; } bool CPythonSystem::IsSoftwareTiling() { if (m_Config.bSoftwareTiling == 1) return true; return false; } bool CPythonSystem::IsUseDefaultIME() { return m_Config.bUseDefaultIME; } void CPythonSystem::SetFOVLevel(const float fFOV) { m_Config.iFOVLevel = std::min(std::max(fFOV, 30.0f), 100.0f); } void CPythonSystem::SetObjectDistance(float fDist) { if (fDist > 25600.0) fDist = 25600.0; m_Config.fobjectDist = fDist; } bool CPythonSystem::LoadConfig() { FILE* fp = fopen(__ConfigPath("metin2.cfg").c_str(), "rt"); if (!fp) return false; char buf[256]; char command[256]; char value[256]; while (fgets(buf, 256, fp)) { if (sscanf(buf, " %255s %255s\n", command, value) == EOF) break; if (!SDL_strcasecmp(command, "WIDTH")) m_Config.width = atoi(value); else if (!SDL_strcasecmp(command, "HEIGHT")) m_Config.height = atoi(value); else if (!SDL_strcasecmp(command, "BPP")) m_Config.bpp = atoi(value); else if (!SDL_strcasecmp(command, "FREQUENCY")) m_Config.frequency = atoi(value); else if (!SDL_strcasecmp(command, "SOFTWARE_CURSOR")) m_Config.is_software_cursor = atoi(value) ? true : false; else if (!SDL_strcasecmp(command, "OBJECT_CULLING")) m_Config.is_object_culling = atoi(value) ? true : false; else if (!SDL_strcasecmp(command, "VISIBILITY")) m_Config.iDistance = atoi(value); else if (!SDL_strcasecmp(command, "MUSIC_VOLUME")) { if (strchr(value, '.') == 0) { // Old compatiability m_Config.music_volume = std::pow(10.0f, (-1.0f + (((float)atoi(value)) / 5.0f))); if (atoi(value) == 0) m_Config.music_volume = 0.0f; } else m_Config.music_volume = float(atof(value)); } else if (!SDL_strcasecmp(command, "VOICE_VOLUME")) m_Config.voice_volume = uint8_t(char(atoi(value))); else if (!SDL_strcasecmp(command, "GAMMA")) m_Config.gamma = atoi(value); else if (!SDL_strcasecmp(command, "IS_SAVE_ID")) m_Config.isSaveID = atoi(value); else if (!SDL_strcasecmp(command, "SAVE_ID")) strncpy(m_Config.SaveID, value, 20); else if (!SDL_strcasecmp(command, "PRE_LOADING_DELAY_TIME")) g_iLoadingDelayTime = atoi(value); else if (!SDL_strcasecmp(command, "WINDOWED")) m_Config.bWindowed = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "USE_DEFAULT_IME")) m_Config.bUseDefaultIME = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SOFTWARE_TILING")) m_Config.bSoftwareTiling = uint8_t(atoi(value)); else if (!SDL_strcasecmp(command, "SHADOW_LEVEL")) m_Config.iShadowLevel = atoi(value); else if (!SDL_strcasecmp(command, "DECOMPRESSED_TEXTURE")) m_Config.bDecompressDDS = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "NO_SOUND_CARD")) m_Config.bNoSoundCard = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "VIEW_CHAT")) m_Config.bViewChat = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "ALWAYS_VIEW_NAME")) m_Config.bAlwaysShowName = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_DAMAGE")) m_Config.bShowDamage = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_SALESTEXT")) m_Config.bShowSalesText = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_OUTLINE")) m_Config.bShowOutline = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_MOBAIFLAG")) m_Config.bShowMobAIFlag = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_MOBLEVEL")) m_Config.bShowMobLevel = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SNOW_TEXTURE_MODE")) m_Config.bSnowTexturesMode = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "SHOW_SHADOW")) m_Config.bShowShadow = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "QUEST_LETTER")) m_Config.questLetter = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "COUNTRY_FLAG")) m_Config.countryFlag = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "AFFECT_ICONS")) m_Config.affectIcons = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "shop_range")) m_Config.shopnames_range = uint8_t(atoi(value)); else if (!SDL_strcasecmp(command, "perspective")) m_Config.iFOVLevel = float(atof(value)); else if (!SDL_strcasecmp(command, "effect_level")) m_Config.iEffectLevel = uint8_t(atoi(value)); else if (!SDL_strcasecmp(command, "pet_status")) m_Config.bPetStatus = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "mount_status")) m_Config.bMountStatus = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "npc_status")) m_Config.bNpcStatus = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "night_mode")) m_Config.bNightMode = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "special_message")) m_Config.bMessage = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "DUNGEON_TRACK")) m_Config.bDungeonTrack = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "BOSS_TRACK")) m_Config.bBossTrack = atoi(value) == 1 ? true : false; else if (!SDL_strcasecmp(command, "OBJECT_DIST")) m_Config.fobjectDist = float(atof(value) > 25600.0 ? 25600.0 : atof(value)); } if (m_Config.bWindowed && SDL_WasInit(SDL_INIT_VIDEO)) { // GetSystemMetrics(SM_CXFULLSCREEN / SM_CYFULLSCREEN): the primary display's client area. SDL_Rect bounds{}; if (SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &bounds)) { const unsigned screen_width = unsigned(bounds.w); const unsigned screen_height = unsigned(bounds.h); if (m_Config.width >= screen_width) m_Config.width = screen_width; if (m_Config.height >= screen_height) m_Config.height = screen_height; } } m_OldConfig = m_Config; fclose(fp); return true; } bool CPythonSystem::SaveConfig() { FILE* fp = fopen(__ConfigPath("metin2.cfg").c_str(), "wt"); if (!fp) return false; fprintf(fp, "WIDTH %d\n" "HEIGHT %d\n" "BPP %d\n" "FREQUENCY %d\n" "SOFTWARE_CURSOR %d\n" "OBJECT_CULLING %d\n" "VISIBILITY %d\n" "MUSIC_VOLUME %.3f\n" "VOICE_VOLUME %d\n" "GAMMA %d\n" "IS_SAVE_ID %d\n" "SAVE_ID %s\n" "PRE_LOADING_DELAY_TIME %d\n" "DECOMPRESSED_TEXTURE %d\n", int(m_Config.width), int(m_Config.height), int(m_Config.bpp), int(m_Config.frequency), int(m_Config.is_software_cursor), int(m_Config.is_object_culling), m_Config.iDistance, double(m_Config.music_volume), int(m_Config.voice_volume), m_Config.gamma, m_Config.isSaveID, m_Config.SaveID, g_iLoadingDelayTime, int(m_Config.bDecompressDDS)); if (m_Config.bWindowed == 1) fprintf(fp, "WINDOWED %d\n", int(m_Config.bWindowed)); if (m_Config.bViewChat == 0) fprintf(fp, "VIEW_CHAT %d\n", int(m_Config.bViewChat)); if (m_Config.bAlwaysShowName != DEFAULT_VALUE_ALWAYS_SHOW_NAME) fprintf(fp, "ALWAYS_VIEW_NAME %d\n", int(m_Config.bAlwaysShowName)); if (m_Config.bShowDamage == 0) fprintf(fp, "SHOW_DAMAGE %d\n", int(m_Config.bShowDamage)); if (m_Config.bShowSalesText == 0) fprintf(fp, "SHOW_SALESTEXT %d\n", int(m_Config.bShowSalesText)); if (m_Config.bShowMobAIFlag == 0) fprintf(fp, "SHOW_MOBAIFLAG %d\n", int(m_Config.bShowMobAIFlag)); if (m_Config.bShowMobLevel == 0) fprintf(fp, "SHOW_MOBLEVEL %d\n", int(m_Config.bShowMobLevel)); fprintf(fp, "SHOW_OUTLINE %d\n", int(m_Config.bShowOutline)); fprintf(fp, "USE_DEFAULT_IME %d\n", int(m_Config.bUseDefaultIME)); fprintf(fp, "SOFTWARE_TILING %d\n", int(m_Config.bSoftwareTiling)); fprintf(fp, "SHADOW_LEVEL %d\n", m_Config.iShadowLevel); fprintf(fp, "SNOW_TEXTURE_MODE %d\n", int(m_Config.bSnowTexturesMode)); fprintf(fp, "SHOW_SHADOW %d\n", int(m_Config.bShowShadow)); fprintf(fp, "shop_range\t%d\n", int(m_Config.shopnames_range)); fprintf(fp, "QUEST_LETTER %d\n", int(m_Config.questLetter)); fprintf(fp, "COUNTRY_FLAG %d\n", int(m_Config.countryFlag)); fprintf(fp, "AFFECT_ICONS %d\n", int(m_Config.affectIcons)); fprintf(fp, "perspective\t%.1f\n", double(m_Config.iFOVLevel)); fprintf(fp, "effect_level\t%d\n", int(m_Config.iEffectLevel)); fprintf(fp, "pet_status\t%d\n", int(m_Config.bPetStatus)); fprintf(fp, "mount_status\t%d\n", int(m_Config.bMountStatus)); fprintf(fp, "npc_status\t%d\n", int(m_Config.bNpcStatus)); fprintf(fp, "night_mode\t%d\n", int(m_Config.bNightMode)); fprintf(fp, "special_message\t%d\n", int(m_Config.bMessage)); fprintf(fp, "DUNGEON_TRACK\t%d\n", int(m_Config.bDungeonTrack)); fprintf(fp, "BOSS_TRACK\t%d\n", int(m_Config.bBossTrack)); fprintf(fp, "OBJECT_DIST\t%.5f\n", double(m_Config.fobjectDist)); fprintf(fp, "\n"); fclose(fp); return true; } bool CPythonSystem::LoadInterfaceStatus() { FILE* File = fopen(__ConfigPath("interface.cfg").c_str(), "rb"); if (!File) return false; // fread of the Win32 TWindowStatus[WINDOW_MAX_NUM]; a short file fills only its whole leading bytes. unsigned char raw[sizeof(int32_t) * 5 * WINDOW_MAX_NUM] = {}; const size_t read = fread(raw, 1, sizeof(raw), File); fclose(File); for (size_t i = 0; i < WINDOW_MAX_NUM; ++i) { int32_t* fields[5] = { &m_WindowStatus[i].isVisible, &m_WindowStatus[i].isMinimized, &m_WindowStatus[i].ixPosition, &m_WindowStatus[i].iyPosition, &m_WindowStatus[i].iHeight, }; for (size_t f = 0; f < 5; ++f) { const size_t offset = (i * 5 + f) * sizeof(int32_t); if (offset + sizeof(int32_t) <= read) *fields[f] = GetInt32(raw + offset); } } return true; } void CPythonSystem::SaveInterfaceStatus() { if (!m_poInterfaceHandler) return; PyCallClassMemberFunc(m_poInterfaceHandler, "OnSaveInterfaceStatus", Py_BuildValue("()")); FILE* File = fopen(__ConfigPath("interface.cfg").c_str(), "wb"); if (!File) { SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Cannot open interface.cfg"); return; } unsigned char raw[sizeof(int32_t) * 5 * WINDOW_MAX_NUM]; for (size_t i = 0; i < WINDOW_MAX_NUM; ++i) { const TWindowStatus& s = m_WindowStatus[i]; const int32_t fields[5] = { s.isVisible, s.isMinimized, s.ixPosition, s.iyPosition, s.iHeight }; for (size_t f = 0; f < 5; ++f) PutInt32(raw + (i * 5 + f) * sizeof(int32_t), fields[f]); } fwrite(raw, 1, sizeof(raw), File); fclose(File); } bool CPythonSystem::isInterfaceConfig() { return m_isInterfaceConfig; } const CPythonSystem::TWindowStatus& CPythonSystem::GetWindowStatusReference(int iIndex) { // Windows returns m_WindowStatus[iIndex] unchecked; out of range reads a zeroed status here. static const TWindowStatus s_kEmpty = {}; if (iIndex < 0 || iIndex >= WINDOW_MAX_NUM) return s_kEmpty; return m_WindowStatus[iIndex]; } void CPythonSystem::ApplyConfig() { if (m_OldConfig.gamma != m_Config.gamma) { float val = 1.0f; switch (m_Config.gamma) { case 0: val = 0.4f; break; case 1: val = 0.7f; break; case 2: val = 1.0f; break; case 3: val = 1.2f; break; case 4: val = 1.4f; break; } // CPythonGraphic::SetGamma (D3D gamma ramp): no gamma ramp in the SDL renderer yet. m_fAppliedGamma = val; } // is_software_cursor -> CPythonApplication::SetCursorMode: the port always uses the system cursor. m_OldConfig = m_Config; ChangeSystem(); } void CPythonSystem::ChangeSystem() { SoundManager& rkSndMgr = SoundManager::Instance(); rkSndMgr.SetMusicVolume(m_Config.music_volume); rkSndMgr.SetSoundVolumeGrade(m_Config.voice_volume); } void CPythonSystem::Clear() { SetInterfaceHandler(nullptr); } CPythonSystem::CPythonSystem() { Reload(); } void CPythonSystem::Reload() { memset(&m_Config, 0, sizeof(TConfig)); memset(m_WindowStatus, 0, sizeof(m_WindowStatus)); ClearDisplaySettings(); m_poInterfaceHandler = nullptr; m_fAppliedGamma = 0.0f; SetDefaultConfig(); // LoadConfig copies m_OldConfig only on success; without metin2.cfg Windows leaves it zeroed. memset(&m_OldConfig, 0, sizeof(TConfig)); LoadConfig(); ChangeSystem(); if (LoadInterfaceStatus()) m_isInterfaceConfig = true; else m_isInterfaceConfig = false; } // --------------------------------------------------------------------------------------------- // systemSetting module (PythonSystemModule.cpp) namespace { PyObject* systemGetWidth(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetWidth()); } PyObject* systemGetHeight(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetHeight()); } PyObject* systemSetInterfaceHandler(PyObject* poSelf, PyObject* poArgs) { PyObject* poHandler; if (!PyTuple_GetObject(poArgs, 0, &poHandler)) return Py_BuildException(); CPythonSystem::Instance().SetInterfaceHandler(poHandler); return Py_BuildNone(); } PyObject* systemDestroyInterfaceHandler(PyObject* poSelf, PyObject* poArgs) { CPythonSystem::Instance().DestroyInterfaceHandler(); return Py_BuildNone(); } PyObject* systemReserveResource(PyObject* poSelf, PyObject* poArgs) { return Py_BuildNone(); } PyObject* systemisInterfaceConfig(PyObject* poSelf, PyObject* poArgs) { int isInterfaceConfig = CPythonSystem::Instance().isInterfaceConfig(); return Py_BuildValue("i", isInterfaceConfig); } PyObject* systemSaveWindowStatus(PyObject* poSelf, PyObject* poArgs) { int iIndex; if (!PyTuple_GetInteger(poArgs, 0, &iIndex)) return Py_BuildException(); int iVisible; if (!PyTuple_GetInteger(poArgs, 1, &iVisible)) return Py_BuildException(); int iMinimized; if (!PyTuple_GetInteger(poArgs, 2, &iMinimized)) return Py_BuildException(); int ix; if (!PyTuple_GetInteger(poArgs, 3, &ix)) return Py_BuildException(); int iy; if (!PyTuple_GetInteger(poArgs, 4, &iy)) return Py_BuildException(); int iHeight; if (!PyTuple_GetInteger(poArgs, 5, &iHeight)) return Py_BuildException(); CPythonSystem::Instance().SaveWindowStatus(iIndex, iVisible, iMinimized, ix, iy, iHeight); return Py_BuildNone(); } PyObject* systemGetWindowStatus(PyObject* poSelf, PyObject* poArgs) { int iIndex; if (!PyTuple_GetInteger(poArgs, 0, &iIndex)) return Py_BuildException(); const CPythonSystem::TWindowStatus& c_rWindowStatus = CPythonSystem::Instance().GetWindowStatusReference(iIndex); return Py_BuildValue("iiiii", c_rWindowStatus.isVisible, c_rWindowStatus.isMinimized, c_rWindowStatus.ixPosition, c_rWindowStatus.iyPosition, c_rWindowStatus.iHeight); } PyObject* systemGetConfig(PyObject* poSelf, PyObject* poArgs) { CPythonSystem::TConfig* tmp = CPythonSystem::Instance().GetConfig(); int iRes = CPythonSystem::Instance().GetResolutionIndex(tmp->width, tmp->height, tmp->bpp); int iFrequency = CPythonSystem::Instance().GetFrequencyIndex(iRes, tmp->frequency); // Windows passes the float music_volume to an "i" slot of the 32-bit x86 varargs list: it is // promoted to a double that fills two int slots, so every later field shifts one place and // iDistance falls off the end. const double fMusicVolume = tmp->music_volume; uint64_t uBits; memcpy(&uBits, &fMusicVolume, sizeof(uBits)); return Py_BuildValue("iiiiiiii", iRes, iFrequency, int(tmp->is_software_cursor), int(tmp->is_object_culling), int(uint32_t(uBits)), int(uint32_t(uBits >> 32)), int(tmp->voice_volume), tmp->gamma); } PyObject* systemSetSaveID(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); char* szSaveID; if (!PyTuple_GetString(poArgs, 1, &szSaveID)) return Py_BuildException(); CPythonSystem::Instance().SetSaveID(iValue, szSaveID); return Py_BuildNone(); } PyObject* systemisSaveID(PyObject* poSelf, PyObject* poArgs) { int value = CPythonSystem::Instance().IsSaveID(); return Py_BuildValue("i", value); } PyObject* systemGetSaveID(PyObject* poSelf, PyObject* poArgs) { const char* c_szSaveID = CPythonSystem::Instance().GetSaveID(); return Py_BuildValue("s", c_szSaveID); } PyObject* systemGetMusicVolume(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("f", CPythonSystem::Instance().GetMusicVolume()); } PyObject* systemGetSoundVolume(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetSoundVolume()); } PyObject* systemSetMusicVolume(PyObject* poSelf, PyObject* poArgs) { float fVolume; if (!PyTuple_GetFloat(poArgs, 0, &fVolume)) return Py_BuildException(); CPythonSystem::Instance().SetMusicVolume(fVolume); return Py_BuildNone(); } PyObject* systemSetSoundVolumef(PyObject* poSelf, PyObject* poArgs) { float fVolume; if (!PyTuple_GetFloat(poArgs, 0, &fVolume)) return Py_BuildException(); CPythonSystem::Instance().SetSoundVolumef(fVolume); return Py_BuildNone(); } PyObject* systemIsSoftwareCursor(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsSoftwareCursor()); } PyObject* systemSetViewChatFlag(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetViewChatFlag(iFlag); return Py_BuildNone(); } PyObject* systemIsViewChat(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsViewChat()); } PyObject* systemSetAlwaysShowNameFlag(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetAlwaysShowNameFlag(iFlag); return Py_BuildNone(); } PyObject* systemSetShowDamageFlag(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetShowDamageFlag(iFlag); return Py_BuildNone(); } PyObject* systemSetShowSalesTextFlag(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetShowSalesTextFlag(iFlag); return Py_BuildNone(); } PyObject* systemIsShowMobAIFlag(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsShowMobAIFlag()); } PyObject* systemSetShowMobAIFlag(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetShowMobAIFlagFlag(iFlag); // Windows then calls MobInfoAiFlagRefresh on every enemy CInstanceBase; the port has no // CInstanceBase mob-info tail yet (PORT-PLAN pass 25). return Py_BuildNone(); } PyObject* systemIsShowMobLevel(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsShowMobLevel()); } PyObject* systemSetShowMobLevel(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetShowMobLevelFlag(iFlag); // Windows: MobInfoLevelRefresh on every enemy CInstanceBase (see systemSetShowMobAIFlag). return Py_BuildNone(); } PyObject* systemIsAlwaysShowName(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsAlwaysShowName()); } PyObject* systemIsShowDamage(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsShowDamage()); } PyObject* systemIsShowOutline(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("b", CPythonSystem::Instance().IsShowOutline()); } PyObject* systemSetShowOutlineFlag(PyObject* poSelf, PyObject* poArgs) { // The parse result is ignored on Windows (isShow stays uninitialised); false here. bool isShow = false; PyTuple_GetBoolean(poArgs, 0, &isShow); CPythonSystem::Instance().SetShowOutlineFlag(isShow); return Py_BuildNone(); } PyObject* systemIsShowSalesText(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsShowSalesText()); } PyObject* systemIsSnowTexturesMode(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().IsSnowTexturesMode()); } PyObject* systemSetSnowTexturesMode(PyObject* poSelf, PyObject* poArgs) { int iFlag; if (!PyTuple_GetInteger(poArgs, 0, &iFlag)) return Py_BuildException(); CPythonSystem::Instance().SetSnowTexturesMode(iFlag); return Py_BuildNone(); } PyObject* systemSetConfig(PyObject* poSelf, PyObject* poArgs) { int res_index; uint32_t width; uint32_t height; uint32_t bpp; int frequency_index; uint32_t frequency; int software_cursor; int shadow; int object_culling; int music_volume; int voice_volume; int gamma; int distance; if (!PyTuple_GetInteger(poArgs, 0, &res_index)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 1, &frequency_index)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 2, &software_cursor)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 3, &shadow)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 4, &object_culling)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 5, &music_volume)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 6, &voice_volume)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 7, &gamma)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 8, &distance)) return Py_BuildException(); if (!CPythonSystem::Instance().GetResolution(res_index, &width, &height, &bpp)) return Py_BuildNone(); if (!CPythonSystem::Instance().GetFrequency(res_index, frequency_index, &frequency)) return Py_BuildNone(); CPythonSystem::TConfig tmp; memcpy(&tmp, CPythonSystem::Instance().GetConfig(), sizeof(tmp)); tmp.width = width; tmp.height = height; tmp.bpp = bpp; tmp.frequency = frequency; tmp.is_software_cursor = software_cursor ? true : false; tmp.is_object_culling = object_culling ? true : false; tmp.music_volume = (char)music_volume; tmp.voice_volume = uint8_t((char)voice_volume); tmp.gamma = gamma; tmp.iDistance = distance; CPythonSystem::Instance().SetConfig(&tmp); return Py_BuildNone(); } PyObject* systemApplyConfig(PyObject* poSelf, PyObject* poArgs) { CPythonSystem::Instance().ApplyConfig(); return Py_BuildNone(); } PyObject* systemSaveConfig(PyObject* poSelf, PyObject* poArgs) { int ret = CPythonSystem::Instance().SaveConfig(); return Py_BuildValue("i", ret); } PyObject* systemGetResolutionCount(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetResolutionCount()); } PyObject* systemGetFrequencyCount(PyObject* poSelf, PyObject* poArgs) { int index; if (!PyTuple_GetInteger(poArgs, 0, &index)) return Py_BuildException(); return Py_BuildValue("i", CPythonSystem::Instance().GetFrequencyCount(index)); } PyObject* systemGetResolution(PyObject* poSelf, PyObject* poArgs) { int index; uint32_t width = 0, height = 0, bpp = 0; if (!PyTuple_GetInteger(poArgs, 0, &index)) return Py_BuildException(); CPythonSystem::Instance().GetResolution(index, &width, &height, &bpp); return Py_BuildValue("iii", width, height, bpp); } PyObject* systemGetCurrentResolution(PyObject* poSelf, PyObject* poArgs) { CPythonSystem::TConfig* tmp = CPythonSystem::Instance().GetConfig(); return Py_BuildValue("iii", tmp->width, tmp->height, tmp->bpp); } PyObject* systemGetFrequency(PyObject* poSelf, PyObject* poArgs) { int index, frequency_index; uint32_t frequency = 0; if (!PyTuple_GetInteger(poArgs, 0, &index)) return Py_BuildException(); if (!PyTuple_GetInteger(poArgs, 1, &frequency_index)) return Py_BuildException(); CPythonSystem::Instance().GetFrequency(index, frequency_index, &frequency); return Py_BuildValue("i", frequency); } PyObject* systemGetShadowLevel(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetShadowLevel()); } PyObject* systemSetShadowLevel(PyObject* poSelf, PyObject* poArgs) { int level; if (!PyTuple_GetInteger(poArgs, 0, &level)) return Py_BuildException(); if (level > 0) CPythonSystem::Instance().SetShadowLevel(level); return Py_BuildNone(); } PyObject* systemIsShowShadow(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("b", CPythonSystem::Instance().IsShadow()); } PyObject* systemSetShowShadow(PyObject* poSelf, PyObject* poArgs) { bool isShow = false; PyTuple_GetBoolean(poArgs, 0, &isShow); CPythonSystem::Instance().SetShadow(isShow); return Py_BuildNone(); } PyObject* systemSetShopNamesRange(PyObject* poSelf, PyObject* poArgs) { unsigned char fIndex; if (!PyTuple_GetByte(poArgs, 0, &fIndex)) return Py_BuildException(); CPythonSystem::Instance().SetShopNamesRange(fIndex); return Py_BuildNone(); } PyObject* systemGetShopNamesRange(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetShopNamesRange()); } PyObject* systemSetQuestIconMode(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetQuestLetter(iValue ? true : false); return Py_BuildNone(); } PyObject* systemGetQuestIconMode(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetQuestLetter()); } PyObject* systemSetCountryFlag(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetCountryFlag(iValue ? true : false); return Py_BuildNone(); } PyObject* systemGetCountryFlag(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetCountryFlag()); } PyObject* systemSetAffectIcons(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetAffectIcons(iValue ? true : false); return Py_BuildNone(); } PyObject* systemGetAffectIcons(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetAffectIcons()); } PyObject* systemSetFOVLevel(PyObject* poSelf, PyObject* poArgs) { float fFOV; if (!PyTuple_GetFloat(poArgs, 0, &fFOV)) return Py_BuildException(); CPythonSystem::Instance().SetFOVLevel(fFOV); return Py_BuildNone(); } PyObject* systemGetFOVLevel(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("f", CPythonSystem::Instance().GetFOVLevel()); } PyObject* systemSetEffectLevel(PyObject* poSelf, PyObject* poArgs) { unsigned char iIndex; if (!PyTuple_GetByte(poArgs, 0, &iIndex)) return Py_BuildException(); CPythonSystem::Instance().SetEffectLevel(iIndex); return Py_BuildNone(); } PyObject* systemGetEffectLevel(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetEffectLevel()); } PyObject* systemSetPetRender(PyObject* poSelf, PyObject* poArgs) { bool bFlag; if (!PyTuple_GetBoolean(poArgs, 0, &bFlag)) return Py_BuildException(); CPythonSystem::Instance().SetPetRender(bFlag); return Py_BuildNone(); } PyObject* systemGetPetRender(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetPetRender()); } PyObject* systemSetMountRender(PyObject* poSelf, PyObject* poArgs) { bool bFlag; if (!PyTuple_GetBoolean(poArgs, 0, &bFlag)) return Py_BuildException(); CPythonSystem::Instance().SetMountRender(bFlag); return Py_BuildNone(); } PyObject* systemGetMountRender(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetMountRender()); } PyObject* systemSetShopNameStatus(PyObject* poSelf, PyObject* poArgs) { bool bFlag; if (!PyTuple_GetBoolean(poArgs, 0, &bFlag)) return Py_BuildException(); CPythonSystem::Instance().SetShopNameStatus(bFlag); return Py_BuildNone(); } PyObject* systemGetShopNameStatus(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetShopNameStatus()); } PyObject* systemSetNightMode(PyObject* poSelf, PyObject* poArgs) { bool bFlag; if (!PyTuple_GetBoolean(poArgs, 0, &bFlag)) return Py_BuildException(); CPythonSystem::Instance().SetNightMode(bFlag); return Py_BuildNone(); } PyObject* systemGetNightMode(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetNightMode()); } PyObject* systemSetStuffMessage(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetStuffMessage(iValue); return Py_BuildNone(); } PyObject* systemGetStuffMessage(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetStuffMessage()); } PyObject* systemSetDungeonTrack(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetDungeonTrack(iValue); return Py_BuildNone(); } PyObject* systemGetDungeonTrack(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetDungeonTrack()); } PyObject* systemSetBossTrack(PyObject* poSelf, PyObject* poArgs) { int iValue; if (!PyTuple_GetInteger(poArgs, 0, &iValue)) return Py_BuildException(); CPythonSystem::Instance().SetBossTrack(iValue); return Py_BuildNone(); } PyObject* systemGetBossTrack(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("i", CPythonSystem::Instance().GetBossTrack()); } PyObject* systemSetMapObjectDistance(PyObject* poSelf, PyObject* poArgs) { float fValue; if (!PyTuple_GetFloat(poArgs, 0, &fValue)) return Py_BuildException(); CPythonSystem::Instance().SetObjectDistance(fValue); return Py_BuildNone(); } PyObject* systemGetMapObjectDistance(PyObject* poSelf, PyObject* poArgs) { return Py_BuildValue("f", CPythonSystem::Instance().GetObjectDistance()); } } // namespace void initsystemSetting() { static PyMethodDef s_methods[] = { { "GetWidth", systemGetWidth, METH_VARARGS }, { "GetHeight", systemGetHeight, METH_VARARGS }, { "SetShadow", systemSetShowShadow, METH_VARARGS }, { "IsShadow", systemIsShowShadow, METH_VARARGS }, { "SetInterfaceHandler", systemSetInterfaceHandler, METH_VARARGS }, { "DestroyInterfaceHandler", systemDestroyInterfaceHandler, METH_VARARGS }, { "ReserveResource", systemReserveResource, METH_VARARGS }, { "isInterfaceConfig", systemisInterfaceConfig, METH_VARARGS }, { "SaveWindowStatus", systemSaveWindowStatus, METH_VARARGS }, { "GetWindowStatus", systemGetWindowStatus, METH_VARARGS }, { "GetResolutionCount", systemGetResolutionCount, METH_VARARGS }, { "GetFrequencyCount", systemGetFrequencyCount, METH_VARARGS }, { "GetCurrentResolution", systemGetCurrentResolution, METH_VARARGS }, { "GetResolution", systemGetResolution, METH_VARARGS }, { "GetFrequency", systemGetFrequency, METH_VARARGS }, { "ApplyConfig", systemApplyConfig, METH_VARARGS }, { "SetConfig", systemSetConfig, METH_VARARGS }, { "SaveConfig", systemSaveConfig, METH_VARARGS }, { "GetConfig", systemGetConfig, METH_VARARGS }, { "SetSaveID", systemSetSaveID, METH_VARARGS }, { "isSaveID", systemisSaveID, METH_VARARGS }, { "GetSaveID", systemGetSaveID, METH_VARARGS }, { "GetMusicVolume", systemGetMusicVolume, METH_VARARGS }, { "GetSoundVolume", systemGetSoundVolume, METH_VARARGS }, { "SetMusicVolume", systemSetMusicVolume, METH_VARARGS }, { "SetSoundVolumef", systemSetSoundVolumef, METH_VARARGS }, { "IsSoftwareCursor", systemIsSoftwareCursor, METH_VARARGS }, { "SetViewChatFlag", systemSetViewChatFlag, METH_VARARGS }, { "IsViewChat", systemIsViewChat, METH_VARARGS }, { "SetAlwaysShowNameFlag", systemSetAlwaysShowNameFlag, METH_VARARGS }, { "IsAlwaysShowName", systemIsAlwaysShowName, METH_VARARGS }, { "SetShowDamageFlag", systemSetShowDamageFlag, METH_VARARGS }, { "IsShowDamage", systemIsShowDamage, METH_VARARGS }, { "SetShowSalesTextFlag", systemSetShowSalesTextFlag, METH_VARARGS }, { "IsShowSalesText", systemIsShowSalesText, METH_VARARGS }, { "SetShowOutlineFlag", systemSetShowOutlineFlag, METH_VARARGS }, { "IsShowOutline", systemIsShowOutline, METH_VARARGS }, { "GetShadowLevel", systemGetShadowLevel, METH_VARARGS }, { "SetShadowLevel", systemSetShadowLevel, METH_VARARGS }, { "SetSnowTexturesMode", systemSetSnowTexturesMode, METH_VARARGS }, { "IsSnowTexturesMode", systemIsSnowTexturesMode, METH_VARARGS }, { "IsShowMobAIFlag", systemIsShowMobAIFlag, METH_VARARGS }, { "SetShowMobAIFlag", systemSetShowMobAIFlag, METH_VARARGS }, { "IsShowMobLevel", systemIsShowMobLevel, METH_VARARGS }, { "SetShowMobLevel", systemSetShowMobLevel, METH_VARARGS }, { "SetShopNamesRange", systemSetShopNamesRange, METH_VARARGS }, { "GetShopNamesRange", systemGetShopNamesRange, METH_VARARGS }, { "SetQuestIconMode", systemSetQuestIconMode, METH_VARARGS }, { "GetQuestIconMode", systemGetQuestIconMode, METH_VARARGS }, { "SetCountryFlag", systemSetCountryFlag, METH_VARARGS }, { "GetCountryFlag", systemGetCountryFlag, METH_VARARGS }, { "SetAffectIcons", systemSetAffectIcons, METH_VARARGS }, { "GetAffectIcons", systemGetAffectIcons, METH_VARARGS }, { "GetFOVLevel", systemGetFOVLevel, METH_VARARGS }, { "SetFOVLevel", systemSetFOVLevel, METH_VARARGS }, { "SetEffectLevel", systemSetEffectLevel, METH_VARARGS }, { "GetEffectLevel", systemGetEffectLevel, METH_VARARGS }, { "GetPetRender", systemGetPetRender, METH_VARARGS }, { "SetPetRender", systemSetPetRender, METH_VARARGS }, { "GetMountRender", systemGetMountRender, METH_VARARGS }, { "SetMountRender", systemSetMountRender, METH_VARARGS }, { "SetShopNameStatus", systemSetShopNameStatus, METH_VARARGS }, { "GetShopNameStatus", systemGetShopNameStatus, METH_VARARGS }, { "GetNightMode", systemGetNightMode, METH_VARARGS }, { "SetNightMode", systemSetNightMode, METH_VARARGS }, { "SetStuffMessage", systemSetStuffMessage, METH_VARARGS }, { "GetStuffMessage", systemGetStuffMessage, METH_VARARGS }, { "SetDungeonTrack", systemSetDungeonTrack, METH_VARARGS }, { "GetDungeonTrack", systemGetDungeonTrack, METH_VARARGS }, { "SetBossTrack", systemSetBossTrack, METH_VARARGS }, { "GetBossTrack", systemGetBossTrack, METH_VARARGS }, { "SetMapObjectDistance", systemSetMapObjectDistance, METH_VARARGS }, { "GetMapObjectDistance", systemGetMapObjectDistance, METH_VARARGS }, { NULL, NULL, 0 } }; PyObject* poModule = Py_InitModule("systemSetting", s_methods); PyModule_AddIntConstant(poModule, "WINDOW_STATUS", CPythonSystem::WINDOW_STATUS); PyModule_AddIntConstant(poModule, "WINDOW_INVENTORY", CPythonSystem::WINDOW_INVENTORY); PyModule_AddIntConstant(poModule, "WINDOW_ABILITY", CPythonSystem::WINDOW_ABILITY); PyModule_AddIntConstant(poModule, "WINDOW_SOCIETY", CPythonSystem::WINDOW_SOCIETY); PyModule_AddIntConstant(poModule, "WINDOW_JOURNAL", CPythonSystem::WINDOW_JOURNAL); PyModule_AddIntConstant(poModule, "WINDOW_COMMAND", CPythonSystem::WINDOW_COMMAND); PyModule_AddIntConstant(poModule, "WINDOW_QUICK", CPythonSystem::WINDOW_QUICK); PyModule_AddIntConstant(poModule, "WINDOW_GAUGE", CPythonSystem::WINDOW_GAUGE); PyModule_AddIntConstant(poModule, "WINDOW_MINIMAP", CPythonSystem::WINDOW_MINIMAP); PyModule_AddIntConstant(poModule, "WINDOW_CHAT", CPythonSystem::WINDOW_CHAT); } } // namespace ava2