我想说,RMXP的魔塔样板里面的对话手册的功能都比你这个好···因为那个是在游戏中编辑的线索,你这个需要提前在脚本编辑器设定··· |
下面是在原始脚本里添加的: DataManager里 #-------------------------------------------------------------------------- # ● 生成各种游戏对象 #-------------------------------------------------------------------------- def self.create_game_objects $game_temp = Game_Temp.new $game_system = Game_System.new $game_timer = Game_Timer.new $game_message = Game_Message.new $game_switches = Game_Switches.new $game_variables = Game_Variables.new $game_self_switches = Game_SelfSwitches.new $game_actors = Game_Actors.new $game_party = Game_Party.new $game_troop = Game_Troop.new $game_map = Game_Map.new $game_player = Game_Player.new $game_eventVar = Game_EventVariables.new end SceneManager里 #-------------------------------------------------------------------------- # ● 运行 #-------------------------------------------------------------------------- def self.run DataManager.init EventBookDef.init Audio.setup_midi if use_midi? @scene = first_scene_class.new @scene.main while @scene end Window_MenuCommand里 #-------------------------------------------------------------------------- # ● 独自添加指令用 #-------------------------------------------------------------------------- def add_original_commands add_command(EventBookDef::Menu, :eventBook) end Scene_Menu里 #-------------------------------------------------------------------------- # ● 生成指令窗口 #-------------------------------------------------------------------------- def create_command_window @command_window = Window_MenuCommand.new @command_window.set_handler(:item, method(:command_item)) @command_window.set_handler(:skill, method(:command_personal)) @command_window.set_handler(:equip, method(:command_personal)) @command_window.set_handler(:status, method(:command_personal)) @command_window.set_handler(:formation, method(:command_formation)) @command_window.set_handler(:save, method(:command_save)) @command_window.set_handler(:game_end, method(:command_game_end)) @command_window.set_handler(:cancel, method(:return_scene)) @command_window.set_handler(:eventBook, method(:command_openBook)) end # 事件薄 def command_openBook SceneManager.call(Scene_EventBook) end |
#------------------------------------------------------------------------------ # 事件薄案件详细内容场景 #------------------------------------------------------------------------------ class Scene_EventDetail < Scene_Base def start super create_detailWindow end def create_detailWindow @detail_window = Window_EventDetail.new() @detail_window.set_handler(:cancel,method(:return_scene)) end end #------------------------------------------------------------------------------ # 事件薄案件详细内容窗口 #------------------------------------------------------------------------------ class Window_EventDetail < Window_Selectable def initialize super(0, 0, Graphics.width, Graphics.height) @data = EventBookDef.getDetailData @line = 0 create_tile create_key_content activate end def create_tile str = @data[:case][:text] p str draw_text_ex((Graphics.width-text_size(str).width)/2,Font.default_size * @line,str) @line += 1 end def create_key_content # 画线索的名字 chapter = @data[:chapter] castTemp = $game_eventVar.Chapter[chapter[:context]].getCase(@data[:case][:context]) i = 0 until i >= castTemp.Keys.size chapterIns = EventBookDef.getChapterByIndex(chapter[:context]) caseIns = chapterIns.getCase(@data[:case][:text]) keyIns = caseIns.Key(castTemp.Keys[i]) draw_text_ex(4, Font.default_size*@line,keyIns.name) @line += 1 draw_text_ex(20,Font.default_size*@line,keyIns.detail) @line += 1 i+=1 end end # 难道需要自动换行? #-------------------------------------------------------------------------- # ● 文字的处理 # c : 文字 # text : 绘制处理中的字符串缓存(字符串可能会被修改) # pos : 绘制位置 {:x, :y, :new_x, :height} #-------------------------------------------------------------------------- alias parent_process_character process_character def process_character(c, text, pos) case c when "\r" # 回车 return when "\n" # 换行 return when "\f" # 翻页 return when "\e" # 控制符 process_escape_character(obtain_escape_code(text), text, pos) else # 普通文字 process_normal_character(c,pos) process_next_character(text.slice(0,1),text,pos) end end def process_next_character(c,text,pos) case c when "\r" return when "\n" return when "\f" return when "\e" return else next_pos = pos[:x] + text_size(c).width * 2 + self.padding if next_pos > width process_new_line(text,pos) @line += 1 end end end end |
#------------------------------------------------------------------------- # 事件薄界面 #------------------------------------------------------------------------- class Scene_EventBook < Scene_MenuBase def start super create_book end def create_book @book_window = Window_EventBook.new @book_window.set_handler(:cancel, method(:on_cancel)) @book_window.set_handler(:ok, method(:on_ok)) end def on_cancel case @book_window.type when 1 @book_window.type = 0 @book_window.activate when 0 return_scene end end def on_ok case @book_window.type when 0 @book_window.type = 1 @book_window.activate when 1 @book_window.selectEvent SceneManager.call(Scene_EventDetail) end end end |
#-------------------------------------------------------------------------------- # 事件薄详细内容窗口 #-------------------------------------------------------------------------------- class Window_EventBook < Window_Selectable #-------------------------------------------------------------------------- # ● 定义实例变量 #-------------------------------------------------------------------------- attr_accessor :BGSprite attr_accessor :type def initialize @BGSprite = Sprite.new(Viewport.new) @BGSprite.bitmap = Cache.load_bitmap(EventBookDef::ResFolder,EventBookDef::ResCover) bitmapTemp = Cache.load_bitmap(EventBookDef::ResFolder,EventBookDef::ResTag) if @BGSprite != nil super(([email protected] - bitmapTemp.width)/2,(Graphics.height - @BGSprite.height)/2, @BGSprite.width, @BGSprite.height) else super(([email protected] - bitmapTemp.width)/2,(Graphics.height - @BGSprite.height)/2, Graphics.width, Graphics.height) end @BGSprite.x = self.x @BGSprite.y = self.y self.windowskin = nil preCount = EventBookDef::BookTagPreCount + 2#@BGSprite.height / bitmapTemp.height book_x = x + @BGSprite.width book_y = y + (@BGSprite.height - bitmapTemp.height*preCount)/2 preCount -= 2 #这里减去上下翻页提示数量 @book_menu = EventNoteMenu.new(preCount,book_x,book_y,bitmapTemp.width,bitmapTemp.height*preCount) bitmapTemp.dispose @type = 0 @dirty = true activate end def Type?(type) @type == type end def type=(type) @type = type @dirty = true end def switchChapters return unless @book_menu != nil if @type == 0 && @dirty data = [] i = 0 if $game_eventVar.Last_Chapter == -1 msgbox("未调用任何StartChapter") @dirty = false return end until i > $game_eventVar.Last_Chapter data.push({:text=>EventBookDef.getChapterByIndex(i).name,:context => i}) i+=1 end @book_menu.setData(data) @dirty = false end end def switchEvent return unless @book_menu != nil if @type == 1 && @dirty data = [] @chapter = @book_menu.getData if @chapter == nil @dirty = false @type = 0 return end caseTemp = $game_eventVar.Chapter[@book_menu.getData[:context]].case caseTemp.each {|p| data.push({:text=>EventBookDef.getCaseName(@chapter[:text],p.id),:context=>p.id})} @book_menu.setData(data) @dirty = false end end def update super @book_menu.update switchChapters switchEvent end def selectEvent data = {:chapter=>@chapter,:case=>@book_menu.getData} EventBookDef.setDetailData(data) end end |
#----------------------------------------------------------------------------- # 事件薄主界面 #----------------------------------------------------------------------------- # 事件薄标签 class EventNoteTag < Sprite attr_accessor:info def initialize(viewport = nil) super(viewport) create_tag end def dispose self.bitmap.dispose if bitmap super end def selected self.zoom_x = 1.1 self.zoom_y = 1.1 end def unselected self.zoom_x = 1 self.zoom_y = 1 end def create_tag self.bitmap = Cache.load_bitmap(EventBookDef::ResFolder,EventBookDef::ResTag).clone end def setPos(x,y) self.x = x self.y = y end def update super end def info=(info) @info = info update_info end def update_info #self.contents.draw_text(self.bitmap.rect,"",1) self.bitmap.clear self.bitmap = Cache.load_bitmap(EventBookDef::ResFolder,EventBookDef::ResTag).clone self.bitmap.draw_text(self.bitmap.rect,info,1) end end # 事件薄标签菜单 class EventNoteMenu < Window attr_accessor:preCount #一页可显示标签数 attr_accessor:index #当前光标所在位置 attr_reader:startIndex #当前页开始位置 attr_reader:endIndex #当前页结束位置 def initialize(preCount = 1,x,y,w,h) super(x,y,w,h) @preCount = preCount @viewport = Viewport.new @tags = [] @tagsData = [] @pointTag = [] @index = -1 @last_index = -2 @maxSize = 0 @startIndex = 0 @last_startIndex = -1 @maxSize > @preCount ? @endIndex = @preCount : @endIndex = @maxSize create_onePageTags create_pointTags update_tagsContent update_tags #select(0) end def dispose @viewport.dispose if @viewport super end def create_onePageTags count = 0 until count == @preCount || count == @maxSize @tags.push(EventNoteTag.new(@viewport)) count+=1 end @startIndex = 0 if @maxSize end def create_pointTags return unless @maxSize > @preCount @pointTag[0] = EventNoteTag.new(@viewport) @pointTag[0].x = x @pointTag[0].y = y @pointTag[0].info = EventBookDef::PointText @pointTag[1] = EventNoteTag.new(@viewport) @pointTag[1].info = EventBookDef::PointText @pointTag[1].x = x @pointTag[1].y = y end def setData(tagsData) @tagsData.clear if @tagsData @tagsData = tagsData @maxSize = @tagsData.size @maxSize > @preCount ? @endIndex = @preCount : @endIndex = @maxSize @tags.each {|tag| tag.dispose} @tags.clear @pointTag.each{|tag| tag.dispose } @pointTag.clear create_onePageTags create_pointTags update_tagsContent @index = -1 @last_index = -2 update_tags select(0) end def getData return @tagsData[@startIndex + @index] if @index && @startIndex return nil end def cursor_movable? @index >= 0 && @index < @preCount end def cursor_up(wrap = false) @index -= 1 select(@index) end def cursor_down(wrap = false) @index += 1 select(@index) end def pageUp @index -= @preCount select([@index,@startIndex].max) end def pageDown @index += @preCount select([@index,@endIndex].min) end def select(index) return unless @maxSize != 0 @index = index if @index < 0 if @startIndex > 0 @startIndex -= 1 @endIndex -= 1 else Sound.play_buzzer end @index = 0 update_tagsContent Sound.play_cursor else if @index == (@endIndex - @startIndex) if @endIndex != @maxSize @startIndex += 1 @endIndex += 1 else Sound.play_buzzer end @index -= 1 update_tagsContent Sound.play_cursor end end @tags[@index].selected if @index >= 0 @tags[@last_index].unselected if @last_index >= 0 && @index != @last_index update_tags end def process_cursor_move return unless cursor_movable? @last_index = @index cursor_down (Input.trigger?(:DOWN)) if Input.repeat?(:DOWN) cursor_up (Input.trigger?(:UP)) if Input.repeat?(:UP) pageUp if Input.trigger?(:R) pageDown if Input.trigger?(:L) Sound.play_cursor if @index != @last_index end def update super process_cursor_move end def update_tags #return unless @index != @last_index index = 0 height = 0 until index == @preCount || index == @maxSize @tags[index].setPos(x,(index+1) * @tags[index].height + y) if index != @index @tags[index].setPos(x, @tags[index-1].height * index+@tags[index].height + y) if index > 0 height = @tags[index].y index += 1 end update_pointTags(height) end def update_pointTags(height) return unless @maxSize > @preCount @startIndex == 0 ? @pointTag[0].visible = false : @pointTag[0].visible = true @endIndex == @maxSize ? @pointTag[1].visible = false : @pointTag[1].visible = true @pointTag[1].setPos(x,height+@pointTag[1].height) end def update_tagsContent index = 0 until index == @preCount || index == @maxSize @tags[index].info = @tagsData[@startIndex + index][:text] index += 1 end end end |
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-15 15:09
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.