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.

Window_Command in Scene_Menu - How ones position is determined in the other...

The thread title really says it all, but to elaborate:

I've been pouring over the Scene_Menu and Window_Command scripts (Base versions), and while I can see where in Scene_Menu the Command Window is called and can successfully edit it for new commands, etc, I am unable to move it from it's standard position (IE, the left side top.) For any other window in the Scene, there is a couple of lines to define it's position on screen, but I'm not seeing one for Window_Command.

Would someone kindly point out what I'm obviously missing, so that I may put that darn window where I want it?
 

khmp

Sponsor

The command window's instance followed by ".x" or ".y". I'm not on my laptop so I don't know the name of the command window. But right below where it says something like the below line.
Code:
@commands = Command_Window.new(100, options)
You can add these two lines and the window's upper left corner will appear at 100, 100. But you can make them whatever you want.
Code:
@commands.x = 100
@commands.y = 100

Oh because "Command_Window" derives from "Window" you have those methods inherited from the parent. Usually any method defined in an ancestor/parent is usable by a child.

Good luck with it Shadriss! :thumb:
 
Translated : Those commands (The .x and .y) aren't used in the original menu, but can be added in. Ok, great. Thanks much. I figured it might be something along those lines, but didn't want to screw with the work I'd already done to test it. Aside from which I had about 15 other windows to look at and figure out. :)

Thanks again.
 

khmp

Sponsor

No I think I explained it poorly. Those methods already exist but not inside the class definition of Window_Command. Like let's say you have a golf club class definition.
Code:
class Golf_Club
  def distance=(x)
    @distance = x
  end
  def arc=(x)
    @arc = x
  end
end
Then later on in the script we have a putter class which derives from Golf_Club.
Code:
class Putter < Golf_Club
  def max_power(x)
    @max_power = x
  end
end
And then when I make an instance of a Putter I can do something like this.
Code:
@my_putter = Putter.new
@my_putter.distance = 30
@my_putter.arc = 0
@my_putter.max_power = 1
You'll notice that just because the distance method isn't technically defined within the Putter class, I can still use the method because it is defined within the parent. The same thing is occurring when you use the method ".x" and ".y" when working with a Window_Command instance. I hope that helps you out. If you have any questions just let me know.
 
let's say you added / modified a method inside Golf_Club and created the Golf_Club window

Code:
class Golf_Club
  def self.distance
    @distance = x
  end
end

Code:
class Window_Golf_Club < Window_Base
  def iniitialize
    super(0, 0, 160, 192) # x = 0, y = 0, width = 160, height = 192
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.draw_text(0, 0, 96, 32, Golf_Club.distance.to_s, 1)
  end
end
inside Scene_Menu you created a window like this
@golf_club_window = Window_Golf_Club.new

if you leave it as it is, it could hide the @command_window. Since you want both to be visible, you would need to do this modification inside Scene_Menu

@golf_club_window.y = 208

This would force the game to place the @golf_club_window just a few pixels below the @command_window.

let's say you want it to be on the right hand side instead... Just add this line there

@golf_club_window.x = 480

now you can either place it below the @command_window or on the right hand side at will. This is valid for any window you create in a Scene script.
 
Actually, I must have replied poorly. I understood what you meant. I was only saying that in the default Scene_Menu, it didn't use the .x and .y methods to determine the Window_Command position, and hence, weren't used. Therefore, since they both derived from Window_Base (as do all the other windows) I could add in those methods to Scene_Menu to redefine the position of the Command Window.

I did one CMS about a year ago, and figured out a lot of this. Just never wanted to move the command window before, so didn't look into this. Obvious in hindsight, of course.  :smile:
 

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