CMS Layout Tutorial...

Started by Calintz, January 27, 2008, 01:05:02 pm

Previous topic - Next topic

Calintz

January 27, 2008, 01:05:02 pm Last Edit: January 27, 2008, 01:06:35 pm by Calintz16438
I'm always seeing all kinds of different CMS's everywhere, and I really want to make one of my own. However, I always run into a pretty big problem...I don't know how to properly organize one of these.

I do know that every >> class Window_""[/b] << needs it's own scene, to call it, correct?? Well, when I look at the way other people have organized their CMS's, they have both the >> class Window_"" << and it's proper scene in the CMS's script.

I was wondering if someone could make me a tutorial, not going into detail about how to make a CMS, but rather a list in order of what needs to be where...Like, do I need to make the window first, or it's scene...When do I call the Scene_Menu, and things like that...


Kudos in advance, and I know it sounds kinda like a bribe, but whoever completes this request for me, gets powered up!! I do this for everyone who completes a request for me.

Blizzard

January 27, 2008, 01:13:59 pm #1 Last Edit: January 27, 2008, 01:15:15 pm by Blizzard
In fact, you can call any window for your scene that already exists. It's rather easy. This would be the template for it:

class Scene_MINE
 
  def main
    # intializing windows
    # some extra processing if you need it
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      break if $scene != self
    end
    Graphics.freeze
    # window disposal
    # some extra exit processing if you need it
  end
 
  def update
    # updating stuff and handling
  end
 
end


The best way to make a CMS is to copy the scene and the windows used. Then you simply rename the window classes and let your modified menu scene call them. Let your menu scene stay Scene_Menu, though, so it can override the original. Then start messing around with the window copies and watch what happens. That way you can make a CMS without fully understanding how everything works. You can learn scene creation later and advanced window handling later.

BTW, variables with $ before the identifier (or name) are global, that means EVERY class can see them. Variables with an @ can be seen only within the class itself, but they are "global" within that class. That's why people store windows in @something_window variables: To be able to acces them from other methods. The last ones are local variables which have only a name without any prefix. They are deleted (actually the reference is) if the execution exits the current method.

EDIT:

I don't see anything wrong with accomplish -> reward system. :P
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

January 27, 2008, 01:16:02 pm #2 Last Edit: January 27, 2008, 01:18:51 pm by Calintz16438
I know most of that, like creating a window itself. I do know how to do that, and I know how to add it to the menu, I just don't know what would go where inside a CMS script...

When you say copy the scene and it's windows used, you mean the regular Scene_Menu, and then copy Window_Item and all the rest??

Blizzard

January 27, 2008, 01:26:19 pm #3 Last Edit: January 27, 2008, 01:29:30 pm by Blizzard
Creating an instance of a class (not just windows, this works in general):
@gold_window = Window_Gold.new


Window/Sprite/Bitmap disposal (not necessary for instances of other classes than windows and sprites, rarely necessary for bitmaps):
@gold_window.dispose


And yeah. Copy the code from the scene and then mess around like setting a line commented with a # in front (to "turn if off") and see what happens if that line is not executed.

EDIT:

To define what a window does and how it looks like, you can simply look at the code of that window and mess around with it. I suggest you really first try Window_Gold as it is the most simple.

class Window_Gold < Window_Base
  ...
end
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

January 27, 2008, 01:31:54 pm #4 Last Edit: January 27, 2008, 01:37:57 pm by Calintz16438
Ok, thank you...
I will begins farting around now... ;D

P.S. Looks like first come, first serve, Lol, and the Raging Snowstorm is powered up!!

Edit
I understood every line in Window_Gold, except for this one:
- cx = contents.text_size($data_system.words.gold).width...(What the heck is that "cx"??

Blizzard

January 27, 2008, 02:13:21 pm #5 Last Edit: January 27, 2008, 02:15:05 pm by Blizzard
Just a temporary variable. I'll explain it.

$data_system.words.gold - the word for gold that you set up in the database
self.contents.text_size('TEXTSTRING') - a method that returns an instance of the class "Rect" which has the attributes x, y, width and height, it basically returns the rectangle needed to draw the text
rect.width - get the width value of the returned rectangle
cx = SOMETHING - store the result in the local variable called cx
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

I see...
I have made minor modifications to the Default menu, and I will post it soon...

Blizzard

In this case it's used the be able to draw text to look like as if it is draw with one command, but using different colors.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

I don't understand what you mean??

Blizzard



The EXP is drawn in a different color. That can only be done if first one color is selected, then the number drawn and the width of the number stored (i.e. in cx), then the color changed and the word EXP drawn with an offset which is equal to cx increased by i.e. 4.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

Alright, gotcha now!!

I want to add an option to your CMS, you don't have a problem with that!!??

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Calintz

Ok cool...
So back to the topic...

So to make a CMS, simply copy Scene_Menu and all of it's windows, and paste them into one script above main. Then, tinker with their individual properties t'il you basically see fit, right??

I started a CMS, by doing this, and I joined the game statistic into one window kinda like you did in your CMS, but a little differently. I did this, by making a new window >> Window_GameStatistics, and copied the original 3 statistics' draw_text commands into one >>
Spoiler: ShowHide
#============================================================================
# ** Window_GameStatistics
#----------------------------------------------------------------------------
# This window will show all three of the basic game statistics in one window
# instead of three - (Gold, Playtime, and Steps taken)
#----------------------------------------------------------------------------
class Window_GameStatistics < Window_Base
 
  def initialize
    super(0, 0, 160, 150)
    self.contents = Bitmap.new(width - 32, height - 32)
    refresh
  end
 
  def refresh
    self.contents.clear
    cx = contents.text_size($data_system.words.gold).width
    self.contents.font.color = normal_color
    self.contents.draw_text(22, 0, 120-cx-2, 32, $game_party.gold.to_s, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(22-cx, 0, cx, 32, $data_system.words.gold, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(4, 28, 120, 32, "Time")
    @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(4, 28, 120, 32, text, 2)
    #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
    if Graphics.frame_count / Graphics.frame_rate != @total_sec
      refresh
    end
  end
    self.contents.font.color = system_color
    self.contents.draw_text(4, 54, 120, 32, "Steps")
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 74, 12, 32, $game_party.steps.to_s, 2)
  end

end
<< and then just replaced their .disposes and .updates with >> Window_Gamestatistics.update etc...

In the end, this is what I made >>
Spoiler: ShowHide


P.S. I added your TUT Viewer to the main menu  ;D

Blizzard

Very nice. You're getting the grip of it. :)
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

Nortos

doing well Calintz :) you should add location to your game statistics as well here' s the code from my menus location you can muddle with it to get what you want

class Window_Location < Window_Base
 
def initialize
  super(0, 0, 480, 64)
   self.contents = Bitmap.new(width - 32, height - 32)
   self.contents.font.name = "Tahoma"
   self.contents.font.size = 14
   refresh
end

def refresh
   self.contents.clear
   data = load_data("Data/MapInfos.rxdata")
   self.contents.font.color = system_color
   self.contents.draw_text(0, 0, 248, 32, "Location:")
   self.contents.font.color = normal_color
   self.contents.draw_text(90, 0, 208, 32, data[$game_map.map_id].name, 2)
  end
end


btw when I was doing my CMS dubs scripting tut 3 was good help he gives basics of CMS's there

Calintz

January 27, 2008, 06:24:01 pm #15 Last Edit: January 27, 2008, 06:25:08 pm by Calintz16438
Lol, that's easy now seeing it, however I never would have guessed the actualt syntax used to call it!! :P Thnx Nortos...

- I just finished my edit of your CMS Blizzard, and this is what it looks like now:
Spoiler: ShowHide


- All that's left, is making new icon graphics for the index options, so there's some individuality to the usage of your CMS in my game, on par with the use of it in everyone else's games. ** I even remembered to make sure that when leaving the tutorial viewer, that the highlighted option is still located on it :)

!! Thnx Blizzard

Calintz

Two things...
>> Can I animate that little guy in anyway possible, or would that cause unsightely lag??
>> Main Q >> How do I change the x position of menu_index options??

Nortos

answered your question somewhere else about the animated but for the X location you mean for Blizz's CMS or a different one, Blizz uses different syntax for his commands

Calintz

Another few days, and My CMS should be out. Some tweaking for bells and whistles, and a little organizing is left.

Sally

i wanna make my own inventory menu :P