230 lines
7.7 KiB
Ruby
230 lines
7.7 KiB
Ruby
# encoding: UTF-8
|
|||
|
|
# LonaCraft: keep the world ticking under craft / rename UI online
|
||
|
|
# (same live Spriteset_Map pattern as multiplayer ESC / bank / ItemStorage).
|
||
|
|
# Offline keeps vanilla Scene_MenuBase snapshot pause.
|
||
|
|
return unless defined?(MPLiveEscMenu) && defined?(MPLiveEscMenu::SpritesetHost)
|
||
|
|
|
||
|
|
module LonaCraft
|
||
|
|
module LiveMenu
|
||
|
|
def self.online?
|
||
|
|
MPLiveEscMenu.online?
|
||
|
|
rescue
|
||
|
|
false
|
||
|
|
end
|
||
|
|
|
||
|
|
def self.craft_scene?(sc = nil)
|
||
|
|
sc ||= (SceneManager.scene rescue nil)
|
||
|
|
defined?(Scene_LonaCraft) && sc.is_a?(Scene_LonaCraft)
|
||
|
|
rescue
|
||
|
|
false
|
||
|
|
end
|
||
|
|
|
||
|
|
def self.rename_scene?(sc = nil)
|
||
|
|
sc ||= (SceneManager.scene rescue nil)
|
||
|
|
defined?(Scene_LonaCraftBaseName) && sc.is_a?(Scene_LonaCraftBaseName)
|
||
|
|
rescue
|
||
|
|
false
|
||
|
|
end
|
||
|
|
|
||
|
|
def self.live_scene?(sc = nil)
|
||
|
|
craft_scene?(sc) || rename_scene?(sc)
|
||
|
|
rescue
|
||
|
|
false
|
||
|
|
end
|
||
|
|
|
||
|
|
def self.harden_windows(scene, windows)
|
||
|
|
return unless online? && scene
|
||
|
|
opacity = MPLiveEscMenu::STORAGE_WINDOW_BACK_OPACITY
|
||
|
|
content_z = scene.mp_live_storage_content_z if scene.respond_to?(:mp_live_storage_content_z)
|
||
|
|
content_z ||= (System_Settings::SCENE_Menu_ContentBase_Z rescue 2010).to_i
|
||
|
|
Array(windows).each do |win|
|
||
|
|
next unless win
|
||
|
|
begin
|
||
|
|
win.back_opacity = opacity if win.respond_to?(:back_opacity=)
|
||
|
|
rescue
|
||
|
|
end
|
||
|
|
begin
|
||
|
|
win.z = content_z if win.respond_to?(:z=) && win.z.to_i < content_z
|
||
|
|
rescue
|
||
|
|
end
|
||
|
|
end
|
||
|
|
rescue
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
# Scene_LonaCraft — craft stations / hand craft from ESC menu
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
if defined?(Scene_LonaCraft)
|
||
|
|
class Scene_LonaCraft < Scene_MenuBase
|
||
|
|
include MPLiveEscMenu::SpritesetHost
|
||
|
|
|
||
|
|
unless method_defined?(:lc_live_craft_start_without)
|
||
|
|
alias_method :lc_live_craft_start_without, :start
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_craft_create_background_without)
|
||
|
|
alias_method :lc_live_craft_create_background_without, :create_background
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_craft_update_without)
|
||
|
|
alias_method :lc_live_craft_update_without, :update
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_craft_terminate_without)
|
||
|
|
alias_method :lc_live_craft_terminate_without, :terminate
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_craft_dispose_background_without)
|
||
|
|
alias_method :lc_live_craft_dispose_background_without, :dispose_background
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_craft_open_result_without)
|
||
|
|
alias_method :lc_live_craft_open_result_without, :open_result
|
||
|
|
end
|
||
|
|
|
||
|
|
def hud
|
||
|
|
return MPLiveEscMenu.damage_hud if LonaCraft::LiveMenu.online?
|
||
|
|
nil
|
||
|
|
end
|
||
|
|
|
||
|
|
def create_background(*args, &block)
|
||
|
|
if LonaCraft::LiveMenu.online?
|
||
|
|
mp_live_create_dim_background_menubase
|
||
|
|
else
|
||
|
|
lc_live_craft_create_background_without(*args, &block)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def start(*args, &block)
|
||
|
|
lc_live_craft_start_without(*args, &block)
|
||
|
|
return unless LonaCraft::LiveMenu.online?
|
||
|
|
mp_live_setup_spriteset
|
||
|
|
LonaCraft::LiveMenu.harden_windows(self, [
|
||
|
|
@list_title, @info_title, @list_window, @detail_window, @result_window
|
||
|
|
])
|
||
|
|
end
|
||
|
|
|
||
|
|
def update(*args, &block)
|
||
|
|
if LonaCraft::LiveMenu.online?
|
||
|
|
return if mp_live_tick_world_or_exit_on_transfer
|
||
|
|
end
|
||
|
|
lc_live_craft_update_without(*args, &block)
|
||
|
|
end
|
||
|
|
|
||
|
|
def open_result(*args, &block)
|
||
|
|
lc_live_craft_open_result_without(*args, &block)
|
||
|
|
LonaCraft::LiveMenu.harden_windows(self, [@result_window]) if LonaCraft::LiveMenu.online?
|
||
|
|
end
|
||
|
|
|
||
|
|
def terminate(*args, &block)
|
||
|
|
mp_live_dispose_spriteset if LonaCraft::LiveMenu.online? || @mp_live_spriteset
|
||
|
|
lc_live_craft_terminate_without(*args, &block)
|
||
|
|
end
|
||
|
|
|
||
|
|
def dispose_background(*args, &block)
|
||
|
|
mp_live_dispose_owned_bg_sprite_bitmap
|
||
|
|
lc_live_craft_dispose_background_without(*args, &block)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
# Scene_LonaCraftBaseName — rename base
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
if defined?(Scene_LonaCraftBaseName)
|
||
|
|
class Scene_LonaCraftBaseName < Scene_MenuBase
|
||
|
|
include MPLiveEscMenu::SpritesetHost
|
||
|
|
|
||
|
|
unless method_defined?(:lc_live_rename_start_without)
|
||
|
|
alias_method :lc_live_rename_start_without, :start
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_rename_create_background_without)
|
||
|
|
alias_method :lc_live_rename_create_background_without, :create_background
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_rename_update_without)
|
||
|
|
alias_method :lc_live_rename_update_without, :update
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_rename_terminate_without)
|
||
|
|
alias_method :lc_live_rename_terminate_without, :terminate
|
||
|
|
end
|
||
|
|
unless method_defined?(:lc_live_rename_dispose_background_without)
|
||
|
|
alias_method :lc_live_rename_dispose_background_without, :dispose_background
|
||
|
|
end
|
||
|
|
|
||
|
|
def hud
|
||
|
|
return MPLiveEscMenu.damage_hud if LonaCraft::LiveMenu.online?
|
||
|
|
nil
|
||
|
|
end
|
||
|
|
|
||
|
|
def create_background(*args, &block)
|
||
|
|
if LonaCraft::LiveMenu.online?
|
||
|
|
mp_live_create_dim_background_menubase
|
||
|
|
else
|
||
|
|
lc_live_rename_create_background_without(*args, &block)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
def start(*args, &block)
|
||
|
|
lc_live_rename_start_without(*args, &block)
|
||
|
|
return unless LonaCraft::LiveMenu.online?
|
||
|
|
mp_live_setup_spriteset
|
||
|
|
LonaCraft::LiveMenu.harden_windows(self, [@edit_window])
|
||
|
|
end
|
||
|
|
|
||
|
|
def update(*args, &block)
|
||
|
|
if LonaCraft::LiveMenu.online?
|
||
|
|
return if mp_live_tick_world_or_exit_on_transfer
|
||
|
|
end
|
||
|
|
lc_live_rename_update_without(*args, &block)
|
||
|
|
end
|
||
|
|
|
||
|
|
def terminate(*args, &block)
|
||
|
|
mp_live_dispose_spriteset if LonaCraft::LiveMenu.online? || @mp_live_spriteset
|
||
|
|
lc_live_rename_terminate_without(*args, &block)
|
||
|
|
end
|
||
|
|
|
||
|
|
def dispose_background(*args, &block)
|
||
|
|
mp_live_dispose_owned_bg_sprite_bitmap
|
||
|
|
lc_live_rename_dispose_background_without(*args, &block)
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
# Register with multiplayer live UI (movement freeze + net sync)
|
||
|
|
#------------------------------------------------------------------------------
|
||
|
|
module MPLiveEscMenu
|
||
|
|
class << self
|
||
|
|
unless method_defined?(:lc_live_blocking_scene_without)
|
||
|
|
alias_method :lc_live_blocking_scene_without, :live_blocking_scene?
|
||
|
|
def live_blocking_scene?
|
||
|
|
return true if online? && defined?(LonaCraft::LiveMenu) && LonaCraft::LiveMenu.live_scene?
|
||
|
|
lc_live_blocking_scene_without
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
if defined?(WebSocket)
|
||
|
|
module WebSocket
|
||
|
|
class << self
|
||
|
|
unless method_defined?(:lc_live_gameplay_scene_without)
|
||
|
|
alias_method :lc_live_gameplay_scene_without, :gameplay_scene_active?
|
||
|
|
def gameplay_scene_active?
|
||
|
|
if connected? && defined?(LonaCraft::LiveMenu) && LonaCraft::LiveMenu.live_scene?
|
||
|
|
return true
|
||
|
|
end
|
||
|
|
lc_live_gameplay_scene_without
|
||
|
|
end
|
||
|
|
end
|
||
|
|
|
||
|
|
unless method_defined?(:lc_live_scene_spriteset_without)
|
||
|
|
alias_method :lc_live_scene_spriteset_without, :scene_with_map_spriteset
|
||
|
|
def scene_with_map_spriteset
|
||
|
|
sc = SceneManager.scene rescue nil
|
||
|
|
if sc && defined?(LonaCraft::LiveMenu) && LonaCraft::LiveMenu.live_scene?(sc)
|
||
|
|
return sc if sc.respond_to?(:spriteset) && sc.spriteset
|
||
|
|
end
|
||
|
|
lc_live_scene_spriteset_without
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|
||
|
|
end
|