From 967cfff5ec4db3fb26bc88c3fa8a9af103ad4c43 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 27 Jun 2016 17:54:04 +0200 Subject: [PATCH] Fix toasts --- deps/mongoose | 2 +- deps/protobuf | 2 +- src/Components/Modules/Toast.cpp | 31 +++++++++++++------------------ src/Game/Functions.cpp | 1 + src/Game/Functions.hpp | 5 ++++- 5 files changed, 20 insertions(+), 21 deletions(-) diff --git a/deps/mongoose b/deps/mongoose index 5a19135c..79325bd2 160000 --- a/deps/mongoose +++ b/deps/mongoose @@ -1 +1 @@ -Subproject commit 5a19135c356ed82a3508cd2c1399f532253ecc46 +Subproject commit 79325bd219ae6fea7809324c38824269c2774fd1 diff --git a/deps/protobuf b/deps/protobuf index 0ab78e19..2bcd43af 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 0ab78e19eb56fb992105eba034f3b63fd67b4ae5 +Subproject commit 2bcd43afe4b649c95d932daf31b0b83948f7cf7c diff --git a/src/Components/Modules/Toast.cpp b/src/Components/Modules/Toast.cpp index 7e1510eb..e21e4976 100644 --- a/src/Components/Modules/Toast.cpp +++ b/src/Components/Modules/Toast.cpp @@ -86,34 +86,29 @@ namespace Components bWidth += (bWidth % 2); bHeight += (bHeight % 2); -#pragma warning(push) -#pragma warning(disable: 4244) - // Corners - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2, height - bHeight / 2, cornerSize, cornerSize, 0, 0, 0.5f, 0.5f, color, circle); // Top-Left - Game::R_AddCmdDrawStretchPic(width / 2 + bWidth / 2 - cornerSize, height - bHeight / 2, cornerSize, cornerSize, 0.5f, 0, 0, 0.5f, color, circle); // Top-Right - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2, height + bHeight / 2 - cornerSize, cornerSize, cornerSize, 0, 0.5f, 0.5f, 0, color, circle); // Bottom-Left - Game::R_AddCmdDrawStretchPic(width / 2 + bWidth / 2 - cornerSize, height + bHeight / 2 - cornerSize, cornerSize, cornerSize, 0.5f, 0.5f, 0, 0, color, circle); // Bottom-Right + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2), static_cast(height - bHeight / 2), cornerSize * 1.0f, cornerSize * 1.0f, 0, 0, 0.5f, 0.5f, color, circle); // Top-Left + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 + bWidth / 2 - cornerSize), static_cast(height - bHeight / 2), cornerSize * 1.0f, cornerSize * 1.0f, 0.5f, 0, 0, 0.5f, color, circle); // Top-Right + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2), static_cast(height + bHeight / 2 - cornerSize), cornerSize * 1.0f, cornerSize * 1.0f, 0, 0.5f, 0.5f, 0, color, circle); // Bottom-Left + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 + bWidth / 2 - cornerSize), static_cast(height + bHeight / 2 - cornerSize), cornerSize * 1.0f, cornerSize * 1.0f, 0.5f, 0.5f, 0, 0, color, circle); // Bottom-Right // Border - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2 + cornerSize, height - bHeight / 2 + aCorners, bWidth - cornerSize * 2, cornerSize - aCorners, 0, 0, 1.0f, 1.0f, color, white); // Top - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2 + cornerSize, height + bHeight / 2 - cornerSize, bWidth - cornerSize * 2, cornerSize - aCorners, 0, 0, 1.0f, 1.0f, color, white); // Bottom - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2 + aCorners, height - bHeight / 2 + cornerSize, cornerSize - aCorners, bHeight - cornerSize * 2, 0, 0, 1.0f, 1.0f, color, white); // Left - Game::R_AddCmdDrawStretchPic(width / 2 + bWidth / 2 - cornerSize, height - bHeight / 2 + cornerSize, cornerSize - aCorners, bHeight - cornerSize * 2, 0, 0, 1.0f, 1.0f, color, white); // Right + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2 + cornerSize), static_cast(height - bHeight / 2 + aCorners), static_cast(bWidth - cornerSize * 2), static_cast(cornerSize - aCorners), 0, 0, 1.0f, 1.0f, color, white); // Top + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2 + cornerSize), static_cast(height + bHeight / 2 - cornerSize), static_cast(bWidth - cornerSize * 2), static_cast(cornerSize - aCorners), 0, 0, 1.0f, 1.0f, color, white); // Bottom + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2 + aCorners), static_cast(height - bHeight / 2 + cornerSize), static_cast(cornerSize - aCorners), static_cast(bHeight - cornerSize * 2), 0, 0, 1.0f, 1.0f, color, white); // Left + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 + bWidth / 2 - cornerSize), static_cast(height - bHeight / 2 + cornerSize), static_cast(cornerSize - aCorners), static_cast(bHeight - cornerSize * 2), 0, 0, 1.0f, 1.0f, color, white); // Right // Center - Game::R_AddCmdDrawStretchPic(width / 2 - (bWidth - cornerSize * 2) / 2, height - (bHeight - cornerSize * 2) / 2, bWidth - cornerSize * 2, bHeight - cornerSize * 2, 0, 0, 1.0f, 1.0f, color, white); + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - (bWidth - cornerSize * 2) / 2), static_cast(height - (bHeight - cornerSize * 2) / 2), static_cast(bWidth - cornerSize * 2), static_cast(bHeight - cornerSize * 2), 0, 0, 1.0f, 1.0f, color, white); // Image - Game::R_AddCmdDrawStretchPic(width / 2 - bWidth / 2 + iOffsetLeft, height - bHeight / 2 + iOffset, imgDim, imgDim, 0, 0, 1.0f, 1.0f, wColor, image); + Game::CL_DrawStretchPicPhysical(static_cast(width / 2 - bWidth / 2 + iOffsetLeft), static_cast(height - bHeight / 2 + iOffset), imgDim * 1.0f, imgDim * 1.0f, 0, 0, 1.0f, 1.0f, wColor, image); // Text int leftText = width / 2 - bWidth / 2 - cornerSize + iOffsetLeft * 2 + imgDim; int rightText = width / 2 + bWidth / 2 - cornerSize - aCorners - iOffsetLeft; - Game::R_AddCmdDrawText(toast->Title.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - titleSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 7, 1.0f, 1.0f, 0, wColor, 0); // Title - Game::R_AddCmdDrawText(toast->Desc.data(), 0x7FFFFFFF, font, leftText + (rightText - leftText) / 2 - descrSize / 2 + cornerSize, height - bHeight / 2 + cornerSize * 2 + 33, 1.0f, 1.0f, 0, wColor, 0); // Description - -#pragma warning(pop) + Game::R_AddCmdDrawText(toast->Title.data(), 0x7FFFFFFF, font, static_cast(leftText + (rightText - leftText) / 2 - titleSize / 2 + cornerSize), static_cast(height - bHeight / 2 + cornerSize * 2 + 7), 1.0f, 1.0f, 0, wColor, 0); // Title + Game::R_AddCmdDrawText(toast->Desc.data(), 0x7FFFFFFF, font, static_cast(leftText + (rightText - leftText) / 2 - descrSize / 2 + cornerSize), static_cast(height - bHeight / 2 + cornerSize * 2 + 33), 1.0f, 1.0f, 0, wColor, 0); // Description } void Toast::Handler() @@ -148,7 +143,7 @@ namespace Components Command::Add("testtoast", [] (Command::Params) { - Toast::Show("specialty_nuke", "Test", "This is a test toast", 3000); + Toast::Show("cardicon_prestige10", "Test", "This is a test toast", 3000); }); } diff --git a/src/Game/Functions.cpp b/src/Game/Functions.cpp index d0886ed4..87d76412 100644 --- a/src/Game/Functions.cpp +++ b/src/Game/Functions.cpp @@ -12,6 +12,7 @@ namespace Game CL_IsCgameInitialized_t CL_IsCgameInitialized = (CL_IsCgameInitialized_t)0x43EB20; CL_ConnectFromParty_t CL_ConnectFromParty = (CL_ConnectFromParty_t)0x433D30; CL_DownloadsComplete_t CL_DownloadsComplete = (CL_DownloadsComplete_t)0x42CE90; + CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical = (CL_DrawStretchPicPhysical_t)0x4FC120; CL_ResetViewport_t CL_ResetViewport = (CL_ResetViewport_t)0x4A8830; Cmd_AddCommand_t Cmd_AddCommand = (Cmd_AddCommand_t)0x470090; diff --git a/src/Game/Functions.hpp b/src/Game/Functions.hpp index 246563de..b48db643 100644 --- a/src/Game/Functions.hpp +++ b/src/Game/Functions.hpp @@ -21,6 +21,9 @@ namespace Game typedef void(__cdecl * CL_DownloadsComplete_t)(int controller); extern CL_DownloadsComplete_t CL_DownloadsComplete; + typedef void(_cdecl * CL_DrawStretchPicPhysical_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, Game::Material* material); + extern CL_DrawStretchPicPhysical_t CL_DrawStretchPicPhysical; + typedef void(__cdecl * CL_ResetViewport_t)(); extern CL_ResetViewport_t CL_ResetViewport; @@ -302,7 +305,7 @@ namespace Game typedef void(__cdecl * R_AddCmdDrawText_t)(const char *text, int maxChars, Font *font, float x, float y, float xScale, float yScale, float rotation, const float *color, int style); extern R_AddCmdDrawText_t R_AddCmdDrawText; - typedef void(_cdecl * R_AddCmdDrawStretchPic_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, void* material); + typedef void(_cdecl * R_AddCmdDrawStretchPic_t)(float x, float y, float w, float h, float xScale, float yScale, float xay, float yay, const float *color, Game::Material* material); extern R_AddCmdDrawStretchPic_t R_AddCmdDrawStretchPic; typedef void(__cdecl * R_LoadGraphicsAssets_t)();