interface styles: add 2010 menu

This commit is contained in:
Ron Young
2019-04-06 20:37:03 -04:00
committed by Adam
parent a70ba37cd0
commit 917921dd47
7 changed files with 201 additions and 0 deletions

View File

@@ -1600,4 +1600,6 @@ public interface Client extends GameEngine
NodeCache getItemCompositionCache();
EnumComposition getEnum(int id);
void draw2010Menu();
}

View File

@@ -52,4 +52,14 @@ public interface InterfaceStylesConfig extends Config
{
return false;
}
@ConfigItem(
keyName = "hdMenu",
name = "High Detail menu",
description = "Replaces game menu with the RuneScape High Detail mode design"
)
default boolean hdMenu()
{
return false;
}
}

View File

@@ -34,6 +34,7 @@ import net.runelite.api.Client;
import net.runelite.api.HealthBarOverride;
import net.runelite.api.SpriteID;
import net.runelite.api.SpritePixels;
import net.runelite.api.events.BeforeMenuRender;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.WidgetPositioned;
import net.runelite.api.widgets.Widget;
@@ -115,6 +116,16 @@ public class InterfaceStylesPlugin extends Plugin
overrideHealthBars();
}
@Subscribe
public void onBeforeMenuRender(BeforeMenuRender event)
{
if (config.hdMenu())
{
client.draw2010Menu();
event.consume();
}
}
private void overrideSprites()
{
for (SpriteOverride spriteOverride : SpriteOverride.values())

View File

@@ -0,0 +1,112 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.mixins;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSFont;
@Mixin(RSClient.class)
public abstract class MenuMixin implements RSClient
{
private static final int MENU_BORDER_OUTER_2010 = 0x6D6A5B;
private static final int MENU_BORDER_INNER_2010 = 0x524A3D;
private static final int MENU_PADDING_2010 = 0x2B2622;
private static final int MENU_BACKGROUND_2010 = 0x2B271C;
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;
@Inject
@Override
public void draw2010Menu()
{
int x = getMenuX();
int y = getMenuY();
int w = getMenuWidth();
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);
// 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);
// 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);
// 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);
// Options background
RasterizerFillRectangle(x + 3, y + 19, w - 6, h - 22, MENU_BACKGROUND_2010);
// 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);
RSFont font = getFontBold12();
font.drawTextLeftAligned("Choose Option", x + 3, y + 14, MENU_TEXT_2010, -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];
}
font.drawTextLeftAligned(s, x + 3, rowY, MENU_TEXT_2010, -1);
// Highlight current option
if (mouseX > x && mouseX < w + x && mouseY > rowY - 13 && mouseY < rowY + 3)
{
RasterizerFillRectangleAlpha(x + 3, rowY - 12, w - 6, 15, 0xffffff, 80);
}
}
}
}

View File

@@ -932,4 +932,37 @@ public interface RSClient extends RSGameEngine, Client
@Import("getEnum")
RSEnum getRsEnum(int id);
@Import("menuX")
int getMenuX();
@Import("menuY")
int getMenuY();
@Import("menuHeight")
int getMenuHeight();
@Import("menuWidth")
int getMenuWidth();
@Import("fontBold12")
RSFont getFontBold12();
@Import("drawHorizontalLine")
void RasterizerDrawHorizontalLine(int x, int y, int w, int rgb);
@Import("drawVerticalLine")
void RasterizerDrawVerticalLine(int x, int y, int h, int rgb);
@Import("drawGradient")
void RasterizerDrawGradient(int x, int y, int w, int h, int rgbTop, int rgbBottom);
@Import("fillRectangleAlpha")
void RasterizerFillRectangleAlpha(int x, int y, int w, int h, int rgb, int a);
@Import("drawRectangle")
void RasterizerDrawRectangle(int x, int y, int w, int h, int rgb);
@Import("drawCircle")
void RasterizerDrawCircle(int x, int y, int r, int rgb);
}

View File

@@ -0,0 +1,30 @@
/*
* Copyright (c) 2019, Ron Young <https://github.com/raiyni>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.rs.api;
public interface RSFont extends RSFontTypeFace
{
}

View File

@@ -36,4 +36,7 @@ public interface RSFontTypeFace extends FontTypeFace
@Import("verticalSpace")
@Override
int getBaseline();
@Import("drawTextLeftAligned")
void drawTextLeftAligned(String text, int x, int y, int fontColor, int shadowColor);
}