Issues With In-Scene Command Window Changing
So, I'm going back through some old code and I came across the attempt I was making at a quest log script and I recalled why I gave up on it. I cannot for the life of me get the quest description to display on the display window when I select it from the main quest log command window.Below is a spoiler tag of my code snippet. If anyone could give me any insight as to why it isn't working I would appreciate it. I am not looking for anyone to hand me the answer as, personally, I'd rather someone hint to me where I should start looking or where the problem may lie. Thank you in advance for any any and all help given.
Spoiler: Code Snippet Ruby:
module Quests List = {} List = { :name => "Quest 1", :symbol => :quest1, :description=> "Description text for quest 01." } List = { :name => "Quest 2", :symbol => :quest2, :description=> "Description text for quest 02." } end#============================================================================= # ▼ Scene_Menu #----------------------------------------------------------------------------- #This class performs the menu screen processing. #============================================================================= class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # ■ Create Command Window #-------------------------------------------------------------------------- alias :wea_create_command_window :create_command_window #-------------------------------------------------------------------------- def create_command_window() wea_create_command_window() # calls original method @command_window.set_handler(:journal_scene, method(:journal_command)) end #-------------------------------------------------------------------------- # ■ Call Journal Scene #-------------------------------------------------------------------------- def journal_command() SceneManager.call(Journal) end end # end Scene_Menu#============================================================================= # ▼ Window_MenuCommand #----------------------------------------------------------------------------- #This command window appears on the menu screen. #============================================================================= class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # ■ For Adding Original Commands #-------------------------------------------------------------------------- alias :wea_add_original_commands :add_original_commands #-------------------------------------------------------------------------- def add_original_commands() wea_add_original_commands() # calls original method add_command("Journal", :journal_scene, true) end end # end Window_MenuCommand#============================================================================= # ▼ Journal #----------------------------------------------------------------------------- #This window appears when the Journal option is selected from the main menu. #============================================================================= class Journal < Scene_Base #-------------------------------------------------------------------------- # ■ Start Processing #-------------------------------------------------------------------------- def start() super() @window_list = Window_QuestList.new(0,0) @window_summary = Window_QuestSummary.new() create_handlers() create_background() # Control Window Variables @window_list.activate() @window_summary.deactivate() @current_command_index = 0 @command_index = @window_list.return_index() end #-------------------------------------------------------------------------- # ■ Create Background #-------------------------------------------------------------------------- def create_background() @background_sprite = Sprite.new() @background_sprite.bitmap = SceneManager.background_bitmap @background_sprite.color.set(16, 16, 16, 128) end #-------------------------------------------------------------------------- # ■ Create Handlers #-------------------------------------------------------------------------- def create_handlers() Quests::List.each do |id, contents| @window_list.set_handler(contents[:symbol], method(:change_focus)) end end #-------------------------------------------------------------------------- # ■ Create Handlers #-------------------------------------------------------------------------- def change_focus() @window_list.deactivate() @window_summary.activate() end #-------------------------------------------------------------------------- # ■ Frame Update #-------------------------------------------------------------------------- def update() super() process_input() @command_index = @window_list.return_index() if @current_command_index != @command_index @current_command_index = @command_index @window_summary.set_index(@command_index) end end #-------------------------------------------------------------------------- # ■ Process Input Triggers #-------------------------------------------------------------------------- def process_input() process_on_cancel() if Input.trigger?(:B) end #-------------------------------------------------------------------------- # ■ Process On Cancel #-------------------------------------------------------------------------- def process_on_cancel() if @window_list.is_active? == true Sound.play_cancel() return_scene() else Sound.play_cancel() @window_list.activate() @window_summary.deactivate() end end #-------------------------------------------------------------------------- # ■ Termination Processing #-------------------------------------------------------------------------- def terminate() super() @window_list.dispose() @window_summary.dispose() @background_sprite.dispose() end end # end Journal#============================================================================= # ▼ Quest List Window #----------------------------------------------------------------------------- #This window displays a list of active quests. #============================================================================= class Window_QuestList < Window_Command #-------------------------------------------------------------------------- # ■ Object Initialization #-------------------------------------------------------------------------- def initialize(x, y) clear_command_list() make_command_list() super(x, y) refresh() select(0) @index = 0 @current_index = 0 end #-------------------------------------------------------------------------- # ■ Get Window Width #-------------------------------------------------------------------------- def window_width() return 160 end #-------------------------------------------------------------------------- # ■ Get Window Height #-------------------------------------------------------------------------- def window_height() return Graphics.height end #-------------------------------------------------------------------------- # ■ Create Quest List #-------------------------------------------------------------------------- def make_command_list() add_quests() end #-------------------------------------------------------------------------- # ■ Add Quests to List #-------------------------------------------------------------------------- def add_quests() Quests::List.each do |id, contents| add_command(contents[:name], contents[:sumbol], true) end end #-------------------------------------------------------------------------- # ■ Move Cursor Down #-------------------------------------------------------------------------- def cursor_down(wrap = true) if index < item_max - col_max || (wrap && col_max == 1) select((index + col_max) % item_max) @current_index = index end end #-------------------------------------------------------------------------- # ■ Move Cursor Up #-------------------------------------------------------------------------- def cursor_up(wrap = true) if index >= col_max || (wrap && col_max == 1) select((index - col_max + item_max) % item_max) @current_index = index end end #-------------------------------------------------------------------------- # ■ Return Highlighted Index #-------------------------------------------------------------------------- def return_index() return @index end #-------------------------------------------------------------------------- # ■ Activate Window #-------------------------------------------------------------------------- def activate() self.active = true self end #-------------------------------------------------------------------------- # ■ Deactivate Window #-------------------------------------------------------------------------- def deactivate() self.active = false self end #-------------------------------------------------------------------------- # ■ Deactivate Window #-------------------------------------------------------------------------- def is_active?() return self.active end end#============================================================================== # ▼ Window_ScrollText #------------------------------------------------------------------------------ #This window is for displaying scrolling text. No frame is displayed, but it # is handled as a window for convenience. #============================================================================== class Window_QuestSummary < Window_ScrollText #-------------------------------------------------------------------------- # ■ Object Initialization #-------------------------------------------------------------------------- def initialize() super() self.x = 160 self.width = (Graphics.width - 160) self.height = Graphics.height self.opacity = 255 self.arrows_visible = false @index = 0 @current_index = 0 @max_up_scroll = 0 @scroll_pos = 0 show() end #-------------------------------------------------------------------------- # ■ Frame Update #-------------------------------------------------------------------------- def update() super if self.active == true process_input() if @index != @current_index clear_summary_text() draw_summary_text(@index) end end self.oy = @scroll_pos end #-------------------------------------------------------------------------- # ■ Clear Quest Summary #-------------------------------------------------------------------------- def clear_summary_text() contents.clear() end #-------------------------------------------------------------------------- # ■ Draw Quest Summary #-------------------------------------------------------------------------- def draw_summary_text(index) text = Quests::List[:description] draw_text_ex(0, 0, text) end #-------------------------------------------------------------------------- # ■ Shift Index Text #-------------------------------------------------------------------------- def set_index(index) @index = index end #-------------------------------------------------------------------------- # ■ Process Key input #-------------------------------------------------------------------------- def process_input() @scroll_pos -= 1 if Input.press?(:UP) && @scroll_pos != @max_up_scroll @scroll_pos += 1 if Input.press?(:DOWN) end #-------------------------------------------------------------------------- # ■ Activate Window #-------------------------------------------------------------------------- def activate() self.active = true self end #-------------------------------------------------------------------------- # ■ Deactivate Window #-------------------------------------------------------------------------- def deactivate() self.active = false self end end
本贴来自国际rpgmaker官方论坛作者:Wyn Wizard处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/issues-with-in-scene-command-window-changing.165770/
页:
[1]