Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Changing Window Styles in Game
#1
Hi All,

I need help with a script that is meant to change windows styles during the game. A menu lets you select the window styles and should then apply them. This is working as styles for menus and the battle scenes do change but doesn't seem to apply to text boxes when talking to characters...

Script is below from the whole of the options screen -the section I believe controls the windows styles is Window_Windowskin: have I missed something?


Code:
#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base
  #--------------------------------------------------------------------------
  def draw_meter(now, max, x, y, width, height, start_color, end_color=start_color )
    self.contents.fill_rect(x, y, width, height, Color.new(0,0,0,255))
    now = now > max ? max : now
    percentage = max != 0 ? (width) * now / max.to_f : 0
    if start_color == end_color
      self.contents.fill_rect(x, y, percentage, height, start_color)
    else
      for i in 0..percentage-1
        r = start_color.red + (end_color.red - start_color.red) / percentage * i
        g = start_color.green + (end_color.green - start_color.green) / percentage * i
        b = start_color.blue + (end_color.blue - start_color.blue) / percentage * i
        a = start_color.alpha + (end_color.alpha - start_color.alpha) / percentage * i
        self.contents.fill_rect(x+i, y, 1, height, Color.new(r, g, b, a))
      end
    end
  end
  #--------------------------------------------------------------------------
end


#==============================================================================
# ■ Window_Option
#==============================================================================

class Window_Option < Window_Base
  #--------------------------------------------------------------------------
  def initialize
    super(6*32, 128, 13*32+16, 2*24+32)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = "Berlin Sans FB"
    self.contents.font.size = 20
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    
    self.contents.fill_rect(20, 0+10, 200, 6, Color.new(0, 0, 0, 255))
    self.contents.fill_rect(20, 24+10, 200, 6, Color.new(0, 0, 0, 255))
    
    draw_meter($game_system.se_volume, 100, 21, 1+10, 198, 4, Color.new(255, 255, 255, 255))
    draw_meter($game_system.me_volume, 100, 21, 25+10, 198, 4, Color.new(255, 255, 255, 255))
    
    self.contents.font.color = Color.new( 80, 32, 32)
    self.contents.draw_text(0, 0, width-32, 24, "0")
    self.contents.draw_text(224, 0, 32, 24, "100")
    self.contents.draw_text(0, 0, width-32-2, 24, $game_system.se_volume.to_s + "/ 100", 2)

    self.contents.draw_text(0, 24, width-32, 24, "0")
    self.contents.draw_text(224, 24, 32, 24, "100")
    self.contents.draw_text(0, 24, width-32-2, 24, $game_system.me_volume.to_s + "/ 100", 2)
  end
  #--------------------------------------------------------------------------
end


#==============================================================================
# ■ Window_OptionCommand
#==============================================================================

class Window_OptionCommand < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(16, 160, 5*32, 4*24+32)
    @commands = [" ", " ", " ", " "]
    @description = ["",
                                "",
                                "",
                                ""]
    @item_max = 4
    @column_max = 1
    self.contents = Bitmap.new(width - 32, height-32)
    self.contents.font.name = "Berlin Sans FB"
    self.contents.font.size = 20
    for i in 0..(@item_max-1)
      draw_item(i, normal_color)
    end
    self.z = 200
    self.index = 0
  end
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = Color.new( 80, 32, 32)
    rect = Rect.new(0, 24*index, width-32, 24)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], 1)
  end
  #--------------------------------------------------------------------------
  def update_help
    @help_window.set_text(@description[index], 1)
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    self.cursor_rect.set(0, 24*index, width-32, 24)
  end
  #--------------------------------------------------------------------------
end


#==============================================================================
# ■ Window_Windowskin
#==============================================================================

