Thread: New Interface Type: Percentage Bars - Horizontal and Vertical

Results 1 to 5 of 5
  1. #1 New Interface Type: Percentage Bars - Horizontal and Vertical 
    Community Veteran

    Dexter Morgan's Avatar
    Join Date
    Nov 2008
    Age
    28
    Posts
    4,419
    Thanks given
    1,184
    Thanks received
    757
    Rep Power
    3098
    Code:
    	public int percentageCompleted;
    	public int percentageTotal;
    	public int percentageSpriteEmpty;
    	public int percentageSpriteFull;
    	public int percentageDimension;
    	public boolean verticleBar;
    
    	public static Widget addPercentageBar(int id, int percentageDimension, int percentageTotal,
    			int percentageSpriteEmpty, int percentageSpriteFull, boolean verticleBar) {
    		Widget rs = interfaceCache[id] = new Widget();
    		rs.id = id;
    		rs.parent = id;
    		rs.type = TYPE_PERCENTAGE;
    		rs.atActionType = 0;
    		rs.contentType = 0;
    		rs.opacity = 0;
    		rs.hoverType = 0;
    		rs.percentageCompleted = 0;
    		rs.percentageDimension = percentageDimension;
    		rs.percentageSpriteFull = percentageSpriteFull;
    		rs.percentageSpriteEmpty = percentageSpriteEmpty;
    		rs.percentageTotal = percentageTotal;
    		rs.verticleBar = verticleBar;
    		rs.width = 0;
    		rs.height = 0;
    		return rs;
    	}
    In drawInterface

    Code:
    				else if (childInterface.type == Widget.TYPE_PERCENTAGE) {
    					GameFont textDrawingArea = childInterface.textDrawingAreas;
    					RSFont font = newSmallFont;
    					int size = 2;
    					if (textDrawingArea == smallText) {
    						font = newSmallFont;
    						size = 3;
    					} else if (textDrawingArea == regularText) {
    						font = newRegularFont;
    						size = 3;
    					} else if (textDrawingArea == boldText) {
    						font = newBoldFont;
    						size = 0;
    					} else if (textDrawingArea == gameFont) {
    						font = newFancyFont;
    						size = 3;
    					}
    					int completed = childInterface.percentageCompleted;
    					int total = childInterface.percentageTotal;
    					int complete = (completed * childInterface.percentageDimension) / total;
    					int percentage = (completed * 100) / total;
    					boolean verticle = childInterface.verticleBar;
    
    					cacheSprite[childInterface.percentageSpriteEmpty].drawSprite(_x, currentY);
    					for (int i = 0; i < complete; i++) {
    						cacheSprite[childInterface.percentageSpriteFull].drawSprite(_x + 1 + (verticle ? 0 : i), currentY + 1 + (verticle ? i : 0));
    					}
    	if (verticle) {
    						int xWidth = cacheSprite[childInterface.percentageSpriteEmpty].myWidth;
    						font.drawCenteredString(percentage + "%", _x + (xWidth / 2),
    								currentY + 9 + size + (childInterface.percentageDimension) + 6,
    								0xffffff, 0);
    					} else {
    						font.drawCenteredString(percentage + "%",
    								_x + (childInterface.percentageDimension / 2) + 3, currentY + 9 + size,
    								0xffffff, 0);
    					}
    				}
    Example:
    Attached image

    Here's the sprites from the above. The full sprite needs to be 1 pixel.
    Attached image
    Attached image

    There are other ways of doing it as well. This is one of them
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member

    Join Date
    Oct 2017
    Age
    23
    Posts
    215
    Thanks given
    211
    Thanks received
    113
    Rep Power
    300
    awesome, kinda needed this, my current progress bar is so stupid.

    Appreciate it dexter!
    Spoiler for signature too large:
    end me
    Attached image
    Attached image
    Reply With Quote  
     

  4. Thankful user:


  5. #3  
    Registered Member
    Brainpower's Avatar
    Join Date
    Jan 2019
    Posts
    130
    Thanks given
    13
    Thanks received
    13
    Rep Power
    101
    Looks pretty good, won't use but thanks for the contribution.
    Reply With Quote  
     

  6. #4  
    Throne Scape - Founder/Developer
    Mokhtar's Avatar
    Join Date
    Mar 2018
    Posts
    803
    Thanks given
    43
    Thanks received
    171
    Rep Power
    299
    Thanks looks good
    Reply With Quote  
     

  7. #5  
    COMMING SOON

    Fluxious's Avatar
    Join Date
    Jan 2019
    Posts
    388
    Thanks given
    195
    Thanks received
    198
    Rep Power
    502
    thanks, unique and amazing.
    Attached image
    Reply With Quote  
     


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. New interface format and old
    By Groovy in forum Help
    Replies: 2
    Last Post: 07-10-2010, 11:37 PM
  2. Replies: 2
    Last Post: 05-31-2010, 03:11 PM
  3. Replies: 0
    Last Post: 09-15-2009, 01:08 AM
  4. Adding new special bar (EASY AND SHORT)
    By Jonas++ in forum Tutorials
    Replies: 41
    Last Post: 02-25-2009, 06:35 AM
  5. Replies: 22
    Last Post: 06-05-2008, 05:01 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •