Skip to content
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.

Commit

Permalink
Allow wall overlays to use Palette
Browse files Browse the repository at this point in the history
  • Loading branch information
Starkku committed Oct 6, 2023
1 parent 6c30c32 commit 3674aa1
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion FA2sp/Ext/CLoading/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class NOVTABLE CLoadingExt : public CLoading
static ppmfc::CString GetBuildingImageName(ppmfc::CString ID, int nFacing, int state);

static void ClearItemTypes();
private:
void GetFullPaletteName(ppmfc::CString& PaletteName);
private:
static ppmfc::CString* __cdecl GetDictName(ppmfc::CString* ret, const char* ID, int nFacing) { JMP_STD(0x475450); }
static ppmfc::CString GetDictName(ppmfc::CString ID, int nFacing)
{
Expand Down
25 changes: 25 additions & 0 deletions FA2sp/Ext/CLoading/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include "Body.h"

#include <Drawing.h>
#include <CFinalSunApp.h>
#include <CMixFile.h>
#include <CLoading.h>
#include <CINI.h>
#include "..\..\Miscs\Palettes.h"
#include "..\CMapData\Body.h"

DEFINE_HOOK(486B00, CLoading_InitMixFiles, 7)
{
Expand Down Expand Up @@ -82,3 +85,25 @@ DEFINE_HOOK(4B8CFC, CMapData_CreateMap_InitMixFiles_Removal, 5)
reinterpret_cast<CLoadingHelper*>(CLoading::Instance())->DTOR();
return 0x4B8D0C;
}


DEFINE_HOOK(4903F3, CLoading_DrawOverlay_Palette, 7)
{
GET(CLoadingExt*, pThis, EDI);
REF_STACK(ImageDataClass, pDrawData, STACK_OFFS(0x1C8, 0xC8));
GET_STACK(int, nOverlayIndex, STACK_OFFS(0x1C8, -0x8));

if (nOverlayIndex >= 0 && nOverlayIndex < 255)
{
auto const& typeData = CMapDataExt::OverlayTypeDatas[nOverlayIndex];

if (typeData.Wall)

Check failure on line 100 in FA2sp/Ext/CLoading/Hooks.cpp

View workflow job for this annotation

GitHub Actions / build

'Wall': is not a member of 'OverlayTypeData' [D:\a\FA2sp\FA2sp\FA2sp.vcxproj]
{
auto palName = typeData.PaletteName;
pThis->GetFullPaletteName(palName);
pDrawData.pPalette = PalettesManager::LoadPalette(palName);
}
}

return 0;
}
1 change: 1 addition & 0 deletions FA2sp/Ext/CMapData/Body.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
struct OverlayTypeData
{
bool Rock;
ppmfc::CString PaletteName;
};

struct BuildingDataExt
Expand Down
1 change: 1 addition & 0 deletions FA2sp/Ext/CMapData/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ DEFINE_HOOK(47AB50, CLoading_InitPics_InitOverlayTypeDatas, 7)
{
auto& item = CMapDataExt::OverlayTypeDatas.emplace_back();
item.Rock = Variables::Rules.GetBool(id, "IsARock");
item.PaletteName = CINI::Art->GetString(id, "Palette", "unit");
}

return 0;
Expand Down
18 changes: 18 additions & 0 deletions FA2sp/Ext/CTileSetBrowserView/Hooks.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <CPalette.h>
#include <CTileSetBrowserView.h>
#include <Helpers/Macro.h>

Expand All @@ -20,6 +21,23 @@ DEFINE_HOOK(4F258B, CTileSetBrowserView_OnDraw_SetOverlayFrameToDisplay, 7)
return i < nDisplayLimit ? 0x4F2230 : 0x4F2598;
}

DEFINE_HOOK(4F22F7, CTileSetBrowserView_OnDraw_OverlayPalette, 5)
{
GET(Palette*, pPalette, EAX);
GET_STACK(BytePalette*, pBytePalette, STACK_OFFS(0xDC, 0xBC));

if (pPalette == Palette::PALETTE_ISO || pPalette == Palette::PALETTE_THEATER || pPalette == Palette::PALETTE_UNIT)
return 0;

*pBytePalette = BytePalette();

for (int i = 0; i < 256; i++)
{
pBytePalette->Data[i] = pPalette->GetByteColor(i);
}

return 0x4F2315;
}

//DEFINE_HOOK(4F1D70, ASDG, 6)
//{
Expand Down

0 comments on commit 3674aa1

Please sign in to comment.