Thread: Converting from TextDrawingArea to RSFont

Results 1 to 1 of 1
  1. #1 Converting from TextDrawingArea to RSFont 
    Donator

    Join Date
    Oct 2014
    Posts
    146
    Thanks given
    5
    Thanks received
    18
    Rep Power
    4
    Hello everyone,

    This snippet is for the purpose of converting TextDrawingArea types to RSFont types. This allows you to use the tags shown here
    In this tutorial is assuming you've already followed the tutorial here or have in some other way incorporated the RSFont system to your client.


    This is ALL client sided, and I've used the Ruse base in this example (which I believe uses a Simplicity client).

    Firstly open up your RSFont.java (sometimes called RSFontSystem.java).

    Find this method:

    Code:
    public void drawBasicString(String string, int drawX, int drawY) {
    and change it to this:

    Code:
    public void drawBasicString(String string, int drawX, int drawY, boolean handleOldSyntax) {
    Now inside the drawBasicString method under:

    Code:
    int startIndex = -1;
    Add this:

    Code:
    if(handleOldSyntax) {
    			string = handleOldSyntax(string);
    	}

    Next find this method (yes it has the same name just with an extra parameter):

    Code:
    public void drawBasicString(String string, int drawX, int drawY, int color, int shadow) {
    And change it to this:

    Code:
    public void drawBasicString(String string, int drawX, int drawY, int color, int shadow, boolean handleOldSyntax) {
    Inside the same method change this:

    Code:
    drawBasicString(string, drawX, drawY);
    to this:

    Code:
    drawBasicString(string, drawX, drawY, handleOldSyntax);
    Now find the method:

    Code:
    public void drawCenteredString(String string, int drawX, int drawY, int color, int shadow)
    Inside that method replace your if statement with this one:

    Code:
    if (string != null) {
    			setColorAndShadow(color, shadow);
    			string = handleOldSyntax(string);
    			drawBasicString(string, drawX - getTextWidth(string) / 2, drawY, true);
    	}
    Finally find the method:

    Code:
    public void drawRAString(String string, int drawX, int drawY, int color, int shadow) {
    and replace this line:

    Code:
    drawBasicString(string, drawX - getTextWidth(string), drawY);
    to this:

    Code:
    drawBasicString(string, drawX - getTextWidth(string), drawY, true);
    You are now done with the class RSFont.java (or RSFontSystem.java) you may now close it.

    You can now open up Client.java.

    You are going to firstly going to find all instances of "drawBasicString" (by using CTRL + F) and make a quick change to all of them. You're simply going to specify another argument (handleOldSyntax) and set that as true for each instance of this method that you find.

    For example one instance of drawBasicString in my Client.java is this:

    Code:
    newRegularFont.drawBasicString("" + cash, x, y + 21, getAmountColor((long) Long.parseLong(RSInterface.interfaceCache[8135].message)), 0);
    All I'm going to do is add true at the end like this:

    Code:
    newRegularFont.drawBasicString("" + cash, x, y + 21, getAmountColor((long) Long.parseLong(RSInterface.interfaceCache[8135].message)), 0, true);
    Simply rinse and repeat.

    Now finally this last part can be done completely to your liking/need. What we'll be doing is replacing instances of TextDrawingArea drawing text to the client with RSFont. I'm going to show you just one example of changing drawing methods from TextDrawingArea to RSFont.
    This will allow you to use the new tags in the right click menus.

    Find the method:

    Code:
    private void drawMenu() {
    You will see this statement somewhere in the method:

    Code:
    chatTextDrawingArea.method385(0xc6b895, "Choose Option", j + 14, i + 3);
    You're going to want to change that to:

    Code:
    newBoldFont.drawBasicString("Choose Option", i + 3, j + 14, 0xc6b895, 0, true);
    You'll also find this statement in the same method:

    Code:
    chatTextDrawingArea.drawRegularText(true, i + 4, j2, menuActionName[l1], i2 + 1);
    Change that to:

    Code:
    newBoldFont.drawBasicString(menuActionName[l1], i, i2, j2, 0, true);
    As you can see all we've done is change the drawing method from using a type TextDrawingArea to a type RSFont.

    This will now allow you to use the new tags on all right click menus (e.g. right clicking players). You're free to change the drawing methods for any other TextDrawingArea type to RSFont if you'd like to support the use of the new tags. Another example would be modification to the drawTooltip method so that tags are supported when hovering over players.

    I understand that most clients have both TextDrawingArea and RSFont implemented, but not fully to the extent where it's actually being used to draw stuff, and since this was my case I decided that making this tutorial might be beneficial to some individuals.

    Credit:
    98% - Stewie (for actually creating the RSFont text engine).
    2% - Me (just for putting this tutorial together).


    Thank you for reading.
    Last edited by Unlike Me; 12-27-2018 at 04:10 AM.
    Reply With Quote  
     

  2. Thankful user:



Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 8
    Last Post: 12-09-2017, 09:48 AM
  2. convert from long to int
    By 'Varbit in forum Help
    Replies: 17
    Last Post: 08-07-2015, 10:25 AM
  3. Replies: 5
    Last Post: 07-11-2011, 09:44 PM
  4. Replies: 2
    Last Post: 07-10-2011, 12:03 PM
  5. convert from delta to emulous
    By oblivion-rs in forum Requests
    Replies: 0
    Last Post: 07-11-2010, 05:21 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •