じ☆ve冰风 发表于 2026-8-3 07:22:19

Single Quest Title ACE

Single Quest Title ACE

by Kyonides​

Introduction

A forumer once asked any of the available scripters to come up with a way to show the current quest's title on screen the same way the map name is displayed on the map.

Well, now it is possible!
data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7

The user also wanted to use some game variables that I hate a lot, but there is one that will hold the title until it gets replaced by a new one.

Here are the list of available Constants:

[*]HIDE_WHEN_ZERO - true or false
[*]SWITCH_ID - switch in charge or showing or hiding the quest title window
[*]VAR_ID - variable holding the quest title
[*]WINDOW_X, WINDOW_Y, WINDOW_WIDTH and WINDOW_HEIGHT constants are self evident.

This script has only 2 script calls, the second one is usually optional.

[*]Set New Title:
new_quest_title("Quest Name")
[*]Repeat the Most Recent Title:
repeat_quest_title!
The Script

                Ruby:       
# * Single Quest Title ACE * #
#Scripter : Kyonides Arkanthes
#2023-05-21

# This scriptlet lets you show the Current Quest Title on the map using a
# given Game Variable. The state of a certain Game Switch determines
# whether or not the window will be visible on screen.

# * Script Calls * #

# - Set New Title
# new_quest_title("Quest Name")

# - Repeat the Most Recent Title
# repeat_quest_title!

module SingleQuest
HIDE_WHEN_ZERO = nil
SWITCH_ID = 1
VAR_ID = 1
WINDOW_X = 0
WINDOW_Y = 0
WINDOW_WIDTH = 240
WINDOW_HEIGHT = 56

class TitleWindow < Window_Base
include SingleQuest
def initialize
    super(WINDOW_X, WINDOW_Y, window_width, WINDOW_HEIGHT)
    $game_variables = "" if $game_variables == 0
    self.opacity = 0
    self.contents_opacity = 0
    @back_color1 = Color.new(0, 0, 0, 192)
    @back_color2 = Color.new(0, 0, 0, 0)
    @show_count = 0
    refresh
end

def window_width
    Graphics.width - WINDOW_WIDTH
end

def refresh
    contents.clear
    return if $game_variables.empty?
    rect = contents.rect
    draw_background(rect)
    draw_text(rect, $game_variables)
end

def draw_background(rect)
    temp_rect = rect.dup
    temp_rect.width /= 2
    contents.gradient_fill_rect(temp_rect, @back_color2, @back_color1)
    temp_rect.x = temp_rect.width
    contents.gradient_fill_rect(temp_rect, @back_color1, @back_color2)
end

def update_fadein
    self.contents_opacity += 16
end

def update_fadeout
    self.contents_opacity -= 16
end

def update
    super
    self.visible = $game_switches
    if self.visible && @show_count > 0
      update_fadein
      @show_count -= 1
    elsif HIDE_WHEN_ZERO
      update_fadeout
    end
end

def open
    refresh
    @show_count = 150
    self.contents_opacity = 0
    self
end

def close
    @show_count = 0
    self
end
end

end

module SceneManager
extend self
attr_accessor :quest_window
end

class Game_Interpreter
def new_quest_title(title)
    $game_variables = title
    repeat_quest_title!
end

def repeat_quest_title!
    SceneManager.quest_window.open
end
end

class Scene_Map
alias :kyon_single_quest_scn_map_create_all_win :create_all_windows
def create_all_windows
    kyon_single_quest_scn_map_create_all_win
    make_single_quest_window
end

def make_single_quest_window
    @quest_window = SingleQuest::TitleWindow.new
    SceneManager.quest_window = @quest_window
    @quest_window.open
end
attr_reader :quest_window
end


Terms & Conditions

Free for use in any game.
Include my nickname in your game credits.
Don't adopt stray cats nor sleeping beauties nor undead fans nor blue squirrels even if they desperately need to drink a cup of coffee!
That's it!


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