The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Tsunokiette on January 07, 2006, 09:01:59 PM

Title: Cursor Command
Post by: Tsunokiette on January 07, 2006, 09:01:59 PM
This will allow you to create a Command Window that uses a cursor (or pointer whatever you want to call it) instead of a selector around the text. Of course you can also create a normal menu using this as well.

First of all, import this into the icons folder. (make the background transparent...)

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi9.photobucket.com%2Falbums%2Fa57%2Ftsunokiette%2Fhand.png&hash=04fea0340f30094bf53df46c895c3e81d32dde1e)

Then place this with all the other Window Scripts

# ==============================
# * Cursor Command *           
# ------------------------------
# Version 1               
# 01.07.06                 
# ------------------------------
# Tsunokiette (Give credit)
# ==============================
class Cursor_Command < Window_Base

def initialize(width, commands, pointer = false)
super(0, 0, width, commands.size * 32 + 32)
@item_max = commands.size
@commands = commands
@pointer = pointer
self.contents = Bitmap.new(width - 32, @item_max * 32)
refresh
self.index = 0
end

def refresh(index = 0)
self.contents.clear
for i in 0...@item_max
draw_item(i, normal_color)
end
if @pointer == true
draw_pointer(index)
end
end

def draw_pointer(index)
rect2 = Rect.new(0, 32 * index + 4, 24, 24)
self.contents.fill_rect(rect2, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon('hand')
self.contents.blt(0, 0, bitmap, rect2)
end

def draw_item(index, color)
self.contents.font.color = color
if @pointer == true
rect1 = Rect.new(24, 32 * index, self.contents.width - 24, 32)
self.contents.fill_rect(rect1, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect1, @commands[index],1)
else
rect1 = Rect.new(0, 32 * index, self.contents.width, 32)
self.contents.fill_rect(rect1, Color.new(0, 0, 0, 0))
self.contents.draw_text(rect1, @commands[index],1)
end
end

def disable_item(index)
draw_item(index, disabled_color)
end

def update_cursor_rect
if @index < 0 or @pointer == true
self.cursor_rect.empty
return
end
x = 0
y = 32 * @index
cursor_width = self.contents.width
self.cursor_rect.set(x, y, cursor_width, 32)
end

alias :original_update :update
def update
if @pointer == true
refresh(@index)
end
original_update
end

end


To create a nomal menu do this-

@menu = Cursor_Command.new(width,[commands])

To create a menu using the pointer (cursor) do this-

@menu = Cursor_Command.new(width,[commands],true)

If you get an error tell me immediately, it's a simple script so if it has any errors, it shouldn't be too hard to fix
Title: Cursor Command
Post by: Ramiro on January 07, 2006, 09:08:32 PM
Cool thing Tsukionette!!! That
Title: where do I add this part of the script
Post by: darklinkn2it on February 12, 2006, 09:16:51 AM
Quote@menu = Cursor_Command.new(width,[commands],true)

where do I add this?
Title: Re: Cursor Command
Post by: Atracious on March 04, 2008, 04:06:07 AM
Quote from: Tsunokiette on January 07, 2006, 09:01:59 PM
This will allow you to create a Command Window that uses a cursor (or pointer whatever you want to call it) instead of a selector around the text. Of course you can also create a normal menu using this as well.
is there a way to make there be no cursor? just get rid of the stupid box for some menus.....?
Title: Re: Cursor Command
Post by: Tsunokiette on March 07, 2008, 04:53:42 PM
I'm not sure what you mean. Do you mean the default cursor? (The selection box that highlights the options)

It's like a 5 second edit, but why would you want to do that? You need to have some sort of indication that the option is selected.

If you're talking about getting rid of it when the pointer (or whatever) is being used, that already happens.
Title: Re: Cursor Command
Post by: Atracious on March 07, 2008, 10:30:57 PM
Quote from: Tsunokiette on March 07, 2008, 04:53:42 PM
I'm not sure what you mean. Do you mean the default cursor? (The selection box that highlights the options)

It's like a 5 second edit, but why would you want to do that? You need to have some sort of indication that the option is selected.
Yes i want to get rid of the selection box, i will have a way of showing what is selected, but the window has a special set-up, which makes the selection boxes not line up properly, so i would like to get rid of them entirely.
Title: Re: Cursor Command
Post by: Tsunokiette on March 08, 2008, 04:03:24 AM
Quote from: atracious on March 07, 2008, 10:30:57 PM
Yes i want to get rid of the selection box, i will have a way of showing what is selected, but the window has a special set-up, which makes the selection boxes not line up properly, so i would like to get rid of them entirely.

M'kay.

Just add this into your window code -

def update_cursor_rect
self.cursor_rect.empty
end
Title: Re: Cursor Command
Post by: Atracious on March 08, 2008, 04:28:09 AM
thanks that did the trick! :)
Title: Re: Cursor Command
Post by: vath on March 12, 2008, 02:59:12 PM
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg138.imageshack.us%2Fimg138%2F1080%2Fzzzir1.jpg&hash=18b9cf8fcd75579e9713e6474645a7b3b90351f7)
;9 i put the "window_script" above "main"
and, where to put  this command ?
@menu = Cursor_Command.new(width,[commands],true)[
Title: Re: Cursor Command
Post by: Tsunokiette on March 12, 2008, 10:07:32 PM
Quote from: vath on March 12, 2008, 02:59:12 PM
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg138.imageshack.us%2Fimg138%2F1080%2Fzzzir1.jpg&hash=18b9cf8fcd75579e9713e6474645a7b3b90351f7)
;9 i put the "window_script" above "main"
and, where to put  this command ?
@menu = Cursor_Command.new(width,[commands],true)[

My post got screwed somehow. Anyways, find line 35 and delete the second ")" that's there. It shouldn't be there.

And you put

@menu = Cursor_Command.new(width,[commands],true)

In the same place you would put a normal command window. In fact you should be able to just change the first part to Cursor_Command.new and add ",true" to the end.
Title: Re: Cursor Command
Post by: royalgia on January 18, 2009, 08:51:34 AM
Sory but i can't see the demo, who can help me please ?? upload it to mediafire.com for me, thousand thanks  :lol: