RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
going from one selectable window to the next?

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 82
We learn by living...
I'm not sure how to get that to work...

I'm trying to make a windows version of a skill builder (rather than an event version) and this is what I've got so far:

Code: [Select]
class Journal

def initialize(menu_index = 0)
   @menu_index = menu_index #Store the cursor position
end 
 
   
 
#BLOCK 1
def main
   @window_1=Window_1.new
   @window_1.y=380

#   @window_2=Window_2.new
#   @window_2.y=0
   
#BLOCK 2: Window 2 Command list   
  s1 = "Add"
  s2 = "Buy"
  s3 = "Edit"
  s4 = "New"
  s5 = "X-Change"
@window_2 = Window_Command.new(200, [s1,s2,s3,s4,s5]) #was 160
@window_2.y=0
@window_2.height=380 #Force a new height for the menu window
@window_2.index = @menu_index


@window_3=Window_3.new
@window_3.x=200

@window_4=Window_4.new
@window_4.x=200
@window_4.visible = false
@window_4.active = false #this is new can't tell if works

@window_5=Window_5.new
@window_5.x=200
@window_5.visible = false
@window_5.active = false #this is new can't tell if works


#BLOCK 2
   Graphics.transition
   loop do
    Graphics.update
    Input.update
    update
    if $scene != self
     break
    end
   end

#BLOCK 3
  Graphics.freeze
   @window_1.dispose
   @window_2.dispose
   @window_3.dispose
   @window_4.dispose
   @window_5.dispose
  end

#BLOCK 4
def update
  @window_1.update
  @window_2.update
  @window_3.update
  @window_4.update
  @window_5.update
 
#BLOCK NEW 

if Input.trigger?(Input::C) #Do the following if ENTER is pressed...
case @window_2.index #window_2 is the menu... index is it's cursor position !
  when 0 #Remember that the cursor position start at 0, because it's an Array !!
    add_sk #improve skill level from character list
  when 1
    buy_sk #buy skill from existing list
  when 2
    edit_sk #change parameters of existing skill
  when 3
    new_sk #make a new skill
  when 4
    x_change #change life points into skill points
end 
end
 
 
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Map.new
   end
  end

 
#==================================================================== 
#  All the "def add_sk" through "def x_change" should go here.
#  warning, these are case sensitive THEY MUST BE LOWER CASED.
#==================================================================== 

  def add_sk #s1, menu_index=0
$game_actors[1].str += 10 #here for test purposes only
#@window_4=Window_4.new #works, overlaps
#@window_4.x=200
@window_4.visible = true
@window_4.active = true
@window_3.visible = false

@window_5.visible = false
end 


  def buy_sk #s2, menu_index=1
$game_actors[1].dex += 10 #works, added by shintashi
@window_3.visible = true
@window_4.visible = false

@window_5.visible = false
end 


  def edit_sk #s3, menu_index=2
$game_actors[1].mod_tgh += 10 #here for test purposes only
@window_3.visible = false #works

@window_5.visible = true #works
@window_5.active = true #test

#$scene = Scene_Skill.new #works, but useless redirection to skill menu
end 


  def new_sk #s4, menu_index=3
  Audio.bgm_play("Audio/BGM/043-Positive01.mid", 100, 100) #for test purposes
@window_5.visible = false
  end


  def x_change #s5, menu_index=4
@window_3.visible = true

@window_4.visible = false
@window_5.visible = false

 if $game_actors[1].life_points > 0   
  Audio.se_play("Audio/SE/006-System06.ogg", 100, 100)
  $game_actors[1].life_points -= 1
  $game_actors[1].mod_skill_pts += 3
 else
  Audio.se_play("Audio/SE/004-System04.ogg", 100, 100)
  end
end
 

#======================== END MAIN SCENE ============================ 
end



#====================================================================
#      Window 1 - super (x, y, width, height)
#====================================================================
#
# This is a random filler window for now. It serves to occupy space
#--------------------------------------------------------------------
class Window_1 < Window_Base

  def initialize
    super(0, 0, 640,100)
    self.contents = Bitmap.new(width-32, height-32)
    #self.contents.font.name = "Arial" 
    #self.contents.font.size = 24
    refresh
  end
 
  def refresh
    self.contents.clear
    self.contents.font.color = text_color(6)
    self.contents.draw_text(0, 0, 100, 32, "PlayTime:")
   
    #CODE TO SHOW PLAYTIME (Copied from Window_PlayTime)
    @total_sec = Graphics.frame_count / Graphics.frame_rate
    hour = @total_sec / 60 / 60
    min = @total_sec / 60 % 60
    sec = @total_sec % 60
    text = sprintf("%02d:%02d:%02d", hour, min, sec)
    self.contents.font.color = normal_color
    self.contents.draw_text(100, 0, 120, 32, text)
    #END OF CODE TO SHOW PLAYTIME
   
    self.contents.font.color = text_color(6)
    self.contents.draw_text(250, 0, 50, 32, "Gold:")
    self.contents.font.color = text_color(0)
    self.contents.draw_text(305, 0, 100, 32, $game_party.gold.to_s)
   
    self.contents.font.color = text_color(6)
    self.contents.draw_text(400, 0, 100, 32, "Map ID:")
    self.contents.font.color = text_color(0)
    self.contents.draw_text(480, 0, 100, 32, $game_map.map_id.to_s)
  end
 
  def update
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
 
end


#====================================================================
#      Window 4: Like Window 1 - Real stuff will come later
#====================================================================

class Window_4 < Window_Base
 
  #BLOCK 1
  def initialize
    super(0, 0, 440,380)
    self.contents = Bitmap.new(width-32, height-32)
  refresh 
  end #end initialize
   
   
def refresh
self.contents.clear #if you don't do this it turns to mush when changing values
  #BLOCK 2
    self.contents.font.color = text_color(0)
    self.contents.draw_text(100, 90, 200, 32, "Some")
    self.contents.draw_text(100, 122, 200, 32, "Stuff")
    self.contents.draw_text(100, 154, 200, 32, "goes")
    self.contents.draw_text(100, 186, 200, 32, "here")
    self.contents.draw_text(100, 218, 200, 32, "X-change")
   
  end# end refesh
 
  def update
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end #end if
  end # end update
 
end # end window 4


#====================================================================
#      Window 3: Exchange Life Points for Skill Points
#====================================================================

class Window_3 < Window_Base

  #BLOCK 1
  def initialize
    super(0, 0, 440,380)
    self.contents = Bitmap.new(width-32, height-32)
  refresh 
  end #end initialize
 
 
     def refresh
       self.contents.clear #if you don't do this it turns to mush
    #BLOCK 2
     for i in 0...$game_party.actors.size
      x = 0
      y = i * 150
      if i >= 2
        x=250
        y -= 300
      end     
      actor = $game_party.actors[i]

    #BLOCK NEW
    self.contents.font.color = text_color(6)
    self.contents.draw_text(x+200, y, 200, 32, "Life Points")
    self.contents.font.color = text_color(0)
    self.contents.draw_text(x+285, y, 96, 32, actor.life_points.to_s)
 
    self.contents.font.color = text_color(6)
    self.contents.draw_text(x+200, y+32, 200, 32, "Skill Points")
    self.contents.font.color = text_color(0)
    self.contents.draw_text(x+285, y+32, 96, 32, actor.skill_points.to_s)
   
   
    #BLOCK 2.0
      self.contents.font.color = text_color(6)
      self.contents.draw_text(x, y, 200, 32, actor.name)
      offset_x=contents.text_size(actor.name).width+10
      self.contents.font.color = text_color(4)
      self.contents.draw_text(x+offset_x, y, 200, 32, "Lv: " + actor.level.to_s)
      draw_actor_hp(actor, x, y+32)
      draw_actor_sp(actor, x, y+64)
      draw_actor_exp(actor, x, y+96)
    end #end for loop
  end #end refresh
 
 
def update
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end #end if
  end # end update
 
end #end window 3

#====================================================================
#      Window 5: Skill Select Window
#====================================================================

class Window_5 < Window_Selectable # < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize
    super(0, 0, 440, 380)
    self.contents = Bitmap.new(width-32, height-32)
    @column_max = 2
    refresh
    self.index = 0 #may crash
  end
 
  #BLOCK 1
  def skill
   # self.index = 0 #may fail
    return @data[self.index]
  end
 
  #BLOCK 2
  def row_max
    # Compute rows from number of items and columns
    return (@item_max + @column_max - 1) / @column_max
  end
 
 
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      @actor = actor

    # self.contents.clear #if you don't do this it turns to mush
         @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
    end
      if skill != nil
        @data.push(skill)
      end
    end
    # If item count is not 0, make a bit map and draw all items
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      for i in 0...@item_max
        draw_item(i)
       end
    end
  end
 
  #--------------------------------------------------------------------------
  # * Draw Item
  #     index : item number
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = normal_color
    else
      self.contents.font.color = disabled_color
    end
   
    x = 4 + index % 2 * (158 + 32) #288 +32
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == normal_color ? 255 : 128
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 164, 32, skill.name, 0) #204 not 164
    end
end


It's the last part, window 5, that doesn't work right. I'm supposed to be able to click on "edit" (edit_sk) and it should active and visible window 5. That part works. The actor's skill also lights up, as if it's selectable, but this is where the problems start:

First, the "selectable skill" isn't really selectable (don't know how to make it selectable either)
Second, if the actor has multiple skills, only the last skill shows up, instead of all their skills displaying neatly in left right columns. (At this point I would settle for a single column).


Is there a good place to learn about making selectable windows? i'm trying to mimic the normal 'escape' menu feature that starts with item, skill, equip,... and then allows you to highlight your player, then hit the button to load the next window.

Right now I can make that first selectable window, but I don't know how to go from one selectable window to the next.

***
Rep:
Level 82
We learn by living...
ok, so update:

I've figured out the document I am trying to clone is called "scene menu" and realized "active" needed to be swapped out, as shown below. The skill in the new window now blinks while the menu options in the previous window stop blinking, but nothing happens when the spacebar is pressed, which may be related to the fact that only one skill is showing. I've seen an error like this before.

Code: [Select]
  def edit_sk #s3, menu_index=2
$game_actors[1].mod_tgh += 10 #here for test purposes only
@window_3.visible = false #works
#@window_5.index = 0 #tested, does nothing

@window_5.visible = true #works

@window_2.active = false
@window_5.active = true #changes which window has active buttons
@window_5.index = 0 #tested
end


edit: I got the blinky thing to go back and forth...by editing the cancel button in 'main'. I also got the sound to play when canceling.
Code: [Select]
if Input.trigger?(Input::B)
      if @window_5.active == true
        @window_2.active = true
        @window_5.active = false
        $game_system.se_play($data_system.cancel_se)
      else
        $game_system.se_play($data_system.cancel_se)
        $scene = Scene_Map.new
      end
   end
/code]
« Last Edit: January 05, 2011, 03:00:58 AM by shintashi »

***
Rep:
Level 82
We learn by living...
so I figured out another part of my problem, and now multiple skills show up   :blizj:

this is what I was supposed to have:
Code: [Select]
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil
        @data.push(skill)
      end
    end

but I had this:
Code: [Select]
  @data = []
    for i in 0...@actor.skills.size #how many skills does actor have?
      skill = $data_skills[@actor.skills[i]]
    end
      if skill != nil #if skill doesn't exist
        @data.push(skill) #skip to next skill
      end


in other words I had an "end" in the wrong place. I'm still not sure how the "select" functions are supposed to trigger, but now it at least pretends to work. I'm going to have to disect the scene_skill and scene_item C button codes.