[RGSS3][Solved] Re ordering the party with visible numbers

Started by bigace, March 19, 2015, 04:06:20 am

Previous topic - Next topic

bigace

Hopefully the title makes sense, so anyways so far I've created the re order part in the gif below:
Spoiler: ShowHide


But in this next gif you will notice that I'm missing one key component (not including the yes/no question at the end), which is the numbers that will appear next to the actors names after the player clicks on them.

This is a gif of the OG version menu in the game Revelations Demon Slayer to show what I am talking about:
Spoiler: ShowHide


So in that second gif you should hopefully see what I was talking about on the left side of the status window. The problem is that I have no clue how to write that at the moment and was hoping someone had an ideal on how to go about this.

If you need anything else don't hesitate to ask!


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

LiTTleDRAgo


KK20

The easiest way to do it would be to just use draw_text at pre-defined locations based on the window's index. If pressing B is supposed to remove the last added number, you could then just use a fill_rect(x,y,w,h,Color.new(0,0,0,0)) based on the location of the last number assigned to a party member.

If your actor names are already being drawn at a small x-coordinate value (between 0 and 32), then I would suggest moving the names over to the right a bit more so that you can devote a column of empty space on the left next to them to draw these numbers.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

bigace

March 19, 2015, 04:34:44 pm #3 Last Edit: March 19, 2015, 04:37:29 pm by bigace
I believe I figured it out and I post my findings when its done, but I'm pretty sure it involves editing the pending_index=(index) and draw_item_background(index) methods in class Window_MenuStatus.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

bigace

So this is what I have so far:
Spoiler: ShowHide

class Game_Party < Game_Unit
  def set_party_order_to_array(array)
    @battle_party = Array.new(array)
    refresh_actors
  end
  def refresh_actors
    $game_player.refresh
    $game_map.need_refresh = true
  end
end
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
class Window_MenuStatus < Window_Selectable
  def initialize(x, y)
    super(x, y, window_width, window_height)
    @pending_index = []
    refresh
  end
  def draw_item(index, *args)
    actor_id = $game_party.battle_party[index]
    return unless actor_id
    actor = $game_actors[actor_id]
    rect = item_rect(index)
    draw_item_counter(rect, index)
    draw_actor_simple_status(actor, rect.x, rect.y + 1.5 / 2)
  end
  def draw_item_counter(rect, index)
    if index == @pending_index[0]
        contents.font.bold = true
        contents.fill_rect(item_rect(index), pending_color)
        draw_text(rect.x+6, rect.y, rect.width, rect.height, @pending_index[1])
        contents.font.bold = false
    end
  end
  def pending_index=(index)
    @pending_index = index
    redraw_item(@pending_index[0])
  end
end
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
class Scene_Menu < Scene_ItemBase
def start
super
    @actor_array = []
  end
def command_formation
@status_window.select_last
@status_window.activate
@status_window.set_handler(:ok,     method(:on_formation_ok))
@status_window.set_handler(:cancel, method(:on_formation_cancel))
refresh_help_window
end
def on_formation_ok
if @actor_array.size < @status_window.item_max
unless @actor_array.include?(user.id)
@actor_array << user.id
@status_window.pending_index = [@status_window.index, @actor_array.size]
end
if @actor_array.size == @status_window.item_max-1
(@status_window.item_max+1).times do |i|
unless @actor_array.include?(i) || i <= 0
@actor_array << i
@status_window.pending_index = [i-1, @actor_array.size]
end
break if @actor_array.size == @status_window.item_max
end
if @actor_array.size == @status_window.item_max
@window_question.set_handler(:yes,    method(:on_order_ok))
@window_question.set_handler(:no,     method(:on_order_cancel))
@window_question.set_handler(:cancel, method(:on_order_cancel))
@window_question.question = 'Is this ok?'
@window_question.activate.show.select(1)
end
else
@status_window.activate
end
end
end
def on_order_ok
$game_party.set_party_order_to_array(@actor_array)
on_order_cancel
party_refresh
end
def on_order_cancel
@status_window.pending_index.clear
@actor_array.clear
@window_question.deactivate.hide
@status_window.unselect
@sort_window.activate
end
def on_formation_cancel
if @actor_array.size > 0
@actor_array.pop
@status_window.redraw_item(@status_window.index)
if @actor_array.size == 0
@status_window.unselect
@sort_window.activate
else
        @status_window.activate
end
else
@status_window.unselect
@sort_window.activate
end
refresh_help_window
end
def party_refresh
@monster_list.refresh
@windows.each {|x| x.refresh unless x.visible == false}
$game_party.refresh_actors
end
end




So far I am able to get the numbers to appear after every time I click on an actor and then disappear after the new party order has been created but I still don't really have any ideal how to go backwards (Pressing :B) and removing the previous selected actor. I can remove it from the array as you can in the code above but not the highlight or number.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

LiTTleDRAgo

March 21, 2015, 07:18:10 pm #5 Last Edit: March 22, 2015, 03:16:47 am by LiTTleDRAgo

bigace

Just a heads up I changed the parent class of Scene_Menu so it's not going to be easily imported without the whole thing and:

Quotejust glanced on your script, you should draw the number in the different sprite so you can delete & redraw it freely without affecting the others


I don't get it?


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

LiTTleDRAgo

what I mean earlier is create a new sprite, and draw all you want to do there

forget it, try this cheap fix :

Spoiler: ShowHide
class Game_Party < Game_Unit
  def set_party_order_to_array(array)
    @battle_party = Array.new(array)
    refresh_actors
  end
  def refresh_actors
    $game_player.refresh
    $game_map.need_refresh = true
  end
end
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
class Window_MenuStatus < Window_Selectable
  def initialize(x, y)
    super(x, y, window_width, window_height)
    @pending_index = []
    refresh
  end
  def draw_item(index, *args)
    actor_id = $game_party.battle_party[index]
    return unless actor_id
    actor = $game_actors[actor_id]
    rect = item_rect(index)
    draw_item_counter(rect, index)
    draw_actor_simple_status(actor, rect.x, rect.y + 1.5 / 2)
  end
  def draw_item_counter(rect, index)
    if index == @pending_index[0]
        contents.font.bold = true
        contents.fill_rect(item_rect(index), pending_color)
        draw_text(rect.x+6, rect.y, rect.width, rect.height, @pending_index[1])
        contents.font.bold = false
    end
  end
  def pending_index=(index)
    @pending_index = index
    redraw_item(@pending_index[0])
  end
end
#■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■
class Scene_Menu < Scene_ItemBase
 
  def start
    super
    @actor_array = []
    @status_contents = []                                                  # <<<
  end
 
  def command_formation
    @status_window.select_last
    @status_window.activate
    @status_window.set_handler(:ok,     method(:on_formation_ok))
    @status_window.set_handler(:cancel, method(:on_formation_cancel))
    refresh_help_window
  end
 
  def on_formation_ok
    if @actor_array.size < @status_window.item_max
      unless @actor_array.include?(user.id)
        @actor_array << user.id
        @status_contents << @status_window.contents.clone                  # <<<
        @status_window.pending_index = [@status_window.index, @actor_array.size]
      end
      if @actor_array.size == @status_window.item_max-1
        (@status_window.item_max+1).times do |i|
          unless @actor_array.include?(i) || i <= 0
            @actor_array << i
            @status_contents << @status_window.contents.clone              # <<<
            @status_window.pending_index = [i-1, @actor_array.size]
          end
          break if @actor_array.size == @status_window.item_max
        end
        if @actor_array.size == @status_window.item_max
          @window_question.set_handler(:yes,    method(:on_order_ok))
          @window_question.set_handler(:no,     method(:on_order_cancel))
          @window_question.set_handler(:cancel, method(:on_order_cancel))
          @window_question.question = 'Is this ok?'
          @window_question.activate.show.select(1)
        end
      else
        @status_window.activate
      end
    end
  end
 
  def on_order_ok
    $game_party.set_party_order_to_array(@actor_array)
    on_order_cancel
    party_refresh
  end
 
  def on_order_cancel
    @status_window.pending_index.clear
    @actor_array.clear
    @window_question.deactivate.hide
    @status_window.unselect
    @sort_window.activate
    @status_contents.each {|s| s.disposed? || s.dispose }                  # <<<
    @status_contents.clear                                                 # <<<
  end
 
  def on_formation_cancel
    if @actor_array.size > 0
      @actor_array.pop
      temp = @status_contents.pop                                          # <<<
      @status_window.contents.clear                                        # <<<
      @status_window.contents.blt(0,0,temp,temp.rect)                      # <<<
      temp.dispose                                                         # <<<
      @status_window.redraw_item(@status_window.index)
      if @actor_array.size == 0
        @status_window.unselect
        @sort_window.activate
        @status_contents.each {|s| s.disposed? || s.dispose }              # <<<
        @status_contents.clear                                             # <<<
      else
        @status_window.activate
      end
    else
      @status_window.unselect
      @sort_window.activate
      @status_contents.each {|s| s.disposed? || s.dispose }                # <<<
      @status_contents.clear                                               # <<<
    end
    refresh_help_window
  end
 
  def party_refresh
    @monster_list.refresh
    @windows.each {|x| x.refresh unless x.visible == false}
    $game_party.refresh_actors
  end
end


untested because of insufficient code

bigace

Cool thanks drago, it works. Now all I have to finish is when the player hits no instead of yes it erases the highlights and numbers. That shouldn't be too hard now, so thank you for your's and KK20's help.


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.