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.
CMS help [RESOLVED]

0 Members and 1 Guest are viewing this topic.

***
Rep:
Level 88
I am currently working on making a CMS for my game but i kinda hit a wall in one respect. I would like to display my skills on several 'pages', by this i mean that i want to show the first 6 skills in the window, then when right is pressed it will draw the next 6 items, i just need to know how to make the left/right page switching work....

EDIT:
after a bit of fiddleing i figured it out: i added a parameter to the initialize method and used global variables to keep track of what page i was on, then added conditions to whether left or right was pushed that change the page variable and dispose of the menu and re-initialize it with the new page #.

here's the old code:
Spoiler for:
Code: [Select]
class Test_Menu_9 < Window_Selectable
  def initialize(actor)
    super(0, 0, 450, 235)
    @actor = actor
    @item_max = 6
    refresh
    self.index = 0
  end
   
  def skill
    return @data[self.index]
  end
   
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in 0...@actor.skills.size
      skill = $data_skills[@actor.skills[i]]
      if skill != nil
       # if @actor.skill_can_use?(skill.id)
          @data.push(skill)
       # end
     end
     @column_max = ((@data.size - 1) / 6) +1
    end
    # If the number of items is not 0, it draws up bit map, drawing all item
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def draw_item(index)
    skill = @data[index]
    x = 0
    y = index * 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)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), 255)
    self.contents.draw_text(x + 30, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 200, y, 48, 32, skill.sp_cost.to_s, 2)
  end
   
end
Code: [Select]
class Test_Scene_2
#BLOCK 1
def main
   @window_1=Test_Menu_7.new
   @window_8=Test_Menu_8.new
   @window_8.x=190
   @window_3=Test_Menu_11.new($Character_Id_I_Am_Working_With)
   @window_3.y=80
   @window_9=Test_Menu_9b.new($game_party.actors[$Character_Id_I_Am_Working_With])
   @window_9.x=190
   @window_9.y=55
   @window_10=Test_Menu_10.new
   @window_10.x=190
   @window_10.y=290
   @window_6=Test_Menu_6.new
   @window_6.x=190
   @window_6.y=395
  #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_8.dispose
   @window_3.dispose
   @window_9.dispose
   @window_10.dispose
   @window_6.dispose
  end
#BLOCK 4
def update
   @window_9.update
   
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Map.new
   end
   
  end
end

and the new code:
Spoiler for:
Code: [Select]
class Test_Menu_9b < Window_Selectable
  def initialize(actor, thepage)
    super(0, 0, 450, 235)
    @actor = actor
    $my_current_page = thepage
    $my_current_page_start = thepage * 6
    $my_current_page_end = $my_current_page_start + 5
    @item_max = 6
    refresh
    self.index = 0
  end
   
  def skill
    return @data[self.index]
  end
   
  def refresh
    if self.contents != nil
      self.contents.dispose
      self.contents = nil
    end
    @data = []
    for i in $my_current_page_start..$my_current_page_end
      if i<@actor.skills.size
        skill = $data_skills[@actor.skills[i]]
        if skill != nil
         # if @actor.skill_can_use?(skill.id)
            @data.push(skill)
            $my_number_pages = ((@actor.skills.size - 1) / 6)
         # end
      end
     end
    end
    # If the number of items is not 0, it draws up bit map, drawing all item
    @item_max = @data.size
    if @item_max > 0
      self.contents = Bitmap.new(width - 32, row_max * 32)
      self.contents.font.name = $fontface
      self.contents.font.size = $fontsize
      for i in 0...@item_max
        draw_item(i)
      end
    end
  end
 
  def draw_item(index)
    skill = @data[index]
    x = 0
    y = index * 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)
    self.contents.blt(x, y, bitmap, Rect.new(0, 0, 24, 24), 255)
    self.contents.draw_text(x + 30, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 200, y, 48, 32, skill.sp_cost.to_s, 2)
  end
   
end
Code: [Select]
class Test_Scene_2
#BLOCK 1
def main
   @window_1=Test_Menu_7.new
   @window_8=Test_Menu_8.new
   @window_8.x=190
   @window_3=Test_Menu_11.new($Character_Id_I_Am_Working_With)
   @window_3.y=80
   @window_9=Test_Menu_9b.new($game_party.actors[$Character_Id_I_Am_Working_With], 0)
   @window_9.x=190
   @window_9.y=55
   @window_10=Test_Menu_10.new
   @window_10.x=190
   @window_10.y=290
   @window_6=Test_Menu_6.new
   @window_6.x=190
   @window_6.y=395
  #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_8.dispose
   @window_3.dispose
   @window_9.dispose
   @window_10.dispose
   @window_6.dispose
  end
#BLOCK 4
def update
   @window_9.update
   
   if Input.trigger?(Input::B)
     $game_system.se_play($data_system.cancel_se)
     $scene = Scene_Map.new
   end
   
   if Input.trigger?(Input::LEFT)
     if $my_current_page > 0
       @window_9.dispose
       $my_current_page = $my_current_page - 1
       @window_9=Test_Menu_9b.new($game_party.actors[$Character_Id_I_Am_Working_With], $my_current_page)
       @window_9.x=190
       @window_9.y=55
      end
    end
   
   if Input.trigger?(Input::RIGHT)
     if $my_current_page < $my_number_pages
       @window_9.dispose
       $my_current_page = $my_current_page + 1
       @window_9=Test_Menu_9b.new($game_party.actors[$Character_Id_I_Am_Working_With], $my_current_page)
       @window_9.x=190
       @window_9.y=55
      end
    end
   
  end
end

i do realize it might be hard to see what i'm saying because i'm not good at explaining....so please tell me if you don't understand! I've attached the demo of what it does.
« Last Edit: October 08, 2008, 09:29:29 PM by atracious »
"Facts are useless. You could use facts to prove anything that's even remotely true." Homer Jay Simpson

"I do not know what weapons WWIII will be fought with but i know WWIV will be fought with sticks and stones" Albert Einstein

"It's better to have loved and lost than never to have loved at all." from In Memoriam, by Alfred, Lord Tennyson.

"all your base are belonging to us!" awful fantasy 3

"the grapes damb it, it's alway's the grapes!"

Funny anagrams:
Desperation=A rope ends it
Mother in law=Woman hitler
Lottery machine=Money lost in 'em
Election results=Lies lets recount
Dormitory=Dirty room
Snooze alarms=Alas! No more Z's
Eleven plus two=Twelve plus one
Cosmetic surgery="Yes, I correct mugs."
The IRS=Theirs!
Public relations=Crap, built on lies
Astronomer=Moon starer
Dementia="Detain me."
Internet chat rooms=The moron interacts
The eyes!=They see!

Currently making:
http://rmrk.net/index.php/topic,13132.0.html