RMVXA [SOLVED] Yanfly's Menu Cursor doesn't appear in "Show Choices" command boxes

Status
Not open for further replies.

Tomasque

Villager
Member
Joined
Mar 5, 2021
Messages
5
Reaction score
5
First Language
English
Primarily Uses
RMVXA
The "Yanfly Engine Ace - Menu Cursor v1.00" script doesn't show the custom cursor if the command box was opened by the "Show Choices" command (or in the Save Screen). This happens even in an otherwise empty test project.



Here's a list of where the glitch happens:
Show Choices
Save Screen (I don't mind that)
And here's a list of where the glitch doesn't happen:
Title Screen
Menu Screen
Shop Screen
Battle Screen
Name Change

I use a slightly altered version of the script, but both versions have the glitch in them. Mine adds "@menu_cursors.clear" just under line 210 (it fixes a bug that crashes the game if you back out of the GAME END menu).

Finally, although I doubt this makes any difference at all, I've attached the sprite I'm using for the cursor. I thought it might have been something to do with the small size, but a large sprite doesn't fix it.

If there's anything else I can provide, tell me.

Thank you.



EDIT:

I managed to fix it on my own :smile:

Well, kinda. Rather, I figured out how to make Tomy's KMS Cursor Animation function identically to Yanfly's script, but without the glitch. It really only required deleting code that made it move smoothly (so that it'd move instantly like I wanted), along with some minor changes to variables.

Since Tomy allows the distribution of modified versions of his script, I'll share my altered script here for anyone who might come across this later. Just remember to give Tomy the credit for the script.

If you use it, you're going to need to make three modifications on your end:
1. Change the POSITION_REV values to align your cursor sprite again.
2. Widen your cursor's canvas so that it's 8 times the width, but keep your cursor on the left.
(The script cuts the canvas into 8 pieces and considers each a separate frame of animation.)
3. Edit the Window.png file and from the lower right box remove what's in the upper left corner.
(Tomy's script doesn't disable the default flashing cursor, so doing this deletes it manually.)

If you have any questions, message me and I'll see what I can do.

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/ ◆ Animated Cursor - KMS_CursorAnimation ◆ VX Ace ◆
#_/ ◇ Last update : 2012/02/19 (TOMY@Kamesoft) ◇
#_/ ◇ Website: http://ytomy.sakura.ne.jp/
#_/ ◇ Translated by Mr. Bubble ◇
#_/----------------------------------------------------------------------------
#_/ Displays an animated cursor for menu selection windows.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
# This script adds a cursor animation for selectable windows. The number
# of frames a cursor animation graphic can have is unlimited as long as the
# cursor graphic supports that many frames.
#----------------------------------------------------------------------------
# Script Calls
#----------------------------------------------------------------------------
# Script calls are used in "Script..." event commands located under Tab 3.
#
# show_cursor_animation
# Shows the cursor animation if it is not visible already.
#
# hide_cursor_animation
# Hides the cursor animation if it is visable.
#----------------------------------------------------------------------------
# Conditional Branch Script Calls
#----------------------------------------------------------------------------
# Conditional branch script calls are used in the "Script" box in Conditional
# Branch event commands.
#
# cursor_animation_visible?
# Returns true if the cursor is visble. Returns false if cursor is hidden
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ BEGIN Setting ★
#==============================================================================

module KMS_CursorAnimation
# * Default Cursor Visibility Setting
# true : Show cursor animation by default (can be seen on title screen)
# false : Hide cursor animation by default (only seen in a new/loaded game)
DEFAULT_ANIMATION = true

# * Cursor Animation File
# Cursor graphics are placed in the "Graphics/System" folder in your project
ANIMATION_FILE = "MenuCursor"
# * Cursor Frame Count
# The number of frames in the cursor animation graphic. Cursor frame
# counts are unlimited as long as the cursor graphic supports that
# many frames.
FRAME_COUNT = 1
# * Cursor Animation speed
# Higher values make the cursor animation slower.
ANIMATION_WAIT = 4

# * Cursor Opacity
OPACITY = 224
# * Cursor Blending Type
# 0 : Normal
# 1 : Add
# 2 : Sub
BLEND_TYPE = 1
# * Cursor Base Position
# 0 : Higher
# 1 : Center
# 2 : Lower
BASE_POSITION = 1
# * Cursor Position Adjustment [x, y]
POSITION_REV = [-5.5, -4.5]
end

#==============================================================================
# ☆ END Setting ☆
#==============================================================================

$kms_imported = {} if $kms_imported == nil
$kms_imported["CursorAnimation"] = true

# *****************************************************************************

#==============================================================================
# □ KMS_Commands
#==============================================================================

module KMS_Commands
module_function
#--------------------------------------------------------------------------
# ○ カーソルアニメを表示
#--------------------------------------------------------------------------
def show_cursor_animation
$game_system.cursor_animation_visible = true
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを非表示
#--------------------------------------------------------------------------
def hide_cursor_animation
$game_system.cursor_animation_visible = false
end
#--------------------------------------------------------------------------
# ○ カーソルアニメ表示状態の取得
#--------------------------------------------------------------------------
def cursor_animation_visible?
return $game_system.cursor_animation_visible
end
end

#==============================================================================
# ■ Game_Interpreter
#==============================================================================

class Game_Interpreter
# イベントコマンドから直接コマンドを叩けるようにする
include KMS_Commands
end

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
#--------------------------------------------------------------------------
# ○ クラス変数
#--------------------------------------------------------------------------
@@__cursor_animation = nil # カーソルアニメ
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# x : ウィンドウの X 座標
# y : ウィンドウの Y 座標
# width : ウィンドウの幅
# height : ウィンドウの高さ
#--------------------------------------------------------------------------
alias initialize_KMS_CursorAnimation initialize
def initialize(x, y, width, height)
initialize_KMS_CursorAnimation(x, y, width, height)

@@__cursor_animation.add_window(self)
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
unless method_defined?:)dispose_KMS_CursorAnimation)
alias dispose_KMS_CursorAnimation dispose
end
def dispose
@@__cursor_animation.remove_window(self)

dispose_KMS_CursorAnimation
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを生成
#--------------------------------------------------------------------------
def self.create_cursor_animation
@@__cursor_animation = Cursor_Animation.new
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを破棄
#--------------------------------------------------------------------------
def self.dispose_cursor_animation
@@__cursor_animation.dispose
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを表示
#--------------------------------------------------------------------------
def self.show_cursor_animation
@@__cursor_animation.visible = true
@@__cursor_animation.update
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを隠す
#--------------------------------------------------------------------------
def self.hide_cursor_animation
@@__cursor_animation.visible = false
@@__cursor_animation.update
end
#--------------------------------------------------------------------------
# ○ カーソルアニメを更新
#--------------------------------------------------------------------------
def self.update_cursor_animation
@@__cursor_animation.update
end
end

#==============================================================================
# ■ Game_System
#==============================================================================

class Game_System
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_writer :cursor_animation_visible
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
alias initialize_KMS_CursorAnimation initialize
def initialize
initialize_KMS_CursorAnimation

@cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
end
#--------------------------------------------------------------------------
# ○ カーソルアニメ可否フラグを取得
#--------------------------------------------------------------------------
def cursor_animation_visible
if @cursor_animation_visible.nil?
@cursor_animation_visible = KMS_CursorAnimation::DEFAULT_ANIMATION
end
return @cursor_animation_visible
end
end

#==============================================================================
# □ Sprite_CursorAnimation
#------------------------------------------------------------------------------
#  カーソルアニメーション用の処理を追加したスプライトのクラスです。
#==============================================================================

class Sprite_CursorAnimation < Sprite
#--------------------------------------------------------------------------
# ● オブジェクト初期化
# viewport : ビューポート
#--------------------------------------------------------------------------
def initialize(viewport = nil)
super(viewport)
@duration = 0
@frame_count = 0

self.bitmap = Cache.system(KMS_CursorAnimation::ANIMATION_FILE)
self.src_rect.width = bitmap.width / 8
self.src_rect.height = bitmap.height /
([KMS_CursorAnimation::FRAME_COUNT - 1, 0].max / 8 + 1)
self.ox = src_rect.width / 2
self.oy = src_rect.height / 2
self.opacity = KMS_CursorAnimation::oPACITY
self.blend_type = KMS_CursorAnimation::BLEND_TYPE
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
super
return unless visible

@frame_count += 1
return if @frame_count % KMS_CursorAnimation::ANIMATION_WAIT != 0

@frame_count = 0
@duration -= 1
if @duration < 0
@duration = KMS_CursorAnimation::FRAME_COUNT - 1
end
update_animation
end
#--------------------------------------------------------------------------
# ○ アニメーションを更新
#--------------------------------------------------------------------------
def update_animation
self.src_rect.x = src_rect.width * (@duration % 8)
self.src_rect.y = src_rect.height * (@duration / 8)
end
end

#==============================================================================
# □ Cursor_Animation
#------------------------------------------------------------------------------
#  カーソル周りのアニメーションを扱うクラスです。
#==============================================================================

class Cursor_Animation
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :visible
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize
reset
end
#--------------------------------------------------------------------------
# ○ 破棄
#--------------------------------------------------------------------------
def dispose
@target_sprite.dispose
@target_sprite = nil
@viewport.dispose
@viewport = nil
end
#--------------------------------------------------------------------------
# ○ リセット
#--------------------------------------------------------------------------
def reset
@visible = false

