Skip to content

Commit

Permalink
Fixed CD player persisting through menus (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dummiesman committed Jun 26, 2018
1 parent a02cdde commit 6bf172a
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
43 changes: 42 additions & 1 deletion src/handlers/bugfix_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,14 +476,55 @@ void mmHudMapHandler::Install() {

static ConfigValue<bool> cfgChatMusicFix("ChatMusicFix", true);

// Fixes chat music presisting after the chat box is closed
// fix cd player persisting through popups
bool wasCdPlayerEnabled = false;

void mmPopupHandler::HudEnable() {
auto cdPlayer = mmGameManager::Instance.get()->getGame()->getPlayer()->getHUD()->getCdPlayer();

// if cd player is inactive, and it was active before
// reactivate it
if(wasCdPlayerEnabled && !cdPlayer->isActive())
cdPlayer->Toggle();

ageHook::Thunk<0x42D910>::Call<void>(this); // mmHUD::Enable
}

void mmPopupHandler::HudDisable(int a1) {
auto cdPlayer = mmGameManager::Instance.get()->getGame()->getPlayer()->getHUD()->getCdPlayer();
wasCdPlayerEnabled = cdPlayer->isActive();

// hide the cd player if shown
if (wasCdPlayerEnabled)
cdPlayer->Toggle();

ageHook::Thunk<0x42D970>::Call<void>(this, a1); // mmHUD::Disable
}

void mmPopupHandler::Install() {
// Fixes chat music presisting after the chat box is closed
if (cfgChatMusicFix) {
InstallPatch({ 0x01 }, {
0x42B558+1,
0x42B537+1,
});
}

// CD player fixes
InstallCallback("mmPopup::DisablePU", "Shows the CD player on popup disable",
&HudEnable, {
cbHook<CALL>(0x42A2F5),
}
);

InstallCallback("mmPopup::ShowResults", "Hides the CD player when popups are showing",
&HudDisable, {
cbHook<CALL>(0x42A65F),
cbHook<CALL>(0x42A722),
cbHook<CALL>(0x42A7EB),
cbHook<CALL>(0x42A3BF),
}
);
}

/*
Expand Down
2 changes: 2 additions & 0 deletions src/handlers/bugfix_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ class mmHudMapHandler {

class mmPopupHandler {
public:
void HudEnable();
void HudDisable(int a1);
static void Install();
};

Expand Down

0 comments on commit 6bf172a

Please sign in to comment.