设为首页收藏本站同能贴吧 切换语言 繁体中文
开启辅助访问 切换到窄版
扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 128|回复: 0

[转载发布] Dialogue History v1.4

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    2026-7-12 04:10
  • 签到天数: 209 天

    连续签到: 2 天

    [LV.7]常住居民III

    9068

    主题

    864

    回帖

    6万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    58857
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    68819

    灌水之王

    发表于 5 天前 | 显示全部楼层 |阅读模式



    This is was originally a script request fulfilled here.

    Features
    Provides an object recording:
    -dialogue messages
    -dialogue choices made
    -numbers entered
    -selected objects through events
    -names entered
    -scrolling text
    You may enable or disable some of the recorded objects in the script options.

    The recorder can be accessed with script calls or by pressing a key (by default F8), even during messages! (only works on the map scene)

    Loading a save will also load the dialogue history if you enable it.

    If the history is too big, it may take some time to load, don't forget to clear it! Alternatively, you can setup a maximum number of entries, if there are too many, the older ones will be discarded automatically.

    Script commands
                    Ruby:       
    1. #(you may either use $game_system.dialogue_recorder or dialogue_recorder)
    2. dialogue_recorder.start #starts recording messages
    3. dialogue_recorder.stop #stops the recording
    4. dialogue_recorder.clear #clear all saved messages
    5. dialogue_recorder.display #open the history scene
    6. dialogue_recorder.enable_load_on_save #enable the hisotry scene on save load
    7. dialogue_recorder.disable_load_on_save #disable it on save load
    8. dialogue_recorder.access = true #toggle the access to history scene by key
    9. dialogue_recorder.access = false #toggle the access to history scene by key
    复制代码


    The script
    Gitlab link
                    Ruby:       
    1. #==============================================================================
    2. # Dialogue History v1.4
    3. #------------------------------------------------------------------------------
    4. # Author: Timtrack
    5. # date: 28/03/2026
    6. #==============================================================================
    7. $imported ||= {}
    8. $imported["TIM-DialogueHistory"] = true
    9. #==============================================================================
    10. # Version History
    11. #------------------------------------------------------------------------------
    12. # 30/09/2025: Original release
    13. # 30/09/2025: v1.1 smoother sliding, no longer selecting windows
    14. # 01/10/2025: v1.2 fixing dispose order, added more general support for window
    15. #                  positionning, messages are no longer displayed in history
    16. #                  when they are still on the map
    17. # 02/10/2025: v1.3 added text scroll saving and fixed crash at the end of text
    18. #                  scroll when dialogue history 1.2 stores messages.
    19. # 07/02/2026: v1.3a cleaning code
    20. # 28/03/2026: v1.4 bugfix of multiple messages recorded when parallel process
    21. #                  events are running, renamed methods is_message? and
    22. #                  is_scrolltext? into message? and scrolltext?
    23. #                  Added script option to save the variables and names when
    24. #                  the message is recorded instead of loading the current value
    25. #                  of the variable or name
    26. #==============================================================================
    27. # Description
    28. #------------------------------------------------------------------------------
    29. # Records the last messages, scroll text, choices, numbers entered,
    30. # names given to actors and items selected displays them if necessary or when
    31. # loading a save.
    32. #
    33. # Available script calls:
    34. #
    35. # To start recording:
    36. #   dialogue_recorder.start
    37. #
    38. # To pause the recording:
    39. #   dialogue_recorder.stop
    40. #
    41. # To erase all history:
    42. #   dialogue_recorder.clear
    43. #
    44. # To set or remove the loading of the history when loading the save:
    45. #   dialogue_recorder.enable_load_on_save
    46. #   dialogue_recorder.disable_load_on_save
    47. #
    48. # To display the history:
    49. #   dialogue_recorder.display
    50. #
    51. # You can access the history on the map by pressing a key set in the module.
    52. # To enable or disable the feature, do:
    53. #   dialogue_recorder.access = true
    54. #   dialogue_recorder.access = false
    55. #
    56. # note for scripters: the recorder is set in $game_system.dialogue_recorder,
    57. # the display method is the same as doing
    58. # SceneManager.call(Scene_DialogueHistory)
    59. #==============================================================================
    60. # Term of use: Free to use in free or commercial games if you give credit
    61. #==============================================================================
    62. # Installation & Compatibility: put the script above main, includes
    63. # compatibility with Yanfly's Message System and Yanfly's Save Engine as long
    64. # as you put my script below them.
    65. #==============================================================================
    66. #============================================================================
    67. # DialogueHistory -> Configure the default values here
    68. #============================================================================
    69. module DialogueHistory
    70.   #start recoding at the start of the game?
    71.   INIT_RECORD = true
    72.   #allows to access the history when pressing a key on Scene_Map
    73.   INIT_ACCESS = true
    74.   #activate the display of history when loading a save by default?
    75.   INIT_RECALL = true
    76.   #when loading a save, if history must be displayed but empty, display anyway?
    77.   RECALL_IF_EMPTY = false
    78.   #the key to press to get into the history menu when on the map (works too
    79.   #during messages)
    80.   ACCESS_KEY = :F8
    81.   #what type of things are recorded?
    82.   RECORD_MESSAGES = true
    83.   RECORD_CHOICES = true
    84.   RECORD_NUMBERS = true
    85.   RECORD_NAMES = true
    86.   RECORD_ITEMS = true
    87.   RECORD_SCROLLTEXT = true
    88.   #change the default texts here (message characters supported):
    89.   module Vocab
    90.     HELP_MENU_TEXT = "Dialogue History"
    91.    
    92.     CHOICE_STR = "\\C[1]>>\\C[0] %s" #%s is the name of the choice
    93.     NUMBER_STR = "\\C[1]Entered:\\C[0] %d" #%d is the number chosen
    94.     NAME_STR = "\\C[1]Entered:\\C[0] %s" #%s is the name chosen
    95.     ITEM_STR = "\\C[1]Selected:\\C[0] \\i[%d] %s" #%d icon index, %s item name
    96.   end #Vocab
    97.   #put a positive value above 0 if you want the dialogue history to have limited
    98.   #entries without having to control them, each message, choice, actor's name
    99.   #change, item selected and number entered is a single entry
    100.   MAX_HISTORY = 0
    101.   #pixels per frame for sliding in dialogue history
    102.   SCROLL_SPEED = 5 #when up/down
    103.   SCROLL_SPEED_UP = 20 #when left/right or shift is pressed
    104.   #will save the text as is (following Window_Base) instead of dynamicly
    105.   #loading it, if true, variables and names will be stored as the value they
    106.   #had when recorded, if false, they will change if their values are updated
    107.   #(recommended value is true, false is recomended if script conflict)
    108.   PREPROCESS_TEXT = true
    109. end #DialogueHistory
    110. #============================================================================
    111. # Don't edit anything past this point unless you know what you are doing!
    112. #============================================================================
    113. #============================================================================
    114. # Dialogue_Entry -> parent class for objects in the Dialogue_Recorder list
    115. #============================================================================
    116. class Dialogue_Entry
    117.   #--------------------------------------------------------------------------
    118.   # method: rows -> counts the lines of the history window
    119.   #--------------------------------------------------------------------------
    120.   def rows; 1; end
    121.   #--------------------------------------------------------------------------
    122.   # method: width -> the width of the default history window
    123.   #--------------------------------------------------------------------------
    124.   def width; Graphics.width/2; end
    125.   #--------------------------------------------------------------------------
    126.   # method: text -> gives a string to display on a window, handles special
    127.   # characters
    128.   #--------------------------------------------------------------------------
    129.   def text; ""; end
    130.   #--------------------------------------------------------------------------
    131.   # method: message? -> tests if Message_Entry object
    132.   #--------------------------------------------------------------------------
    133.   def message?; false; end
    134.   #--------------------------------------------------------------------------
    135.   # method: scrolltext? -> tests if ScrollText_Entry object
    136.   #--------------------------------------------------------------------------
    137.   def scrolltext?; false; end
    138.   #--------------------------------------------------------------------------
    139.   # method: valid? -> tests if Dialogue_Entry can be displayed
    140.   #--------------------------------------------------------------------------
    141.   def valid?; true; end
    142.   #--------------------------------------------------------------------------
    143.   # method: preprocess?
    144.   #--------------------------------------------------------------------------
    145.   def preprocess?; DialogueHistory::PREPROCESS_TEXT; end
    146. end #Dialogue_Entry
    147. #============================================================================
    148. # Message_PostData -> stores positionning among other things that can only be
    149. # calculated after the new page was drawn from the previous message, only
    150. # useful for patches like with ATS: Face Options
    151. #============================================================================
    152. class Message_PostData
    153.   attr_accessor :y
    154.   def initialize(msg_window)
    155.     @y = msg_window.y
    156.   end
    157. end #Message_Entry
    158. #============================================================================
    159. # ScrollText_Entry -> stores a message data
    160. #============================================================================
    161. class ScrollText_Entry < Dialogue_Entry
    162.   attr_reader :data, :post_data
    163.   def initialize
    164.     #puts "recording scrolltext..."
    165.     @data = $game_message.dup
    166.     @data.preprocess_text if preprocess?
    167.     @data.choice_proc = nil #to allow saving the data
    168.     @data.background = 2 #no background
    169.     @rows = Window_Base.count_lines(text)#rows
    170.   end
    171.   #--------------------------------------------------------------------------
    172.   # new method: add_message_post_data
    173.   #--------------------------------------------------------------------------
    174.   def add_message_post_data
    175.     @valid = true
    176.   end
    177.   #--------------------------------------------------------------------------
    178.   # override methods: width, rows, text, scrolltext?, valid?
    179.   #--------------------------------------------------------------------------
    180.   def width; Graphics.width; end
    181.   def rows; @rows; end
    182.   def text; @data.all_text; end
    183.   def scrolltext?; true; end
    184.   def valid?; @valid; end
    185. end #ScrollText_Entry
    186. #============================================================================
    187. # Message_Entry -> stores a message data
    188. #============================================================================
    189. class Message_Entry < Dialogue_Entry
    190.   attr_reader :data, :post_data
    191.   def initialize
    192.     #puts "recording msg..."
    193.     @data = $game_message.dup
    194.     @data.preprocess_text if preprocess?
    195.     @data.choice_proc = nil #to allow saving the data
    196.     @rows = 4
    197.     @width = Graphics.width
    198.     if $imported["YEA-MessageSystem"]
    199.       @rows = Variable.message_rows
    200.       @width = Variable.message_width
    201.     end
    202.   end
    203.   #--------------------------------------------------------------------------
    204.   # new method: add_message_post_data
    205.   #--------------------------------------------------------------------------
    206.   def add_message_post_data
    207.     @post_data = $game_temp.message_post_data.dup
    208.     @valid = true
    209.   end
    210.   #--------------------------------------------------------------------------
    211.   # override methods: width, rows, text, message?, valid?
    212.   #--------------------------------------------------------------------------
    213.   def width; @width; end
    214.   def rows; @rows; end
    215.   def text; @data.all_text; end
    216.   def message?; true; end
    217.   def valid?; @valid; end
    218. end #Message_Entry
    219. #============================================================================
    220. # Choice_Entry -> stores a dialogue choice made
    221. #============================================================================
    222. class Choice_Entry < Dialogue_Entry
    223.   def initialize(choices, picked_choice)
    224.     #puts "recording choice..."
    225.     @choices = choices
    226.     @n = picked_choice
    227.   end
    228.   #--------------------------------------------------------------------------
    229.   # override method: text
    230.   #--------------------------------------------------------------------------
    231.   def text
    232.     sprintf(DialogueHistory::Vocab::CHOICE_STR, @choices[@n])
    233.   end
    234. end #Choice_Entry
    235. #============================================================================
    236. # Name_Entry -> stores a name entered
    237. #============================================================================
    238. class Name_Entry < Dialogue_Entry
    239.   def initialize(actor, name)
    240.     #puts "recording name..."
    241.     @actor = actor
    242.     @value = name
    243.   end
    244.   #--------------------------------------------------------------------------
    245.   # override method: text
    246.   #--------------------------------------------------------------------------
    247.   def text
    248.     sprintf(DialogueHistory::Vocab::NAME_STR, @value)
    249.   end
    250. end #Name_Entry
    251. #============================================================================
    252. # Item_Entry -> stores an item selected
    253. #============================================================================
    254. class Item_Entry < Dialogue_Entry
    255.   def initialize(item_id)
    256.     #puts "recording item..."
    257.     @value = item_id
    258.   end
    259.   #--------------------------------------------------------------------------
    260.   # new method: item
    261.   #--------------------------------------------------------------------------
    262.   def item
    263.     $data_items[@value]
    264.   end
    265.   #--------------------------------------------------------------------------
    266.   # override method: text
    267.   #--------------------------------------------------------------------------
    268.   def text
    269.     return sprintf(DialogueHistory::Vocab::ITEM_STR,0,"") if item.nil?
    270.     sprintf(DialogueHistory::Vocab::ITEM_STR, item.icon_index, item.name)
    271.   end
    272. end #Text_Entry
    273. #============================================================================
    274. # Value_Entry -> stores a number entered
    275. #============================================================================
    276. class Value_Entry < Dialogue_Entry
    277.   def initialize(value)
    278.     #puts "recording number..."
    279.     @value = value
    280.   end
    281.   #--------------------------------------------------------------------------
    282.   # override method: text
    283.   #--------------------------------------------------------------------------
    284.   def text
    285.     sprintf(DialogueHistory::Vocab::NUMBER_STR, @value)
    286.   end
    287. end #Value_Entry
    288. #============================================================================
    289. # Dialogue_Recorder -> the history of dialogues and other inputs
    290. #============================================================================
    291. class Dialogue_Recorder
    292.   attr_accessor :record_messages, :record_choices, :record_numbers
    293.   attr_accessor :record_items, :record_names, :record_scrolltext
    294.   attr_accessor :max_history, :access
    295.   #--------------------------------------------------------------------------
    296.   # method: initialize
    297.   #--------------------------------------------------------------------------
    298.   def initialize
    299.     @list = []
    300.     @max_history = DialogueHistory::MAX_HISTORY
    301.     @max_history = nil if @max_history <= 0
    302.     @record = DialogueHistory::INIT_RECORD
    303.     @recall = DialogueHistory::INIT_RECALL
    304.     @access = DialogueHistory::INIT_ACCESS
    305.     #booleans for specific entries:
    306.     @record_messages = DialogueHistory::RECORD_MESSAGES
    307.     @record_choices = DialogueHistory::RECORD_CHOICES
    308.     @record_numbers = DialogueHistory::RECORD_NUMBERS
    309.     @record_items = DialogueHistory::RECORD_ITEMS
    310.     @record_names = DialogueHistory::RECORD_NAMES
    311.     @record_scrolltext = DialogueHistory::RECORD_SCROLLTEXT
    312.   end
    313.   #--------------------------------------------------------------------------
    314.   # methods: start/stop -> to start or stop the saving of the dialogues
    315.   #--------------------------------------------------------------------------
    316.   def start; @record = true; end
    317.   def stop; @record = false; end
    318.   def recording?; @record; end
    319.   #--------------------------------------------------------------------------
    320.   # methods: enable/disable_load_on_save -> to start or stop the trigger
    321.   # of the history scene when loading a save
    322.   #--------------------------------------------------------------------------
    323.   def enable_load_on_save; @recall = true; end
    324.   def disable_load_on_save; @recall = false; end
    325.   def load_on_save?
    326.     @recall && (DialogueHistory::RECALL_IF_EMPTY || !@list.empty?)
    327.   end
    328.   #--------------------------------------------------------------------------
    329.   # method: clear
    330.   #--------------------------------------------------------------------------
    331.   def clear; @list.clear; end
    332.   #--------------------------------------------------------------------------
    333.   # method: add_entry -> stores a Dialogue_Entry object
    334.   #--------------------------------------------------------------------------
    335.   def add_entry(entry)
    336.     @list.push(entry)
    337.     return unless @max_history && @list.size > @max_history
    338.     @list.shift(@list.size - @max_history)
    339.   end
    340.   #--------------------------------------------------------------------------
    341.   # method: list -> gets the valid entries
    342.   #--------------------------------------------------------------------------
    343.   def list
    344.     @list.select{|e| e.valid?}
    345.   end
    346.   #--------------------------------------------------------------------------
    347.   # method: display -> calls the history menu
    348.   #--------------------------------------------------------------------------
    349.   def display
    350.     SceneManager.call(Scene_DialogueHistory)
    351.   end
    352. end #Dialogue_Recorder
    353. #============================================================================
    354. # Game_System
    355. #============================================================================
    356. class Game_System
    357.   attr_reader :dialogue_recorder
    358.   #--------------------------------------------------------------------------
    359.   # alias method: initialize
    360.   #--------------------------------------------------------------------------
    361.   alias tim_dialogue_history_initialize initialize
    362.   def initialize
    363.     @dialogue_recorder = Dialogue_Recorder.new
    364.     tim_dialogue_history_initialize
    365.   end
    366. end #Game_System
    367. #============================================================================
    368. # Game_Temp
    369. #============================================================================
    370. class Game_Temp
    371.   attr_accessor :message_post_data
    372. end #Game_Temp
    373. #============================================================================
    374. # Game_Interpreter
    375. #============================================================================
    376. class Game_Interpreter
    377.   #--------------------------------------------------------------------------
    378.   # alias method: command_101 (messages)
    379.   #--------------------------------------------------------------------------
    380.   alias record_command_101 command_101
    381.   def command_101
    382.     @author = true #this will check if this interpreter is the one writing msg
    383.     record_command_101
    384.     @author = nil
    385.   end
    386.   #--------------------------------------------------------------------------
    387.   # alias method: command_105 (scroll text)
    388.   #--------------------------------------------------------------------------
    389.   alias record_command_105 command_105
    390.   def command_105
    391.     @author = true
    392.     record_command_105
    393.     @author = nil
    394.   end
    395.   #--------------------------------------------------------------------------
    396.   # new method: dialogue_recorder
    397.   #--------------------------------------------------------------------------
    398.   def dialogue_recorder
    399.     $game_system.dialogue_recorder
    400.   end
    401.   #--------------------------------------------------------------------------
    402.   # alias method: wait_for_message -> catches messages and scrolltext
    403.   #--------------------------------------------------------------------------
    404.   alias record_wait_for_message wait_for_message
    405.   def wait_for_message
    406.     unless @author && dialogue_recorder.recording? && $game_message.has_text?
    407.       return record_wait_for_message
    408.     end
    409.     bscroll = $game_message.scroll_mode && dialogue_recorder.record_scrolltext
    410.     bmsg = !$game_message.scroll_mode && dialogue_recorder.record_messages
    411.     return record_wait_for_message unless bscroll || bmsg
    412.     entry = nil
    413.     entry = Message_Entry.new if bmsg
    414.     entry = ScrollText_Entry.new if bscroll
    415.     dialogue_recorder.add_entry(entry)
    416.     record_wait_for_message
    417.     entry.add_message_post_data
    418.   end
    419.   #--------------------------------------------------------------------------
    420.   # alias method: setup_choices -> alters the Proc to add the entry
    421.   # that stores the result
    422.   #--------------------------------------------------------------------------
    423.   alias record_setup_choices setup_choices
    424.   def setup_choices(params)
    425.     record_setup_choices(params)
    426.     old_proc = $game_message.choice_proc
    427.     $game_message.choice_proc = Proc.new do |n|
    428.       if dialogue_recorder.record_choices && dialogue_recorder.recording?
    429.         dialogue_recorder.add_entry(Choice_Entry.new(params[0],n))
    430.       end
    431.       old_proc.call(n)
    432.     end
    433.   end
    434. end #Game_Interpreter
    435. #============================================================================
    436. # Game_Message
    437. #============================================================================
    438. class Game_Message
    439.   #--------------------------------------------------------------------------
    440.   # new method: preprocess_text
    441.   #--------------------------------------------------------------------------
    442.   def preprocess_text
    443.     w = Window_Base.new(0,0,0,0)
    444.     @texts = @texts.map{|txt| w.convert_escape_characters(txt)}
    445.     w.dispose
    446.   end
    447. end #Game_Message
    448. #============================================================================
    449. # Window_Base
    450. #============================================================================
    451. class Window_Base < Window
    452.   #--------------------------------------------------------------------------
    453.   # new class method: count_lines
    454.   #--------------------------------------------------------------------------
    455.   def self.count_lines(text)
    456.     w = Window_Base.new(0,0,0,0)
    457.     c = w.convert_escape_characters(text).lines.count
    458.     w.dispose
    459.     return c
    460.   end
    461. end #Window_NumberInput
    462. #============================================================================
    463. # Window_NumberInput
    464. #============================================================================
    465. class Window_NumberInput < Window_Base
    466.   #--------------------------------------------------------------------------
    467.   # alias method: process_ok for input number
    468.   #--------------------------------------------------------------------------
    469.   alias record_process_ok process_ok
    470.   def process_ok
    471.     n = @number
    472.     record_process_ok
    473.     if $game_system.dialogue_recorder.record_numbers &&
    474.         $game_system.dialogue_recorder.recording?
    475.       $game_system.dialogue_recorder.add_entry(Value_Entry.new(n))
    476.     end
    477.   end
    478. end #Window_NumberInput
    479. #============================================================================
    480. # Window_KeyItem
    481. #============================================================================
    482. class Window_KeyItem < Window_ItemList
    483.   #--------------------------------------------------------------------------
    484.   # alias method: on_input_ok for input items
    485.   #--------------------------------------------------------------------------
    486.   alias record_on_ok on_ok
    487.   def on_ok
    488.     record_on_ok
    489.     item_id = $game_variables[$game_message.item_choice_variable_id]
    490.     if $game_system.dialogue_recorder.record_items &&
    491.         $game_system.dialogue_recorder.recording?
    492.       $game_system.dialogue_recorder.add_entry(Item_Entry.new(item_id))
    493.     end
    494.   end
    495.   #--------------------------------------------------------------------------
    496.   # alias method: on_input_ok for input items
    497.   #--------------------------------------------------------------------------
    498.   alias record_on_cancel on_cancel
    499.   def on_cancel
    500.     record_on_cancel
    501.     item_id = $game_variables[$game_message.item_choice_variable_id]
    502.     if $game_system.dialogue_recorder.record_items &&
    503.         $game_system.dialogue_recorder.recording?
    504.       $game_system.dialogue_recorder.add_entry(Item_Entry.new(item_id))
    505.     end
    506.   end
    507. end #Window_KeyItem
    508. #============================================================================
    509. # Window_Message
    510. #============================================================================
    511. class Window_Message < Window_Base
    512.   #--------------------------------------------------------------------------
    513.   # alias method: new_page -> saves the post-data in a temporary object
    514.   #--------------------------------------------------------------------------
    515.   alias record_new_page new_page
    516.   def new_page(text, pos)
    517.     record_new_page(text,pos)
    518.     $game_temp.message_post_data = Message_PostData.new(self)
    519.   end
    520. end #Window_Message
    521. #============================================================================
    522. # Scene_Name
    523. #============================================================================
    524. class Scene_Name < Scene_MenuBase
    525.   #--------------------------------------------------------------------------
    526.   # alias method: on_input_ok for input name
    527.   #--------------------------------------------------------------------------
    528.   alias record_on_input_ok on_input_ok
    529.   def on_input_ok
    530.     if $game_system.dialogue_recorder.record_names &&
    531.         $game_system.dialogue_recorder.recording?
    532.       entry = Name_Entry.new(@actor, @edit_window.name)
    533.       $game_system.dialogue_recorder.add_entry(entry)
    534.     end
    535.     record_on_input_ok
    536.   end
    537. end #Scene_Name
    538. #============================================================================
    539. # Scene_Map
    540. #============================================================================
    541. class Scene_Map < Scene_Base
    542.   #--------------------------------------------------------------------------
    543.   # alias method: update
    544.   #--------------------------------------------------------------------------
    545.   alias record_update update
    546.   def update
    547.     record_update
    548.     update_message_history unless scene_changing?
    549.   end
    550.   #--------------------------------------------------------------------------
    551.   # new method: update_message_history
    552.   #--------------------------------------------------------------------------
    553.   def update_message_history
    554.     return unless $game_system.dialogue_recorder.access &&
    555.                   Input.press?(DialogueHistory::ACCESS_KEY)
    556.     $game_system.dialogue_recorder.display
    557.   end
    558. end #Scene_Map
    559. #============================================================================
    560. # Scene_File & Scene_Load
    561. #============================================================================
    562. if $imported["YEA-SaveEngine"]
    563.   class Scene_File < Scene_MenuBase
    564.     #--------------------------------------------------------------------------
    565.     # alias method: on_load_success
    566.     #--------------------------------------------------------------------------
    567.     alias record_on_load_success on_load_success
    568.     def on_load_success
    569.       record_on_load_success
    570.       return unless $game_system.dialogue_recorder.load_on_save?
    571.       $game_system.dialogue_recorder.display
    572.     end
    573.   end #Scene_File
    574. else #no save engine
    575.   class Scene_Load < Scene_File
    576.     #--------------------------------------------------------------------------
    577.     # alias method: on_load_success
    578.     #--------------------------------------------------------------------------
    579.     alias record_on_load_success on_load_success
    580.     def on_load_success
    581.       record_on_load_success
    582.       return unless $game_system.dialogue_recorder.load_on_save?
    583.       $game_system.dialogue_recorder.display
    584.     end
    585.   end #Scene_Load
    586. end #$imported["YEA-SaveEngine"]
    587. #============================================================================
    588. # Window_NameMessage
    589. #============================================================================
    590. if $imported["YEA-MessageSystem"]
    591. class Window_NameMessage < Window_Base
    592.   #--------------------------------------------------------------------------
    593.   # alias method: initialize
    594.   #--------------------------------------------------------------------------
    595.   alias record_winname_initialize initialize
    596.   def initialize(message_window)
    597.     @entry = message_window.entry if message_window.is_a?(Window_DialogueEntry)
    598.     record_winname_initialize(message_window)
    599.   end
    600.   #--------------------------------------------------------------------------
    601.   # alias method: set_y_position
    602.   #--------------------------------------------------------------------------
    603.   alias record_set_y_position set_y_position
    604.   def set_y_position
    605.     return  record_set_y_position unless @entry && @entry.message?
    606.     self.y = @message_window.y - self.height
    607.     self.y += YEA::MESSAGE::NAME_WINDOW_Y_BUFFER
    608.   end
    609. end #Window_NameMessage
    610. end #$imported["YEA-MessageSystem"]
    611. #============================================================================
    612. # Window_DialogueEntry
    613. #============================================================================
    614. class Window_DialogueEntry < Window_Message
    615.   attr_reader   :entry
    616.   #--------------------------------------------------------------------------
    617.   # override method: initialize
    618.   # entry is a Dialogue_Entry object
    619.   # index the position of the message in the history
    620.   #--------------------------------------------------------------------------
    621.   def initialize(entry, index)
    622.     @entry = entry
    623.     @index = index
    624.     super()
    625.     self.x = (Graphics.width - self.width)/2
    626.     process_all_text
    627.   end
    628.   #--------------------------------------------------------------------------
    629.   # override method: window_height (restoring behavior if overwritten by
    630.   # Yanfly's message system)
    631.   #--------------------------------------------------------------------------
    632.   def window_height
    633.     return fitting_height(visible_line_number)
    634.   end
    635.   #--------------------------------------------------------------------------
    636.   # override method: window_width
    637.   #--------------------------------------------------------------------------
    638.   def window_width
    639.     @entry.width
    640.   end
    641.   #--------------------------------------------------------------------------
    642.   # new method: total_height (counts additional windows like name window if
    643.   # Yanfly's message system is used)
    644.   #--------------------------------------------------------------------------
    645.   def total_height
    646.     top_h + height + bottom_h
    647.   end
    648.   #--------------------------------------------------------------------------
    649.   # new method: offset_y -> for the parent to know where to put this window
    650.   # after the last one
    651.   #--------------------------------------------------------------------------
    652.   def offset_y
    653.     top_h
    654.   end
    655.   #--------------------------------------------------------------------------
    656.   # new method: active_window_list (takes care of additional windows)
    657.   #--------------------------------------------------------------------------
    658.   def active_window_list
    659.     wl = [self]
    660.     if $imported["YEA-MessageSystem"] && !@name_text.empty?
    661.       wl.push(@name_window)
    662.     end
    663.     return wl
    664.   end
    665.   #--------------------------------------------------------------------------
    666.   # new method: top_h -> height above the message window
    667.   #--------------------------------------------------------------------------
    668.   def top_h
    669.     active_window_list.collect{|w| self.y - w.y}.max
    670.   end
    671.   #--------------------------------------------------------------------------
    672.   # new method: bottom_h -> height below the message window
    673.   #--------------------------------------------------------------------------
    674.   def bottom_h
    675.     active_window_list.collect{|w| (w.y+w.height) - (self.y+height)}.max
    676.   end
    677.   #--------------------------------------------------------------------------
    678.   # override method: visible_line_number -> dynamic line numbers, compatible
    679.   # with Yanfly's message system
    680.   #--------------------------------------------------------------------------
    681.   def visible_line_number
    682.     return @entry.rows
    683.   end
    684.   #--------------------------------------------------------------------------
    685.   # override methods: wait, wait_for_one_character, update_fiber, input_pause
    686.   # -> removes any notion of time or user input
    687.   #--------------------------------------------------------------------------
    688.   def wait(duration); end
    689.   def wait_for_one_character; end
    690.   def update_fiber; end
    691.   def input_pause; end
    692.   #--------------------------------------------------------------------------
    693.   # override method: process_all_text -> text is now set by @entry
    694.   #--------------------------------------------------------------------------
    695.   def process_all_text
    696.     clear_name_window if $imported["YEA-MessageSystem"]
    697.     open
    698.     text = convert_escape_characters(@entry.text)
    699.     pos = {}
    700.     new_page(text, pos)
    701.     process_character(text.slice!(0, 1), text, pos) until text.empty?
    702.   end
    703.   #--------------------------------------------------------------------------
    704.   # new method: face_offset_x -> define the offset made by the face
    705.   #--------------------------------------------------------------------------
    706.   def face_offset_x
    707.     $imported["YEA-MessageSystem"] ? YEA::MESSAGE::FACE_INDENT_X : 112
    708.   end
    709.   #--------------------------------------------------------------------------
    710.   # override method: new_line_x -> face presence defined by @entry
    711.   #--------------------------------------------------------------------------
    712.   def new_line_x
    713.     !@entry.message? || @entry.data.face_name.empty? ? 0 : face_offset_x
    714.   end
    715.   #--------------------------------------------------------------------------
    716.   # override method: update_background -> background is defined by @entry
    717.   #--------------------------------------------------------------------------
    718.   def update_background
    719.     if @entry.message? || @entry.scrolltext?
    720.       @background = @entry.data.background
    721.     end
    722.     self.opacity = @background == 0 ? 255 : 0
    723.   end
    724.   #--------------------------------------------------------------------------
    725.   # override method: viewport= -> sets the viewport of the background too
    726.   #--------------------------------------------------------------------------
    727.   def viewport=(v)
    728.     super
    729.     @back_sprite.viewport = v
    730.     @name_window.viewport = v if $imported["YEA-MessageSystem"]
    731.   end
    732.   #--------------------------------------------------------------------------
    733.   # override method: y=
    734.   #--------------------------------------------------------------------------
    735.   def y=(new_y)
    736.     super
    737.     @name_window.set_y_position if $imported["YEA-MessageSystem"]
    738.   end
    739.   #--------------------------------------------------------------------------
    740.   # override method: new_page -> refers to @entry instead of $game_message
    741.   #--------------------------------------------------------------------------
    742.   def new_page(text, pos)
    743.     update_background
    744.     adjust_message_window_size if $imported["YEA-MessageSystem"]
    745.     contents.clear
    746.     if @entry.message?
    747.       draw_face(@entry.data.face_name, @entry.data.face_index, 0, 0)
    748.     end
    749.     reset_font_settings
    750.     pos[:x] = new_line_x
    751.     pos[:y] = 0
    752.     pos[:new_x] = new_line_x
    753.     pos[:height] = calc_line_height(text)
    754.     clear_flags
    755.   end
    756.   #--------------------------------------------------------------------------
    757.   # override method: process_escape_character
    758.   #--------------------------------------------------------------------------
    759.   def process_escape_character(code, text, pos)
    760.     case code.upcase
    761.     when '$'
    762.       #do nothing
    763.     else
    764.       super
    765.     end
    766.   end
    767. end #Window_DialogueEntry
    768. #============================================================================
    769. # Scene_DialogueHistory
    770. #============================================================================
    771. class Scene_DialogueHistory < Scene_MenuBase
    772.   #--------------------------------------------------------------------------
    773.   # override method: start
    774.   #--------------------------------------------------------------------------
    775.   def start
    776.     super
    777.     create_help_window
    778.     create_history_viewport
    779.     create_history_windows
    780.   end
    781.   #--------------------------------------------------------------------------
    782.   # override method: terminate
    783.   #--------------------------------------------------------------------------
    784.   def terminate
    785.     super
    786.     @history_windows.each {|window| window.dispose }
    787.     @history_viewport.dispose
    788.   end
    789.   #--------------------------------------------------------------------------
    790.   # override method: create_help_window
    791.   #--------------------------------------------------------------------------
    792.   def create_help_window
    793.     @help_window = Window_Help.new(1)
    794.     @help_window.viewport = @viewport
    795.     @help_window.set_text(help_window_text)
    796.   end
    797.   #--------------------------------------------------------------------------
    798.   # new method: help_window_text
    799.   #--------------------------------------------------------------------------
    800.   def help_window_text
    801.     DialogueHistory::Vocab::HELP_MENU_TEXT
    802.   end
    803.   #--------------------------------------------------------------------------
    804.   # new method: create_history_viewport
    805.   #--------------------------------------------------------------------------
    806.   def create_history_viewport
    807.     @history_viewport = Viewport.new
    808.     @history_viewport.rect.y = @help_window.height
    809.     @history_viewport.rect.height -= @help_window.height
    810.   end
    811.   #--------------------------------------------------------------------------
    812.   # new method: create_history_windows
    813.   #--------------------------------------------------------------------------
    814.   def create_history_windows
    815.     l = $game_system.dialogue_recorder.list
    816.     @history_windows = Array.new(l.size) do |i|
    817.       Window_DialogueEntry.new(l[i],i)
    818.     end
    819.     y = 0
    820.     @history_windows.each do |w|
    821.       w.viewport = @history_viewport
    822.       w.y = y + w.offset_y
    823.       y += w.total_height
    824.     end
    825.     @total_height = y
    826.   end
    827.   #--------------------------------------------------------------------------
    828.   # override method: update
    829.   #--------------------------------------------------------------------------
    830.   def update
    831.     super
    832.     @history_windows.each {|window| window.update }
    833.     update_window_selection
    834.   end
    835.   #--------------------------------------------------------------------------
    836.   # new method: item_max
    837.   #--------------------------------------------------------------------------
    838.   def item_max
    839.     $game_system.dialogue_recorder.list.size
    840.   end
    841.   #--------------------------------------------------------------------------
    842.   # new method: move_viewport
    843.   #--------------------------------------------------------------------------
    844.   def move_viewport(diff)
    845.     y = @history_viewport.oy + diff
    846.     max_oy = @total_height-@history_viewport.rect.height
    847.     @history_viewport.oy = [0,[y, max_oy].min].max
    848.   end
    849.   #--------------------------------------------------------------------------
    850.   # new method: update_window_selection
    851.   #--------------------------------------------------------------------------
    852.   def update_window_selection
    853.     return on_ok     if Input.trigger?(:C)
    854.     return on_cancel if Input.trigger?(:B)
    855.     update_cursor
    856.   end
    857.   #--------------------------------------------------------------------------
    858.   # new method: on_ok
    859.   #--------------------------------------------------------------------------
    860.   def on_ok
    861.     Sound.play_cancel
    862.     return_scene
    863.   end
    864.   #--------------------------------------------------------------------------
    865.   # new method: on_cancel
    866.   #--------------------------------------------------------------------------
    867.   def on_cancel
    868.     Sound.play_cancel
    869.     return_scene
    870.   end
    871.   #--------------------------------------------------------------------------
    872.   # new method: update_cursor
    873.   #--------------------------------------------------------------------------
    874.   def update_cursor
    875.     return if @history_windows.empty?
    876.     cursor_down if Input.press?(:DOWN)
    877.     cursor_up if Input.press?(:UP)
    878.     cursor_left if Input.press?(:LEFT)
    879.     cursor_right if Input.press?(:RIGHT)
    880.   end
    881.   #--------------------------------------------------------------------------
    882.   # new method: cursor_down
    883.   #--------------------------------------------------------------------------
    884.   def cursor_down
    885.     speed = DialogueHistory::SCROLL_SPEED
    886.     speed = DialogueHistory::SCROLL_SPEED_UP if Input.press?(:SHIFT)
    887.     move_viewport(speed)
    888.   end
    889.   #--------------------------------------------------------------------------
    890.   # new method: cursor_up
    891.   #--------------------------------------------------------------------------
    892.   def cursor_up
    893.     speed = DialogueHistory::SCROLL_SPEED
    894.     speed = DialogueHistory::SCROLL_SPEED_UP if Input.press?(:SHIFT)
    895.     move_viewport(-speed)
    896.   end
    897.   #--------------------------------------------------------------------------
    898.   # new method: cursor_right
    899.   #--------------------------------------------------------------------------
    900.   def cursor_right
    901.     move_viewport(DialogueHistory::SCROLL_SPEED_UP)
    902.   end
    903.   #--------------------------------------------------------------------------
    904.   # new method: cursor_left
    905.   #--------------------------------------------------------------------------
    906.   def cursor_left
    907.     move_viewport(-DialogueHistory::SCROLL_SPEED_UP)
    908.   end
    909. end #Scene_DialogueHistory
    复制代码


    Version History
    v1.4 should fix the multi record bug with parallel process events, it also now stores the values of the dynamic message data (variables, actor's names etc.) instead of reloading their value. The compatibility patch with ATS was updated to fit the update.

    Compatibility
    Natively compatible with Yanfly's Message System and Yanfly's Save Engine (put my script below them)
    Requires a patch to work with ATS: Face Options by modern algebra.

    Term of use
    Free to use in any game, please give credit.


    本贴来自国际rpgmaker官方论坛作者:Timtrack处,因国际论坛即将永久关站,为了存档多年珍贵资料,署名转载到本论坛存档,由于官方帖子为英文原帖,需要中文翻译请点击论坛顶部切换语言为中文就可以将帖子翻译成中文浏览,方便大家随时查看,原文地址:https://forums.rpgmakerweb.com/threads/dialogue-history-v1-4.182386/

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    简体中文
    繁體中文
    English(英语)
    日本語(日语)
    Deutsch(德语)
    Русский язык(俄语)
    بالعربية(阿拉伯语)
    Türkçe(土耳其语)
    Português(葡萄牙语)
    ภาษาไทย(泰国语)
    한어(朝鲜语/韩语)
    Français(法语)
    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-8-8 07:55 , Processed in 0.067330 second(s), 55 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回复 返回顶部 返回列表