Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

How to add buttons in the title screen

Hello I don't know If I'm putting this in the right board, essentially I want to modify the Title Screen using the script and I'm wondering how to do that. What I want to do is to remove the window in the center of the title screen and replace it with buttons that you could select with the arrow keys, something like this:

Diagram:

Any help at all will be appreceated, Thank you.

EDIT: It RPG maker XP btw
 
Hmmm... Try adding this in a new section anywhere below Window_Command:
Code:
class Window_Command::Volley < Window_Selectable

  def initialize(width, height, commands)

    super(0, 0, width, height)

    self.contents = Bitmap.new(width - 32, height - 32)

    @commands = commands

    @item_max = @commands.size

    @disabled = Hash.new(false)

    refresh

  end

  def refresh

    for i in 0...@item_max

      draw_command(i)

    end

  end

  def disabled?(index = @index)

    return @disabled[index]

  end

  def disable_item(index)

    @disabled[index] = true

    draw_command(index)

  end

  def draw_command(i)

    x, y, command = *@commands[i]

    size = self.contents.text_size(command)

    color = disabled?(i) ? disabled_color : normal_color

    self.contents.font.color = color

    self.contents.draw_text(x, y, size.width, size.height, command)

  end

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    x, y, command = *@commands[@index]

    size = self.contents.text_size(command)

    self.cursor_rect.set(x - 2, y - 2, size.width + 4, size.height + 4)

  end

end

 

class Window_Command::Volley::Picture < Window_Command::Volley

  def draw_command(i)

    x, y, filename = *@commands[i]

    bitmap = RPG::Cache.picture(filename)

    @sizes = {} if @sizes == nil

    @sizes[i] = [bitmap.width, bitmap.height]

    color = disabled?(i) ? disabled_color : normal_color

    self.contents.blt(x, y, bitmap, bitmap.rect, color.alhpa)

  end

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    x, y, filename = *@commands[@index]

    w, h = *@sizes[@index]

    self.cursor_rect.set(x - 2, y - 2, w + 4, h + 4)

  end

end

Ok now in Scene_Title, you'll see something like:

@command_window = Window_Command.new(192, [s1, s2, s3])

Change that line and the following lines (down to @command_window.y =)

Code:
 

commands = []

commands << [x, y, 'New Game']

commands << [x, y, 'Continue']

@command_window = Window_Command::Volley::Picture.new(640, 480, commands)

@command_window.opacity = 0

 

Now in those lines I gave you to change, change x, y with your position you want your pictures to be displayed (something like 8, 368 and 40, 400).

Now add your pictures "New Game" and "Continue" into your Pictures folder (in your projects Graphics folder).

I haven't tested this (as I didnt bother to open XP), so let me know how this works for you.
 
Umm Im getting this message: Script 'Scene_Title' line 41: Name error occured. Undefined local varible or method 'commands' for #<Scene_Title: 0x1371008.

I'm going to take another look at the process to see if I'm the one who messed up.
Oh and when you mean new section you mean insert right(and what should i name said script?)

And Thank you btw.
 
Can you post your modification of Scene_Title

And yes, just press insert above Main, copy the script I gave you in it, and if you want name it Window_Command::Volley or whatever. The name doesn't really matter.
 
Her's the code section and I put The other script below Window_Command

Code:
# Make command window

    s1 = "New Game"

    s2 = "Continue"

    s3 = "Shutdown"

    

    @commands = []

    commands << [8, 368, 'New Game']

    commands << [40, 400, 'Continue']

    @command_window = Window_Command::Volley::Picture.new(640, 480, commands)

    @command_window.opacity = 0

    # Continue enabled determinant

    # Check if at least one save file exists

    # If enabled, make @continue_enabled true; if disabled, make it false

    @continue_enabled = false

    for i in 0..3

      if FileTest.exist?("Save#{i+1}.rxdata")

        @continue_enabled = true

      end

    end
 
Cool, solved one problem, just got another. Again, I'm really sorry for putting you through this.
Script 'Window_Command: Volley' line 47: NoMethodEnter occured. undefined method 'alpha' for (255.000000, 255, 255, 255):Color.

annd here's the script.
Code:
class Window_Command::Volley::Picture < Window_Command::Volley

  def draw_command(i)

    x, y, filename = *@commands[i]

    bitmap = RPG::Cache.picture(filename)

    @sizes = {} if @sizes == nil

    @sizes[i] = [bitmap.width, bitmap.height]

    color = disabled?(i) ? disabled_color : normal_color

    self.contents.blt(x, y, bitmap, bitmap.rect, color.alhpa)

  end

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    x, y, filename = *@commands[@index]

    w, h = *@sizes[@index]

    self.cursor_rect.set(x - 2, y - 2, w + 4, h + 4)

  end

end

I srsly apologize for being a useless git when it comes to code.
 
I assume you didn't look close enough at your error message, but it should've actually been 'alhpa'. Anyway, here's your error:
Code:
self.contents.blt(x, y, bitmap, bitmap.rect, color.alhpa)
Change it to color.alpha, and you're set.
 
Ya! It starts. Thank you, the both of you now I'm going to place the buttons and figure out how to start the game via buttons, I'll post back here in a week if there's anything else I can't figure out in the title screen.

Srsly though I cannot thank you enough both for your help(and berate myself for lack of intelligence.)

On a side note though is there any Custom Menu Scripts floating around here or should I event it?
 
Ya your signature is pretty inspiring, any ways for some reason the buttons do nothing yet there is no error message, so I'm wondering if I'm missing anything like a cursor or something or other.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top