Advertisement
DaxSoft

dsi menu

Oct 26th, 2017
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 22.84 KB | None | 0 0
  1. =begin
  2. Default menu screen to DSi System
  3. &beta
  4. =end
  5. Ligni.register(:dsi_menu, "dax", 0.1, [[:dsi, "dax"]]) {
  6.     #==============================================================================
  7.     # ** Window_MenuStatus
  8.     #------------------------------------------------------------------------------
  9.     #  Esta janela exibe os parâmetros dos membros do grupo na tela de menu.
  10.     #==============================================================================
  11.     class Window_MenuStatus < Window_Selectable
  12.         def initialize(x, y, ih=nil)
  13.             super(x, y, window_width, window_height)
  14.             @pending_index = -1
  15.             @ih = ih
  16.             refresh
  17.         end
  18.  
  19.         def window_width
  20.             DS.screen.width
  21.         end
  22.         #--------------------------------------------------------------------------
  23.         # * Aquisição da altura da janela
  24.         #--------------------------------------------------------------------------
  25.         def window_height
  26.             DS.screen.height
  27.         end
  28.         #--------------------------------------------------------------------------
  29.         # * Aquisição de altura do item
  30.         #--------------------------------------------------------------------------
  31.         def item_height
  32.             return @ih.nil? ? (height - standard_padding * 2) / 4 : @ih
  33.         end
  34.         #--------------------------------------------------------------------------
  35.         # * Desenho de um item
  36.         #     index : índice do item
  37.         #--------------------------------------------------------------------------
  38.         def draw_item(index)
  39.             actor = $game_party.members[index]
  40.             enabled = $game_party.battle_members.include?(actor)
  41.             rect = item_rect(index)
  42.             draw_item_background(index)
  43.             draw_actor_face(actor, rect.x + 1, rect.y + 2, enabled, 96, 96, 0.45)
  44.             contents.font.size = 16
  45.             draw_text(rect.x + 50, rect.y - 2, 96, 24, actor.name.to_s)
  46.             draw_actor_level(actor, rect.x + 196, rect.y - 2)
  47.             draw_actor_hp(actor, rect.x + 50, rect.y+16, 48)
  48.             draw_actor_mp(actor, rect.x + 112, rect.y+16, 48)
  49.             draw_actor_icons(actor, rect.x + 160, rect.y+16)
  50.         end
  51.     end
  52.     # menu
  53.     class Window_MenuCommand < Window_Command
  54.         #--------------------------------------------------------------------------
  55.         # * Adição dos comandos principais
  56.         #--------------------------------------------------------------------------
  57.         def add_main_commands
  58.             add_command(Vocab::item,   :item,   main_commands_enabled)
  59.             add_command(Vocab::skill,  :skill,  main_commands_enabled)
  60.             add_command(Vocab::equip,  :equip,  main_commands_enabled)
  61.         end
  62.     end
  63.     # [Menu]
  64.     class Scene_Menu < Scene_MenuBase
  65.         # start
  66.         def start
  67.             Window_MenuCommand::init_command_position
  68.             $game_system.default_background = DS::SETUP[:MENU][:BACKGROUND]
  69.             super
  70.             create_command_window
  71.             create_status_window
  72.             create_gold_window
  73.         end
  74.         #--------------------------------------------------------------------------
  75.         # * Criação da janela de dinheiro
  76.         #--------------------------------------------------------------------------
  77.         def create_gold_window
  78.             @gold_window = Window_Gold.new
  79.             @gold_window.x = 0
  80.             @gold_window.y = 0
  81.         end
  82.         def create_command_window
  83.             @command_window = Window_MenuCommand.new
  84.             @command_window.set_handler(:item,      method(:command_item))
  85.             @command_window.set_handler(:skill,     method(:command_personal))
  86.             @command_window.set_handler(:equip,     method(:command_personal))
  87.             @command_window.set_handler(:formation, method(:command_formation))
  88.             @command_window.set_handler(:save,      method(:command_save))
  89.             @command_window.set_handler(:game_end,  method(:command_game_end))
  90.             @command_window.set_handler(:cancel,  method(:return_scene))
  91.             @command_window.height = 164
  92.             @command_window.position(1)
  93.             @command_window.y = DS.screen.height + ( (DS.screen.height - @command_window.height) / 2 )
  94.             @command_window.z = DS.screen.z + 2
  95.         end
  96.  
  97.         #--------------------------------------------------------------------------
  98.         # * Criação da janela de atributos
  99.         #--------------------------------------------------------------------------
  100.         def create_status_window
  101.             @status_window = Window_MenuStatus.new(0, 0)
  102.             @status_window.z = DS.screen.z + 1
  103.             @status_window.y = DS.screen.height
  104.             @status_window.visible = false
  105.         end
  106.  
  107.         def command_personal
  108.             Graphics.wait(5)
  109.             @status_window.select_last
  110.             @status_window.activate
  111.             @status_window.set_handler(:ok,     method(:on_personal_ok))
  112.             @status_window.set_handler(:cancel, method(:on_personal_cancel))
  113.         end
  114.  
  115.         def command_save
  116.             SceneManager.call(Scene_DSSave)
  117.         end
  118.  
  119.         # terminate
  120.         def terminate
  121.             super
  122.         end
  123.  
  124.         # update
  125.         def update
  126.             super
  127.             @status_window.visible = @status_window.active
  128.             @command_window.visible = !@status_window.visible
  129.         end
  130.     end
  131.  
  132.     # [End]
  133.     class Scene_End
  134.         #--------------------------------------------------------------------------
  135.         # * Criação da janela de comando
  136.         #--------------------------------------------------------------------------
  137.         def create_command_window
  138.             @command_window = Window_GameEnd.new
  139.             @command_window.set_handler(:to_title, method(:command_to_title))
  140.             @command_window.set_handler(:shutdown, method(:command_shutdown))
  141.             @command_window.set_handler(:cancel,   method(:return_scene))
  142.             @command_window.position(1)
  143.             @command_window.y = DS.screen.height + ( (DS.screen.height - @command_window.height) / 2 )
  144.             @command_window.z = DS.screen.z + 2
  145.         end
  146.     end
  147.     #==============================================================================
  148.     # ** Window_Gold
  149.     #------------------------------------------------------------------------------
  150.     #  Esta janela exibe a quantia de dinheiro.
  151.     #==============================================================================
  152.  
  153.     class Window_Gold < Window_Base
  154.         #--------------------------------------------------------------------------
  155.         # * Aquisição da largura da janela
  156.         #--------------------------------------------------------------------------
  157.         def window_width
  158.             return DS.screen.width
  159.         end
  160.         #--------------------------------------------------------------------------
  161.         # * Renovação
  162.         #--------------------------------------------------------------------------
  163.         def refresh
  164.             contents.clear
  165.             contents.draw_icon(361, 0, 0)
  166.             contents.draw_text(28, -12, 96, self.height, sprintf("%d %s", value, currency_unit))
  167.             contents.draw_text(-28, -12, self.width, self.height, $game_map.display_name.to_s, 2)
  168.         end
  169.     end
  170.     Ligni.remove(:Window_ItemCategory)
  171.     class Window_ItemCategory < Window_Command
  172.         #--------------------------------------------------------------------------
  173.         # * Variáveis públicas
  174.         #--------------------------------------------------------------------------
  175.         attr_reader   :item_window
  176.         #--------------------------------------------------------------------------
  177.         # * Inicialização do objeto
  178.         #--------------------------------------------------------------------------
  179.         def initialize
  180.           super(0, 0)
  181.           self.z = DS.screen.z + 100
  182.         end
  183.         #--------------------------------------------------------------------------
  184.         # * Aquisição da largura da janela
  185.         #--------------------------------------------------------------------------
  186.         def window_width
  187.           164
  188.         end
  189.         #--------------------------------------------------------------------------
  190.         # * Aquisição do número de colunas
  191.         #--------------------------------------------------------------------------
  192.         def col_max
  193.           return 1
  194.         end
  195.         #--------------------------------------------------------------------------
  196.         # * Atualização da tela
  197.         #--------------------------------------------------------------------------
  198.         def update
  199.           super
  200.           @item_window.category = current_symbol if @item_window
  201.         end
  202.         #--------------------------------------------------------------------------
  203.         # * Criação da lista de comandos
  204.         #--------------------------------------------------------------------------
  205.         def make_command_list
  206.           add_command(Vocab::item,     :item)
  207.           add_command(Vocab::weapon,   :weapon)
  208.           add_command(Vocab::armor,    :armor)
  209.           add_command(Vocab::key_item, :key_item)
  210.         end
  211.         #--------------------------------------------------------------------------
  212.         # * Definição da janela de itens
  213.         #     item_window : janela de itens
  214.         #--------------------------------------------------------------------------
  215.         def item_window=(item_window)
  216.           @item_window = item_window
  217.           update
  218.         end
  219.     end
  220.  
  221.     # item
  222.     class Scene_Item < Scene_ItemBase
  223.         alias :ds_start :start
  224.         def start
  225.             ds_start
  226.             @help_window.visible = @item_window.visible = !@actor_window.visible  
  227.         end
  228.         #--------------------------------------------------------------------------
  229.         # * Criação da janela de categorias
  230.         #--------------------------------------------------------------------------
  231.         def create_category_window
  232.             @category_window = Window_ItemCategory.new
  233.             @category_window.position(1)
  234.             @category_window.y = DS.screen.height + ( (DS.screen.height - @category_window.height) / 2 )
  235.             @category_window.set_handler(:ok,     method(:on_category_ok))
  236.             @category_window.set_handler(:cancel, method(:return_scene))
  237.             @help_window.z = DS.screen.z + 1
  238.             @category_window.z = DS.screen.z + 1
  239.             @help_window.y = DS.screen.height - @help_window.height
  240.         end
  241.         #--------------------------------------------------------------------------
  242.         # * Criação da janela de itens
  243.         #--------------------------------------------------------------------------
  244.         def create_item_window
  245.             @item_window = Window_ItemList.new(0, 0, Graphics.width, DS.screen.height-@help_window.height)
  246.             @item_window.z = DS.screen.z + 1
  247.             @item_window.help_window = @help_window
  248.             @item_window.set_handler(:ok,     method(:on_item_ok))
  249.             @item_window.set_handler(:cancel, method(:on_item_cancel))
  250.             @category_window.item_window = @item_window
  251.         end
  252.  
  253.         def update
  254.             super
  255.             @help_window.visible = @item_window.visible = !@actor_window.visible  
  256.         end
  257.     end
  258.    
  259.     class Window_SkillStatus < Window_Base
  260.         #--------------------------------------------------------------------------
  261.         # * Inicialização do objeto
  262.         #     x      : coordenada X
  263.         #     y      : coordenada Y
  264.         #--------------------------------------------------------------------------
  265.         def initialize(x, y)
  266.           super(x, y, window_width, fitting_height(2))
  267.           @actor = nil
  268.         end
  269.         #--------------------------------------------------------------------------
  270.         # * Aquisição da largura da janela
  271.         #--------------------------------------------------------------------------
  272.         def window_width
  273.           Graphics.width
  274.         end
  275.         #--------------------------------------------------------------------------
  276.         # * Renovação
  277.         #--------------------------------------------------------------------------
  278.         def refresh
  279.           contents.clear
  280.           return unless @actor
  281.           draw_actor_face(@actor, 1, 2, true, 96, 96, 0.45)
  282.           contents.font.size = 16
  283.           draw_text(50, 2, 96, 24, @actor.name.to_s)
  284.           draw_actor_level(@actor, 196, 2)
  285.           draw_actor_hp(@actor, 50, 16, 48)
  286.           draw_actor_mp(@actor, 112, 16, 48)
  287.           draw_actor_icons(@actor, 160, 16)
  288.         end
  289.     end
  290.     # [ Skill ]
  291.     class Scene_Skill < Scene_ItemBase
  292.         alias :ds_start :start
  293.         def start
  294.             ds_start
  295.             @help_window.visible = @item_window.active
  296.             @status_window.visible = !@help_window.visible
  297.             @command_window.visible = !@actor_window.visible  
  298.         end
  299.         #--------------------------------------------------------------------------
  300.         # * Criação da janela de comando
  301.         #--------------------------------------------------------------------------
  302.         def create_command_window
  303.             wy = @help_window.height
  304.             @command_window = Window_SkillCommand.new(0, wy)
  305.             @command_window.help_window = @help_window
  306.             @command_window.actor = @actor
  307.             @command_window.set_handler(:skill,    method(:command_skill))
  308.             @command_window.set_handler(:cancel,   method(:return_scene))
  309.             @command_window.set_handler(:pagedown, method(:next_actor))
  310.             @command_window.set_handler(:pageup,   method(:prev_actor))
  311.             @command_window.z = DS.screen.z + 1
  312.             @command_window.position 1
  313.             @command_window.y = DS.screen.height + ( (DS.screen.height - @command_window.height) / 2 )
  314.         end
  315.         #--------------------------------------------------------------------------
  316.         # * Criação da janela de atributos
  317.         #--------------------------------------------------------------------------
  318.         def create_status_window
  319.             y = DS.screen.height - @help_window.height
  320.             @status_window = Window_SkillStatus.new(0, y)
  321.             @status_window.actor = @actor
  322.             @status_window.visible = false
  323.         end
  324.         #--------------------------------------------------------------------------
  325.         # * Criação da janela de itens
  326.         #--------------------------------------------------------------------------
  327.         def create_item_window
  328.             @item_window = Window_SkillList.new(0, 0, Graphics.width, DS.screen.height-@help_window.height)
  329.             @item_window.actor = @actor
  330.             @item_window.help_window = @help_window
  331.             @item_window.set_handler(:ok,     method(:on_item_ok))
  332.             @item_window.set_handler(:cancel, method(:on_item_cancel))
  333.             @command_window.skill_window = @item_window
  334.             @item_window.z = DS.screen.z + 1
  335.             @help_window.y = DS.screen.height - @help_window.height
  336.             @actor_window.z = @item_window.z
  337.             @actor_window.y = DS.screen.height
  338.         end
  339.  
  340.         def update
  341.             super
  342.             @help_window.visible = @item_window.active
  343.             @status_window.visible = !@help_window.visible
  344.             @command_window.visible = !@actor_window.visible  
  345.         end
  346.     end
  347.     # [equip command]
  348.     Ligni.remove(:Window_EquipCommand)
  349.     class Window_EquipCommand < Window_Command
  350.         #--------------------------------------------------------------------------
  351.         # * Inicialização do objeto
  352.         #     x      : coordenada X
  353.         #     y      : coordenada Y
  354.         #     width  : largura
  355.         #--------------------------------------------------------------------------
  356.         def initialize(x, y, width)
  357.           @window_width = width
  358.           super(x, y)
  359.         end
  360.         #--------------------------------------------------------------------------
  361.         # * Aquisição da largura da janela
  362.         #--------------------------------------------------------------------------
  363.         def window_width
  364.           @window_width
  365.         end
  366.         #--------------------------------------------------------------------------
  367.         # * Criação da lista de comandos
  368.         #--------------------------------------------------------------------------
  369.         def make_command_list
  370.           add_command(Vocab::equip2,   :equip)
  371.           add_command(Vocab::optimize, :optimize)
  372.           add_command(Vocab::clear,    :clear)
  373.         end
  374.     end
  375.      
  376.     # [Equip]
  377.     class Scene_Equip < Scene_MenuBase
  378.         alias :ds_start :start
  379.         def start
  380.             ds_start
  381.             @slot_window.visible = !@item_window.active
  382.             @help_window.visible = @item_window.active
  383.             @status_window.visible = @help_window.visible
  384.             @item_window.visible = @item_window.active
  385.         end
  386.         #--------------------------------------------------------------------------
  387.         # * Criação da janela de atributos
  388.         #--------------------------------------------------------------------------
  389.         def create_status_window
  390.             @status_window = Window_EquipStatus.new(0, @help_window.height)
  391.             @status_window.z = DS.screen.z+1
  392.             @status_window.actor = @actor
  393.         end
  394.         #--------------------------------------------------------------------------
  395.         # * Criação da janela de comando
  396.         #--------------------------------------------------------------------------
  397.         def create_command_window
  398.             @command_window = Window_EquipCommand.new(0, 0, 164)
  399.             @command_window.position 1
  400.             @command_window.y = DS.screen.height + ( (DS.screen.height - @command_window.height) / 2 )
  401.             @command_window.z = DS.screen.z + 1
  402.             @command_window.help_window = @help_window
  403.             @command_window.set_handler(:equip,    method(:command_equip))
  404.             @command_window.set_handler(:optimize, method(:command_optimize))
  405.             @command_window.set_handler(:clear,    method(:command_clear))
  406.             @command_window.set_handler(:cancel,   method(:return_scene))
  407.             @command_window.set_handler(:pagedown, method(:next_actor))
  408.             @command_window.set_handler(:pageup,   method(:prev_actor))
  409.         end
  410.         #--------------------------------------------------------------------------
  411.         # * Criação da janela de slots
  412.         #--------------------------------------------------------------------------
  413.         def create_slot_window
  414.             @slot_window = Window_EquipSlot.new(0, 0, DS.screen.width)
  415.             @slot_window.z = DS.screen.z + 1
  416.             @slot_window.help_window = @help_window
  417.             @slot_window.status_window = @status_window
  418.             @slot_window.actor = @actor
  419.             @slot_window.set_handler(:ok,       method(:on_slot_ok))
  420.             @slot_window.set_handler(:cancel,   method(:on_slot_cancel))
  421.         end
  422.         #--------------------------------------------------------------------------
  423.         # * Criação da janela de item
  424.         #--------------------------------------------------------------------------
  425.         def create_item_window
  426.             @item_window = Window_EquipItem.new(0, DS.screen.height, DS.screen.width, DS.screen.height)
  427.             @item_window.z = DS.screen.z + 1
  428.             @item_window.help_window = @help_window
  429.             @item_window.status_window = @status_window
  430.             @item_window.actor = @actor
  431.             @item_window.set_handler(:ok,     method(:on_item_ok))
  432.             @item_window.set_handler(:cancel, method(:on_item_cancel))
  433.             @slot_window.item_window = @item_window
  434.         end
  435.  
  436.         def update
  437.             super
  438.             @slot_window.visible = !@item_window.active
  439.             @help_window.visible = @item_window.active
  440.             @status_window.visible = @help_window.visible
  441.             @item_window.visible = @item_window.active
  442.         end
  443.     end
  444.     # file
  445.     class Window_File < Window_Command
  446.         #--------------------------------------------------------------------------
  447.         # * Aquisição da altura da janela
  448.         #--------------------------------------------------------------------------
  449.         def window_height
  450.             fitting_height(4)
  451.         end
  452.         #--------------------------------------------------------------------------
  453.         # * Aquisição da largura da janela
  454.         #--------------------------------------------------------------------------
  455.         def window_width
  456.           return 164
  457.         end
  458.         #--------------------------------------------------------------------------
  459.         # * Criação da lista de comandos
  460.         #--------------------------------------------------------------------------
  461.         def make_command_list
  462.           (0..DataManager.savefile_max).each { |index|
  463.             next if index.nil?
  464.             text = FileTest.exist?(sprintf("Save%02d.rvdata2", index + 1)) ? "Saved [%02d]" : "Save [%02d]"
  465.             add_command(sprintf(text, index), :file)
  466.           }
  467.         end
  468.     end
  469.     # [save]
  470.     class Scene_DSSave < Scene_MenuBase
  471.         def start
  472.             super
  473.             @window_save = Window_File.new(0, 0)
  474.             @window_save.z = DS.screen.z + 1
  475.             @window_save.position(1)
  476.             @window_save.y = DS.screen.height + ( (DS.screen.height - @window_save.height) / 2 )
  477.             @window_save.set_handler(:file, method(:save))
  478.             @window_save.set_handler(:cancel, method(:return_scene))
  479.         end
  480.  
  481.         def save
  482.             if DataManager.save_game(@window_save.index)
  483.                 Sound.play_save
  484.                 return_scene
  485.             end
  486.         end
  487.  
  488.         def update
  489.             super
  490.         end
  491.     end
  492.  
  493.     # [load]
  494.     class Scene_DSLoad < Scene_MenuBase
  495.         def start
  496.             super
  497.             @window_save = Window_File.new(0, 0)
  498.             @window_save.z = DS.screen.z + 1
  499.             @window_save.position(1)
  500.             @window_save.y = DS.screen.height + ( (DS.screen.height - @window_save.height) / 2 )
  501.             @window_save.set_handler(:file, method(:load))
  502.             @window_save.set_handler(:cancel, method(:return_scene))
  503.         end
  504.  
  505.         def load  
  506.             if DataManager.load_game(@window_save.index)
  507.                 Sound.play_load
  508.                 fadeout_all
  509.                 $game_system.on_after_load
  510.                 SceneManager.goto(Scene_Map)
  511.             else
  512.                 Sound.play_buzzer
  513.             end
  514.         end
  515.     end
  516. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement