tlac: add three parameter drawRectangle (implemented the same as sega uses)

This commit is contained in:
somewhatlurker
2019-10-21 17:24:35 +11:00
parent b4ee82a643
commit 59c8d164ad
2 changed files with 32 additions and 16 deletions
@@ -211,6 +211,33 @@ namespace TLAC::Components
float height;
};
void(*fillRectangle)(DrawParams* dtParam, RectangleBounds* rect) = (void(*)(DrawParams* dtParam, RectangleBounds* rect))0x140198d80;
void(*drawRectangle)(DrawParams* dtParam, RectangleBounds* rect) = (void(*)(DrawParams* dtParam, RectangleBounds* rect))0x140198320;
// draws only a border -- use fillRectangle to fill contained pixels
void drawRectangle(DrawParams* dtParam, RectangleBounds* rect)
{
((void(*)(DrawParams*, RectangleBounds*))0x140198320)(dtParam, rect);
}
// draws only a border -- use fillRectangle to fill contained pixels
void drawRectangle(DrawParams* dtParam, RectangleBounds* rect, float thickness)
{
uint32_t oldFillColour = dtParam->fillColour;
dtParam->fillColour = dtParam->colour;
// yes this seems pretty dodgy, but sega does it this way so... I guess it's the only way
RectangleBounds tempRect = { rect->x, rect->y, thickness, rect->height }; // left side
fillRectangle(dtParam, &tempRect);
tempRect.x = rect->x + rect->width - thickness; // right side
fillRectangle(dtParam, &tempRect);
tempRect = { rect->x + thickness, rect->y, rect->width - (thickness * 2), thickness }; // top side
fillRectangle(dtParam, &tempRect);
tempRect.y = rect->y + rect->height - thickness; // left side
fillRectangle(dtParam, &tempRect);
dtParam->fillColour = oldFillColour;
}
#pragma pack(pop)
}
@@ -251,24 +251,13 @@ namespace TLAC::Components
const float selectBoxHeight = menuItemHeight;
const float selectBoxThickness = 2;
const float selectBoxX1 = menuX - selectBoxWidth / 2;
const float selectBoxX2 = selectBoxX1 + selectBoxWidth - selectBoxThickness;
const float selectBoxY1 = selectBoxPos;
const float selectBoxY2 = selectBoxY1 + selectBoxThickness;
const float selectBoxY3 = selectBoxY1 + selectBoxHeight - selectBoxThickness;
const float selectBoxSideHeight = selectBoxHeight - 2 * selectBoxThickness;
const float selectBoxX = menuX - selectBoxWidth / 2;
const float selectBoxY = selectBoxPos;
// dirty hack using fillRectangle to get thickness (idk how to set it or it isn't possible to with drawRectangle)
rect = { selectBoxX, selectBoxY, selectBoxWidth, selectBoxHeight };
dtParams.colour = 0xc0ffff00;
dtParams.fillColour = 0xc0ffff00;
rect = { selectBoxX1, selectBoxY1, selectBoxWidth, selectBoxThickness }; // top
fillRectangle(&dtParams, &rect);
rect = { selectBoxX1, selectBoxY3, selectBoxWidth, selectBoxThickness }; // bottom
fillRectangle(&dtParams, &rect);
rect = { selectBoxX1, selectBoxY2, selectBoxThickness, selectBoxSideHeight };
fillRectangle(&dtParams, &rect);
rect = { selectBoxX2, selectBoxY2, selectBoxThickness, selectBoxSideHeight };
fillRectangle(&dtParams, &rect);
drawRectangle(&dtParams, &rect, selectBoxThickness);
// menu