Advertisement
strelokhalfer

Kage

Apr 5th, 2015
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 50.62 KB | None | 0 0
  1.     #==============================================================================
  2.     # ** Spriteset_Map
  3.     #------------------------------------------------------------------------------
  4.     #  This class brings together map screen sprites, tilemaps, etc. It's used
  5.     # within the Scene_Map class.
  6.     #==============================================================================
  7.      
  8.     class Spriteset_Map
  9.         #--------------------------------------------------------------------------
  10.         # * Retreive a correct rect
  11.         #--------------------------------------------------------------------------
  12.             def correct_rect
  13.           real_w = $game_map.width * 32
  14.           real_h = $game_map.height * 32
  15.           loop_h = $game_map.loop_vertical?
  16.           loop_w = $game_map.loop_horizontal?
  17.           coeffx = coeffy = 0
  18.           coeffx = (Graphics.width - real_w)/2 if Graphics.width > real_w  && !loop_w
  19.           coeffy = (Graphics.height - real_h)/2 if Graphics.height > real_h  && !loop_h
  20.           coeffw = (loop_w) ? Graphics.width : [Graphics.width, real_w].min
  21.           coeffh = (loop_h) ? Graphics.height : [Graphics.height, real_h].min
  22.           Rect.new(coeffx, coeffy, coeffw, coeffh)
  23.         end
  24.         #--------------------------------------------------------------------------
  25.         # * Create Viewport
  26.         #--------------------------------------------------------------------------
  27.         def create_viewports
  28.           r = correct_rect
  29.           @viewport1 = Viewport.new(r)
  30.           @viewport2 = Viewport.new(r)
  31.           @viewport3 = Viewport.new(r)
  32.           @viewport2.z = 50
  33.           @viewport3.z = 100
  34.         end
  35.         #--------------------------------------------------------------------------
  36.         # * Refresh viewports
  37.         #--------------------------------------------------------------------------
  38.         def incubator_refresh_viewports
  39.           r = correct_rect
  40.           [@viewport1, @viewport2, @viewport3].each do |vp|
  41.             vp.rect.set(r)
  42.           end
  43.             end
  44.     end
  45.      
  46.     #==============================================================================
  47.     # ** Game_Map
  48.     #------------------------------------------------------------------------------
  49.     #  This class handles maps. It includes scrolling and passage determination
  50.     # functions. The instance of this class is referenced by $game_map.
  51.     #==============================================================================
  52.      
  53.     class Game_Map
  54.         #--------------------------------------------------------------------------
  55.         # * Scroll Down
  56.         #--------------------------------------------------------------------------
  57.         def scroll_down(distance)
  58.           if loop_vertical?
  59.             @display_y += distance
  60.             @display_y %= @map.height * 256
  61.             @parallax_y += distance if @parallax_loop_y
  62.           else
  63.             last_y = @display_y
  64.             tile_y = (Graphics.height > (height * 32)) ? height : screen_tile_y
  65.             @display_y = [@display_y + distance, (height - tile_y)].min
  66.             @parallax_y += @display_y - last_y
  67.           end
  68.         end
  69.         #--------------------------------------------------------------------------
  70.         # * Scroll Right
  71.         #--------------------------------------------------------------------------
  72.         def scroll_right(distance)
  73.           if loop_horizontal?
  74.             @display_x += distance
  75.             @display_x %= @map.width * 256
  76.             @parallax_x += distance if @parallax_loop_x
  77.           else
  78.             last_x = @display_x
  79.             tile_x = (Graphics.width > (width * 32)) ? width : screen_tile_x
  80.             @display_x = [@display_x + distance, (width - tile_x)].min
  81.             @parallax_x += @display_x - last_x
  82.           end
  83.         end
  84.       end
  85.      
  86.       #==============================================================================
  87.       # ** Resolution
  88.       #------------------------------------------------------------------------------
  89.       #  Hack in the matrice :'( :'(
  90.       #==============================================================================
  91.       module Resolution
  92.         extend self
  93.         #------------------------------------------------------------------------
  94.         # * ... no idea
  95.         #------------------------------------------------------------------------
  96.         def fresh_pointer(reg, v)
  97.           ptr = DL::CPtr.new(268435456 + reg)
  98.           ptr[0, v.size] = v
  99.         end
  100.         #------------------------------------------------------------------------
  101.         # * ... pack dimension
  102.         #------------------------------------------------------------------------
  103.         def pack_dimension(width, height)
  104.           [
  105.             [width, height],[width+32, height+32],
  106.             [-(~(width/32)), -(~(height/32))]
  107.           ].collect{|elt| elt.pack('ll').scan(/..../)}
  108.         end
  109.         #------------------------------------------------------------------------
  110.         # * ... Oh yeah, i'm currently listening a nice song !
  111.         #------------------------------------------------------------------------
  112.         def map_reg(width, height)
  113.           empty_buff = [].pack('x4')
  114.           (buff_aa, buff_ab), (buff_ba, buff_bb),
  115.           (buff_ca, buff_cb) = *pack_dimension(width, height)
  116.           {
  117.             6495 => "\x90"*5, 6564 => buff_ab, 6569 => buff_aa,
  118.             6742 => buff_ab, 6747 => buff_aa, 8438 => buff_aa,
  119.             8447 => buff_aa, 8454 => buff_ab, 8463 => buff_ab,
  120.             116195 => empty_buff, 116200 => empty_buff,
  121.             128119 => buff_ab, 128124 => buff_aa, 135679 => buff_bb,
  122.             135684 => buff_ba, 138621 => buff_cb[0], 138753 => buff_ca[0],
  123.             1105576=> buff_ab, 1105581=> buff_aa, 1105631=> buff_ab,
  124.             1105648=> buff_aa, 1105684=> buff_ab, 1105688=> buff_aa,
  125.             1105736=> buff_ab, 1105740=> buff_aa, 1107623=> buff_aa,
  126.             1107651=> buff_ab, 1109673=> buff_aa, 1109689=> buff_ab
  127.           }.each{|k, v| fresh_pointer(k, v)}
  128.         end
  129.         #------------------------------------------------------------------------
  130.         # * ... Change resolution
  131.         #------------------------------------------------------------------------
  132.         def change(w, h)
  133.           map_reg(w, h)
  134.           Graphics.resize_screen(w, h)
  135.         end
  136.       end
  137.      
  138.     #==============================================================================
  139.     # Display v1.0 (21/3/15)
  140.     # by Pheonix KageDesu
  141.     #------------------------------------------------------------------------------
  142.     # Описание: Возможность устанавливать новое разрешение окна игры
  143.     # Как использовать: PKD_Display.set_1024
  144.     # Доступные разрешения:
  145.     #       PKD_Display.set_1024 - 1024 x 768 (Оптимальное)
  146.     #       PKD_Display.set_800 - 800 x 576 (Минимальное)
  147.     #       PKD_Display.set_720p - 1280 x 704 (Максимальное, можно и больше)
  148.     #
  149.     # Внимение, меньше set_800 ставить не рекомендуется. Работа не гарантируется.
  150.     #==============================================================================
  151.      
  152.     # Данный скрипт можно использовать в любых проектах (в том числе и коммерческих),
  153.     # если указано моё авторство (Pheonix KageDesu) на данный скрипт.  
  154.      
  155.     #==============================================================================
  156.     #1 часть скрипта.
  157.      
  158.     module PKD_Display
  159.            
  160.             #НАСТРОЙКИ (Менять не рекомендую)
  161.             #------------------------------------------------------------------------------
  162.            
  163.             #Показывать ли переход при начале битвы (по умолчанию false)
  164.             BATTLE_PICTURE = false #Если System/BattleStart.png у Вас нужного формата, то поставьте true
  165.            
  166.             #Размеры для окон
  167.             W = 544 #По умолчанию 544
  168.             H = 480 #По умолчанию 480
  169.            
  170.             #КОНЕЦ
  171.             #------------------------------------------------------------------------------
  172.            
  173.             WX = Graphics.width
  174.             HX = Graphics.height
  175.            
  176.       def self.cX
  177.         Graphics.width / 2
  178.       end
  179.      
  180.       def self.cY
  181.         Graphics.height / 2
  182.       end
  183.      
  184.            
  185.             def self.toCntrX(x,gl)
  186.                     return (cX - (gl / 2) + x)
  187.             end
  188.            
  189.             def self.toCntrY(y,gl)
  190.                     return (cY - (gl / 2) + y)
  191.             end
  192.            
  193.             def self.window_to_center(window, glW, glH)
  194.                     window.x = toCntrX(window.x,glW)
  195.                     window.y = toCntrY(window.y,glH)
  196.             end
  197.            
  198.             #W,H must be MOD 32 = 0 (должны быть кратны 32)
  199.            
  200.             def self.set_800
  201.                     Resolution.change(800, 576)
  202.             end
  203.            
  204.             def self.set_1024
  205.                     Resolution.change(1024, 768)
  206.             end
  207.            
  208.             def self.set_720p
  209.                     Resolution.change(1280, 704)
  210.             end
  211.              
  212.     end
  213.      
  214.     #==============================================================================
  215.     # Display
  216.     # by Pheonix KageDesu
  217.     #------------------------------------------------------------------------------
  218.     #2 часть скрипта.
  219.      
  220.     module Graphics
  221.             class <<self
  222.                    
  223.                     #ALIAS
  224.                     alias pkd_Graphics_transition transition
  225.                     def transition(duration=10, filename=nil, vague=40)
  226.                             pkd_Graphics_transition(1,"",1)
  227.         end
  228.                    
  229.                     #OVER
  230.                     def fadeout(duration)
  231.                             #EMPTY
  232.         end
  233.                    
  234.                     #OVER
  235.                     def fadein(duration)
  236.                             #EMPTY
  237.         end
  238.      
  239.             end
  240.     end
  241.      
  242.     #==============================================================================
  243.     # ** Spriteset_Battle
  244.     #------------------------------------------------------------------------------
  245.     #  This class brings together battle screen sprites. It's used within the
  246.     # Scene_Battle class.
  247.     #==============================================================================
  248.      
  249.     class Spriteset_Battle
  250.            
  251.             #--------------------------------------------------------------------------
  252.       # * Create Viewport
  253.       #--------------------------------------------------------------------------
  254.             #ALIAS
  255.             alias pkd_Spriteset_Battle_create_viewports create_viewports
  256.       def create_viewports
  257.         pkd_Spriteset_Battle_create_viewports()
  258.                    
  259.                     @viewport1.rect.width = PKD_Display::W
  260.                     @viewport1.rect.height = PKD_Display::H
  261.                    
  262.                     @viewport1.rect.x = PKD_Display.toCntrX(0,PKD_Display::W)
  263.                     @viewport1.rect.y = PKD_Display.toCntrY(0,PKD_Display::H)
  264.                    
  265.                     @viewport2.rect.width = PKD_Display::W
  266.                     @viewport2.rect.height = PKD_Display::H
  267.                    
  268.                     @viewport2.rect.x = PKD_Display.toCntrX(0,PKD_Display::W)
  269.                     @viewport2.rect.y = PKD_Display.toCntrY(0,PKD_Display::H)
  270.                    
  271.                     @viewport3.rect.width = PKD_Display::W
  272.                     @viewport3.rect.height = PKD_Display::H
  273.                    
  274.                     @viewport3.rect.x = PKD_Display.toCntrX(0,PKD_Display::W)
  275.                     @viewport3.rect.y = PKD_Display.toCntrY(0,PKD_Display::H)
  276.       end
  277.                    
  278.             #--------------------------------------------------------------------------
  279.       # * Move Sprite to Screen Center
  280.       #--------------------------------------------------------------------------
  281.             #ALIAS
  282.             alias pkd_Spriteset_Battle_center_sprite center_sprite
  283.       def center_sprite(sprite)
  284.         pkd_Spriteset_Battle_center_sprite(sprite)
  285.         sprite.x = PKD_Display::W / 2
  286.         sprite.y = PKD_Display::H / 2
  287.       end
  288.            
  289.     end
  290.      
  291.     #==============================================================================
  292.     # Display
  293.     # by Pheonix KageDesu
  294.     #------------------------------------------------------------------------------
  295.     #3 часть скрипта.
  296.      
  297.     #==============================================================================
  298.     # ** Scene_Base
  299.     #------------------------------------------------------------------------------
  300.     #  This is a super class of all scenes within the game.
  301.     #==============================================================================
  302.      
  303.     class Scene_Base
  304.            
  305.       #--------------------------------------------------------------------------
  306.       # * Fade Out All Sounds and Graphics
  307.       #--------------------------------------------------------------------------
  308.             #OVER
  309.       def fadeout_all(time = 1000)
  310.         RPG::BGM.fade(time)
  311.         RPG::BGS.fade(time)
  312.         RPG::ME.fade(time)
  313.                     fadeout(time * Graphics.frame_rate / 1000)
  314.         RPG::BGM.stop
  315.         RPG::BGS.stop
  316.         RPG::ME.stop
  317.       end
  318.      
  319.             #--------------------------------------------------------------------------
  320.       # * General-Purpose Fade Processing
  321.       #--------------------------------------------------------------------------
  322.             #NEW
  323.       def fade_loop(duration)
  324.         duration.times do |i|
  325.           yield 255 * (i + 1) / duration
  326.           update_for_fade
  327.         end
  328.       end
  329.            
  330.             #--------------------------------------------------------------------------
  331.       # * Update Frame (for Fade In)
  332.       #--------------------------------------------------------------------------
  333.             #NEW
  334.       def update_for_fade
  335.         update_basic
  336.       end
  337.            
  338.             #--------------------------------------------------------------------------
  339.       # * Fadeout Screen
  340.       #--------------------------------------------------------------------------
  341.             #NEW
  342.       def fadeout(duration)
  343.                     fade_loop(duration) {|v| @viewport.color.set(0, 0, 0, v) }
  344.       end  
  345.     end
  346.      
  347.     #==============================================================================
  348.     # ** Scene_ItemBase
  349.     #------------------------------------------------------------------------------
  350.     #  This class performs common processing for the item screen and skill screen.
  351.     #==============================================================================
  352.      
  353.     class Scene_ItemBase < Scene_MenuBase
  354.       #--------------------------------------------------------------------------
  355.       # * Show Subwindow
  356.       #--------------------------------------------------------------------------
  357.             #ALIAS
  358.             alias pkd_Scene_Item_Base_show_sub_window show_sub_window
  359.       def show_sub_window(window)
  360.                     window.y = @help_window.y
  361.                     pkd_Scene_Item_Base_show_sub_window(window)
  362.       end
  363.     end
  364.      
  365.     #==============================================================================
  366.     # ** Scene_Menu
  367.     #------------------------------------------------------------------------------
  368.     #  This class performs the menu screen processing.
  369.     #==============================================================================
  370.      
  371.     class Scene_Menu < Scene_MenuBase
  372.            
  373.             #--------------------------------------------------------------------------
  374.       # * Start Processing
  375.       #--------------------------------------------------------------------------
  376.             #ALIAS
  377.             alias pkd_Scene_Menu_start start
  378.       def start
  379.         pkd_Scene_Menu_start()
  380.                     windows_to_center
  381.       end
  382.            
  383.             #--------------------------------------------------------------------------
  384.       # * Create Gold Window
  385.       #--------------------------------------------------------------------------
  386.             #ALIAS
  387.             alias pkd_Scene_Menu_create_gold_window create_gold_window
  388.       def create_gold_window
  389.         pkd_Scene_Menu_create_gold_window()
  390.         @gold_window.y = PKD_Display::H - @gold_window.height
  391.       end
  392.                    
  393.             private
  394.             #NEW
  395.             def windows_to_center
  396.                    
  397.                     glW = @command_window.width + @status_window.width
  398.                     glH = @status_window.height
  399.                    
  400.                     PKD_Display.window_to_center(@command_window,glW,glH)
  401.                     PKD_Display.window_to_center(@gold_window,glW,glH)
  402.                     PKD_Display.window_to_center(@status_window,glW,glH)
  403.             end
  404.            
  405.     end
  406.      
  407.      
  408.     #==============================================================================
  409.     # ** Scene_Map
  410.     #------------------------------------------------------------------------------
  411.     #  This class performs the map screen processing.
  412.     #==============================================================================
  413.      
  414.     class Scene_Map
  415.            
  416.             #--------------------------------------------------------------------------
  417.       # * Fadein Screen
  418.       #--------------------------------------------------------------------------
  419.             #NEW
  420.       def fadein(duration)
  421.                     fade_loop(duration) {|v| @viewport.color.set(0, 0, 0, 255 - v) }
  422.       end
  423.       #--------------------------------------------------------------------------
  424.       # * Fadeout Screen
  425.       #--------------------------------------------------------------------------
  426.             #NEW
  427.       def fadeout(duration)
  428.                     fade_loop(duration) {|v| @viewport.color.set(0, 0, 0, v) }
  429.       end
  430.            
  431.             #--------------------------------------------------------------------------
  432.       # * Post Processing for Transferring Player
  433.       #--------------------------------------------------------------------------
  434.             #ALIAS
  435.             alias PKD_SceneMap_post_transfer post_transfer
  436.       def post_transfer    
  437.                     @spriteset.incubator_refresh_viewports
  438.                     @spriteset.update
  439.                     PKD_SceneMap_post_transfer()
  440.             end
  441.            
  442.             #--------------------------------------------------------------------------
  443.       # * Execute Pre-Battle Transition
  444.       #--------------------------------------------------------------------------
  445.             #OVER
  446.       def perform_battle_transition
  447.                     if PKD_Display::BATTLE_PICTURE
  448.                             Graphics.transition(60, "Graphics/System/BattleStart", 100)
  449.                     end
  450.         Graphics.freeze
  451.       end
  452.            
  453.     end
  454.      
  455.     #==============================================================================
  456.     # ** Scene_Status
  457.     #------------------------------------------------------------------------------
  458.     #  This class performs the status screen processing.
  459.     #==============================================================================
  460.      
  461.     class Scene_Status < Scene_MenuBase
  462.             #--------------------------------------------------------------------------
  463.       # * Start Processing
  464.       #--------------------------------------------------------------------------
  465.             #ALIAS
  466.             alias pkd_Scene_Status_start start
  467.       def start
  468.         pkd_Scene_Status_start()
  469.                     @status_window.window_to_center
  470.                     @status_window.window_to_size
  471.       end
  472.     end
  473.      
  474.     #==============================================================================
  475.     # ** Scene_Item
  476.     #------------------------------------------------------------------------------
  477.     #  This class performs the item screen processing.
  478.     #==============================================================================
  479.      
  480.     class Scene_Item < Scene_ItemBase
  481.            
  482.             #--------------------------------------------------------------------------
  483.       # * Start Processing
  484.       #--------------------------------------------------------------------------
  485.             #ALIAS
  486.             alias pkd_Scene_Item_start start
  487.       def start
  488.         pkd_Scene_Item_start()
  489.                     windows_to_center
  490.       end
  491.            
  492.             #--------------------------------------------------------------------------
  493.       # * Create Item Window
  494.       #--------------------------------------------------------------------------
  495.             #OVER
  496.       def create_item_window
  497.         wy = @category_window.y + @category_window.height
  498.         wh = PKD_Display::H - wy
  499.         @item_window = Window_ItemList.new(0, wy, PKD_Display::W, wh)
  500.         @item_window.viewport = @viewport
  501.         @item_window.help_window = @help_window
  502.         @item_window.set_handler(:ok,     method(:on_item_ok))
  503.         @item_window.set_handler(:cancel, method(:on_item_cancel))
  504.         @category_window.item_window = @item_window
  505.                     @item_window.window_to_center
  506.       end
  507.            
  508.             private
  509.             #NEW
  510.             def windows_to_center  
  511.                     @category_window.window_to_center
  512.                     @help_window.window_to_center
  513.                     @help_window.width = PKD_Display::W
  514.             end
  515.            
  516.     end
  517.      
  518.     #==============================================================================
  519.     # ** Scene_Skill
  520.     #------------------------------------------------------------------------------
  521.     #  This class performs skill screen processing. Skills are handled as items for
  522.     # the sake of process sharing.
  523.     #==============================================================================
  524.      
  525.     class Scene_Skill < Scene_ItemBase
  526.       #--------------------------------------------------------------------------
  527.       # * Start Processing
  528.       #--------------------------------------------------------------------------
  529.             #ALIAS
  530.             alias pkd_Scene_Skill_start start
  531.       def start
  532.         pkd_Scene_Skill_start()
  533.                     windows_to_center
  534.       end
  535.            
  536.             #--------------------------------------------------------------------------
  537.       # * Create Item Window
  538.       #--------------------------------------------------------------------------
  539.             #OVER
  540.       def create_item_window
  541.         wx = 0
  542.         wy = @status_window.y + @status_window.height
  543.         ww = PKD_Display::W
  544.         wh = PKD_Display::H - wy
  545.         @item_window = Window_SkillList.new(wx, wy, ww, wh)
  546.         @item_window.actor = @actor
  547.         @item_window.viewport = @viewport
  548.         @item_window.help_window = @help_window
  549.         @item_window.set_handler(:ok,     method(:on_item_ok))
  550.         @item_window.set_handler(:cancel, method(:on_item_cancel))
  551.         @command_window.skill_window = @item_window
  552.                     @item_window.window_to_center
  553.       end
  554.            
  555.             private
  556.             #NEW
  557.             def windows_to_center
  558.                    
  559.                     @help_window.window_to_center
  560.                     @help_window.width = PKD_Display::W
  561.                    
  562.                     @command_window.window_to_center
  563.                    
  564.                     @status_window.width = @help_window.width - @command_window.width
  565.                     @status_window.window_to_center
  566.             end
  567.            
  568.     end
  569.      
  570.     #==============================================================================
  571.     # ** Scene_Equip
  572.     #------------------------------------------------------------------------------
  573.     #  This class performs the equipment screen processing.
  574.     #==============================================================================
  575.      
  576.     class Scene_Equip < Scene_MenuBase
  577.       #--------------------------------------------------------------------------
  578.       # * Start Processing
  579.       #--------------------------------------------------------------------------
  580.             #ALIAS
  581.             alias pkd_Scene_Equip_start start
  582.       def start
  583.         pkd_Scene_Equip_start()
  584.                     windows_to_center
  585.       end
  586.            
  587.             #NEW
  588.             def windows_to_center
  589.                     @help_window.window_to_center
  590.                     @help_window.width = PKD_Display::W
  591.             end
  592.            
  593.             #--------------------------------------------------------------------------
  594.       # * Create Status Window
  595.       #--------------------------------------------------------------------------
  596.             #ALIAS
  597.             alias pkd_Scene_Equip_create_status_window create_status_window
  598.       def create_status_window
  599.         pkd_Scene_Equip_create_status_window()
  600.                     @status_window.window_to_center
  601.       end
  602.            
  603.             #--------------------------------------------------------------------------
  604.       # * Create Command Window
  605.       #--------------------------------------------------------------------------
  606.             #OVER
  607.       def create_command_window
  608.         wx = @status_window.width
  609.         wy = @help_window.height
  610.         ww = PKD_Display::W - @status_window.width
  611.         @command_window = Window_EquipCommand.new(wx, wy, ww)
  612.         @command_window.viewport = @viewport
  613.         @command_window.help_window = @help_window
  614.         @command_window.set_handler(:equip,    method(:command_equip))
  615.         @command_window.set_handler(:optimize, method(:command_optimize))
  616.         @command_window.set_handler(:clear,    method(:command_clear))
  617.         @command_window.set_handler(:cancel,   method(:return_scene))
  618.         @command_window.set_handler(:pagedown, method(:next_actor))
  619.         @command_window.set_handler(:pageup,   method(:prev_actor))
  620.                     @command_window.window_to_center
  621.       end
  622.            
  623.             #--------------------------------------------------------------------------
  624.       # * Create Slot Window
  625.       #--------------------------------------------------------------------------
  626.             #OVER
  627.       def create_slot_window
  628.         wx = @status_window.width
  629.         wy = @command_window.y + @command_window.height
  630.         ww = PKD_Display::W - @status_window.width
  631.         @slot_window = Window_EquipSlot.new(wx, wy, ww)
  632.         @slot_window.viewport = @viewport
  633.         @slot_window.help_window = @help_window
  634.         @slot_window.status_window = @status_window
  635.         @slot_window.actor = @actor
  636.         @slot_window.set_handler(:ok,       method(:on_slot_ok))
  637.         @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  638.                     @slot_window.x = PKD_Display.toCntrX(@slot_window.x/2,@slot_window.width)
  639.       end
  640.            
  641.             #--------------------------------------------------------------------------
  642.       # * Create Item Window
  643.       #--------------------------------------------------------------------------
  644.             #OVER
  645.       def create_item_window
  646.         wx = 0
  647.         wy = @slot_window.y + @slot_window.height
  648.         ww = PKD_Display::W
  649.         wh = PKD_Display::H - @slot_window.y
  650.         @item_window = Window_EquipItem.new(wx, wy, ww, wh)
  651.         @item_window.viewport = @viewport
  652.         @item_window.help_window = @help_window
  653.         @item_window.status_window = @status_window
  654.         @item_window.actor = @actor
  655.         @item_window.set_handler(:ok,     method(:on_item_ok))
  656.         @item_window.set_handler(:cancel, method(:on_item_cancel))
  657.         @slot_window.item_window = @item_window
  658.                     @item_window.x = PKD_Display.toCntrX(@item_window.x,@item_window.width)
  659.       end
  660.            
  661.     end
  662.      
  663.      
  664.     #==============================================================================
  665.     # ** Scene_Battle
  666.     #------------------------------------------------------------------------------
  667.     #  This class performs battle screen processing.
  668.     #==============================================================================
  669.      
  670.     class Scene_Battle
  671.             #--------------------------------------------------------------------------
  672.       # * Start Processing
  673.       #--------------------------------------------------------------------------
  674.             #ALIAS
  675.             alias pkd_Scene_Battle_start start
  676.       def start
  677.                     create_background
  678.                     pkd_Scene_Battle_start()
  679.       end
  680.            
  681.             #NEW
  682.             def create_background
  683.         @background_sprite = Sprite.new
  684.         @background_sprite.bitmap = SceneManager.background_bitmap
  685.         @background_sprite.color.set(16, 16, 16, 180)
  686.       end
  687.            
  688.             #--------------------------------------------------------------------------
  689.       # * Create Information Display Viewport
  690.       #--------------------------------------------------------------------------
  691.             #ALIAS
  692.             alias pkd_Scene_Battle_create_info_viewport create_info_viewport
  693.       def create_info_viewport
  694.         pkd_Scene_Battle_create_info_viewport()
  695.                     @info_viewport.rect.width = PKD_Display::W
  696.                     @info_viewport.rect.x = PKD_Display.toCntrX(0,PKD_Display::W)
  697.       end
  698.            
  699.             #--------------------------------------------------------------------------
  700.       # * Create Help Window
  701.       #--------------------------------------------------------------------------
  702.             #ALIAS
  703.             alias pkd_Scene_Battle_create_help_window create_help_window
  704.       def create_help_window
  705.                     pkd_Scene_Battle_create_help_window()
  706.                    
  707.                     @help_window.width = PKD_Display::W
  708.                     @help_window.x = PKD_Display.toCntrX(0,PKD_Display::W)
  709.                     @help_window.y = @help_window.height
  710.       end
  711.            
  712.             #--------------------------------------------------------------------------
  713.       # * Create Actor Commands Window
  714.       #--------------------------------------------------------------------------
  715.             #ALIAS
  716.             alias pkd_Scene_Battle_create_actor_command_window create_actor_command_window
  717.       def create_actor_command_window
  718.         pkd_Scene_Battle_create_actor_command_window()
  719.                     @actor_command_window.x = PKD_Display::W
  720.       end
  721.                    
  722.     end
  723.      
  724.     #==============================================================================
  725.     # ** Scene_File
  726.     #------------------------------------------------------------------------------
  727.     #  This class performs common processing for the save screen and load screen.
  728.     #==============================================================================
  729.      
  730.     class Scene_File < Scene_MenuBase
  731.            
  732.             #--------------------------------------------------------------------------
  733.       # * Start Processing
  734.       #--------------------------------------------------------------------------
  735.             #ALIAS
  736.             alias pkd_Scene_File_start start
  737.       def start
  738.         pkd_Scene_File_start()
  739.                     @help_window.window_to_center
  740.                     @help_window.width = PKD_Display::W
  741.       end
  742.            
  743.             #--------------------------------------------------------------------------
  744.       # * Create Save File Viewport
  745.       #--------------------------------------------------------------------------
  746.             #ALIAS
  747.             alias pkd_Scene_File_create_savefile_viewport create_savefile_viewport
  748.       def create_savefile_viewport
  749.         pkd_Scene_File_create_savefile_viewport()
  750.                     @savefile_viewport.rect.width = PKD_Display::W
  751.         @savefile_viewport.rect.height = PKD_Display::H - @help_window.height
  752.                     @savefile_viewport.rect.y = PKD_Display.toCntrY(@help_window.y+@help_window.height,PKD_Display::H)
  753.                     @savefile_viewport.rect.x = PKD_Display.toCntrX(0,PKD_Display::W)
  754.       end
  755.            
  756.     end
  757.      
  758.     #==============================================================================
  759.     # ** Scene_Shop
  760.     #------------------------------------------------------------------------------
  761.     #  This class performs shop screen processing.
  762.     #==============================================================================
  763.      
  764.     class Scene_Shop < Scene_MenuBase
  765.            
  766.             #--------------------------------------------------------------------------
  767.       # * Start Processing
  768.       #--------------------------------------------------------------------------
  769.             #ALIAS
  770.             alias pkd_Scene_Shop_start start
  771.       def start
  772.         pkd_Scene_Shop_start()
  773.                    
  774.                     @help_window.window_to_center
  775.                     @help_window.width = PKD_Display::W            
  776.       end
  777.            
  778.             #--------------------------------------------------------------------------
  779.       # * Create Gold Window
  780.       #--------------------------------------------------------------------------
  781.             #ALIAS
  782.             alias pkd_Scene_Shop_create_gold_window create_gold_window
  783.       def create_gold_window
  784.         pkd_Scene_Shop_create_gold_window()        
  785.                     @gold_window.x = PKD_Display.toCntrX(PKD_Display::W - @gold_window.width,PKD_Display::W)
  786.                     @gold_window.y = PKD_Display.toCntrY(@help_window.height,PKD_Display::H)
  787.                    
  788.       end
  789.       #--------------------------------------------------------------------------
  790.       # * Create Command Window
  791.       #--------------------------------------------------------------------------
  792.             #OVER
  793.       def create_command_window
  794.         @command_window = Window_ShopCommand.new(PKD_Display::W - @gold_window.width, @purchase_only)
  795.         @command_window.viewport = @viewport
  796.         @command_window.y = @help_window.height
  797.         @command_window.set_handler(:buy,    method(:command_buy))
  798.         @command_window.set_handler(:sell,   method(:command_sell))
  799.         @command_window.set_handler(:cancel, method(:return_scene))
  800.                     @command_window.y = PKD_Display.toCntrY(@help_window.height,PKD_Display::H)
  801.                     @command_window.width = PKD_Display::W - @gold_window.width
  802.                     @command_window.x = PKD_Display.toCntrX(0,PKD_Display::W)
  803.       end
  804.      
  805.       #--------------------------------------------------------------------------
  806.       # * Create Dummy Window
  807.       #--------------------------------------------------------------------------
  808.             #OVER
  809.       def create_dummy_window
  810.         wy = @command_window.y + @command_window.height
  811.         wh = PKD_Display::H - @command_window.height - @help_window.height
  812.         @dummy_window = Window_Base.new(PKD_Display.toCntrX(0,PKD_Display::W), wy, PKD_Display::W, wh)
  813.         @dummy_window.viewport = @viewport
  814.       end
  815.            
  816.       #--------------------------------------------------------------------------
  817.       # * Create Quantity Input Window
  818.       #--------------------------------------------------------------------------
  819.             #ALIAS
  820.             alias pkd_Scene_Shop_create_number_window create_number_window
  821.       def create_number_window
  822.         pkd_Scene_Shop_create_number_window()
  823.                     @number_window.x = PKD_Display.toCntrX(0,PKD_Display::W)
  824.       end
  825.            
  826.       #--------------------------------------------------------------------------
  827.       # * Create Status Window
  828.       #--------------------------------------------------------------------------
  829.             #ALIAS
  830.             alias pkd_Scene_Shop_create_status_window create_status_window
  831.       def create_status_window
  832.         pkd_Scene_Shop_create_status_window()
  833.                     @status_window.width = PKD_Display::W - @number_window.width
  834.                     @status_window.x = PKD_Display.toCntrX(@number_window.width,PKD_Display::W)
  835.       end
  836.            
  837.       #--------------------------------------------------------------------------
  838.       # * Create Purchase Window
  839.       #--------------------------------------------------------------------------
  840.             #ALIAS
  841.             alias pkd_Scene_Shop_create_buy_window create_buy_window
  842.       def create_buy_window
  843.         pkd_Scene_Shop_create_buy_window()
  844.                     @buy_window.x = PKD_Display.toCntrX(0,PKD_Display::W)
  845.       end
  846.            
  847.       #--------------------------------------------------------------------------
  848.       # * Create Category Window
  849.       #--------------------------------------------------------------------------
  850.             #ALIAS
  851.             alias pkd_Scene_Shop_create_category_window create_category_window
  852.       def create_category_window
  853.         pkd_Scene_Shop_create_category_window()
  854.                     @category_window.x = PKD_Display.toCntrX(0,PKD_Display::W)
  855.       end
  856.            
  857.       #--------------------------------------------------------------------------
  858.       # * Create Sell Window
  859.       #--------------------------------------------------------------------------
  860.             #OVER
  861.       def create_sell_window
  862.         wy = @category_window.y + @category_window.height
  863.                     wh = PKD_Display::H - @category_window.height - @help_window.height - @command_window.height
  864.         @sell_window = Window_ShopSell.new(PKD_Display.toCntrX(0,PKD_Display::W), wy, PKD_Display::W, wh)
  865.         @sell_window.viewport = @viewport
  866.         @sell_window.help_window = @help_window
  867.         @sell_window.hide
  868.         @sell_window.set_handler(:ok,     method(:on_sell_ok))
  869.         @sell_window.set_handler(:cancel, method(:on_sell_cancel))
  870.         @category_window.item_window = @sell_window
  871.       end
  872.            
  873.     end
  874.      
  875.     #==============================================================================
  876.     # Display
  877.     # by Pheonix KageDesu
  878.     #------------------------------------------------------------------------------
  879.     #4 часть скрипта.
  880.      
  881.     #==============================================================================
  882.     # ** Window_Base
  883.     #------------------------------------------------------------------------------
  884.     #  This is a super class of all windows within the game.
  885.     #==============================================================================
  886.      
  887.     class Window_Base
  888.            
  889.             #NEW
  890.             def window_to_center
  891.                     self.x = PKD_Display.toCntrX(x,PKD_Display::W)
  892.                     self.y = PKD_Display.toCntrY(y,PKD_Display::H)
  893.             end
  894.            
  895.             #NEW
  896.             def window_to_size
  897.                     self.width = PKD_Display::W
  898.                     self.height = PKD_Display::H
  899.             end
  900.            
  901.             #NEW
  902.             def window_to_relative(glW, glH)
  903.                     self.x = PKD_Display.toCntrX(x,glW)
  904.                     self.y = PKD_Display.toCntrY(y,glH)
  905.             end
  906.                    
  907.     end
  908.      
  909.     #==============================================================================
  910.     # ** Window_ChoiceList
  911.     #------------------------------------------------------------------------------
  912.     #  This window is used for the event command [Show Choices].
  913.     #==============================================================================
  914.      
  915.     class Window_ChoiceList < Window_Command
  916.       #--------------------------------------------------------------------------
  917.       # * Update Window Position
  918.       #--------------------------------------------------------------------------
  919.             #ALIAS
  920.             alias pkd_Window_ChoiceList_update_placement update_placement
  921.       def update_placement
  922.                     pkd_Window_ChoiceList_update_placement()
  923.                     self.width = [width, PKD_Display::W].min
  924.                     self.x = (Graphics.width/2) - (width / 2)
  925.       end
  926.     end
  927.      
  928.     #==============================================================================
  929.     # ** Window_MenuStatus
  930.     #------------------------------------------------------------------------------
  931.     #  This window displays party member status on the menu screen.
  932.     #==============================================================================
  933.      
  934.     class Window_MenuStatus < Window_Selectable
  935.            
  936.             #--------------------------------------------------------------------------
  937.       # * Get Window Width
  938.       #--------------------------------------------------------------------------
  939.             #OVER
  940.       def window_width
  941.         384
  942.       end
  943.            
  944.       #--------------------------------------------------------------------------
  945.       # * Get Window Height
  946.       #--------------------------------------------------------------------------
  947.       #OVER
  948.             def window_height
  949.         480
  950.       end
  951.            
  952.     end
  953.      
  954.     #==============================================================================
  955.     # ** Window_Message
  956.     #------------------------------------------------------------------------------
  957.     #  This message window is used to display text.
  958.     #==============================================================================
  959.      
  960.     class Window_Message < Window_Base
  961.      
  962.       #--------------------------------------------------------------------------
  963.       # * Object Initialization
  964.       #--------------------------------------------------------------------------
  965.             #ALIAS
  966.             alias pkd_Window_Message_initialize initialize
  967.       def initialize
  968.         pkd_Window_Message_initialize()
  969.                     self.x = PKD_Display.toCntrX(x,window_width)
  970.       end
  971.            
  972.       #--------------------------------------------------------------------------
  973.       # * Get Window Width
  974.       #--------------------------------------------------------------------------
  975.             #OVER
  976.       def window_width
  977.         PKD_Display::W + 20
  978.       end
  979.     end
  980.      
  981.     #==============================================================================
  982.     # ** Window_ItemCategory
  983.     #------------------------------------------------------------------------------
  984.     #  This window is for selecting a category of normal items and equipment
  985.     # on the item screen or shop screen.
  986.     #==============================================================================
  987.      
  988.     class Window_ItemCategory < Window_HorzCommand
  989.       #--------------------------------------------------------------------------
  990.       # * Get Window Width
  991.       #--------------------------------------------------------------------------
  992.             #OVER
  993.       def window_width
  994.         PKD_Display::W
  995.       end
  996.     end
  997.      
  998.     #==============================================================================
  999.     # ** Window_ScrollText
  1000.     #------------------------------------------------------------------------------
  1001.     #  This window is for displaying scrolling text. No frame is displayed, but it
  1002.     # is handled as a window for convenience.
  1003.     #==============================================================================
  1004.      
  1005.     class Window_ScrollText < Window_Base
  1006.       #--------------------------------------------------------------------------
  1007.       # * Object Initialization
  1008.       #--------------------------------------------------------------------------
  1009.             #ALIAS
  1010.             alias pkd_Window_ScrollText_initialize initialize
  1011.       def initialize
  1012.         pkd_Window_ScrollText_initialize()
  1013.                     self.width = PKD_Display::W
  1014.                     self.height = PKD_Display::H
  1015.                     self.x = PKD_Display.toCntrX(0,PKD_Display::W)
  1016.                     self.y = PKD_Display.toCntrY(0,PKD_Display::H)
  1017.       end
  1018.     end
  1019.      
  1020.     #==============================================================================
  1021.     # ** Window_SaveFile
  1022.     #------------------------------------------------------------------------------
  1023.     #  This window displays save files on the save and load screens.
  1024.     #==============================================================================
  1025.      
  1026.     class Window_SaveFile < Window_Base
  1027.       #--------------------------------------------------------------------------
  1028.       # * Object Initialization
  1029.       #     index : index of save files
  1030.       #--------------------------------------------------------------------------
  1031.             #OVER
  1032.       def initialize(height, index)
  1033.                     super(0, index * height, PKD_Display::W, height)
  1034.         @file_index = index
  1035.         refresh
  1036.         @selected = false
  1037.       end
  1038.     end
  1039.      
  1040.      
  1041.     #==============================================================================
  1042.     # ** Window_BattleStatus
  1043.     #------------------------------------------------------------------------------
  1044.     #  This window is for displaying the status of party members on the battle
  1045.     # screen.
  1046.     #==============================================================================
  1047.      
  1048.     class Window_BattleStatus < Window_Selectable
  1049.       #--------------------------------------------------------------------------
  1050.       # * Get Window Width
  1051.       #--------------------------------------------------------------------------
  1052.             #OVER
  1053.       def window_width
  1054.         PKD_Display::W - 128
  1055.       end
  1056.     end
  1057.      
  1058.     #==============================================================================
  1059.     # ** Window_BattleEnemy
  1060.     #------------------------------------------------------------------------------
  1061.     #  Window for selecting the enemy who is the action target on the battle
  1062.     # screen.
  1063.     #==============================================================================
  1064.      
  1065.     class Window_BattleEnemy < Window_Selectable
  1066.       #--------------------------------------------------------------------------
  1067.       # * Get Window Width
  1068.       #--------------------------------------------------------------------------
  1069.             #OVER
  1070.       def window_width
  1071.         PKD_Display::W - 128
  1072.       end
  1073.            
  1074.             #--------------------------------------------------------------------------
  1075.       # * Show Window
  1076.       #--------------------------------------------------------------------------
  1077.             #OVER
  1078.       def show
  1079.         if @info_viewport
  1080.           width_remain = PKD_Display::W - width
  1081.           self.x = @info_viewport.rect.x + width_remain
  1082.           @info_viewport.rect.width = width_remain
  1083.           select(0)
  1084.         end
  1085.         super
  1086.       end
  1087.       #--------------------------------------------------------------------------
  1088.       # * Hide Window
  1089.       #--------------------------------------------------------------------------
  1090.             #OVER
  1091.       def hide
  1092.         @info_viewport.rect.width = PKD_Display::W if @info_viewport
  1093.         super
  1094.       end
  1095.     end
  1096.      
  1097.     #==============================================================================
  1098.     # ** Window_BattleActor
  1099.     #------------------------------------------------------------------------------
  1100.     #  This window is for selecting an actor's action target on the battle screen.
  1101.     #==============================================================================
  1102.      
  1103.     class Window_BattleActor < Window_BattleStatus
  1104.       #--------------------------------------------------------------------------
  1105.       # * Show Window
  1106.       #--------------------------------------------------------------------------
  1107.             #OVER
  1108.       def show
  1109.         if @info_viewport
  1110.           width_remain = PKD_Display::W - width
  1111.           self.x = @info_viewport.rect.x + width_remain
  1112.           @info_viewport.rect.width = width_remain
  1113.           select(0)
  1114.         end
  1115.         super
  1116.       end
  1117.       #--------------------------------------------------------------------------
  1118.       # * Hide Window
  1119.       #--------------------------------------------------------------------------
  1120.             #OVER
  1121.       def hide
  1122.         @info_viewport.rect.width = PKD_Display::W if @info_viewport
  1123.         super
  1124.       end
  1125.     end
  1126.      
  1127.     #==============================================================================
  1128.     # ** Window_BattleSkill
  1129.     #------------------------------------------------------------------------------
  1130.     #  This window is for selecting skills to use in the battle window.
  1131.     #==============================================================================
  1132.      
  1133.     class Window_BattleSkill < Window_SkillList
  1134.       #--------------------------------------------------------------------------
  1135.       # * Object Initialization
  1136.       #     info_viewport : Viewport for displaying information
  1137.       #--------------------------------------------------------------------------
  1138.             #OVER
  1139.       def initialize(help_window, info_viewport)
  1140.         y = help_window.y + help_window.height
  1141.         super(PKD_Display.toCntrX(0,PKD_Display::W), y, PKD_Display::W, info_viewport.rect.y - y)
  1142.         self.visible = false
  1143.         @help_window = help_window
  1144.         @info_viewport = info_viewport
  1145.       end
  1146.     end
  1147.      
  1148.     #==============================================================================
  1149.     # ** Window_BattleItem
  1150.     #------------------------------------------------------------------------------
  1151.     #  This window is for selecting items to use in the battle window.
  1152.     #==============================================================================
  1153.      
  1154.     class Window_BattleItem < Window_ItemList
  1155.             #--------------------------------------------------------------------------
  1156.       # * Object Initialization
  1157.       #     info_viewport : Viewport for displaying information
  1158.       #--------------------------------------------------------------------------
  1159.             #OVER
  1160.       def initialize(help_window, info_viewport)
  1161.         y = help_window.y + help_window.height
  1162.         super(PKD_Display.toCntrX(0,PKD_Display::W), y, PKD_Display::W, info_viewport.rect.y - y)
  1163.         self.visible = false
  1164.         @help_window = help_window
  1165.         @info_viewport = info_viewport
  1166.       end
  1167.     end
  1168.      
  1169.     #==============================================================================
  1170.     #Установка разрешения окна игры
  1171.     PKD_Display.set_1024
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement