Advertisement
Bigace360

Window_GameCompletion [RMVXace]

May 25th, 2012
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.07 KB | None | 0 0
  1. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  2. # ■ Window_GameCompletion [RMVXace]
  3. # ■ Author: Bigace360
  4. # ■ Version: 1.0
  5. # ■ Date: 5.25.2012
  6. # Home Blog: http://bigaceworld.wordpress.com/
  7. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  8. #                                INTRODUCTION                                  #
  9. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  10. #  Shows how much percentage of the game is completed by calling how much a
  11. #  variable is.
  12. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  13. #                                INSTRUCTIONS                                  #
  14. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  15. # In the Event Editor, under the Control Variable tab, set the variable to the
  16. # number you have in the module below. Then have the Operation at Set and then,
  17. # change the constant to whatever number you want to add between 1~100.
  18. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  19. module ACE
  20.     module Completion
  21.         #The set game_variable
  22.         PROGRESS_VARIABLE = 1
  23.       # The way progress percentage will be displayed.
  24.         COMPLETE_PERCENT  = "%1.0f%%"    
  25.         #Name of the window
  26.         HEADER            = 'Game Completion'
  27.         #Colors for the bar
  28.         PRG_COLOR1 = Color.new(150, 0, 0, 255)
  29.         PRG_COLOR2 = Color.new(255, 255, 60, 255)
  30.         #Color for a 100% game completion bar
  31.         FULL_COLOR = Color.new(0, 255, 0, 255)
  32.     end
  33. end
  34. class Window_Progress < Window_Base
  35.     include ACE::Completion
  36.     attr_reader   :progress   # PROGRESS
  37.     def initialize
  38.         super(0, 0, window_width, fitting_height(2))
  39.         @progress = 0
  40.         refresh
  41.     end
  42.     def window_width;  return 160;                                     end   
  43.     def progres_v;     return $game_variables[PROGRESS_VARIABLE];      end
  44.     def complete_rate; progres_v > 0 ? @progress.to_f / progres_v : 0; end
  45.     def refresh
  46.         contents.clear
  47.         draw_completion_bar(x, y, progress)
  48.     end
  49.   def draw_gauge(dx, dy, dw, rate, color1, color2)
  50.         dw += 2 if true
  51.         fill_w = dw * progres_v / [100, 1].max
  52.         gauge_h = 12
  53.         gauge_y = dy + 24
  54.         if true
  55.             outline_colour = gauge_back_color
  56.             outline_colour.alpha = translucent_alpha
  57.             self.contents.fill_rect(dx, gauge_y, dw, gauge_h, outline_colour)
  58.             dx += 1
  59.         end
  60.         self.contents.fill_rect(dx, gauge_y, dw, gauge_h, outline_colour)
  61.         contents.gradient_fill_rect(dx, gauge_y, fill_w, gauge_h, color1, color2)
  62.   end
  63.     def draw_completion_bar(x, y, progress, width = 120)
  64.         draw_gauge(x+5, y+10, width, complete_rate, PRG_COLOR1, PRG_COLOR2)
  65.         if progres_v == 100
  66.             draw_gauge(x+5, y+10, width, complete_rate, FULL_COLOR, FULL_COLOR)
  67.         end
  68.         change_color(system_color)
  69.         draw_text(x, y-6, window_width-32, 32, HEADER, 1)
  70.         change_color(normal_color)
  71.         xr = x + width
  72.         if @progress == 0
  73.             text = sprintf(COMPLETE_PERCENT, progres_v)
  74.         else
  75.       text = sprintf(COMPLETE_PERCENT, @progress.to_i * 100 / 100)
  76.     end
  77.     draw_text(x+10, y+15, width, 32, text, 2)
  78.     end
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement