1298 lines
40 KiB
Ruby
1298 lines
40 KiB
Ruby
$titleCreateActorReq = true
|
||||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** System_NotificationOverlay - JS-стиль уведомления внутри игры
|
|||
|
|
#==============================================================================
|
|||
|
|
module System_NotificationOverlay
|
|||
|
|
# FONT_FILE = "Fonts/Euxoi.ttf" #- # Print () 2026.02.26 шрифты загружаются при запуске клиента, поэтому удаляем
|
|||
|
|
|
|||
|
|
FONT_NAME = ((defined?(FONT_MOD) && FONT_MOD.const_defined?(:TITLE_MENU)) ? FONT_MOD::TITLE_MENU : (Font.default_name rescue (System_Settings::MESSAGE_WINDOW_FONT_NAME rescue "VL Gothic"))) #"Euxoi" # Print () 2026.02.26 у меня системный шрифт - Unifont
|
|||
|
|
FONT_SIZE = 16 #10 # Print () 2026.02.26 размер Unifont это 16
|
|||
|
|
|
|||
|
|
WIDTH = 240
|
|||
|
|
HEIGHT = 56
|
|||
|
|
MARGIN_RIGHT = 10
|
|||
|
|
MARGIN_TOP = 10
|
|||
|
|
SPACING = 10
|
|||
|
|
LIFE_TIME = 3000 # 3 секунды
|
|||
|
|
FADE_TIME = 400 # время исчезновения
|
|||
|
|
SLIDE_IN_TIME = 300 # время появления
|
|||
|
|
MAX_NOTIFICATIONS = 3
|
|||
|
|
DEDUP_FRAMES = 180
|
|||
|
|
|
|||
|
|
# Радужные цвета для анимации рамки
|
|||
|
|
RAINBOW_COLORS = [
|
|||
|
|
Color.new(255, 0, 0), # Красный
|
|||
|
|
Color.new(255, 127, 0), # Оранжевый
|
|||
|
|
Color.new(255, 255, 0), # Желтый
|
|||
|
|
Color.new(0, 255, 0), # Зеленый
|
|||
|
|
Color.new(0, 127, 255), # Голубой
|
|||
|
|
Color.new(0, 0, 255), # Синий
|
|||
|
|
Color.new(127, 0, 255), # Фиолетовый
|
|||
|
|
Color.new(255, 0, 127) # Розовый
|
|||
|
|
]
|
|||
|
|
|
|||
|
|
# legacy Windows font registration path removed for mkxp-z / Ruby 3
|
|||
|
|
class Notification
|
|||
|
|
attr_reader :dead, :target_y
|
|||
|
|
|
|||
|
|
def initialize(text, type = :info)
|
|||
|
|
@text = text.to_s
|
|||
|
|
@type = type
|
|||
|
|
@created_at = current_time
|
|||
|
|
@dead = false
|
|||
|
|
@x = Graphics.width # Начинаем за правым краем
|
|||
|
|
@target_x = Graphics.width - WIDTH - MARGIN_RIGHT
|
|||
|
|
@y = 0
|
|||
|
|
@alpha = 255
|
|||
|
|
@color_phase = 0.0
|
|||
|
|
|
|||
|
|
create_bitmap
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def current_time
|
|||
|
|
(Graphics.frame_count * 1000.0 / Graphics.frame_rate).to_i
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def create_bitmap
|
|||
|
|
@bitmap = Bitmap.new(WIDTH, HEIGHT)
|
|||
|
|
@bitmap.font.name = System_NotificationOverlay::FONT_NAME #"Euxoi" # Print () 2026.02.26 зачем мы обьявляли константы если не используем?
|
|||
|
|
@bitmap.font.size = System_NotificationOverlay::FONT_SIZE #18 # Print () 2026.02.26 тоже самое
|
|||
|
|
@bitmap.font.bold = false #true # Print () 2026.02.26
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
now = current_time
|
|||
|
|
age = now - @created_at
|
|||
|
|
|
|||
|
|
# Анимация появления (slide in)
|
|||
|
|
if age < SLIDE_IN_TIME
|
|||
|
|
progress = age.to_f / SLIDE_IN_TIME
|
|||
|
|
ease = 1 - (1 - progress) ** 3 # ease out cubic
|
|||
|
|
@x = Graphics.width - (Graphics.width - @target_x) * ease
|
|||
|
|
@alpha = (255 * ease).to_i
|
|||
|
|
elsif age > (@life_time || LIFE_TIME)
|
|||
|
|
# Анимация исчезновения
|
|||
|
|
fade_progress = (age - (@life_time || LIFE_TIME)).to_f / FADE_TIME
|
|||
|
|
if fade_progress >= 1
|
|||
|
|
@dead = true
|
|||
|
|
@alpha = 0
|
|||
|
|
else
|
|||
|
|
@alpha = (255 * (1 - fade_progress)).to_i
|
|||
|
|
@x = @target_x + (fade_progress * 50).to_i # Уход вправо
|
|||
|
|
end
|
|||
|
|
else
|
|||
|
|
@x = @target_x
|
|||
|
|
@alpha = 255
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Обновление фазы цвета (полный круг за 2 секунды)
|
|||
|
|
@color_phase = (age % 2000) / 2000.0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def current_border_color
|
|||
|
|
# Интерполяция между двумя соседними цветами радуги
|
|||
|
|
color_count = RAINBOW_COLORS.size
|
|||
|
|
position = @color_phase * color_count
|
|||
|
|
index1 = position.to_i % color_count
|
|||
|
|
index2 = (index1 + 1) % color_count
|
|||
|
|
t = position - position.to_i
|
|||
|
|
|
|||
|
|
c1 = RAINBOW_COLORS[index1]
|
|||
|
|
c2 = RAINBOW_COLORS[index2]
|
|||
|
|
|
|||
|
|
r = (c1.red + (c2.red - c1.red) * t).to_i
|
|||
|
|
g = (c1.green + (c2.green - c1.green) * t).to_i
|
|||
|
|
b = (c1.blue + (c2.blue - c1.blue) * t).to_i
|
|||
|
|
|
|||
|
|
Color.new(r, g, b, @alpha)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def glow_color(base_color)
|
|||
|
|
Color.new(
|
|||
|
|
[base_color.red + 50, 255].min,
|
|||
|
|
[base_color.green + 50, 255].min,
|
|||
|
|
[base_color.blue + 50, 255].min,
|
|||
|
|
(@alpha * 0.5).to_i
|
|||
|
|
)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw(target)
|
|||
|
|
return if @dead || @alpha <= 0
|
|||
|
|
|
|||
|
|
# Очистка области
|
|||
|
|
target.fill_rect(@x, @y, WIDTH, HEIGHT, Color.new(0, 0, 0, 0))
|
|||
|
|
|
|||
|
|
# Тень
|
|||
|
|
shadow_offset = 4
|
|||
|
|
target.fill_rect(@x + shadow_offset, @y + shadow_offset, WIDTH, HEIGHT, Color.new(0, 0, 0, (@alpha * 0.3).to_i))
|
|||
|
|
|
|||
|
|
# Фон с градиентом
|
|||
|
|
for dy in 0...HEIGHT
|
|||
|
|
bg_alpha = (@alpha * (0.85 - dy * 0.3 / HEIGHT)).to_i
|
|||
|
|
target.fill_rect(@x, @y + dy, WIDTH, 1, Color.new(20, 20, 30, bg_alpha))
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Анимированная рамка
|
|||
|
|
border = current_border_color
|
|||
|
|
glow = glow_color(border)
|
|||
|
|
bw = 2 # border width
|
|||
|
|
|
|||
|
|
# Верхняя линия с glow
|
|||
|
|
target.fill_rect(@x - 2, @y - 2, WIDTH + 4, bw + 2, glow)
|
|||
|
|
target.fill_rect(@x, @y, WIDTH, bw, border)
|
|||
|
|
|
|||
|
|
# Нижняя линия
|
|||
|
|
target.fill_rect(@x, @y + HEIGHT - bw, WIDTH, bw, border)
|
|||
|
|
|
|||
|
|
# Боковые линии
|
|||
|
|
target.fill_rect(@x, @y, bw, HEIGHT, border)
|
|||
|
|
target.fill_rect(@x + WIDTH - bw, @y, bw, HEIGHT, border)
|
|||
|
|
|
|||
|
|
# Угловые акценты (светящиеся)
|
|||
|
|
corner_size = 8
|
|||
|
|
target.fill_rect(@x - 1, @y - 1, corner_size, 3, glow)
|
|||
|
|
target.fill_rect(@x - 1, @y - 1, 3, corner_size, glow)
|
|||
|
|
target.fill_rect(@x + WIDTH - corner_size + 1, @y - 1, corner_size, 3, glow)
|
|||
|
|
target.fill_rect(@x + WIDTH - 2, @y - 1, 3, corner_size, glow)
|
|||
|
|
|
|||
|
|
# Текст
|
|||
|
|
text_color = Color.new(255, 255, 255, @alpha)
|
|||
|
|
type_color = get_type_color
|
|||
|
|
|
|||
|
|
# Иконка/тип слева
|
|||
|
|
icon_x = @x + 12
|
|||
|
|
icon_y = @y + HEIGHT/2 - 8
|
|||
|
|
draw_icon(target, icon_x, icon_y, type_color)
|
|||
|
|
|
|||
|
|
# Основной текст # # Print () 2026.02.26 тоже используем константы
|
|||
|
|
target.font.name = System_NotificationOverlay::FONT_NAME #"Euxoi" # Print () 2026.02.26
|
|||
|
|
target.font.size = System_NotificationOverlay::FONT_SIZE #18 # Print () 2026.02.26
|
|||
|
|
target.font.bold = false #true # Print () 2026.02.26
|
|||
|
|
target.font.outline = false
|
|||
|
|
target.font.color = text_color #
|
|||
|
|
|
|||
|
|
# Разбиваем текст по ширине (пикселям, а не символам)
|
|||
|
|
lines = wrap_text_pixels(@text, WIDTH - 45, target)
|
|||
|
|
lines.each_with_index do |line, i|
|
|||
|
|
target.draw_text(@x + 35, @y + 10 + i * 18, WIDTH - 40, 20, line, 0)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Мини-полоса прогресса (визуальный таймер)
|
|||
|
|
if @alpha == 255
|
|||
|
|
life_time = (@life_time || LIFE_TIME)
|
|||
|
|
progress_width = WIDTH * (1 - (current_time - @created_at).to_f / life_time)
|
|||
|
|
target.fill_rect(@x, @y + HEIGHT - 3, progress_width.to_i, 3, Color.new(border.red, border.green, border.blue, 150))
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Исправленный метод переноса - по реальной ширине пикселей
|
|||
|
|
def wrap_text_pixels(text, max_width, bitmap)
|
|||
|
|
return [text] if text.empty?
|
|||
|
|
|
|||
|
|
# Проверяем, влезает ли вся строка
|
|||
|
|
text_width = bitmap.text_size(text).width
|
|||
|
|
return [text] if text_width <= max_width
|
|||
|
|
|
|||
|
|
lines = []
|
|||
|
|
current_line = ""
|
|||
|
|
|
|||
|
|
# Разбиваем по словам
|
|||
|
|
words = text.split(' ')
|
|||
|
|
|
|||
|
|
words.each do |word|
|
|||
|
|
test_line = current_line.empty? ? word : "#{current_line} #{word}"
|
|||
|
|
test_width = bitmap.text_size(test_line).width
|
|||
|
|
|
|||
|
|
if test_width <= max_width
|
|||
|
|
current_line = test_line
|
|||
|
|
else
|
|||
|
|
# Текущая строка заполнена, начинаем новую
|
|||
|
|
lines << current_line unless current_line.empty?
|
|||
|
|
current_line = word
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
lines << current_line unless current_line.empty?
|
|||
|
|
lines
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_icon(target, x, y, color)
|
|||
|
|
# Рисуем простую иконку в зависимости от типа
|
|||
|
|
case @type
|
|||
|
|
when :success
|
|||
|
|
# Галочка
|
|||
|
|
target.fill_rect(x + 2, y + 6, 4, 2, color)
|
|||
|
|
target.fill_rect(x + 4, y + 4, 2, 6, color)
|
|||
|
|
target.fill_rect(x + 6, y + 2, 2, 4, color)
|
|||
|
|
when :error
|
|||
|
|
# Крест
|
|||
|
|
target.fill_rect(x + 4, y, 2, 12, color)
|
|||
|
|
target.fill_rect(x, y + 4, 10, 2, color)
|
|||
|
|
when :warning
|
|||
|
|
# Восклицательный знак
|
|||
|
|
target.fill_rect(x + 4, y, 2, 8, color)
|
|||
|
|
target.fill_rect(x + 4, y + 10, 2, 2, color)
|
|||
|
|
when :network
|
|||
|
|
# Круг/сеть
|
|||
|
|
target.fill_rect(x + 2, y + 4, 6, 2, color)
|
|||
|
|
target.fill_rect(x + 1, y + 6, 8, 2, color)
|
|||
|
|
target.fill_rect(x + 2, y + 8, 6, 2, color)
|
|||
|
|
else
|
|||
|
|
# Инфо - точка
|
|||
|
|
target.fill_rect(x + 3, y + 3, 6, 6, color)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def get_type_color
|
|||
|
|
case @type
|
|||
|
|
when :success then Color.new(100, 255, 100, @alpha)
|
|||
|
|
when :error then Color.new(255, 100, 100, @alpha)
|
|||
|
|
when :warning then Color.new(255, 200, 100, @alpha)
|
|||
|
|
when :network then Color.new(100, 200, 255, @alpha)
|
|||
|
|
else Color.new(200, 200, 200, @alpha)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def height
|
|||
|
|
HEIGHT + SPACING
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def dispose
|
|||
|
|
@bitmap.dispose if @bitmap && !@bitmap.disposed?
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
class << self
|
|||
|
|
def init
|
|||
|
|
@notifications = []
|
|||
|
|
@sprite = nil
|
|||
|
|
@viewport = nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def setup(viewport)
|
|||
|
|
# load_font_once # # Print () 2026.02.26 нам не нужно загружать шрифты
|
|||
|
|
dispose
|
|||
|
|
@viewport = viewport
|
|||
|
|
@sprite = Sprite.new(viewport)
|
|||
|
|
@sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
|||
|
|
@sprite.z = 9999
|
|||
|
|
@sprite.visible = true
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def notify(text, type = :info)
|
|||
|
|
text = text.to_s.strip
|
|||
|
|
return if text == ""
|
|||
|
|
|
|||
|
|
@notifications ||= []
|
|||
|
|
@last_notify_frame ||= {}
|
|||
|
|
frame = (Graphics.frame_count rescue 0).to_i
|
|||
|
|
key = "#{type}:#{text}"
|
|||
|
|
last_frame = @last_notify_frame[key].to_i
|
|||
|
|
return if @last_notify_frame.has_key?(key) && frame - last_frame < DEDUP_FRAMES
|
|||
|
|
@last_notify_frame[key] = frame
|
|||
|
|
|
|||
|
|
@notifications.delete_if do |n|
|
|||
|
|
same = ((n.instance_variable_get(:@text) rescue nil).to_s == text &&
|
|||
|
|
(n.instance_variable_get(:@type) rescue nil).to_s == type.to_s)
|
|||
|
|
n.dispose if same
|
|||
|
|
same
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
notif = Notification.new(text, type)
|
|||
|
|
|
|||
|
|
# Сдвигаем существующие вниз
|
|||
|
|
@notifications.each do |n|
|
|||
|
|
n.instance_variable_set(:@y, n.instance_variable_get(:@y) + notif.height)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
notif.instance_variable_set(:@y, MARGIN_TOP)
|
|||
|
|
@notifications.unshift(notif) # Новые сверху
|
|||
|
|
while @notifications.size > MAX_NOTIFICATIONS
|
|||
|
|
old = @notifications.pop
|
|||
|
|
old.dispose if old
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Звук
|
|||
|
|
play_sound(type)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Короткие методы
|
|||
|
|
def success(text); notify(text, :success); end
|
|||
|
|
def error(text); notify(text, :error); end
|
|||
|
|
def warning(text); notify(text, :warning); end
|
|||
|
|
def network(text); notify(text, :network); end
|
|||
|
|
|
|||
|
|
def play_sound(type)
|
|||
|
|
case type
|
|||
|
|
when :success then Audio.se_play("Audio/SE/Applause1", 70, 100) rescue nil
|
|||
|
|
when :error then Audio.se_play("Audio/SE/Buzzer1", 70, 100) rescue nil
|
|||
|
|
when :warning then Audio.se_play("Audio/SE/Buzzer4", 60, 100) rescue nil
|
|||
|
|
when :network then Audio.se_play("Audio/SE/Cursor2", 60, 120) rescue nil
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
return unless @sprite && @notifications
|
|||
|
|
|
|||
|
|
@sprite.bitmap.clear
|
|||
|
|
|
|||
|
|
@notifications.each(&:update)
|
|||
|
|
@notifications.reject!(&:dead)
|
|||
|
|
|
|||
|
|
# Обновляем Y позиции (плавное движение)
|
|||
|
|
target_y = MARGIN_TOP
|
|||
|
|
@notifications.each do |n|
|
|||
|
|
current = n.instance_variable_get(:@y) || target_y
|
|||
|
|
if current < target_y
|
|||
|
|
new_y = current + (target_y - current) * 0.15 + 0.5
|
|||
|
|
else
|
|||
|
|
new_y = current - (current - target_y) * 0.15
|
|||
|
|
end
|
|||
|
|
n.instance_variable_set(:@y, new_y)
|
|||
|
|
target_y += n.height
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Рисуем
|
|||
|
|
@notifications.each { |n| n.draw(@sprite.bitmap) }
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def dispose
|
|||
|
|
@notifications.each(&:dispose) if @notifications
|
|||
|
|
@notifications = []
|
|||
|
|
if @sprite
|
|||
|
|
@sprite.bitmap.dispose if @sprite.bitmap
|
|||
|
|
@sprite.dispose
|
|||
|
|
@sprite = nil
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
module MPTitleFont
|
|||
|
|
module_function
|
|||
|
|
|
|||
|
|
def pick(*const_names)
|
|||
|
|
const_names.each do |const_name|
|
|||
|
|
next unless defined?(FONT_MOD) && FONT_MOD.const_defined?(const_name)
|
|||
|
|
value = FONT_MOD.const_get(const_name)
|
|||
|
|
value = value[0] if value.is_a?(Array)
|
|||
|
|
value = value.to_s
|
|||
|
|
return value unless value.strip == ""
|
|||
|
|
end
|
|||
|
|
value = (System_Settings::MESSAGE_WINDOW_FONT_NAME rescue nil)
|
|||
|
|
value = value[0] if value.is_a?(Array)
|
|||
|
|
value = value.to_s
|
|||
|
|
return value unless value.strip == ""
|
|||
|
|
"VL Gothic"
|
|||
|
|
rescue
|
|||
|
|
"VL Gothic"
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Глобальные хелперы
|
|||
|
|
def notify(msg, type = :info); System_NotificationOverlay.notify(msg, type); end
|
|||
|
|
def notify_success(msg); System_NotificationOverlay.success(msg); end
|
|||
|
|
def notify_error(msg); System_NotificationOverlay.error(msg); end
|
|||
|
|
def notify_warning(msg); System_NotificationOverlay.warning(msg); end
|
|||
|
|
def notify_network(msg); System_NotificationOverlay.network(msg); end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** Scene_Base - Интеграция уведомлений
|
|||
|
|
#==============================================================================
|
|||
|
|
class Scene_Base
|
|||
|
|
alias :_notify_start :start
|
|||
|
|
def start
|
|||
|
|
_notify_start
|
|||
|
|
System_NotificationOverlay.setup(@viewport) if @viewport
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
alias :_notify_update :update
|
|||
|
|
def update
|
|||
|
|
_notify_update
|
|||
|
|
System_NotificationOverlay.update
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
alias :_notify_terminate :terminate
|
|||
|
|
def terminate
|
|||
|
|
System_NotificationOverlay.dispose if self.is_a?(Scene_Map)
|
|||
|
|
_notify_terminate
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** Scene_Title
|
|||
|
|
#==============================================================================
|
|||
|
|
class Scene_Title < Scene_Base
|
|||
|
|
def start
|
|||
|
|
return SceneManager.goto(Scene_FirstTimeSetup) if $langFirstPick
|
|||
|
|
launch_warning = DataManager.get_constant("LonaRPG","LaunchWarning",1)
|
|||
|
|
return SceneManager.goto(Scene_MapTitle) if $TEST || launch_warning == 1
|
|||
|
|
SceneManager.goto(Scene_AdultContentWarning)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def terminate
|
|||
|
|
SceneManager.snapshot_for_background
|
|||
|
|
Graphics.fadeout(Graphics.frame_rate)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
class Scene_AdultContentWarning < Scene_Base
|
|||
|
|
def start
|
|||
|
|
$loading_screen.dispose if $loading_screen
|
|||
|
|
super
|
|||
|
|
create_warning_posters
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def create_warning_posters
|
|||
|
|
@warning_poster=Sprite.new(@viewport)
|
|||
|
|
@warning_poster.visible=true
|
|||
|
|
if FileTest.exist?("Graphics/Pictures/Warning#{$lang}.png")
|
|||
|
|
@warning_poster.bitmap=Bitmap.new("Graphics/Pictures/Warning#{$lang}.png")
|
|||
|
|
else
|
|||
|
|
@warning_poster.bitmap=Bitmap.new("Graphics/Pictures/WarningENG.png")
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def perform_transition
|
|||
|
|
super
|
|||
|
|
Graphics.fadein(120)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
super
|
|||
|
|
if Input.press_any_thing?
|
|||
|
|
SndLib.ppl_Cheer
|
|||
|
|
SceneManager.goto(Scene_MapTitle)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def terminate
|
|||
|
|
super
|
|||
|
|
DataManager.write_constant("LonaRPG","LaunchWarning",1)
|
|||
|
|
@warning_poster.dispose
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** Scene_MapTitle
|
|||
|
|
#==============================================================================
|
|||
|
|
class Scene_MapTitle < Scene_Map
|
|||
|
|
attr_accessor :character_name
|
|||
|
|
attr_accessor :character_index
|
|||
|
|
|
|||
|
|
def start
|
|||
|
|
$loading_screen.dispose if $loading_screen
|
|||
|
|
if $titleCreateActorReq == true
|
|||
|
|
Cache.clear
|
|||
|
|
DataManager.setup_new_game(false)
|
|||
|
|
$hudForceHide = true
|
|||
|
|
$balloonForceHide = true
|
|||
|
|
tmpPickID = Array.new
|
|||
|
|
tmpPickID << "TitleMarket"
|
|||
|
|
tmpPickID << "TitleMarketDed" if DataManager.get_rec_constant("RecEndLeaveNoer") == 1 && !$DEMO
|
|||
|
|
tmpPickID << "Title666" if DataManager.get_rec_constant("RecEndLeaveNoer") == 1 && !$DEMO
|
|||
|
|
tmpPickID << "TitleHiveBattle" if DataManager.get_rec_constant("RecEndLeaveNoer") == 1 && !$DEMO
|
|||
|
|
|
|||
|
|
tmpPickID = tmpPickID.sample
|
|||
|
|
rnd_map_id = $data_tag_maps[tmpPickID].sample
|
|||
|
|
$game_map.setup(rnd_map_id)
|
|||
|
|
$game_player.moveto(59,55)
|
|||
|
|
$game_portraits.lprt.hide
|
|||
|
|
$game_portraits.rprt.hide
|
|||
|
|
$game_player.force_update = false
|
|||
|
|
$game_system.menu_disabled = true
|
|||
|
|
$titleCreateActorReq = false
|
|||
|
|
Graphics.frame_count = 0
|
|||
|
|
end
|
|||
|
|
super
|
|||
|
|
@hud.hide
|
|||
|
|
@menu = TitleMenu.new
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
super
|
|||
|
|
@menu.update
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def terminate
|
|||
|
|
super
|
|||
|
|
@menu.dispose
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** TitleMenu - Главное меню с онлайн-уведомлениями
|
|||
|
|
#==============================================================================
|
|||
|
|
class TitleMenu < OptionMenu
|
|||
|
|
NICKNAME_JSON_PATH = "ModScripts/multiplayer/nickname.json"
|
|||
|
|
|
|||
|
|
def load_nickname_from_file
|
|||
|
|
return "" unless File.exist?(NICKNAME_JSON_PATH)
|
|||
|
|
|
|||
|
|
raw = Ruby310Compat.read_text_file(NICKNAME_JSON_PATH)
|
|||
|
|
|
|||
|
|
# 1) нормальный вариант через JSON, если доступен
|
|||
|
|
if defined?(JSON)
|
|||
|
|
begin
|
|||
|
|
data = JSON.parse(raw)
|
|||
|
|
nick = data["nickname"] || data[:nickname]
|
|||
|
|
return nick.to_s
|
|||
|
|
rescue
|
|||
|
|
# упадём ниже в простой парсер
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# 2) простой фолбэк без JSON (под твой формат {"nickname":"Никнэйм"})
|
|||
|
|
m = raw.match(/"nickname"\s*:\s*"([^"]*)"/)
|
|||
|
|
m ? m[1].to_s : ""
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_nickname_above_menu
|
|||
|
|
nick = load_nickname_from_file.strip
|
|||
|
|
return if nick.empty?
|
|||
|
|
return unless @foreground_sprite && @foreground_sprite.bitmap
|
|||
|
|
|
|||
|
|
# # на всякий случай грузим твой шрифт (он у тебя в NotificationOverlay) # Print () 2026.02.26
|
|||
|
|
# System_NotificationOverlay.load_font_once rescue nil # Print () 2026.02.26 нам не нужно загружать шрифты
|
|||
|
|
|
|||
|
|
bmp = @foreground_sprite.bitmap
|
|||
|
|
|
|||
|
|
# позиция: над меню
|
|||
|
|
font_size = 22
|
|||
|
|
h = font_size + 8
|
|||
|
|
y = [@indexStartY - h - 16, 0].max
|
|||
|
|
|
|||
|
|
# очищаем область, чтобы не наслаивалось
|
|||
|
|
bmp.fill_rect(0, y, Graphics.width, h, Color.new(0,0,0,0))
|
|||
|
|
|
|||
|
|
bmp.font.name = MPTitleFont.pick(:NPCSTAT, :TITLE_MENU, :FILE_TITLE)
|
|||
|
|
bmp.font.size = 16 #font_size # Print ()
|
|||
|
|
bmp.font.bold = false #true # Print ()
|
|||
|
|
bmp.font.shadow = true #- # Print ()
|
|||
|
|
bmp.font.outline = false
|
|||
|
|
|
|||
|
|
bmp.draw_text(Rect.new(0, y, Graphics.width, h), nick, 1) # 1 = по центру
|
|||
|
|
end
|
|||
|
|
def initialize
|
|||
|
|
create_foreground
|
|||
|
|
create_background
|
|||
|
|
@autoSaveFile = nil
|
|||
|
|
init_AutoSaveFile
|
|||
|
|
super
|
|||
|
|
@online_connecting = false
|
|||
|
|
@online_connect_result = nil
|
|||
|
|
@online_connect_error = nil
|
|||
|
|
@online_connect_thread = nil
|
|||
|
|
@online_connect_started_at = nil
|
|||
|
|
center_menu_layout
|
|||
|
|
@onBegin = true
|
|||
|
|
initial_index = 0
|
|||
|
|
if SceneManager.prevOptChoose != nil
|
|||
|
|
initial_index = SceneManager.prevOptChoose
|
|||
|
|
elsif DataManager.saveFileExistsRGSS?
|
|||
|
|
initial_index = 1
|
|||
|
|
end
|
|||
|
|
refresh_index(initial_index)
|
|||
|
|
update_arrows rescue nil
|
|||
|
|
draw_nickname_above_menu
|
|||
|
|
@onBegin = false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def center_menu_layout
|
|||
|
|
# ширина самого длинного пункта
|
|||
|
|
max_text = 0
|
|||
|
|
@items.each do |sym|
|
|||
|
|
t = @optNames[sym].to_s
|
|||
|
|
w = self.bitmap.text_size(t).width
|
|||
|
|
max_text = w if w > max_text
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
padding = 30
|
|||
|
|
@indexOptWitdh = max_text + padding
|
|||
|
|
|
|||
|
|
# центр по X
|
|||
|
|
@indexStartX = ((Graphics.width - @indexOptWitdh) / 2).to_i
|
|||
|
|
|
|||
|
|
# центр по Y + сдвиг вверх/вниз
|
|||
|
|
lines = [@visible_lines, @items.size].min
|
|||
|
|
total_h = lines * @indexEachY
|
|||
|
|
|
|||
|
|
y_shift = -50 # вверх: отрицательное, вниз: положительное
|
|||
|
|
@indexStartY = ((Graphics.height - total_h) / 2).to_i + y_shift
|
|||
|
|
|
|||
|
|
# на всякий случай, чтобы не ушло в минус
|
|||
|
|
@indexStartY = [@indexStartY, 0].max
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def initialize_basic_setting
|
|||
|
|
super
|
|||
|
|
self.bitmap.font.name = System_Settings::MESSAGE_WINDOW_FONT_NAME
|
|||
|
|
self.bitmap.font.bold = true
|
|||
|
|
self.bitmap.font.outline = false
|
|||
|
|
self.bitmap.font.size = System_Settings::FONT_SIZE::SCENE_TITLE_OPTIONS
|
|||
|
|
@indexStartX = 64
|
|||
|
|
@indexStartY = (Graphics.height * 0.36).to_i
|
|||
|
|
@indexEachY = 21
|
|||
|
|
self.x = 0
|
|||
|
|
self.y = 0
|
|||
|
|
self.ox = 0
|
|||
|
|
self.oy = 0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def initialize_gui_notice
|
|||
|
|
@text_title = ""
|
|||
|
|
@text_warning = ""
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def init_AutoSaveFile
|
|||
|
|
@autoSaveFile = nil
|
|||
|
|
fileE = DataManager.userDataPath_FileSaveAuto_E
|
|||
|
|
fileS = DataManager.userDataPath_FileSaveAuto_S
|
|||
|
|
if File.exist?(fileE) && !File.exist?(fileS)
|
|||
|
|
@autoSaveFile = "SavAutoE"
|
|||
|
|
elsif !File.exist?(fileE) && File.exist?(fileS)
|
|||
|
|
@autoSaveFile = "SavAutoS"
|
|||
|
|
elsif File.exist?(fileE) && File.exist?(fileS)
|
|||
|
|
mtime1 = File.mtime(fileE)
|
|||
|
|
mtime2 = File.mtime(fileS)
|
|||
|
|
if mtime1 > mtime2
|
|||
|
|
@autoSaveFile = "SavAutoE"
|
|||
|
|
elsif mtime1 < mtime2
|
|||
|
|
@autoSaveFile = "SavAutoS"
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
@autoSaveFile
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def mods_scan_folder
|
|||
|
|
modFolder = Dir.entries("ModScripts/_Mods/")
|
|||
|
|
modFolder.delete(".")
|
|||
|
|
modFolder.delete("..")
|
|||
|
|
modFolder
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def title_text_or_fallback(key, fallback)
|
|||
|
|
text = ""
|
|||
|
|
begin
|
|||
|
|
text = $game_text[key, true].to_s
|
|||
|
|
rescue
|
|||
|
|
text = ""
|
|||
|
|
end
|
|||
|
|
return fallback if text.nil? || text.empty? || text == key
|
|||
|
|
text
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def initialize_options
|
|||
|
|
fallback = (defined?($lang) && $lang.to_s == "ENG") ? "ONLINE" : "Онлайн"
|
|||
|
|
buildOptions(:handlerCmdOnline, title_text_or_fallback("menu:title/ONLINE", fallback), "", [""])
|
|||
|
|
buildOptions(:handlerCmdTLoadDoom, $game_text["menu:system/DoomCoreMode_Load0"], "", [""]) if DataManager.saveFileExistsDOOM?
|
|||
|
|
buildOptions(:handlerCmdTLoadAuto, $game_text["menu:system/autosave"], "", [""]) if @autoSaveFile
|
|||
|
|
buildOptions(:handlerCmdOptions, $game_text["menu:title/OPTIONS"], "", [""])
|
|||
|
|
buildOptions(:handlerCmdACHlist, $game_text["menu:title/ACH"], "", [""])
|
|||
|
|
buildOptions(:handlerCmdCredit, $game_text["menu:title/CREDITS"], "", [""])
|
|||
|
|
buildOptions(:handlerSupportMe, $game_text["menu:title/SupportMe"], "", [""])
|
|||
|
|
buildOptions(:MODS, "MODS", "", [""]) if !mods_scan_folder.empty? && $mod_manager.mods.size > 0
|
|||
|
|
buildOptions(:handlerCmdExit, $game_text["menu:title/EXIT_GAME"], "", [""])
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def setOPT(setting, value)
|
|||
|
|
case setting
|
|||
|
|
when :handlerCmdNewGame; handlerCmdNewGame(value)
|
|||
|
|
when :handlerCmdContinue; handlerCmdContinue(value)
|
|||
|
|
when :handlerCmdOnline; handlerCmdOnline(value)
|
|||
|
|
when :handlerCmdTLoadDoom; handlerCmdTLoadDoom(value)
|
|||
|
|
when :handlerCmdTLoadAuto; handlerCmdTLoadAuto(value)
|
|||
|
|
when :handlerCmdOptions; handlerCmdOptions(value)
|
|||
|
|
when :handlerCmdACHlist; handlerCmdACHlist(value)
|
|||
|
|
when :handlerCmdCredit; handlerCmdCredit(value)
|
|||
|
|
when :MODS; handlerCmdMods(value)
|
|||
|
|
when :handlerSupportMe; handlerSupportMe(value)
|
|||
|
|
when :handlerCmdExit; handlerCmdExit(value)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdMods(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
@titleReqCacheClear = false
|
|||
|
|
SceneManager.goto(ModManagerScene)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerSupportMe(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
Thread.new { system("start http://lonadev.idv.tw/ ")}
|
|||
|
|
sleep 0.9
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdNewGame(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.closeChest
|
|||
|
|
$titleCreateActorReq = true
|
|||
|
|
if $TEST
|
|||
|
|
$game_map.setup($data_system.start_map_id)
|
|||
|
|
$game_player.moveto($data_system.start_x, $data_system.start_y)
|
|||
|
|
$game_map.interpreter.new_game_setup
|
|||
|
|
$hudForceHide = false
|
|||
|
|
$balloonForceHide = false
|
|||
|
|
else
|
|||
|
|
$game_map.setup($data_tag_maps["TutorialOP"].sample)
|
|||
|
|
$game_player.moveto(0, 0)
|
|||
|
|
$hudForceHide = true
|
|||
|
|
$balloonForceHide = true
|
|||
|
|
end
|
|||
|
|
SceneManager.scene.fadeout_all
|
|||
|
|
SceneManager.prevOptChooseSet(nil)
|
|||
|
|
SceneManager.prevTitleOptChooseSet(nil)
|
|||
|
|
$game_map.interpreter.change_map_weather_cleaner
|
|||
|
|
$game_player.force_update = true
|
|||
|
|
$game_system.menu_disabled = false
|
|||
|
|
SceneManager.goto(Scene_Map)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdContinue(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
@titleReqCacheClear = false
|
|||
|
|
$game_map.interpreter.chcg_background_color_off
|
|||
|
|
SceneManager.goto(Scene_Load)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdTLoadDoom(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
$game_map.interpreter.chcg_background_color_off
|
|||
|
|
SceneManager.scene.gotoLoadCustomScene("SavDoomMode")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdTLoadAuto(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
$game_map.interpreter.chcg_background_color_off
|
|||
|
|
SceneManager.scene.gotoLoadCustomScene(@autoSaveFile)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdOptions(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
@titleReqCacheClear = false
|
|||
|
|
SceneManager.goto(Scene_TitleOptions)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdCredit(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.closeChest
|
|||
|
|
$titleCreateActorReq = true
|
|||
|
|
$game_player.force_update = true
|
|||
|
|
$game_map.interpreter.chcg_background_color_off
|
|||
|
|
SceneManager.scene.fadeout_all
|
|||
|
|
SceneManager.goto(Scene_Credits)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdACHlist(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
SndLib.openChest
|
|||
|
|
@titleReqCacheClear = false
|
|||
|
|
SceneManager.goto(Scene_ACHlistMenu)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# * ВЫХОД В ГЛАВНОЕ МЕНЮ С ОТКЛЮЧЕНИЕМ ОТ СЕРВЕРА
|
|||
|
|
#==============================================================================
|
|||
|
|
def handlerCmdExit(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
|
|||
|
|
# Отключаемся от сервера если подключены (как F9)
|
|||
|
|
if defined?(WebSocket) && WebSocket.respond_to?(:connected?) && WebSocket.connected?
|
|||
|
|
WebSocket.disconnect
|
|||
|
|
notify_network("Отключено от сервера")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
SndLib.ppl_Boo
|
|||
|
|
SceneManager.scene.fadeout_all
|
|||
|
|
SceneManager.exit
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# * ОНЛАЙН С УВЕДОМЛЕНИЯМИ (JS-стиль)
|
|||
|
|
#==============================================================================
|
|||
|
|
def handlerCmdOnline(value)
|
|||
|
|
return if @onBegin == true
|
|||
|
|
|
|||
|
|
if @online_connecting
|
|||
|
|
notify_warning("Подключение уже выполняется...")
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# Проверяем подключение
|
|||
|
|
if defined?(WebSocket) && WebSocket.respond_to?(:connected?) && WebSocket.connected?
|
|||
|
|
notify_success("Уже подключены. Открываю онлайн-сохранение...")
|
|||
|
|
$game_map.interpreter.chcg_background_color_off rescue nil
|
|||
|
|
SceneManager.goto(Scene_OnlineAutoLoad)
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
notify_network("Подключение к серверу LonaRPG Online")
|
|||
|
|
|
|||
|
|
@online_connecting = true
|
|||
|
|
@online_connect_result = nil
|
|||
|
|
@online_connect_error = nil
|
|||
|
|
@online_connect_started_at = Time.now.to_f rescue nil
|
|||
|
|
|
|||
|
|
# Подключение в фоне, а переход сцены только в главном потоке.
|
|||
|
|
@online_connect_thread = Thread.new do
|
|||
|
|
begin
|
|||
|
|
ok = false
|
|||
|
|
if defined?(WebSocket) && WebSocket.respond_to?(:connect)
|
|||
|
|
host = "lonarpg.online"
|
|||
|
|
port = 6134
|
|||
|
|
begin
|
|||
|
|
if defined?(OnlineServerRegistry)
|
|||
|
|
host = OnlineServerRegistry.selected_host
|
|||
|
|
port = OnlineServerRegistry.selected_port
|
|||
|
|
end
|
|||
|
|
rescue
|
|||
|
|
end
|
|||
|
|
ok = WebSocket.connect(host, port)
|
|||
|
|
else
|
|||
|
|
ok = false
|
|||
|
|
end
|
|||
|
|
@online_connect_result = ok ? :ok : :failed
|
|||
|
|
rescue => e
|
|||
|
|
@online_connect_error = e.message
|
|||
|
|
@online_connect_result = :error
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
process_online_connect_result
|
|||
|
|
return SndLib.sys_buzzer if Input.trigger?(:B) || WolfPad.trigger?(:X_LINK)
|
|||
|
|
@foreground_spriteJoy.opacity = WolfPad.plugged_in? ? 255 : 0
|
|||
|
|
update_crypto_wallets_Y
|
|||
|
|
return refresh_index(@index + 1) if Input.repeat?(:DOWN)
|
|||
|
|
return refresh_index(@index - 1) if Input.repeat?(:UP)
|
|||
|
|
return refresh_index(@index + 1) if Input.repeat?(:R)
|
|||
|
|
return refresh_index(@index - 1) if Input.repeat?(:L)
|
|||
|
|
return runOption if Input.trigger?(:C) || WolfPad.trigger?(:Z_LINK)
|
|||
|
|
mouse_input_check
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def process_online_connect_result
|
|||
|
|
return unless @online_connecting
|
|||
|
|
|
|||
|
|
if @online_connect_result.nil?
|
|||
|
|
begin
|
|||
|
|
if @online_connect_started_at && (Time.now.to_f - @online_connect_started_at) > 10.0
|
|||
|
|
@online_connect_thread.kill if @online_connect_thread && @online_connect_thread.alive?
|
|||
|
|
@online_connect_result = :timeout
|
|||
|
|
end
|
|||
|
|
rescue
|
|||
|
|
end
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
@online_connecting = false
|
|||
|
|
|
|||
|
|
case @online_connect_result
|
|||
|
|
when :ok
|
|||
|
|
notify_success("Подключено! Загрузка онлайн-данных...")
|
|||
|
|
$game_map.interpreter.chcg_background_color_off rescue nil
|
|||
|
|
SceneManager.goto(Scene_OnlineAutoLoad)
|
|||
|
|
when :timeout
|
|||
|
|
notify_error("Сервер не ответил вовремя.")
|
|||
|
|
when :error
|
|||
|
|
notify_error("Ошибка: #{@online_connect_error}")
|
|||
|
|
else
|
|||
|
|
notify_error("Сервер недоступен. Проверьте подключение.")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
@online_connect_result = nil
|
|||
|
|
@online_connect_error = nil
|
|||
|
|
@online_connect_thread = nil
|
|||
|
|
@online_connect_started_at = nil
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def next_option
|
|||
|
|
runOption
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def previous_option
|
|||
|
|
runOption
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def dispose_foreground
|
|||
|
|
@foreground_sprite.bitmap.dispose
|
|||
|
|
@foreground_sprite.dispose
|
|||
|
|
@foreground_spriteJoy.dispose
|
|||
|
|
@foreground_crypto_wallets.dispose
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def dispose_background
|
|||
|
|
@sprite1.bitmap.dispose
|
|||
|
|
@sprite1.dispose
|
|||
|
|
@sprite2.bitmap.dispose
|
|||
|
|
@sprite2.dispose
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def dispose
|
|||
|
|
SceneManager.snapshot_for_background
|
|||
|
|
dispose_background
|
|||
|
|
dispose_foreground
|
|||
|
|
super
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def refresh_index(i)
|
|||
|
|
tmpIndex = @index
|
|||
|
|
size = @items.size
|
|||
|
|
return if size == 0
|
|||
|
|
|
|||
|
|
warp = $LonaINI["GameOptions"]["ui_opt_warping"] == 1 && !($LonaINI["GameOptions"]["ui_opt_warping_mouse_off"] == 1 && Mouse.enable?)
|
|||
|
|
@index = if warp
|
|||
|
|
(i % size)
|
|||
|
|
else
|
|||
|
|
[[i, 0].max, size - 1].min
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
SndLib.play_cursor if tmpIndex != @index && !@onBegin
|
|||
|
|
|
|||
|
|
if @index < @top_index
|
|||
|
|
@top_index = @index
|
|||
|
|
elsif @index > @top_index + @visible_lines
|
|||
|
|
@top_index = @index - @visible_lines
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
SceneManager.prevOptChooseSet(@index)
|
|||
|
|
redraw_visible_items
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_item(i, active = false, displayed_index = nil)
|
|||
|
|
displayed_index ||= i - @top_index
|
|||
|
|
return if displayed_index < 0 || displayed_index > @visible_lines
|
|||
|
|
|
|||
|
|
y = @indexStartY + displayed_index * @indexEachY
|
|||
|
|
c = active ? 255 : 192
|
|||
|
|
self.bitmap.font.color.set(c, c, c)
|
|||
|
|
|
|||
|
|
dx = active ? 5 : 0
|
|||
|
|
w = @indexOptWitdh - dx * 2
|
|||
|
|
w = 10 if w < 10
|
|||
|
|
self.bitmap.draw_text(@indexStartX + dx, y, w, @indexEachY, @optNames[@items[i]], 1)
|
|||
|
|
item_mouse_rect(i, y, active)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def item_mouse_rect(i, y, active)
|
|||
|
|
mouse_rect_y = y
|
|||
|
|
@mouse_all_rectsL ||= []
|
|||
|
|
@mouse_all_rectsR ||= []
|
|||
|
|
@mouse_all_rectsL[i] = Rect.new(@indexStartX, mouse_rect_y+3, @indexOptWitdh, @indexEachY)
|
|||
|
|
@mouse_all_rectsR[i] = Rect.new(@indexStartX, mouse_rect_y+3, @indexOptWitdh, @indexEachY)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_resetWarning
|
|||
|
|
@warning.dispose if @warning
|
|||
|
|
@warning = Sprite.new
|
|||
|
|
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def create_background
|
|||
|
|
@sprite1 = Sprite.new
|
|||
|
|
@sprite2 = Sprite.new
|
|||
|
|
bmp1 = Cache.load_bitmap("Graphics/Online/","titleOptBg") # <= твой фон
|
|||
|
|
bmp2 = Cache.load_bitmap("Graphics/System/TitleScreen/","Title")
|
|||
|
|
@sprite1.bitmap = bmp1
|
|||
|
|
@sprite2.bitmap = bmp2
|
|||
|
|
@sprite1.z = System_Settings::TITLE_BACKGROUND1
|
|||
|
|
@sprite2.z = System_Settings::TITLE_BACKGROUND2
|
|||
|
|
|
|||
|
|
zoom_x = Graphics.width.to_f / bmp1.width + 0.002
|
|||
|
|
zoom_y = Graphics.height.to_f / bmp1.height + 0.002
|
|||
|
|
|
|||
|
|
[@sprite1, @sprite2].each do |s|
|
|||
|
|
s.zoom_x = zoom_x
|
|||
|
|
s.zoom_y = zoom_y
|
|||
|
|
s.x = ((Graphics.width - s.bitmap.width * s.zoom_x) / 2).to_i
|
|||
|
|
s.y = ((Graphics.height - s.bitmap.height * s.zoom_y) / 2).to_i
|
|||
|
|
end
|
|||
|
|
@sprite2.x = 0
|
|||
|
|
@sprite2.y = (Graphics.height * 0.02778).to_i
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def center_sprite(sprite)
|
|||
|
|
sprite.ox = sprite.bitmap.width / 2
|
|||
|
|
sprite.oy = sprite.bitmap.height / 2
|
|||
|
|
sprite.x = Graphics.width / 2
|
|||
|
|
sprite.y = Graphics.height / 2
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def create_foreground
|
|||
|
|
@foreground_sprite.dispose if @foreground_sprite && !@foreground_sprite.disposed?
|
|||
|
|
@foreground_spriteJoy.dispose if @foreground_spriteJoy && !@foreground_spriteJoy.disposed?
|
|||
|
|
|
|||
|
|
@foreground_sprite = Sprite.new
|
|||
|
|
@foreground_spriteJoy = Sprite.new
|
|||
|
|
|
|||
|
|
@foreground_sprite.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
|||
|
|
@foreground_spriteJoy.bitmap = Bitmap.new(Graphics.width, Graphics.height)
|
|||
|
|
|
|||
|
|
@foreground_sprite.z = System_Settings::TITLE_FOREGROUND_Z
|
|||
|
|
@foreground_spriteJoy.z = System_Settings::TITLE_FOREGROUND_Z
|
|||
|
|
|
|||
|
|
@foreground_sprite.x = 0
|
|||
|
|
@foreground_sprite.y = 0
|
|||
|
|
@foreground_spriteJoy.x = 0
|
|||
|
|
@foreground_spriteJoy.y = 0
|
|||
|
|
|
|||
|
|
draw_game_title
|
|||
|
|
draw_crypto_wallets
|
|||
|
|
draw_joystick_mode
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_crypto_wallets
|
|||
|
|
@foreground_crypto_wallets = Sprite.new
|
|||
|
|
@foreground_crypto_wallets.z = System_Settings::TITLE_FOREGROUND_Z
|
|||
|
|
@foreground_crypto_wallets.bitmap = Bitmap.new("Graphics/System/CryptoWalletW.png")
|
|||
|
|
|
|||
|
|
bmp = @foreground_crypto_wallets.bitmap
|
|||
|
|
|
|||
|
|
# ЯКОРЬ: низ по центру (чтобы рос вверх и НЕ уезжал влево)
|
|||
|
|
@foreground_crypto_wallets.ox = bmp.width / 2
|
|||
|
|
@foreground_crypto_wallets.oy = bmp.height
|
|||
|
|
|
|||
|
|
font_size = System_Settings::FONT_SIZE::SCENE_TITLE_VER_INFO
|
|||
|
|
text_height = font_size + 4
|
|||
|
|
margin = 4
|
|||
|
|
|
|||
|
|
# Базовая точка (центр экрана по X, низ экрана по Y)
|
|||
|
|
@wallet_base_x = Graphics.width / 2
|
|||
|
|
@wallet_base_y = Graphics.height - (text_height * 1 + margin * 3)
|
|||
|
|
|
|||
|
|
@foreground_crypto_wallets_zoom = 1.0
|
|||
|
|
@foreground_crypto_wallets.zoom_x = @foreground_crypto_wallets_zoom
|
|||
|
|
@foreground_crypto_wallets.zoom_y = @foreground_crypto_wallets_zoom
|
|||
|
|
|
|||
|
|
@foreground_crypto_wallets.x = @wallet_base_x
|
|||
|
|
@foreground_crypto_wallets.y = @wallet_base_y
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update_crypto_wallets_Y
|
|||
|
|
return if !@foreground_crypto_wallets
|
|||
|
|
|
|||
|
|
font_size = System_Settings::FONT_SIZE::SCENE_TITLE_VER_INFO
|
|||
|
|
text_height = font_size + 4
|
|||
|
|
margin = 4
|
|||
|
|
|
|||
|
|
@foreground_crypto_wallets_zoom = (@items[@index] == :handlerSupportMe) ? 2.0 : 1.0
|
|||
|
|
@foreground_crypto_wallets.zoom_x = @foreground_crypto_wallets_zoom
|
|||
|
|
@foreground_crypto_wallets.zoom_y = @foreground_crypto_wallets_zoom
|
|||
|
|
|
|||
|
|
# Если геймпад-строка показывается — поднимаем базовую линию
|
|||
|
|
lines = WolfPad.plugged_in? ? 2 : 1
|
|||
|
|
@wallet_base_y = Graphics.height - (text_height * lines + margin * 3)
|
|||
|
|
|
|||
|
|
# Важно: x не пересчитываем от ширины — он всегда центр!
|
|||
|
|
@foreground_crypto_wallets.x = Graphics.width / 2
|
|||
|
|
@foreground_crypto_wallets.y = @wallet_base_y
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_game_title
|
|||
|
|
font_size = [System_Settings::FONT_SIZE::SCENE_TITLE_VER_INFO.to_i, 16].max
|
|||
|
|
font = @foreground_sprite.bitmap.font
|
|||
|
|
font.name = MPTitleFont.pick(:FILE_TITLE, :TITLE_MENU, :STAT_INFO)
|
|||
|
|
font.size = font_size
|
|||
|
|
font.outline = false
|
|||
|
|
font.shadow = true if font.respond_to?(:shadow=)
|
|||
|
|
font.bold = false if font.respond_to?(:bold=)
|
|||
|
|
font.color.set(238, 238, 238, 255)
|
|||
|
|
|
|||
|
|
text_height = font_size + 4
|
|||
|
|
y = Graphics.height - text_height - 10
|
|||
|
|
|
|||
|
|
rect = Rect.new(0, y, Graphics.width, text_height)
|
|||
|
|
@foreground_sprite.bitmap.draw_text(rect, title_public_version_text, 1) # 1 = центр
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
# export_full_ver_info предназначен для совместимости сохранений и добавляет
|
|||
|
|
# внутренний hexadecimal version_id (например 333411A). На главном экране
|
|||
|
|
# показываем только понятное игроку название и публичную версию из Game.ini.
|
|||
|
|
def title_public_version_text
|
|||
|
|
text = ($GameINI["Game"]["Title"].to_s rescue "")
|
|||
|
|
text = ($data_system.game_title.to_s rescue "") if text.strip == ""
|
|||
|
|
text = "LonaRPG Online" if text.strip == ""
|
|||
|
|
text = text.gsub(/\s+/, " ").strip
|
|||
|
|
text.sub(/\.[0-9A-F]{6,}\z/i, "")
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_joystick_mode
|
|||
|
|
font_size = System_Settings::FONT_SIZE::SCENE_TITLE_VER_INFO
|
|||
|
|
@foreground_spriteJoy.bitmap.font.size = font_size
|
|||
|
|
@foreground_spriteJoy.bitmap.font.outline = false
|
|||
|
|
|
|||
|
|
text_height = font_size + 4
|
|||
|
|
y = Graphics.height - (text_height * 2) - 12
|
|||
|
|
|
|||
|
|
rect = Rect.new(0, y, Graphics.width, text_height)
|
|||
|
|
@foreground_spriteJoy.bitmap.draw_text(rect, $game_text["menu:title/GamepadMode"], 1) # центр
|
|||
|
|
@foreground_spriteJoy.opacity = 0
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def runOption
|
|||
|
|
options = @optOptions[@items[@index]]
|
|||
|
|
current = @optSettings[@items[@index]]
|
|||
|
|
optSYM = @optSymbol[@items[@index]]
|
|||
|
|
oi = 0
|
|||
|
|
for i in 0...options.size
|
|||
|
|
oi = i if options[i] == current
|
|||
|
|
end
|
|||
|
|
oi = (oi + 1) % options.size
|
|||
|
|
@optSettings[@items[@index]] = options[oi]
|
|||
|
|
clear_item(@index)
|
|||
|
|
draw_item(@index, true)
|
|||
|
|
setOPT(optSYM, options[oi])
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** Вспомогательные классы
|
|||
|
|
#==============================================================================
|
|||
|
|
class NewGameSewer < Scene_Base
|
|||
|
|
def start
|
|||
|
|
super
|
|||
|
|
DataManager.setup_new_game(tmp_tomap=true, tagName="NoerSewer")
|
|||
|
|
SceneManager.goto(Scene_Map)
|
|||
|
|
$game_map.interpreter.new_game_setup
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
class NewGameTutorialOP < Scene_Base
|
|||
|
|
def start
|
|||
|
|
super
|
|||
|
|
DataManager.setup_new_game(tmp_tomap=true, tagName="TutorialOP")
|
|||
|
|
SceneManager.goto(Scene_Map)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
class Empty < Scene_Base
|
|||
|
|
def start
|
|||
|
|
super
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
#==============================================================================
|
|||
|
|
# ** Scene_OnlineAutoLoad - Автозагрузка с уведомлениями
|
|||
|
|
#==============================================================================
|
|||
|
|
class Scene_OnlineAutoLoad < Scene_Base
|
|||
|
|
ONLINE_SLOT_INDEX = 0
|
|||
|
|
|
|||
|
|
def start
|
|||
|
|
super
|
|||
|
|
SceneManager.scene.fadeout_all rescue nil
|
|||
|
|
notify_network("Загрузка сохранения...")
|
|||
|
|
@load_started = false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def update
|
|||
|
|
super
|
|||
|
|
return if @load_started
|
|||
|
|
@load_started = true
|
|||
|
|
|
|||
|
|
unless load_first_slot
|
|||
|
|
notify_error("Не удалось загрузить сохранение #1")
|
|||
|
|
WebSocket.disconnect rescue nil
|
|||
|
|
SceneManager.goto(Scene_MapTitle)
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
notify_success("Игра загружена! Добро пожаловать в онлайн.")
|
|||
|
|
$game_system.on_after_load rescue nil
|
|||
|
|
$game_map.autoplay rescue nil
|
|||
|
|
$game_player.refresh rescue nil
|
|||
|
|
SceneManager.goto(Scene_Map)
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
private
|
|||
|
|
|
|||
|
|
def load_first_slot
|
|||
|
|
if DataManager.respond_to?(:load_game)
|
|||
|
|
return true if DataManager.load_game(ONLINE_SLOT_INDEX)
|
|||
|
|
return true if DataManager.load_game(ONLINE_SLOT_INDEX + 1)
|
|||
|
|
if DataManager.respond_to?(:customModeLoad)
|
|||
|
|
return true if DataManager.customModeLoad("SavAutoE")
|
|||
|
|
return true if DataManager.customModeLoad("SavAutoS")
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
if DataManager.respond_to?(:load_game_without_rescue)
|
|||
|
|
begin
|
|||
|
|
DataManager.load_game_without_rescue(ONLINE_SLOT_INDEX)
|
|||
|
|
return true
|
|||
|
|
rescue
|
|||
|
|
begin
|
|||
|
|
DataManager.load_game_without_rescue(ONLINE_SLOT_INDEX + 1)
|
|||
|
|
return true
|
|||
|
|
rescue
|
|||
|
|
begin
|
|||
|
|
if DataManager.respond_to?(:customModeLoad)
|
|||
|
|
return true if DataManager.customModeLoad("SavAutoE")
|
|||
|
|
return true if DataManager.customModeLoad("SavAutoS")
|
|||
|
|
end
|
|||
|
|
rescue
|
|||
|
|
end
|
|||
|
|
return false
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
false
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
|
|||
|
|
# Hide the "MODS" entry from the main title menu without disabling mods.
|
|||
|
|
# Install: place into ModScripts/
|
|||
|
|
# This patch targets TitleMenu, because the title options are built there.
|
|||
|
|
|
|||
|
|
class TitleMenu
|
|||
|
|
HIDE_MODS_KEY = :MODS
|
|||
|
|
|
|||
|
|
unless method_defined?(:hide_mods_menu_entry__orig_initialize_options)
|
|||
|
|
alias hide_mods_menu_entry__orig_initialize_options initialize_options
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def initialize_options
|
|||
|
|
hide_mods_menu_entry__orig_initialize_options
|
|||
|
|
hide_mods_menu_entry
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
unless method_defined?(:hide_mods_menu_entry__orig_draw_items)
|
|||
|
|
alias hide_mods_menu_entry__orig_draw_items draw_items
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def draw_items
|
|||
|
|
hide_mods_menu_entry
|
|||
|
|
hide_mods_menu_entry__orig_draw_items
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def hide_mods_menu_entry
|
|||
|
|
@optSymbol.delete(HIDE_MODS_KEY) if defined?(@optSymbol) && @optSymbol
|
|||
|
|
@optNames.delete(HIDE_MODS_KEY) if defined?(@optNames) && @optNames
|
|||
|
|
@optOptions.delete(HIDE_MODS_KEY) if defined?(@optOptions) && @optOptions
|
|||
|
|
@optSettings.delete(HIDE_MODS_KEY) if defined?(@optSettings) && @optSettings
|
|||
|
|
|
|||
|
|
if defined?(@items) && @items
|
|||
|
|
@items.delete(HIDE_MODS_KEY)
|
|||
|
|
if @items.empty?
|
|||
|
|
@index = 0
|
|||
|
|
@top_index = 0 if defined?(@top_index)
|
|||
|
|
else
|
|||
|
|
@index = [[@index || 0, 0].max, @items.size - 1].min
|
|||
|
|
@top_index = [[@top_index || 0, 0].max, [@items.size - 1, 0].max].min if defined?(@top_index)
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
end
|
|||
|
|
|
|||
|
|
def handlerCmdMods(*_args)
|
|||
|
|
return
|
|||
|
|
end
|
|||
|
|
end
|