Advertisement
roninator2

Prico Turn Display mod

Dec 5th, 2024
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 14.06 KB | None | 0 0
  1. #==============================================================================
  2. # ★ RGSS3_TurnWindowDisplayforBattle Ver1.05
  3. #==============================================================================
  4. =begin
  5.  
  6.   Author:ぷり娘 (prico)
  7. web site:Sister's Eternal 4th(Ancient)
  8.      URL:http://pricono.whitesnow.jp/
  9. Permission to use: Not required, but please mention in the game, Readme, etc.
  10.  
  11. Displays the current amount of turns on the battle screen.
  12. The number of turns is displayed up to 3 digits (limit 999 turns)
  13.  
  14. By default, it'll appear in semi-transparent window.
  15. Position of Turn Window can be change through script setting.
  16.  
  17. Also, it will hidden during battle events.
  18.  
  19.  
  20.  
  21. 2012.06.21 Ver1.00 Public release
  22. 2012.06.23 Ver1.01 Fixed a bug where an enemy action does not match # turn display.
  23.  
  24. Mods by Roninator2
  25. 2018.09.07 Ver1.02 Made the turn window disappear when selecting skills and items
  26. 2018.09.11 Ver1.03 Made minor changes to fix a bug in the cancel selection.
  27. 2018.09.30 Ver1.04 Made minor changes to fix a bug in the ok selection.
  28. 2018.09.30 Ver1.05 Added Icon.
  29. 2019.01.06 Ver1.06 Made option to use window background
  30. =end
  31.  
  32.  
  33. #==============================================================================
  34. # Setting
  35. #==============================================================================
  36. module Prico
  37.  
  38.   #X coordinate of Turn Window
  39.   WindowX = 440
  40.  
  41.   #Y coordinate of Turn Window
  42.   WindowY = 0
  43.  
  44.   #Turn Window width
  45.   WindowW = 104
  46.  
  47.   #Turn Window Opacity
  48.   View = 255
  49.  
  50.   #Turn Window Icon
  51.   Use_Icon = true
  52.  
  53.   #Turn Window Icon Index
  54.   Icon = 280
  55.  
  56.   #Turn window background. true is windowed, false is shadow (requires Window_blank.png file)
  57.   WindowBack = true
  58. end
  59.  
  60. #==============================================================================
  61. # ■ Scene_Battle
  62. #------------------------------------------------------------------------------
  63. #  Class that performs battle screen processing
  64. #==============================================================================
  65. class Scene_Battle < Scene_Base
  66.   #--------------------------------------------------------------------------
  67.   # ● Create all windows(alias)
  68.   #--------------------------------------------------------------------------
  69.   alias create_all_windows_org create_all_windows
  70.   def create_all_windows
  71.     create_all_windows_org
  72.     create_turn_window
  73.   end
  74.   #--------------------------------------------------------------------------
  75.   # ● Creating turn number window(new)
  76.   #--------------------------------------------------------------------------
  77.   def create_turn_window
  78.     @turn_window = Window_Turn.new(Prico::WindowX,Prico::WindowY)
  79.     @turn_window.visible = false
  80.     $turn_back = false
  81.   end
  82.   #--------------------------------------------------------------------------
  83.   # * Battle Start
  84.   #--------------------------------------------------------------------------
  85.   alias battle_start_org battle_start
  86.   def battle_start
  87.     battle_start_org
  88.     @turn_window.opacity = Prico::View
  89.     @turn_window.visible = true
  90.     $turn_back = true
  91.     @turn_window.refresh
  92.   end
  93.   #--------------------------------------------------------------------------
  94.   # * Process event
  95.   #--------------------------------------------------------------------------
  96.   alias process_event_org process_event
  97.   def process_event
  98.     process_event_org
  99.     @turn_window.visible = false
  100.     $turn_back = false
  101.     @turn_window.refresh
  102.   end
  103.   #--------------------------------------------------------------------------
  104.   # * [Skill] Command
  105.   #--------------------------------------------------------------------------
  106.   alias command_skill_oth command_skill
  107.   def command_skill
  108.     command_skill_oth
  109.     @turn_window.visible = false
  110.     $turn_back = false
  111.     @turn_window.refresh
  112.   end
  113.   #--------------------------------------------------------------------------
  114.   # * Skill [OK]
  115.   #--------------------------------------------------------------------------
  116.   alias on_skill_ok_oth on_skill_ok
  117.   def on_skill_ok
  118.     on_skill_ok_oth
  119.     @turn_window.visible = false
  120.     $turn_back = false
  121.     @turn_window.refresh
  122.   end
  123.   #--------------------------------------------------------------------------
  124.   # * Skill [Cancel]
  125.   #--------------------------------------------------------------------------
  126.   alias on_skill_cancel_oth on_skill_cancel
  127.   def on_skill_cancel
  128.     on_skill_cancel_oth
  129.     @turn_window.visible = true
  130.     $turn_back = true
  131.     @turn_window.refresh
  132.   end
  133.   #--------------------------------------------------------------------------
  134.   # * [Item] Command
  135.   #--------------------------------------------------------------------------
  136.   alias command_item_oth command_item
  137.   def command_item
  138.     command_item_oth
  139.     @turn_window.visible = false
  140.     $turn_back = false
  141.     @turn_window.refresh
  142.   end
  143.   #--------------------------------------------------------------------------
  144.   # * Item [OK]
  145.   #--------------------------------------------------------------------------
  146.   alias on_item_ok_oth on_item_ok
  147.   def on_item_ok
  148.     on_item_ok_oth
  149.     @turn_window.visible = false
  150.     $turn_back = false
  151.     @turn_window.refresh
  152.   end
  153.   #--------------------------------------------------------------------------
  154.   # * Item [Cancel]
  155.   #--------------------------------------------------------------------------
  156.   alias on_item_cancel_oth on_item_cancel
  157.   def on_item_cancel
  158.     on_item_cancel_oth
  159.     @turn_window.visible = true
  160.     $turn_back = true
  161.     @turn_window.refresh
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Start Actor Command Selection
  165.   #--------------------------------------------------------------------------
  166.   def start_actor_command_selection_oth start_actor_command_selection
  167.     start_actor_command_selection_oth
  168.     @turn_window.visible = true
  169.     $turn_back = true
  170.     @turn_window.refresh
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # * Start Actor Selection
  174.   #--------------------------------------------------------------------------
  175.   alias select_actor_selection_oth select_actor_selection
  176.   def select_actor_selection
  177.     select_actor_selection_oth
  178.     @turn_window.visible = false
  179.     $turn_back = false
  180.     @turn_window.refresh
  181.   end
  182.   #--------------------------------------------------------------------------
  183.   # * Actor [OK]
  184.   #--------------------------------------------------------------------------
  185.   alias on_actor_ok_oth on_actor_ok
  186.   def on_actor_ok
  187.     on_actor_ok_oth
  188.     @turn_window.visible = true
  189.     $turn_back = true
  190.     @turn_window.refresh
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Actor [Cancel]
  194.   #--------------------------------------------------------------------------
  195.   alias on_actor_cancel_oth on_actor_cancel
  196.   def on_actor_cancel
  197.     on_actor_cancel_oth
  198.     @turn_window.visible = false
  199.     $turn_back = false
  200.     @turn_window.refresh
  201.   end
  202.   #--------------------------------------------------------------------------
  203.   # * Start Enemy Selection
  204.   #--------------------------------------------------------------------------
  205.   alias select_enemy_selection_oth select_enemy_selection
  206.   def select_enemy_selection
  207.     select_enemy_selection_oth
  208.     @turn_window.visible = false
  209.     $turn_back = false
  210.     @turn_window.refresh
  211.   end
  212.   #--------------------------------------------------------------------------
  213.   # * Enemy [Cancel]
  214.   #--------------------------------------------------------------------------
  215.   alias on_enemy_cancel_oth on_enemy_cancel
  216.   def on_enemy_cancel
  217.     on_enemy_cancel_oth
  218.     @turn_window.visible = false
  219.     $turn_back = false
  220.     if @actor_command_window.active
  221.       $turn_back = true
  222.       @turn_window.visible = true
  223.     end
  224.     @turn_window.refresh
  225.   end
  226.   #--------------------------------------------------------------------------
  227.   # * Enemy [OK]
  228.   #--------------------------------------------------------------------------
  229.   alias on_enemy_ok_oth on_enemy_ok
  230.   def on_enemy_ok
  231.     on_enemy_ok_oth
  232.     @turn_window.visible = false
  233.     $turn_back = false
  234.     if @actor_command_window.active
  235.       $turn_back = true
  236.       @turn_window.visible = true
  237.     end
  238.     @turn_window.refresh
  239.   end
  240.   #--------------------------------------------------------------------------
  241.   # * [Attack] Command
  242.   #--------------------------------------------------------------------------
  243.   alias command_attack_oth command_attack
  244.   def command_attack
  245.     command_attack_oth
  246.     @turn_window.visible = false
  247.     $turn_back = false
  248.     @turn_window.refresh
  249.   end
  250.   #--------------------------------------------------------------------------
  251.   # ● Turn start(alias)
  252.   #--------------------------------------------------------------------------
  253.   alias turn_start_org turn_start
  254.   def turn_start
  255.     turn_start_org
  256.     @turn_window.visible = false
  257.     $turn_back = false
  258.     @turn_window.refresh
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # ● Turn end(alias)
  262.   #--------------------------------------------------------------------------
  263.   alias turn_end_org turn_end
  264.   def turn_end
  265.     turn_end_org
  266.     @turn_window.visible = true
  267.     $turn_back = true
  268.     @turn_window.refresh
  269.   end
  270.  
  271. end
  272. #==============================================================================
  273. # ■ Window_Turn
  274. #   Window that displays the current number of turns
  275. #==============================================================================
  276.  
  277. class Window_Turn < Window_Base
  278.  
  279.   if Prico::WindowBack == true
  280.       #--------------------------------------------------------------------------
  281.       # ● Object initialization
  282.       #--------------------------------------------------------------------------
  283.       def initialize(x, y)
  284.         super(Prico::WindowX,Prico::WindowY,(Prico::Use_Icon ? Prico::WindowW - 25 : Prico::WindowW),line_height * 2)
  285.         self.contents = Bitmap.new(self.width - 24, self.height - 28)
  286.         self.opacity = Prico::View
  287.         refresh
  288.       end
  289.       #--------------------------------------------------------------------------
  290.       # ● Refresh
  291.       #--------------------------------------------------------------------------
  292.       def refresh
  293.         self.contents.clear
  294.         self.contents.font.size = 23
  295.         @text = sprintf("%2d%s", $game_troop.turn_count+1,Prico::Use_Icon ? draw_icon(Prico::Icon,0 + 25,0) : " TURN")
  296.         draw_text_ex(0, 0, @text)
  297.         reset_font_settings
  298.       end
  299.   else
  300.       #--------------------------------------------------------------------------
  301.       # ● Object initialization
  302.       #--------------------------------------------------------------------------
  303.       def initialize(x, y)
  304.         super(Prico::WindowX,Prico::WindowY,(Prico::Use_Icon ? Prico::WindowW - 25 : Prico::WindowW),line_height * 2)
  305.         self.contents = Bitmap.new(self.width - 24, self.height - 28)
  306.         self.windowskin = Cache.system("Window_blank")
  307.         self.opacity = Prico::View
  308.         create_back_bitmap_turn
  309.         create_back_sprite_turn
  310.         refresh
  311.       end
  312.       #--------------------------------------------------------------------------
  313.       # * Dispose Background Bitmap
  314.       #--------------------------------------------------------------------------
  315.       def dispose
  316.         super
  317.         dispose_back_bitmap_turn
  318.         dispose_back_sprite_turn
  319.       end
  320.       #--------------------------------------------------------------------------
  321.       # * Create Background Bitmap
  322.       #--------------------------------------------------------------------------
  323.       def create_back_bitmap_turn
  324.         @back_bitmap_turn = Bitmap.new(width, height)
  325.         rect1 = Rect.new(0, 0, width, 12)
  326.         rect2 = Rect.new(0, 12, width, height - 24)
  327.         rect3 = Rect.new(0, height - 12, width, 12)
  328.         @back_bitmap_turn.gradient_fill_rect(rect1, back_color2, back_color1, true)
  329.         @back_bitmap_turn.fill_rect(rect2, back_color1)
  330.         @back_bitmap_turn.gradient_fill_rect(rect3, back_color1, back_color2, true)
  331.       end
  332.       #--------------------------------------------------------------------------
  333.       # * Get Background Color 1
  334.       #--------------------------------------------------------------------------
  335.       def back_color1
  336.         Color.new(0, 0, 0, Prico::View)
  337.       end
  338.       #--------------------------------------------------------------------------
  339.       # * Get Background Color 2
  340.       #--------------------------------------------------------------------------
  341.       def back_color2
  342.         Color.new(0, 0, 0, Prico::View)
  343.       end
  344.       #--------------------------------------------------------------------------
  345.       # * Create Background Sprite
  346.       #--------------------------------------------------------------------------
  347.       def create_back_sprite_turn
  348.         @back_sprite_turn = Sprite.new
  349.         @back_sprite_turn.bitmap = @back_bitmap_turn
  350.         @back_sprite_turn.z = z - 1
  351.         @back_sprite_turn.y = Prico::WindowY
  352.         @back_sprite_turn.x = Prico::WindowX
  353.       end
  354.       #--------------------------------------------------------------------------
  355.       # * Update Background Sprite
  356.       #--------------------------------------------------------------------------
  357.       def update_back_sprite_turn
  358.         @back_sprite_turn.visible = $turn_back
  359.         @back_sprite_turn.update
  360.       end
  361.       #--------------------------------------------------------------------------
  362.       # ● Refresh
  363.       #--------------------------------------------------------------------------
  364.       def refresh
  365.         update_back_sprite_turn
  366.         self.contents.clear
  367.         self.contents.font.size = 23
  368.         @text = sprintf("%2d%s", $game_troop.turn_count+1,Prico::Use_Icon ? draw_icon(Prico::Icon,0 + 25,0) : " TURN")
  369.         draw_text_ex(0, 0, @text)
  370.         reset_font_settings
  371.       end
  372.       #--------------------------------------------------------------------------
  373.       # * Free Background Bitmap
  374.       #--------------------------------------------------------------------------
  375.       def dispose_back_bitmap_turn
  376.         @back_bitmap_turn.dispose
  377.       end
  378.       #--------------------------------------------------------------------------
  379.       # * Free Background Sprite
  380.       #--------------------------------------------------------------------------
  381.       def dispose_back_sprite_turn
  382.         @back_sprite_turn.dispose
  383.       end
  384.   end
  385. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement