Advertisement
neutale

Alternate Choice Window

Apr 7th, 2018
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.00 KB | None | 0 0
  1. #encoding:utf-8
  2.  
  3. =begin
  4. *******************************************************************************************
  5.    * Alternate Choice Window *
  6.                        for RGSS3
  7.         Ver 1.1.0   2016.02.17
  8.    Author:魂(Lctseng),Bahamut Forum ID:play123
  9.    Please keep this label reprinted
  10.    Home link:http://home.gamer.com.tw/homeindex.php?owner=play123
  11.    Description:
  12.                        Beautifies choice windows and move them to top left screen
  13.    
  14.    Installation: Paste this script above Main
  15.    
  16.    Update Log:
  17.     Ver 1.0.0 :
  18.     Date:2014.09.21
  19.     Ver 1.1.0 :
  20.     Date:2016.02.17
  21.     Summary:
  22.                 ■、Corrected a bug when cancelling
  23.                 ■、Hide arrow of the choice windows
  24.     The following categories can be modiefied or redefined:
  25.                            ■ Window_ChoiceList
  26.                         This script provided a set of modules
  27.                            ■ Lctseng::LargeChoiceWindow
  28. *******************************************************************************************
  29. =end
  30.  
  31.  
  32. #encoding:utf-8
  33. #==============================================================================
  34. # ■ Lctseng::LargeChoiceWindow
  35. #------------------------------------------------------------------------------
  36. #  Choice Window Setting Module
  37. #==============================================================================
  38.  
  39. module Lctseng
  40. module LargeChoiceWindow
  41.   #--------------------------------------------------------------------------
  42.   # ● Whether control character is enabled(ex:\c[n]、\I[n]etc.)
  43.   # Text alignment will not be adjusted (forced left)
  44.   #--------------------------------------------------------------------------
  45.   TEXT_EX_ENABLE = false
  46.   #--------------------------------------------------------------------------
  47.   # ● Text Alignment, used when control characters are not used
  48.   # 0 = left,1 = center,2 = right
  49.   #--------------------------------------------------------------------------
  50.   TEXT_ALIGNMENT = 1
  51.   #--------------------------------------------------------------------------
  52.   # ● Window position/ Size setting
  53.   #--------------------------------------------------------------------------
  54.   # X Coordinate
  55.   WINDOW_X = 0
  56.   # Y Coordinate
  57.   WINDOW_Y = 0
  58.   # Width
  59.   WINDOW_WIDTH = Graphics.width / 2
  60.   # Height
  61.   WINDOW_HEIGHT = Graphics.height - 200
  62.  
  63. end
  64. end
  65.  
  66.  
  67. #*******************************************************************************************
  68. #
  69. #   DO NOT MODIFY UNLESS YOU KNOW WHAT TO DO !
  70. #
  71. #*******************************************************************************************
  72.  
  73. #--------------------------------------------------------------------------
  74. # ★ Script Information Record
  75. #--------------------------------------------------------------------------
  76. if !$lctseng_scripts
  77.   $lctseng_scripts = {}
  78. end
  79.  
  80. # Avoid overwriting old date
  81. @_old_val_script_sym = @_script_sym if !@_script_sym.nil?
  82. @_script_sym = :large_choice_window
  83.  
  84. $lctseng_scripts[@_script_sym] = "1.1.0"
  85.  
  86. puts "Load script:Lctseng - Alternate Choice Window:#{$lctseng_scripts[@_script_sym]}"
  87.  
  88. # Restore old data
  89. @_script_sym = @_old_val_script_sym if !@_old_val_script_sym.nil?
  90.  
  91.  
  92. #encoding:utf-8
  93. #==============================================================================
  94. # ■ Window_ChoiceList
  95. #------------------------------------------------------------------------------
  96. #  Window used for "Display Options" function in event
  97. #==============================================================================
  98.  
  99. class Window_ChoiceList < Window_Command
  100.   #--------------------------------------------------------------------------
  101.   # ●Initialization object  - 【Change definition】
  102.   #--------------------------------------------------------------------------
  103.   def initialize(message_window)
  104.     @message_window = message_window
  105.     super(0, 0)
  106.     self.openness = 255
  107.     self.opacity = 0
  108.     self.contents_opacity = 0
  109.     self.x = Lctseng::LargeChoiceWindow::WINDOW_X
  110.     self.y = Lctseng::LargeChoiceWindow::WINDOW_Y
  111.     deactivate
  112.     @select = Sprite.new(self.viewport)
  113.     @select.bitmap = Bitmap.new(contents_width - 8,line_height)
  114.     @select.bitmap.fill_rect(@select.bitmap.rect,Color.new(0,0,0,200))
  115.     @select.visible = false
  116.     @select.opacity = 0
  117.     @select_flash_count = 90
  118.     self.arrows_visible = false
  119.   end
  120.   #--------------------------------------------------------------------------
  121.   # ● Update open process
  122.   #--------------------------------------------------------------------------
  123.   def update_open
  124.     self.contents_opacity += 16
  125.     @opening = false if open?
  126.   end
  127.   #--------------------------------------------------------------------------
  128.   # ● Update close process
  129.   #--------------------------------------------------------------------------
  130.   def update_close
  131.     self.contents_opacity -= 16
  132.     @closing = false if close?
  133.   end
  134.   #--------------------------------------------------------------------------
  135.   # ● Open?
  136.   #--------------------------------------------------------------------------
  137.   def open?
  138.     self.contents_opacity >= 255
  139.   end
  140.   #--------------------------------------------------------------------------
  141.   # ● Close?
  142.   #--------------------------------------------------------------------------
  143.   def close?
  144.     self.contents_opacity <= 0
  145.   end
  146.   #--------------------------------------------------------------------------
  147.   # ● Update window location - 【Modify definition】
  148.   #--------------------------------------------------------------------------
  149.   def update_placement
  150.   end
  151.   #--------------------------------------------------------------------------
  152.   # ● Width of window
  153.   #--------------------------------------------------------------------------
  154.   def window_width
  155.     Lctseng::LargeChoiceWindow::WINDOW_WIDTH
  156.   end
  157.   #--------------------------------------------------------------------------
  158.   # ● Height of window
  159.   #--------------------------------------------------------------------------
  160.   def window_height
  161.     Lctseng::LargeChoiceWindow::WINDOW_HEIGHT
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # ● Calculate width of window
  165.   #--------------------------------------------------------------------------
  166.   def contents_width
  167.     window_width - standard_padding * 2
  168.   end
  169.   #--------------------------------------------------------------------------
  170.   # ● Calculate height of window
  171.   #--------------------------------------------------------------------------
  172.   def contents_height
  173.     window_height - standard_padding * 3
  174.   end
  175.   #--------------------------------------------------------------------------
  176.   # ● Item rectangle
  177.   #--------------------------------------------------------------------------
  178.   def item_rect(index)
  179.     rect = Rect.new
  180.     rect.width = item_width
  181.     rect.height = item_height
  182.     rect.x = index % col_max * (item_width + spacing)
  183.     ## Calculate interval height
  184.     # Assigned height measures
  185.     remain = contents_height - line_height * row_max
  186.     # assigned number & index
  187.     assign = ((remain / row_max)*index).round
  188.  
  189.     rect.y = (index / col_max * item_height) + assign
  190.     rect
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # ● Draw item
  194.   #--------------------------------------------------------------------------
  195.   def draw_item(index)
  196.     rect = item_rect_for_text(index)
  197.     contents.fill_rect(rect,back_color)
  198.     if Lctseng::LargeChoiceWindow::TEXT_EX_ENABLE
  199.       draw_text_ex(rect.x, rect.y, command_name(index))
  200.     else
  201.       draw_text(rect, command_name(index) , Lctseng::LargeChoiceWindow::TEXT_ALIGNMENT)
  202.     end
  203.   end
  204.   #--------------------------------------------------------------------------
  205.   # ● Background color
  206.   #--------------------------------------------------------------------------
  207.   def back_color
  208.     Color.new(0, 0, 0, back_opacity)
  209.   end
  210.   #--------------------------------------------------------------------------
  211.   # ● Background opacity
  212.   #--------------------------------------------------------------------------
  213.   def back_opacity
  214.     return 128
  215.   end
  216.    #--------------------------------------------------------------------------
  217.   # ● Dispose
  218.   #--------------------------------------------------------------------------
  219.   def dispose
  220.     super
  221.     @select.dispose
  222.   end
  223.    #--------------------------------------------------------------------------
  224.   # ● Update
  225.   #--------------------------------------------------------------------------
  226.   def update
  227.     super
  228.     @select.visible = self.visible
  229.     @select.opacity = [self.contents_opacity,self.openness].min
  230.     @select.x = self.x + self.cursor_rect.x + 16
  231.     @select.y = self.y + self.cursor_rect.y + 12
  232.     if @select_flash_count < 0
  233.       @select_flash_count = 30
  234.       @select.flash(Color.new(255,255,255,64),60)
  235.     else
  236.       @select_flash_count -= 1
  237.     end
  238.     @select.update
  239.   end
  240.  
  241.  
  242. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement