Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Changing cursor Color/Opacity when window is not active?

I'm using this cursor script:

Code:
#==============================================================================
# ++ 矢印型セレクトカーソル ver. 1.12 ++
#  Script by パラ犬
#  http://2d6.parasite.jp/
#
#  Edited by Digital Watch
#------------------------------------------------------------------------------
# コマンド選択時のカーソルを任意の画像にします。
#==============================================================================

module PARA_LEFT_CURSOR
  
  # カーソル画像ファイル名(「Graphics/Pictures」フォルダ内)
  FILE_NAME = "cursor"

  # 表示タイプ( 0:矢印のみ 1:矢印+四角カーソル )
  TYPE = 0

end

# ↑ 設定項目ここまで
#------------------------------------------------------------------------------

#==============================================================================
# â–  Window_Base
#==============================================================================

class Window_Base
  #--------------------------------------------------------------------------
  # ● カーソルの矩形更新
  #--------------------------------------------------------------------------
  alias cursor_rect_para_lcr cursor_rect
  def cursor_rect=(rect)
    if PARA_LEFT_CURSOR::TYPE == 1
      super(rect)
    end
    empty = Rect.new(0,0,0,0)
    if rect != empty and self.visible != false and @index != -1
      if @cursor == nil or @cursor.disposed?
        # スプライトを作成
        @cursor = Sprite.new
        @cursor.bitmap = RPG::Cache.picture(PARA_LEFT_CURSOR::FILE_NAME)
        #@cursor.color = Color.new(128, 128, 128, 128)
      end
      # カーソルスプライトの位置を移動
      #@cursor.x = self.x + rect.x
      @cursor.x = self.x + rect.x - 5
      cy = (rect.height-32) / 2
      @cursor.y = self.y + cy + rect.y + 16
      @cursor.z = self.z + 2
    elsif @cursor != nil
      @cursor.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● 解放
  #--------------------------------------------------------------------------
  alias dispose_para_cur dispose
  def dispose
    super
    if @cursor != nil
      @cursor.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● self.visible
  #--------------------------------------------------------------------------
  def visible=(bool)
    super
    # ウインドウが不可視の時はカーソルを消去
    if @cursor != nil and bool == false
      @cursor.dispose
    end
  end
  #--------------------------------------------------------------------------
  # ● self.x
  #--------------------------------------------------------------------------
  def x=(x)
    super
    if @index != nil
      # カーソルの矩形を更新
      update_cursor_rect
    end
  end
  #--------------------------------------------------------------------------
  # ● self.y
  #--------------------------------------------------------------------------
  def y=(y)
    super
    if @index != nil
      # カーソルの矩形を更新
      update_cursor_rect
    end
  end
end

What I want to do is when a window is not active (IE, in the menu you select Equip, then the active window changes and you select the actor to equip. When you're selecting the actor, the cursor in the main window stays, but the color changes to indicate the window isn't active)

I want the cursor to change to this color:

Code:
Color.new(128, 128, 128, 128)

Does anyone have any idea how I would go about doing this? You can't do anything with self.active in the cursor script because that will ALWAYS return true.

Thanks in advance.
 
Using your script would require me to go through and update ALL my update_cursor_rect methods (there are A LOT), and I really don't want to do that.

Is there any way you could incorporate your self.visible code into the cursor script I'm using?
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top