class Window_Windowskin < Window_Selectable
  #--------------------------------------------------------------------------
  def initialize
    super(6*32, 128+3*24+8, 13*32+16, 32+64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.index = -1
    self.active = false
    @column_max = @item_max = 3#ZVB# Inserisci il numero di windowskin presenti nell'omonima cartella
    refresh
  end
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0..@item_max-1
      x = i % @column_max * (width-32)/@column_max
      y = i / @column_max * 64
      bitmap = RPG::Cache.windowskin("Windowskin#{i + 1}")
      self.contents.blt(x, y, bitmap, Rect.new(64, 0, 128, 64), 255)
    end
  end
  #--------------------------------------------------------------------------
  def update_cursor_rect
    x = index % @column_max * (width-32)/@column_max
    y = index / @column_max * 64
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(x, y, 128, 64)
    end
  end
  #--------------------------------------------------------------------------
end


#==============================================================================
# ■ Scene_Option
#==============================================================================

class Scene_Option
  #--------------------------------------------------------------------------
  def initialize(index=0)
    @index = index
  end
  #--------------------------------------------------------------------------
  def main
    @command_window = Window_OptionCommand.new
    @help_window = Window_Help.new
    @command_window.help_window = @help_window
    @option_window = Window_Option.new
    @windowskin_window = Window_Windowskin.new
    @se_regulation = false
    @me_regulation = false
    @menu = Plane.new    
    @menu.bitmap = RPG::Cache.picture("opzioni")
    @menu.opacity = 255
    @command_window .windowskin = RPG::Cache.windowskin("vuota")
    @help_window .windowskin = RPG::Cache.windowskin("vuota")
    @option_window .windowskin = RPG::Cache.windowskin("vuota")
    @windowskin_window .windowskin = RPG::Cache.windowskin("vuota")
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @command_window.dispose
    @option_window.dispose
    @windowskin_window.dispose
  end
  #--------------------------------------------------------------------------
  def update
    @help_window.update
    @command_window.update
    @option_window.update
    @windowskin_window.update
    if @command_window.active
      @command_window.help_window = @help_window
      update_command
      return
    end
    if @windowskin_window.active
      @help_window.set_text("")
      update_windowskin
      return
    end
    if @se_regulation == true
      update_se_regulation
    end
    if @me_regulation == true
      update_me_regulation
    end
  end
  #--------------------------------------------------------------------------
  def update_command
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Menu.new(4)
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @se_regulation = true
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @me_regulation = true
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @windowskin_window.index = 0
        @windowskin_window.active = true
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Formation.new
      end
      return
    end
  end
  #--------------------------------------------------------------------------
  def update_se_regulation
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @se_regulation = false
      @command_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @se_regulation = false
      @command_window.active = true
      return
    end
    if Input.repeat?(Input::RIGHT) and $game_system.se_volume < 100
      $game_system.se_play($data_system.cursor_se)
      $game_system.se_volume += 1
      @option_window.refresh
    end
    if Input.repeat?(Input::LEFT) and $game_system.se_volume > 0
      $game_system.se_play($data_system.cursor_se)
      $game_system.se_volume -= 1
      @option_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  def update_me_regulation
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @me_regulation = false
      @command_window.active = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @me_regulation = false
      @command_window.active = true
      return
    end
    if Input.repeat?(Input::RIGHT) and $game_system.me_volume < 100
      $game_system.me_volume += 1
      
      $game_system.bgm_memorize
      $game_system.bgm_stop
      $game_system.bgm_restore
      
      @option_window.refresh
    end
    if Input.repeat?(Input::LEFT) and $game_system.me_volume > 0
      $game_system.me_volume -= 1
      
      $game_system.bgm_memorize
      $game_system.bgm_stop
      $game_system.bgm_restore
      
      @option_window.refresh
    end
  end
  #--------------------------------------------------------------------------
  def update_windowskin
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @windowskin_window.active = false
      @command_window.active = true
      @windowskin_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      $data_system.windowskin_name = $game_system.windowskin_name = "Windowskin#{@windowskin_window.index + 1}"
      return
    end
  end
  #--------------------------------------------------------------------------
end

Here is a video of the current behaviour if it helps...

http://www.mediafire.com/?6gg5v9f8yrnstgb

As always any help or pointers would be appreciated - Many Thanks!
Reply }


Messages In This Thread
Changing Window Styles in Game - by JackMonty - 03-09-2013, 12:07 PM
RE: Changing Window Styles in Game - by JackMonty - 03-11-2013, 12:26 AM
RE: Changing Window Styles in Game - by JackMonty - 03-19-2013, 02:36 PM
RE: Changing Window Styles in Game - by JackMonty - 03-21-2013, 11:54 PM
RE: Changing Window Styles in Game - by JackMonty - 03-22-2013, 11:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
   Sorting Items in Shop Window Melana 13 15,635 01-18-2018, 05:49 AM
Last Post: DerVVulfman
   Game Performance Melana 21 19,290 11-24-2016, 03:42 AM
Last Post: finalholylight
   Showing only specific skills in a window Melana 2 5,372 01-12-2016, 01:34 PM
Last Post: Melana
   Game Variables List for Copy/Paste JayRay 4 6,291 01-15-2015, 06:18 AM
Last Post: JayRay
   [RMXP]Game Over and Atoa Battle Status mishaps firestalker 8 9,749 08-07-2014, 01:59 AM
Last Post: firestalker
   [Brainstorming] Pallete Changing. MechanicalPen 6 6,799 02-14-2014, 09:46 PM
Last Post: DerVVulfman
   Help with changing background music volume JackMonty 7 8,497 12-10-2012, 10:59 AM
Last Post: JackMonty
   Something I noticed about the Advanced Shop Status Window yamina-chan 5 9,140 08-21-2011, 09:16 PM
Last Post: yamina-chan
   [Atoa SBS] Changing the command window font MegaPowerNinja 3 7,627 04-12-2011, 10:23 PM
Last Post: Victor Sant
   Repositioning the actor command window. MegaPowerNinja 4 8,603 04-12-2011, 05:21 AM
Last Post: MegaPowerNinja



Users browsing this thread: