diff --git a/GSChaos/CFeatureCreepypasta.cpp b/GSChaos/CFeatureCreepypasta.cpp index 5eb6591b..acea2cba 100644 --- a/GSChaos/CFeatureCreepypasta.cpp +++ b/GSChaos/CFeatureCreepypasta.cpp @@ -22,8 +22,8 @@ const char* CFeatureCreepypasta::GetFeatureName() void CFeatureCreepypasta::SwapBuffers() { - int width = ImGui::GetIO().DisplaySize.x; - int height = ImGui::GetIO().DisplaySize.y; + int width = gImGui.m_vecRealDisplaySize.x; + int height = gImGui.m_vecRealDisplaySize.y; glBlendFunc(GL_SRC_ALPHA, GL_ZERO); glEnable(GL_BLEND); @@ -49,6 +49,8 @@ void CFeatureCreepypasta::SwapBuffers() glEnable(GL_COLOR_LOGIC_OP); glLogicOp(GL_COPY_INVERTED); + + glViewport(0, 0, gImGui.m_vecRealDisplaySize.x, gImGui.m_vecRealDisplaySize.y); glBegin(GL_QUADS); glTexCoord2f(0, 0); @@ -79,6 +81,7 @@ void CFeatureCreepypasta::SwapBuffers() glEnd(); // Restore OpenGL states + glMatrixMode(GL_PROJECTION); glPopMatrix(); diff --git a/GSChaos/CFeatureGTA3HUD.cpp b/GSChaos/CFeatureGTA3HUD.cpp index 4c832f81..412bb2f8 100644 --- a/GSChaos/CFeatureGTA3HUD.cpp +++ b/GSChaos/CFeatureGTA3HUD.cpp @@ -182,6 +182,12 @@ void HOOKED_S_StartDynamicSound(int entnum, int entchannel, sfx_t* sfx, vec_t* o return; } + if (strstr(sfx->name, "items/9mmclip1.wav")) + { + ChaosLoud::EmitSound(SND_GTA_AMMO); + return; + } + if (strstr(sfx->name, "items/smallmedkit1.wav")) { ChaosLoud::EmitSound(g_bActivatedGTA3HUD ? SND_GTA3_ITEM_PICKUP : SND_GTAVC_ITEM_PICKUP); @@ -328,6 +334,8 @@ void CFeatureGTA3HUD::ActivateFeature() m_bActivated = true; + m_flFlashHealthTime = 0.0f; + g_bActivatedGTAVCHUD = false; g_bActivatedGTA3HUD = false; @@ -361,6 +369,8 @@ void CFeatureGTA3HUD::Draw() if (CLWrapper::GetPausedState()) return; + static int oldHealth; + DrawNotify(); ImVec4 armorColor = g_bActivatedGTA3HUD ? ImVec4(GTA3_HUD_ARMOR_COLOR, 255.0f / 255.0f) : ImVec4(GTAVC_HUD_ARMOR_COLOR, 255.0f / 255.0f); @@ -408,11 +418,19 @@ void CFeatureGTA3HUD::Draw() GLuint textureID = g_bActivatedGTA3HUD ? g_ActiveWeapon->iiiTextureID : g_ActiveWeapon->vcTextureID; - if ((gChaos.GetFrameCount() & 16) && (*sv_player)->v.health < 10.0f) + int health = (int)(*sv_player)->v.health; + int armor = (int)(*sv_player)->v.armorvalue; + + if (oldHealth > health) + m_flFlashHealthTime = pEngfuncs->GetAbsoluteTime() + 0.25f; + + if ((ImGui::GetFrameCount() & 8) && (health < 10.0f || m_flFlashHealthTime > pEngfuncs->GetAbsoluteTime())) m_bFlashHealth = true; else m_bFlashHealth = false; + oldHealth = health; + ImVec2 screenPos = ImVec2(ImGui::GetIO().DisplaySize.x - 384, ImGui::GetIO().DisplaySize.y - (ImGui::GetIO().DisplaySize.y / 1.05f)); ImGui::SetNextWindowPos(screenPos, ImGuiCond_Always); @@ -420,20 +438,20 @@ void CFeatureGTA3HUD::Draw() if (ImGui::Begin("#GTAHUD", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoSavedSettings)) { ImVec2 previousPos, curPos; - static ImVec2 iconPos = ImVec2(0.0f,0.0f); + static ImVec2 iconPos = ImVec2(0.0f, 0.0f); ImGui::Spacing(); ImGui::Spacing(); //========================== - + // DRAW ARMOR (FOR POSITION) ImGui::Image((void*)nullptr, ImVec2(56.0f / 1.75f, 51.0f / 1.75f)); ImGui::SameLine(); ImGui::PushFont(gChaos.m_pPricedown); - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", (int)(*sv_player)->v.armorvalue); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", armor); ImGui::PopFont(); @@ -445,7 +463,7 @@ void CFeatureGTA3HUD::Draw() ImGui::SameLine(); ImGui::PushFont(gChaos.m_pPricedown); - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", (int)(*sv_player)->v.health); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", health); ImGui::PopFont(); curPos = ImGui::GetCursorPos(); @@ -455,7 +473,7 @@ void CFeatureGTA3HUD::Draw() // DRAW WEAPON ICON ImGui::SameLine(); - + ImVec2 weaponIconPos = ImGui::GetCursorPos(); ImGui::Image((void*)textureID, ImVec2(128, 128)); @@ -464,7 +482,7 @@ void CFeatureGTA3HUD::Draw() // DRAW ARMOR ImGui::SetCursorPosY(curPos.y + 24.0f); - if ((*sv_player)->v.armorvalue > 0.0f) + if (armor > 0.0f) { ImVec2 armorIconPos = ImGui::GetCursorPos(); // SHADOW @@ -481,21 +499,21 @@ void CFeatureGTA3HUD::Draw() ImGui::SameLine(); ImGui::PushFont(gChaos.m_pPricedown); - if ((*sv_player)->v.armorvalue > 0.0f) + if (armor > 0) { ImVec2 armorPos = ImGui::GetCursorPos(); // SHADOW ImGui::SetCursorPos(ImVec2(armorPos.x + 2, armorPos.y + 2)); - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 255.0f / 255.0f), "%03d", (int)(*sv_player)->v.armorvalue); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 255.0f / 255.0f), "%03d", armor); // REAL ImGui::SetCursorPos(armorPos); - ImGui::TextColored(armorColor, "%03d", (int)(*sv_player)->v.armorvalue); + ImGui::TextColored(armorColor, "%03d", armor); } else - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", (int)(*sv_player)->v.armorvalue); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", armor); ImGui::PopFont(); @@ -522,31 +540,48 @@ void CFeatureGTA3HUD::Draw() if (m_bFlashHealth) { - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", (int)(*sv_player)->v.health); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 0.0f), "%03d", health); } else { ImVec2 healthPos = ImGui::GetCursorPos(); ImGui::SetCursorPos(ImVec2(healthPos.x + 2, healthPos.y + 2)); - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), "%03d", (int)(*sv_player)->v.health); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), "%03d", health); ImGui::SetCursorPos(healthPos); - ImGui::TextColored(healthColor, "%03d", (int)(*sv_player)->v.health); + ImGui::TextColored(healthColor, "%03d", health); } ImGui::PopFont(); // DRAW WEAPON AMMO - /* - ImGui::SetCursorPos(ImVec2(weaponIconPos.x + 64, weaponIconPos.y + 96)); - ImGui::PushFont(m_pArialBlack); - ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), "%i/%i", g_ActiveWeapon->iClip, g_ActiveWeapon->iAmmo); - ImGui::PopFont(); - - ImGui::GetForegroundDrawList()->AddText(m_pArialBlack, 24.0f, weaponIconPos, ImGui::GetColorU32(ImVec4(0.0f, 0.0f, 0.0f, 1.0f)), UTIL_VarArgs("%i/%i", g_ActiveWeapon->iClip, g_ActiveWeapon->iAmmo)); - */ + + // TODO: FINALLY GET PROPER AMMO/CLIP INFORMATION + if (g_bActivatedGTAVCHUD) + { + char buffer[16]; + //sprintf_s(buffer, "%d/%d", g_ActiveWeapon->iClip, g_ActiveWeapon->iAmmo); + sprintf_s(buffer, "69/420"); + + ImVec2 ammoTextSize = gChaos.m_pArborcrest->CalcTextSizeA(22.0f, FLT_MAX, 0.0f, buffer); + + ImVec2 centeredPos = ImVec2( + (weaponIconPos.x + 64) - (ammoTextSize.x / 2.0f), + (weaponIconPos.y + 144) - (ammoTextSize.y / 2.0f) + ); + + ImGui::SetCursorPos(ImVec2(centeredPos.x + 2.0f, centeredPos.y + 2.0f)); + ImGui::PushFont(gChaos.m_pArborcrest); + ImGui::TextColored(ImVec4(0.0f, 0.0f, 0.0f, 1.0f), "%s", buffer); + ImGui::PopFont(); + + ImGui::SetCursorPos(centeredPos); + ImGui::PushFont(gChaos.m_pArborcrest); + ImGui::TextColored(ImVec4(GTAVC_HUD_HEALTH_COLOR, 1.0f), "%s", buffer); + ImGui::PopFont(); + } + ImGui::End(); - //ImGui::GetWindowDrawList()->AddImage((void*)g_ActiveWeapon->textureID, ImVec2(0.0f, 0.0f), ImVec2(ImGui::GetIO().DisplaySize.x, ImGui::GetIO().DisplaySize.y), ImVec2(0, 0), ImVec2(1, 1)); } } diff --git a/GSChaos/CFeatureGTA3HUD.h b/GSChaos/CFeatureGTA3HUD.h index f97ad8af..af9b354e 100644 --- a/GSChaos/CFeatureGTA3HUD.h +++ b/GSChaos/CFeatureGTA3HUD.h @@ -57,6 +57,7 @@ class CFeatureGTA3HUD : public CChaosFeature bool m_bFlashHealth; bool m_bNotificationActive; double m_notifyStartTime; + float m_flFlashHealthTime; const char* m_notifyMessage; }; diff --git a/GSChaos/CFeatureMirrorScreen.cpp b/GSChaos/CFeatureMirrorScreen.cpp index 3fd2fb51..773c07b1 100644 --- a/GSChaos/CFeatureMirrorScreen.cpp +++ b/GSChaos/CFeatureMirrorScreen.cpp @@ -36,8 +36,8 @@ bool CFeatureMirrorScreen::UseCustomDuration() void CFeatureMirrorScreen::SwapBuffers() { - int width = ImGui::GetIO().DisplaySize.x; - int height = ImGui::GetIO().DisplaySize.y; + int width = gImGui.m_vecRealDisplaySize.x; + int height = gImGui.m_vecRealDisplaySize.y; glBlendFunc(GL_SRC_ALPHA, GL_ZERO); glEnable(GL_BLEND); @@ -64,6 +64,8 @@ void CFeatureMirrorScreen::SwapBuffers() glColor4f(1, 1, 1, 1); + glViewport(0, 0, gImGui.m_vecRealDisplaySize.x, gImGui.m_vecRealDisplaySize.y); + glBegin(GL_QUADS); glTexCoord2f(width, 0); diff --git a/GSChaos/CFeatureNightvision.cpp b/GSChaos/CFeatureNightvision.cpp index ab6f9466..7fa6ebf4 100644 --- a/GSChaos/CFeatureNightvision.cpp +++ b/GSChaos/CFeatureNightvision.cpp @@ -52,6 +52,12 @@ void CFeatureNightvision::Draw() if (!IsActive()) return; + if (m_nvSprite == NULL) + { + m_nvSprite = LoadSprite("../chaos/of_nv_b.spr"); + return; + } + // Top left of the screen. int x, y; x = y = 0; diff --git a/GSChaos/ChaosLoudManager.cpp b/GSChaos/ChaosLoudManager.cpp index fb96f6fe..f7dfeba2 100644 --- a/GSChaos/ChaosLoudManager.cpp +++ b/GSChaos/ChaosLoudManager.cpp @@ -34,6 +34,7 @@ namespace ChaosLoud g_wBank[SND_BEAMSTART5].load("chaos/beamstart5.wav"); g_wBank[SND_PAIN].load("chaos/pl_pain2.wav"); g_wBank[SND_XBOW_HIT].load("chaos/xbow_hit.wav"); + g_wBank[SND_GTA_AMMO].load("chaos/gta_ammo.wav"); } void EmitSound(int idx) diff --git a/GSChaos/ChaosLoudManager.h b/GSChaos/ChaosLoudManager.h index 80c5a8a7..be022cdd 100644 --- a/GSChaos/ChaosLoudManager.h +++ b/GSChaos/ChaosLoudManager.h @@ -33,6 +33,7 @@ enum SND_BEAMSTART5, SND_PAIN, SND_XBOW_HIT, + SND_GTA_AMMO, SOUNDBANK_SIZE }; diff --git a/GSChaos/GSChaos.cpp b/GSChaos/GSChaos.cpp index 7a3a0fc5..0f316bc1 100644 --- a/GSChaos/GSChaos.cpp +++ b/GSChaos/GSChaos.cpp @@ -221,6 +221,7 @@ int __stdcall HOOKED_wglSwapBuffers(HDC a1) // ------------------------- glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y); + ImGui::Render(); ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); } @@ -303,9 +304,11 @@ void HOOKED_HUD_Frame(double time) { gChaos.Init(); + ImVec2 realDisplaySize = gImGui.m_vecRealDisplaySize; + // create a load of blank pixels to create textures with - unsigned char* pBlankTex = new unsigned char[ImGui::GetIO().DisplaySize.x * ImGui::GetIO().DisplaySize.y * 3]; - memset(pBlankTex, 0, ImGui::GetIO().DisplaySize.x * ImGui::GetIO().DisplaySize.y * 3); + unsigned char* pBlankTex = new unsigned char[realDisplaySize.x * realDisplaySize.y * 3]; + memset(pBlankTex, 0, realDisplaySize.x * realDisplaySize.y * 3); // Create the SCREEN-HOLDING TEXTURE glBindTexture(GL_TEXTURE_RECTANGLE_NV, 32767); diff --git a/GSChaos/GSChaos.vcxproj.filters b/GSChaos/GSChaos.vcxproj.filters index 506ea005..aa1b92da 100644 --- a/GSChaos/GSChaos.vcxproj.filters +++ b/GSChaos/GSChaos.vcxproj.filters @@ -648,6 +648,9 @@ Effects + + Effects + @@ -1276,6 +1279,9 @@ Effects + + Effects + diff --git a/GSChaos/imgui_manager.cpp b/GSChaos/imgui_manager.cpp index feec9dd4..7d6e868b 100644 --- a/GSChaos/imgui_manager.cpp +++ b/GSChaos/imgui_manager.cpp @@ -35,8 +35,9 @@ bool CImGuiManager::CanUseEngineResolution() return (ScreenWidth > 0 && ScreenHeight > 0); } -void CImGuiManager::UpdateResolution(ImVec2& displaySize, ImVec2& frameBufferScale) +void CImGuiManager::UpdateResolution(ImVec2& displaySize, ImVec2& frameBufferScale, ImVec2 realDisplaySize) { + m_vecRealDisplaySize = realDisplaySize; displaySize = ImVec2(ScreenWidth, ScreenHeight); //frameBufferScale = ImVec2(1, 1); } @@ -62,7 +63,8 @@ void CImGuiManager::Draw() // ------------------------- - glViewport(0, 0, ScreenWidth, ScreenHeight); + glViewport(0, 0, (int)ImGui::GetIO().DisplaySize.x, (int)ImGui::GetIO().DisplaySize.y); + ImGui::Render(); ImGui_ImplOpenGL2_RenderDrawData(ImGui::GetDrawData()); } \ No newline at end of file diff --git a/GSChaos/imgui_manager.hpp b/GSChaos/imgui_manager.hpp index 407fe476..f8273bb7 100644 --- a/GSChaos/imgui_manager.hpp +++ b/GSChaos/imgui_manager.hpp @@ -19,8 +19,10 @@ class CImGuiManager void Init(); void InitBackends(void* hwnd); bool CanUseEngineResolution(); - void UpdateResolution(ImVec2& displaySize, ImVec2& frameBufferScale); + void UpdateResolution(ImVec2& displaySize, ImVec2& frameBufferScale, ImVec2 realDisplaySize); void Draw(); + + ImVec2 m_vecRealDisplaySize; }; #endif //IMGUI_MANAGER_HPP_GUARD diff --git a/GSChaos/includes.h b/GSChaos/includes.h index 1a51ca8e..61acfaa8 100644 --- a/GSChaos/includes.h +++ b/GSChaos/includes.h @@ -75,6 +75,8 @@ #include "CLWrapper.h" #include "in_camera.h" +extern CImGuiManager gImGui; + extern void* g_lpClient; extern void* g_lpOpenGL32; extern void* g_lpHW; diff --git a/external/imgui/backends/imgui_impl_win32.cpp b/external/imgui/backends/imgui_impl_win32.cpp index 618be4bb..de5bc6a1 100644 --- a/external/imgui/backends/imgui_impl_win32.cpp +++ b/external/imgui/backends/imgui_impl_win32.cpp @@ -384,7 +384,7 @@ void ImGui_ImplWin32_NewFrame() ::GetClientRect(bd->hWnd, &rect); if (gImGui.CanUseEngineResolution()) { - gImGui.UpdateResolution(io.DisplaySize, io.DisplayFramebufferScale); + gImGui.UpdateResolution(io.DisplaySize, io.DisplayFramebufferScale, ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top))); } else io.DisplaySize = ImVec2((float)(rect.right - rect.left), (float)(rect.bottom - rect.top));