Skip to content

Commit

Permalink
fix hud editor position bugs (#622)
Browse files Browse the repository at this point in the history
  • Loading branch information
Archez authored May 31, 2024
1 parent 63c293f commit 7bf60f6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
29 changes: 18 additions & 11 deletions mm/2s2h/BenGui/HudEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ extern "C" void HudEditor_ModifyRectPosValuesFromBase(s16 baseX, s16 baseY, s16*
*rectTop = baseY + (offsetFromBaseY * CVarGetFloat(hudEditorElements[hudEditorActiveElement].scaleCvar, 1.0f));
}

extern "C" void HudEditor_ModifyRectPosValues(s16* rectLeft, s16* rectTop) {
s16 offsetFromBaseX = *rectLeft - hudEditorElements[hudEditorActiveElement].defaultX;
s16 offsetFromBaseY = *rectTop - hudEditorElements[hudEditorActiveElement].defaultY;
void HudEditor_ModifyRectPosValuesFloat(f32* rectLeft, f32* rectTop) {
f32 offsetFromBaseX = *rectLeft - hudEditorElements[hudEditorActiveElement].defaultX;
f32 offsetFromBaseY = *rectTop - hudEditorElements[hudEditorActiveElement].defaultY;
*rectLeft = CVarGetInteger(hudEditorElements[hudEditorActiveElement].xCvar,
hudEditorElements[hudEditorActiveElement].defaultX) +
(offsetFromBaseX * CVarGetFloat(hudEditorElements[hudEditorActiveElement].scaleCvar, 1.0f));
Expand All @@ -78,6 +78,16 @@ extern "C" void HudEditor_ModifyRectPosValues(s16* rectLeft, s16* rectTop) {
}
}

extern "C" void HudEditor_ModifyRectPosValues(s16* rectLeft, s16* rectTop) {
f32 newLeft = *rectLeft;
f32 newTop = *rectTop;

HudEditor_ModifyRectPosValuesFloat(&newLeft, &newTop);

*rectLeft = (s16)newLeft;
*rectTop = (s16)newTop;
}

extern "C" void HudEditor_ModifyRectSizeValues(s16* rectWidth, s16* rectHeight) {
*rectWidth *= CVarGetFloat(hudEditorElements[hudEditorActiveElement].scaleCvar, 1.0f);
*rectHeight *= CVarGetFloat(hudEditorElements[hudEditorActiveElement].scaleCvar, 1.0f);
Expand All @@ -90,16 +100,13 @@ extern "C" void HudEditor_ModifyTextureStepValues(s16* dsdx, s16* dtdy) {

// Modify matrix values based on the identity matrix (0,0) centered on the screen
extern "C" void HudEditor_ModifyMatrixValues(f32* transX, f32* transY) {
*transX = (f32)(SCREEN_WIDTH / 2) + *transX;
*transY = (f32)(SCREEN_HEIGHT / 2) - *transY;

s16 newX = *transX;
s16 newY = *transY;
*transX = ((f32)SCREEN_WIDTH / 2) + *transX;
*transY = ((f32)SCREEN_HEIGHT / 2) - *transY;

HudEditor_ModifyRectPosValues(&newX, &newY);
HudEditor_ModifyRectPosValuesFloat(transX, transY);

*transX = (f32)newX - (SCREEN_WIDTH / 2);
*transY = (f32)(SCREEN_HEIGHT / 2) - newY;
*transX = *transX - ((f32)SCREEN_WIDTH / 2);
*transY = ((f32)SCREEN_HEIGHT / 2) - *transY;
}

extern "C" void HudEditor_ModifyKaleidoEquipAnimValues(s16* ulx, s16* uly, s16* shrinkRate) {
Expand Down
8 changes: 4 additions & 4 deletions mm/src/code/z_parameter.c
Original file line number Diff line number Diff line change
Expand Up @@ -7391,10 +7391,10 @@ void Interface_DrawTimers(PlayState* play) {
s16 j;
s16 i;
// 2S2H [Cosmetic] Hud editor values for timers
s16 newTimerX;
s16 newTimerY;
u8 modifiedTimerHudValues;
s16 hudTimerElement;
s16 newTimerX = 0;
s16 newTimerY = 0;
u8 modifiedTimerHudValues = false;
s16 hudTimerElement = HUD_EDITOR_ELEMENT_NONE;

OPEN_DISPS(play->state.gfxCtx);

Expand Down

0 comments on commit 7bf60f6

Please sign in to comment.