Aamelo
Reality Bender.
- 49
- Posts
- 14
- Years
- Age 28
- Lisbon, Portugal
- Seen Aug 15, 2016
Couldn't find anything odd about the pre-defined options, maybe was the language or something. Else, it was my fault for using V4 Options in V9...
Heres the script:
Heres the script:
Spoiler:
Code:
class Window_PokemonOption < Window_DrawableCommand
attr_reader :mustUpdateOptions
def initialize(options,x,y,width,height)
@options=options
@nameBaseColor=Color.new(162,206,255)
@nameShadowColor=Color.new(0,71,151)
@selBaseColor=Color.new(99,173,253)
@selShadowColor=Color.new(0,45,96)
@optvalues=[]
@mustUpdateOptions=false
for i in [email protected]
@optvalues[i]=0
end
super(x,y,width,height)
end
def [](i)
return @optvalues[i]
end
def []=(i,value)
@optvalues[i]=value
refresh
end
def itemCount
return @options.length+1
end
def drawItem(index,count,rect)
rect=drawCursor(index,rect)
optionname=([email protected]) ? _INTL("Cancel") : @options[index].name
optionwidth=(rect.width*9/20)
pbDrawShadowText(self.contents,rect.x,rect.y,optionwidth,rect.height,optionname,
@nameBaseColor,@nameShadowColor)
self.contents.draw_text(rect.x,rect.y,optionwidth,rect.height,optionname)
return if [email protected]
if @options[index].is_a?(EnumOption)
if @options[index].values.length>1
totalwidth=0
for value in @options[index].values
totalwidth+=self.contents.text_size(value).width
end
spacing=(optionwidth-totalwidth)/(@options[index].values.length-1)
spacing=0 if spacing<0
xpos=optionwidth+rect.x
ivalue=0
for value in @options[index].values
pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value,
(ivalue==self[index]) ? @selBaseColor : self.baseColor,
(ivalue==self[index]) ? @selShadowColor : self.shadowColor
)
self.contents.draw_text(xpos,rect.y,optionwidth,rect.height,value)
xpos+=self.contents.text_size(value).width
xpos+=spacing
ivalue+=1
end
else
pbDrawShadowText(self.contents,rect.x+optionwidth,rect.y,optionwidth,rect.height,
optionname,self.baseColor,self.shadowColor)
end
elsif @options[index].is_a?(NumberOption)
value=_ISPRINTF("{1:d}",@options[index].optstart+self[index])
xpos=optionwidth+rect.x
pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value,
@selBaseColor,@selShadowColor)
else
value=@options[index].values[self[index]]
xpos=optionwidth+rect.x
pbDrawShadowText(self.contents,xpos,rect.y,optionwidth,rect.height,value,
@selBaseColor,@selShadowColor)
self.contents.draw_text(xpos,rect.y,optionwidth,rect.height,value)
end
end
def update
dorefresh=false
oldindex=self.index
@mustUpdateOptions=false
super
dorefresh=self.index!=oldindex
if self.active && self.index<@options.length
if Input.repeat?(Input::LEFT)
self[self.index]=@options[self.index].prev(self[self.index])
dorefresh=true
@mustUpdateOptions=true
elsif Input.repeat?(Input::RIGHT)
self[self.index]=@options[self.index].next(self[self.index])
dorefresh=true
@mustUpdateOptions=true
end
end
refresh if dorefresh
end
end
module PropertyMixin
def get
@getProc ? @getProc.call() : nil
end
def set(value)
@setProc.call(value) if @setProc
end
end
class EnumOption
include PropertyMixin
attr_reader :values
attr_reader :name
def initialize(name,options,getProc,setProc)
@values=options
@name=name
@getProc=getProc
@setProc=setProc
end
def next(current)
index=current+1
[email protected] if index>@values.length-1
return index
end
def prev(current)
index=current-1
index=0 if index<0
return index
end
end
class EnumOption2
include PropertyMixin
attr_reader :values
attr_reader :name
def initialize(name,options,getProc,setProc)
@values=options
@name=name
@getProc=getProc
@setProc=setProc
end
def next(current)
index=current+1
[email protected] if index>@values.length-1
return index
end
def prev(current)
index=current-1
index=0 if index<0
return index
end
end
class NumberOption
include PropertyMixin
attr_reader :name
attr_reader :optstart
def initialize(name,format,optstart,optend,getProc,setProc)
@name=name
@format=format
@optstart=optstart
@optend=optend
@getProc=getProc
@setProc=setProc
end
def next(current)
index=current+@optstart
index+=1
if index>@optend
index=@optstart
end
return index-@optstart
end
def prev(current)
index=current+@optstart
index-=1
if index<@optstart
index=@optend
end
return index-@optstart
end
end
#####################
#
# Stores game options
#
$SpeechFrames=[
MessageConfig::TextSkinName, # Default text skin
]
$TextFrames=[
"Graphics/Windowskins/"+MessageConfig::ChoiceSkinName,
]
$VersionStyles=[
[MessageConfig::FontName], # Default font style
["Power Red and Blue"],
["Power Red and Green"],
["Power Clear"],
["Power Red and Blue Intl"]
]
def pbSettingToTextSpeed(speed)
return 3 if speed==0
return 2 if speed==1
return 1 if speed==2
return -2 if speed==3
return MessageConfig::TextSpeed if MessageConfig::TextSpeed
return ((Graphics.frame_rate>40) ? -2 : 1)
end
module MessageConfig
def self.pbDefaultSystemFrame
if !$PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/"+MessageConfig::ChoiceSkinName)||""
else
return pbResolveBitmap($TextFrames[$PokemonSystem.frame])||""
end
end
def self.pbDefaultSpeechFrame
if !$PokemonSystem
return pbResolveBitmap("Graphics/Windowskins/"+MessageConfig::TextSkinName)||""
else
return pbResolveBitmap("Graphics/Windowskins/"+$SpeechFrames[$PokemonSystem.textskin])||""
end
end
def self.pbDefaultSystemFontName
if !$PokemonSystem
return MessageConfig.pbTryFonts(MessageConfig::FontName,"Arial Narrow","Arial")
else
return MessageConfig.pbTryFonts($VersionStyles[$PokemonSystem.font][0],"Arial Narrow","Arial")
end
end
def self.pbDefaultTextSpeed
return pbSettingToTextSpeed($PokemonSystem ? $PokemonSystem.textspeed : nil)
end
def pbGetSystemTextSpeed
return $PokemonSystem ? $PokemonSystem.textspeed : ((Graphics.frame_rate>40) ? 2 : 3)
end
end
class PokemonSystem
attr_accessor :textspeed
attr_accessor :battlestyle
attr_accessor :frame
attr_accessor :font
attr_accessor :screensize
attr_accessor :battlescene
attr_accessor :tilemap
attr_accessor :textskin
attr_accessor :language
def language
return (!@language) ? 0 : @language
end
def textskin
return (!@textskin) ? 0 : @textskin
end
def initialize
@battlestyle = 0 # Battle style (0=shift, 1=set)
@battlescene = 0 # Battle scene (animations) (0=on, 1=off)
@textspeed = 2 # Text speed (0=slow, 1=mid, 2=fast)
@font = 0 # Font (see also $VersionStyles)
@language = 0 # Language (see also LANGUAGES in script PokemonSystem)
end
end
class PokemonOptionScene
def pbUpdate
pbUpdateSpriteHash(@sprites)
end
def pbStartScene
@sprites={}
@viewport=Viewport.new(0,0,Graphics.width,Graphics.height)
@viewport.z=99999
@sprites["title"]=Window_UnformattedTextPokemon.newWithSize(
_INTL("Options"),0,0,Graphics.width,64,@viewport)
# These are the different options in the game. To add an option, define a
# setter and a getter for that option. To delete an option, comment it out
# or delete it. The game's options may be placed in any order.
@PokemonOptions=[
EnumOption.new(_INTL("Text Speed"),[_INTL("Slow"),_INTL("Mid"),_INTL("Fast")],
proc { $PokemonSystem.textspeed }, # Getter
proc {|value|
$PokemonSystem.textspeed=value
MessageConfig.pbSetTextSpeed(pbSettingToTextSpeed(value))
} # Setter
),
EnumOption.new(_INTL("Battle Scene"),[_INTL("On"),_INTL("Off")],
proc { $PokemonSystem.battlescene },
proc {|value| $PokemonSystem.battlescene=value }
),
EnumOption.new(_INTL("Battle Style"),[_INTL("Shift"),_INTL("Set")],
proc { $PokemonSystem.battlestyle },
proc {|value| $PokemonSystem.battlestyle=value }
),
EnumOption.new(_INTL("Font Style"),[_INTL("Em"),_INTL("R/S"),_INTL("FRLG"),_INTL("DP")],
proc { $PokemonSystem.font },
proc {|value|
$PokemonSystem.font=value
MessageConfig.pbSetSystemFontName($VersionStyles[value])
}
),
# Quote this section out if you don't want to allow players to change the screen
# size.
# EnumOption2.new(_INTL("Screen Size"),[_INTL("240x160"),_INTL("480x320"),_INTL("320x240"),_INTL("640x480")],
# proc { $PokemonSystem.screensize },
# proc {|value|
# oldvalue=$PokemonSystem.screensize
# $PokemonSystem.screensize=value
# $ResizeOffsetX=[0,0,80,80][value]
# $ResizeOffsetY=[0,0,80,80][value]
# pbSetResizeFactor([0.5,1.0,0.5,1.0][value])
# if value!=oldvalue
# ObjectSpace.each_object(TilemapLoader){|o| next if o.disposed?; o.updateClass }
# end
# }
# ),
# ------------------------------------------------------------------------------
]
@sprites["option"]=Window_PokemonOption.new(@PokemonOptions,0,
@sprites["title"].height,Graphics.width,
Graphics.height-@sprites["title"].height)
@sprites["option"].viewport=@viewport
@sprites["option"].visible=true
# Get the values of each option
for i in [email protected]
@sprites["option"][i]=(@PokemonOptions[i].get || 0)
end
pbDeactivateWindows(@sprites)
pbFadeInAndShow(@sprites) { pbUpdate }
end
def pbOptions
pbActivateWindow(@sprites,"option"){
loop do
Graphics.update
Input.update
pbUpdate
if @sprites["option"].mustUpdateOptions
# Set the values of each option
for i in [email protected]
@PokemonOptions[i].set(@sprites["option"][i])
end
end
if Input.trigger?(Input::B)
break
end
if Input.trigger?(Input::C) && @sprites["option"][email protected]
break
end
end
}
end
def pbEndScene
pbFadeOutAndHide(@sprites) { pbUpdate }
# Set the values of each option
for i in [email protected]
@PokemonOptions[i].set(@sprites["option"][i])
end
pbDisposeSpriteHash(@sprites)
pbRefreshSceneMap
@viewport.dispose
end
end
class PokemonOption
def initialize(scene)
@scene=scene
end
def pbStartScreen
@scene.pbStartScene
@scene.pbOptions
@scene.pbEndScene
end
end