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.

Window : Command Icons

Window : Command Icons
Version: 3.5
By: Kain Nobel

Introduction

Easily allows you to put icons in your command windows, without having to go through and edit other scripts.

Features

  • Will put icons in any Window_Command (or Window_HorizCommand)
  • No need to edit other scripts to achieve this effect
  • Easy to use

Screenshots

The Title...
WindowCommandIcons01.png

The Menu...
WindowCommandIcons02.png

The Battle (Party Command)...
WindowCommandIcons03.png

The Battle (Actor Command)...
WindowCommandIcons04.png

Script

Code:
#===============================================================================

# ** Window : Command Icons

#===============================================================================

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

SDK.log('Window.CommandIcons', 'Kain Nobel ©', 3.5, '2009.06.17')

#-------------------------------------------------------------------------------

# * SDK Enabled Test : Begin

#-------------------------------------------------------------------------------

if SDK.enabled?('Window.CommandIcons')

 

#===============================================================================

# ** Window_Base

#===============================================================================

 

class Window_Base < Window

  #-----------------------------------------------------------------------------

  # * Included Modules

  #-----------------------------------------------------------------------------

  include SDK::Vocab

  #-----------------------------------------------------------------------------

  # * Icons

  #-----------------------------------------------------------------------------

  Icons                         = Hash.new  # Don't tamper with

  Icons.default                 = Hash.new  # Don't tamper with

  Icons.default.default         = Hash.new  # Don't tamper with

  Icons.default.default.default = Hash.new  # Don't tamper with

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Title  : @command_window                                          #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Title', '@command_window'

  Icons[s][w][Scene_Title::New_Game] = '050-Skill07'

  Icons[s][w][Scene_Title::Continue] = '039-Item08'

  Icons[s][w][Scene_Title::Shutdown] = '046-Skill03'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Menu   : @command_window                                          #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Menu', '@command_window'

  Icons[s][w][Scene_Menu::Item]      = '032-Item01'

  Icons[s][w][Scene_Menu::Skill]     = '044-Skill01'

  Icons[s][w][Scene_Menu::Equip]     = '001-Weapon01'

  Icons[s][w][Scene_Menu::Status]    = '050-Skill07'

  Icons[s][w][Scene_Menu::Save]      = '037-Item06'

  Icons[s][w][Scene_Menu::End_Game]  = '046-Skill03'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Batte  : @actor_command_window                                    #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Battle', '@actor_command_window'

  Icons[s][w][Scene_Battle::Attack]  = '001-Weapon01'

  Icons[s][w][Scene_Battle::Skill]   = '044-Skill01'

  Icons[s][w][Scene_Battle::Guard]   = '009-Shield01'

  Icons[s][w][Scene_Battle::Item]    = '032-Item01'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Battle : @party_command_window                                    #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Battle', '@party_command_window'

  Icons[s][w][Scene_Battle::Fight]   = '001-Weapon01'

  Icons[s][w][Scene_Battle::Escape]  = '020-Accessory05'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_End    : @command_window

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_End', '@command_window'

  #-----------------------------------------------------------------------------

  # * Icon Settings

  #-----------------------------------------------------------------------------

  def icon_settings

    if @icon_settings.nil?

      scene_key       = "#{$scene.class}"

      window_key      = get_scene_instance

      @icon_settings  = Icons[scene_key][window_key]

    end

    @icon_settings

  end

  #-----------------------------------------------------------------------------

  # * Icon At?

  #-----------------------------------------------------------------------------

  def icon_at?(index)

    settings = icon_settings

    settings[@commands[index]]

  end

  #-----------------------------------------------------------------------------

  # * Command Has Icon Key?

  #-----------------------------------------------------------------------------

  def command_icon_key?(index)

    icon_settings.has_key?(@commands[index])

  end

  #-----------------------------------------------------------------------------

  # * Command Has Icon Value?

  #-----------------------------------------------------------------------------

  def command_icon_value?(index)

    icon_settings[@command[index]].is_a?(String)

  end

  #-----------------------------------------------------------------------------

  # * Command Has Icon?

  #-----------------------------------------------------------------------------

  def command_icon?(index)

    icon_settings.has_key?(@commands[index])

  end

  #-----------------------------------------------------------------------------

  # * Command Icon

  #-----------------------------------------------------------------------------

  def command_icon(index)

    RPG::Cache.icon(icon_at?(index))

  end

  #-----------------------------------------------------------------------------

  # * Get Scene Instance

  #-----------------------------------------------------------------------------

  def get_scene_instance

    $scene.instance_variables.each do |object_name|

      object = $scene.instance_variable_get(object_name)

      return object_name if object == self

    end

  end

end

 

#===============================================================================

# ** Window_Command

#===============================================================================

 

class Window_Command < Window_Selectable

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :commandicons_wincommand_drawitem, :draw_item

  #-----------------------------------------------------------------------------

  # * Draw Item

  #-----------------------------------------------------------------------------

  def draw_item(index, color)

    unless command_icon?(index)

      commandicons_wincommand_drawitem(index, color)

      return

    end

    icon = command_icon(index)

    op = (color == disabled_color ? 160 : 255)

    self.contents.blt(0, 32 * index + 4, icon, icon.rect, op)

    self.contents.font.color = color

    rect = Rect.new(28, 32 * index, self.contents.width - 28, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    self.contents.draw_text(rect, @commands[index])

  end

end

 

#===============================================================================

# ** Window_HorizCommand

#===============================================================================

 

class Window_HorizCommand < Window_Selectable

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :commandicons_winhcommand_drawitem, :draw_item

  #-----------------------------------------------------------------------------

  # * Draw Item

  #-----------------------------------------------------------------------------

  def draw_item(index, color)

    unless command_icon?(index)

      commandicons_winhcommand_drawitem(index, color)

      return

    end

    icon = command_icon(index)

    op = (color == disabled_color ? 160 : 255)

    x = index * @c_spacing + 4

    self.contents.blt(x, 4, icon, icon.rect, op)

    command = commands[index]

    x += 28

    self.contents.font.color = color

    self.contents.draw_text(x, 0, @c_spacing - 8, 32, command, @alignment)

  end

end

 

#-------------------------------------------------------------------------------

# * SDK Enabled Test : End

#-------------------------------------------------------------------------------

end
Code:
#===============================================================================

# ** Window : Command Icons

#===============================================================================

#-------------------------------------------------------------------------------

# * SDK Log

#-------------------------------------------------------------------------------

SDK.log('Window.CommandIcons', 'Kain Nobel ©', 3.5, '2009.06.17')

#-------------------------------------------------------------------------------

# * SDK Enabled Test : Begin

#-------------------------------------------------------------------------------

if SDK.enabled?('Window.CommandIcons')

 

#===============================================================================

# ** Window_Base

#===============================================================================

 

class Window_Base < Window

  #-----------------------------------------------------------------------------

  # * Included Modules

  #-----------------------------------------------------------------------------

  include SDK::Vocab

  #-----------------------------------------------------------------------------

  # * Icons

  #-----------------------------------------------------------------------------

  Icons = Hash.new  # Don't tamper with

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Title  : @command_window                                          #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Title', '@command_window'

  Icons[s] ||= Hash.new

  Icons[s][w] = Hash.new

  Icons[s][w][Scene_Title::New_Game] = '050-Skill07'

  Icons[s][w][Scene_Title::Continue] = '039-Item08'

  Icons[s][w][Scene_Title::Shutdown] = '046-Skill03'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Menu   : @command_window                                          #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Menu', '@command_window'

  Icons[s] ||= Hash.new

  Icons[s][w] = Hash.new

  Icons[s][w][Scene_Menu::Item]      = '032-Item01'

  Icons[s][w][Scene_Menu::Skill]     = '044-Skill01'

  Icons[s][w][Scene_Menu::Equip]     = '001-Weapon01'

  Icons[s][w][Scene_Menu::Status]    = '050-Skill07'

  Icons[s][w][Scene_Menu::Save]      = '037-Item06'

  Icons[s][w][Scene_Menu::End_Game]  = '046-Skill03'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Batte  : @actor_command_window                                    #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Battle', '@actor_command_window'

  Icons[s] ||= Hash.new

  Icons[s][w] = Hash.new

  Icons[s][w][Scene_Battle::Attack]  = '001-Weapon01'

  Icons[s][w][Scene_Battle::Skill]   = '044-Skill01'

  Icons[s][w][Scene_Battle::Guard]   = '009-Shield01'

  Icons[s][w][Scene_Battle::Item]    = '032-Item01'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_Battle : @party_command_window                                    #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_Battle', '@party_command_window'

  Icons[s] ||= Hash.new

  Icons[s][w] = Hash.new

  Icons[s][w][Scene_Battle::Fight]   = '001-Weapon01'

  Icons[s][w][Scene_Battle::Escape]  = '020-Accessory05'

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  # ** Scene_End    : @command_window                                          #

  #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::#

  s, w = 'Scene_End', '@command_window'

  Icons[s] ||= Hash.new

  Icons[s][w] = Hash.new

  Icons[s][w][Scene_End::To_Title]   = '001-Weapon01'

  Icons[s][w][Scene_End::Shutdown]   = '001-Weapon01'

  Icons[s][w][Scene_End::Cancel]     = '001-Weapon01'

  #-----------------------------------------------------------------------------

  # * Update

  #-----------------------------------------------------------------------------

  alias_method :commandicons_winbase_update, :update

  def update

    commandicons_winbase_update

    if self.respond_to?(:refresh) && self.respond_to?(:commands) && !@icons_set

      self.refresh

      @icons_set = true

    end

  end

  #-----------------------------------------------------------------------------

  # * Icon Settings

  #-----------------------------------------------------------------------------

  def icon_settings

    scene_key       = "#{$scene.class}"

    window_key      = get_scene_instance

    if Icons.has_key?(scene_key) && Icons[scene_key].has_key?(window_key)

      return Icons[scene_key][window_key]

    end

  end

  #-----------------------------------------------------------------------------

  # * Icon At?

  #-----------------------------------------------------------------------------

  def icon_at?(index)

    settings = icon_settings

    settings[@commands[index]]

  end

  #-----------------------------------------------------------------------------

  # * Command Icon?

  #-----------------------------------------------------------------------------

  def command_icon?(index)

    return false unless icon_settings.is_a?(Hash)

    icons = icon_settings

    icons.has_key?(@commands[index]) && icons[@commands[index]].is_a?(String)

  end

  #-----------------------------------------------------------------------------

  # * Command Icon

  #-----------------------------------------------------------------------------

  def command_icon(index)

    RPG::Cache.icon(icon_at?(index))

  end

  #-----------------------------------------------------------------------------

  # * Get Scene Instance

  #-----------------------------------------------------------------------------

  def get_scene_instance

    $scene.instance_variables.each do |object_name|

      object = $scene.instance_variable_get(object_name)

      next unless object.kind_of?(Window)

      next unless object.respond_to?(:commands)

      return object_name if object == self

    end

  end

end

 

#===============================================================================

# ** Window_Command

#===============================================================================

 

class Window_Command < Window_Selectable

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :commandicons_wincommand_drawitem, :draw_item

  #-----------------------------------------------------------------------------

  # * Draw Item

  #-----------------------------------------------------------------------------

  def draw_item(index, color)

    unless command_icon?(index)

      commandicons_wincommand_drawitem(index, color)

      return

    end

    icon = command_icon(index)

    op = (color == disabled_color ? 160 : 255)

    self.contents.blt(0, 32 * index + 4, icon, icon.rect, op)

    self.contents.font.color = color

    rect = Rect.new(28, 32 * index, self.contents.width - 28, 32)

    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

    self.contents.draw_text(rect, @commands[index])

  end

end

 

#===============================================================================

# ** Window_HorizCommand

#===============================================================================

 

class Window_HorizCommand < Window_Selectable

  #-----------------------------------------------------------------------------

  # * Alias Listings

  #-----------------------------------------------------------------------------

  alias_method :commandicons_winhcommand_drawitem, :draw_item

  #-----------------------------------------------------------------------------

  # * Draw Item

  #-----------------------------------------------------------------------------

  def draw_item(index, color)

    unless command_icon?(index)

      commandicons_winhcommand_drawitem(index, color)

      return

    end

    icon = command_icon(index)

    op = (color == disabled_color ? 160 : 255)

    x = index * @c_spacing + 4

    self.contents.blt(x, 4, icon, icon.rect, op)

    command = commands[index]

    x += 28

    self.contents.font.color = color

    self.contents.draw_text(x, 0, @c_spacing - 8, 32, command, @alignment)

  end

end

 

#-------------------------------------------------------------------------------

# * SDK Enabled Test : End

#-------------------------------------------------------------------------------

end
Instructions

Place Above Main and Below SDK, this script is already set up for Title, Menu and Battle and End Game scenes. Just follow the example of how I set it up and it should be easy enough to understand. I would suggest having this script at the bottom of your scripts, just one up from Main.

FAQ

First thing you need to do is set your keys for Scene and Window, where s is the name of the $scene the window will be in, and w is the name of the instance variable which represents the window. Basically, an example would be...

s, w = 'Scene_Menu', '@command_window'

Then, you have to create a new hash within Icons constant for it...

Icons ||= Hash.new # This will create a new hash for the scene, only if it isn't defined
Icons[w] = Hash.new # This will create a new hash for the window

Then you set all your icons like so...

Icons[w]["Command Name"] = "icon filename"

The end result should look like...

Code:
s, w = 'Scene_Menu', '@command_window'

Icons[s] ||= Hash.new

Icons[s][w] = Hash.new

Icons[s][w]['My Command'] = 'My Icon'

...and thats basically how it works...


Compatibility

This script does use SDK, but with some editing you can make it non-SDK. If I have some time I'll make a non-SDK version, but really I expect you to be responsible enough to be able to figure that out on your own :P

Terms and Conditions

Another "Free to use in commercial and non-commercial games" script, but credit is required!
 
Nice work Kain! :thumb:

I started making a Non-SDK version, but I ran into a bit of a problem.

'Shutdown' has the icon, no matter what scene. Is that supposed to happen? Because other than that, it's done and Non-SDK.
 

Atoa

Member

I have a more simple script that do exaclty the same thing.

The icon file name is based on the command name (so it's the command name + '_icon') and the commands without icon are shown normally.
 
@Kain: Another great script. Just one question; Could we add/remove icons by adding/removing the following?
Code:
   s, w = 'Scene_Battle', '@party_command_window'

   Icons[s][w][Scene_Battle::Fight]   = '001-Weapon01'

   Icons[s][w][Scene_Battle::Escape]  = '020-Accessory05'
for example...
Code:
   s, w = 'Scene_Login', '@login_command_window'

   Icons[s][w][Scene_Login::Login]   = 'ICON-NAME'

   Icons[s][w][Scene_Login::Register]  = 'ICON-NAME'

   Icons[s][w][Scene_Login::Quit]  = 'ICON-NAME'
??? That's what I got out of it... Please correct me if I'm wrong...
Also, will this conflict with command windows that don't have icons (aren't listed?)

@Atoa: Care to link, or release if you haven't already?
 

Atoa

Member

@TehSeph
Well most of my scripts aren't on english and i'm really busy to translate them.

And let's stick on the topic xD
 
I'd still like to know why the commands have the same icons regardless of the scene and window, Kain. Of course there is the Icons[scene][window][command], but it does pretty much nothing, the command is the only key that changes anything.
 
@TehSeph : Yeah, thats basically how it works! And yes, if there is no icon assigned to a certain command it'll just display normally, no error occurs or anything.

@Atoa : You can share yours here if you'd like or PM me with it so I can look it over, maybe I'll learn something new ;)

@Ulqiorra : That is an interesting find, I didn't think it would do that but now I see what you're talking about, thanks for pointing that out. I have a theory of what might be causing that, so I'll look into it tonight and see if I can fix it.
 
Which version of SDK does this need? 2.4 or 2.3?

EDIT: Nevermind. Though i notice quite an interesting problem if anyone is using a simple menu edit script like i am. (By kRECKER) using more commands than the default ones.

It does work with it though you won't see any icons with it unless there's a way to add them. I'll show you an example.

CustomEDIT.png


This is the script i'm using.
viewtopic.php?t=18863
 
@XP Learner : You need to add the icon into the script, it doesn't automatically define the icons for ya and it only works for command windows...

Code:
s, w = 'Scene_Menu', '@command_window'

Icons[s][w]['Spirit']  = 'my icon name'

If you look in the screenshots for Battle, you'll see that the Gambit command has its own icon, I set it up just like that :P

@Everyone else : I've been trying to fix the weird issue where it ignores the scene and window, just sets icons based on command... I'm glad it was pointed out, and I'm having alot of trouble trying to get it to work.

If anybody else is able to figure it out, the method you need to look at is Window_Base#get_scene_instance. After a couple hours of testing and tweaking it, all that happens is it'll return an array of all the $scene's instance variables always excluding the window in question...

Code:
["@continue_enabled", "@previous_scene"]

...What this means is that when a window is initialized, ie @command_window = Window_Command.new(160, commands), that the instance of @command_window isn't yet created when the method is ran, until after everything has already initialized and ran once.

So... now we have an idea of the problem, but I still haven't figured out a solution. What intrigues me is how it'll still set the correct icons for most of the windows reguardless of the window key, instead of raising some kind of game crashing error or just not setting anything.

So when you set...

Icons['Scene_Menu']['@command_window']

...The key that Window_Base#get_scene_instance returns...

Icons['Scene_Menu'][['@menu_index', '@previous_scene']]

...meaning the window hasn't registered to the instance of '@command_window' yet...

One solution could be to, after the very first update, create a new bitmap with just the icons and then blt self.contents onto it with x + 28 or something (since the instance will then be registered within the scene), but again I'm not sure if that'll be the most effecient fix, or if that'll even work like I think it will and I can already tell that won't work the same for HorizCommand as it would for regular Window_Command windows (or maybe it will, who knows... too tired to think at this point).

If anybody who knows their stuff has any tips or advice I'll definately take it, but I'm gonna try a couple things tomorrow and see if I can get this working correctly, only if I can get some free time that is.
 
Yeah basically, an object doesn't "exist" until its initialize method hasn't finished to run.

if i follow the process of instructions,

scne -> create_window -> my_window.new -> initialize -> refresh -> draw_item ( with your stuff in it ) , initialize runs refresh before it has ended, and refresh execute draw_item, where is the code that kain added. Therefore by the times it runs, the instance variable isn't yet defined. (just in the process of being it)

basically a solution would be to have a my_window.refresh right after the my_window.new so that we go again through draw_item.

sadly, i've been looking for a way of getting the receiver name, from its instance ( like each time you do foo = thing.new, the thing instance knows the variable is called "foo" ) but nothing at all.
 

Atoa

Member

Here is the code.

He is really simple. a added a line to get the command name and add the icon based on it.
If the icon doesn't exist, it would return a "no file" erro, but i added an rescue to prevent that, so if the icon doesn't exist, the rescue call the old draw item method.

It's not SDK compilant, but it would be easy to make it, since it would only change the "draw_item" method of the "Window_HorizCommand"
Code:
#==============================================================================

# Icon Command

# by Atoa

#==============================================================================

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;">This script allow you to add icons for any command created with "Window_Command"

<span style="color:#000080; font-style:italic;">class.

<span style="color:#000080; font-style:italic;">This also works for "Window_ShopCommand" and "Window_PartyCommand" classes

 

<span style="color:#000080; font-style:italic;">To add the icon, just add an graphic with the command name + "_ic" to the Icon folder.

<span style="color:#000080; font-style:italic;">So if you want the "Attack" command to have an icon, the icon must be named

<span style="color:#000080; font-style:italic;">"Attack_ic"

 

<span style="color:#000080; font-style:italic;">Commands without icons are shown normally

<span style="color:#000080; font-style:italic;">=end

#==============================================================================

# Window_Command

#==============================================================================

class Window_Command < Window_Selectable

  #--------------------------------------------------------------------------

  alias draw_item_window_command_ic draw_item

  def draw_item(index, color)

    begin

      bitmap = RPG::Cache.icon(@commands[index] + "_ic")

      opacity = color == normal_color ? 255 : 128

      self.contents.blt(4, 32 * index + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

      self.contents.font.color = color

      rect = Rect.new(32, 32 * index, self.contents.width - 32, 32)

      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

      self.contents.draw_text(rect, @commands[index])

    rescue

      draw_item_window_command_ic(index, color)

    end

  end

end

 

#==============================================================================

# Window_ShopCommand

#==============================================================================

class Window_ShopCommand < Window_Selectable

  #--------------------------------------------------------------------------

  alias draw_item_window_shopcommand_ic draw_item

  def draw_item(index)

    begin

      bitmap = RPG::Cache.icon(@commands[index] + "_ic")

      x = 32 + index * 160

      self.contents.blt(x - 28, 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

      self.contents.draw_text(x, 0, 128, 32, @commands[index])

    rescue

      draw_item_window_shopcommand_ic(index)

    end

  end

end

 

#==============================================================================

# Window_PartyCommand

#==============================================================================

class Window_PartyCommand < Window_Selectable

  #--------------------------------------------------------------------------

  alias draw_item_window_partycommand_ic draw_item

  def draw_item(index, color)

    begin

      bitmap = RPG::Cache.icon(@commands[index] + "_ic")

      self.contents.blt(184 + index * 160 + 4 , 4, bitmap, Rect.new(0, 0, 24, 24), opacity)

      self.contents.font.color = color

      rect = Rect.new(184 + index * 160 + 32, 0, 118, 32)

      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))

      self.contents.draw_text(rect, @commands[index], 0)

    rescue

      draw_item_window_partycommand_ic(index, color)

    end

  end

end

 
 
When I get some free time I'll try and get a non-SDK version up, but before I do that I'm trying to fix some issues in the origional version first, if you can wait.

Okay, slight update please visit the top post and try out Command Icons (Take 2!)^^

Whats different in that version, I fixed the Icons hash and got rid of the default and default.default setting, since I noticed apparently when defining icons for a new window it'll all stack in the same hash, rather than a window having it's own hash, when the default is defined as a hash too (sorry if I made you crosseyed with that statement...)

In lamens terms, this means that the icons set properly when different between windows and command names, (ie "Shutdown" for Scene_Title#@command_window will be different than "Shutdown" for Scene_End#@command_window, if you give them different icons.)

It is improved in that sense, but on the other hand there was also a problem where the instance of @command_window (or w/e) isn't set until after the command window initializes, meaning the script itself was giving the wrong key in most cases, you can read more about that in my previous post. THAT issue has been fixed too, the only quirk is in certain scenes it'll show the command window normally with no icons, then a split second later the icons will appear, it needs to do that so the instance of it is registered when looking for the window key.

That shouldn't be a BIG deal (or maybe it will be to some) but, with the way this script works, it might be the only solution if you're wanting to use different command icons between windows. Alternatively, I could throw out the Icons[scene][window] key altogether, and just use an Icons[scene] key without the window being used, and that'll get rid of the re-refresh I have to do once the instance has been created. Only case where the scene => window => command_icons keys would matter is if you have two command windows, with some of the same command names, but you're wanting different icons between the two...

Its up to you guys how you'd like me to do it, so please give me some input so I know what would be mostly perferred. Throw out the Icons[scene][window] key and just use Icons[scene] key, or keep the window key and deal with the 1 second update? Any alternative suggestions I'll take into account too, just give me some feedback on it.
 

Atoa

Member

@MCsephiroth13
I don't think you noticed, but mine script is non-SDK.
It's works a bit different from the Kain Nobel's but the result is the same.
 
Kain Nobel":2uvf7hxf said:
@TehSeph : Yeah, thats basically how it works! And yes, if there is no icon assigned to a certain command it'll just display normally, no error occurs or anything.
Ahh I see. Another question. Any way to tweak this to remove the text and just place an icon? I'm thinking of modifying this script to use pictures instead, then making pictures for each of the commands.
 
Thats odd, it shows icons in my project and I put it in a new project with just SDK and its working just fine, maybe its another script conflicting with it? o.O

I'll try and post a non-SDK version tomorrow for those of you who need it.
 

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