I'm editing the basic menu so the choices listed are shown horizontal instead of vertical.
So far, removing everything but the command window is easy but I need to add one thing.
(http://i.imgur.com/bvUjIlF.png)
As shown in the picture above, I'm thinking of having that bar visible all the time. Text shows in the window, one line at a time to conserve space. This requires 2 things:
1 - The command window needs to be horizontal instead of vertical because of the menu being icons only.
2 - The command window should not have anything visible other than the cursor itself. The text of each option should be shown on the left side of the bar to indicate what each selection does.
Now this is made in script troubleshooting because I'd like to understand how it's done not someone makes it for me and be done with it. I appreciate the help of course, it's just I'd like to know what has to be changed in case of further adjustments or for future menu ideas.
Thanks for the help.
Do you have any code to share?
Well that is a picture heh...
So far I edited scene menu to remove the unnecessary stuff:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize(menu_index = 0)
@menu_index = menu_index
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
@mapback = Spriteset_Map.new
# Make command window
s1 = "Inventory"
s2 = "Notes"
s3 = "Role Cards"
s4 = "Options"
#s5 = "Save"
#s6 = "End Game"
@command_window = Window_Command.new(160, [s1, s2, s3, s4])
@command_window.index = @menu_index
# If number of party members is 0
if $game_party.actors.size == 0
# Disable items, skills, equipment, and status
@command_window.disable_item(0)
@command_window.disable_item(1)
@command_window.disable_item(2)
@command_window.disable_item(3)
end
# If save is forbidden
if $game_system.save_disabled
# Disable save
@command_window.disable_item(4)
end
# Make play time window
#@playtime_window = Window_PlayTime.new
#@playtime_window.x = 0
#@playtime_window.y = 224
# Make steps window
#@steps_window = Window_Steps.new
#@steps_window.x = 0
#@steps_window.y = 320
# Make gold window
#@gold_window = Window_Gold.new
#@gold_window.x = 0
#@gold_window.y = 416
# Make status window
#@status_window = Window_MenuStatus.new
#@status_window.x = 160
#@status_window.y = 0
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@mapback.dispose
@command_window.dispose
#@playtime_window.dispose
#@steps_window.dispose
#@gold_window.dispose
#@status_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@mapback.update
@command_window.update
#@playtime_window.update
#@steps_window.update
#@gold_window.update
#@status_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# If command other than save or end game, and party members = 0
if $game_party.actors.size == 0 and @command_window.index < 4
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Branch by command window cursor position
case @command_window.index
when 0 # item
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to item screen
$scene = Scene_Item.new
when 1 # skill
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Make status window active
@command_window.active = false
@status_window.active = true
@status_window.index = 0
when 4 # save
# If saving is forbidden
if $game_system.save_disabled
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to save screen
$scene = Scene_Save.new
when 5 # end game
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to end game screen
$scene = Scene_End.new
end
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when status window is active)
#--------------------------------------------------------------------------
def update_status
# If B button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Make command window active
@command_window.active = true
@status_window.active = false
@status_window.index = -1
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 1 # skill
# If this actor's action limit is 2 or more
if $game_party.actors[@status_window.index].restriction >= 2
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to skill screen
$scene = Scene_Skill.new(@status_window.index)
when 2 # equipment
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to equipment screen
$scene = Scene_Equip.new(@status_window.index)
when 3 # status
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Switch to status screen
$scene = Scene_Status.new(@status_window.index)
end
return
end
end
end
Once I manage to make the command list horizontal I'll see on editing what each selection opens.
So far, I found this: http://www.gdunlimited.net/forums/topic/4593-horizontal-command-window/ (http://www.gdunlimited.net/forums/topic/4593-horizontal-command-window/)
Has the ability of turning command windows into horizontal from vertical with some little modification.
I might take a quick peek at my Alive menu script as it's horizontal and uses similar functions (Icon instead of text) as I'm trying to do here. There's no guarantee I'll understand what to edit tough that's why I made this thread so you guys can help me learn.
Sorry for the double post.
Long story short, I managed to use and edit the script I have in my Alive project.
Instead of showing all the icons like the picture above, when you open the menu, an icon shows with arrows on both sides. This let's you move back/forward for the other options. After struggling for the help text for quite a bit, I managed to also make it work.
So, I guess this thread has no purpose and can be closed.
So I guess, I could still use some opinions...
The menu after I opted to edit the script in my Alive project (To have horizontal commands as icons one at a time) I changed it from the picture in the first post into:
(http://i.imgur.com/5I8mkWV.png)
However, there's one thing that irks me a little, which is when the menu is not open. When you are not interacting with anyone or into the menu, the bottom bar is left with those 2 blocks empty. Now, I had some ideas like editing the picture to show the inventory icon plus arrows to make it look less empty and it "works", I guess.... Not sure if it's enough tough.
So, I thought about hiding it instead of having the bottom bar show all the time and have it show in accordance to when it's needed.
This however made me halt on when I needed to show a picture instead of the windowskin when I interact with someone. I tried searching and tried different methods but kept getting errors so I scratched everything and went back showing the picture.
The question, however is:
What do I need to add to show a picture in the message script.
Thanks
I guess I don't really understand how your code works. The whole window on the bottom and scrolling through the item options is a Window object that is handled in Scene_Menu? And when you exit the scene, you return back to Scene_Map and the window is now a picture (essentially a dummy)? And you're asking how you can combine two scenes together?
I think I just need a clarification how your menu thing works.
No no no.
I explained how it worked, which is essentially how you said it, via a picture on the screen and everything shows on it (Messages, menu commands etc etc). Then I tried improving on it as I thought having the blank picture showing at all time would look weird?
I tried removing the picture itself and have it show via scripting instead of the windowskin when you interact with someone or open the menu, but I can't seem to make a picture show in window message since there is no scene message.
I only got errors.
So why can't you just use a Show Picture event command?
Replacing the windowskin with a picture would be so much easier than having to add the picture on every dialogue tough.
I did it successfully for the menu and other windows but I can't seem to understand how to show a picture as background instead of the windowskin when a message appears.
Use the Window#opacity attribute and set it to 0. This will turn the windowskin "invisible" but leave the text in, say your message box, visible.
Well...... That's how it's set atm.
Opacity = 0 and the picture showing underneath. I however, was thinking on making the said picture show only when dialogue appears, just like the picture shows when the menu is called.
And by trying, I meant trying to use something like this in window_message:
@menu_back.bitmap = RPG::Cache.picture("") rescue nil
So no one can guide me on how to show a picture in window_message?
@menu_back.bitmap = RPG::Cache.picture("") rescue nil
This type of code gives me an error since it's in window type not class type.
I gave up because I still don't get what you're doing.
Post a demo.
I'm trying to show a picture in window_message when dialogue appears on the screen and this line of code that I use in scene_menu:
@menu_back.bitmap = RPG::Cache.picture("") rescue nil
Doesn't work.
Don't know how can I explain more easy than that.
What is @menu_back? How are you initializing it? How does your Scene_Map look? How does the menu even work? Why does the menu even need to be visible during dialogue?
All of these things I have no idea. Thus, post a demo or I'm done.
Quote from: KK20 on February 21, 2015, 04:16:08 pm
What is @menu_back? How are you initializing it? How does your Scene_Map look? How does the menu even work? Why does the menu even need to be visible during dialogue?
All of these things I have no idea. Thus, post a demo or I'm done.
@menu_back is what I guess the code information is stored in:
#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Scene_Menu
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
#Invisible Background
@mapback = Spriteset_Map.new
#Picture under windowskin
@menu_back = Sprite.new
@menu_back.bitmap = RPG::Cache.picture("") rescue nil
@menu_back.z = 3000 #3000
@menu_back.opacity = 0
icons = ['Menu0','Menu1','Menu2']
@command_window = Window_Item_Command.new(0,64,@menu_index) #0,64
@help_window = Window_Help.new
@help_window.opacity = 0
@help_window.x = 0
@help_window.y = 415 # 415
@help_window.z = 3000 #3000
@command_window.help_window = @help_window
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
@menu_back.dispose
@command_window.dispose
@help_window.dispose
@mapback.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
@mapback.update
@command_window.update
@help_window.update
@menu_back.update
- Scene_Map is untouched.
- I mentioned the menu because it has that piece of coding (As shown above) that let's me show a picture instead of using the windowskin when the menu is called. I never said the menu needs to show up when dialogue is on the screen, I just said I'm trying to show a picture instead of the windowskin.
I'm simply asking how can I show a picture when dialogue appears on the screen via scripting.
I could provide a demo if you really need it eventough I see no point. The only script I have in it so far is an edit of the original menu.
And this is why I have confusion: you're showing me code that has absolutely nothing to do with what you want.
First off, the code you posted is a modification of Scene_Menu which has no relationship with the message window at all. You need Scene_Map for that.
class Scene_Map
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make sprite set
@spriteset = Spriteset_Map.new
# Make message window
@message_window = Window_Message.new #<================== It's right here
If the picture you're trying to show is always the same, add this modified Scene_Map and change the values in the main method. I put division lines for the part you need to fix.
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs map screen processing.
#==============================================================================
class Scene_Map
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make sprite set
@spriteset = Spriteset_Map.new
# Make message window
@message_window = Window_Message.new
#================================================
@message_picture = Sprite.new
@message_picture = RPG::Cache.picture("Filename")
@message_picture.visible = false
@message_picture.x = ?
@message_picture.y = ?
#================================================
# Transition run
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of sprite set
@spriteset.dispose
# Dispose of message window
@message_window.dispose
@message_picture.dispose
# If switching to title screen
if $scene.is_a?(Scene_Title)
# Fade out screen
Graphics.transition
Graphics.freeze
end
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Loop
loop do
# Update map, interpreter, and player order
# (this update order is important for when conditions are fulfilled
# to run any event, and the player isn't provided the opportunity to
# move in an instant)
$game_map.update
$game_system.map_interpreter.update
$game_player.update
# Update system (timer), screen
$game_system.update
$game_screen.update
# Abort loop if player isn't place moving
unless $game_temp.player_transferring
break
end
# Run place move
transfer_player
# Abort loop if transition processing
if $game_temp.transition_processing
break
end
end
# Update sprite set
@spriteset.update
# Update message window
@message_window.update
@message_picture.update
# If game over
if $game_temp.gameover
# Switch to game over screen
$scene = Scene_Gameover.new
return
end
# If returning to title screen
if $game_temp.to_title
# Change to title screen
$scene = Scene_Title.new
return
end
# If transition processing
if $game_temp.transition_processing
# Clear transition processing flag
$game_temp.transition_processing = false
# Execute transition
if $game_temp.transition_name == ""
Graphics.transition(20)
else
Graphics.transition(40, "Graphics/Transitions/" +
$game_temp.transition_name)
end
end
# If showing message window
if $game_temp.message_window_showing
@message_picture.visible = true
return
else
@message_picture.visible = false
end
# If encounter list isn't empty, and encounter count is 0
if $game_player.encounter_count == 0 and $game_map.encounter_list != []
# If event is running or encounter is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.encounter_disabled
# Confirm troop
n = rand($game_map.encounter_list.size)
troop_id = $game_map.encounter_list[n]
# If troop is valid
if $data_troops[troop_id] != nil
# Set battle calling flag
$game_temp.battle_calling = true
$game_temp.battle_troop_id = troop_id
$game_temp.battle_can_escape = true
$game_temp.battle_can_lose = false
$game_temp.battle_proc = nil
end
end
end
# If B button was pressed
if Input.trigger?(Input::B)
# If event is running, or menu is not forbidden
unless $game_system.map_interpreter.running? or
$game_system.menu_disabled
# Set menu calling flag or beep flag
$game_temp.menu_calling = true
$game_temp.menu_beep = true
end
end
# If debug mode is ON and F9 key was pressed
if $DEBUG and Input.press?(Input::F9)
# Set debug calling flag
$game_temp.debug_calling = true
end
# If player is not moving
unless $game_player.moving?
# Run calling of each screen
if $game_temp.battle_calling
call_battle
elsif $game_temp.shop_calling
call_shop
elsif $game_temp.name_calling
call_name
elsif $game_temp.menu_calling
call_menu
elsif $game_temp.save_calling
call_save
elsif $game_temp.debug_calling
call_debug
end
end
end
#--------------------------------------------------------------------------
# * Battle Call
#--------------------------------------------------------------------------
def call_battle
# Clear battle calling flag
$game_temp.battle_calling = false
# Clear menu calling flag
$game_temp.menu_calling = false
$game_temp.menu_beep = false
# Make encounter count
$game_player.make_encounter_count
# Memorize map BGM and stop BGM
$game_temp.map_bgm = $game_system.playing_bgm
$game_system.bgm_stop
# Play battle start SE
$game_system.se_play($data_system.battle_start_se)
# Play battle BGM
$game_system.bgm_play($game_system.battle_bgm)
# Straighten player position
$game_player.straighten
# Switch to battle screen
$scene = Scene_Battle.new
end
#--------------------------------------------------------------------------
# * Shop Call
#--------------------------------------------------------------------------
def call_shop
# Clear shop call flag
$game_temp.shop_calling = false
# Straighten player position
$game_player.straighten
# Switch to shop screen
$scene = Scene_Shop.new
end
#--------------------------------------------------------------------------
# * Name Input Call
#--------------------------------------------------------------------------
def call_name
# Clear name input call flag
$game_temp.name_calling = false
# Straighten player position
$game_player.straighten
# Switch to name input screen
$scene = Scene_Name.new
end
#--------------------------------------------------------------------------
# * Menu Call
#--------------------------------------------------------------------------
def call_menu
# Clear menu call flag
$game_temp.menu_calling = false
# If menu beep flag is set
if $game_temp.menu_beep
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Clear menu beep flag
$game_temp.menu_beep = false
end
# Straighten player position
$game_player.straighten
# Switch to menu screen
$scene = Scene_Menu.new
end
#--------------------------------------------------------------------------
# * Save Call
#--------------------------------------------------------------------------
def call_save
# Straighten player position
$game_player.straighten
# Switch to save screen
$scene = Scene_Save.new
end
#--------------------------------------------------------------------------
# * Debug Call
#--------------------------------------------------------------------------
def call_debug
# Clear debug call flag
$game_temp.debug_calling = false
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Straighten player position
$game_player.straighten
# Switch to debug screen
$scene = Scene_Debug.new
end
#--------------------------------------------------------------------------
# * Player Place Move
#--------------------------------------------------------------------------
def transfer_player
# Clear player place move call flag
$game_temp.player_transferring = false
# If move destination is different than current map
if $game_map.map_id != $game_temp.player_new_map_id
# Set up a new map
$game_map.setup($game_temp.player_new_map_id)
end
# Set up player position
$game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
# Set player direction
case $game_temp.player_new_direction
when 2 # down
$game_player.turn_down
when 4 # left
$game_player.turn_left
when 6 # right
$game_player.turn_right
when 8 # up
$game_player.turn_up
end
# Straighten player position
$game_player.straighten
# Update map (run parallel process event)
$game_map.update
# Remake sprite set
@spriteset.dispose
@spriteset = Spriteset_Map.new
# If processing transition
if $game_temp.transition_processing
# Clear transition processing flag
$game_temp.transition_processing = false
# Execute transition
Graphics.transition(20)
end
# Run automatic change for BGM and BGS set on the map
$game_map.autoplay
# Frame reset
Graphics.frame_reset
# Update input information
Input.update
end
end
You asked me how the menu works so I posted the code. I mean, showing a picture wouldn't solve anything heh... When I was trying to show a picture for when dialogue is on the screen, I tried to copy the same lines of code used in that scene menu but alas it doesn't work in window_message as it gives an error.
Scene_Map is default atm. I had no idea it was tied to the window_message. I'm not familiar with the rmxp coding language.
All I was trying to accomplish is, showing a custom picture on the screen whenever you speak with an npc or interact with something. Hiding the window is easy with opacity = 0, showing a picture to have the text show over it was giving me a headache to make it work as I don't have much knowledge on ruby.
I'll check it tomorrow and see if that is what I was trying to accomplish.
Thank you for the help.
[Edit]
Nope, gives me a nomethod error on:
@message_picture.visible = false
If I comment it off gives an error on other lines like:
and
# If showing message window
if $game_temp.message_window_showing
@message_picture.visible = true
return
else
@message_picture.visible = false
end
I am using http://forum.chaos-project.com/index.php/topic,14790.0.html ring choice window script if that has any incompatabilities.
Whoops, forgot to put .bitmap
@message_picture.bitmap = RPG::Cache.picture("Filename")
Even you should have seen that :U
I tried it in a hurry before going to sleep :P
Anyway, I tried something similar before but it shows for a split second when the game launches and the picture never shows in any dialogue.
This has nothing to do with the menu but with the title screen but didn't see any point in making a new thread so.....
I am making a new title scene ontop of the default one and require some help.
I made it so when you click on new game instead of going into to the game, you go into a "new" title screen. This new one so far gives you the option to pick a difficulty or to go back to the title screen.
"Easy, Normal, Hard, Go Back"
Atm they show vertical, I want to show the first 3 horizontal and the fourth option underneath them unless it's too much work. (I'm thinking on adding a picture for each mode to explain what is different)
Once that is done, a help window shouldn't be too much hard to do.
How would I go in achieving this?
#==============================================================================
# ** Scene_Mode
#------------------------------------------------------------------------------
# This class performs title screen processing.
#==============================================================================
class Scene_Mode
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make system object
$game_system = Game_System.new
# Make title graphic
@sprite = Sprite.new
@sprite.bitmap = RPG::Cache.title($data_system.title_name)
# Make command window
s1 = "Easy Mode"
s2 = "Normal Mode"
s3 = "Hard Mode"
s4 = "Go Back"
@command_window = Window_Command.new(192, [s1, s2, s3, s4])
@command_window.back_opacity = 160
@command_window.x = 320 - @command_window.width / 2
@command_window.y = 288
# Play title BGM
$game_system.bgm_play($data_system.title_bgm)
# Stop playing ME and BGS
Audio.me_stop
Audio.bgs_stop
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of command window
@command_window.dispose
# Dispose of title graphic
@sprite.bitmap.dispose
@sprite.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
# Branch by command window cursor position
case @command_window.index
when 0 # Easy Mode
command_easy_mode
when 1 # Normal Mode
command_normal_mode
when 2 # Hard Mode
command_hard_mode
when 3 # Go Back
command_go_back
end
end
end
#--------------------------------------------------------------------------
# * Command: Easy Mode
#--------------------------------------------------------------------------
def command_easy_mode
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Map.new
end
#--------------------------------------------------------------------------
# * Command: Normal Mode
#--------------------------------------------------------------------------
def command_normal_mode
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Command: Hard Mode
#--------------------------------------------------------------------------
def command_hard_mode
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Title.new
end
#--------------------------------------------------------------------------
# * Command: Go Back
#--------------------------------------------------------------------------
def command_go_back
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Stop BGM
Audio.bgm_stop
# Reset frame count for measuring play time
Graphics.frame_count = 0
# Make each type of game object
$game_temp = Game_Temp.new
$game_system = Game_System.new
$game_switches = Game_Switches.new
$game_variables = Game_Variables.new
$game_self_switches = Game_SelfSwitches.new
$game_screen = Game_Screen.new
$game_actors = Game_Actors.new
$game_party = Game_Party.new
$game_troop = Game_Troop.new
$game_map = Game_Map.new
$game_player = Game_Player.new
# Set up initial party
$game_party.setup_starting_members
# Set up initial map position
$game_map.setup($data_system.start_map_id)
# Move player to initial position
$game_player.moveto($data_system.start_x, $data_system.start_y)
# Refresh player
$game_player.refresh
# Run automatic change for BGM and BGS set with map
$game_map.autoplay
# Update map (run parallel process event)
$game_map.update
# Switch to map screen
$scene = Scene_Title.new
end
end
The coding was taken from scene_title and edited to show those new options and it works. I tried removing redundant lines of codes but don't know if removing anything else would be bad.
[Edit]
This seems to work for horizontal commands but the text on cursor is not working as intended.
#==============================================================================
# Window Horizontal Command
# Created By SephirothSpawn (11.03.05)
# Last Updated: 11.03.05
#==============================================================================
class Window_HorizCommand < Window_Selectable
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(commands, width = 640, height = 64)
super(0, 0, width, height)
self.contents = Bitmap.new(width - 32, height - 32)
@commands = commands
@item_max = @commands.size
@column_max = @commands.size
refresh
self.index = 0
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
for i in 0...@item_max
draw_item(i)
end
end
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
width = self.width - 32
off = width / @item_max
x = 40 + index * off #4
self.contents.draw_text(x, 0, off - 32, 32, @commands[index]) #32, 32
end
#--------------------------------------------------------------------------
# * Disable Item
# index : item number
#--------------------------------------------------------------------------
def disable_item(index)
draw_item(index, disabled_color)
end
end
The first command is aligned "well" while the rest are all to the right like this:
(http://i.imgur.com/qhbZgMO.png)
You would need to make a new class extending Window_Selectable to achieve this effect, namely how the window draws the cursor selection rectangle. You'll also need to modify the 'update' method so that pressing left or right would change difficulties and only by pressing up or down would the cursor move to Go Back.
In my Advance Wars Engine, when viewing unit stats, I had to do something along the lines of
rect = case self.index
when 0 then Rect.new(0, 0, 100, 32)
when 1 then Rect.new(0, 32, 50, 32)
when 2 then Rect.new(0, 64, 50, 32)
when 3 then Rect.new(80, 32, 50, 32)
...
where the cursor location and size is determined based on the window's index variable.
Forgive me but I don't have any clue on how to do that myself so I might as well keep them in the same column. Is it possible instead of having an option to go back, pressing ESC would send you back to the title screen?
Also would you mind checking what is the problem in the script above? The cursor/text are not getting aligned properly.
Thanks
Quote from: Vexus on March 19, 2015, 02:31:40 pm
Is it possible instead of having an option to go back, pressing ESC would send you back to the title screen?
Going off the scene code that you provided:
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# If C button was pressed
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se) #<================== You should move your sound effect up here
# Branch by command window cursor position
case @command_window.index
when 0 # Easy Mode
command_easy_mode
when 1 # Normal Mode
command_normal_mode
when 2 # Hard Mode
command_hard_mode
end
elsif Input.trigger?(Input::B) #<================== Reads as "if the C button was not triggered but the B button was triggered"
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new #<==================== You don't need command_go_back anymore
end
end
As for the window, I think it was because it was drawing based of the window's width and not the window content's width.
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
width = self.contents.width - 32 #<============== only change I made
off = width / @item_max
x = 40 + index * off #4
self.contents.draw_text(x, 0, off - 32, 32, @commands[index]) #32, 32
end
The go back part works, thanks :)
The other thing however is not working even with that line changed. The text is still not aligning with the cursor itself. I have a feeling there's something wrong in the script itself not overwriting some other script correctly.
#--------------------------------------------------------------------------
# * Draw Item
# index : item number
#--------------------------------------------------------------------------
def draw_item(index)
off = self.width / @item_max
x = index * off
self.contents.draw_text(x, 0, off - 32, 32, @commands[index], 1) #32, 32
end
That....worked!
Thanks haha, adding a picture based on which option is being highlighted shouldn't be much trouble if I mimic the status window script you gave me.
Well, at least that's what I think.
[Edit]
Nope, I don't see how can I make it work.
Any help please?
In your scene class under
def main, you will want an instance variable that will hold your Sprite. Also set the coordinates.
@mode_sprite = Sprite.new
@mode_sprite.x, @mode_sprite.y = X_COORD, Y_COORD
And don't forget to dispose it too when changing scenes.
Moving onto the update method, it's the same procedure that I showed you before where you do something different based on the window's cursor index. You will want to change the sprite's bitmap based on the index value.
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update command window
@command_window.update
# Draw the sprite
@mode_sprite.bitmap = case @command_window.index
when 0 then RPG::Cache.picture("easymodepic")
when 1 then RPG::Cache.picture("normalmodepic")
when 2 then RPG::Cache.picture("hardmodepic")
end
# If C button was pressed
if Input.trigger?(Input::C)
$game_system.se_play($data_system.decision_se)
# Branch by command window cursor position
case @command_window.index
when 0 # Easy Mode
command_easy_mode
when 1 # Normal Mode
command_normal_mode
when 2 # Hard Mode
command_hard_mode
end
elsif Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
$scene = Scene_Title.new
end
end
Gonna check it tomorrow as i'm about to go to sleep.
Thanks
I was getting close-ish... sort of.
(http://i.imgur.com/BAAalcB.png)
Created a new bitmap and was going to try mimicking the same idea in the status screen.
[Edit]
I kept what I did so far plus added what you posted on the previous post and it works.
Thanks :)
Now, I either add text directly in the game based on the position of the cursor or make a picture with text in it and align only the picture.