Advertisement
LiTTleDRAgo

[RGSS] PK8's RMXP to RMVX(Ace) Windowskin Converter (edited)

Aug 10th, 2014
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 12.32 KB | None | 0 0
  1. =begin
  2.  
  3.  RMXP to RMVX (Ace) Windowskin Converter v1.0.4
  4.  by PK8
  5.  Created: 5/1/2012
  6.  Modified: 6/12/2012
  7.  ──────────────────────────────────────────────────────────────────────────────
  8.  ■ Author's Notes
  9.    I was in yet another experimental kind of mood and decided to script this.
  10.    Mainly inspired by a web-based windowskin converter I wanted to do for my
  11.    old site.
  12.  ──────────────────────────────────────────────────────────────────────────────
  13.  ■ Introduction
  14.    This script will take whatever XP windowskin you give it and mould
  15.    it into a windowskin that would fit right in with RPG Maker VX in-game.
  16.  ──────────────────────────────────────────────────────────────────────────────
  17.  ■ Features
  18.    o Very plug and play. Add this script in, change your windowskin to an
  19.      XP windowskin, edit a couple of settings, and there you go!
  20.  ──────────────────────────────────────────────────────────────────────────────
  21.  ■ Methods Aliased
  22.    o Window_Base.initialize
  23.    o Window_Base.update
  24.  ──────────────────────────────────────────────────────────────────────────────
  25.  ■ Changelog (MM/DD/YYYY)
  26.    v1     (05/01/2012): Initial release.
  27.    v1.0.1 (05/02/2012): I removed a setting. Instead of setting which area would
  28.                         the script copy over to the bitmap, it would copy
  29.                         certain areas depending on the filename. (Applies to XP)
  30.    v1.0.2 (05/03/2012): Disposes the new_windowskin bitmap after it's done
  31.                         generating the converted skin.
  32.    v1.0.3 (05/05/2012): Added a compatibility setting for my windowskin script,
  33.                         took out the compatibility flag setting, and added a
  34.                         switch setting.
  35.    v1.0.4 (06/12/2012): Reduced the code by a couple of lines.
  36.  ──────────────────────────────────────────────────────────────────────────────
  37.  ■ Importing RPG Maker XP Windowskins
  38.    
  39.    o This script has been made to be used along with other windowskin changing
  40.      scripts. To allow this script to be used along with other windowskin
  41.      changers, set the Compatibility setting to anything other than false.
  42.    o If the windowskin doesn't have a "$" or a "!" in its filename...
  43.        It will apply the windowskin's wallpaper onto the background.
  44.    o If the windowskin has a "$" in its filename
  45.        It will apply the windowskin's wallpaper onto the background and pattern.
  46.    o If the windowskin has a "!" in its filename
  47.        It will apply the windowskin's wallpaper onto the pattern.
  48.    
  49. =end
  50.  
  51. #==============================================================================
  52. # ** Configuration
  53. #==============================================================================
  54.  
  55. module PK8
  56.   class Windowskin_Conversion
  57.     #--------------------------------------------------------------------------
  58.     # * Do not modify
  59.     #--------------------------------------------------------------------------
  60.     Colors = []
  61.  
  62.     #--------------------------------------------------------------------------
  63.     # * General Settings
  64.     #--------------------------------------------------------------------------
  65.     # Enable/Disable the script.
  66.     Switch = true
  67.    
  68.     # 0/"Top"/"Stretch"/"Background"/"BG"
  69.     # 1/"Bottom"/"Tile"/"Tiled"/"Pattern"
  70.     # 2/"Whole"/"All"
  71.     Apply = 0
  72.    
  73.     # Which windowskin changer are you using?
  74.     # Values allowed: "woratana", "dervvulfman", "pk8", false
  75.     Compatibility = false
  76.    
  77.     #--------------------------------------------------------------------------
  78.     # * Colors
  79.     #--------------------------------------------------------------------------
  80.     Colors[0]  = [255, 255, 255]    # Normal Text Color
  81.     Colors[1]  = [32 , 160, 214]
  82.     Colors[2]  = [255, 120, 76]
  83.     Colors[3]  = [102, 204, 64]
  84.     Colors[4]  = [153, 204, 255]
  85.     Colors[5]  = [204, 192, 255]
  86.     Colors[6]  = [255, 255, 160]
  87.     Colors[7]  = [128, 128, 128]
  88.     Colors[8]  = [192, 192, 192]
  89.     Colors[9]  = [32 , 128, 204]
  90.     Colors[10] = [255, 56 , 16]
  91.     Colors[11] = [0  , 160, 16]
  92.     Colors[12] = [64 , 154, 222]
  93.     Colors[13] = [160, 152, 255]
  94.     Colors[14] = [255, 204, 32]
  95.     Colors[15] = [0  , 0  , 0]
  96.     Colors[16] = [132, 170, 255]    # System Text Color
  97.     Colors[17] = [255, 255, 64]     # Crisis Color
  98.     Colors[18] = [255, 32 , 32]     # Knockout Color
  99.     Colors[19] = [32 , 32 , 64]     # Gauge Back Color
  100.     Colors[20] = [224, 128, 64]     # HP Gauge Color 1
  101.     Colors[21] = [240, 192, 64]     # HP Gauge Color 2
  102.     Colors[22] = [64 , 128, 192]    # MP Gauge Color 1
  103.     Colors[23] = [64 , 192, 240]    # MP Gauge Color 2 / MP Cost Color
  104.     Colors[24] = [128, 255, 128]    # Power Up Color
  105.     Colors[25] = [192, 128, 128]    # Power Down Color
  106.     Colors[26] = [128, 128, 255]
  107.     Colors[27] = [255, 128, 255]
  108.     Colors[28] = [0  , 160, 64]     # TP Gauge Color 1
  109.     Colors[29] = [0  , 224, 96]     # TP Gauge Color 2 / TP Cost Color
  110.     Colors[30] = [160, 96 , 224]
  111.     Colors[31] = [192, 128, 255]
  112.    
  113.     #--------------------------------------------------------------------------
  114.     # * Do not modify
  115.     #--------------------------------------------------------------------------
  116.     Apply = Apply.downcase if Apply.is_a?(String)
  117.     Compatibility = Compatibility.downcase if Compatibility.is_a?(String)
  118.   end
  119. end
  120.  
  121. #==============================================================================
  122. # ** Window_Base
  123. #------------------------------------------------------------------------------
  124. #  This class is for all in-game windows.
  125. #==============================================================================
  126. if RUBY_VERSION == '1.9.2'
  127. class Window_Base < Window
  128.   #--------------------------------------------------------------------------
  129.   # * Alias Listings
  130.   #--------------------------------------------------------------------------
  131.   unless method_defined?(:pk8_xpwindowskin_initialize)
  132.     alias_method(:pk8_xpwindowskin_initialize, :initialize)
  133.     alias_method(:pk8_xpwindowskin_update, :update)
  134.   end
  135.   #--------------------------------------------------------------------------
  136.   # * Object Initialization
  137.   #--------------------------------------------------------------------------
  138.   def initialize(*args)
  139.     pk8_xpwindowskin_initialize(*args)
  140.     self.padding = 16
  141.     if PK8::Windowskin_Conversion::Switch == true
  142.       if self.windowskin.width == 192 and self.windowskin.height == 128
  143.         new_windowskin = Bitmap.new(128, 128)
  144.         if PK8::Windowskin_Conversion::Compatibility != false
  145.           case PK8::Windowskin_Conversion::Compatibility
  146.           when "woratana", "wora", "worale"
  147.             sign = $game_system.skin[/^[\!\$]./]
  148.           when "dervvulfman", "dervv", "derv"
  149.             sign = $game_system.windowskin[/^[\!\$]./]
  150.           when "pk8", "punk", "punkid89"
  151.             sign = $game_system.windowskin_name[/^[\!\$]./]
  152.           end
  153.           if sign == nil or (sign != nil and sign.include?("$"))
  154.             # Converts XP's background to VX
  155.             new_windowskin.stretch_blt(Rect.new(0, 0, 64, 64), self.windowskin,
  156.               Rect.new(0, 0, 128, 128))
  157.           end
  158.           if sign != nil and (sign.include?("$") or sign.include?("!"))
  159.             # Converts XP's background to VX pattern
  160.             new_windowskin.stretch_blt(Rect.new(0, 64, 64, 64), self.windowskin,
  161.               Rect.new(0, 0, 128, 128))
  162.           end
  163.         else
  164.           case PK8::Windowskin_Conversion::Apply
  165.           when 0, "top", "stretch", "background", "bg"
  166.             # Converts XP's background to VX
  167.             new_windowskin.stretch_blt(Rect.new(0, 0, 64, 64), self.windowskin,
  168.               Rect.new(0, 0, 128, 128))
  169.           when 1, "bottom", "tile", "tiled", "pattern"
  170.             # Converts XP's background to VX pattern
  171.             new_windowskin.stretch_blt(Rect.new(0, 64, 64, 64), self.windowskin,
  172.               Rect.new(0, 0, 128, 128))
  173.           when 2, "all", "whole"
  174.             new_windowskin.stretch_blt(Rect.new(0, 0, 64, 64), self.windowskin,
  175.               Rect.new(0, 0, 128, 128))
  176.             new_windowskin.stretch_blt(Rect.new(0, 64, 64, 64), self.windowskin,
  177.               Rect.new(0, 0, 128, 128))
  178.           end
  179.         end
  180.         new_windowskin.blt(64, 0, self.windowskin, Rect.new(128, 0, 64, 96))
  181.         for i in 0...PK8::Windowskin_Conversion::Colors.size
  182.           column, row = i*8%64, ((i/8).abs)*8
  183.           new_windowskin.fill_rect(64 + column, 96 + row, 8, 8, Color.new(
  184.             *PK8::Windowskin_Conversion::Colors[i]))
  185.         end
  186.         self.windowskin = new_windowskin.clone
  187.         new_windowskin.dispose
  188.       end
  189.     end
  190.   end
  191.   #--------------------------------------------------------------------------
  192.   # * Frame Update
  193.   #--------------------------------------------------------------------------
  194.   def update
  195.     pk8_xpwindowskin_update
  196.     if PK8::Windowskin_Conversion::Switch == true
  197.       if self.windowskin.width == 192 and self.windowskin.height == 128
  198.         if PK8::Windowskin_Conversion::Compatibility != false
  199.           new_windowskin = Bitmap.new(128, 128)
  200.           case PK8::Windowskin_Conversion::Compatibility
  201.           when "woratana", "wora", "worale"
  202.             sign = $game_system.skin[/^[\!\$]./]
  203.           when "dervvulfman", "dervv", "derv"
  204.             sign = $game_system.windowskin[/^[\!\$]./]
  205.           when "pk8", "punk", "punkid89"
  206.             sign = $game_system.windowskin_name[/^[\!\$]./]
  207.           end
  208.           if sign == nil or (sign != nil and sign.include?("$"))
  209.             # Converts XP's background to VX
  210.             new_windowskin.stretch_blt(Rect.new(0, 0, 64, 64), self.windowskin,
  211.               Rect.new(0, 0, 128, 128))
  212.           end
  213.           if sign != nil and (sign.include?("$") or sign.include?("!"))
  214.             # Converts XP's background to VX pattern
  215.             new_windowskin.stretch_blt(Rect.new(0, 64, 64, 64), self.windowskin,
  216.               Rect.new(0, 0, 128, 128))
  217.           end
  218.           new_windowskin.blt(64, 0, self.windowskin, Rect.new(128, 0, 64, 96))
  219.           for i in 0...PK8::Windowskin_Conversion::Colors.size
  220.             column, row = i*8%64, ((i/8).abs)*8
  221.             new_windowskin.fill_rect(64 + column, 96 + row, 8, 8, Color.new(
  222.               *PK8::Windowskin_Conversion::Colors[i]))
  223.           end
  224.           self.windowskin = new_windowskin.clone
  225.           new_windowskin.dispose
  226.         end
  227.       end
  228.     end
  229.   end
  230. end
  231. #==============================================================================
  232. # ** Window_Selectable
  233. #------------------------------------------------------------------------------
  234. #  This window class contains cursor movement and scroll functions.
  235. #==============================================================================
  236.  
  237. class Window_Selectable < Window_Base
  238.   #--------------------------------------------------------------------------
  239.   # * Update Cursor Rectangle
  240.   #--------------------------------------------------------------------------
  241.   def update_cursor_rect
  242.     return self.cursor_rect.empty if @index < 0
  243.     row      = @index / @column_max
  244.     page_max = (self.page_row_max - 1)
  245.     self.top_row = row            if row < self.top_row
  246.     self.top_row = row - page_max if row > self.top_row + page_max
  247.     cursor_width = self.width / @column_max - 32
  248.     x = @index % @column_max * (cursor_width + 32)
  249.     y = @index / @column_max * 32 #- self.oy
  250.     self.cursor_rect.set(x, y, cursor_width, 32)
  251.   end
  252. end
  253. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement