Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
October 22, 2021 06:10 pm GMT

Third Hacktoberfest Contribution

For my 3rd contribution, I decided to go with a project that I'd frequently used as an end user in the past, runelite. Runelite is an open source client for Old-School Runescape, which almost every player uses. The client features a bunch of helpful plugins that enhance the user's experience over the default, plugin-less, base client.

I looked through the issues and was able to find a feature request I found interesting.

The Issue

The issue author pointed out that the NPC Indicator plugin, which highlights NPCs by name, has the ability to set a highlight and fill colour. While the Ground Marker, Ground Item, and Object Marker plugins, which have similar functionality to the NPC Indicator plugin, do not.

NPC Indicator plugin at work with red fill colourNPC Indicator plugin at work with red fill colour

Working on the Issue

Following the project's CONTRIBUTING.md, I set up a local instance and got to work.

After using the NPC Indicator plugin as a reference, I was able to figure out how to add new settings to plugins.

Image description

Image description

Ground Marker Plugin

I started by looking for where these colours were being passed to render the highlight. I was able to figure out that the renderPolygon function was the final destination in all 4 plugins. I passed the fill colour object to this function and it worked! I just had to repeat the steps for the other 2 plugins.

Object Indicator Plugin

Or so I thought.. Turns out, the Object Indicator plugin has a feature that "remembers" the colour set at the time of marking. This means, if you highlight/mark an in-game object, then change the colour of the highlights, only future highlights will have the new colour.

Image description

After some looking around, I realized that the plugin iterates through a list of ColorTileObject objects, which is simply a list of objects that we've highlighted. It gets the colour of each of these objects, and if the "remember" option is selected, it uses the ColorTileObject object's colours. So, I added a fillColour attribute to the ColorTileObject class, and the fill colour was able to be remembered.

Image description

Image description

Ground Item Plugin

The Ground Item plugin, which highlights items on the ground based on price, was also not as straight-forward as I thought. I learned that after finding an item on the ground, the plugin took the item's price, ran it through the getHighlighted function, and returned a Color object which denotes the price range. Because I wanted the fill colour to also line up with different price ranges, I had to either make a new function the returns a fill colour, or alter the getHighlighted function to return an object that contains both. I opted with the latter because It'd save time by only checking the price once.

To do this, I added a fillColor attribute to the PriceHighlight class, which contains information on each highlighted item.

static class PriceHighlight{    private final int price;    private final Color color;    private final Color fillColor;}

Then, I altered the getHighlighted function to return a PriceHighlight object, which would contain the item's information including fill and outline colours, depending on price. I then added a function called getItemFillColor that checks if the PriceHighlight object should be coloured differently based on plugin settings. This mimicked the already existing getItemColor function.

The Ground Item plugin now had fully customizable fill colours for each price tier.

Pull Request

After making sure each plugin is fully functioning, I submitted my pull request, which at the time of writing, still hasn't been reviewed.

Result

Before

No fill color customization, stuck with black.
Image description

After

Full fill color customization.
Image description


Original Link: https://dev.to/ar/third-hacktoberfest-contribution-340m

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To