diff --git a/cmake/compiler-flags-gl.txt b/cmake/compiler-flags-gl.txt index 226cdc7ca6..d90c13cfb0 100644 --- a/cmake/compiler-flags-gl.txt +++ b/cmake/compiler-flags-gl.txt @@ -4,7 +4,6 @@ src/OpenSHC/IO/LowLevelMemory/putFileNameAndAppendFileExtension.cpp src/OpenSHC/IO/DecoderState/encodeData.cpp src/OpenSHC/IO/DecoderState/decodeData.cpp src/OpenSHC/IO/ResourceManager/swapMapDataWithNextMap.cpp -src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp src/OpenSHC/IO/ResourceManager/readFirstPartOfCurrentResourceIntoMemory.cpp src/OpenSHC/IO/ResourceManager/readNextPartOfCurrentResourceIntoMemory.cpp src/OpenSHC/Map/TileMapState/updateMoatCountdownTimers.cpp @@ -69,6 +68,7 @@ src/OpenSHC/Map/Buildings/BuildingsState/canUnitReachBuildingPerimeter.cpp src/OpenSHC/Synchrony/GameSynchronyState/receiveAllTransmittedCommands.cpp src/OpenSHC/Synchrony/GameSynchronyState/processSyncPacket.cpp src/OpenSHC/Synchrony/GameSynchronyState/translateMultiplayerIDsIntoPlayerIDs.cpp +src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp src/OpenSHC/Map/Buildings/UpdateStables.cpp src/OpenSHC/Map/Buildings/UpdateArmorersWorkshop.cpp src/OpenSHC/Map/Buildings/UpdateFletchersWorkshop.cpp diff --git a/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp new file mode 100644 index 0000000000..97461b47fc --- /dev/null +++ b/src/OpenSHC/Rendering/Bink/AIMessageQueue/playAiLordMessage.cpp @@ -0,0 +1,132 @@ +#include "../AIMessageQueue.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/DisplayElements.func.hpp" +#include "OpenSHC/UI/MenuModalComposition.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/UI/Enums/BuildingsAndStatusMenuTabType.hpp" +#include "OpenSHC/UI/Enums/DisplayElementID.hpp" +#include "OpenSHC/UI/Enums/MenuModalType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuModalComposition2.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace Rendering { + namespace Bink { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B7C90 + void AIMessageQueue::playAiLordMessage(int x, int y) + { + DWORD const now = timeGetTime(); + int yOffset = 0; + if (!MACRO_CALL_MEMBER(Game::GameCore_Func::getAreWeInAInGameMenu, DAT_GameCore::ptr)()) { + return; + } + if (DAT_GameCore::instance.currentMenuViewType == UI::Enums::MVT_BUILDING_AND_STATUS_MENU) { + if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_BARRACKS_OR_MPMENU_MODEM) { + yOffset = -40; + } else if (DAT_GameCore::instance.activeMenuTab.tabType == UI::Enums::BASMTT_MERCENARYPOST) { + yOffset = -40; + } else { + yOffset = -20; + } + } + if (MACRO_CALL(UI::DisplayElements_Func::GetIfDisplayElementStateNotZero)( + UI::Enums::DEID_KEEP_AND_GRANERY_PLACEMENT_INFO)) { + yOffset -= 40; + } + int textHeight; + int textWidth; + if (!this->currentMessageUnknownValue_0x4) { + textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineWideTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 1); + textWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineWideTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + (WCHAR*)this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineWideTextUnk, DAT_TextManagerObject::ptr)( + (WCHAR*)this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); + } else { + textHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + this->currentMessageText_0x8, 0, 0, 580, 0, 0, 1); + textWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + this->currentMessageText_0x8, 0, 0, 580, 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + this->currentMessageText_0x8, x - textWidth, yOffset - textHeight + y, 580, + OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); + } + if ((int)this->currentMessageUnknownValue2_0xd4 > 0) { + int const nameHeight = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], 0, 0, 580, + 0, 0, 1); + int const nameWidth = MACRO_CALL_MEMBER(Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], 0, 0, 580, + 0, 0, 2); + MACRO_CALL_MEMBER(Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.DAT_PlayerNames[this->currentMessageUnknownValue2_0xd4], + x - nameWidth, yOffset - nameHeight + y, 580, OpenSHC::Rendering::Colors::COL_CCFAFF, 0, 18, 0); + int aiCharacter = 0; + if (DAT_GameSynchronyState::instance.currentPlayerFullIDArray[this->currentMessageUnknownValue2_0xd4] + == -1) { + aiCharacter + = DAT_GameSynchronyState::instance.currentAIArray[this->currentMessageUnknownValue2_0xd4]; + } + int const faceX = x - nameWidth - 80; + int const faceY = y - nameHeight - 48; + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + DE::SHCDE::GM_INTERFACE_ICONS2, this->currentMessageUnknownValue2_0xd4 + 546, faceX, faceY); + if (!aiCharacter) { + MACRO_CALL_MEMBER(UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(DE::SHCDE::GM_INTERFACE_ICONS2, 539, faceX, faceY); + } else { + MACRO_CALL_MEMBER( + UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + DE::SHCDE::GM_INTERFACE_ICONS2, aiCharacter + 522, faceX, faceY); + } + } + if (!MACRO_CALL_MEMBER(Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, DAT_SoundSystemState::ptr)( + Audio::MSS::enums::SND_STR_SPEECH_1)) { + this->mbr_0x92c = 1; + } + if ((int)(now - this->videoStartTimeUnk_0xd8) <= 10000 && textWidth != 0) { + return; + } + if (this->currentMessageVfxFile_0xc[0] != '\0') { + if (DAT_BinkControlState::instance.binkObjPtrArray[1] != NULL) { + return; + } + } else if (this->currentMessageSfxFile_0x70[0] != '\0' && DAT_SoundSystemState::instance.waveOutOpenUnk_0x8 + && DAT_SoundSystemState::instance.soundActiveUnk_0x0 && !this->mbr_0x92c) { + return; + } + if (DAT_GameCore::instance.gamePausedLogical) { + return; + } + this->mbr_0x928 = 0; + DAT_GameCore::instance.countdown = 2; + MACRO_CALL_MEMBER(UI::MenuModalComposition_Func::activateModalDialog, DAT_MenuModalComposition2::ptr)( + UI::Enums::MMT_NONE, FALSE); + } + + } +} +} diff --git a/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp new file mode 100644 index 0000000000..d765ad72cd --- /dev/null +++ b/src/OpenSHC/Rendering/Bink/BinkControlClass/copyBinkToVideoBuffer.cpp @@ -0,0 +1,134 @@ +#include "../BinkControlClass.func.hpp" + +#include "OpenSHC/Audio/MSS/SoundSystem.func.hpp" +#include "OpenSHC/Rendering.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/Audio/MSS/enums/SHC_SoundStream.hpp" +#include "OpenSHC/Rendering/Bink/UnsortedBinkFlag.hpp" +#include "OpenSHC/UI/Menu.hpp" + +#include "OpenSHC/Globals/COL_BLACK.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_SoundSystemState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace Rendering { + namespace Bink { + + using OpenSHC::Audio::MSS::enums::SHC_SoundStream; + + // The original inlined this per-video body into the loop: its early returns are the jumps to the loop + // increment. Plain `inline` is not expanded by MSVC here, so it has to be __forceinline (same code as a goto, + // no goto needed). + static __forceinline void copyBinkToVideoBuffer_copyFrame( + BinkControlClass* self, int binkObjIndex, dword videoTarget) + { + if (self->soundStreamIndex[binkObjIndex] != OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { + if (!MACRO_CALL_MEMBER(OpenSHC::Audio::MSS::SoundSystem_Func::isSampleOrStreamPlaying, + DAT_SoundSystemState::ptr)((SHC_SoundStream)self->soundStreamIndex[binkObjIndex]) + || timeGetTime() - self->startTime[binkObjIndex] > 20000) { + self->soundStreamIndex[binkObjIndex] = OpenSHC::Audio::MSS::enums::SND_STR_MUSIC; + } + } + + if (self->unknownParam07[binkObjIndex] == videoTarget) { + self->unknown01_zero[binkObjIndex] = 0; + self->unknown02_zero[binkObjIndex] = 0; + } + + if (self->binkObjPtrArray[binkObjIndex] == NULL || self->unknownParam07[binkObjIndex] != videoTarget) { + return; + } + + if (BinkWait(self->binkObjPtrArray[binkObjIndex]) == 0) { + BinkDoFrame(self->binkObjPtrArray[binkObjIndex]); + + if ((self->binkObjPtrArray[binkObjIndex]->FrameNum == self->binkObjPtrArray[binkObjIndex]->Frames) + && (self->unknownParam03[binkObjIndex] == 0)) { + if (self->soundStreamIndex[binkObjIndex] == OpenSHC::Audio::MSS::enums::SND_STR_MUSIC) { + if (videoTarget != 2) { + self->unknown01_zero[binkObjIndex] = 1; + MACRO_CALL_MEMBER(OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, self)( + binkObjIndex); + return; + } + self->unknown02_zero[binkObjIndex] = 1; + } else if (videoTarget == 2) { + self->unknown02_zero[binkObjIndex] = 1; + } + } else { + BinkNextFrame(self->binkObjPtrArray[binkObjIndex]); + } + + self->frameReadyToDisplay[binkObjIndex] = TRUE; + } + + if (videoTarget == 2) { + int const menuBorderHeight = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight; + int const menuBorderWidth = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth; + OpenSHC::UI::Menu* const menu = DAT_MenuHandlerState::instance.currentMenu; + menu->xPosition = menuBorderWidth; + menu->yPosition = menuBorderHeight; + DAT_MenuHandlerState::instance.y = menuBorderHeight; + DAT_MenuHandlerState::instance.x = menuBorderWidth; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawColorBox, + DAT_PencilRenderCore::ptr)(0, 0, DAT_WindowAndDirectDraw::instance.resolutionX, + DAT_WindowAndDirectDraw::instance.resolutionY, COL_BLACK::instance.shortValue); + } + + if (!self->frameReadyToDisplay[binkObjIndex]) { + return; + } + + IDirectDrawSurface* surface; + if (self->unknownParam04[binkObjIndex] != 0) { + HRESULT result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); + while (result == DDERR_SURFACELOST) { + if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Restore() + != DD_OK) { + return; + } + result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame, DDLOCK_WAIT, NULL); + } + BinkCopyToBuffer(self->binkObjPtrArray[binkObjIndex], + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame.lpSurface, + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfMapGame.lPitch, + self->binkObjPtrArray[binkObjIndex]->Height, self->xPos[binkObjIndex], self->yPos[binkObjIndex], + self->mapGameSurfaceType | OpenSHC::Rendering::Bink::UBF_BINKCOPYALL); + surface = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_mapGame; + } else { + HRESULT result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Lock( + NULL, &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); + while (result == DDERR_SURFACELOST) { + if (DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Restore() + != DD_OK) { + return; + } + result = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu->Lock(NULL, + &DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104, DDLOCK_WAIT, NULL); + } + BinkCopyToBuffer(self->binkObjPtrArray[binkObjIndex], + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104.lpSurface, + DAT_WindowAndDirectDraw::instance.surfDescBink_offSurfScreenMenu_0x104.lPitch, + self->binkObjPtrArray[binkObjIndex]->Height, self->xPos[binkObjIndex], self->yPos[binkObjIndex], + self->screenMenuSurfaceType_0x5c | OpenSHC::Rendering::Bink::UBF_BINKCOPYALL); + surface = DAT_WindowAndDirectDraw::instance.directDrawOffscreenSurfacePointer_screenMenu; + } + surface->Unlock(NULL); + } + + // FUNCTION: STRONGHOLDCRUSADER 0x00408FC0 + void BinkControlClass::copyBinkToVideoBuffer(dword videoTarget) + { + for (int binkObjIndex = 0; binkObjIndex < 2; ++binkObjIndex) { + copyBinkToVideoBuffer_copyFrame(this, binkObjIndex, videoTarget); + } + } + + } +} +} diff --git a/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp new file mode 100644 index 0000000000..0f872621d0 --- /dev/null +++ b/src/OpenSHC/Rendering/BlitMapImageWithVerticalClipAndYOffset.cpp @@ -0,0 +1,381 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Globals/DAT_00ed3154.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_GMImageOffsets.hpp" +#include "OpenSHC/Globals/DAT_GmImageAddressToBeRendered.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeX.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_DrawSomeY.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_RowsLeft.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_SecondBlitImageIndex.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_WhatToDraw.hpp" +#include "OpenSHC/Globals/DAT_RenderMap_YOffset.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { + +// Like BlitMapImageWithVerticalClip, but the second image (DAT_RenderMap_SecondBlitImageIndex) starts +// 160 - DAT_RenderMap_YOffset rows in. +// The copy loops are handwritten assembly in the original, transcribed here from the binary. + +// FUNCTION: STRONGHOLDCRUSADER 0x00454080 +void Rendering::BlitMapImageWithVerticalClipAndYOffset() +{ + // The asm below names these globals, which inline asm can only do once C++ code has instantiated them; + // sizeof does that without generating any code. + (void)sizeof(DAT_WindowAndDirectDraw::instance); + (void)sizeof(DAT_RenderMap_DrawSomeX::instance); + (void)sizeof(DAT_RenderMap_WhatToDraw::instance); + char* image = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + char* nextImage = (char*)DAT_TextureRenderCoreObject::instance.gmProcessedImageData; + int drawY = DAT_RenderMap_DrawSomeY::instance + (DAT_00ed3154::instance - DAT_RenderMap_YOffset::instance) + 9; + int height = DAT_GMImageHeaders::instance.imh[DAT_GmImageAddressToBeRendered::instance].height - 7; + int skip = 0; + int nextSkip = 160 - DAT_RenderMap_YOffset::instance; + if (DAT_RenderMap_RowsLeft::instance <= 0) { + return; + } + if (drawY < DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start) { + skip = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start - drawY; + DAT_RenderMap_RowsLeft::instance -= skip; + drawY = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.start; + nextSkip += skip; + height -= skip; + } + if (DAT_RenderMap_RowsLeft::instance + drawY + >= DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end) { + DAT_RenderMap_RowsLeft::instance = DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end - drawY; + // fixme: always adds 0, the original subtracts the already shortened row count + height += (DAT_TextureRenderCoreObject::instance.mapGameSurfaceHeightRange.end + - DAT_RenderMap_RowsLeft::instance - drawY); + } + // rows to bytes: tile objects are 15 dwords per row + skip *= 60; + nextSkip *= 60; + int firstRows; + if (height <= 0) { + firstRows = 0; + } else if (height < DAT_RenderMap_RowsLeft::instance) { + DAT_RenderMap_RowsLeft::instance -= height; + firstRows = height; + nextSkip += height * 60; + } else { + firstRows = DAT_RenderMap_RowsLeft::instance; + DAT_RenderMap_RowsLeft::instance = 0; + skip = nextSkip; + } + if (DAT_RenderMap_WhatToDraw::instance == 3) { + skip -= 480; + } + image += DAT_GMImageOffsets::instance[DAT_GmImageAddressToBeRendered::instance]; + nextImage += DAT_GMImageOffsets::instance[DAT_RenderMap_SecondBlitImageIndex::instance]; + if (!DAT_TextureRenderCoreObject::instance.isZoom2) { + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov edi, DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame + mov eax, DAT_RenderMap_DrawSomeX::instance + add eax, eax + add edi, eax + mov eax, drawY + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle next_image +row_start: + mov eax, DAT_RenderMap_WhatToDraw::instance + cmp eax, 1 + je copy_right_half + cmp eax, 2 + je copy_left_half + cmp eax, 3 + je copy_middle +copy_whole_row: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle next_image + jmp copy_whole_row +copy_right_half: + mov ebx, dword ptr [esi + 0x1c] + mov ecx, dword ptr [esi + 0x20] + mov dword ptr [edi + 0xddec], ebx + mov dword ptr [edi + 0xbe40], ecx + mov eax, dword ptr [esi + 0x24] + mov ebx, dword ptr [esi + 0x28] + mov ecx, dword ptr [esi + 0x2c] + mov dword ptr [edi + 0x9e94], eax + mov dword ptr [edi + 0x7ee8], ebx + mov dword ptr [edi + 0x5f3c], ecx + mov eax, dword ptr [esi + 0x30] + mov ebx, dword ptr [esi + 0x34] + mov ecx, dword ptr [esi + 0x38] + mov dword ptr [edi + 0x3f90], eax + mov dword ptr [edi + 0x1fe4], ebx + mov dword ptr [edi + 0x38], ecx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle next_image + jmp copy_right_half +copy_left_half: + mov eax, dword ptr [esi] + mov ebx, dword ptr [esi + 4] + mov ecx, dword ptr [esi + 8] + mov dword ptr [edi], eax + mov dword ptr [edi + 0x1fb4], ebx + mov dword ptr [edi + 0x3f68], ecx + mov eax, dword ptr [esi + 0xc] + mov ebx, dword ptr [esi + 0x10] + mov ecx, dword ptr [esi + 0x14] + mov dword ptr [edi + 0x5f1c], eax + mov dword ptr [edi + 0x7ed0], ebx + mov dword ptr [edi + 0x9e84], ecx + mov eax, dword ptr [esi + 0x18] + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xbe38], eax + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle next_image + jmp copy_left_half +copy_middle: + mov ebx, dword ptr [esi + 0x1c] + mov dword ptr [edi + 0xddec], ebx + add esi, 0x3c + add edi, 0x1fb0 + sub edx, 1 + cmp edx, 0 + jle next_image + jmp copy_middle +next_image: + cmp DAT_RenderMap_RowsLeft::instance, 0 + jle done + mov edx, DAT_RenderMap_RowsLeft::instance + mov DAT_RenderMap_RowsLeft::instance, 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp row_start +done: + } + // clang-format on + return; + } + // clang-format off + __asm { + mov esi, image + mov eax, skip + add esi, eax + mov edi, DAT_WindowAndDirectDraw::instance.surfacePointer_mapGame + mov eax, DAT_RenderMap_DrawSomeX::instance + and eax, 0xfffffffe + add edi, eax + mov eax, drawY + mov ecx, eax + shr eax, 1 + mov edx, 0x1fb0 + mul edx + add edi, eax + mov edx, firstRows + cmp edx, 0 + jle zoom_next_image +zoom_row_start: + mov eax, DAT_RenderMap_WhatToDraw::instance + cmp eax, 1 + je zoom_right_half + cmp eax, 2 + je zoom_left_half + cmp eax, 3 + je zoom_middle +zoom_whole_row: + mov eax, ecx + and eax, 1 + cmp eax, 0 + jne zoom_whole_row_odd + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_whole_row +zoom_whole_row_odd: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + mov ax, word ptr [esi + 0x24] + mov bx, word ptr [esi + 0x2c] + mov word ptr [edi + 0x3f72], ax + mov word ptr [edi + 0x1fc6], bx + mov ax, word ptr [esi + 0x34] + mov word ptr [edi + 0x1a], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_whole_row +zoom_right_half: + mov eax, ecx + and eax, 1 + jne zoom_right_half_odd + mov ax, word ptr [esi + 0x20] + mov bx, word ptr [esi + 0x28] + mov word ptr [edi + 0x5f20], ax + mov word ptr [edi + 0x3f74], bx + mov ax, word ptr [esi + 0x30] + mov bx, word ptr [esi + 0x38] + mov word ptr [edi + 0x1fc8], ax + mov word ptr [edi + 0x1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_right_half +zoom_right_half_odd: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov bx, word ptr [esi + 0x24] + mov word ptr [edi + 0x5f1e], ax + mov word ptr [edi + 0x3f72], bx + mov ax, word ptr [esi + 0x2c] + mov bx, word ptr [esi + 0x34] + mov word ptr [edi + 0x1fc6], ax + mov word ptr [edi + 0x1a], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_right_half +zoom_left_half: + mov eax, ecx + and eax, 1 + jne zoom_left_half_odd + mov ax, word ptr [esi] + mov bx, word ptr [esi + 8] + mov word ptr [edi], ax + mov word ptr [edi + 0x1fb4], bx + mov ax, word ptr [esi + 0x10] + mov bx, word ptr [esi + 0x18] + mov word ptr [edi + 0x3f68], ax + mov word ptr [edi + 0x5f1c], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_left_half +zoom_left_half_odd: + add edi, 0x1fb0 + mov ax, word ptr [esi + 4] + mov bx, word ptr [esi + 0xc] + mov word ptr [edi + 2], ax + mov word ptr [edi + 0x1fb6], bx + mov ax, word ptr [esi + 0x14] + mov bx, word ptr [esi + 0x1c] + mov word ptr [edi + 0x3f6a], ax + mov word ptr [edi + 0x5f1e], bx + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_left_half +zoom_middle: + mov eax, ecx + and eax, 1 + jne zoom_middle_odd + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_middle +zoom_middle_odd: + add edi, 0x1fb0 + mov ax, word ptr [esi + 0x1c] + mov word ptr [edi + 0x5f1e], ax + add esi, 0x3c + add ecx, 1 + sub edx, 1 + cmp edx, 0 + jle zoom_next_image + jmp zoom_middle +zoom_next_image: + cmp DAT_RenderMap_RowsLeft::instance, 0 + jle zoom_done + mov edx, DAT_RenderMap_RowsLeft::instance + mov DAT_RenderMap_RowsLeft::instance, 0 + mov esi, dword ptr nextImage + mov eax, dword ptr nextSkip + add esi, eax + jmp zoom_row_start +zoom_done: + } + // clang-format on +} + +} diff --git a/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp new file mode 100644 index 0000000000..71fc42b84b --- /dev/null +++ b/src/OpenSHC/Synchrony/GameSynchronyState/determineGameTicksToPerform.cpp @@ -0,0 +1,104 @@ +#include "../GameSynchronyState.func.hpp" + +#include "OpenSHC/Synchrony.func.hpp" +#include "OpenSHC/Game/GameMode.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameLoopStopwatch.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MillisecCarry.hpp" + +namespace OpenSHC { +namespace Synchrony { + + // FUNCTION: STRONGHOLDCRUSADER 0x00487A30 + int GameSynchronyState::determineGameTicksToPerform(int currentPlayerSlotID) + { + int gameSpeed = DAT_GameCore::instance.gameSpeedLevel; + if (!gameSpeed) { + gameSpeed = 40; + DAT_GameCore::instance.gameSpeedLevel = gameSpeed; + } + if (DAT_GameCore::instance.currentlyInGameUnk_0xa4 != TRUE) { + return 0; + } + if (this->DAT_GameHalted) { + return 0; + } + if ((this->currentGameMode == Game::GM_SOLITARY) + || (this->currentGameMode == Game::GM_SKIRMISH_SINGLE_PLAYER)) { + this->mapTimeInTicksSinglePlayer = DAT_GameCore::instance.mapTimeInTicks; + } else { + // Calculate multiplayer game speed. + DAT_GameCore::instance.gameSpeedMultiplicator = 1; + gameSpeed = this->skirmishGameSpeedLevel; + DAT_GameSynchronyState::instance.relativeTickTime = 0; + MACRO_CALL_MEMBER(Synchrony::GameSynchronyState_Func::computeLatencyAdjustmentFromMatchTimes, this)( + currentPlayerSlotID); + if ((int)this->ticksBehindFastestPlayer < 0) { + DAT_GameSynchronyState::instance.relativeTickTime = (int)this->ticksBehindFastestPlayer; + } else { + if (0 < (int)this->ticksAheadOfSlowestPlayer) { + DAT_GameSynchronyState::instance.relativeTickTime = (int)this->ticksAheadOfSlowestPlayer; + if ((int)this->ticksAheadOfSlowestPlayer > (int)this->commandDelay + 75) { + if ((int)this->unknownIncrementBy40_01 < 1) { + this->unknownIncrementBy40_01 = 1; + } + gameSpeed = (int)this->unknownIncrementBy40_01; + if ((int)this->unknownIncrementBy40_01 > this->skirmishGameSpeedLevel) { + gameSpeed = this->skirmishGameSpeedLevel; + } + } else if (5 < (int)this->ticksAheadOfSlowestPlayer) { + gameSpeed = ((5 - (int)this->ticksAheadOfSlowestPlayer) * 2) / 3 + this->skirmishGameSpeedLevel; + if (gameSpeed < 15) { + gameSpeed = 15; + } + } + } + } + } + int tickDuration; + if (DAT_GameCore::instance.gameSpeedMultiplicator < 0) { + tickDuration = -1000 / gameSpeed * DAT_GameCore::instance.gameSpeedMultiplicator; + } else if (1 < DAT_GameCore::instance.gameSpeedMultiplicator) { + tickDuration = 1000 / gameSpeed / DAT_GameCore::instance.gameSpeedMultiplicator; + } else { + tickDuration = 1000 / gameSpeed; + } + DAT_MillisecCarry::instance += DAT_GameLoopStopwatch::instance.duration_0x0 - tickDuration; + int const millisecCarry = DAT_MillisecCarry::instance; + if (millisecCarry < 0) { + // Wait + if (millisecCarry < -tickDuration) { + DAT_MillisecCarry::instance = millisecCarry + tickDuration; + return 0; + } + } else { + // Execute game ticks + if (DAT_GameCore::instance.averageTimePerGameTick > tickDuration && millisecCarry >= tickDuration * 2 + && tickDuration == 1000 / gameSpeed) { + // Slow down + DAT_MillisecCarry::instance = 0; + return 2; + } + if (DAT_GameCore::instance.averageTimePerGameTick > (tickDuration * 7) / 10 + && millisecCarry >= tickDuration * 2 && tickDuration == 1000 / gameSpeed) { + // Slow down + DAT_MillisecCarry::instance = 0; + return 3; + } + if (millisecCarry > tickDuration * 10) { + // Cap game ticks per rendering + DAT_MillisecCarry::instance = 0; + return 11; + } + if (millisecCarry > tickDuration) { + DAT_MillisecCarry::instance = millisecCarry - (millisecCarry / tickDuration) * tickDuration; + return millisecCarry / tickDuration + 1; + } + } + return 1; + } + +} +} diff --git a/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp new file mode 100644 index 0000000000..0c636e9b23 --- /dev/null +++ b/src/OpenSHC/UI/BuildingMenus/RenderBuildingMenu_ChapelAndChurch.cpp @@ -0,0 +1,217 @@ +#include "../BuildingMenus.func.hpp" + +#include "OpenSHC/Map/Units/UnitsState.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/Map/Buildings/BuildingTypeShort.hpp" +#include "OpenSHC/Map/Units/UnitType.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_00b98428.hpp" +#include "OpenSHC/Globals/DAT_00b9842c.hpp" +#include "OpenSHC/Globals/DAT_00b98430.hpp" +#include "OpenSHC/Globals/DAT_00b9843c.hpp" +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_CurrentlyRenderedSpriteID.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_HusbandID.hpp" +#include "OpenSHC/Globals/DAT_HusbandUnitType.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderedUnitOwner.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UnitsState.hpp" +#include "OpenSHC/Globals/DAT_WifeID.hpp" +#include "OpenSHC/Globals/DAT_WifeUnitType.hpp" +#include "OpenSHC/Globals/INT_0061824c.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::Map::Buildings::BuildingTypeShort; + + // FUNCTION: STRONGHOLDCRUSADER 0x0043C1E0 + void BuildingMenus::RenderBuildingMenu_ChapelAndChurch() + { + int const buildingID = DAT_BuildingsState::instance.menuSelectedBuildingID; + BuildingTypeShort const buildingType + = DAT_BuildingsState::instance.buildings[DAT_BuildingsState::instance.menuSelectedBuildingID].buildingType; + if (buildingType == OpenSHC::Map::Buildings::BT_CHAPEL) { + int const titleY = DAT_MenuHandlerState::instance.y + 467; + int const titleX = DAT_MenuHandlerState::instance.x + 25; + // "Chapel" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 0), + titleX, titleY, OpenSHC::Text::TTA_LEFT, 0, 16, FALSE, 0); + } else if (buildingType == OpenSHC::Map::Buildings::BT_CHURCH) { + int const titleY = DAT_MenuHandlerState::instance.y + 467; + int const titleX = DAT_MenuHandlerState::instance.x + 25; + // "Church" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 3), + titleX, titleY, OpenSHC::Text::TTA_LEFT, 0, 16, FALSE, 0); + } else if (buildingType == OpenSHC::Map::Buildings::BT_CATHEDRAL) { + int const titleY = DAT_MenuHandlerState::instance.y + 467; + int const titleX = DAT_MenuHandlerState::instance.x + 25; + // "Cathedral" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_IN_CHURCH, 4), + titleX, titleY, OpenSHC::Text::TTA_LEFT, 0, 16, FALSE, 0); + } + + if (DAT_BuildingsState::instance.buildings[buildingID].currentEmployeeCount == 0) { + int const noticeY = DAT_MenuHandlerState::instance.y + 517; + int const noticeX = DAT_MenuHandlerState::instance.x + 175; + // "No Wedding this month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), + noticeX, noticeY, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + return; + } + // a new couple each month + if (DAT_GameState::instance.mapAndTime.month != INT_0061824c::instance) { + INT_0061824c::instance = DAT_GameState::instance.mapAndTime.month; + DAT_00b9843c::instance = MACRO_CALL_MEMBER(OpenSHC::Map::Units::UnitsState_Func::chooseHusbandAndWife, + DAT_UnitsState::ptr)((int*)DAT_HusbandID::ptr, (int*)DAT_WifeID::ptr); + if (DAT_00b9843c::instance == 0) { + int const noticeY = DAT_MenuHandlerState::instance.y + 517; + int const noticeX = DAT_MenuHandlerState::instance.x + 175; + // "No Wedding this month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), + noticeX, noticeY, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + return; + } + DAT_HusbandUnitType::instance + = (UnitTypeInt)(short)DAT_UnitsState::instance.units[DAT_HusbandID::instance].unitType; + DAT_WifeUnitType::instance + = (UnitTypeInt)(short)DAT_UnitsState::instance.units[DAT_WifeID::instance].unitType; + // the trade of the wife picks the text; each trade walks through its own ten texts + switch (DAT_WifeUnitType::instance) { + case OpenSHC::Map::Units::UT_BREWER: + ++DAT_00b98428::instance; + if (DAT_00b98428::instance > 9) { + DAT_00b98428::instance = 0; + } + break; + case OpenSHC::Map::Units::UT_TANNER: + ++DAT_00b9842c::instance; + if (DAT_00b9842c::instance > 9) { + DAT_00b9842c::instance = 0; + } + break; + default: + ++DAT_00b98430::instance; + if (DAT_00b98430::instance > 9) { + DAT_00b98430::instance = 0; + } + } + } + if (DAT_00b9843c::instance != 0) { + // the wedding is off when one of the two changed trade + if ((short)DAT_UnitsState::instance.units[DAT_HusbandID::instance].unitType + != DAT_HusbandUnitType::instance) { + DAT_00b9843c::instance = 0; + } + if ((short)DAT_UnitsState::instance.units[DAT_WifeID::instance].unitType != DAT_WifeUnitType::instance) { + DAT_00b9843c::instance = 0; + } + if (DAT_00b9843c::instance != 0) { + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, DAT_TextureRenderCoreObject::ptr)( + 1, DAT_MenuHandlerState::instance.x + 371, DAT_MenuHandlerState::instance.y + 480); + if (DAT_WifeUnitType::instance != OpenSHC::Map::Units::UT_BREWER) { + if (DAT_WifeUnitType::instance == OpenSHC::Map::Units::UT_TANNER) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b9842c::instance + 12, + DAT_MenuHandlerState::instance.x + 180, DAT_MenuHandlerState::instance.y + 559, 350, 0, 18, + 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineTextUnk, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b98430::instance + 23, + DAT_MenuHandlerState::instance.x + 180, DAT_MenuHandlerState::instance.y + 559, 350, 0, 18, + 0); + } + } else { + int const textY = DAT_MenuHandlerState::instance.y + 559; + int const textX = DAT_MenuHandlerState::instance.x + 180; + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, DAT_00b98428::instance + 1), + textX, textY, 350, 0, 18, 0); + } + // the pictures of the couple + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + DAT_CurrentlyRenderedSpriteID::instance = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getPeasantGmID, DAT_UnitsState::ptr)(DAT_HusbandID::instance); + DAT_RenderedUnitOwner::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, + 3, DAT_MenuHandlerState::instance.x + 130, DAT_MenuHandlerState::instance.y + 452); + DAT_CurrentlyRenderedSpriteID::instance = MACRO_CALL_MEMBER( + OpenSHC::Map::Units::UnitsState_Func::getPeasantGmID, DAT_UnitsState::ptr)(DAT_WifeID::instance); + DAT_RenderedUnitOwner::instance = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_CurrentlyRenderedSpriteID::instance, + 3, DAT_MenuHandlerState::instance.x + 145, DAT_MenuHandlerState::instance.y + 477); + // the names of the two + int const husbandID = DAT_HusbandID::instance; + char const husbandName = (char)DAT_UnitsState::instance.units[DAT_HusbandID::instance].firstNameIndex; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (husbandName > 0) { + int const nameY = DAT_MenuHandlerState::instance.y + 492; + int const nameX = DAT_MenuHandlerState::instance.x + 215; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, husbandName), + nameX, nameY, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + char const surname = (char)DAT_UnitsState::instance.units[husbandID].rng1_to_70; + if (surname != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, surname, DAT_MenuHandlerState::instance.x + 220, + DAT_MenuHandlerState::instance.y + 492, OpenSHC::Text::TTA_LEFT, 0, 18, TRUE); + } + } + int const wifeID = DAT_WifeID::instance; + char const wifeName = (char)DAT_UnitsState::instance.units[DAT_WifeID::instance].firstNameIndex; + if (wifeName > 0) { + int const nameY = DAT_MenuHandlerState::instance.y + 517; + int const nameX = DAT_MenuHandlerState::instance.x + 230; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_PEASANT_NAMES, wifeName), + nameX, nameY, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + char const surname = (char)DAT_UnitsState::instance.units[wifeID].rng1_to_70; + if (surname != 0) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderText2, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_PEASANT_SURNAMES, surname, DAT_MenuHandlerState::instance.x + 235, + DAT_MenuHandlerState::instance.y + 517, OpenSHC::Text::TTA_LEFT, 0, 18, TRUE); + } + } + // a wedding is on: no "No Wedding this month" + if (DAT_00b9843c::instance != 0) { + return; + } + } + } + int const noticeY = DAT_MenuHandlerState::instance.y + 517; + int const noticeX = DAT_MenuHandlerState::instance.x + 175; + // "No Wedding this month" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MARRIAGE, 34), + noticeX, noticeY, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + } + +} +} diff --git a/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp new file mode 100644 index 0000000000..13b5085064 --- /dev/null +++ b/src/OpenSHC/UI/MinimapViewState/locatePlayerKeepPositionsOnMinimap.cpp @@ -0,0 +1,92 @@ +#include "../MinimapViewState.func.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_TileMapState.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004B5F70 + void MinimapViewState::locatePlayerKeepPositionsOnMinimap(uint flags, int widthFactor, int heightFactor) + { + int scale = 1; + int firstRow = 0; + int orientationOffset = 8; + int divisor = 2; + for (int player = 0; player < countof(this->DAT_MapU4B64.keepPositions); ++player) { + this->DAT_MapU4B64.keepPositions[player].x = -1; + this->DAT_MapU4B64.keepPositions[player].y = -1; + } + if ((flags & 4) != 0) { + scale = 2; + } + int const columns = 400 / widthFactor * scale; + int const lastRow = scale * 200; + if (DAT_TileMapState::instance.mapSize <= 200) { + firstRow = 100; + divisor = 1; + } + int const viewportHeight = DAT_ViewportRenderState::instance.viewportState.viewportHeight; + int rowParity = viewportHeight + 1; + if (DAT_TileMapState::instance.mapOrientation != 0) { + if (DAT_TileMapState::instance.mapOrientation == 6) { + orientationOffset = 80408; + } else if (DAT_TileMapState::instance.mapOrientation == 4) { + orientationOffset = 160808; + } else if (DAT_TileMapState::instance.mapOrientation == 2) { + orientationOffset = 241208; + } + } + int const firstColumn = firstRow / 2; + int rowBase = firstColumn * 401 + orientationOffset + 1; + for (int row = firstRow; row < lastRow - firstRow; ++row) { + // the screen tile rows are staggered: every other row is half a tile in and one tile longer + int rowX; + int rowLength; + if (rowParity == viewportHeight + 1) { + rowParity = viewportHeight; + rowX = widthFactor / 2; + rowLength = 200; + } else { + rowParity = viewportHeight + 1; + rowX = 0; + rowLength = 201; + } + if (0 <= row) { + if (400 <= row) { + return; + } + if (scale != 2 || (row * heightFactor & 1) == 0) { + int const lastColumn = columns / divisor - firstColumn; + for (int column = firstColumn; column < lastColumn; ++column) { + int const x = (column - firstColumn) * widthFactor + rowX; + int const buildingID + = DAT_TileMapState::instance.BuildingLayer[DAT_ViewportRenderState::instance + .screenPointToTileNumber[column + rowBase]]; + if (buildingID != 0) { + int const type = DAT_BuildingsState::instance.buildings[buildingID].buildingType; + if (OpenSHC::Map::Buildings::BT_MANORHOUSE <= type + && type <= OpenSHC::Map::Buildings::BT_KEEPFIVE) { + int const owner = DAT_BuildingsState::instance.buildings[buildingID].owner; + if (this->DAT_MapU4B64.keepPositions[owner - 1].x == -1) { + int const y = (row - firstRow) * heightFactor; + if (scale == 1) { + this->DAT_MapU4B64.keepPositions[owner - 1].x = x; + this->DAT_MapU4B64.keepPositions[owner - 1].y = y; + } else { + this->DAT_MapU4B64.keepPositions[owner - 1].x = x / scale; + this->DAT_MapU4B64.keepPositions[owner - 1].y = y / scale; + } + } + } + } + } + } + } + rowBase += rowLength; + } + } + +} +} diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp new file mode 100644 index 0000000000..d2c3f764ae --- /dev/null +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/isMouseOnButtonImageUnk.cpp @@ -0,0 +1,82 @@ +#include "../AlphaAndButtonSurface.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/COL_MAGENTA.hpp" +#include "OpenSHC/Globals/DAT_ButtonX.hpp" +#include "OpenSHC/Globals/DAT_ButtonY.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonGmDataIndex.hpp" +#include "OpenSHC/Globals/DAT_CurrentButtonPictureInGm.hpp" +#include "OpenSHC/Globals/DAT_GMImageHeaders.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_MouseState.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UIButtonDefinedData.hpp" +#include "OpenSHC/Globals/GMFirstPictureIndex.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004630D0 + BOOLEnum AlphaAndButtonSurface::isMouseOnButtonImageUnk() + { + ushort* const surface = this->surfacePtr; + if (DAT_CurrentButtonPictureInGm::instance >= 0) { + int const imageIndex = GMFirstPictureIndex::instance[DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0] + + DAT_CurrentButtonPictureInGm::instance - 1; + int const width = DAT_GMImageHeaders::instance.imh[imageIndex].width; + this->currentImageWidth = width; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ShortValue, DAT_LowLevelMemory::ptr)( + DAT_GMImageHeaders::instance.imh[imageIndex].height * width * 2, + (ushort)COL_MAGENTA::instance.shortValue, surface); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .gmId_0x0, + DAT_CurrentButtonPictureInGm::instance, 0, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return surface[(DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance) * this->currentImageWidth + - DAT_ButtonX::instance + DAT_MouseState::instance.screenSpaceX] + != (ushort)COL_MAGENTA::instance.shortValue; + } + // A negative picture number means the alpha image of the button. + DAT_CurrentButtonPictureInGm::instance = -DAT_CurrentButtonPictureInGm::instance; + int const imageIndex = GMFirstPictureIndex::instance[DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .alphaGmIdUnk_0xc] + + DAT_CurrentButtonPictureInGm::instance - 1; + int const width = DAT_GMImageHeaders::instance.imh[imageIndex].width; + this->currentImageWidth = width; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ShortValue, DAT_LowLevelMemory::ptr)( + DAT_GMImageHeaders::instance.imh[imageIndex].height * width * 2, + (ushort)COL_MAGENTA::instance.shortValue, this->surfacePtr); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_BUTTON_AND_ALPHA; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)((OpenSHC::DE::SHCDE::eGM)DAT_UIButtonDefinedData::instance + .ButtonGmDataArray[DAT_CurrentButtonGmDataIndex::instance] + .alphaGmIdUnk_0xc, + DAT_CurrentButtonPictureInGm::instance, 0, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + ushort const pixel + = surface[this->currentImageWidth * (DAT_MouseState::instance.screenSpaceY - DAT_ButtonY::instance) + + (DAT_MouseState::instance.screenSpaceX - DAT_ButtonX::instance)]; + if (pixel != (ushort)COL_MAGENTA::instance.shortValue && (char)(pixel & 0x1f) >= 31) { + return TRUE; + } + return FALSE; + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp new file mode 100644 index 0000000000..a0fec67402 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/AlphaAndButtonSurface/openBuildingStatusMenuForBuildingID.cpp @@ -0,0 +1,461 @@ +#include "../AlphaAndButtonSurface.func.hpp" + +#include "OpenSHC/Game/GameCore.func.hpp" +#include "OpenSHC/Map/Buildings/BuildingsState.func.hpp" +#include "OpenSHC/Text/TextEditorState.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Map/Buildings/BuildingType.hpp" +#include "OpenSHC/UI/Enums/MenuViewType.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_BuildingsState.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_TextEditorState.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::Map::Buildings::BuildingType; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x00463310 + BOOLEnum AlphaAndButtonSurface::openBuildingStatusMenuForBuildingID(int buildingID) + { + if (buildingID <= 0) { + return FALSE; + } + if (DAT_GameCore::instance.gamePausedLogical != 0) { + return FALSE; + } + short const owner = DAT_BuildingsState::instance.buildings[buildingID].owner; + dword menuTab = 1; + if (owner != DAT_GameSynchronyState::instance.currentPlayerSlotID) { + // Someone else's building: most types are only selected, walls and towers of allies open their menu. + if (owner == 0 + && DAT_BuildingsState::instance.buildings[buildingID].buildingType + == OpenSHC::Map::Buildings::BT_STATUE) { + menuTab = 89; + goto openMenu; + } + switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { + case OpenSHC::Map::Buildings::BT_HOVEL: + case OpenSHC::Map::Buildings::BT_HOUSE: + case OpenSHC::Map::Buildings::BT_WOODCUTTERSHUT: + case OpenSHC::Map::Buildings::BT_OXTETHER: + case OpenSHC::Map::Buildings::BT_IRONMINE: + case OpenSHC::Map::Buildings::BT_PITCHRIG: + case OpenSHC::Map::Buildings::BT_HUNTERSHUT: + case OpenSHC::Map::Buildings::BT_MERCENARYPOST: + case OpenSHC::Map::Buildings::BT_BARRACKS: + case OpenSHC::Map::Buildings::BT_STOCKPILE: + case OpenSHC::Map::Buildings::BT_ARMORY: + case OpenSHC::Map::Buildings::BT_FLETCHER: + case OpenSHC::Map::Buildings::BT_BLACKSMITH: + case OpenSHC::Map::Buildings::BT_POLETURNER: + case OpenSHC::Map::Buildings::BT_ARMOURER: + case OpenSHC::Map::Buildings::BT_TANNER: + case OpenSHC::Map::Buildings::BT_BAKERY: + case OpenSHC::Map::Buildings::BT_BREWERY: + case OpenSHC::Map::Buildings::BT_GRANARY: + case OpenSHC::Map::Buildings::BT_QUARRY: + case OpenSHC::Map::Buildings::BT_INN: + case OpenSHC::Map::Buildings::BT_APOTHECARY: + case OpenSHC::Map::Buildings::BT_ENGINEERSGUILD: + case OpenSHC::Map::Buildings::BT_TUNNELERSGUILD: + case OpenSHC::Map::Buildings::BT_MARKETPLACE: + case OpenSHC::Map::Buildings::BT_WELL: + case OpenSHC::Map::Buildings::BT_OILSMELTER: + case OpenSHC::Map::Buildings::BT_SIEGETENT: + case OpenSHC::Map::Buildings::BT_WHEATFARM: + case OpenSHC::Map::Buildings::BT_HOPFARM: + case OpenSHC::Map::Buildings::BT_APPLEFARM: + case OpenSHC::Map::Buildings::BT_DAIRYFARM: + case OpenSHC::Map::Buildings::BT_MILL: + case OpenSHC::Map::Buildings::BT_STABLES: + case OpenSHC::Map::Buildings::BT_CHAPEL: + case OpenSHC::Map::Buildings::BT_CHURCH: + case OpenSHC::Map::Buildings::BT_CATHEDRAL: + case OpenSHC::Map::Buildings::BT_WOODGATE2: + case OpenSHC::Map::Buildings::BT_TUNNEL: + case OpenSHC::Map::Buildings::BT_GALLOWS: + case OpenSHC::Map::Buildings::BT_STOCKS: + case OpenSHC::Map::Buildings::BT_WITCHHOIST: + case OpenSHC::Map::Buildings::BT_MAYPOLE: + case OpenSHC::Map::Buildings::BT_KILLINGPIT: + case OpenSHC::Map::Buildings::BT_SIEGETOWER_PLACED: + case OpenSHC::Map::Buildings::BT_WATERPOT: + case OpenSHC::Map::Buildings::BT_CESSPIT: + case OpenSHC::Map::Buildings::BT_BURNINGSTAKE: + case OpenSHC::Map::Buildings::BT_GIBBET: + case OpenSHC::Map::Buildings::BT_DUNGEON: + case OpenSHC::Map::Buildings::BT_STRETCHINGRACK: + case OpenSHC::Map::Buildings::BT_RACKFLOGGING: + case OpenSHC::Map::Buildings::BT_CHOPPINGBLOCK: + case OpenSHC::Map::Buildings::BT_DUNKINGSTOOL: + case OpenSHC::Map::Buildings::BT_DOGCAGE: + case OpenSHC::Map::Buildings::BT_STATUE: + case OpenSHC::Map::Buildings::BT_SHRINE: + case OpenSHC::Map::Buildings::BT_BEEHIVE: + case OpenSHC::Map::Buildings::BT_DANCINGBEAR: + case OpenSHC::Map::Buildings::BT_BEARCAVE: + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: + case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: + case OpenSHC::Map::Buildings::BT_WOODGATE1: + case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: + case OpenSHC::Map::Buildings::BT_TOWER1: + case OpenSHC::Map::Buildings::BT_TOWER2: + case OpenSHC::Map::Buildings::BT_TOWER3: + case OpenSHC::Map::Buildings::BT_TOWER4: + case OpenSHC::Map::Buildings::BT_TOWER5: + if (DAT_GameState::instance.mapAndTime.playerTeams[owner] + != DAT_GameState::instance.mapAndTime + .playerTeams[DAT_GameSynchronyState::instance.currentPlayerSlotID]) { + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + } + break; + case OpenSHC::Map::Buildings::BT_OUTPOST_EUROPEAN: + case OpenSHC::Map::Buildings::BT_OUTPOST_ARABIAN: + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_EDITOR) { + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + } + break; + default: + return FALSE; + } + } + MACRO_CALL_MEMBER( + OpenSHC::Map::Buildings::BuildingsState_Func::extendResourceCountdownForPlayerBuildingsOfType, + DAT_BuildingsState::ptr)( + (OpenSHC::Map::Buildings::BuildingType)(DAT_BuildingsState::instance.buildings[buildingID] + .buildingType), + 1, DAT_GameSynchronyState::instance.currentPlayerSlotID); + int const currentPlayer = DAT_GameSynchronyState::instance.currentPlayerSlotID; + switch (DAT_BuildingsState::instance.buildings[buildingID].buildingType) { + case OpenSHC::Map::Buildings::BT_MERCENARYPOST: + menuTab = 44; + break; + case OpenSHC::Map::Buildings::BT_OUTPOST_EUROPEAN: + case OpenSHC::Map::Buildings::BT_OUTPOST_ARABIAN: + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_EDITOR) { + menuTab = 45; + break; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_MANORHOUSE: + case OpenSHC::Map::Buildings::BT_STONEKEEP: + case OpenSHC::Map::Buildings::BT_STRONGHOLD: + case OpenSHC::Map::Buildings::BT_KEEPFOUR: + case OpenSHC::Map::Buildings::BT_KEEPFIVE: + case OpenSHC::Map::Buildings::BT_KEEPDOOR_LEFT: + case OpenSHC::Map::Buildings::BT_KEEPDOOR_RIGHT: + case OpenSHC::Map::Buildings::BT_KEEPDOOR: { + int const taxes + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .taxesSetting; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .taxesSetting2 = taxes; + menuTab = 2; + DAT_GameState::instance.playerDataArray[currentPlayer].taxesSliderUI = taxes; + break; + } + case OpenSHC::Map::Buildings::BT_INN: + menuTab = 3; + break; + case OpenSHC::Map::Buildings::BT_HOVEL: + case OpenSHC::Map::Buildings::BT_HOUSE: + menuTab = 5; + break; + case OpenSHC::Map::Buildings::BT_WOODCUTTERSHUT: + menuTab = 6; + break; + case OpenSHC::Map::Buildings::BT_OXTETHER: + menuTab = 7; + break; + case OpenSHC::Map::Buildings::BT_IRONMINE: + menuTab = 8; + break; + case OpenSHC::Map::Buildings::BT_PITCHRIG: + menuTab = 9; + break; + case OpenSHC::Map::Buildings::BT_HUNTERSHUT: + menuTab = 10; + break; + case OpenSHC::Map::Buildings::BT_STOCKPILE: + menuTab = 11; + break; + case OpenSHC::Map::Buildings::BT_ARMORY: + menuTab = 12; + break; + case OpenSHC::Map::Buildings::BT_FLETCHER: + menuTab = 13; + break; + case OpenSHC::Map::Buildings::BT_BLACKSMITH: + menuTab = 14; + break; + case OpenSHC::Map::Buildings::BT_POLETURNER: + menuTab = 15; + break; + case OpenSHC::Map::Buildings::BT_ARMOURER: + menuTab = 16; + break; + case OpenSHC::Map::Buildings::BT_TANNER: + menuTab = 17; + break; + case OpenSHC::Map::Buildings::BT_BAKERY: + menuTab = 18; + break; + case OpenSHC::Map::Buildings::BT_BREWERY: + menuTab = 19; + break; + case OpenSHC::Map::Buildings::BT_GRANARY: { + int const rations + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .rationsSetting; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .rationsSetting2 = rations; + menuTab = 4; + DAT_GameState::instance.playerDataArray[currentPlayer].rationsSetting3 = rations; + break; + } + case OpenSHC::Map::Buildings::BT_QUARRY: + menuTab = 20; + break; + case OpenSHC::Map::Buildings::BT_QUARRYSTOCKPILE: + menuTab = 21; + break; + case OpenSHC::Map::Buildings::BT_APOTHECARY: + menuTab = 22; + break; + case OpenSHC::Map::Buildings::BT_ENGINEERSGUILD: + menuTab = 23; + break; + case OpenSHC::Map::Buildings::BT_TUNNELERSGUILD: + menuTab = 24; + break; + case OpenSHC::Map::Buildings::BT_MARKETPLACE: + menuTab = 25; + break; + case OpenSHC::Map::Buildings::BT_WELL: + menuTab = 26; + break; + case OpenSHC::Map::Buildings::BT_WATERPOT: + menuTab = 40; + break; + case OpenSHC::Map::Buildings::BT_OILSMELTER: + menuTab = 27; + break; + case OpenSHC::Map::Buildings::BT_SIEGETENT: + menuTab = 28; + break; + case OpenSHC::Map::Buildings::BT_WHEATFARM: + menuTab = 29; + break; + case OpenSHC::Map::Buildings::BT_HOPFARM: + menuTab = 30; + break; + case OpenSHC::Map::Buildings::BT_APPLEFARM: + menuTab = 31; + break; + case OpenSHC::Map::Buildings::BT_DAIRYFARM: + menuTab = 32; + break; + case OpenSHC::Map::Buildings::BT_MILL: + menuTab = 33; + break; + case OpenSHC::Map::Buildings::BT_STABLES: + menuTab = 34; + break; + case OpenSHC::Map::Buildings::BT_CHAPEL: + case OpenSHC::Map::Buildings::BT_CHURCH: + menuTab = 35; + break; + case OpenSHC::Map::Buildings::BT_CATHEDRAL: + menuTab = 96; + break; + case OpenSHC::Map::Buildings::BT_GATEHOUSELARGE: + case OpenSHC::Map::Buildings::BT_GATEHOUSESMALL: + case OpenSHC::Map::Buildings::BT_WOODGATE1: + if (DAT_BuildingsState::instance.buildings[buildingID].field_0x2c6 != 0) { + return FALSE; + } + menuTab = 36; + break; + case OpenSHC::Map::Buildings::BT_DRAWBRIDGE: { + // The drawbridge belongs to the large or the small gatehouse next to it. + int gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), + (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), + OpenSHC::Map::Buildings::BT_GATEHOUSELARGE, 0); + if (gatehouse == 0) { + gatehouse = MACRO_CALL_MEMBER(OpenSHC::Map::Buildings::BuildingsState_Func::findParticularBuilding, + DAT_BuildingsState::ptr)((int)DAT_BuildingsState::instance.buildings[buildingID].owner, + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].x), + (int)((short)DAT_BuildingsState::instance.buildings[buildingID].y), + (int)(DAT_BuildingsState::instance.buildings[buildingID].widthOrHeight), + OpenSHC::Map::Buildings::BT_GATEHOUSESMALL, 0); + } + if (gatehouse != 0 && DAT_BuildingsState::instance.buildings[gatehouse].field_0x2c6 != 0) { + return FALSE; + } + menuTab = 37; + break; + } + case OpenSHC::Map::Buildings::BT_WOODGATE2: + menuTab = 38; + break; + case OpenSHC::Map::Buildings::BT_TUNNEL: + menuTab = 39; + break; + case OpenSHC::Map::Buildings::BT_SIGNPOST: + menuTab = 41; + break; + case OpenSHC::Map::Buildings::BT_KILLINGPIT: + menuTab = 42; + break; + case OpenSHC::Map::Buildings::BT_CAMPGROUND: + menuTab = 43; + break; + case OpenSHC::Map::Buildings::BT_TOWER1: + case OpenSHC::Map::Buildings::BT_TOWER2: + case OpenSHC::Map::Buildings::BT_TOWER3: + case OpenSHC::Map::Buildings::BT_TOWER4: + case OpenSHC::Map::Buildings::BT_TOWER5: + menuTab = 46; + break; + case OpenSHC::Map::Buildings::BT_GALLOWS: + menuTab = 47; + break; + case OpenSHC::Map::Buildings::BT_STOCKS: + menuTab = 48; + break; + case OpenSHC::Map::Buildings::BT_WITCHHOIST: + menuTab = 49; + break; + case OpenSHC::Map::Buildings::BT_MAYPOLE: + menuTab = 50; + break; + case OpenSHC::Map::Buildings::BT_GARDEN: + menuTab = 51; + break; + case OpenSHC::Map::Buildings::BT_CAMPFIRE: + case OpenSHC::Map::Buildings::BT_PARADEGROUND: + case OpenSHC::Map::Buildings::BT_PARADEGROUND2: + case OpenSHC::Map::Buildings::BT_PARADEGROUND3: + case OpenSHC::Map::Buildings::BT_PARADEGROUND4: + case OpenSHC::Map::Buildings::BT_PARADEGROUND5: + menuTab = 52; + break; + case OpenSHC::Map::Buildings::BT_CATAPULT: + menuTab = 58; + break; + case OpenSHC::Map::Buildings::BT_TREBUCHET: + menuTab = 59; + break; + case OpenSHC::Map::Buildings::BT_BATTERINGRAM: + menuTab = 60; + break; + case OpenSHC::Map::Buildings::BT_SIEGETOWER: + menuTab = 61; + break; + case OpenSHC::Map::Buildings::BT_SHIELD: + menuTab = 62; + break; + case OpenSHC::Map::Buildings::BT_FIREBALLISTA: + menuTab = 95; + break; + case OpenSHC::Map::Buildings::BT_CESSPIT: + menuTab = 80; + break; + case OpenSHC::Map::Buildings::BT_BURNINGSTAKE: + menuTab = 81; + break; + case OpenSHC::Map::Buildings::BT_GIBBET: + menuTab = 82; + break; + case OpenSHC::Map::Buildings::BT_DUNGEON: + menuTab = 83; + break; + case OpenSHC::Map::Buildings::BT_STRETCHINGRACK: + menuTab = 84; + break; + case OpenSHC::Map::Buildings::BT_RACKFLOGGING: + menuTab = 85; + break; + case OpenSHC::Map::Buildings::BT_CHOPPINGBLOCK: + menuTab = 86; + break; + case OpenSHC::Map::Buildings::BT_DUNKINGSTOOL: + menuTab = 87; + break; + case OpenSHC::Map::Buildings::BT_DOGCAGE: + menuTab = 88; + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .releaseDogsFlag + = DAT_BuildingsState::instance.buildings[buildingID].flagonsOfAleOrCheeseOrReleaseDogs; + break; + case OpenSHC::Map::Buildings::BT_STATUE: + menuTab = 89; + break; + case OpenSHC::Map::Buildings::BT_SHRINE: + menuTab = 90; + break; + case OpenSHC::Map::Buildings::BT_BEEHIVE: + menuTab = 91; + break; + case OpenSHC::Map::Buildings::BT_DANCINGBEAR: + menuTab = 92; + break; + case OpenSHC::Map::Buildings::BT_BEARCAVE: + menuTab = 94; + break; + case OpenSHC::Map::Buildings::BT_SIEGETOWER_PLACED: + DAT_BuildingsState::instance.selectedBuildingID = buildingID; + DAT_BuildingsState::instance.selectedBuildingUID + = DAT_BuildingsState::instance.buildings[buildingID].uid; + return FALSE; + case OpenSHC::Map::Buildings::BT_BARRACKS: + break; + default: + return FALSE; + } + openMenu: + MACRO_CALL_MEMBER( + OpenSHC::Text::TextEditorState_Func::closeHelpDialogAndReturnToMenu, DAT_TextEditorState::ptr)(); + DAT_GameCore::instance.buildingandstatusmenuMenuTabToSwitchTo = menuTab; + MACRO_CALL_MEMBER(OpenSHC::Game::GameCore_Func::switchToMenuView, DAT_GameCore::ptr)( + OpenSHC::UI::Enums::MVT_BUILDING_AND_STATUS_MENU, 0); + DAT_BuildingsState::instance.newSelectedBuildingID = buildingID; + DAT_BuildingsState::instance.newSelectedUnitID = 0; + if (DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CRUSADER_TUTORIAL) { + MACRO_CALL(OpenSHC::UI::Helpers_Func::SetTutorialBuildingActionState)( + 8, (BuildingType)((int)((short)DAT_BuildingsState::instance.buildings[buildingID].buildingType))); + } + DAT_BuildingsState::instance.selectedBuildingID = 0; + DAT_BuildingsState::instance.selectedBuildingUID = 0; + return TRUE; + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp new file mode 100644 index 0000000000..de203babd4 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderGreatestLordScreen.cpp @@ -0,0 +1,643 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/GreatestLord.func.hpp" +#include "OpenSHC/UI/Rendering/PencilRenderCore.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/CHAR_00eb0e44.hpp" +#include "OpenSHC/Globals/COL_WHITE.hpp" +#include "OpenSHC/Globals/DAT_00eb9af8.hpp" +#include "OpenSHC/Globals/DAT_00ed3118.hpp" +#include "OpenSHC/Globals/DAT_BlendingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_FinalResultsOrderByColumn.hpp" +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_MissionDefinedData.hpp" +#include "OpenSHC/Globals/DAT_PencilRenderCore.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00ec082c.hpp" + +namespace OpenSHC { +namespace UI { + + using OpenSHC::DE::SHCDE::eTextSections; + + // The tables behind the Greatest Lord screen, one entry per player slot (index 0 unused). The original keeps them + // in one block of the stack frame, and its statistic orders are filled by one strided loop, so they are one + // struct here rather than separate arrays. + struct GreatestLordTablesUnk { + int points[9]; + int stars[9]; + int overallOrder[9]; + int kills[9]; + int losses[9]; + // Player order per statistic, best first: 0 kills, 1 buildings burned, 2 food, 3 gold, 4 max population, + // 5 wood, 6 stone, 7 iron, 8 pitch, 9 unused, 10 losses, 11 weapons, 12 buildings lost, 13 troops, + // 14 goods received, 15 goods sent. + int statOrder[16][9]; + }; + + // FUNCTION: STRONGHOLDCRUSADER 0x004D5810 + void Rendering::RenderGreatestLordScreen() + { + int columnOffset; + int index; + int x; + GreatestLordTablesUnk tables; + char saveText[100]; + char scoreText[100]; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + x = DAT_MenuHandlerState::instance.x + 10; + columnOffset = 58; + } else { + x = DAT_MenuHandlerState::instance.x - 102; + columnOffset = 522; + } + int y = DAT_MenuHandlerState::instance.y; + + for (int player = 1; player < 9; ++player) { + tables.points[player] = 0; + } + for (int player = 1; player < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix); + ++player) { + int kills = 0; + for (int victim = 1; victim < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[0]); + ++victim) { + if (victim != player) { + kills += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[player][victim]; + } + } + tables.kills[player] = kills; + int losses = 0; + for (int killer = 0; killer < countof(DAT_GameSynchronyState::instance.finalResults.finalKillMatrix); + ++killer) { + if (killer != player) { + losses += DAT_GameSynchronyState::instance.finalResults.finalKillMatrix[killer][player]; + } + } + tables.losses[player] = losses; + } + for (int player = 1; player < 9; ++player) { + tables.stars[player] = 0; + } + for (int player = 1; player < 9; ++player) { + tables.overallOrder[player] = player; + for (int stat = 0; stat < 16; ++stat) { + tables.statOrder[stat][player] = player; + } + } + + // bubble sort every order at once; index is the pass here and the rank further down + for (index = 8; index > 0; --index) { + for (int i = 1; i < index; ++i) { + int const first = tables.overallOrder[i]; + int const firstScore = MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)(first); + int const second = tables.overallOrder[i + 1]; + int const secondScore = MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)(second); + if (firstScore < secondScore + || firstScore == secondScore + && (DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[first] + < DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[second] + || DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[first] + == DAT_GameSynchronyState::instance.finalResults.finalTimeAlive[second] + && DAT_GameState::instance.mapAndTime.playerIsAlive[first] + < DAT_GameState::instance.mapAndTime.playerIsAlive[second])) { + tables.overallOrder[i] = second; + tables.overallOrder[i + 1] = first; + } + + int current = tables.statOrder[0][i]; + if (tables.kills[current] < tables.kills[tables.statOrder[0][i + 1]]) { + tables.statOrder[0][i] = tables.statOrder[0][i + 1]; + tables.statOrder[0][i + 1] = current; + } + current = tables.statOrder[10][i]; + if (tables.losses[tables.statOrder[10][i + 1]] < tables.losses[current]) { + tables.statOrder[10][i] = tables.statOrder[10][i + 1]; + tables.statOrder[10][i + 1] = current; + } + current = tables.statOrder[1][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[current] + < DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][i + 1]]) { + tables.statOrder[1][i] = tables.statOrder[1][i + 1]; + tables.statOrder[1][i + 1] = current; + } + current = tables.statOrder[2][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][i + 1]]) { + tables.statOrder[2][i] = tables.statOrder[2][i + 1]; + tables.statOrder[2][i + 1] = current; + } + current = tables.statOrder[3][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGold[current] + < DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][i + 1]]) { + tables.statOrder[3][i] = tables.statOrder[3][i + 1]; + tables.statOrder[3][i + 1] = current; + } + current = tables.statOrder[4][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[current] + < DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][i + 1]]) { + tables.statOrder[4][i] = tables.statOrder[4][i + 1]; + tables.statOrder[4][i + 1] = current; + } + current = tables.statOrder[5][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][i + 1]]) { + tables.statOrder[5][i] = tables.statOrder[5][i + 1]; + tables.statOrder[5][i + 1] = current; + } + current = tables.statOrder[6][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][i + 1]]) { + tables.statOrder[6][i] = tables.statOrder[6][i + 1]; + tables.statOrder[6][i + 1] = current; + } + current = tables.statOrder[7][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalIronProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][i + 1]]) { + tables.statOrder[7][i] = tables.statOrder[7][i + 1]; + tables.statOrder[7][i + 1] = current; + } + current = tables.statOrder[8][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][i + 1]]) { + tables.statOrder[8][i] = tables.statOrder[8][i + 1]; + tables.statOrder[8][i + 1] = current; + } + current = tables.statOrder[11][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][i + 1]]) { + tables.statOrder[11][i] = tables.statOrder[11][i + 1]; + tables.statOrder[11][i + 1] = current; + } + current = tables.statOrder[12][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[tables.statOrder[12][i + 1]] + < DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[current]) { + tables.statOrder[12][i] = tables.statOrder[12][i + 1]; + tables.statOrder[12][i + 1] = current; + } + current = tables.statOrder[13][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[current] + < DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[tables.statOrder[13][i + 1]]) { + tables.statOrder[13][i] = tables.statOrder[13][i + 1]; + tables.statOrder[13][i + 1] = current; + } + current = tables.statOrder[14][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[current] + < DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[tables.statOrder[14][i + 1]]) { + tables.statOrder[14][i] = tables.statOrder[14][i + 1]; + tables.statOrder[14][i + 1] = current; + } + current = tables.statOrder[15][i]; + if (DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[current] + < DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[tables.statOrder[15][i + 1]]) { + tables.statOrder[15][i] = tables.statOrder[15][i + 1]; + tables.statOrder[15][i + 1] = current; + } + } + } + + // bonus points for the winner and for a clear lead in a statistic + tables.points[tables.overallOrder[1]] += 3; + if (tables.kills[tables.statOrder[0][1]] > 10 + && tables.kills[tables.statOrder[0][1]] > tables.kills[tables.statOrder[0][2]] * 2) { + tables.points[tables.statOrder[0][1]] += 3; + } + int value = DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][1]]; + if (value > 2 + && value > DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[tables.statOrder[1][2]] * 2) { + tables.points[tables.statOrder[1][1]] += 2; + } + value = DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][1]]; + if (value > 50 + && value > DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[tables.statOrder[2][2]] * 2) { + tables.points[tables.statOrder[2][1]] += 2; + } + value = DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][1]]; + if (value > 100 + && value > DAT_GameSynchronyState::instance.finalResults.finalGold[tables.statOrder[3][2]] * 2) { + tables.points[tables.statOrder[3][1]] += 3; + } + short const maxPopulation + = DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][1]]; + if (maxPopulation > 24 + && maxPopulation + > DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[tables.statOrder[4][2]] * 2) { + // fixme: the original gives the population point to the player with the most kills + ++tables.points[tables.statOrder[0][1]]; + } + value = DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][1]]; + if (value > 100 + && value > DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[tables.statOrder[5][2]] * 2) { + ++tables.points[tables.statOrder[5][1]]; + } + value = DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][1]]; + if (value > 50 + && value > DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[tables.statOrder[6][2]] * 2) { + ++tables.points[tables.statOrder[6][1]]; + } + value = DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][1]]; + if (value > 10 + && value > DAT_GameSynchronyState::instance.finalResults.finalIronProduced[tables.statOrder[7][2]] * 2) { + ++tables.points[tables.statOrder[7][1]]; + } + value = DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][1]]; + if (value > 20 + && value > DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[tables.statOrder[8][2]] * 2) { + ++tables.points[tables.statOrder[8][1]]; + } + value = DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][1]]; + if (value > 20 + && value + > DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[tables.statOrder[11][2]] * 2) { + ++tables.points[tables.statOrder[11][1]]; + } + + // three points per star, at most five, and at most four unless player slot 1 took part + int starLimitUnk = 0; + if (DAT_GameSynchronyState::instance.finalResults.active[1]) { + starLimitUnk = 8; + } + for (int player = 1; player < 9; ++player) { + tables.stars[player] = tables.points[player] / 3; + if (tables.points[player] / 3 > 5) { + tables.stars[player] = 5; + } + if (starLimitUnk < 4 && tables.stars[player] == 5) { + tables.stars[player] = 4; + } + } + + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x, DAT_MenuHandlerState::instance.y, + DAT_MenuHandlerState::instance.x + 800, DAT_MenuHandlerState::instance.y + 600, 16); + // "Greatest Lord" + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, DAT_PencilRenderCore::ptr)( + OpenSHC::DE::SHCDE::TEXT_MP_RANK, 1, DAT_MenuHandlerState::instance.x + 40, y, 720, 720); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBlendedBlackBox, + DAT_PencilRenderCore::ptr)(DAT_MenuHandlerState::instance.x - 112, + DAT_MenuHandlerState::instance.y - 84, DAT_MenuHandlerState::instance.x + 912, + DAT_MenuHandlerState::instance.y + 684, 16); + // "Greatest Lord" + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::PencilRenderCore_Func::drawHeaderTextBanner, DAT_PencilRenderCore::ptr)( + OpenSHC::DE::SHCDE::TEXT_MP_RANK, 1, DAT_MenuHandlerState::instance.x - 104, y - 30, 1008, 0); + y += 20; + } + y += 190; + int iconY = y - 18; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + int player; + for (index = 0; index < 8; ++index) { + switch (DAT_FinalResultsOrderByColumn::instance) { + case 0: + player = tables.overallOrder[index + 1]; + break; + case 1: + player = tables.statOrder[0][index + 1]; + break; + case 2: + player = tables.statOrder[1][index + 1]; + break; + case 3: + player = tables.statOrder[10][index + 1]; + break; + case 4: + player = tables.statOrder[3][index + 1]; + break; + case 5: + player = tables.statOrder[2][index + 1]; + break; + case 6: + player = tables.statOrder[5][index + 1]; + break; + case 7: + player = tables.statOrder[6][index + 1]; + break; + case 8: + player = tables.statOrder[7][index + 1]; + break; + case 9: + player = tables.statOrder[8][index + 1]; + break; + case 10: + player = tables.statOrder[4][index + 1]; + break; + case 11: + player = tables.statOrder[11][index + 1]; + break; + case 12: + player = tables.statOrder[12][index + 1]; + break; + case 13: + player = tables.statOrder[13][index + 1]; + break; + case 14: + player = tables.statOrder[14][index + 1]; + break; + case 15: + player = tables.statOrder[15][index + 1]; + break; + } + if (!DAT_GameSynchronyState::instance.finalResults.active[player]) { + continue; + } + char* const name = DAT_GameSynchronyState::instance.finalResults.names[player]; + DAT_TextManagerObject::instance.field_0x30 = 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText6Unk, DAT_TextManagerObject::ptr)( + name, x, y, 260, + DAT_RenderingDefinedData::instance + .ColorArray[DAT_BlendingDefinedData::instance.PlayerSlotUnitColor[player]], + 0, 18, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)(name, 18); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + int iconX = x; + if (DAT_GameState::instance.mapAndTime.playerIsAlive[player] != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 139, x, iconY - 2); + iconX = x + 22; + } + for (int star = 0; star < tables.stars[player]; ++star) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 139, iconX, iconY - 2); + iconX += 22; + } + for (int lord = 0; lord < DAT_GameSynchronyState::instance.finalResults.finalKilledLords[player]; ++lord) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 138, iconX, iconY - 5); + iconX += 22; + } + if (DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] != 0) { + // "(" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_close_005a2778, iconX + 8, iconY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, DAT_TextureRenderCoreObject::ptr)( + OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS2, 665, iconX + 14, iconY - 5); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] % 12), + iconX + 28, iconY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, FALSE, 0); + iconX += 32; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalDateOfDeathInMonths[player] / 12, iconX, iconY, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 19, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + s_brace_open_005a2774, iconX, iconY, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 19, TRUE, 0); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + if (INT_00ec082c::instance == 0 || INT_00ec082c::instance == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + tables.kills[player], x + 279, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + tables.losses[player], x + 337, y, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGold[player], x + 395, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalFoodProduced[player], x + 453, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalWoodProduced[player], x + 511, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalStoneProduced[player], x + 569, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalIronProduced[player], x + 627, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalPitchProduced[player], x + 685, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalWeaponsProduced[player], x + 743, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + if (INT_00ec082c::instance == 1 || INT_00ec082c::instance == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalMaxPopulation[player], columnOffset + 279 + x, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, + DAT_GameSynchronyState::instance.finalResults.finalMaxGoodThings[player] * 6 + - DAT_GameSynchronyState::instance.finalResults.finalMaxBadThings[player] + 140, + columnOffset + 330 + x, y, OpenSHC::IO::Graphics::GID_INTERFACE_ICONS_3, 176, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalBuildingsBurned[player], columnOffset + 395 + x, + y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalBuidingsDestroyed[player], + columnOffset + 453 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, + FALSE, 0); + if (INT_00ec082c::instance == 1) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], + columnOffset + 511 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], + columnOffset + 569 + x, y, OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, + 18, FALSE, 0); + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], columnOffset + 627 + x, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + } + if (INT_00ec082c::instance == 3) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalTroopsProduced[player], x + 511, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsRecieved[player], x + 569, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameSynchronyState::instance.finalResults.finalGoodsSent[player], x + 627, y, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + } + y += 45; + iconY += 45; + } + + if (CHAR_00eb0e44::instance == '\0') { + if (DAT_00eb9af8::instance == 0 + && DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearStart != 0) { + // fixme: the original writes the date into the (no longer needed) statistic orders + char* const dateText = (char*)tables.statOrder[0]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(dateText, s__s__d____s__d_005aaf3c, + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.tail.tail1.monthStart), + DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearStart, + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_MONTHS, + DAT_GameSynchronyState::instance.finalResults.tail.tail1.monthEnd), + DAT_GameSynchronyState::instance.finalResults.tail.tail1.yearEnd); + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 545, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + dateText, DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 575, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 602, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + dateText, DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 632, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + } + } else if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 457, DAT_MenuHandlerState::instance.y + 560, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)((eTextSections)DAT_MissionDefinedData::instance + .GreatestLordTextEntries[DAT_00eb9af8::instance][0], + DAT_MissionDefinedData::instance.GreatestLordTextEntries[DAT_00eb9af8::instance][1]), + DAT_MenuHandlerState::instance.x + 412, DAT_MenuHandlerState::instance.y + 617, + OpenSHC::Text::TTA_CENTER, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + } + } + DAT_00eb9af8::instance = DAT_FinalResultsOrderByColumn::instance; + if (CHAR_00eb0e44::instance == '\0') { + return; + } + + // Extreme: show the score and the save file to submit it with + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(scoreText, s____d_005aaf2c, + MACRO_CALL(OpenSHC::UI::GreatestLord_Func::ComputeSkMasterScore)( + DAT_GameSynchronyState::instance.currentPlayerSlotID)); + MACRO_CALL(OpenSHC::OS_Func::_sprintf)( + saveText, s____M_d_d_sav_005aaf18, DAT_GameCore::instance.extremeTrailProgress + 1, DAT_00ed3118::instance); + int boxRight; + int boxLeft; + int boxTop; + int boxBottom; + if (DAT_WindowAndDirectDraw::instance.currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + // "Extreme Score" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + scoreText, DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + // "Save File" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 553, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 50 + DAT_MenuHandlerState::instance.x; + // "To submit this score, visit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), + DAT_MenuHandlerState::instance.x + 50, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // "www.fireflyworlds.com" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), + DAT_MenuHandlerState::instance.x + 56, DAT_MenuHandlerState::instance.y + 575, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_FFFFFF, 18, TRUE, 0); + if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x) { + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 + 56 + DAT_MenuHandlerState::instance.x; + } + boxLeft = DAT_MenuHandlerState::instance.x + 30; + boxTop = DAT_MenuHandlerState::instance.y + 546; + boxBottom = DAT_MenuHandlerState::instance.y + 595; + } else { + // "Extreme Score" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 27), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + scoreText, DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + // "Save File" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 28), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)(saveText, + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 610, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, TRUE, 0); + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 42 + DAT_MenuHandlerState::instance.x; + // "To submit this score, visit" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 29), + DAT_MenuHandlerState::instance.x - 42, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_CCFAFF, 18, FALSE, 0); + // "www.fireflyworlds.com" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_SKIRMISH_CHOOSE2, 30), + DAT_MenuHandlerState::instance.x - 36, DAT_MenuHandlerState::instance.y + 632, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_FFFFFF, 18, TRUE, 0); + if (boxRight < DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x) { + boxRight = DAT_TextManagerObject::instance.currentXOffset_0x0 - 36 + DAT_MenuHandlerState::instance.x; + } + boxLeft = DAT_MenuHandlerState::instance.x - 62; + boxTop = DAT_MenuHandlerState::instance.y + 603; + boxBottom = DAT_MenuHandlerState::instance.y + 652; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::PencilRenderCore_Func::drawBorderBox, DAT_PencilRenderCore::ptr)( + boxLeft, boxTop, boxRight + 20, boxBottom, COL_WHITE::instance.shortValue); + } + +} +} diff --git a/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp new file mode 100644 index 0000000000..dbf243e10c --- /dev/null +++ b/src/OpenSHC/UI/Rendering/RenderMissionObjectivesUnk.cpp @@ -0,0 +1,502 @@ +#include "../Rendering.func.hpp" + +#include "OpenSHC/Game/GameStateStructures.func.hpp" +#include "OpenSHC/Global.func.hpp" +#include "OpenSHC/Text/FontSizeClass.func.hpp" +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode2.hpp" +#include "OpenSHC/Game/Resources/ResourceType.hpp" +#include "OpenSHC/Game/ScenarioEvents/Enums/ScenarioEventConditionIndex.hpp" +#include "OpenSHC/IO/Graphics/GmID.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_GameCore.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MapPropertiesState.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" +#include "OpenSHC/Globals/INT_00eb0b24.hpp" +#include "OpenSHC/Globals/INT_00ec02e8.hpp" +#include "OpenSHC/Globals/INT_00ed27c4.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00eb1238.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed2630.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed2fc8.hpp" +#include "OpenSHC/Globals/INT_ARRAY_00ed3070.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x004D76A0 + int Rendering::RenderMissionObjectivesUnk() + { + int y = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 100; + int value = 0; + int boxX = 300; + int eventIndex = -1; + int column = 200; + int const headerX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30; + int const headerY = DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 50; + DAT_TextManagerObject::instance.field_0x24 = 1; + if (DAT_GameCore::instance.section1095 == 2) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 26), + headerX, headerY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + } else { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 0), + headerX, headerY, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + + // first pass: measure the texts for the number column and the tick boxes + for (int objective = 0; objective < OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER; ++objective) { + if (INT_ARRAY_00ed2630::instance[objective] == 0) { + continue; + } + if ((objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_4_CATTLE_FARMS + || objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_2_INNS) + && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + continue; + } + int textIndex = objective; + if (objective >= OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED) { + textIndex = objective + 1; + } + if (textIndex == 17) { + textIndex = 6; + } else if (textIndex == 15) { + textIndex = 8; + } + int const textWidth + = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, textIndex), + 18); + int const textEnd = textWidth + 30; + if (textEnd > boxX - 5) { + boxX = textWidth + 35; + } + int numberWidth; + switch (objective) { + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: + if (textEnd > column - 5) { + column = textWidth + 35; + } + numberWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], 18); + if (DAT_GameCore::instance.gameSuspended == 1) { + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + switch (objective) { + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentPopulation; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[Game::Resources::RT_GOLD]; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .previousBlessedPeoplePercentage; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + value = -DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + } + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); + } + if (numberWidth + column > boxX - 5) { + boxX = numberWidth + column + 5; + } + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17: + if (textEnd > column - 5) { + column = textWidth + 35; + } + numberWidth = MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], 18); + if (INT_ARRAY_00eb1238::instance[objective] > 0) { + numberWidth = numberWidth + + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::computeTextWidth, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, INT_ARRAY_00eb1238::instance[objective]), + 18) + + 6; + } + if (DAT_GameCore::instance.gameSuspended == 1) { + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeTextWidth, + DAT_TextManagerObject::ptr)((char*)s___005aaf78, 18); + int resource = INT_ARRAY_00eb1238::instance[objective]; + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[resource]; + numberWidth += MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::computeNumberTextWidth, + DAT_TextManagerObject::ptr)(value, 18); + } + if (numberWidth + column > boxX - 5) { + boxX = numberWidth + column + 5; + } + break; + } + } + + // second pass: draw them + for (int objective = 0; objective < OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER; ++objective) { + if (INT_ARRAY_00ed2630::instance[objective] == 0) { + continue; + } + if ((objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_4_CATTLE_FARMS + || objective == OpenSHC::Game::ScenarioEvents::Enums::SECI_2_INNS) + && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_BUILDERUnk) { + continue; + } + int textIndex = objective; + if (objective >= OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED) { + textIndex = objective + 1; + } + if (textIndex == 17 || textIndex == 5 || textIndex == 6) { + textIndex = 7; + } else if (textIndex == 15) { + textIndex = 8; + } else if (textIndex == 3 && DAT_GameCore::instance.gameMode_2 == OpenSHC::Game::GM_CAMPAIGN_MISSION) { + if (DAT_GameCore::instance.missionNumber1to20 == 13) { + textIndex = 12; + } else if (DAT_GameCore::instance.missionNumber1to20 == 18) { + textIndex = 13; + } else if (DAT_GameCore::instance.missionNumber1to20 == 21) { + textIndex = 14; + } + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, textIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + switch (objective) { + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + if (DAT_GameCore::instance.gameSuspended != 1) { + break; + } + // " (" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + switch (objective) { + case OpenSHC::Game::ScenarioEvents::Enums::SECI_POPULATION: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentPopulation; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOLD_ACQUIRED: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[Game::Resources::RT_GOLD]; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_BLESSED: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .previousBlessedPeoplePercentage; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_PERCENT_DRINKING_ALE: + value = MACRO_CALL_MEMBER(OpenSHC::Game::GameStateStructures_Func::computeAleCoverage, + DAT_GameState::ptr)(DAT_GameSynchronyState::instance.currentPlayerSlotID); + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_CRUELTY: + value = -DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_MAXIMUM_PLEASANTNESS: + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + break; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s_brace_open_005a2774, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + break; + case OpenSHC::Game::ScenarioEvents::Enums::SECI_FOOD_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_GOODS_ACQUIRED: + case OpenSHC::Game::ScenarioEvents::Enums::SECI_WEAPONS_ACQUIRED_17: + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, + DAT_TextManagerObject::ptr)(INT_ARRAY_00ed2fc8::instance[objective], + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + if (INT_ARRAY_00eb1238::instance[objective] > 0) { + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_GOODS, INT_ARRAY_00eb1238::instance[objective]), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + } + if (DAT_GameCore::instance.gameSuspended != 1) { + break; + } + // " (" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s___005aaf74, DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, + OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + { + int resource = INT_ARRAY_00eb1238::instance[objective]; + if (resource == Game::Resources::RT_PARTIALPITCH) { + resource = Game::Resources::RT_PITCH; + } + value = DAT_GameState::instance + .playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[resource]; + } + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)(value, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + // ")" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + (char*)s_brace_open_005a2774, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + column + 6, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, TRUE, 0); + break; + } + // tick box: done or not + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + if (INT_ARRAY_00ed3070::instance[objective] != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_BUTTONS, 6, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + boxX, y - 25); + } else { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_BUTTONS, 5, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + boxX, y); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y += 30; + } + + // The win timer: a progress bar + if (INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_WIN_TIMER] != 0 + && DAT_MapPropertiesState::instance.SEC_Section1081) { + int const total = DAT_MapPropertiesState::instance.SEC_Section1090; + int done = DAT_MapPropertiesState::instance.SEC_Section1090 + - DAT_MapPropertiesState::instance.SEC_Section1080; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, 25), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; + if (DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 + > barX) { + barX = DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 2, barX + 2, y + 1, 24); + if (done > total) { + done = total; + } + if (done != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRect, + DAT_TextureRenderCoreObject::ptr)( + 0, 0, done * 250 / total + barX + 2, DAT_WindowAndDirectDraw::instance.resolutionY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawTgxGmOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 4, barX + 2, y + 1); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRectToGameResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 1, barX, y - 1, + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y += 21; + } + + // time until the next one-off invasion or the deadline of the mission, as a progress bar + int timerText = 15; + if (INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_NO_ENEMY_AND_INVASIONS_LEFT] + != 0 + || INT_ARRAY_00ed2630::instance[OpenSHC::Game::ScenarioEvents::Enums::SECI_NO_ENEMY_ON_MAP] != 0 + || INT_00ec02e8::instance) { + for (int i = 0; i < DAT_MapPropertiesState::instance.eventsCount; ++i) { + if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 1 + && DAT_MapPropertiesState::instance.scenarioEvents[i].data.invasion.repeatMonths == 0) { + eventIndex = i; + } else if (DAT_MapPropertiesState::instance.scenarioEvents[i].header.tl_type == 3 + && DAT_MapPropertiesState::instance.scenarioEvents[i] + .data.scenario.conditions[OpenSHC::Game::ScenarioEvents::Enums::SECI_AUTO_STOP] + .enabled + && (DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType == 1 + || DAT_MapPropertiesState::instance.scenarioEvents[i].data.scenario.ScenarioEventType + == 27)) { + if (eventIndex == -1) { + eventIndex = i; + timerText = 17; + } + break; + } + } + if (eventIndex >= 0) { + int const start = DAT_MapPropertiesState::instance.SEC_StartingMonth + + DAT_MapPropertiesState::instance.SEC_StartingYear * 12; + int const total = DAT_MapPropertiesState::instance.scenarioEvents[eventIndex].header.month + + DAT_MapPropertiesState::instance.scenarioEvents[eventIndex].header.year * 12 - start; + int elapsed = DAT_GameState::instance.mapAndTime.year * 12 - start + + DAT_GameState::instance.mapAndTime.month; + if (!DAT_GameCore::instance.gameSuspended) { + elapsed = 0; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_OBJECTIVES, timerText), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 30, y, OpenSHC::Text::TTA_LEFT, + OpenSHC::Rendering::Colors::COL_C2F0EB, 18, FALSE, 0); + int barX = DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 301; + if (DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40 + > barX) { + barX = DAT_TextManagerObject::instance.currentXOffset_0x0 + + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithBlending, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 2, barX + 2, y + 1, 24); + if (elapsed > total) { + elapsed = total; + } + if (elapsed != 0) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRect, + DAT_TextureRenderCoreObject::ptr)( + 0, 0, elapsed * 250 / total + barX + 2, DAT_WindowAndDirectDraw::instance.resolutionY); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::drawTgxGmOnFlaggedSurface, + DAT_TextureRenderCoreObject::ptr)( + OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 4, barX + 2, y + 1); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::TextureRenderCore_Func::setRenderingRectToGameResolution, + DAT_TextureRenderCoreObject::ptr)(); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGMWithAlphaMask, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 1, barX, + y - 1, OpenSHC::IO::Graphics::GID_INTERFACE_SLIDER_BAR, 3, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue + = OpenSHC::Rendering::Enums::RT_MAP_GAME; + y += 21; + } + } + } + + if (DAT_GameCore::instance.gameMode_2 != OpenSHC::Game::GM_BUILDERUnk) { + return y; + } + // builder mode: the map name and its description, scrolled by pages + int const offset = y - DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - 30; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL(OpenSHC::Global_Func::GetStringBasedOnHardcodedMaps)( + DAT_GameCore::instance.standaloneFilename, &eventIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 400, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + 10, OpenSHC::Text::TTA_CENTER, + OpenSHC::Rendering::Colors::COL_CCFAFF, 17, FALSE, 0); + // the visible height, rounded up to whole lines of 23 pixels + int pageHeight = 377 - offset; + pageHeight += 22 - (pageHeight + 22) % 23; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRange, + DAT_TextureRenderCoreObject::ptr)(DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + offset + 45, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight + pageHeight + offset + 45); + if (!DAT_GameCore::instance.descriptionUseStringTable) { + INT_00ed27c4::instance = (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, 0, 0, 720, 0, 0, 1) + - 1) + / pageHeight + + 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + DAT_GameCore::instance.temporaryTextBufferOfSize1000, + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - INT_00eb0b24::instance * pageHeight + offset + + 50, + 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); + } else if (DAT_GameCore::instance.descriptionStringTableIndex) { + INT_00ed27c4::instance + = (MACRO_CALL_MEMBER(OpenSHC::Text::FontSizeClass_Func::renderMultilineTextUnk, + &DAT_TextManagerObject::instance.fontSizeClassArray[18])( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex), + 0, 0, 720, 0, 0, 1) + - 1) + / pageHeight + + 1; + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderMultilineText5Unk, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER( + OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, DAT_TextManagerObject::ptr)( + OpenSHC::DE::SHCDE::TEXT_MAP_NAMES, DAT_GameCore::instance.descriptionStringTableIndex), + DAT_WindowAndDirectDraw::instance.mainMenuBorderWidth + 40, + DAT_WindowAndDirectDraw::instance.mainMenuBorderHeight - INT_00eb0b24::instance * pageHeight + offset + + 50, + 720, OpenSHC::Rendering::Colors::COL_C2F0EB, 18, 0); + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::setScreenMenuSurfaceHeightRangeToResolution, + DAT_TextureRenderCoreObject::ptr)(); + return y; + } + +} +} diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp new file mode 100644 index 0000000000..e821e4228d --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/bltMapGameSurfaceToScreen.cpp @@ -0,0 +1,54 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x004706E0 + void WindowAndDirectDraw::bltMapGameSurfaceToScreen( + int windowedX, int windowedY, int windowedWidth, int windowedHeigth) + { + if (!this->drawingReady_0x0) { + return; + } + if (GetForegroundWindow() != this->windowHandle) { + return; + } + RECT sourceRect; + RECT destinationRect; + int const cameraOffsetX = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + if (!this->NOTSelfBufferOrWindowMode_0xf8) { + sourceRect.left = windowedX - 32; + sourceRect.top = windowedY - 8; + sourceRect.right = windowedWidth + 32; + sourceRect.bottom = windowedHeigth + 8; + destinationRect.right = this->clientOnScreenCoords.left - cameraOffsetX + windowedWidth + 32; + destinationRect.left = this->clientOnScreenCoords.left - cameraOffsetX + windowedX - 32; + destinationRect.top = this->clientOnScreenCoords.top + - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + windowedY - 8; + destinationRect.bottom = this->clientOnScreenCoords.top + - DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY + windowedHeigth + 8; + } else { + sourceRect.left = 0; + sourceRect.top = 0; + sourceRect.right = this->gameResolutionX; + sourceRect.bottom = this->gameResolutionY; + destinationRect.left = 0; + destinationRect.top = 0; + destinationRect.right = this->gameResolutionX; + destinationRect.bottom = this->gameResolutionY; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + this)(&destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, this->directDrawOffscreenSurfacePointer_mapGame, &sourceRect, DDBLT_WAIT, NULL); + if (this->NOTSelfBufferOrWindowMode_0xf8 == TRUE) { + this->directDrawPrimarySurfacePointer->Flip(NULL, DDFLIP_WAIT); + } + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp new file mode 100644 index 0000000000..7da33efa08 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/prepareWindowAndDDraw_2Unk.cpp @@ -0,0 +1,65 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/Rendering/Bink/BinkControlClass.func.hpp" +#include "OpenSHC/Rendering/ScreenResolutionEnum.hpp" +#include "OpenSHC/WindowsHelper/Enums/BOOLEnum.hpp" + +#include "OpenSHC/Globals/DAT_BinkControlState.hpp" +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + using OpenSHC::Rendering::ScreenResolutionEnum; + using OpenSHC::WindowsHelper::Enums::BOOLEnum; + + // FUNCTION: STRONGHOLDCRUSADER 0x004729B0 + void WindowAndDirectDraw::prepareWindowAndDDraw_2Unk( + BOOLEnum runAsExclusiveFullscreen, ScreenResolutionEnum resEnum) + { + if (this->drawingReady_0x0) { + dword const pendingBltMode = this->pendingBltMode; + this->pendingBltMode = 0; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + this->byteSizeofScreenResolution, 0, this->surfacePointer_screenMenu); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::renderBltAndFlip, this)(1); + this->pendingBltMode = pendingBltMode; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::releaseSurfacesAndDirectDraw, this)( + TRUE); + this->runGameAsExclusiveFullscreen = runAsExclusiveFullscreen; + this->currentGameResolution = resEnum; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::getDeviceCapsAndSetup, this)(); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setupPreferredScreenResolution, this)(); + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setWindowStyleRectAndPosition, this)(); + this->drawingReady_0x0 + = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::initializeDirectDraw, this)(); + // If DirectDraw can't start in the chosen resolution, retry once in 800x600, else ask to close. + while (!this->drawingReady_0x0) { + if (this->currentGameResolution == OpenSHC::Rendering::SRE_800x600) { + this->postWindowCloseMessage = 1; + break; + } + this->currentGameResolution = OpenSHC::Rendering::SRE_800x600; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::getDeviceCapsAndSetup, this)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setupPreferredScreenResolution, this)(); + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::setWindowStyleRectAndPosition, this)(); + this->drawingReady_0x0 + = MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::initializeDirectDraw, this)(); + } + this->unk_resetViewportRelated = 2; + DAT_WindowAndDirectDraw::instance.pendingMenuRedraw = 1; + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, DAT_BinkControlState::ptr)(0); + MACRO_CALL_MEMBER( + OpenSHC::Rendering::Bink::BinkControlClass_Func::stopBinkPlayback, DAT_BinkControlState::ptr)(1); + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp new file mode 100644 index 0000000000..dc5ecaf1c5 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/renderBltAndFlip.cpp @@ -0,0 +1,157 @@ +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_UIDragDropDefinedData.hpp" +#include "OpenSHC/Globals/DAT_ViewportRenderState.hpp" +#include "OpenSHC/Globals/DAT_WindowAndDirectDraw.hpp" + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // Blits the menu bar (mode 2) or one of two menu panels (modes 3 and 4) from the screen menu surface over the + // map. The original has this code twice, word for word: after the map blit and again after the flip. + static __forceinline void blitMenuOverlayUnk( + WindowAndDirectDraw* window, RECT& sourceRect, RECT& destinationRect) + { + if (window->unk_resetViewportRelated == 2 && DAT_WindowAndDirectDraw::instance.pendingBltMode != 2) { + window->mbr_0xcc++; + sourceRect.top = DAT_WindowAndDirectDraw::instance.resolutionY - 128; + sourceRect.bottom = DAT_WindowAndDirectDraw::instance.resolutionY; + destinationRect.left = window->clientOnScreenCoords.left; + destinationRect.bottom + = DAT_WindowAndDirectDraw::instance.resolutionY + window->clientOnScreenCoords.top; + destinationRect.right + = window->clientOnScreenCoords.left + DAT_WindowAndDirectDraw::instance.resolutionX; + sourceRect.right = DAT_WindowAndDirectDraw::instance.resolutionX; + destinationRect.top = destinationRect.bottom - 128; + sourceRect.left = 0; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + window)(&destinationRect, &sourceRect); + window->directDrawBackbufferSurfacePointer->Blt(&destinationRect, + window->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + return; + } + if (window->unk_resetViewportRelated == 3) { + sourceRect.left = DAT_MenuHandlerState::instance.x + 571; + sourceRect.top = DAT_MenuHandlerState::instance.y + 465; + sourceRect.right = DAT_MenuHandlerState::instance.x + 697; + sourceRect.bottom = DAT_MenuHandlerState::instance.y + 591; + destinationRect.left = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 571; + destinationRect.top = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 465; + destinationRect.right = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 697; + destinationRect.bottom = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 591; + } else if (window->unk_resetViewportRelated == 4) { + sourceRect.left = DAT_MenuHandlerState::instance.x + 664; + sourceRect.top = DAT_MenuHandlerState::instance.y + 464; + sourceRect.right = DAT_MenuHandlerState::instance.x + 792; + sourceRect.bottom = DAT_MenuHandlerState::instance.y + 592; + destinationRect.left = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 664; + destinationRect.top = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 464; + destinationRect.right = DAT_MenuHandlerState::instance.x + window->clientOnScreenCoords.left + 792; + destinationRect.bottom = DAT_MenuHandlerState::instance.y + window->clientOnScreenCoords.top + 592; + } else { + return; + } + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + window)(&destinationRect, &sourceRect); + window->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, window->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + } + + // FUNCTION: STRONGHOLDCRUSADER 0x00470040 + void WindowAndDirectDraw::renderBltAndFlip(int request) + { + RECT destinationRect; + RECT sourceRect; + int menuBarHeight = 128; + BOOL mapBltPending = FALSE; + if (request >= 100) { + request -= 100; + } + if (this->pendingBltMode != 0) { + mapBltPending = TRUE; + } + if (request != 0) { + this->windowMoveEventBlitCountdown = 0; + } + if (!this->drawingReady_0x0) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + return; + } + if (GetForegroundWindow() != this->windowHandle) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + return; + } + if (this->windowMoveEventBlitCountdown != 0) { + DAT_UIDragDropDefinedData::instance.MenuView_TriggerInitial = TRUE; + this->windowMoveEventBlitCountdown--; + return; + } + DWORD const now = timeGetTime(); + // This may be an actual max fps: 200fps. But only other certain conditions? -TheRedDaemon + if (this->unk_resetViewportRelated == 1) { + mapBltPending = FALSE; + this->pendingBltMode = 0; + } else if ((int)(now - this->windowRenderTimeUnk_0x1e0) < 5) { + return; + } + this->windowRenderTimeUnk_0x1e0 = now; + if (!mapBltPending) { + sourceRect.left = 0; + sourceRect.top = 0; + sourceRect.right = this->gameResolutionX; + sourceRect.bottom = this->gameResolutionY; + if (request == 1) { + char debugText[2000]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(debugText, s_Vid__d__sys__d_005a6208, + this->directDrawBackbufferSurfacePointer, this->directDrawOffscreenSurfacePointer_screenMenu); + } + if (this->runGameAsExclusiveFullscreen) { + this->directDrawBackbufferSurfacePointer->BltFast(0, 0, + this->directDrawOffscreenSurfacePointer_screenMenu, &this->clientOnScreenCoords, + DDBLTFAST_WAIT); + } else { + destinationRect = this->clientOnScreenCoords; + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, this)( + &destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt(&destinationRect, + this->directDrawOffscreenSurfacePointer_screenMenu, &sourceRect, DDBLT_WAIT, NULL); + } + } + if (this->pendingBltMode != 0) { + if (this->pendingBltMode == 2) { + menuBarHeight = 0; + } + sourceRect.left = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX; + sourceRect.right = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetX + + DAT_WindowAndDirectDraw::instance.resolutionX; + sourceRect.top = DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + sourceRect.bottom = DAT_WindowAndDirectDraw::instance.resolutionY - menuBarHeight + + DAT_ViewportRenderState::instance.viewportState.currentCameraOffsetY; + destinationRect.left = this->clientOnScreenCoords.left; + destinationRect.right = this->clientOnScreenCoords.left + DAT_WindowAndDirectDraw::instance.resolutionX; + destinationRect.top = this->clientOnScreenCoords.top; + destinationRect.bottom + = this->clientOnScreenCoords.top - menuBarHeight + DAT_WindowAndDirectDraw::instance.resolutionY; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::adjustForNotExclusiveFullscreenUnk, + this)(&destinationRect, &sourceRect); + this->directDrawBackbufferSurfacePointer->Blt( + &destinationRect, this->directDrawOffscreenSurfacePointer_mapGame, &sourceRect, DDBLT_WAIT, NULL); + blitMenuOverlayUnk(this, sourceRect, destinationRect); + } + if (this->NOTSelfBufferOrWindowMode_0xf8 == TRUE) { + this->directDrawPrimarySurfacePointer->Flip(NULL, DDFLIP_WAIT); + blitMenuOverlayUnk(this, sourceRect, destinationRect); + } + DAT_WindowAndDirectDraw::instance.pendingBltMode = 0; + this->unk_resetViewportRelated = 0; + } + + } +} +} diff --git a/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp new file mode 100644 index 0000000000..6123591cb7 --- /dev/null +++ b/src/OpenSHC/UI/Rendering/WindowAndDirectDraw/takeScreenshot.cpp @@ -0,0 +1,88 @@ +// disable deprecation warnings for strcpy, strcat and sprintf +#pragma warning(disable : 4996) + +#include "../WindowAndDirectDraw.func.hpp" + +#include "OpenSHC/IO/LowLevelMemory.func.hpp" +#include "OpenSHC/IO/ResourceManager.func.hpp" +#include "OpenSHC/OS.func.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_LowLevelMemory.hpp" +#include "OpenSHC/Globals/DAT_ResourceManager.hpp" + +#include + +namespace OpenSHC { +namespace UI { + namespace Rendering { + + // FUNCTION: STRONGHOLDCRUSADER 0x00479540 + void WindowAndDirectDraw::takeScreenshot(int screenshotNumber) + { + char path[1000]; + // NOTE: Requires direct, non-resolved call due to copy elision. + strcpy(path, DAT_ResourceManager::ptr->paths_getDocumentsFolderString(true).c_str()); + if (screenshotNumber == -1) { + strcat(path, S_SCREEN_CAPTURE_BMP_005A6538); + } else { + char fileName[1000]; + MACRO_CALL(OpenSHC::OS_Func::_sprintf)(fileName, s_screen_capture__03d_bmp_005a6520, screenshotNumber); + strcat(path, fileName); + } + + // The game links its own copy of the VC8 library; this is the same std::ofstream from the compiler's + // headers. + std::ofstream file(path, std::ios::binary); + if (file.fail()) { + return; + } + + MACRO_CALL_MEMBER( + OpenSHC::UI::Rendering::WindowAndDirectDraw_Func::bltMapGameSurfaceToScreenMenuSurfaceComplete, this)(); + + BITMAPFILEHEADER fileHeader; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + sizeof(fileHeader), '\0', &fileHeader); + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::copyData, DAT_LowLevelMemory::ptr)( + 2, (void*)DAT_BMP_MAGICVALUE, &fileHeader); + fileHeader.bfSize + = this->numPixel_GameX_x_3_x_GameY_0x4c + sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + fileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); + for (uint i = 0; i < sizeof(fileHeader); ++i) { + file << ((char*)&fileHeader)[i]; + } + + BITMAPINFOHEADER infoHeader; + MACRO_CALL_MEMBER(OpenSHC::IO::LowLevelMemory_Func::fillMemory_ByteValue, DAT_LowLevelMemory::ptr)( + sizeof(infoHeader), '\0', &infoHeader); + infoHeader.biSize = sizeof(infoHeader); + infoHeader.biPlanes = 1; + infoHeader.biBitCount = 24; + infoHeader.biWidth = this->resolutionX; + infoHeader.biHeight = this->resolutionY; + infoHeader.biCompression = BI_RGB; + infoHeader.biSizeImage = this->numPixel_GameX_x_3_x_GameY_0x4c; + for (uint i = 0; i < sizeof(infoHeader); ++i) { + file << ((char*)&infoHeader)[i]; + } + + // RGB565 rows, bottom-up, written as BGR24. The walking pointer and the named char locals are both + // load-bearing: row[x] cost 10 points and passing the expressions directly cost 6 (quick_diff). + for (int y = this->resolutionY - 1; y >= 0; --y) { + ushort* pixelPtr = this->surfacePointer_screenMenu + this->resolutionX * y; + for (int x = 0; x < this->resolutionX; ++x) { + int const pixel = *pixelPtr++; + char const blue = (char)pixel << 3; + file << blue; + char const green = (char)(pixel >> 5) * 4; + file << green; + char const red = (char)((short)pixel >> 11) << 3; + file << red; + } + } + } + + } +} +} diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp new file mode 100644 index 0000000000..a5ab2fe1a2 --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Army.cpp @@ -0,0 +1,131 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/UI/Helpers.func.hpp" +#include "OpenSHC/UI/Rendering/TextureRenderCore.func.hpp" +#include "OpenSHC/DE/SHCDE/eGM.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Map/Units/UnitTypeInt.hpp" +#include "OpenSHC/Rendering/Colors/ColorsEnum.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" +#include "OpenSHC/string-literals.hpp" + +#include "OpenSHC/Globals/DAT_00b95b68.hpp" +#include "OpenSHC/Globals/DAT_00b9845c.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" +#include "OpenSHC/Globals/DAT_UnitTypeGroups.hpp" +#include "OpenSHC/Globals/DAT_UnitTypeRelatedCounter.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x00447FA0 + void StatusMenus::RenderStatusMenu_Army() + { + int const x = DAT_MenuHandlerState::instance.x; + int const y = DAT_MenuHandlerState::instance.y; + int const firstGroupIcon = DAT_00b95b68::instance * 9; + int const top = y + 447; + ++DAT_00b9845c::instance; + int nudge = 0; + if (40 < DAT_00b9845c::instance) { + DAT_00b9845c::instance = 0; + MACRO_CALL(OpenSHC::UI::Helpers_Func::CountPlayerUnitsByType)(); + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Army" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 5), + x + 25, y + 467, OpenSHC::Text::TTA_LEFT, 0, 17, FALSE, 0); + int groupSize; + if (DAT_00b95b68::instance == 2) { + groupSize = 8; + nudge = -6; + } else { + groupSize = 9; + } + // an icon and the head count of each unit type in the group + for (int i = 0; i < groupSize; ++i) { + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderLoadedGfx, + DAT_TextureRenderCoreObject::ptr)(firstGroupIcon + i + 4, x + 85 + i * 46, top + 40); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_UnitTypeRelatedCounter::instance[DAT_UnitTypeGroups::instance[0][firstGroupIcon + i]], + nudge + i * 46 + x + 111, top + 125, OpenSHC::Text::TTA_CENTER, 0, 17, FALSE, 0); + if (2 < i) { + nudge = 0; + } + } + if (DAT_00b95b68::instance != 0) { + // "Total Troops" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 16), + x + 116, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID].armySize, + x + 122, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + // the fear factor's combat bonus, green when positive and red when negative + int const fearFactor + = DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel; + uint color; + int percentX; + if (0 < fearFactor) { + DAT_TextManagerObject::instance.field_0x20 = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 177, x + 116, top + 27); + // "Troop combat bonus:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 31), + x + 156, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + * 5, + x + 162, top + 25, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_00FF00, 0, 18, TRUE, 0); + color = OpenSHC::Rendering::Colors::COL_00FF00; + percentX = x + 164; + } else if (fearFactor < 0) { + DAT_TextManagerObject::instance.field_0x20 = 1; + MACRO_CALL_MEMBER(OpenSHC::UI::Rendering::TextureRenderCore_Func::renderGM, + DAT_TextureRenderCoreObject::ptr)(OpenSHC::DE::SHCDE::GM_INTERFACE_ICONS3, 178, x + 116, top + 17); + // "Troop combat bonus:" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 31), + x + 146, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumber2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .fearFactorLevel + * 5, + x + 152, top + 25, OpenSHC::Text::TTA_LEFT, OpenSHC::Rendering::Colors::COL_0000FF, 0, 18, TRUE, 0); + color = OpenSHC::Rendering::Colors::COL_0000FF; + percentX = x + 154; + } else { + // "No 'fear factor' bonus." + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 30), + x + 116, top + 25, OpenSHC::Text::TTA_LEFT, 0, 18, FALSE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + return; + } + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderInGameTextWithShadow, DAT_TextManagerObject::ptr)( + s_percentage_005a2770, percentX, top + 25, OpenSHC::Text::TTA_LEFT, color, 0, 18, TRUE, 0); + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + DAT_TextManagerObject::instance.field_0x20 = 0; + } + +} +} diff --git a/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp new file mode 100644 index 0000000000..d2dd4d338a --- /dev/null +++ b/src/OpenSHC/UI/StatusMenus/RenderStatusMenu_Food.cpp @@ -0,0 +1,52 @@ +#include "../StatusMenus.func.hpp" + +#include "OpenSHC/Text/TextManager.func.hpp" +#include "OpenSHC/DE/SHCDE/eTextSections.hpp" +#include "OpenSHC/Game/GameMode.hpp" +#include "OpenSHC/Rendering/Enums/RenderTarget.hpp" +#include "OpenSHC/Text/TextAlignment.hpp" + +#include "OpenSHC/Globals/DAT_ARRAY_0061818c.hpp" +#include "OpenSHC/Globals/DAT_GameState.hpp" +#include "OpenSHC/Globals/DAT_GameSynchronyState.hpp" +#include "OpenSHC/Globals/DAT_MenuHandlerState.hpp" +#include "OpenSHC/Globals/DAT_RenderingDefinedData.hpp" +#include "OpenSHC/Globals/DAT_TextManagerObject.hpp" +#include "OpenSHC/Globals/DAT_TextureRenderCoreObject.hpp" + +namespace OpenSHC { +namespace UI { + + // FUNCTION: STRONGHOLDCRUSADER 0x0043FAC0 + void StatusMenus::RenderStatusMenu_Food() + { + int const left = DAT_MenuHandlerState::instance.x + 178; + int const top = DAT_MenuHandlerState::instance.y + 512; + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_SCREEN_MENU; + // "Food" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 4), + DAT_MenuHandlerState::instance.x + 25, DAT_MenuHandlerState::instance.y + 467, OpenSHC::Text::TTA_LEFT, 0, + 17, FALSE, 0); + if (DAT_GameSynchronyState::instance.currentGameMode == OpenSHC::Game::GM_SOLITARY) { + // "Clicking on a food toggles consumption" + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderTextToScreen, DAT_TextManagerObject::ptr)( + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::getTextStringInGroupAtOffset, + DAT_TextManagerObject::ptr)(OpenSHC::DE::SHCDE::TEXT_REPORT_BUTTONS, 23), + DAT_MenuHandlerState::instance.x + 316, top + 70, OpenSHC::Text::TTA_CENTER, 0, 18, FALSE, 0); + } + // the stock of the four foods + int x = left + 12; + for (int food = 0; food < 4; ++food) { + MACRO_CALL_MEMBER(OpenSHC::Text::TextManager_Func::renderNumberToScreen2, DAT_TextManagerObject::ptr)( + DAT_GameState::instance.playerDataArray[DAT_GameSynchronyState::instance.currentPlayerSlotID] + .currentResources[DAT_ARRAY_0061818c::instance[food]], + x, DAT_MenuHandlerState::instance.y + 549, OpenSHC::Text::TTA_LEFT, 0, 17, FALSE, 0); + x += 80; + } + DAT_TextureRenderCoreObject::instance.drawBufferChoiceValue = OpenSHC::Rendering::Enums::RT_MAP_GAME; + } + +} +} diff --git a/status/addresses-SHC-3BB0A8C1.txt b/status/addresses-SHC-3BB0A8C1.txt index 6ec8017690..8727c7c0d4 100644 --- a/status/addresses-SHC-3BB0A8C1.txt +++ b/status/addresses-SHC-3BB0A8C1.txt @@ -2579,7 +2579,7 @@ SHC_3BB0A8C1_0x00408EB0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00408ED0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00408FC0 | 0.0% | Pending +SHC_3BB0A8C1_0x00408FC0 | 84.1% | Reg alloc only SHC_3BB0A8C1_0x004090E8 | 0.0% | Pending @@ -13475,7 +13475,7 @@ SHC_3BB0A8C1_0x0043C160 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0043C1A0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x0043C1E0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043C1E0 | 87.6% | text without the decompiler's temporaries; husband id and text counters swap edx and esi, two arms the other way round SHC_3BB0A8C1_0x0043C6A0 | 100.0% | Reimplemented, identical code; the loop-end compare (one past the table) is the next global's symbol in the original, unnamed in ours @@ -13605,7 +13605,7 @@ SHC_3BB0A8C1_0x0043F6A0 | 0.0% | Pending SHC_3BB0A8C1_0x0043F930 | 0.0% | Pending -SHC_3BB0A8C1_0x0043FAC0 | 0.0% | Pending +SHC_3BB0A8C1_0x0043FAC0 | 86.8% | loop body registers rotate SHC_3BB0A8C1_0x0043FBB0 | 100.0% | Reimplemented @@ -16373,7 +16373,7 @@ SHC_3BB0A8C1_0x00447D30 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00447DC0 | 0.0% | Pending -SHC_3BB0A8C1_0x00447FA0 | 0.0% | Pending +SHC_3BB0A8C1_0x00447FA0 | 40.2% | Register allocation differs SHC_3BB0A8C1_0x004482F0 | 0.0% | Pending @@ -16971,7 +16971,7 @@ SHC_3BB0A8C1_0x00453600 | 100.0% | Reimplemented SHC_3BB0A8C1_0x00453B00 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00454080 | 0.0% | Pending +SHC_3BB0A8C1_0x00454080 | 86.3% | the C++ part before the asm keeps its values in other registers; the asm matches SHC_3BB0A8C1_0x00454620 | 100.0% | Reimplemented @@ -19155,11 +19155,11 @@ SHC_3BB0A8C1_0x00462FF0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004630B0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004630D0 | 0.0% | Pending +SHC_3BB0A8C1_0x004630D0 | 93.5% | Alpha branch's pixel index is reassociated SHC_3BB0A8C1_0x00463270 | 0.0% | Pending -SHC_3BB0A8C1_0x00463310 | 0.0% | Pending +SHC_3BB0A8C1_0x00463310 | 86.1% | One push: esi (menu tab's 1) in the original, the immediate 1 in ours; constant reuse, no source form (msvc-backend.md: which constant gets the callee-saved register) SHC_3BB0A8C1_0x004637E8 | 0.0% | Pending @@ -21245,13 +21245,13 @@ SHC_3BB0A8C1_0x0046FF50 | 100.0% | Reimplemented SHC_3BB0A8C1_0x0046FFB0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x00470040 | 0.0% | Pending +SHC_3BB0A8C1_0x00470040 | 57.2% | Zero not kept in ebp; param_1 takes the register instead SHC_3BB0A8C1_0x00470610 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004706A0 | 0.0% | Pending -SHC_3BB0A8C1_0x004706E0 | 0.0% | Pending +SHC_3BB0A8C1_0x004706E0 | 82.1% | join stores not shared SHC_3BB0A8C1_0x004707F0 | 0.0% | Pending @@ -21413,7 +21413,7 @@ SHC_3BB0A8C1_0x004728F0 | 0.0% | Pending SHC_3BB0A8C1_0x00472950 | 0.0% | Pending -SHC_3BB0A8C1_0x004729B0 | 0.0% | Pending +SHC_3BB0A8C1_0x004729B0 | 79.1% | Callee-saved register swap only SHC_3BB0A8C1_0x00472A90 | 100.0% | Reimplemented @@ -22125,7 +22125,7 @@ SHC_3BB0A8C1_0x00479369 | 0.0% | Pending SHC_3BB0A8C1_0x00479400 | 0.0% | Pending -SHC_3BB0A8C1_0x00479540 | 0.0% | Pending +SHC_3BB0A8C1_0x00479540 | 86.4% | calls into the C++ library (ofstream constructor, destructor, operator<<) that reccmp cannot map; register rotation SHC_3BB0A8C1_0x00479790 | 0.0% | Pending @@ -23071,7 +23071,7 @@ SHC_3BB0A8C1_0x00487770 | 0.0% | Pending SHC_3BB0A8C1_0x00487800 | 0.0% | Pending -SHC_3BB0A8C1_0x00487A30 | 0.0% | Pending +SHC_3BB0A8C1_0x00487A30 | 75.6% | this kept in edi across the proxied computeLatencyAdjustmentFromMatchTimes, where the original reuses ecx (built knowing the callee, as /GL); quick_diff 1.0000 with the callee compiled in SHC_3BB0A8C1_0x00487C50 | 100.0% | Reimplemented @@ -26891,7 +26891,7 @@ SHC_3BB0A8C1_0x004B58D0 | 0.0% | Pending SHC_3BB0A8C1_0x004B5A20 | 0.0% | Pending -SHC_3BB0A8C1_0x004B5F70 | 0.0% | Pending +SHC_3BB0A8C1_0x004B5F70 | 55.9% | Frame one slot smaller SHC_3BB0A8C1_0x004B61F0 | 100.0% | Reimplemented @@ -27095,7 +27095,7 @@ SHC_3BB0A8C1_0x004B7AB0 | 0.0% | Pending SHC_3BB0A8C1_0x004B7AF0 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004B7C90 | 0.0% | Pending +SHC_3BB0A8C1_0x004B7C90 | 74.5% | Register allocation: the original keeps the text's width in ebx and reads x from the stack; ours gives y and x the two registers and keeps the width in a slot (allocator keys y 170, x 92, width 67); 14 source forms no better SHC_3BB0A8C1_0x004B7F60 | 100.0% | Reimplemented @@ -35577,7 +35577,7 @@ SHC_3BB0A8C1_0x004D55D0 | 100.0% | Reimplemented SHC_3BB0A8C1_0x004D5780 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D5810 | 0.0% | Pending +SHC_3BB0A8C1_0x004D5810 | 58.8% | Frame 8 bytes larger, reg alloc SHC_3BB0A8C1_0x004D5990 | 0.0% | Pending @@ -35841,7 +35841,7 @@ SHC_3BB0A8C1_0x004D6F60 | 0.0% | Pending SHC_3BB0A8C1_0x004D7200 | 100.0% | Reimplemented -SHC_3BB0A8C1_0x004D76A0 | 0.0% | Pending +SHC_3BB0A8C1_0x004D76A0 | 58.2% | Register assignment differs SHC_3BB0A8C1_0x004D7730 | 0.0% | Pending