Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ■ Galge Conversation System
- # @version 0.7 12/02/15 RGSS3
- # @author Saba Kan
- # @translator kirinelf (Made a small edit to picture IDs)
- #------------------------------------------------------------------------------
- #
- #==============================================================================
- module Saba
- module Gal
- # --------------------Config---------------------
- # Fine tuning of actor graphic positioning.
- # {Actor ID=>pixels shifted} E.g. {1=>-4} (Actor ID 1's graphic shifted 4
- # pixels to the left/up)
- OFFSET_X = {1=>0, 2=>-30, 3=>-30, 6=>-40, 7=>-45, 8=>-40}
- OFFSET_Y = {1=>0, 2=>10, 3=>40, 4=>10, 7=>-15, 8=>5}
- # This only applies to OFFSET_X above, for displaying character graphics on
- # the left.
- # 座標に -1 をかける場合 true に設定します。
- # If the coordinates above have '-1', set to true. <= ?
- MIRROR_LEFT_OFFSET_X = false
- # Speech balloon graphic coordinates.
- BALLOON_LEFT_X = 210 # X Coordinate when it appears on the left.
- BALLOON_RIGHT_X = 300 # X Coordinate when it appears on the right.
- BALLOON_Y = 254 # Y Coordinate
- # Name window width. Default of 114 is for a name 4 characters long.
- NAME_WINDOW_WIDTH = 114
- # For skipping text. A is Shift on the keyboard.
- SKIP_BUTTON = Input::A
- # This switch ID disables skipping of the text.
- SKIP_DISABLE_SWITCH = 131
- # This switch changes the message display mode.
- MESSAGE_MODE_SWITCH = 132
- # This switch ID toggles display of the name.
- DISPLAY_NAME_SWITCH = 133
- # This switch toggles display of speech balloon graphics.
- DISPLAY_BALLOON_SWITCH = 134
- # This switch clears all speech balloon graphics.
- CLEAR_BALLOON_SWITCH = 135
- # This switch toggles playing of message sound effects.
- PLAY_MESSAGE_SE_SWITCH = 136
- # Variable to determine speech balloon color.
- # ※Will be automatically entered into the variable.
- BALLOON_VARIABLE = 131
- # Variable to determine speech balloon location.
- # ※Will be automatically entered into the variable.
- BALLOON_POSITION_VARIABLE = 132
- # If you want character graphics displayed on the right to be mirrored,
- # set to 'true'.
- MIRROR_LEFT = false
- # If you want character graphics displayed on the left to be mirrored,
- # set to 'true'.
- MIRROR_RIGHT = false
- # This setting changes the base picture ID of the potraits. Generally
- # speaking, the lower this is the better. However, some people might use
- # a lot of pictures, and it's a hassle to remember which IDs the script uses.
- # This setting allows you to define the base picture ID of the potraits.
- # Potraits on the right will have this ID, and potraits on the left will have
- # this ID + 2. For example, the default setting has the picture IDs of 10
- # and 12.
- BASE_PICTURE_ID = 10
- # If you don't want different characters to have different windowskins,
- # set to 'true'.
- # Window1.png and Balloon1.png will be used if 'true'.
- USE_SINGLE_WINDOW_SKIN = false
- # Tone overlay of characters in conversation.
- # Red, Green, Blue, Gray
- # Active Character
- ACTIVE_TONE = Tone.new(0, 0, 0, 0)
- # Inactive Character (0, 0, 0, 0) <= No change.
- INACTIVE_TONE = Tone.new(-104, -104, -104, 0)
- # Frames to wait after tone change during character switching.
- TONE_CHANGE_DURATION = 17
- # Event Command "Show Balloon Icon" Icon Positioning
- OFFSET_EVENT_BALLOON_X = {1=>0, 2=>0, 3=>-30, 6=>-40, 7=>-45, 8=>-40}
- OFFSET_EVENT_BALLOON_Y = {1=>0, 2=>10, 3=>40, 4=>10, 7=>-15, 8=>5}
- end
- end
- #=========================================================================
- # Do not edit anything under this line unless you know what you're doing!
- #=========================================================================
- $imported = {} if $imported == nil
- $imported["GalGameTalkSystem"] = true
- # ピクチャ表示用
- class Game_Interpreter
- def pic(name, index, position)
- actor_id = name["actor".length..-1].to_i
- $game_variables[Saba::Gal::BALLOON_POSITION_VARIABLE] = position
- x = picture_base_x(position) + offset_x(position, actor_id)
- y = picture_base_y(position) + offset_y(actor_id)
- $game_variables[Saba::Gal::BALLOON_VARIABLE] = actor_id
- picture = screen.pictures[position + Saba::Gal::BASE_PICTURE_ID]
- name = name + "_" + (index + 1).to_s
- @actor1_position = nil if @actor1_position == position
- if Saba::Gal::MIRROR_LEFT && position == 1
- picture.mirror_pic = true
- elsif Saba::Gal::MIRROR_RIGHT && position == 2
- picture.mirror_pic = true
- else
- picture.mirror_pic = false
- end
- picture.show(name, 0, x, y, 100, 100, 255, 0)
- if @actor_id != actor_id
- picture.start_tone_change(Saba::Gal::INACTIVE_TONE, 0)
- deactivate_other_pictures(position)
- activate(picture, position, actor_id)
- end
- @actor_id = actor_id
- end
- #--------------------------------------------------------------------------
- # ● ピクチャのオフセット位置のx座標取得
- #--------------------------------------------------------------------------
- def offset_x(position, actor_id)
- n = Saba::Gal::OFFSET_X[actor_id]
- return 0 if n == nil
- if position == 1 && Saba::Gal::MIRROR_LEFT_OFFSET_X
- return -n
- else
- return n
- end
- end
- #--------------------------------------------------------------------------
- # ● ピクチャのオフセット位置のy座標取得
- #--------------------------------------------------------------------------
- def offset_y(actor_id)
- n = Saba::Gal::OFFSET_Y[actor_id]
- return 0 if n == nil
- return n
- end
- #--------------------------------------------------------------------------
- # ● イベントバルーンのオフセット位置のx座標取得
- #--------------------------------------------------------------------------
- def offset_event_balloon_x(position, actor_id)
- n = Saba::Gal::OFFSET_EVENT_BALLOON_X[actor_id]
- return 0 if n == nil
- if position == 1 && Saba::Gal::MIRROR_LEFT_OFFSET_X
- return -n
- else
- return n
- end
- end
- #--------------------------------------------------------------------------
- # ● イベントバルーンのオフセット位置のy座標取得
- #--------------------------------------------------------------------------
- def offset_event_balloon_y(actor_id)
- n = Saba::Gal::OFFSET_EVENT_BALLOON_Y[actor_id]
- return 0 if n == nil
- return n
- end
- #--------------------------------------------------------------------------
- # ● 指定のピクチャを明るく
- #--------------------------------------------------------------------------
- def activate(picture, position, actor_id)
- if Input.press?(Saba::Gal::SKIP_BUTTON)
- picture.start_tone_change(Saba::Gal::ACTIVE_TONE, 1)
- else
- picture.start_tone_change(Saba::Gal::ACTIVE_TONE, 25)
- end
- $game_temp.pic_actors[position] = actor_id
- end
- #--------------------------------------------------------------------------
- # ● 指定のピクチャ以外を暗く
- #--------------------------------------------------------------------------
- def deactivate_other_pictures(position)
- screen.pictures.size.times do |index|
- next if screen.pictures[index].number == 1
- next if index == position + 10
- deactivate(screen.pictures[index])
- end
- end
- #--------------------------------------------------------------------------
- # ● 指定のピクチャを暗く
- #--------------------------------------------------------------------------
- def deactivate(picture)
- unless Input.press?(Saba::Gal::SKIP_BUTTON)
- picture.start_tone_change(Saba::Gal::INACTIVE_TONE, 25)
- end
- end
- def picture_base_x(position)
- case position
- when 2
- return 25
- when 0
- return Graphics.width - 244
- when 3
- return 200
- end
- end
- def picture_base_y(position)
- return 30
- end
- def act(position)
- $game_variables[Saba::Gal::BALLOON_VARIABLE] = $game_temp.pic_actors[position]
- if position < 3
- $game_variables[Saba::Gal::BALLOON_POSITION_VARIABLE] = position
- end
- picture = screen.pictures[position + 10]
- deactivate_other_pictures(position)
- if Input.press?(Saba::Gal::SKIP_BUTTON)
- picture.start_tone_change(Saba::Gal::ACTIVE_TONE, 1)
- @wait_count = 0
- else
- picture.start_tone_change(Saba::Gal::ACTIVE_TONE, Saba::Gal::TONE_CHANGE_DURATION)
- @wait_count = 0
- end
- end
- def dis(position)
- picture = screen.pictures[position + 10]
- picture.erase
- end
- end
- class Scene_Map
- #--------------------------------------------------------------------------
- # ● メッセージウィンドウの作成
- #--------------------------------------------------------------------------
- alias saba_gal_create_message_window create_message_window
- def create_message_window
- saba_gal_create_message_window
- create_gal_window
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- alias saba_gal_update update
- def update
- create_gal_window
- update_gal_event_balloon
- saba_gal_update
- end
- #--------------------------------------------------------------------------
- # ● ギャルゲーウィンドウ作成
- # ギャルゲーモードの時、ウィンドウを切り替えます。
- #--------------------------------------------------------------------------
- def create_gal_window
- if $game_switches[Saba::Gal::MESSAGE_MODE_SWITCH]
- if ! @message_window.is_a?(Window_MessageGal)
- # ギャルゲーウィンドウにする
- @message_window.dispose
- @message_window = Window_MessageGal.new
- end
- else
- if @message_window.is_a?(Window_MessageGal)
- # 通常ウィンドウに戻す
- @message_window.dispose
- @message_window = Window_Message.new
- end
- end
- end
- def on_a
- p 11
- end
- #--------------------------------------------------------------------------
- # ● ギャルゲーウィンドウのフキダシアイコン作成
- #--------------------------------------------------------------------------
- def create_gal_event_balloon(character)
- dispose_gal_event_balloon
- @saba_balloon_sprite = Sprite_Character.new(@viewport, character)
- end
- #--------------------------------------------------------------------------
- # ● ギャルゲーウィンドウのフキダシアイコン破棄
- #--------------------------------------------------------------------------
- def dispose_gal_event_balloon
- if @saba_balloon_sprite
- @saba_balloon_sprite.dispose
- @saba_balloon_sprite = nil
- end
- end
- #--------------------------------------------------------------------------
- # ● ギャルゲーウィンドウのフキダシアイコン更新
- #--------------------------------------------------------------------------
- def update_gal_event_balloon
- if @saba_balloon_sprite
- if @saba_balloon_sprite.character.balloon_id == 0 || Input.press?(Saba::Gal::SKIP_BUTTON)
- dispose_gal_event_balloon
- else
- @saba_balloon_sprite.update
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● スプライトセットの解放
- #--------------------------------------------------------------------------
- alias saba_gal_dispose_spriteset dispose_spriteset
- def dispose_spriteset
- saba_gal_dispose_spriteset
- dispose_gal_event_balloon
- end
- end
- class Window_MessageGal < Window_Message
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super
- self.x = 10
- create_baloon_sprite
- $game_temp.window_number = -1
- update_balloon
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ幅の取得
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width - 20
- end
- #--------------------------------------------------------------------------
- # ● 表示行数の取得
- #--------------------------------------------------------------------------
- def visible_line_number
- return 3
- end
- #--------------------------------------------------------------------------
- # ● 改ページが必要か判定
- #--------------------------------------------------------------------------
- def need_new_page?(text, pos)
- pos[:y] > contents.height && !text.empty?
- end
- #--------------------------------------------------------------------------
- # ● 通常文字の処理
- #--------------------------------------------------------------------------
- def process_normal_character(c, pos)
- if Input.press?(Saba::Gal::SKIP_BUTTON) && skip_enabled?
- @pause_skip = true
- end
- text_width = text_size(c).width
- if display_name? && (pos[:y] == 0)
- @name_sprite.bitmap.draw_text(pos[:x], 26, text_width * 2, pos[:height], c)
- pos[:x] += text_width
- return
- end
- if display_name?
- draw_text(pos[:x], pos[:y] - pos[:height], text_width * 2, pos[:height], c)
- else
- draw_text(pos[:x], pos[:y], text_width * 2, pos[:height], c)
- end
- pos[:x] += text_width
- unless Input.press?(Saba::Gal::SKIP_BUTTON) && skip_enabled?
- wait_for_one_character
- end
- end
- #--------------------------------------------------------------------------
- # ● 制御文字によるアイコン描画の処理
- #--------------------------------------------------------------------------
- def process_draw_icon(icon_index, pos)
- if display_name?
- draw_icon(icon_index, pos[:x], pos[:y] - pos[:height])
- else
- draw_icon(icon_index, pos[:x], pos[:y])
- end
- pos[:x] += 24
- end
- #--------------------------------------------------------------------------
- # ● 全ウィンドウの作成
- #--------------------------------------------------------------------------
- def create_all_windows
- super
- @name_window = Window_Base.new(20, Graphics.height - 126, Saba::Gal::NAME_WINDOW_WIDTH, 37)
- @name_window.z = 480
- @name_window.visible = false
- @name_sprite = Sprite_Base.new(nil)
- @name_sprite.z = 500
- @name_sprite.x = 30
- @name_sprite.y = Graphics.height - 146
- @name_sprite.bitmap = Bitmap.new(230, 300)
- end
- #--------------------------------------------------------------------------
- # ● フキダシスプライトを生成します。
- #--------------------------------------------------------------------------
- def create_baloon_sprite
- @balloon_sprite = Sprite_Base.new
- @balloon_sprite.z = 500
- @balloon_sprite.y = Graphics.height - 384
- @balloon_sprite.bitmap = Bitmap.new(400, 300)
- @balloon_sprite.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 全ウィンドウの解放
- #--------------------------------------------------------------------------
- def dispose_all_windows
- super
- @name_window.dispose
- @name_sprite.bitmap.dispose
- @name_sprite.dispose
- @balloon_sprite.dispose
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウの更新
- #--------------------------------------------------------------------------
- def update
- super
- update_name_visibility
- update_balloon_visibility
- update_balloon
- update_opacity
- end
- #--------------------------------------------------------------------------
- # ● 不透明度の更新
- #--------------------------------------------------------------------------
- def update_opacity
- if @background != 0
- self.opacity = 0
- return
- end
- return if self.opacity == 255
- self.opacity += 9
- end
- #--------------------------------------------------------------------------
- # ● 入力待ち処理
- #--------------------------------------------------------------------------
- def input_pause
- self.pause = true
- wait(10)
- Fiber.yield until Input.trigger?(:B) || Input.trigger?(:C) || (Input.press?(Saba::Gal::SKIP_BUTTON) && skip_enabled?)
- if self.visible == false
- self.visible = true
- Sound.play_cursor
- input_pause
- return
- end
- Input.update
- self.pause = false
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウを開き、完全に開くまで待つ
- #--------------------------------------------------------------------------
- def open_and_wait
- open
- update_picture
- until open?
- update_balloon
- Fiber.yield
- end
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウを閉じ、完全に閉じるまで待つ
- #--------------------------------------------------------------------------
- def close_and_wait
- close
- @name_window.visible = false
- @name_sprite.visible = false
- until all_close?
- Fiber.yield
- end
- end
- #--------------------------------------------------------------------------
- # ● 改ページ処理
- #--------------------------------------------------------------------------
- def new_page(text, pos)
- @name_sprite.bitmap.clear
- contents.clear
- reset_font_settings
- pos[:x] = new_line_x
- pos[:y] = 0
- pos[:new_x] = new_line_x
- pos[:height] = calc_line_height(text)
- clear_flags
- end
- #--------------------------------------------------------------------------
- # ● 立ち絵の更新
- #--------------------------------------------------------------------------
- def update_picture
- return if $game_message.face_name.empty?
- $game_map.interpreter.pic($game_message.face_name, $game_message.face_index, $game_message.position)
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ位置の更新
- #--------------------------------------------------------------------------
- def update_placement
- @position = 2
- self.y = @position * (Graphics.height - height) / 2
- @gold_window.y = y > 0 ? 0 : Graphics.height - @gold_window.height
- end
- #--------------------------------------------------------------------------
- # ● 背景と位置の変更判定
- #--------------------------------------------------------------------------
- def settings_changed?
- @background != $game_message.background
- end
- #--------------------------------------------------------------------------
- # ● 改行位置の取得
- #--------------------------------------------------------------------------
- def new_line_x
- return 0
- end
- #--------------------------------------------------------------------------
- # ● 次の語を表示すべきかどうかを判定します。
- #--------------------------------------------------------------------------
- def show_next_message?
- if skip_enabled?
- return Input.trigger?(Input::C) || Input.trigger?(Input::B) || Input.trigger?(Saba::Gal::SKIP_BUTTON)
- else
- return Input.trigger?(Input::C) || Input.trigger?(Input::B)
- end
- end
- #--------------------------------------------------------------------------
- # ● メッセージスキップが有効かどうかを判定します。
- #--------------------------------------------------------------------------
- def skip_enabled?
- return $game_switches[Saba::Gal::SKIP_DISABLE_SWITCH] != true
- end
- #--------------------------------------------------------------------------
- # ● スイッチに従って、名前ウィンドウの表示を切り替えます。
- #--------------------------------------------------------------------------
- def update_name_visibility
- if @closing || close? || ! self.visible
- @name_window.visible = false
- @name_sprite.visible = false
- return
- end
- if $game_switches[Saba::Gal::DISPLAY_NAME_SWITCH] != true
- @name_window.visible = false
- @name_sprite.visible = false
- else
- @name_window.visible = true
- @name_sprite.visible = true
- end
- end
- #--------------------------------------------------------------------------
- # ● ふきだしの表示を切り替えます。
- #--------------------------------------------------------------------------
- def update_balloon_visibility
- if self.openness < 255
- @balloon_sprite.visible = false
- return
- end
- if @balloon_sprite.visible != $game_switches[Saba::Gal::DISPLAY_BALLOON_SWITCH]
- @balloon_sprite.visible = $game_switches[Saba::Gal::DISPLAY_BALLOON_SWITCH]
- update_balloon
- end
- end
- #--------------------------------------------------------------------------
- # ● 名前を表示すべきかどうかを判定します。
- #--------------------------------------------------------------------------
- def display_name?
- return $game_switches[Saba::Gal::DISPLAY_NAME_SWITCH] == true
- end
- #--------------------------------------------------------------------------
- # ● フキダシをまっさらにします。
- #--------------------------------------------------------------------------
- def clear_balloon
- @balloon_sprite.bitmap.clear_rect(100, 254, 300, 100)
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウの色が変わったかどうかを判定します。
- #--------------------------------------------------------------------------
- def window_color_changed?
- if $game_temp.window_number != $game_variables[Saba::Gal::BALLOON_VARIABLE] || $game_switches[Saba::Gal::CLEAR_BALLOON_SWITCH]
- $game_temp.window_number = $game_variables[Saba::Gal::BALLOON_VARIABLE]
- return true
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● フキダシを更新します。
- #--------------------------------------------------------------------------
- def update_balloon
- return unless window_color_changed?
- clear_balloon
- if Saba::Gal::USE_SINGLE_WINDOW_SKIN
- self.windowskin = Cache.system("Window1")
- else
- self.windowskin = Cache.system("Window" + $game_temp.window_number.to_s)
- if openness == 255
- self.opacity = 140 unless $game_switches[Saba::Gal::CLEAR_BALLOON_SWITCH]
- end
- end
- $game_switches[Saba::Gal::CLEAR_BALLOON_SWITCH] = false
- if $game_temp.window_number != nil && $game_temp.window_number > 0
- if Saba::Gal::USE_SINGLE_WINDOW_SKIN
- balloon = Cache.system("Balloon1")
- else
- balloon = Cache.system("Balloon" + $game_temp.window_number.to_s)
- end
- w = balloon.width / 2
- h = balloon.height
- if $game_variables[Saba::Gal::BALLOON_POSITION_VARIABLE] == 2
- @balloon_sprite.bitmap.blt(Saba::Gal::BALLOON_LEFT_X, Saba::Gal::BALLOON_Y, balloon, Rect.new(w, 0, w, h))
- else
- @balloon_sprite.bitmap.blt(Saba::Gal::BALLOON_RIGHT_X, Saba::Gal::BALLOON_Y, balloon, Rect.new(0, 0, w, h))
- end
- end
- end
- end
- class Game_Picture
- attr_accessor:mirror_pic
- alias saba_gal_initialze initialize
- def initialize(number)
- saba_gal_initialze(number)
- @mirror_pic = false
- end
- end
- class Sprite_Picture < Sprite
- alias saba_gal_update update
- def update
- saba_gal_update
- if @picture_name != ""
- self.mirror = @picture.mirror_pic
- end
- end
- end
- class Game_Pictures
- def size
- return @data.size
- end
- end
- class Game_Temp
- attr_accessor :window_number
- attr_accessor :pic_actors
- alias saba_pic_initialize initialize
- def initialize
- saba_pic_initialize
- @pic_actors = []
- end
- end
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● フキダシアイコンの表示
- #--------------------------------------------------------------------------
- alias saba_gal_command_213 command_213
- def command_213
- unless message_mode?
- saba_gal_command_213
- return
- end
- command = @list[@index + 1]
- if command == nil || command.code != 101
- p "イベントコマンドのフキダシアイコンの表示 の後にメッセージイベントを入れてください"
- return
- end
- return if Input.press?(Saba::Gal::SKIP_BUTTON)
- params = command.parameters
- name = params[0]
- actor_id = name["actor".length..-1].to_i
- position = params[3]
- x = (picture_base_x(position) + offset_event_balloon_x(position, actor_id) + 80) / 32.0 + $game_map.display_x
- y = (picture_base_y(position) + offset_event_balloon_y(actor_id)) / 32.0 + $game_map.display_y
- balloon_char = Game_Character.new
- balloon_char.moveto(x, y)
- balloon_char.balloon_id = @params[1]
- SceneManager.scene.create_gal_event_balloon(balloon_char)
- end
- #--------------------------------------------------------------------------
- # ● 会話モードかどうかを判定します。
- #--------------------------------------------------------------------------
- def message_mode?
- return $game_switches[Saba::Gal::MESSAGE_MODE_SWITCH] == true
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment