trample Posted April 14, 2023 at 08:40 PM Share Posted April 14, 2023 at 08:40 PM Olá, já não sei mais o que fazer. Eu mexi tanto em uns arquivos que não tinha me deparado com um erro que provavelmente editei. Meus arquivos estão em Cython, o que se torna cansativo ter que compilar inúmeras vezes para poder encontrar o erro. Gostaria de saber se alguém tem um sistema de música, volume, ou algo do gênero, ou até mesmo se poderiam me dar referências de onde posso encontrar um sistema completo que me ajude a encontrar o erro. Ou, se alguém preferir, poderiam me ajudar chamando pelo Discord, pois também estou por lá. Meu Discord é Trample#5769 . Link to comment
trample Posted April 14, 2023 at 11:19 PM Author Share Posted April 14, 2023 at 11:19 PM tem como eu setar auto salvamento em outro arquivo m2.pyc da musica e ao mesmo tempo corrigir para que ele salve o volume toda vez que for modificado idependente da funçao ? Quote #include "StdAfx.h" #include "PythonSystem.h" #include "PythonApplication.h" #define DEFAULT_VALUE_ALWAYS_SHOW_NAME true void CPythonSystem::SetInterfaceHandler(PyObject* poHandler) { m_poInterfaceHandler = poHandler; } void CPythonSystem::DestroyInterfaceHandler() { m_poInterfaceHandler = NULL; } void CPythonSystem::SaveWindowStatus(int iIndex, int iVisible, int iMinimized, int ix, int iy, int iHeight) { 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::GetDisplaySettings() { memset(m_ResolutionList, 0, sizeof(TResolution) * RESOLUTION_MAX_NUM); m_ResolutionCount = 0; LPDIRECT3D8 lpD3D = CPythonGraphic::Instance().GetD3D(); D3DADAPTER_IDENTIFIER8 d3dAdapterIdentifier; D3DDISPLAYMODE d3ddmDesktop; lpD3D->GetAdapterIdentifier(0, D3DENUM_NO_WHQL_LEVEL, &d3dAdapterIdentifier); lpD3D->GetAdapterDisplayMode(0, &d3ddmDesktop); DWORD dwNumAdapterModes = lpD3D->GetAdapterModeCount(0); for (UINT iMode = 0; iMode < dwNumAdapterModes; iMode++) { D3DDISPLAYMODE DisplayMode; lpD3D->EnumAdapterModes(0, iMode, &DisplayMode); DWORD bpp = 0; if (DisplayMode.Width < 800 || DisplayMode.Height < 600) { continue; } if (DisplayMode.Format == D3DFMT_R5G6B5) { bpp = 16; } else if (DisplayMode.Format == D3DFMT_X8R8G8B8) { bpp = 32; } else { continue; } int check_res = false; for (int i = 0; !check_res && i < m_ResolutionCount; ++i) { if (m_ResolutionList[i].bpp != bpp || m_ResolutionList[i].width != DisplayMode.Width || m_ResolutionList[i].height != DisplayMode.Height) { continue; } int check_fre = false; for (int j = 0; j < m_ResolutionList[i].frequency_count; ++j) { if (m_ResolutionList[i].frequency[j] == DisplayMode.RefreshRate) { check_fre = true; break; } } if (!check_fre) { if (m_ResolutionList[i].frequency_count < FREQUENCY_MAX_NUM) { m_ResolutionList[i].frequency[m_ResolutionList[i].frequency_count++] = DisplayMode.RefreshRate; } } check_res = true; } if (!check_res) { if (m_ResolutionCount < RESOLUTION_MAX_NUM) { m_ResolutionList[m_ResolutionCount].width = DisplayMode.Width; m_ResolutionList[m_ResolutionCount].height = DisplayMode.Height; m_ResolutionList[m_ResolutionCount].bpp = bpp; m_ResolutionList[m_ResolutionCount].frequency[0] = DisplayMode.RefreshRate; m_ResolutionList[m_ResolutionCount].frequency_count = 1; ++m_ResolutionCount; } } } } 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, OUT DWORD* width, OUT DWORD* height, OUT DWORD* 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, OUT DWORD* 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(DWORD width, DWORD height, DWORD bit) { DWORD 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, DWORD frequency) { DWORD re_frequency; int i = 0; while (GetFrequency(res_index, i, &re_frequency)) { if (re_frequency == frequency) { return i; } i++; } return 0; } DWORD CPythonSystem::GetWidth() { return m_Config.width; } DWORD CPythonSystem::GetHeight() { return m_Config.height; } DWORD CPythonSystem::GetBPP() { return m_Config.bpp; } DWORD 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 = int (5 * fVolume); } void CPythonSystem::SetSoundVolumef(float fVolume) { m_Config.voice_volume = 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 = MIN(level, 5); CPythonBackground::instance().RefreshShadowLevel(); } #ifdef ENABLE_SHOPNAMES_RANGE void CPythonSystem::SetShopNamesRange(float fRange) { m_Config.shopnames_range = fRange; } float CPythonSystem::GetShopNamesRange() { return m_Config.shopnames_range; } #endif 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_s(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 = 5; m_Config.voice_volume = 5; m_Config.bDecompressDDS = 0; m_Config.bSoftwareTiling = 0; m_Config.iShadowLevel = 3; m_Config.bViewChat = true; m_Config.bAlwaysShowName = true; m_Config.bShowDamage = true; m_Config.bShowSalesText = true; #ifdef ENABLE_SHOPNAMES_RANGE m_Config.shopnames_range = 0.0f; #endif #ifdef ENABLE_FOG_FIX m_Config.bFogMode = false; #endif m_Config.bEnableNight = false; m_Config.bEnableSnow = false; m_Config.bEnableSnowTexture = false; m_Config.bShowMoneyLog = true; } 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; } bool CPythonSystem::IsEnableSnowFall() { return m_Config.bEnableSnow; } void CPythonSystem::SetEnableSnowFall(int iFlag) { m_Config.bEnableSnow = iFlag == 1 ? true : false; } void CPythonSystem::SetShowSalesTextFlag(int iFlag) { m_Config.bShowSalesText = iFlag == 1 ? true : false; } #ifdef ENABLE_FOG_FIX void CPythonSystem::SetFogMode(int iFlag) { m_Config.bFogMode = iFlag == 1 ? true : false; } bool CPythonSystem::IsFogMode() { return m_Config.bFogMode; } #endif bool CPythonSystem::IsEnableNightMode() { return m_Config.bEnableNight; } void CPythonSystem::SetEnableNightMode(int iFlag) { m_Config.bEnableNight = iFlag == 1 ? true : false; } bool CPythonSystem::IsEnableSnowTexture() { return m_Config.bEnableSnowTexture; } void CPythonSystem::SetEnableeSnowTexture(int iFlag) { m_Config.bEnableSnowTexture = iFlag == 1 ? true : false; } bool CPythonSystem::IsShowMoneyLog() { return m_Config.bShowMoneyLog; } void CPythonSystem::SetShowMoneyLog(int iFlag) { m_Config.bShowMoneyLog = 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; } bool CPythonSystem::LoadConfig() { FILE* fp = NULL; if (NULL == (fp = fopen("lib/m2.pyc", "rt"))) { return false; } char buf[256]; char command[256]; char value[256]; while (fgets(buf, 256, fp)) { if (sscanf(buf, " %s %s\n", command, value) == EOF) { break; } if (!stricmp(command, "WIDTH")) { m_Config.width = atoi(value); } else if (!stricmp(command, "HEIGHT")) { m_Config.height = atoi(value); } else if (!stricmp(command, "BPP")) { m_Config.bpp = atoi(value); } else if (!stricmp(command, "FREQUENCY")) { m_Config.frequency = atoi(value); } else if (!stricmp(command, "SOFTWARE_CURSOR")) { m_Config.is_software_cursor = atoi(value) ? true : false; } else if (!stricmp(command, "OBJECT_CULLING")) { m_Config.is_object_culling = atoi(value) ? true : false; } else if (!stricmp(command, "VISIBILITY")) { m_Config.iDistance = atoi(value); } else if (!stricmp(command, "MUSIC_VOLUME")) { m_Config.music_volume = (char)atoi(value); } else if (!stricmp(command, "VOICE_VOLUME")) { m_Config.voice_volume = (char)atoi(value); } else if (!stricmp(command, "GAMMA")) { m_Config.gamma = atoi(value); } else if (!stricmp(command, "IS_SAVE_ID")) { m_Config.isSaveID = atoi(value); } else if (!stricmp(command, "SAVE_ID")) { strncpy_s(m_Config.SaveID, value, 20); } else if (!stricmp(command, "PRE_LOADING_DELAY_TIME")) { g_iLoadingDelayTime = atoi(value); } else if (!stricmp(command, "WINDOWED")) { m_Config.bWindowed = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "USE_DEFAULT_IME")) { m_Config.bUseDefaultIME = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SOFTWARE_TILING")) { m_Config.bSoftwareTiling = atoi(value); } else if (!stricmp(command, "SHADOW_LEVEL")) { m_Config.iShadowLevel = atoi(value); } else if (!stricmp(command, "DECOMPRESSED_TEXTURE")) { m_Config.bDecompressDDS = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "NO_SOUND_CARD")) { m_Config.bNoSoundCard = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "VIEW_CHAT")) { m_Config.bViewChat = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "ALWAYS_VIEW_NAME")) { m_Config.bAlwaysShowName = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SHOW_DAMAGE")) { m_Config.bShowDamage = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SHOW_SALESTEXT")) { m_Config.bShowSalesText = atoi(value) == 1 ? true : false; } #ifdef ENABLE_SHOPNAMES_RANGE else if (!stricmp(command, "SHOPNAMES_RANGE")) { if(strchr(value, '.') == 0) { m_Config.shopnames_range = pow(10.0f, (-1.0f + (((float) atoi(value)) / 5.0f))); if(atoi(value) == 0) { m_Config.shopnames_range = 0.0f; } } else { m_Config.shopnames_range = atof(value); } } #endif else if (!stricmp(command, "NIGHT_MODE_ON")) { m_Config.bEnableNight = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SNOW_MODE_ON")) { m_Config.bEnableSnow = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SNOW_TEXTURE_MODE")) { m_Config.bEnableSnowTexture = atoi(value) == 1 ? true : false; } else if (!stricmp(command, "SHOW_MONEY_LOG")) { m_Config.bShowMoneyLog = atoi(value) == 1 ? true : false; } #ifdef ENABLE_FOG_FIX else if (!stricmp(command, "FOG_MODE_ON")) { m_Config.bFogMode = atoi(value) == 1 ? true : false; } #endif } if (m_Config.bWindowed) { unsigned screen_width = GetSystemMetrics(SM_CXFULLSCREEN); unsigned screen_height = GetSystemMetrics(SM_CYFULLSCREEN); 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; if (NULL == (fp = fopen("lib/m2.pyc", "wt"))) { 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 %d\n" "VOICE_VOLUME %d\n" "GAMMA %d\n" #ifdef ENABLE_SHOPNAMES_RANGE "SHOPNAMES_RANGE %.3f\n" #endif "NIGHT_MODE_ON %d\n" "SNOW_MODE_ON %d\n" "SNOW_TEXTURE_MODE %d\n" "SHOW_MONEY_LOG %d\n", m_Config.width, m_Config.height, m_Config.bpp, m_Config.frequency, m_Config.is_software_cursor, m_Config.is_object_culling, m_Config.iDistance, m_Config.music_volume, m_Config.voice_volume, m_Config.gamma, #ifdef ENABLE_SHOPNAMES_RANGE m_Config.shopnames_range, #endif m_Config.bEnableNight, m_Config.bEnableSnow, m_Config.bEnableSnowTexture ); if (m_Config.bWindowed == 1) { fprintf(fp, "WINDOWED %d\n", m_Config.bWindowed); } if (m_Config.bViewChat == 0) { fprintf(fp, "VIEW_CHAT %d\n", m_Config.bViewChat); } if (m_Config.bAlwaysShowName == 0) { fprintf(fp, "ALWAYS_VIEW_NAME %d\n", m_Config.bAlwaysShowName); } if (m_Config.bShowDamage == 0) { fprintf(fp, "SHOW_DAMAGE %d\n", m_Config.bShowDamage); } if (m_Config.bShowSalesText == 0) { fprintf(fp, "SHOW_SALESTEXT %d\n", m_Config.bShowSalesText); } #ifdef ENABLE_FOG_FIX if (m_Config.bFogMode == 0) { fprintf(fp, "FOG_MODE_ON %d\n", m_Config.bFogMode); } #endif fprintf(fp, "USE_DEFAULT_IME %d\n", m_Config.bUseDefaultIME); fprintf(fp, "SOFTWARE_TILING %d\n", m_Config.bSoftwareTiling); fprintf(fp, "SHADOW_LEVEL %d\n", m_Config.iShadowLevel); fprintf(fp, "\n"); fclose(fp); return true; } bool CPythonSystem::LoadInterfaceStatus() { FILE* File; File = fopen("interface.cfg", "rb"); if (!File) { return false; } fread(m_WindowStatus, 1, sizeof(TWindowStatus) * WINDOW_MAX_NUM, File); fclose(File); return true; } void CPythonSystem::SaveInterfaceStatus() { if (!m_poInterfaceHandler) { return; } PyCallClassMemberFunc(m_poInterfaceHandler, "OnSaveInterfaceStatus", Py_BuildValue("()")); FILE* File; File = fopen("interface.cfg", "wb"); if (!File) { TraceError("Cannot open interface.cfg"); return; } fwrite(m_WindowStatus, 1, sizeof(TWindowStatus) * WINDOW_MAX_NUM, File); fclose(File); } bool CPythonSystem::isInterfaceConfig() { return m_isInterfaceConfig; } const CPythonSystem::TWindowStatus & CPythonSystem::GetWindowStatusReference(int iIndex) { 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::Instance().SetGamma(val); } if (m_OldConfig.is_software_cursor != m_Config.is_software_cursor) { if (m_Config.is_software_cursor) { CPythonApplication::Instance().SetCursorMode(CPythonApplication::CURSOR_MODE_SOFTWARE); } else { CPythonApplication::Instance().SetCursorMode(CPythonApplication::CURSOR_MODE_HARDWARE); } } m_OldConfig = m_Config; ChangeSystem(); } void CPythonSystem::ChangeSystem() { CSoundManager &rkSndMgr = CSoundManager::Instance(); rkSndMgr.SetMusicVolume(m_Config.music_volume); rkSndMgr.SetSoundVolumeGrade(m_Config.voice_volume); } void CPythonSystem::Clear() { SetInterfaceHandler(NULL); } CPythonSystem::CPythonSystem() { memset(&m_Config, 0, sizeof(TConfig)); m_poInterfaceHandler = NULL; SetDefaultConfig(); LoadConfig(); ChangeSystem(); if (LoadInterfaceStatus()) { m_isInterfaceConfig = true; } else { m_isInterfaceConfig = false; } } CPythonSystem::~CPythonSystem() { assert(m_poInterfaceHandler == NULL && "CPythonSystem MUST CLEAR!"); } Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now