じ☆ve冰风 发表于 3 天前

KDiurnalis VX

KDiurnalis VX
version 1.0.5
by Kyonides Arkanthes​


Introduction

This is a Party's Journal Script!

Tweak this script's CONSTANTS in order to customize the Journal Menu's GUI.
You can find them under the KDiurnalis module.

There are two ways to open the Journal Menu.
$scene = KDiurnalis::Scene.new
KDiurnalis.open!

To learn more about how to use my script please read the instructions embedded in it.

Notes:

The demo includes examples of how you can easily add entry lines to an existing date.
It will automatically create a new date entry if the current date is different from the previous one.

Now it features stuff like automatic substitutions of tags like \n or \e!

The Script

                Ruby:       
# * KDiurnalis VX#   Scripter : Kyonides Arkanthes#   v 1.0.5 - 2022-06-16# * Non Plug & Play Script * ## The Party's Journal Script!# Tweak this script's CONSTANTS in order to customize the Journal Menu's GUI.# You can find them under the KDiurnalis module.# * Overwritten Method * ## Scene_File#do_load# * Script Calls * ## - Open Journal Scene - 2 Options# $scene = KDiurnalis::Scene.new# KDiurnalis.open!# - Add New Journal Page Steps - ## -- Step 1# Location: can be replaced with a "String" or :map for current map name.# $game_party.add_journal_entry("Title", Location)# -- Step 2# Add as many Message Windows and lines of text as you wish!# -- Step 3# - Stop Using Message Windows as Journal Entry's Page Contents# Simply stop adding any more message windows!module KDiurnalisLOAD_OPENS_JOURNAL = trueSHOW_DATES = nil# Place the Backdrop in the Pictures directory.# Options: "Filename" or nilBACKDROP = "backdrop circles blue"TITLE = "%s's Journal"TITLE_ALIGN = 1NO_ENTRY = "No Entry Found"module Start    TITLE = "My New Adventure"    LOCATION = "Home"    TEXT = []    TEXT << "My history begins today."    TEXT << "I am very excited indeed."endPAGES_FOUND = "%s Pages Found"PAGES_LABEL = "Page %s/%s"PAGES_LABEL_ALIGN = 2HELP_WIN_OPACITY = 160# Window's Coordinates = LIST_WIN_COORD= DUMMY_WIN_COORD = INFO_WIN_COORD= # * End of Setup * #extend selfattr_accessor :use_message_windowdef open!() $scene = Scene.new enddef after_load_scene    LOAD_OPENS_JOURNAL ? open! : $scene = Scene_Map.newenddef end_of_entry!() @use_message_window = nil endalias :end_of_message! :end_of_entry!class KDJournaldef initialize    @dates = []    date = KDDate.new    entry = KDEntry.new(Start::TITLE.dup)    entry.location = Start::LOCATION    entry.texts = Start::TEXT.dup    date.add_entry(entry)    add_date(date)enddef add_date(date)    @dates.unshift(date)    @last_date = dateenddef map(&blk) @dates.map(&blk) enddef last() @dates[-1] enddef [](pos) @dates enddef empty?() @dates.empty? enddef any?() @dates.any? enddef size() @dates.size endattr_reader :dates, :last_dateendclass KDDatedef initialize    time = Time.now    @year = time.year    @month = time.month    @month_name = time.strftime("%b")    @day = time.mday    @day_name = time.strftime("%a")    @title = "#{@month_name} #{@day}, #{@year}"    @entries = []enddef same_date?(nyear, nmonth, nday)    nyear == @year && nmonth == @month && nday == @dayenddef add_entry(entry)    @entries << entry    @last_entry = entryendattr_reader :year, :month, :month_name, :day, :day_name, :entries, :last_entryattr_accessor :titleendclass KDEntrydef initialize(new_title)    @title = new_title    @location = ""    @texts = []endattr_reader :titleattr_accessor :texts, :locationendclass KDHelpWindow < Window_Basedef initialize    x, w = 80, Graphics.width    super(x, 12, w - x * 2, 56)enddef set_text(text, align=0)    return if text == @text or align == @align    @text = text    @align = align    refreshenddef refresh    contents.clear    contents.draw_text(0, 0, width - 32, 24, @text, @align)endendclass KDListWindow < Window_Selectabledef initialize(wx, wy, w, h)    @data = []    super    @data = $game_party.journal_entries    refresh    @index = 0enddef draw_item(index)    item = @data    rect = item_rect(index)    rect.x += 4    rect.width -= 8    contents.draw_text(rect, item.title)enddef refresh    create_contents    item_max.times{|i| draw_item(i) }enddef update_help() @help_window.index = @index enddef item_max() @data.any? ? @data.size : 1 enddef item() @data[@index] endendclass KDDummyWindow < Window_Basedef initialize(wx, wy, w, h)    super    @index = 0    refreshenddef refresh    contents.clear    date = $game_party.journal_entries[@index]    pages = sprintf(PAGES_FOUND, date.entries.size)    contents.draw_text(0, 0, width - 32, 24, pages)enddef index=(pos)    return if @index == pos    @index = pos    refreshendendclass KDInfoWindow < Window_Basedef show_entries(entry)    self.visible = true    @entries = entry    @total = @entries.size    @index = @total - 1    @entry = @entries.last    refreshenddef refresh    contents.clear    w = width - 32    f = contents.font    f.bold = true    contents.draw_text(0, 0, w, 24, @entry.title, 1)    contents.draw_text(4, 32, w, 24, @entry.location)    f.bold = false    ly = 64    @entry.texts.each do |text|      contents.draw_text(4, ly, w, 24, text)      ly += 24    end    ly = height - 56    pages = sprintf(PAGES_LABEL, @index + 1, @entries.size)    contents.draw_text(0, ly, w, 24, pages, PAGES_LABEL_ALIGN)enddef update    if Input.trigger?(Input::LEFT)      return Sound.play_buzzer if @total == 1      Sound.play_cursor      @index = (@index - 1) % @total      @entry = @entries[@index]      refresh      return    elsif Input.trigger?(Input::RIGHT)      return Sound.play_buzzer if @total == 1      Sound.play_cursor      @index = (@index + 1) % @total      @entry = @entries[@index]      refresh    endenddef clear() contents.clear endendclass Scene < Scene_Basedef start    @stage = SHOW_DATES ? :list : :info    lx, ly, lw, lh, lbo = LIST_WIN_COORD    dx, dy, dw, dh, dbo = DUMMY_WIN_COORD    ix, iy, iw, ih, ibo = INFO_WIN_COORD    @backdrop = Sprite.new    if BACKDROP      @backdrop.bitmap = Cache.picture(BACKDROP).dup    else      @backdrop.bitmap = SceneManager.background_bitmap      @backdrop.color.set(16, 16, 16, 128)    end    @help_window = KDHelpWindow.new    text = sprintf(TITLE, $game_party.name)    @help_window.set_text(text, TITLE_ALIGN)    @help_window.back_opacity = HELP_WIN_OPACITY    @list_window = KDListWindow.new(lx, ly, lw, lh)    @list_window.back_opacity = lbo    @list_window.visible = SHOW_DATES    @dummy_window = KDDummyWindow.new(dx, dy, dw, dh)    @dummy_window.back_opacity = dbo    @dummy_window.visible = SHOW_DATES    @list_window.help_window = @dummy_window    @info_window = KDInfoWindow.new(ix, iy, iw, ih)    @info_window.back_opacity = ibo    @info_window.visible = !SHOW_DATES    open_last_entryenddef open_last_entry    if SHOW_DATES      date = @list_window.item      @info_window.show_entries(date.entries)    else      entries = $game_party.journal_entries.map{|date| date.entries }      entries = entries.flatten      @info_window.show_entries(entries)    end    @stage = :infoenddef terminate    @help_window.dispose    @list_window.dispose    @dummy_window.dispose    @info_window.dispose    @backdrop.bitmap.dispose    @backdrop.disposeenddef update    case @stage    when :list      update_list    when :info      update_info    endenddef update_list    @list_window.update    if Input.trigger?(Input::B)      Sound.play_cancel      $scene = Scene_Map.new      return    elsif Input.trigger?(Input::C)      Sound.play_decision      @dummy_window.visible = false      open_last_entry    endenddef update_info    @info_window.update    if Input.trigger?(Input::B)      Sound.play_cancel      unless SHOW_DATES      $scene = Scene_Map.new      return      end      @info_window.visible = false      @info_window.clear      @dummy_window.visible = true      @stage = :list    endendendendclass Game_Partyalias :kyon_diurnalis_gm_pty_init :initializedef initialize    kyon_diurnalis_gm_pty_init    @journal_entries = KDiurnalis::KDJournal.newenddef add_journal_entry(title, place)    place = $game_map.map_name if place == :map    date = @journal_entries.last_date    time = Time.now    KDiurnalis.use_message_window = true    entry = KDiurnalis::KDEntry.new(title)    entry.location = place    if date and date.same_date?(time.year, time.month, time.day)      date.add_entry(entry)    else      date = KDiurnalis::KDDate.new      date.add_entry(entry)      @journal_entries.add_date(date)    endenddef total_journal_entries?(n)    @journal_entries.size == nenddef last_journal_entry_pages?(n)    @journal_entries.last.entries.size == nendattr_reader :journal_entriesendclass Game_Mapalias :kyon_diurnalis_gm_map_setup :setupdef setup(map_id)    kyon_diurnalis_gm_map_setup(map_id)    @map_name = load_data("Data/MapInfos.rvdata").nameendattr_reader :map_nameendclass Game_Eventdef name() @event.name enddef name=(text) @event.name = text endendclass Game_Interpreteralias :kyon_diurnalis_gm_int_comm_101 :command_101def process_journal_entries    date = $game_party.journal_entries.last_date    entry = date.last_entry    codes =     command = @list[@index]    while codes.include?(command.code)      line = command.parameters      line.gsub!(/\\N\[(+)\]/i) { $game_actors[$1.to_i].name }      line.gsub!(/\\E\[(+)\]/i) { $game_map.events[$1.to_i].name }      entry.texts << line if command.code == 401      @index += 1      command = @list[@index]    end    KDiurnalis.end_of_message!    falseenddef command_101    if KDiurnalis.use_message_window      process_journal_entries    else      kyon_diurnalis_gm_int_comm_101    endendendclass Scene_Filedef do_load    file = File.open(@savefile_windows[@index].filename, "rb")    read_save_data(file)    file.close    KDiurnalis.after_load_scene    RPG::BGM.fade(1500)    Graphics.fadeout(60)    Graphics.wait(40)    return if KDiurnalis.show_last_entry    @last_bgm.play    @last_bgs.playendend



DOWNLOAD DEMO​

Terms & Conditions

Free as in beer for non commercial games.
Contact me if you want to go commercial. (There will be an inexpensive charge for this script only.)


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