The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Rune on May 06, 2007, 11:01:21 AM

Title: Simple 3-person CMS
Post by: Rune on May 06, 2007, 11:01:21 AM
This is my second script (The first one was a window XD)

Screeny:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fi163.photobucket.com%2Falbums%2Ft302%2Fpsychomathic-paniac%2FCMS_screeny.jpg&hash=6e062f4df10ddf14117014ac0d503cd8ee6c6877)

Replace this with Scene_Menu
#+++++++++++++++++++++++++++++++#
#                            Rune's CMS                              #
#                               Ver 0.1                                 #
#+++++++++++++++++++++++++++++++#

class Scene_Menu
  def initialize(menu_index = 0)
    @menu_index = menu_index
  end
  def main
    @spriteset = Spriteset_Map.new
    s1 = $data_system.words.item
    s2 = $data_system.words.skill
    s3 = $data_system.words.equip
    s4 = "Status"
    s5 = "Save"
    s6 = "Quit"
    @status_window = Window_MenuStatus.new
    @status_window.x = 80
    @status_window.y = 64
    @status_window.opacity = 160
    @command_window = Window_Command.new(480, [s1, s2, s3, s4, s5, s6], 6)
    @command_window.x = 80
    @command_window.y = 0
    @command_window.opacity = 255
    @command_window.index = @menu_index
    @steps_window = Window_Steps.new
    @steps_window.x = 0
    @steps_window.y = 394
    @steps_window.opacity = 255
    if $game_party.actors.size == 0
      @command_window.disable_item(0)
      @command_window.disable_item(1)
      @command_window.disable_item(2)
      @command_window.disable_item(3)
    end
    if $game_system.save_disabled
      @command_window.disable_item(4)
    end
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @command_window.dispose
    @status_window.dispose
    @steps_window.dispose
    @spriteset.dispose
  end
end
  def update
    @spriteset.update
    @command_window.update
    @status_window.update
    @steps_window.update
    if @command_window.active
      update_command
      return
    end
    if @status_window.active
      update_status
      return
    end
  end
    def update_command
     if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 0
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Item.new
      when 1
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 2
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 3 
        $game_system.se_play($data_system.decision_se)
        @command_window.active = false
        @status_window.active = true
        @status_window.index = 0
      when 4
        if $game_system.save_disabled
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Save.new
      when 5
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_End.new
      end
    end
  def update_status
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @command_window.active = true
      @status_window.active = false
      @status_window.index = -1
      return
    end
    if Input.trigger?(Input::C)
      case @command_window.index
      when 1
        if $game_party.actors[@status_window.index].restriction >= 2
          $game_system.se_play($data_system.buzzer_se)
          return
        end
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Skill.new(@status_window.index)
      when 2
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Equip.new(@status_window.index)
      when 3
        $game_system.se_play($data_system.decision_se)
        $scene = Scene_Status.new(@status_window.index)
      end
      return
    end
  end
end


To get the location up instead of the steps counter put this scriptlet above main

$data_mapinfos = load_data('Data/MapInfos.rxdata')

class Window_Steps

def refresh
contents.clear
contents.font.color = system_color
contents.draw_text(4, 0, 120, 32, 'Location')
contents.font.color = normal_color
name = $data_mapinfos[$game_map.map_id].name 
contents.draw_text(0, 32, 128, 32, name)

end
end


And to get the horizontal commands to work, put this somewhere above main

#==============================================================================
# ¦ Window_Command
#------------------------------------------------------------------------------
#  ?????????????????????
#==============================================================================

class Window_Command < Window_Selectable
  #--------------------------------------------------------------------------
  # ? ?????????
  #     width    : ???????
  #     commands : ??????????
  #--------------------------------------------------------------------------
  def initialize(width, commands, column_max = 1, style = 0, inf_scroll = 1)
    # ????????????????????
    super(0, 0, width, (commands.size * 1.0 / column_max).ceil * 32 + 32)
    @inf_scroll = inf_scroll
    @item_max = commands.size
    @commands = commands
    @column_max = column_max
    @style = style
    self.contents = Bitmap.new(width - 32, (@item_max * 1.0 / @column_max).ceil * 32)
    self.contents.font.name = "Comic Sans MS"
    self.contents.font.size = 24
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # ? ?????
  #     index : ????
  #     color : ???
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    rect = Rect.new(index%@column_max * (self.width / @column_max) + 4, 32 * (index/@column_max), self.width / @column_max - 40, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index], @style)
  end
  #--------------------------------------------------------------------------
  # ? ??????
  #     index : ????
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
 
  def update_help
    @help_window.set_actor($game_party.actors[$scene.actor_index])
  end
end


Hope you like and post here if you have any trouble or queries ;)
Title: Re: Simple 3-person CMS
Post by: ChaosSpartan28 on May 06, 2007, 04:17:21 PM
very nice. I like how it doesnt take up the entire screen. But the options' words font sizes dont match up. Some are boldish and others arent.

Question About it

Can it only support 3 people?
Title: Re: Simple 3-person CMS
Post by: modern algebra on May 06, 2007, 05:17:24 PM
Who made the horizontal command script?

And good job. It's a nice first CMS.
Title: Re: Simple 3-person CMS
Post by: The Shadow on May 06, 2007, 05:25:10 PM
I don't like that a little bit of Shadows face is entering the location window. And I also don't like the different font styles in the option command. Equip and Status is wrong.

Basicly, I like the old one better.
Title: Re: Simple 3-person CMS
Post by: Rune on May 06, 2007, 05:34:26 PM
@Modern Algebra - Not sure who made the Location script or the horizontal commands O_o... my friend just gave them to me... I think anyway...

@ChaosSpartan28 - The font sizes are the same, it's just that the longer words are 'compressed' into a small space... if you look at the menu in my game, you can barely see the 'Bestiary' option XD
The menu can support 4 characters but the fourth one doesn't show up in the menu...

@Black Shadow - With the font styles, as above. I'll try changing it so that the location window is under the face... but so that the location is still visible, I had a bit of trouble with that...

And the old CMS was an edit of one that my friend made... this is my first Menu from scratch
Title: Re: Simple 3-person CMS
Post by: Winged on May 06, 2007, 10:22:48 PM
That looks awesome! Nice job (Should be moved to database, a lot of people request CMSs these days =/

~Winged
Title: Re: Simple 3-person CMS
Post by: Rune on May 07, 2007, 08:08:29 AM
Crikey, my first script in the database? I didn't think it was that good :D
Title: Re: Simple 3-person CMS
Post by: Falcon on May 07, 2007, 08:51:26 AM
I talked to Nouman a while ago about making the database for all completed scripts, we scripters don't waste hours on work to see our work ignored with a bunch of requests.
Title: Re: Simple 3-person CMS
Post by: Rune on May 07, 2007, 08:56:04 AM
Oh okay :D