Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Drago - Message Log
- # Version : 1.2
- # Contact : littledrago.blogspot.com / forum.chaos-project.com
- #==============================================================================
- #
- # Instruction :
- #
- # $scene = Scene_MessageLog.new
- #
- #==============================================================================
- module MESSAGE_LOG
- MESSAGE_LOG_TEXT = "MESSAGE LOG"
- MESSAGE_LOG_FONT = "Arial"
- MESSAGE_LOG_SIZE = 30
- FRAME_OPACITY = 180
- FRAME_COLOR = Color.new(180,180,180)
- OFFSET_X = 100
- OFFSET_Y = 10
- EDGE_XY = [20,10]
- end
- #==============================================================================
- # ** Script Check
- #==============================================================================
- ($imported ||= {})[:drg_message_log] = 1.2
- core_engine = "This script needs Drago - Core Engine ver 1.52 or above"
- multi_message = "This script isn't compatible with Multi Message Windows"
- ($imported[:drg_core_engine] || 0) >= 1.52 || raise(core_engine)
- ($multiple_message_windows) && raise(multi_message)
- #==============================================================================
- # ** Scene_MessageLog
- #------------------------------------------------------------------------------
- # This class performs message log processing.
- #==============================================================================
- class Scene_MessageLog
- #--------------------------------------------------------------------------
- # * Include
- #--------------------------------------------------------------------------
- include MESSAGE_LOG
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_sec_reader :scene_update, '[Graphics,Input,self]'
- #--------------------------------------------------------------------------
- # * Main Processing
- #--------------------------------------------------------------------------
- def main
- @spriteset = Spriteset_Map.new
- init_message_log
- Graphics.transition
- scene_update.update while $scene == self
- Graphics.freeze
- all_variable_dispose
- end
- #--------------------------------------------------------------------------
- # * init_message_log
- #--------------------------------------------------------------------------
- def init_message_log
- @message_log_frame = Sprite.new
- @message_log_text = Sprite.new
- edge = [Graphics.width - EDGE_XY[0]*2, Graphics.height - EDGE_XY[1]*2]
- @message_log_frame.bitmap = Bitmap.new(*edge)
- @message_log_text.bitmap = @message_log_frame.bitmap.dup
- @message_log_text.opacity = 255
- @message_log_text.z = @message_log_frame.z + 10
- @message_log_text.x, @message_log_text.y = EDGE_XY[0], EDGE_XY[1]
- @message_log_frame.x, @message_log_frame.y = EDGE_XY[0], EDGE_XY[1]
- @message_log_frame.opacity = FRAME_OPACITY
- @index = 0
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- [(mess = @message_log_frame.bitmap).clear,@message_log_text.bitmap.clear]
- @message_log_height = 0
- cls = [Color.new(0,0,0,0), Color.new(255,255,255,255)]
- mess.fill_rect( mess.rect,FRAME_COLOR)
- $game_temp.message_log.reverse.each_with_index do |i,s|
- next if (@index ||= 0) > s
- @message_log_height += (i.height+20)
- v = mess.height - @message_log_height
- @message_log_text.bitmap.blt(20 ,v ,i, i.rect)
- mess.fill_rect( Rect.new(30,v-15,mess.width-60,2),cls[0])
- end
- @message_log_text.fill_rect( Rect.new(0,0,mess.width,50),cls[0])
- mess.fill_rect( Rect.new(10,40, mess.width-20,2), cls[1])
- mess.font.name = MESSAGE_LOG_FONT
- mess.font.size = [MESSAGE_LOG_SIZE, 12].max
- mess.draw_text(10,0, mess.width, 45,MESSAGE_LOG_TEXT)
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- if cancel_mesage_log
- $game_system.se_play($data_system.cancel_se)
- return $scene = Scene_Map.new
- end
- scroll = mouse_scroll
- if (el = elmessage_log(scroll)) || (er = ermessage_log(scroll))
- s = @index
- el && @index = [@index + 1, $game_temp.message_log.size-1].min
- er && @index = [@index - 1, 0].max
- $game_system.se_play($data_system.cursor_se) if s != @index
- return refresh
- end
- end
- #--------------------------------------------------------------------------
- # * Cancel Message Log
- #--------------------------------------------------------------------------
- def cancel_mesage_log
- return true if Input.trigger?(Input::F8)
- return true if Input.trigger?(Input::B)
- if $mouse_controller || $BlizzABS
- return true if Input.trigger?(Input::Key['Mouse Right'])
- elsif (($imported ||= {})[:drg_custom_input] || 0) >= 2.00
- return true if Mouse.press?(Mouse::SECONDARY)
- end
- return false
- end
- #--------------------------------------------------------------------------
- # * elmessage_log
- #--------------------------------------------------------------------------
- def elmessage_log(sc = 0)
- return true if Input.trigger?(Input::L)
- return true if Input.repeat?(Input::UP)
- return true if sc > 0
- return false
- end
- #--------------------------------------------------------------------------
- # * ermessage_log
- #--------------------------------------------------------------------------
- def ermessage_log(sc = 0)
- return true if Input.trigger?(Input::R)
- return true if Input.repeat?(Input::DOWN)
- return true if sc < 0
- return false
- end
- #--------------------------------------------------------------------------
- # * mouse_scroll
- #--------------------------------------------------------------------------
- def mouse_scroll
- @scroll_count = (@scroll_count || 0) + 1
- return (@scroll_count = 0) if @scroll_count < 5
- if $mouse_controller && Input.respond_to?(:scroll?)
- return 1 if Input.scroll_up?
- return -1 if Input.scroll_down?
- elsif (($imported ||= {})[:drg_custom_input] || 0) >= 2.00
- return 1 if Mouse.scroll_up?
- return -1 if Mouse.scroll_down?
- end
- return 0
- end
- end
- #==============================================================================
- # ** Game_Temp
- #------------------------------------------------------------------------------
- # This class handles temporary data that is not included with save data.
- # Refer to "$game_temp" for the instance of this class.
- #==============================================================================
- class Game_Temp
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_sec_reader :message_log, 'Array.new'
- end
- #==============================================================================
- # ** Window_Base
- #------------------------------------------------------------------------------
- # This class is for all in-game windows.
- #==============================================================================
- class Window_Base
- #--------------------------------------------------------------------------
- # * record_message
- #--------------------------------------------------------------------------
- def record_message
- xy = MESSAGE_LOG::OFFSET_X, MESSAGE_LOG::OFFSET_Y
- edge = MESSAGE_LOG::EDGE_XY
- saved_bitmap = Bitmap.new(Graphics.width-edge[0]*2,self.contents.height+10)
- saved_bitmap.blt(xy[0],xy[1],self.contents,self.contents.rect)
- save_message_bitmap(saved_bitmap)
- end
- #--------------------------------------------------------------------------
- # * save_message_bitmap
- #--------------------------------------------------------------------------
- def save_message_bitmap(saved_bitmap)
- d = $game_temp.message_log
- ($game_temp.message_log.push(saved_bitmap))
- ($game_temp.message_log.shift).dispose if d.size + 1 > 20
- end
- end
- #==============================================================================
- # ** Window_InputNumber
- #------------------------------------------------------------------------------
- # This window is for inputting numbers, and is used within the
- # message window.
- #==============================================================================
- class Window_InputNumber
- #--------------------------------------------------------------------------
- # * Dispose
- #--------------------------------------------------------------------------
- define_pre_alias(:dispose) { record_message }
- end
- #==============================================================================
- # ** Window_Message
- #------------------------------------------------------------------------------
- # This message window is used to display text.
- #==============================================================================
- class Window_Message
- #--------------------------------------------------------------------------
- # * Terminate Message
- #--------------------------------------------------------------------------
- define_pre_alias(:terminate_message) do
- if @contents_showing
- if (record_input = $game_temp.num_input_variable_id != 0)
- record_input = $game_temp.message_log.pop
- end
- record_message
- record_input && $game_temp.message_log << record_input
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement