Oh no, I made another script!
Fullscreen Choices
Version: 2.1a
Author: Welfare-Daddy Pacman
Date: 20/4/2011
Version History
- <Version 1.0> 11.04.2011 - Original Release
- <Version 2.0> 19.04.2011 - Revamped script: added more customization, fixed layout and moved main processing out of class declaration.
- <Version 2.0a> 19.04.2011 - Script works now. Doi.
- <Version 2.1> 19.04.2011 - Got rid of the scene in the battle test.
- <Version 2.1a> 20.04.2011 - Made script more efficient by making it inherit from Scene_Title instead of Scene_Base, allowing the battle test to run smoother.
Planned Future Versions
- Version 2.5 - Putting music into the choice scene.
Description
This script is a rewrite of Main. Do not put it in Materials. Replace Main with this script. This script simply puts a choice of playing windowed or full-screened or simply quitting the game before the title screen shows.
Features
Screenshots
Hardly necessary.
Instructions
Follow the instructions in the script to the letter.
Script
[spoiler=Code]
=begin
================================================================================
Author: Welfare-Daddy Pacman (rmrk.net)
Based from Mr. Wiggles
Version 2.0
Last update: 19/4/2011
Description:
This script simply puts a choice of playing windowed or full-screened or
simply quitting the game before the title screen shows.
Instructions:
-Replace Main with this script. Plug-and-play, unless you want to configure
some stuff.
-Configuration begins at line 17 and ends at line 35.
================================================================================
=end
#-------------------------------------------------------------------------------
# BEGIN EDITING SECTION
#-------------------------------------------------------------------------------
SKIP_TOGGLE = false # This will skip the toggle if you have a save slot.
COMMAND_OPACITY = 160 # Change this value to the opacity you want.
INPUT_KEY = Input::C # This is the key used to confirm the command prompt.
QUIT_KEY = Input::B # This is the key used to quit the command prompt.
SCENE = Scene_Title.new # The scene that is after or before Scene_Screenchoice.
FULLSCREENTEXT = "Full-screen" # The text displayed on the full-screen option.
WINDOWEDTEXT = "Windowed" # The text displayed on the windowed option.
QUITTEXT = "Quit" # The text displayed on the quit option.
WINDOWX = 272 # The x placement of the command window.
WINDOWY = 208 # The y placement of the command window.
WINDOWWIDTH = 192 # The width of the window. Alter this to accommodate
# for large option texts.
#-------------------------------------------------------------------------------
# END EDITING SECTION A
#-------------------------------------------------------------------------------
# Start Scene_Screenchoice
#-------------------------------------------------------------------------------
class Scene_Screenchoice < Scene_Title
def main
if $BTEST # If battle test
battle_test # Run battle test
else
@title = Scene_Title.new
@title.load_database
s1 = FULLSCREENTEXT # Check FULLSCREENTEXT
s2 = WINDOWEDTEXT # Check WINDOWEDTEXT
s3 = QUITTEXT # Check QUITTEXT
@command_window = Window_Command.new(WINDOWWIDTH, [s1, s2, s3]) # Create
@command_window.opacity = COMMAND_OPACITY # Check opacity
@command_window.x = WINDOWX - @command_window.width / 2 # Check X
@command_window.y = WINDOWY - @command_window.height / 2 # Check Y
Graphics.transition # Transition
loop do # Loop
Graphics.update # Update graphics
Input.update # Update input
update # Duh.
if $scene != self # If scene isn't self
break # Stop updating
end
end
Graphics.freeze # Freeze Graphics
@command_window.dispose # Dispose command window
end
end
#-------------------------------------------------------------------------------
# Update
#-------------------------------------------------------------------------------
def update
@command_window.update
if Input.trigger?(INPUT_KEY)
case @command_window.index
when 0
Sound.play_decision
unless $keybd
call_fullscreen
end
call_scene_title
when 1
Sound.play_decision
call_scene_title
when 2
close_window
end
end
if Input.trigger?(QUIT_KEY)
close_window
end
end
#-------------------------------------------------------------------------------
# Call Scene_Title
#-------------------------------------------------------------------------------
def call_scene_title
$scene = Scene_Title.new
end
#-------------------------------------------------------------------------------
# Call Fullscreen
#-------------------------------------------------------------------------------
def call_fullscreen
$keybd = Win32API.new 'user32.dll', 'keybd_event', ['i', 'i', 'l', 'l'], 'v'
$keybd.call 0xA4, 0, 0, 0
$keybd.call 13, 0, 0, 0
$keybd.call 13, 0, 2, 0
$keybd.call 0xA4, 0, 2, 0
end
#-------------------------------------------------------------------------------
# Close Window
#-------------------------------------------------------------------------------
def close_window
Sound.play_decision
RPG::BGM.fade(800)
RPG::BGS.fade(800)
RPG::ME.fade(800)
$scene = nil
end
end
#-------------------------------------------------------------------------------
# Main Processing
#-------------------------------------------------------------------------------
begin
Graphics.freeze
if SKIP_TOGGLE and (Dir.glob('Save*.rvdata').size > 0)
$scene = SCENE
else
$scene = Scene_Screenchoice.new
end
while $scene != nil
$scene.main
end
Graphics.transition(20)
rescue Errno::ENOENT
filename = $!.message.sub("No such file or directory - ", "")
print("Unable to find file #{filename}.")
end
#-------------------------------------------------------------------------------
# END
#-------------------------------------------------------------------------------
[/spoiler]
Credit
- Welfare-Daddy Pacman
- Mr. Wiggles
Thanks
- Mr. Wiggles for the original script.
- Modern Algebra for his help with scripting (and being awesome).
- LoganForrests for the same reason. :P
- Zeriab for improving suggestions.
Support
I'm on RMRK a lot. Just post here or PM me.
Known Compatibility Issues
Will probably not work with debug scripts that refer to main.
Demo
Not applicable.
Author's Notes
Free for use in commercial and non-commercial games with credit. If you are using it in a commercial game, let me know.
Restrictions
Eh. Don't take credit for mine or Mr. Wiggles work.
:ccbysa: :rmvx:
For indie games. :nespad:
I have three suggestions:
- Include the load_database method in Scene_Title
- Move the main loop out of the class declaration
- Fix up the indention
*hugs*
Yeah, I probably should've paid more attention to that stuff. However, I'm working on another script at the moment, and I'm a little swamped with other stuff. Also, I have a tingly feeling in my heart because you posted here. I feel special.
How could I forget to include the load_database method? Doi. Not quite sure what that second one means though...
Thanks for the suggestions!
EDIT: Don't really see the point of load_database in the script if it is made in Scene_Title, but I'll do it anyway.
Oh, nvm about the load_database method. I thought you wrote an rmxp script as Scene_ScreenChoice doesn't inherit from Scene_Base.
Your improper indentions does sorta hide my second bullet point.
Anyway your class is structured a bit like this:
class Scene_ScreenChoice < Scene_Base
# ...
begin
# main loop
end
end
I suggest moving the main loop out of the class declaration. I.e.
class Scene_ScreenChoice < Scene_Base
# ...
end
begin
# main loop
end
*hugs*
Alrighty, I'll give that a shot.
At the moment, however, I'm working on putting music into the scene. I've never dealt with operating BGMs in script before, only terminating them. As a result, I don't know how to do it and I can't recall any scripts I could 'study' to get the function from.
Another thing I'm doing is to get rid of the window before battle tests, as it's just annoying. That shouldn't be difficult at all though.
I'll fix my indentation for you though (do you mean to put it all as far left as possible or that there's something wrong with the way it's put out?)
Major update!
Done a lot of stuff to the script, namely:
- Fixed layout of script
- Added much more customization
- Moved main processing out of class declaration
The music is yet to come.
EDIT: I screwed up, don't use that version! I will fix it in several minutes. The full-screen function will not work with this script!
EDIT EDIT: Works now.
Oh my good golly gosh, so many updates today!
I've taken out the scene in the battle test. It was really annoying, and it added some girth to my script that brought it closer to my 200 line goal. :P
More updates!
I've updated this to 2.1a, allowing for quicker running by changing the inheritance from Scene_Base to Scene_Title, letting the battle test run smoother and the script to run faster.
Good work. Your script looks much better now ^_^
Since your scene inherits from Scene_Title there should be no need to create a new Scene_Title.
@title = Scene_Title.new
@title.load_database
That could just probably just be changed into: load_database
Consider storing the wanted fullscreen option in the game.ini file. I have made a wrapper which does the Win32APi calls for you: http://pastebin.com/KZyTS6cB
You can then write the setting to the ini file like this:
Utility.write_ini('Fullscreen', '1') # Fullscreen mode on
Utility.write_ini('Fullscreen', '0') # Fullscreen mode off
To read from the ini file you can use something like this:
if Utility.read_ini('Fullscreen') == '1'
# Turn fullscreen on automatically and continue
elsif Utility.read_ini('Fullscreen') == '0'
# Continue in windowed mode
else
# Fullscreen setting has not been set. Ask the player
end
*hugs*
Dear lord that's helpful.
I was worrying a bit because if you boot the game up in full-screen and select windowed, it stays in fullscreen because I didn't write to put the game in windowed, just to start the scene.
Also thanks for that title pointout. Doesn't really change much, but it gets rid of a line and a half :P
I'll take a crack at that right now.
And thanks for dropping by on my CP thread.
EDIT: Works great Zeriab! Everything is functioning perfectly.
Awesome!
*adds to game*
Just out of curiosity, but why is the keyboard handle a global variable? If its to be used throughout a game, that's perfectly fine, but in this case its merely being called once when the game starts, so why not make it a local variable?
Kinda glad you asked, Zer0. Yes, it's intended for people to be able to use it through other means. But you are quite right, and you know my hatred toward unneeded globals. And configuration data defined outside of a module. How dare I?!
This is in need of an update.
This is a neat script :D I'm going to use this (b'.')b
EDIT: I selected full-screen and itwindowed my game :(
As I said, this script needs an update. I'm busy beyond reason today, but I'll see what I can do tomorrow.
probably long past by now, but couldn't you always study on of the auto scripts in the game for the music thing... im sure its in there somewhere otherwise music wouldn't play in the game at all.
I overcame problems like that many months ago. I simply haven't redone this script.
Great script mate , now that RMVX-Ace is out will you be making a new version that is compatible with RMVX-Ace?
I have a draft for one. It has the same problem as this one; if the game is in fullscreen and you select windowed, it remains in fullscreen.
That said, you could probably easily fix this by making F12 exit instead of restart. Would you like me to post it?