@viewport = Viewport.new(0, 0, 640, 480)
@windows = []
@target_sprite = Sprite_CursorAnimation.new(@viewport)
@active_window = nil

@viewport.visible = false
@viewport.z = 30000
end
#--------------------------------------------------------------------------
# ○ ウィンドウ追加
#--------------------------------------------------------------------------
def add_window(*window)
@windows |= window.find_all { |w|
w.is_a?(Window_Selectable) || w.is_a?(Window_SaveFile)
}
@windows.flatten!
end
#--------------------------------------------------------------------------
# ○ ウィンドウ削除
#--------------------------------------------------------------------------
def remove_window(*window)
@windows -= window
end
#--------------------------------------------------------------------------
# ○ フレーム更新
#--------------------------------------------------------------------------
def update
return if @viewport.nil?

@viewport.update
@target_sprite.update

# 座標調整
dest_x, dest_y = get_cursor_pos
if @target_sprite.x != dest_x
@target_sprite.x = dest_x
end
if @target_sprite.y != dest_y
@target_sprite.y = dest_y
end
end
#--------------------------------------------------------------------------
# ○ カーソル位置取得
# [x, y] の形で返す。
#--------------------------------------------------------------------------
def get_cursor_pos
dx = dy = 0

# 可視状態のアクティブウィンドウを取得
unless window_active?(@active_window)
@active_window = search_active_window
end

# アクティブウィンドウがなければ非表示
if @active_window.nil? || !KMS_Commands.cursor_animation_visible?
@viewport.visible = false
dx = Graphics.width / 2
dy = Graphics.height / 2
return [dx, dy]
end
@viewport.visible = @visible

# カーソル位置を計算
rect = @active_window.cursor_rect
dx = rect.x + 16 + KMS_CursorAnimation::pOSITION_REV[0]
dy = rect.y + 16 + KMS_CursorAnimation::pOSITION_REV[1]
vp = @active_window.viewport
if vp != nil
dx += vp.rect.x - vp.ox
dy += vp.rect.y - vp.oy
end
dx += @active_window.x - @active_window.ox
dy += @active_window.y - @active_window.oy

case KMS_CursorAnimation::BASE_POSITION
when 0 # 上
dy += @target_sprite.oy
when 1 # 中央
dy += rect.height / 2
when 2 # 下
dy += rect.height - @target_sprite.oy
end
return [dx, dy]
end
#--------------------------------------------------------------------------
# ○ ウィンドウの可視・アクティブ状態判定
#--------------------------------------------------------------------------
def window_active?(window)
return false if window.nil?
return false if window.disposed?
return false unless window.visible

if window.is_a?(Window_Selectable)
return window.active
elsif window.is_a?(Window_SaveFile)
return window.selected
end
return false
end
#--------------------------------------------------------------------------
# ○ アクティブウィンドウを探す
#--------------------------------------------------------------------------
def search_active_window
return @windows.find { |w|
if !w.visible
false
elsif w.is_a?(Window_Selectable)
w.active && w.index >= 0
elsif w.is_a?(Window_SaveFile)
w.selected
else
false
end
}
end
end

#==============================================================================
# ■ Scene_Base
#==============================================================================

class Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias start_KMS_CursorAnimation start
def start
Window_Base.create_cursor_animation
Window_Base.show_cursor_animation

start_KMS_CursorAnimation
end
#--------------------------------------------------------------------------
# ● 終了前処理
#--------------------------------------------------------------------------
alias pre_terminate_KMS_CursorAnimation pre_terminate
def pre_terminate
Window_Base.dispose_cursor_animation

pre_terminate_KMS_CursorAnimation
end
#--------------------------------------------------------------------------
# ● フレーム更新(基本)
#--------------------------------------------------------------------------
alias update_basic_KMS_CursorAnimation update_basic
def update_basic
update_basic_KMS_CursorAnimation

# カーソルアニメを更新
Window_Base.update_cursor_animation
end
end
 

Attachments

  • MenuCursor.png
    MenuCursor.png
    162 bytes · Views: 0
Last edited:

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
8,268
Reaction score
5,445
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

I managed to review my previous lessons on Learn MV and fixed a lot of things. Yay! :kaopride:
I've decided "Attack on Equestria" should be released first... hence this new ARG channel! https://www.youtube.com/channel/UClKiUI8xOVx9dsF4kRXUmxw
Check it out, and subscribe! The ARG will lead up to the video game. It's not a creepy game, but I just thought it should follow ARG standards.
For anyone interested in my project M - i finally made a gamethread about it :D

Forum statistics

Threads
110,409
Messages
1,053,088
Members
143,472
Latest member
Rocket
Top