menumixin: add mixins for menu alpha.

This commit is contained in:
Ganom
2020-05-14 22:53:16 -04:00
parent 86ee1c364c
commit 97011b7e36
2 changed files with 80 additions and 21 deletions

View File

@@ -44,6 +44,7 @@ public abstract class MenuMixin implements RSClient
private static final int MENU_TEXT_2010 = 0xC6B895;
private static final int MENU_HEADER_GRADIENT_TOP_2010 = 0x322E22;
private static final int MENU_HEADER_GRADIENT_BOTTOM_2010 = 0x090A04;
private static final int ORIGINAL_BG = 0x5D5447;
@Shadow("client")
private static RSClient client;
@@ -53,7 +54,7 @@ public abstract class MenuMixin implements RSClient
@Inject
@Override
public void draw2010Menu()
public void draw2010Menu(int alpha)
{
int x = getMenuX();
int y = getMenuY();
@@ -61,36 +62,36 @@ public abstract class MenuMixin implements RSClient
int h = getMenuHeight();
// Outside border
rasterizerDrawHorizontalLine(x + 2, y, w - 4, MENU_BORDER_OUTER_2010);
rasterizerDrawHorizontalLine(x + 2, y + h - 1, w - 4, MENU_BORDER_OUTER_2010);
rasterizerDrawVerticalLine(x, y + 2, h - 4, MENU_BORDER_OUTER_2010);
rasterizerDrawVerticalLine(x + w - 1, y + 2, h - 4, MENU_BORDER_OUTER_2010);
rasterizerDrawHorizontalLineAlpha(x + 2, y, w - 4, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawHorizontalLineAlpha(x + 2, y + h - 1, w - 4, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawVerticalLineAlpha(x, y + 2, h - 4, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawVerticalLineAlpha(x + w - 1, y + 2, h - 4, MENU_BORDER_OUTER_2010, alpha);
// Padding
rasterizerDrawRectangle(x + 1, y + 5, w - 2, h - 6, MENU_PADDING_2010);
rasterizerDrawHorizontalLine(x + 1, y + 17, w - 2, MENU_PADDING_2010);
rasterizerDrawCircle(x + 2, y + h - 3, 0, MENU_PADDING_2010);
rasterizerDrawCircle(x + w - 3, y + h - 3, 0, MENU_PADDING_2010);
rasterizerDrawRectangleAlpha(x + 1, y + 5, w - 2, h - 6, MENU_PADDING_2010, alpha);
rasterizerDrawHorizontalLineAlpha(x + 1, y + 17, w - 2, MENU_PADDING_2010, alpha);
rasterizerDrawCircleAlpha(x + 2, y + h - 3, 0, MENU_PADDING_2010, alpha);
rasterizerDrawCircleAlpha(x + w - 3, y + h - 3, 0, MENU_PADDING_2010, alpha);
// Header
rasterizerDrawGradient(x + 2, y + 1, w - 4, 16, MENU_HEADER_GRADIENT_TOP_2010, MENU_HEADER_GRADIENT_BOTTOM_2010);
rasterizerFillRectangle(x + 1, y + 1, 2, 4, MENU_PADDING_2010);
rasterizerFillRectangle(x + w - 3, y + 1, 2, 4, MENU_PADDING_2010);
rasterizerDrawGradientAlpha(x + 2, y + 1, w - 4, 16, MENU_HEADER_GRADIENT_TOP_2010, MENU_HEADER_GRADIENT_BOTTOM_2010, alpha, alpha);
rasterizerFillRectangleAlpha(x + 1, y + 1, 2, 4, MENU_PADDING_2010, alpha);
rasterizerFillRectangleAlpha(x + w - 3, y + 1, 2, 4, MENU_PADDING_2010, alpha);
// Inside border
rasterizerDrawHorizontalLine(x + 2, y + 18, w - 4, MENU_BORDER_INNER_2010);
rasterizerDrawHorizontalLine(x + 3, y + h - 3, w - 6, MENU_BORDER_INNER_2010);
rasterizerDrawVerticalLine(x + 2, y + 18, h - 21, MENU_BORDER_INNER_2010);
rasterizerDrawVerticalLine(x + w - 3, y + 18, h - 21, MENU_BORDER_INNER_2010);
rasterizerDrawHorizontalLineAlpha(x + 2, y + 18, w - 4, MENU_BORDER_INNER_2010, alpha);
rasterizerDrawHorizontalLineAlpha(x + 3, y + h - 3, w - 6, MENU_BORDER_INNER_2010, alpha);
rasterizerDrawVerticalLineAlpha(x + 2, y + 18, h - 21, MENU_BORDER_INNER_2010, alpha);
rasterizerDrawVerticalLineAlpha(x + w - 3, y + 18, h - 21, MENU_BORDER_INNER_2010, alpha);
// Options background
rasterizerFillRectangle(x + 3, y + 19, w - 6, h - 22, MENU_BACKGROUND_2010);
rasterizerFillRectangleAlpha(x + 3, y + 19, w - 6, h - 22, MENU_BACKGROUND_2010, alpha);
// Corner insets
rasterizerDrawCircle(x + 1, y + 1, 0, MENU_BORDER_OUTER_2010);
rasterizerDrawCircle(x + w - 2, y + 1, 0, MENU_BORDER_OUTER_2010);
rasterizerDrawCircle(x + 1, y + h - 2, 0, MENU_BORDER_OUTER_2010);
rasterizerDrawCircle(x + w - 2, y + h - 2, 0, MENU_BORDER_OUTER_2010);
rasterizerDrawCircleAlpha(x + 1, y + 1, 0, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawCircleAlpha(x + w - 2, y + 1, 0, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawCircleAlpha(x + 1, y + h - 2, 0, MENU_BORDER_OUTER_2010, alpha);
rasterizerDrawCircleAlpha(x + w - 2, y + h - 2, 0, MENU_BORDER_OUTER_2010, alpha);
RSFont font = getFontBold12();
font.drawTextLeftAligned("Choose Option", x + 3, y + 14, MENU_TEXT_2010, -1);
@@ -121,6 +122,47 @@ public abstract class MenuMixin implements RSClient
}
}
@Inject
@Override
public void drawOriginalMenu(int alpha)
{
int x = getMenuX();
int y = getMenuY();
int w = getMenuWidth();
int h = getMenuHeight();
rasterizerFillRectangleAlpha(x, y, w, h, ORIGINAL_BG, alpha);
rasterizerDrawRectangleAlpha(x, y, w, h, ORIGINAL_BG, alpha);
rasterizerFillRectangleAlpha(x + 1, y + 1, w - 2, 16, 0, alpha);
rasterizerDrawRectangleAlpha(x + 1, y + 18, w - 2, h - 19, 0, alpha);
RSFont font = getFontBold12();
font.drawTextLeftAligned("Choose Option", x + 3, y + 14, ORIGINAL_BG, -1);
int mouseX = getMouseX();
int mouseY = getMouseY();
int count = getMenuOptionCount();
String[] targets = getMenuTargets();
String[] options = getMenuOptions();
for (int i = 0; i < count; i++)
{
int rowY = y + (count - 1 - i) * 15 + 31;
String s = options[i];
if (!targets[i].isEmpty())
{
s += " " + targets[i];
}
int highlight = 0xFFFFFF;
if (mouseX > x && mouseX < w + x && mouseY > rowY - 13 && mouseY < rowY + 3)
{
highlight = 0xFFFF00;
}
font.drawTextLeftAligned(s, x + 3, rowY, highlight, -1);
}
}
@Inject
@Override
public MenuEntry getLeftClickMenuEntry()
@@ -166,7 +208,9 @@ public abstract class MenuMixin implements RSClient
public void setTempMenuEntry(MenuEntry entry)
{
if (entry == null || tempMenuAction == null)
{
return;
}
tempMenuAction.setOption(entry.getOption());
tempMenuAction.setOpcode(entry.getOpcode());

View File

@@ -1009,21 +1009,36 @@ public interface RSClient extends RSGameShell, Client
@Import("Rasterizer2D_drawHorizontalLine")
void rasterizerDrawHorizontalLine(int x, int y, int w, int rgb);
@Import("Rasterizer2D_drawHorizontalLineAlpha")
void rasterizerDrawHorizontalLineAlpha(int x, int y, int w, int rgb, int a);
@Import("Rasterizer2D_drawVerticalLine")
void rasterizerDrawVerticalLine(int x, int y, int h, int rgb);
@Import("Rasterizer2D_drawVerticalLineAlpha")
void rasterizerDrawVerticalLineAlpha(int x, int y, int h, int rgb, int a);
@Import("Rasterizer2D_fillRectangleGradient")
void rasterizerDrawGradient(int x, int y, int w, int h, int rgbTop, int rgbBottom);
@Import("Rasterizer2D_fillRectangleGradientAlpha")
void rasterizerDrawGradientAlpha(int x, int y, int w, int h, int rgbTop, int rgbBottom, int alphaTop, int alphaBottom);
@Import("Rasterizer2D_fillRectangleAlpha")
void rasterizerFillRectangleAlpha(int x, int y, int w, int h, int rgb, int a);
@Import("Rasterizer2D_drawRectangle")
void rasterizerDrawRectangle(int x, int y, int w, int h, int rgb);
@Import("Rasterizer2D_drawRectangleAlpha")
void rasterizerDrawRectangleAlpha(int x, int y, int w, int h, int rgb, int a);
@Import("drawCircle")
void rasterizerDrawCircle(int x, int y, int r, int rgb);
@Import("Rasterizer2D_drawCircleAlpha")
void rasterizerDrawCircleAlpha(int x, int y, int r, int rgb, int a);
@Import("HealthBarDefinition_cached")
RSEvictingDualNodeHashTable getHealthBarCache();