Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
446ad25
feat: create dynamic FramePieceRenderer anchoring system
Jameskmonger Jul 17, 2023
6da7a2a
refactor: migrate chatbox rendering to FramePieceRenderer
Jameskmonger Jul 17, 2023
43a88e6
refactor: move unnecessary RenderTabArea
Jameskmonger Jul 17, 2023
23c359f
refactor: split Minimap and MinimapRenderer
Jameskmonger Jul 18, 2023
c5d918f
refactor: extend FrameRenderer interface and move logic to ResizableF…
Jameskmonger Jul 18, 2023
8de35ea
refactor: remove drawFramePiece
Jameskmonger Jul 18, 2023
d13a4c1
refactor: create FixedFrameRenderer and defer all coords checks
Jameskmonger Jul 18, 2023
9247136
refactor: dont create renderer by default
Jameskmonger Jul 18, 2023
c251a09
refactor: remove unused minimap instance
Jameskmonger Jul 18, 2023
b1b1c60
refactor: simplify frame checks in drawGameScreen
Jameskmonger Jul 18, 2023
8a0e02a
refactor: rename drawFrame
Jameskmonger Jul 18, 2023
350a64c
refactor: move needless if check
Jameskmonger Jul 18, 2023
4a18ad0
refactor: move gameScreenImageProducer to ScreenController and add ra…
Jameskmonger Jul 18, 2023
bd3cbe5
refactor: convert DebugTools to instanced rasterizer
Jameskmonger Jul 18, 2023
b47b6e6
refactor: pass RasterizerInstanced to FrameRenderer
Jameskmonger Jul 18, 2023
ac8245a
refactor: convert resizable debug view to instanced rasterizer
Jameskmonger Jul 18, 2023
b590300
refactor: use rasterizer directly, move methods out of FramePieceRend…
Jameskmonger Jul 18, 2023
996346c
fix: add check for MAX_VALUE in RasterizerInstanced.copyPixels
Jameskmonger Jul 18, 2023
9bb6811
refactor: draw to specified RasterizerInstanced
Jameskmonger Jul 18, 2023
15d7bf8
refactor: rename createGameRasterizer to setDrawComponent
Jameskmonger Jul 18, 2023
6c19949
refactor: move genuine statics to top
Jameskmonger Jul 18, 2023
c55029f
refactor: create rasterizer on ScreenController immediately
Jameskmonger Jul 18, 2023
8474afc
refactor: use instanced Rasteriser in Game
Jameskmonger Jul 18, 2023
d698a7b
refactor: rename LoginScreen
Jameskmonger Jul 18, 2023
9a82a3a
refactor: de-staticify loginscreen
Jameskmonger Jul 18, 2023
8233c9d
refactor: rename cleanup
Jameskmonger Jul 18, 2023
9960ae9
refactor: add optional RasterizerInstanced to ProducingGraphicsBuffers
Jameskmonger Jul 18, 2023
75ddfee
refactor: convert LoginScreen to use instance rasterizer (except text…
Jameskmonger Jul 18, 2023
b570848
refactor: convert text to use instanced rasterizer
Jameskmonger Jul 18, 2023
0ee8158
refactor: rename Model draw methods
Jameskmonger Jul 18, 2023
4eedccb
fix: reset bounds after draw
Jameskmonger Jul 18, 2023
46eb24b
refactor: move lookup tables to Constants3D
Jameskmonger Jul 18, 2023
889aaac
refactor: create Palette class to store color palette
Jameskmonger Jul 18, 2023
a87da62
refactor: don't make Rasterizer3D extend Rasterizer
Jameskmonger Jul 18, 2023
ac4041e
refactor: rename to decapitalise Rasterizer (for easier searching)
Jameskmonger Jul 18, 2023
c23afb3
refactor: create Game3DRenderer for screen overlays
Jameskmonger Jul 18, 2023
ceb6f20
Revert "refactor: use instanced Rasteriser in Game"
Jameskmonger Jul 19, 2023
c119b91
refactor: convert ChatBox to instanced rasterizer
Jameskmonger Jul 21, 2023
e3c3952
refactor: remove needless Rasterizer. specifiers
Jameskmonger Jul 21, 2023
62e3b37
refactor: use instanced Rasterizer in ScreenController
Jameskmonger Jul 21, 2023
e6821b6
refactor: use instanced rasterizer for minimap
Jameskmonger Jul 21, 2023
483975b
refactor: dont extend Rasterizer in ImageRGB
Jameskmonger Jul 21, 2023
53d7b48
refactor: use instanced rasterizer for console scrollbar
Jameskmonger Jul 21, 2023
1c0ac11
refactor: convert "loading text" to instanced rasterizer
Jameskmonger Jul 21, 2023
a0322d9
refactor: convert healthbar to instanced rasterizer
Jameskmonger Jul 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/main/java/org/runejs/client/MovedStatics.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public class MovedStatics {
public static boolean aBoolean512;
public static int[] anIntArray3111;
public static Signlink signlink;
public static ProducingGraphicsBuffer tabPieveLowerRight;
public static ProducingGraphicsBuffer tabPieceLowerRight;
public static GameSocket lostConnectionSocket;
public static ProducingGraphicsBuffer tabPieceLeft;
public static int anInt3048 = 1;
Expand Down Expand Up @@ -1459,7 +1459,7 @@ private static void method344(int arg0) {
tabHighlightImageBottomLeft = null;
tabHighlightImageBottomLeftEdge = null;
fullScreenTextureArray = null;
tabPieveLowerRight = null;
tabPieceLowerRight = null;
framePieceTop = null;
chatboxBackgroundImage = null;
}
Expand Down Expand Up @@ -1921,7 +1921,7 @@ public static void drawWelcomeScreenGraphics() {
framePieceTop.drawGraphics(0, 0, graphics);
mapBackRight.drawGraphics(516, 4, graphics);
tabPieceUpperRight.drawGraphics(516, 205, graphics);
tabPieveLowerRight.drawGraphics(496, 357, graphics);
tabPieceLowerRight.drawGraphics(496, 357, graphics);
chatboxTop.drawGraphics(0, 338, graphics);
}
} catch(Exception exception) {
Expand Down Expand Up @@ -1971,7 +1971,7 @@ public static void method763(Component arg0, CacheArchive arg2) {
tabPieceUpperRight = createGraphicsBuffer(image.imageWidth, image.imageHeight, arg0);
image.drawInverse(0, 0);
image = method1028(arg2, Native.imgBackvmid3, Native.aClass1_305);
tabPieveLowerRight = createGraphicsBuffer(image.imageWidth, image.imageHeight, arg0);
tabPieceLowerRight = createGraphicsBuffer(image.imageWidth, image.imageHeight, arg0);
image.drawInverse(0, 0);
image = method1028(arg2, Native.imgBackhmid2, Native.aClass1_305);
chatboxTop = createGraphicsBuffer(image.imageWidth, image.imageHeight, arg0);
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/runejs/client/frame/ChatBoxRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.runejs.client.frame;

import org.runejs.client.Game;
import org.runejs.client.MovedStatics;
import org.runejs.client.ProducingGraphicsBuffer;
import org.runejs.client.media.RasterizerInstanced;

/**
* Renders the chat box.
*/
public class ChatBoxRenderer extends FramePieceRenderer {
private final ProducingGraphicsBuffer graphics;

public ChatBoxRenderer() {
super(
new FramePieceAnchor(
FramePieceAnchor.Anchor.BOTTOM | FramePieceAnchor.Anchor.LEFT,
0,
-22
),
516,
184
);

graphics = MovedStatics.createGraphicsBuffer(this.width, this.height, Game.gameCanvas);
rasterizerInstanced = new RasterizerInstanced(graphics);
}

public ProducingGraphicsBuffer getDrawable() {
return graphics;
}

public void render() {
copyProducer(ChatBox.chatBoxImageProducer, 17, 16);
copyProducer(MovedStatics.chatModes, 0, 112);
copyProducerCutOff(MovedStatics.tabBottom, 496, 125, 20, MovedStatics.tabBottom.height, 0, 0);
copyProducer(MovedStatics.chatboxRight, 0, 16);
copyProducerCutOff(MovedStatics.chatboxTop, 0, 0, MovedStatics.chatboxTop.width - 37, MovedStatics.chatboxTop.height - 3, 0, 3);
copyProducerCutOff(MovedStatics.tabPieceLowerRight, 496, 16, 20, MovedStatics.tabPieceLowerRight.height, 0, 0);
}
}
68 changes: 68 additions & 0 deletions src/main/java/org/runejs/client/frame/FramePieceAnchor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.runejs.client.frame;

/**
* Represents an anchor for a {@link FramePieceRenderer},
* i.e. the position of the piece relative to the overall window.
*/
public class FramePieceAnchor {
/**
* The different anchor types.
*
* These are bit flags, so they can be combined.
*/
public static class Anchor {
public static final int LEFT = 0b0001;
public static final int RIGHT = 0b0010;
public static final int TOP = 0b0100;
public static final int BOTTOM = 0b1000;
}

/**
* The anchor type, composed of the {@link Anchor} flags.
*/
public final int anchor;

/**
* The margin from the anchor in the X direction.
*/
public final int marginX;

/**
* The margin from the anchor in the Y direction.
*/
public final int marginY;

public FramePieceAnchor(int anchor, int marginX, int marginY) {
this.anchor = anchor;
this.marginX = marginX;
this.marginY = marginY;
}

/**
* Gets the position of the piece relative to the overall window.
*
* @param drawWidth The width of the window.
* @param drawHeight The height of the window.
* @param sizeX The width of the piece.
* @param sizeY The height of the piece.
* @return The position of the piece.
*/
public int[] getPosition(int drawWidth, int drawHeight, int sizeX, int sizeY) {
int x = 0;
int y = 0;

if ((anchor & Anchor.LEFT) == Anchor.LEFT) {
x = marginX;
} else if ((anchor & Anchor.RIGHT) == Anchor.RIGHT) {
x = drawWidth - sizeX - marginX;
}

if ((anchor & Anchor.TOP) == Anchor.TOP) {
y = marginY;
} else if ((anchor & Anchor.BOTTOM) == Anchor.BOTTOM) {
y = drawHeight - sizeY - marginY;
}

return new int[]{x, y};
}
}
62 changes: 61 additions & 1 deletion src/main/java/org/runejs/client/frame/FramePieceRenderer.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
package org.runejs.client.frame;

import org.runejs.client.ProducingGraphicsBuffer;
import org.runejs.client.cache.media.ImageRGB;
import org.runejs.client.media.RasterizerInstanced;

public class FramePieceRenderer {
public abstract class FramePieceRenderer {
public RasterizerInstanced rasterizerInstanced;

public final FramePieceAnchor anchor;
public final int width;
public final int height;

public FramePieceRenderer(FramePieceAnchor anchor, int width, int height) {
this.anchor = anchor;
this.width = width;
this.height = height;
}

public abstract ProducingGraphicsBuffer getDrawable();

/**
* Draws the piece.
* @param drawWidth The width of the window.
* @param drawHeight The height of the window.
*
* TODO (jkm) refactor this to not use static `ScreenController`.
*/
public void draw(int drawWidth, int drawHeight) {
int[] position = this.anchor.getPosition(drawWidth, drawHeight, this.width, this.height);

ScreenController.drawFramePiece(
getDrawable(),
position[0],
position[1]
);
}

/**
* Copies the pixels from a ProducingGraphicsBuffer to the rasterizer.
*
* See {@link RasterizerInstanced#copyPixels} for more information.
*
* @param producer The ProducingGraphicsBuffer to copy from.
* @param x The X position to copy to.
* @param y The Y position to copy to.
*/
protected void copyProducer(ProducingGraphicsBuffer producer, int x, int y) {
rasterizerInstanced.copyPixels(producer.pixels, producer.width, producer.height, x, y);
}

/**
* Copies the pixels from a ProducingGraphicsBuffer to the rasterizer.
*
* See {@link RasterizerInstanced#copyPixelsCutOff} for more information.
*
* @param producer The ProducingGraphicsBuffer to copy from.
* @param x The X position to copy to.
* @param y The Y position to copy to.
* @param width The width of the area to copy.
* @param height The height of the area to copy.
* @param offsetX The X offset to copy from.
* @param offsetY The Y offset to copy from.
*/
protected void copyProducerCutOff(ProducingGraphicsBuffer producer, int x, int y, int width, int height, int offsetX, int offsetY) {
rasterizerInstanced.copyPixelsCutOff(producer.pixels, producer.width, producer.height, x, y, width, height, offsetX, offsetY);
}

public void shapeImageToPixels(ImageRGB image, int x, int y, int width, int height, int arg4, int arg5, int k1, int zoom, int[] arg8, int[] arg9) {
try {
int centerX = -width / 2;
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/runejs/client/frame/Minimap.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,16 @@ public class Minimap extends FramePieceRenderer {
private static int[] resizableMinimapLineOffsets;

public Minimap() {
super(
new FramePieceAnchor(
FramePieceAnchor.Anchor.TOP | FramePieceAnchor.Anchor.RIGHT,
0,
0
),
210,
210
);

this.tempResizableMiniMapimage = MovedStatics.createGraphicsBuffer(210, 210, Game.gameCanvas);
resizableMinimapOffsets1 = new int[200];
resizableMinimapOffsets2 = new int[200];
Expand Down Expand Up @@ -422,8 +432,8 @@ public static void drawMapBack() {
}
}

public void drawResizableMiniMapArea(int x, int y) {
ScreenController.drawFramePiece(resizableMiniMapimage, x, y);
public ProducingGraphicsBuffer getDrawable() {
return resizableMiniMapimage;
}

public void RenderResizableMiniMapArea(int x, int y) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
public class ResizableFrameRenderer implements FrameRenderer {
private final Minimap minimap;
private final TabProducer tabProducer;
private final ChatBoxRenderer chatbox;

public ResizableFrameRenderer(Minimap minimap, TabProducer tabProducer) {
public ResizableFrameRenderer(Minimap minimap, TabProducer tabProducer, ChatBoxRenderer chatbox) {
this.minimap = minimap;
this.tabProducer = tabProducer;
this.chatbox = chatbox;
}

@Override
public void run() {
while(true){
if(Game.gameStatusCode <= 35 && Game.gameStatusCode >= 30){
minimap.RenderResizableMiniMapArea(ScreenController.drawWidth - 210, 0);
}
if(Game.gameStatusCode <= 35 && Game.gameStatusCode >= 30){
tabProducer.RenderResizableSideBarArea();
chatbox.render();
}
try {
Thread.sleep(1);
Expand Down
41 changes: 5 additions & 36 deletions src/main/java/org/runejs/client/frame/ScreenController.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class ScreenController {
public static int drawHeight = 540;
public static Minimap minimap = new Minimap();
public static TabProducer tabProducer = new TabProducer();
public static ChatBoxRenderer chatBoxRenderer = new ChatBoxRenderer();
private static Thread drawingThread;
private static FrameRenderer renderer;
public static boolean DebugView = false;
Expand Down Expand Up @@ -129,15 +130,14 @@ public static void setBounds() {
*/
public static void RenderResizableUI() {
if (drawingThread == null) {
renderer = new ResizableFrameRenderer(minimap, tabProducer);
renderer = new ResizableFrameRenderer(minimap, tabProducer, chatBoxRenderer);
drawingThread = new Thread(renderer);
drawingThread.start();
}
minimap.drawResizableMiniMapArea(drawWidth - 210, 0);
RenderTabArea(drawWidth - 234, drawHeight - (337));
RenderChatArea(0, drawHeight - (162));

tabProducer.drawResizableSideBarArea(drawWidth - 241, drawHeight - (334));
minimap.draw(drawWidth, drawHeight);
tabProducer.draw(drawWidth, drawHeight);
chatBoxRenderer.draw(drawWidth, drawHeight);

if (DebugView) {
int mX = MouseHandler.mouseX;
Expand Down Expand Up @@ -200,37 +200,6 @@ public static Dimension getInnerSize(Frame frame) {
return size;
}

/**
* TODO (jkm) move all this to ResizableFrameRenderer
*/
public static void RenderTabArea(int x, int y) {
// height 337
// width 234
drawFramePiece(MovedStatics.tabPieceLeft, x + 212, y + 39);
drawFramePieceCutout(MovedStatics.tabPieceUpperRight, x, y + 39, MovedStatics.tabPieceUpperRight.width - 15, MovedStatics.tabPieceUpperRight.height, 15, 0);
drawFramePieceCutout(MovedStatics.tabPieveLowerRight, x, y + 191, MovedStatics.tabPieveLowerRight.width - 35, MovedStatics.tabPieveLowerRight.height, 35, 0);
drawFramePieceCutout(MovedStatics.chatboxTop, x, y + 172, MovedStatics.chatboxTop.width - 531, MovedStatics.chatboxTop.height, 531, 0);
drawFramePieceCutout(MovedStatics.tabBottom, x, y + 300, MovedStatics.tabBottom.width - 35, MovedStatics.tabBottom.height, 35, 0);
drawFramePieceCutout(MovedStatics.tabTop, x, y, MovedStatics.tabTop.width - 15, MovedStatics.tabTop.height - 6, 15, 6);
drawFramePiece(MovedStatics.tabImageProducer, x + 22, y + 39);
}

/**
* TODO (jkm) move all this to ResizableFrameRenderer
*/
public static void RenderChatArea(int x, int y) {
//width 516
//height 184
drawFramePiece(ChatBox.chatBoxImageProducer, x + 17, y + 16);
drawFramePiece(MovedStatics.chatModes, x, y + 112);
drawFramePieceCutout(MovedStatics.tabBottom, x + 496, y + 125, 20, MovedStatics.tabBottom.height, 0, 0);
drawFramePiece(MovedStatics.chatboxRight, x, y + 16);
drawFramePieceCutout(MovedStatics.chatboxTop, x, y, MovedStatics.chatboxTop.width - 37, MovedStatics.chatboxTop.height - 3, 0, 3);
// System.out.println(Class40_Sub5_Sub1.chatboxRight.height + (Class17.chatboxTop.height-3) + HuffmanEncoding.aProducingGraphicsBuffer_1541.height);

drawFramePieceCutout(MovedStatics.tabPieveLowerRight, x + 496, y + 16, 20, MovedStatics.tabPieveLowerRight.height, 0, 0);
}

public static void drawFramePiece(ProducingGraphicsBuffer framePiece, int x, int y) {
Rasterizer.copyPixels(framePiece.pixels, framePiece.width, framePiece.height, x, y);
}
Expand Down
16 changes: 13 additions & 3 deletions src/main/java/org/runejs/client/frame/tab/TabProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.runejs.client.ProducingGraphicsBuffer;
import org.runejs.client.cache.media.ImageRGB;
import org.runejs.client.cache.media.gameInterface.GameInterface;
import org.runejs.client.frame.FramePieceAnchor;
import org.runejs.client.frame.FramePieceRenderer;
import org.runejs.client.frame.ScreenController;
import org.runejs.client.frame.tab.parts.TabParts;
import org.runejs.client.media.RasterizerInstanced;

Expand Down Expand Up @@ -44,6 +44,16 @@ public class TabProducer extends FramePieceRenderer {


public TabProducer() {
super(
new FramePieceAnchor(
FramePieceAnchor.Anchor.BOTTOM | FramePieceAnchor.Anchor.RIGHT,
0,
0
),
241,
334
);

this.tempResizableSideBar = MovedStatics.createGraphicsBuffer(241, 334, Game.gameCanvas);
resizableSideBarImage = MovedStatics.createGraphicsBuffer(241, 334, Game.gameCanvas);
rasterizerInstanced = new RasterizerInstanced(this.tempResizableSideBar);
Expand Down Expand Up @@ -155,8 +165,8 @@ public int[] getTabButtonBox(int tabButtonIndex) {



public void drawResizableSideBarArea(int x, int y) {
ScreenController.drawFramePiece(resizableSideBarImage, x, y);
public ProducingGraphicsBuffer getDrawable() {
return resizableSideBarImage;
}

public int[] getTabInterfaceCoordSize(int baseX, int baseY) {
Expand Down
Loading