Bigace360

Window_GameCompletion [RMXP] v2.0

May 31st, 2012
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.67 KB | None | 0 0
  1. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  2. # ■ Window_GameCompletion [RMXP]
  3. # ■ Author: Bigace360
  4. # ■ Version: 2.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. #                               VERSION HISTORY                                #
  14. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  15. #  v 1.0 - 5.25.2012 > Started and Finished Script
  16. #  v 2.0 - 5.31.2012 > Rewrote the script for compatiblity with the Warrior Engine
  17. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  18. #                                INSTRUCTIONS                                  #
  19. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  20. # In the Event Editor, under the Control Variable tab, set the variable to the
  21. # number you have in the module below. Then have the Operation at Set and then,
  22. # change the constant to whatever number you want to add between 1~100.
  23. #+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
  24. #
  25. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  26. # ■ Warrior Engine (Setting module for the Warrior Engine)
  27. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
  28. module Warrior_Engine
  29.     #=============================================================================
  30.     # ▼ Warning DO NOT TOUCH THIS MODULE, altering this will ruin any chances of
  31.     #   any script that requires this engine to run.
  32.     #
  33.     # For Configurations go to Module Core below this one.
  34.     #=============================================================================
  35.     module MESSAGE
  36.         #--------------------------------------------------------------------------
  37.         # * required
  38.         #   This method checks for the existance of the basic module and other
  39.         #   WARRIOR scripts required for this script to work, don't edit this
  40.         #--------------------------------------------------------------------------
  41.         def self.required(name, req, version, type = nil)
  42.             if !$imported[:ace_warrior_module]
  43.                 msg = "The script '%s' requires the script\n"
  44.                 msg += "'Warrior_Engine' v%s or higher above it to work properly\n"
  45.                 msg += "Go to http://bigaceworld.wordpress.com/ to download this script."
  46.                 print(sprintf(msg, self.script_name(name), version))
  47.                 exit
  48.             else
  49.                 self.required_script(name, req, version, type)
  50.             end
  51.         end
  52.         #--------------------------------------------------------------------------
  53.         # * script_name
  54.         #   Get the script name base on the imported value, don't edit this
  55.         #--------------------------------------------------------------------------
  56.         def self.script_name(name, ext = "WE")
  57.             name = name.to_s.gsub("_", " ").upcase.split
  58.             name.collect! {|char| char == ext ? "#{char} -" : char.capitalize }
  59.             name.join(" ")
  60.         end
  61.     end
  62. end
  63.  
  64. #=============================================================================
  65. # ▼ BEGIN CONFIGURATIONS HERE BELOW
  66. #=============================================================================
  67.  
  68. module ACE
  69.     module Completion
  70.         #The set game_variable
  71.         PROGRESS_VARIABLE = 1
  72.         # The way progress percentage will be displayed.
  73.         COMPLETE_PERCENT  = "%1.0f%%"    
  74.         #Name of the window
  75.         HEADER            = 'Game Completion'
  76.         #Colors for the bar
  77.         PRG_COLOR1 = Color.new(150, 0, 0, 255)
  78.         PRG_COLOR2 = Color.new(255, 255, 60, 255)
  79.         #Color for a 100% game completion bar
  80.         FULL_COLOR = Color.new(0, 255, 0, 255)
  81.     end
  82. end
  83.  
  84. #==============================================================================
  85. # ▼ Editting anything past this point may potentially result in causing
  86. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  87. # halitosis so edit at your own risk.
  88. #==============================================================================
  89.  
  90. $imported ||= {}
  91. $imported[:completion_script] = 2.0
  92. Warrior_Engine::MESSAGE.required(:completion_script, :ace_warrior_module, 1.00, :above)
  93.  
  94. class Window_Progress < Window_Base
  95.     include ACE::Completion
  96.     attr_reader   :progress   # PROGRESS
  97.     def initialize(x, y)
  98.         super(x, y, 160, 64)
  99.         self.contents = Bitmap.new(width - 32, height - 32)
  100.         @progress = 0
  101.         refresh
  102.     end
  103.     def window_width;  return 160;                                     end   
  104.     def progres_v;     return $game_variables[PROGRESS_VARIABLE];      end
  105.     def complete_rate; progres_v > 0 ? @progress.to_f / progres_v : 0; end
  106.     def refresh
  107.         contents.clear
  108.         draw_completion_bar(0, -4, progress)
  109.     end
  110.     def draw_gauge(dx, dy, dw, rate, color1, color2)
  111.         dw += 2 if true
  112.         fill_w = dw * progres_v / [100, 1].max
  113.         warrior_guage(dx, dy, dw, rate, fill_w, color1, color2, 8)
  114.     end
  115.     def draw_completion_bar(x, y, progress, width = 120)
  116.         draw_gauge(x+5, y+3, width, complete_rate, PRG_COLOR1, PRG_COLOR2)
  117.         if progres_v == 100
  118.             draw_gauge(x+5, y, width, complete_rate, FULL_COLOR, FULL_COLOR)
  119.         end
  120.         change_color(system_color)
  121.         draw_text(x, y-5, window_width-32, 32, HEADER, 1)
  122.         change_color(normal_color)
  123.         xr = x + width
  124.         if @progress == 0
  125.             text = sprintf(COMPLETE_PERCENT, progres_v)
  126.         else
  127.             text = sprintf(COMPLETE_PERCENT, @progress.to_i * 100 / 100)
  128.         end
  129.         self.contents.font.size = 14
  130.         draw_text(x+5, y+12, width, 32, text, 2)
  131.     end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment