Custom Menu Help::Window_Selectable?[xp]

Started by (Hexamin), March 27, 2010, 10:49:21 am

Previous topic - Next topic

(Hexamin)

Okay, so I'm trying to make a custom window, unfortunately this is my first time diving into the Window_Selectable class.  I need to jump in head first.  This is what I'm trying to do.  At the bottom of my menu, you will see 3 sprites of my party members.  I want to be able to select the members.  My END result would be something like this.

You will be able to have 1 active part member, but you can choose which one it is.  I want to be able to choose which one it is in the little window at the bottom of my window.  It'd be great if I could somehow get a side-to-side scrolling effect, so if you have more than 3 party members, you can scroll through them and then when you hit "enter" you'll choose the selected party member as your active party member.  If you need more clarification let me know.  I'd love to figure this out on my own, but.. I've never dealt with Window_Selectable before, and am looking for any basic/advanced/good information on using Window_Selectable for menus.

Screenshot of Menu: ShowHide




Thanks in advance!  ^_^
Max 1111101000; characters remaining: 1110111000

G_G

Here's the window. I think this is what you want.

class Window_MenuStatus < Window_Selectable
  def initialize
    super(0, 0, 240, 96)
    self.contents = Bitmap.new(width - 32, height - 32)
    @column_max = 3
    refresh
    self.active = false
    self.index = -1
  end
  def refresh
    self.contents.clear
    @item_max = $game_party.actors.size - 1
    for i in 1...$game_party.actors.size
      x = 64 * i
      y = 0
      actor = $game_party.actors[i]
      draw_actor_graphic(actor, x - 32, y + 56)
    end
  end
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
    else
      self.cursor_rect.set(@index * 64, 0, 64, 64)
    end
  end
end


Try it in the default menu that way you can look at the window.

(Hexamin)

I actually have it down, but its just going with 3 party members.  Now I'm going to... set up a couple things to implement my 1 party member active thing.

I'll need an array for the party members I currently have.  I think I just use an array that has the ID of the actors I want in my party.  So for this example, lets say I have actors 2, 3, 4, and 5 in my party.

$parti = [2, 3, 4, 5]

or should it be one less for each number?  If i'm using

$game_party.remove_actor[x]
$game_party.add_actor[y]

where x is the previous party member and y would be the new actor in $parti, based on the index of my window... would it read 2 and add actor with ID 2? or 3?  I still get confused, I know arrays are tricky and don't wanna get confused.

Okay, moving along.  So I have that array, $parti, now then... I want it so I can cycle through the portraits of the potential party members.  So i'll need to scroll somehow...

if I do a check on the index, or a case self.index, when 0: scroll left, when 2: scroll right, type thing...

*ponders ponders ponders*

Hmmm...

Well, lets see, when I open the window the cursor will be at index=1, and the sprite it will have selected will be the current party member.  I need to make sure whenever I open the window, the current party member is in the middle...  I can check that by...

$parti.each{|i|
if $game_party.actors[1].id = i
loc = $parti.index[i]
}

so now... variable "loc" should equal the index of $parti, so... if the current party member is the 3rd index... then the 2nd index will be on the left, and the 4th on the left, leaving the 1st index out of the scene for the time being...

This is a bit of a headache.  i'm going to post my thoughts so far and see if you can help me scramble through this.  Haha
Max 1111101000; characters remaining: 1110111000

G_G

March 27, 2010, 11:43:12 am #3 Last Edit: March 27, 2010, 11:44:23 am by Hellfire's G_G
look at my window at this line
for i in 1...$game_party.actors.size

This gets the last 3 party members in the party. If none exist then it doesnt do anything.
If you're trying to set the index to the middle actor do this.
@index = 1 if $game_party.actors[2] != nil


EDIT:
I don't see why you need global variables to get the actors and stuff. Try this.

@actors = $game_party.actors


Also look at my window and look how it draws the last 3 party members out. Then in you're menu check the window's index.

(Hexamin)

That's just it, $game_party.actors.size is going to = 1 (2) because my game only calls for the main player, and one party member.

I'll use $parti, actually, I'll use Manip::PARTY for my array that stores the "other party members" even though they're not actually in the party.  Does this make sense?  It's a bit confusing, even to me, the one trying to explain his own thoughts.  Haha.  :^_^':
Max 1111101000; characters remaining: 1110111000

G_G

March 27, 2010, 11:50:04 am #5 Last Edit: March 27, 2010, 11:54:01 am by Hellfire's G_G
Okay so you're trying to only display the last 3 members of the party right? Not the first one right?
If so then use this.
actors = $game_party.actors
for i in 1...actors.size
   #draw graphic here
end


Much like my code in my window I posted. It will not draw the first actor.


class Window_MenuStatus < Window_Selectable
 def initialize
   super(0, 0, 240, 96)
   self.contents = Bitmap.new(width - 32, height - 32)
   @column_max = 3
   refresh
   self.active = false
   self.index = -1
 end
 def refresh
   self.contents.clear
   @item_max = $game_party.actors.size - 1
   for i in 1...$game_party.actors.size
     x = 64 * i
     y = 0
     actor = $game_party.actors[i]
     draw_actor_graphic(actor, x - 32, y + 56)
   end
 end
 def update_cursor_rect
   if @index < 0
     self.cursor_rect.empty
   else
     self.cursor_rect.set(@index * 64, 0, 64, 64)
   end
 end
end


Try the window in a new project and place the window in a new script. Notice how it only draws Basil, Gloria, and Hilda in the window and Aluxes isn't drawn at all. Is that what you're trying to do?

EDIT: And you're code you sent me this.
class Hex_Party_Window < Window_Selectable
  def initialize
    super(0, 0, 200, 76)
    @column_max = 3
    @item_max = $game_party.actors.size
    self.contents = Bitmap.new(width-32, height-32)
    @actors = $game_party.actors
    refresh
  end
  def refresh
    for i in 1...$game_party.actors.size
      x = 17 * i
      bitmap = RPG::Cache.character(@actors[i].character_name, @actors[i].character_hue)
      self.contents.blt(x, 0, bitmap, Rect.new(0, 0, bitmap.width / 4, bitmap.height / 4)
    end
  end
end


Also you don't need to use the {} all the time going through arrays.

(Hexamin)

Okay, so my array Manip::PARTY get pushed with $data_actors[id]
this is how i'm drawing the "party members" even though they aren't $game_party members (only 1 of them is)


x = 17
    Manip::PARTY.each{|i|
      draw_actor_graphic(i, x, 48)
      @item_max += 1
      x += 66
    }

or I guess I could...

@item_max = Manip::PARTY.size + 1
x=17
for i in 0..Manip::PARTY.size
draw_actor_graphic(i, x, 48)
x += 66
end

Max 1111101000; characters remaining: 1110111000

Ryex

the hard part of your code will be getting it to work properly with orientalist selection if you need hepl with that you can look at my menu (collapsed CMS) or just post here
I no longer keep up with posts in the forum very well. If you have a question or comment, about my work, or in general I welcome PM's. if you make a post in one of my threads and I don't reply with in a day or two feel free to PM me and point it out to me.<br /><br />DropBox, the best free file syncing service there is.<br />

(Hexamin)

woah, say what?  yes, please elaborate, haha.
Max 1111101000; characters remaining: 1110111000