[XP][VX] Window tone

Started by Wecoc, January 16, 2013, 07:48:59 am

Previous topic - Next topic

Wecoc

Window Tone
Authors: Wecoc
Version: 1.1
Type: Window Add-On
Key Term: Misc Add-on



Introduction

This is a simple Add-On for XP and VX that allows you to change the Window tones on game (in Ace that function already exists) You can change 'back' tone, 'cursor' tone and 'border' tone separately. I used the Window class from Pokemon Essentials as a base to make this.



Features


  • Red, Green, Blue and Gray are managed separately.

  • Different window sprites ('back', 'cursor' and 'border') are managed separately.

  • get, set and increase(positive or negative) color values.

  • Where are you from? Do you spell gray or grey? It doesn't matter, it supports both.




Screenshots

Spoiler: ShowHide






Script

Spoiler: ShowHide
#==============================================================================
# [XP][VX] Window tone (by Wecoc) v. 1.1
# (Window de Pokemon Essentials)
#==============================================================================
#==============================================================================
# Game_System
#==============================================================================


class Game_System
  attr_accessor :back_r
  attr_accessor :back_g
  attr_accessor :back_b
  attr_accessor :back_s

  attr_accessor :cursor_r
  attr_accessor :cursor_g
  attr_accessor :cursor_b
  attr_accessor :cursor_s

  attr_accessor :border_r
  attr_accessor :border_g
  attr_accessor :border_b
  attr_accessor :border_s

  alias ini initialize unless $@
  def initialize
    ini
    @back_r = 0
    @back_g = 0
    @back_b = 0
    @back_s = 0

    @cursor_r = 0
    @cursor_g = 0
    @cursor_b = 0
    @cursor_s = 0

    @border_r = 0
    @border_g = 0
    @border_b = 0
    @border_s = 0
  end
end

class WindowCursorRect < Rect
  def initialize(window)
    @window=window
    @x=0
    @y=0
    @width=0
    @height=0
  end
  attr_reader :x,:y,:width,:height
  def empty
    needupdate=@x!=0 || @y!=0 || @width!=0 || @height!=0
    if needupdate
    @x=0
    @y=0
    @width=0
    @height=0
    @window.width=@window.width
    end
  end
  def isEmpty?
  return @x==0 && @y==0 && @width==0 && @height==0
  end
  def set(x,y,width,height)
    needupdate=@x!=x || @y!=y || @width!=width || @height!=height
    if needupdate
    @x=x
    @y=y
    @width=width
    @height=height
    @window.width=@window.width
    end
  end
  def height=(value)
    @height=value; @window.width=@window.width
  end
  def width=(value)
    @width=value; @window.width=@window.width
  end
  def x=(value)
    @x=value; @window.width=@window.width
  end
  def y=(value)
    @y=value; @window.width=@window.width
  end
end

#==============================================================================
# Window
#==============================================================================

class Window
attr_reader :tone
attr_reader :color
attr_reader :blend_type
attr_reader :contents_blend_type
attr_reader :viewport
attr_reader :contents
attr_reader :ox
attr_reader :oy
attr_reader :x
attr_reader :y
attr_reader :z
attr_reader :width
attr_reader :active
attr_reader :pause
attr_reader :height
attr_reader :opacity
attr_reader :back_opacity
attr_reader :contents_opacity
attr_reader :visible
attr_reader :cursor_rect
attr_reader :openness
attr_reader :stretch
def windowskin
  @_windowskin
end
def initialize(viewport=nil)
  @sprites={}
  @spritekeys=[
  "back",
  "corner0","side0","scroll0",
  "corner1","side1","scroll1",
  "corner2","side2","scroll2",
  "corner3","side3","scroll3",
  "cursor","contents","pause"
  ]
  @sidebitmaps=[nil,nil,nil,nil]
  @cursorbitmap=nil
  @bgbitmap=nil
  @viewport=viewport
  for i in @spritekeys
  @sprites[i]=Sprite.new(@viewport)
  end
  @disposed=false
  @tone=Tone.new(0,0,0)
  @color=Color.new(0,0,0,0)

  @back_r = $game_system.back_r
  @back_g = $game_system.back_g
  @back_b = $game_system.back_b
  @back_s = $game_system.back_s

  @cursor_r = $game_system.cursor_r
  @cursor_g = $game_system.cursor_g
  @cursor_b = $game_system.cursor_b
  @cursor_s = $game_system.cursor_s

  @border_r = $game_system.border_r
  @border_g = $game_system.border_g
  @border_b = $game_system.border_b
  @border_s = $game_system.border_s

  @blankcontents=Bitmap.new(1,1)
  @contents=@blankcontents
  @_windowskin=nil
  @rpgvx=false
  @x=0
  @y=0
  @width=0
  @openness=255
  @height=0
  @ox=0
  @oy=0
  @z=0
  @stretch=true
  @visible=true
  @active=true
  @blend_type=0
  @contents_blend_type=0
  @opacity=255
  @back_opacity=255
  @contents_opacity=255
  @cursor_rect=WindowCursorRect.new(self)
  @cursorblink=0
  @cursoropacity=255
  @pause=false
  @pauseopacity=255
  @pauseframe=0
  privRefresh(true)
end
def dispose
  if !self.disposed?
  for i in @sprites
    i[1].dispose if i[1]
    @sprites[i[0]]=nil
  end
  for i in 0...@sidebitmaps.length
    @sidebitmaps[i].dispose if @sidebitmaps[i]
    @sidebitmaps[i]=nil
  end
  @blankcontents.dispose
  @cursorbitmap.dispose if @cursorbitmap
  @backbitmap.dispose if @backbitmap
  @sprites.clear
  @sidebitmaps.clear
  @_windowskin=nil
  @_contents=nil
  @disposed=true

  $game_system.back_r = @back_r
  $game_system.back_g = @back_g
  $game_system.back_b = @back_b
  $game_system.back_s = @back_s

  $game_system.cursor_r = @cursor_r
  $game_system.cursor_g = @cursor_g
  $game_system.cursor_b = @cursor_b
  $game_system.cursor_s = @cursor_s

  $game_system.border_r = @border_r
  $game_system.border_g = @border_g
  $game_system.border_b = @border_b
  $game_system.border_s = @border_s
  end
end
def openness=(value)
  @openness=value
  @openness=0 if @openness<0
  @openness=255 if @openness>255
  privRefresh
end
def stretch=(value)
  @stretch=value
  privRefresh(true)
end
def visible=(value)
  @visible=value
  privRefresh
end
def viewport=(value)
  @viewport=value
  for i in @spritekeys
  @sprites[i].dispose
  if @sprites[i].is_a?(Sprite)
    @sprites[i]=Sprite.new(@viewport)
  elsif @sprites[i].is_a?(Plane)
    @sprites[i]=Plane.new(@viewport)
  else
    @sprites[i]=nil
  end
  end
  privRefresh(true)
end
def z=(value)
  @z=value
  privRefresh
end
def disposed?
  return @disposed
end
def contents=(value)
  @contents=value
  privRefresh
end
def windowskin=(value)
  @_windowskin=value
  if value && value.is_a?(Bitmap) && !value.disposed? && value.width==128
    @rpgvx=true
  else
    @rpgvx=false
  end
  privRefresh(true)
end
def ox=(value)
  @ox=value
  privRefresh
end
def active=(value)
  @active=value
  privRefresh(true)
end
def cursor_rect=(value)
  if !value
    @cursor_rect.empty
  else
    @cursor_rect.set(value.x,value.y,value.width,value.height)
  end
end
def oy=(value)
  @oy=value
  privRefresh
end
def width=(value)
  @width=value
  privRefresh(true)
end
def height=(value)
  @height=value
  privRefresh(true)
end
def pause=(value)
  @pause=value
  @pauseopacity=0 if !value
  privRefresh
end
def x=(value)
  @x=value
  privRefresh
end
def y=(value)
  @y=value
  privRefresh
end
def opacity=(value)
  @opacity=value
  @opacity=0 if @opacity<0
  @opacity=255 if @opacity>255
  privRefresh
end
def back_opacity=(value)
  @back_opacity=value
  @back_opacity=0 if @back_opacity<0
  @back_opacity=255 if @back_opacity>255
  privRefresh
end

def get_back_red
  if @back_r == nil
    return 0
  else
    return @back_r
  end
end
def get_back_green
  if @back_g == nil
    return 0
  else
  return @back_g
  end
end
def get_back_blue
  if @back_b == nil
    return 0
  else
  return @back_b
  end
end
def get_back_gray
  if @back_s == nil
    return 0
  else
  return @back_s
  end
end
def get_back_grey
  get_back_gray
end


def set_back_red(value)
  @back_r=value
  @back_r=-255 if @back_r<-255
  @back_r=255 if @back_r>255
end
def set_back_green(value)
  @back_g=value
  @back_g=-255 if @back_g<-255
  @back_g=255 if @back_g>255
end
def set_back_blue(value)
  @back_b=value
  @back_b=-255 if @back_b<-255
  @back_b=255 if @back_b>255
end
def set_back_gray(value)
  @back_s=value
  @back_s=0 if @back_s<0
  @back_s=255 if @back_s>255
end
def set_back_grey(value)
  set_back_gray(value)
end


def increase_back_red(value)
  @back_r+=value
  @back_r=-255 if @back_r<-255
  @back_r=255 if @back_r>255
end
def increase_back_green(value)
  @back_g+=value
  @back_g=-255 if @back_g<-255
  @back_g=255 if @back_g>255
end
def increase_back_blue(value)
  @back_b+=value
  @back_b=-255 if @back_b<-255
  @back_b=255 if @back_b>255
end
def increase_back_gray(value)
  @back_s+=value
  @back_s=0 if @back_s<0
  @back_s=255 if @back_s>255
end
def increase_back_grey(value)
  increase_back_gray(value)
end


def get_cursor_red
  if @cursor_r == nil
    return 0
  else
    return @cursor_r
  end
end
def get_cursor_green
  if @cursor_g == nil
    return 0
  else
  return @cursor_g
  end
end
def get_cursor_blue
  if @cursor_b == nil
    return 0
  else
  return @cursor_b
  end
end
def get_cursor_gray
  if @cursor_s == nil
    return 0
  else
  return @cursor_s
  end
end
def get_cursor_grey
  get_cursor_gray
end

def set_cursor_red(value)
  @cursor_r=value
  @cursor_r=-255 if @cursor_r<-255
  @cursor_r=255 if @cursor_r>255
end
def set_cursor_green(value)
  @cursor_g=value
  @cursor_g=-255 if @cursor_g<-255
  @cursor_g=255 if @cursor_g>255
end
def set_cursor_blue(value)
  @cursor_b=value
  @cursor_b=-255 if @cursor_b<-255
  @cursor_b=255 if @cursor_b>255
end
def set_cursor_gray(value)
  @cursor_s=value
  @cursor_s=0 if @cursor_s<0
  @cursor_s=255 if @cursor_s>255
end
def set_cursor_grey(value)
  set_cursor_gray(value)
end

def increase_cursor_red(value)
  @cursor_r+=value
  @cursor_r=-255 if @cursor_r<-255
  @cursor_r=255 if @cursor_r>255
end
def increase_cursor_green(value)
  @cursor_g+=value
  @cursor_g=-255 if @cursor_g<-255
  @cursor_g=255 if @cursor_g>255
end
def increase_cursor_blue(value)
  @cursor_b+=value
  @cursor_b=-255 if @cursor_b<-255
  @cursor_b=255 if @cursor_b>255
end
def increase_cursor_gray(value)
  @cursor_s+=value
  @cursor_s=0 if @cursor_s<0
  @cursor_s=255 if @cursor_s>255
end
def increase_cursor_grey(value)
  increase_cursor_gray(value)
end

def get_cursor_red
  if @cursor_r == nil
    return 0
  else
    return @cursor_r
  end
end
def get_cursor_green
  if @cursor_g == nil
    return 0
  else
  return @cursor_g
  end
end
def get_cursor_blue
  if @cursor_b == nil
    return 0
  else
  return @cursor_b
  end
end
def get_cursor_gray
  if @cursor_s == nil
    return 0
  else
  return @cursor_s
  end
end
def get_cursor_grey
  get_cursor_gray
end

def set_border_red(value)
  @border_r=value
  @border_r=-255 if @border_r<-255
  @border_r=255 if @border_r>255
end
def set_border_green(value)
  @border_g=value
  @border_g=-255 if @border_g<-255
  @border_g=255 if @border_g>255
end
def set_border_blue(value)
  @border_b=value
  @border_b=-255 if @border_b<-255
  @border_b=255 if @border_b>255
end
def set_border_gray(value)
  @border_s=value
  @border_s=0 if @border_s<0
  @border_s=255 if @border_s>255
end
def set_border_grey(value)
  set_border_gray(value)
end

def increase_border_red(value)
  @border_r+=value
  @border_r=-255 if @border_r<-255
  @border_r=255 if @border_r>255
end
def increase_border_green(value)
  @border_g+=value
  @border_g=-255 if @border_g<-255
  @border_g=255 if @border_g>255
end
def increase_border_blue(value)
  @border_b+=value
  @border_b=-255 if @border_b<-255
  @border_b=255 if @border_b>255
end
def increase_border_gray(value)
  @border_s+=value
  @border_s=0 if @border_s<0
  @border_s=255 if @border_s>255
end
def increase_border_grey(value)
  increase_border_gray(value)
end

def contents_opacity=(value)
  @contents_opacity=value
  @contents_opacity=0 if @contents_opacity<0
  @contents_opacity=255 if @contents_opacity>255
  privRefresh
end

def tone=(value)
  @tone=value
  privRefresh
end
def color=(value)
  @color=value
  privRefresh
end
def blend_type=(value)
  @blend_type=value
  privRefresh
end
def flash(color,duration)
  return if disposed?
  for i in @sprites
  i[1].flash(color,duration)
  end
end
def update
  return if disposed?
  mustchange=false
  if @active
  if @cursorblink==0
    @cursoropacity-=8
    @cursorblink=1 if @cursoropacity<=128
  else
    @cursoropacity+=8
    @cursorblink=0 if @cursoropacity>=255
  end
  mustchange=true if !@cursor_rect.isEmpty?
  else
  mustchange=true if @cursoropacity!=128
  @cursoropacity=128
  end
  if @pause
  @pauseframe=(Graphics.frame_count / 8) % 4
  @pauseopacity=[@pauseopacity+64,255].min
  mustchange=true
  end
  privRefresh if mustchange
  for i in @sprites
  i[1].update
  end
end
private
def ensureBitmap(bitmap,dwidth,dheight)
  if !bitmap||bitmap.disposed?||bitmap.width<dwidth||bitmap.height<dheight
  bitmap.dispose if bitmap
  bitmap=Bitmap.new([1,dwidth].max,[1,dheight].max)
  end
  return bitmap
end
def tileBitmap(dstbitmap,dstrect,srcbitmap,srcrect)
  return if !srcbitmap || srcbitmap.disposed?
  left=dstrect.x
  top=dstrect.y
  y=0;loop do break unless y<dstrect.height
  x=0;loop do break unless x<dstrect.width
    dstbitmap.blt(x+left,y+top,srcbitmap,srcrect)
    x+=srcrect.width
  end
  y+=srcrect.height
  end
end
def privRefresh(changeBitmap=false)
  return if self.disposed?
  backopac=self.back_opacity*self.opacity/255
  contopac=self.contents_opacity
  cursoropac=@cursoropacity*contopac/255
  for i in 0...4
  @sprites["corner#{i}"].bitmap=@_windowskin
  @sprites["scroll#{i}"].bitmap=@_windowskin
  end
  @sprites["pause"].bitmap=@_windowskin
  @sprites["contents"].bitmap=@contents
  if @_windowskin && !@_windowskin.disposed?
  for i in 0...4
    @sprites["corner#{i}"].opacity=@opacity
    @sprites["corner#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["corner#{i}"].color=@color
    @sprites["corner#{i}"].blend_type=@blend_type
    @sprites["corner#{i}"].visible=@visible
    @sprites["side#{i}"].opacity=@opacity
    @sprites["side#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["side#{i}"].color=@color
    @sprites["side#{i}"].blend_type=@blend_type
    @sprites["side#{i}"].visible=@visible
    @sprites["scroll#{i}"].opacity=@opacity
    @sprites["scroll#{i}"].tone=Tone.new(@border_r, @border_g, @border_b, @border_s)
    @sprites["scroll#{i}"].blend_type=@blend_type
    @sprites["scroll#{i}"].color=@color
    @sprites["scroll#{i}"].visible=@visible
  end
  @sprites["back"].color=@color
  @sprites["back"].tone=Tone.new(@back_r, @back_g, @back_b, @back_s)
  @sprites["back"].blend_type=@blend_type

  @sprites["cursor"].color=@color
  @sprites["cursor"].tone=Tone.new(@cursor_r, @cursor_g, @cursor_b, @cursor_s)
  @sprites["cursor"].blend_type=@blend_type

  @sprites["pause"].color=@color
  @sprites["pause"].tone=@tone
  @sprites["pause"].blend_type=@blend_type

  @sprites["contents"].color=@color
  @sprites["contents"].tone=@tone
  @sprites["contents"].blend_type=@blend_type

  @sprites["contents"].blend_type=@contents_blend_type
  @sprites["back"].opacity=backopac
  @sprites["contents"].opacity=contopac
  @sprites["cursor"].opacity=cursoropac
  @sprites["pause"].opacity=@pauseopacity
  @sprites["back"].visible=@visible
  @sprites["contents"].visible=@visible && @openness==255
  @sprites["pause"].visible=@visible && @pause
  @sprites["cursor"].visible=@visible && @openness==255
  hascontents=(@contents && !@contents.disposed?)
  @sprites["scroll0"].visible = @visible && hascontents && @oy > 0
  @sprites["scroll1"].visible = @visible && hascontents && @ox > 0
  @sprites["scroll2"].visible = @visible && hascontents && (@contents.width - @ox) > @width-32
  @sprites["scroll3"].visible = @visible && hascontents && (@contents.height - @oy) > @height-32
  else
  for i in 0...4
    @sprites["corner#{i}"].visible=false
    @sprites["side#{i}"].visible=false
    @sprites["scroll#{i}"].visible=false
  end
  @sprites["contents"].visible=@visible && @openness==255
  @sprites["contents"].color=@color
  @sprites["contents"].tone=@tone
  @sprites["contents"].blend_type=@contents_blend_type
  @sprites["contents"].opacity=contopac
  @sprites["back"].visible=false
  @sprites["pause"].visible=false
  @sprites["cursor"].visible=false
  end
  for i in @sprites
  i[1].z=@z
  end
  if @rpgvx
    @sprites["cursor"].z=@z#+1
    @sprites["contents"].z=@z#+2
    @sprites["pause"].z=@z#+2
  else
    @sprites["cursor"].z=@z+1
    @sprites["contents"].z=@z+2
    @sprites["pause"].z=@z+2
  end
  if @rpgvx
  trimX=64
  trimY=0
  backRect=Rect.new(0,0,64,64)
  blindsRect=Rect.new(0,64,64,64)
  else
  trimX=128
  trimY=0
  backRect=Rect.new(0,0,128,128)
  blindsRect=nil
  end
  @sprites["corner0"].src_rect.set(trimX,trimY+0,16,16);
  @sprites["corner1"].src_rect.set(trimX+48,trimY+0,16,16);
  @sprites["corner2"].src_rect.set(trimX,trimY+48,16,16);
  @sprites["corner3"].src_rect.set(trimX+48,trimY+48,16,16);
  @sprites["scroll0"].src_rect.set(trimX+24, trimY+16, 16, 8) # up
  @sprites["scroll3"].src_rect.set(trimX+24, trimY+40, 16, 8) # down
  @sprites["scroll1"].src_rect.set(trimX+16, trimY+24, 8, 16) # left
  @sprites["scroll2"].src_rect.set(trimX+40, trimY+24, 8, 16) # right
  cursorX=trimX
  cursorY=trimY+64
  sideRects=[
  Rect.new(trimX+16,trimY+0,32,16),
  Rect.new(trimX,trimY+16,16,32),
  Rect.new(trimX+48,trimY+16,16,32),
  Rect.new(trimX+16,trimY+48,32,16)
  ]
  if @width>32 && @height>32
  @sprites["contents"].src_rect.set(@ox,@oy,@width-32,@height-32)
  else
  @sprites["contents"].src_rect.set(0,0,0,0)
  end
  pauseRects=[
  trimX+32,trimY+64,
  trimX+48,trimY+64,
  trimX+32,trimY+80,
  trimX+48,trimY+80,
  ]
  pauseWidth=16
  pauseHeight=16
  @sprites["pause"].src_rect.set(
    pauseRects[@pauseframe*2],
    pauseRects[@pauseframe*2+1],
    pauseWidth,pauseHeight
  )
  @sprites["pause"].x=(@x+(@width/2)-(pauseWidth/2))#+216
  @sprites["pause"].y=(@y+@height-16)#-8
  @sprites["contents"].x=@x+16
  @sprites["contents"].y=@y+16
  @sprites["corner0"].x=@x
  @sprites["corner0"].y=@y
  @sprites["corner1"].x=@x+@width-16
  @sprites["corner1"].y=@y
  @sprites["corner2"].x=@x
  @sprites["corner2"].y=@y+@height-16
  @sprites["corner3"].x=@x+@width-16
  @sprites["corner3"].y=@y+@height-16
  @sprites["side0"].x=@x+16
  @sprites["side0"].y=@y
  @sprites["side1"].x=@x
  @sprites["side1"].y=@y+16
  @sprites["side2"].x=@x+@width-16
  @sprites["side2"].y=@y+16
  @sprites["side3"].x=@x+16
  @sprites["side3"].y=@y+@height-16
  @sprites["scroll0"].x = @x+@width / 2 - 8
  @sprites["scroll0"].y = @y+8
  @sprites["scroll1"].x = @x+8
  @sprites["scroll1"].y = @y+@height / 2 - 8
  @sprites["scroll2"].x = @x+@width - 16
  @sprites["scroll2"].y = @y+@height / 2 - 8
  @sprites["scroll3"].x = @x+@width / 2 - 8
  @sprites["scroll3"].y = @y+@height - 16
  @sprites["back"].x=@x+2
  @sprites["back"].y=@y+2
  @sprites["cursor"].x=@x+16+@cursor_rect.x
  @sprites["cursor"].y=@y+16+@cursor_rect.y
  if changeBitmap && @_windowskin && !@_windowskin.disposed?
  width=@cursor_rect.width
  height=@cursor_rect.height
  if width > 0 && height > 0
      cursorrects=[
      # sides
      Rect.new(cursorX+2, cursorY+0, 28, 2),
      Rect.new(cursorX+0, cursorY+2, 2, 28),
      Rect.new(cursorX+30, cursorY+2, 2, 28),
      Rect.new(cursorX+2, cursorY+30, 28, 2),
      # corners
      Rect.new(cursorX+0, cursorY+0, 2, 2),
      Rect.new(cursorX+30, cursorY+0, 2, 2),
      Rect.new(cursorX+0, cursorY+30, 2, 2),
      Rect.new(cursorX+30, cursorY+30, 2, 2),
      # back
      Rect.new(cursorX+2, cursorY+2, 28, 28)
      ]
      margin=2
      fullmargin=4
       
      @cursorbitmap = ensureBitmap(@cursorbitmap, width, height)
      @cursorbitmap.clear
      @sprites["cursor"].bitmap=@cursorbitmap
      @sprites["cursor"].src_rect.set(0,0,width,height)
      rect = Rect.new(margin,margin,
                      width - fullmargin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8])
      @cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4])# top left
      @cursorbitmap.blt(width-margin, 0, @_windowskin, cursorrects[5]) # top right
      @cursorbitmap.blt(0, height-margin, @_windowskin, cursorrects[6]) # bottom right
      @cursorbitmap.blt(width-margin, height-margin, @_windowskin, cursorrects[7]) # bottom left
      rect = Rect.new(margin, 0,
                      width - fullmargin, margin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
      rect = Rect.new(0, margin,
                      margin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[1])
      rect = Rect.new(width - margin, margin,
                      margin, height - fullmargin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2])
      rect = Rect.new(margin, height-margin,
                      width - fullmargin, margin)
      @cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3])
  else
      @sprites["cursor"].visible=false
      @sprites["cursor"].src_rect.set(0,0,0,0)
  end
  for i in 0..3
    dwidth=(i==0||i==3) ? @width-32 : 16
    dheight=(i==0||i==3) ? 16 : @height-32
    @sidebitmaps[i]=ensureBitmap(@sidebitmaps[i],dwidth,dheight)
    @sprites["side#{i}"].bitmap=@sidebitmaps[i]
    @sprites["side#{i}"].src_rect.set(0,0,dwidth,dheight)
    @sidebitmaps[i].clear
    if sideRects[i].width>0 && sideRects[i].height>0
    @sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
      @_windowskin,sideRects[i])
    end
  end
  backwidth=@width-4
  backheight=@height-4
  if backwidth>0 && backheight>0
    @backbitmap=ensureBitmap(@backbitmap,backwidth,backheight)
    @sprites["back"].bitmap=@backbitmap
    @sprites["back"].src_rect.set(0,0,backwidth,backheight)
    @backbitmap.clear
    if @stretch
    @backbitmap.stretch_blt(@sprites["back"].src_rect,@_windowskin,backRect)
    else
    tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,backRect)
    end
    if blindsRect
    tileBitmap(@backbitmap,@sprites["back"].src_rect,@_windowskin,blindsRect)
    end
  else
    @sprites["back"].visible=false
    @sprites["back"].src_rect.set(0,0,0,0)
  end
  end
  if @openness!=255
  opn=@openness/255.0
  for k in @spritekeys
    sprite=@sprites[k]
    ratio=(@height<=0) ? 0 : (sprite.y-@y)*1.0/@height
    sprite.zoom_y=opn
    sprite.oy=0
    sprite.y=(@y+(@height/2.0)+(@height*ratio*opn)-(@height/2*opn)).floor
  end
  else
  for k in @spritekeys
    sprite=@sprites[k]
    sprite.zoom_y=1.0
  end
  end
  i=0
  for k in @spritekeys
  sprite=@sprites[k]
  y=sprite.y
  sprite.y=i
  sprite.oy=(sprite.zoom_y<=0) ? 0 : (i-y)/sprite.zoom_y
  end
end
end



Instructions

The next codes can be used also changing 'back' to 'cursor' or 'border' depending on the situation. I used the 'back' case because it's maybe the most common.

The next controls return the actual red,green,blue or gray tone of the window
@window.get_back_red
@window.get_back_green
@window.get_back_blue
@window.get_back_gray

To manage that you can do it in two ways, the first one to change the color directly (value from -255 to 255 on red/green/blue and 0 to 255 for grey)
@window.set_back_red(value)
@window.set_back_green(value)
@window.set_back_blue(value)
@window.set_back_gray(value)

Or you can change it increasing the value to the actual tone.
@window.increase_back_red(valor)
@window.increase_back_green(valor)
@window.increase_back_blue(valor)
@window.increase_back_gray(valor)


I made an easy example for RMXP, too. You can check it:

#==============================================================================
# [RMXP] Window Tone Example (by Wecoc)
# This scripts changes "Status" to a tone management window.
#==============================================================================

#==============================================================================
# * Scene_Menu edit
#==============================================================================

class Scene_Menu

  def main
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Color test"
    s5 = "Save"
    s6 = "Quit"
    @command_window = Window_Command.new(160, [s1, s2, s3, s4, s5, s6])
    @command_window.index = @menu_index
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    @playtime_window = Window_PlayTime.new
    @playtime_window.x = 0
    @playtime_window.y = 224
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 320
    @gold_window = Window_Gold.new
    @gold_window.x = 0
    @gold_window.y = 416
    @status_window = Window_MenuStatus.new
    @status_window.x = 160
    @status_window.y = 0
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @playtime_window.dispose
    @steps_window.dispose
    @gold_window.dispose
    @status_window.dispose
  end

  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
      return
    end
    if Input.trigger?(Input::C)
      if $game_party.actors.size == 0 and @command_window.index < 4
        $game_system.se_play($data_system.buzzer_se)
        return
      end
      case @command_window.index
      when 0  # item
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1  # skill
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2  # equipment
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3  # status
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_ColorWindow.new
      when 4  # save
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5  # end game
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
      return
    end
  end
end


#==========================================================
# * Scene_ColorWindow by Wecoc
#==========================================================

class Scene_ColorWindow
  def main
    s1 = "Red"
    s2 = "Green"
    s3 = "Blue"
    s4 = "Gray"
    @color_window = Window_Command.new(200, [s1, s2, s3, s4])
    @color_window.x = 240
    @color_window.y = 240
    refresh
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @color_window.dispose
  end

  def refresh
    @r = @color_window.get_back_red
    @g = @color_window.get_back_green
    @b = @color_window.get_back_blue
    @s = @color_window.get_back_gray
    @color_window.refresh
    @color_window.contents.draw_text(64, 0,100,32,@r.to_s,2)
    @color_window.contents.draw_text(64,32,100,32,@g.to_s,2)
    @color_window.contents.draw_text(64,64,100,32,@b.to_s,2)
    @color_window.contents.draw_text(64,96,100,32,@s.to_s,2)
  end

  def update
    @color_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(3)
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $scene = Scene_Menu.new(3)
      return
    end
    if Input.repeat?(Input::RIGHT)
      $game_system.se_play($data_system.cursor_se)
      case @color_window.index
      when 0 # red
        if @r == -255
          @color_window.increase_back_red(5)
        else
          @color_window.increase_back_red(10)
        end
      when 1 # green
        if @g == -255
          @color_window.increase_back_green(5)
        else
          @color_window.increase_back_green(10)
        end
      when 2 #blue
        if @b == -255
          @color_window.increase_back_blue(5)
        else
          @color_window.increase_back_blue(10)
        end
      when 3 #gray
        @color_window.increase_back_gray(10)
      end
      refresh
    end
    if Input.repeat?(Input::LEFT)
      $game_system.se_play($data_system.cursor_se)
      case @color_window.index
      when 0 # red
        if @r == 255
          @color_window.increase_back_red(-5)
        else
          @color_window.increase_back_red(-10)
        end
      when 1 # green
        if @g == 255
          @color_window.increase_back_green(-5)
        else
          @color_window.increase_back_green(-10)
        end
      when 2 #blue
        if @b == 255
          @color_window.increase_back_blue(-5)
        else
          @color_window.increase_back_blue(-10)
        end
      when 3 #gray
        if @s == 255
          @color_window.increase_back_gray(-5)
        else
          @color_window.increase_back_gray(-10)
        end
      end
      refresh
    end
  end
end



Compatibility

No compatibility issues found.


Credits and Thanks


  • Pokemon Essentials - for the original code source

  • Wecoc - for the simple add-on




Author's Notes

If you have any problem with that script or with incompatibilities don't hestitate to ask.