WindowSkins XP
#1
WindowSkins XP

by Kyonides

Introduction

There was once a forumer that just wanted to be able to change a windowskin at will. Even if the guy never mentioned using a menu to achieve this goal, I simply went back to my script testing lab and came up with this script.

It overwrites Scene_Title's update method.

The script is compatible with Scene_Title and Scene_Menu, but the latter has not been altered at all.

The TITLE_COMMANDS array contains the commands that will be displayed on the title screen.

Every SKINS array entry will include a pair of strings as seen in this example here:

SKINS << ["Skin Name", "File Name"]

The MENU_POS constant tells the script which menu option it should pick after going back to the main menu screen.

The Script

Code:
# * WindowSkins XP * #
#  Scripter : Kyonides
#  2024-11-15

module WindowSkin
  TITLE_COMMANDS = []
  TITLE_COMMANDS << "New Game"
  TITLE_COMMANDS << "Continue"
  TITLE_COMMANDS << "Windowskin"
  TITLE_COMMANDS << "Shutdown"
  MENU_POS = 0
  LABEL_CHOOSE = "Choose a Windowskin"
  LABEL_TEST = "Selected Windowskin"
  SKINS = []
  SKINS << ["Default", "001-Blue01"]
  SKINS << ["Windows Vista", "Windows Vista"]
  SKINS << ["", ""]
  extend self
  @index = MENU_POS
  attr_accessor :index, :scene_class
  def open_scene
    if @scene_class == Scene_Title
      $scene = @scene_class.new
    elsif @scene_class == Scene_Menu
      $scene = @scene_class.new(SCENE_MENU_POS)
    else
      print "Next scene class remains unconfigured."
    end
  end
end

class Game_System
  alias :kyon_win_skin_gm_sys_init :initialize
  def initialize
    kyon_win_skin_gm_sys_init
    windowskin_index
    reset_windowskin_name
  end

  def windowskin_index
    @windowskin_index ||= WindowSkin.index
  end

  def reset_windowskin_name
    @windowskin_name = WindowSkin::SKINS[@windowskin_index][1]
  end
  attr_writer :windowskin_index
end

class Window_Base
  attr_writer :windowskin_name
end

class Window_Command
  def reset_commands(commands)
    @item_max = commands.size
    @commands = commands
    self.height = @item_max * 32 + 32
    self.contents.dispose
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
  end
end

class Scene_Title
  def reset_command_window
    @command_window.reset_commands(WindowSkin::TITLE_COMMANDS)
    @command_window.disable_item(1) unless @continue_enabled
    @reset_commands = true
  end

  def update
    unless @reset_commands
      reset_command_window
      return
    end
    @command_window.update
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        command_new_game
      when 1
        command_continue
      when 2
        command_windowskin
      when 3
        command_shutdown
      end
    end
  end

  def command_windowskin
    WindowSkin.scene_class = $scene.class
    $scene = WindowScene.new
  end
end

class WindowScene
  include WindowSkin
  def main
    start
    Graphics.transition
    main_loop
    Graphics.freeze
    dispose
  end

  def reset_windowskin
    skin = SKINS[@index][1]
    $game_system.windowskin_name = skin
  end

  def start
    @index = $game_system.windowskin_index
    reset_windowskin
    options = SKINS.map {|entry| entry[0] }
    @running = true
    @help_window = Window_Help.new
    @help_window.set_text(LABEL_CHOOSE, 1)
    @command_window = Window_Command.new(180, options)
    @command_window.y = 64
    @command_window.index = @index
    @dummy_window = Window_Base.new(220, 96, 300, 64)
    bitmap = Bitmap.new(@dummy_window.width - 32, @dummy_window.height - 32)
    bitmap.draw_text(bitmap.rect, LABEL_TEST, 1)
    @dummy_window.contents = bitmap
  end

  def dispose
    @dummy_window.dispose
    @command_window.dispose
    @help_window.dispose
  end

  def main_loop
    while @running
      Graphics.update
      Input.update
      update
    end
  end

  def update
    @command_window.update
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      WindowSkin.open_scene
      return @running = nil
    elsif Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @index = @command_window.index
      WindowSkin.index = @index
      reset_windowskin
      @dummy_window.update
      @help_window.update
    end
  end
end

Terms & Conditions

Free for use in ANY game! Gamer
Due credit is mandatory.
Mention this forum as well.
That's it! Tongue sticking out
"For God has not destined us for wrath, but for obtaining salvation through our Lord Jesus Christ," 1 Thessalonians 5:9

Maranatha!

The Internet might be either your friend or enemy. It just depends on whether or not she has a bad hair day.

[Image: SP1-Scripter.png]
[Image: SP1-Writer.png]
[Image: SP1-Poet.png]
[Image: SP1-PixelArtist.png]
[Image: SP1-Reporter.png]

My Original Stories (available in English and Spanish)

List of Compiled Binary Executables I have published...
HiddenChest & Roole

Give me a free copy of your completed game if you include at least 3 of my scripts! Laughing + Tongue sticking out

Just some scripts I've already published on the board...
KyoGemBoost XP VX & ACE, RandomEnkounters XP, KSkillShop XP, Kolloseum States XP, KEvents XP, KScenario XP & Gosu, KyoPrizeShop XP Mangostan, Kuests XP, KyoDiscounts XP VX, ACE & MV, KChest XP VX & ACE 2016, KTelePort XP, KSkillMax XP & VX & ACE, Gem Roulette XP VX & VX Ace, KRespawnPoint XP, VX & VX Ace, GiveAway XP VX & ACE, Klearance XP VX & ACE, KUnits XP VX, ACE & Gosu 2017, KLevel XP, KRumors XP & ACE, KMonsterPals XP VX & ACE, KStatsRefill XP VX & ACE, KLotto XP VX & ACE, KItemDesc XP & VX, KPocket XP & VX, OpenChest XP VX & ACE
Reply }


Messages In This Thread
WindowSkins XP - by kyonides - Yesterday, 08:14 AM



Users browsing this thread: 2 Guest(s)