Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: nathmatt on June 02, 2010, 01:16:53 pm

Title: [XP] Picture Command
Post by: nathmatt on June 02, 2010, 01:16:53 pm
Picture Command
Authors: Nathmatt
Version: 1.00
Type: Command
Key Term: Menu Add-on



Introduction
This script makes a real picture command


Features




Screenshots
(http://img337.imageshack.us/img337/2130/screenshotwc.png)

made with just this (http://yfrog.com/fvmenutp)


Demo

No Demo


Script

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Picture Command by Nathmatt
# Version: 1.01
# Type: Command
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#==============================================================================
# Picture Command Config
#==============================================================================
module Picture_Command_Config
 Distance         = 5                   # Distance between pictures
 Replace_Selector = false               # New picture or false
 Piture_Selector  = false               # Curser piture or false for default
 Selctor_Off_X    = 30                  # curser's x offset
 Selctor_Off_Y    = 20                  # curser's x offset
end
#==============================================================================
# Picture Command
#==============================================================================
class Picture_Command < Window_Selectable
 #--------------------------------------------------------------------------
 # * Object Initialization
 #     width    : window width
 #     commands : command text string array
 #--------------------------------------------------------------------------
 def initialize(commands,graphic)
   @bitmap = RPG::Cache.picture(graphic)
   @cw = @bitmap.width
   @ch = @bitmap.height
   @dis = Picture_Command_Config::Distance
   super(0, 0, @cw + 32, commands.size * (@ch + @dis) + 32)
   @item_max = commands.size
   @commands = commands
   self.contents = Bitmap.new(width - 32, height - 32)
   self.index = -1
   refresh
   self.x -= 10
   self.index = 0
   self.opacity = 0
 end
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
   self.contents.clear
   (0...@item_max).each{|i|draw_item(i, normal_color)}
 end
 #--------------------------------------------------------------------------
 # * Draw Item
 #     index : item number
 #     color : text color
 #--------------------------------------------------------------------------
 def draw_item(i, color)
   pic = (Picture_Command_Config::Piture_Selector != false ?
   Picture_Command_Config::Piture_Selector: @bitmap)
   self.contents.font.color = color
   self.contents.fill_rect(0, (@ch + @dis) * i, @cw, @ch, Color.new(0,0,0,0))
   rect = Rect.new(0, 0, @cw, @ch)
   self.contents.blt(0, (@ch + @dis) * i, pic, rect)
   rect = Rect.new(0, (@ch + @dis) * i, @cw, @ch)
   self.contents.draw_text(rect, @commands[i],1)
 end
 #--------------------------------------------------------------------------
 # * Disable Item
 #     index : item number
 #--------------------------------------------------------------------------
 def disable_item(index)
   draw_item(index, disabled_color)
 end
 #--------------------------------------------------------------------------
 # * Cursor Rectangle Update
 #--------------------------------------------------------------------------
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
   elsif Picture_Command_Config::Piture_Selector != false
     if @curser_selsect == nil
       @curser_selsect = Sprite.new
       @curser_selsect.bitmap = RPG::Cache.picture(
       Picture_Command_Config::Piture_Selector)
     end
     @curser_selsect.x = Picture_Command_Config::Selctor_Off_X
     @curser_selsect.y = (@index * (@ch + @dis)
     ) + Picture_Command_Config::Selctor_Off_Y
     @curser_selsect.z = 9999
   else
     self.cursor_rect.set(0, @index * (@ch + @dis), @cw, @ch)
   end
 end
end



Instructions
Just set up the config and use Picture_Command.new(commands,picture)
instead of Window_Command.new(width,commands)


Compatibility
no Compatibility known


Credits and Thanks




Author's Notes

Just post any suggestions
Title: Re: Picture Command
Post by: Jragyn on June 03, 2010, 04:44:19 am
Just from the description and what the post entails, I feel like as a reader, I don't understand what this does. Is this a scripting tool of sorts?
Title: Re: Picture Command
Post by: Valdred on June 03, 2010, 05:14:21 am
I'm pretty sure it allows the scripter to make a menu (command window) from a picture, to give him more freedom. Nice work. Levels up
Title: Re: Picture Command
Post by: nathmatt on June 03, 2010, 09:37:36 am
it allows you to use a picture to make each command kinda like mogs but you give it the picture and it creates it as many times as needed

update 1.01 changed it so you give the picture when you call it so you can use this in more than one scene