Save-Point
Use iconsets in XP - LegACy - Printable Version

+- Save-Point (https://www.save-point.org)
+-- Forum: Material Development (https://www.save-point.org/forum-8.html)
+--- Forum: Scripts Database (https://www.save-point.org/forum-39.html)
+---- Forum: RPGMaker XP (RGSS) Engine (https://www.save-point.org/forum-116.html)
+---- Thread: Use iconsets in XP - LegACy (/thread-721.html)



Use iconsets in XP - LegACy - Legacy - 02-19-2010

VX iconsets in XP - by LegACy
[size=normal]Version 1.0[/size]

Description:
This little snippet allows you to use IconSets instead of single files for icons, just like VX. Easy to install and easy to use.

Compatibility:
no issues so far.

Screenshots:
[Image: 76376419.png]

Instructions:

Place above main, and above any custom scripts. So, place under Scene_Debug.

to use follow this syntax: draw_icon(file_name, icon_index, x, y)
- file_name : the file name for the iconset
- icon_index : Icon number
- x : draw spot x-coordinate
- y : draw spot y-coordinate

* All iconsets must be placed in the Pictures folder.

for the VX iconset, and the set used in the Example please use this:

[Image: iconset.png]

Main Script:

Code:
#=======================================================
# ~** VX iconsets in XP **~
#=======================================================
#  Author:      LegACy  (LegacyX)
#  Version:     1.0
#  Build Date:  2009-02-26
#-------------------------------------------------------------------------------
#
#   This little snippet allows you to use VX iconsets in XP
#
#========================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # * Draw Icon
  #     file_name : the file name for the iconset
  #     icon_index : Icon number
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     enabled    : Enabled flag. When false, draw semi-transparently.
  #--------------------------------------------------------------------------
  def draw_icon(file_name,icon_index, x, y, enabled = true)
    bitmap = RPG::Cache.picture(file_name.to_s)
    rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
    self.contents.blt(x, y, bitmap, rect, enabled ? 255 : 128)
  end
  
end

Example Window using this script:

Code:
class Sample_Window < Window_Base
  #----------------------------------------------------------------------
  # * Object Initialization
  #----------------------------------------------------------------------
  def initialize
    super(20, 20, 100, 100)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh # Calls the refresh function in this class
  end

  def refresh
   self.contents.clear
# file name is " IconSet", icon is the 5th in the set.
   self.draw_icon("IconSet", 5, 20, 30)
  end

end

To test this, make a new event, then add a call event and paste this: Sample_Window.new



Any problems or questions please ask. ~LegACy


Use iconsets in XP - LegACy - Villain - 02-19-2010

nice job! It's convinient!