Changed: PokemonMessages --- Left +++ Right @@ -144,6 +144,15 @@ module PokemonSkins + @defaultTextSkin=nil def self.getDefaultTextSkin - return MessageConfig::TextSkinName + textSkin=MessageConfig::TextSkinName + if textSkin==nil + if !@defaultTextSkin + skin=load_data("Data/System.rxdata").windowskin_name rescue nil + skin="../System/Window" if !skin + @defaultTextSkin=skin + end + return @defaultTextSkin + end end end @@ -389,4 +398,5 @@ if variableNumber && variableNumber>0 $game_variables[variableNumber]=ret + $game_map.refresh if $game_map end return ret @@ -460,4 +470,5 @@ end message=_MAPINTL($game_map.map_id,message) + @message_waiting=true if commands cmdlist=[] @@ -472,16 +483,21 @@ Kernel.pbMessage(message+messageend) end + @message_waiting=false return true end def command_102 - command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1]) - @branch[@list[@index].indent] = command - Input.update # Must call Input.update again to avoid extra triggers + @message_waiting=true + command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1]) + @message_waiting=false + @branch[@list[@index].indent] = command + Input.update # Must call Input.update again to avoid extra triggers return true end def command_103 varnumber=@list[@index].parameters[0] + @message_waiting=true $game_variables[varnumber]=Kernel.pbChooseNumberNew(nil,$game_variables[varnumber],@list[@index].parameters[1]) - Input.update # Must call Input.update again to avoid extra triggers + @message_waiting=false + Input.update # Must call Input.update again to avoid extra triggers return true end @@ -504,6 +520,8 @@ numInputDigitsMax=nil text="" + firstText=nil if @list[@index].parameters.length==1 text+=@list[@index].parameters[0] + firstText=@list[@index].parameters[0] text+=" " if text[text.length-1,1]!=" " message+=text @@ -546,4 +564,13 @@ @index=nextIndex elsif code == 101 + if @list[@index].parameters.length==1 + text=@list[@index].parameters[0] + if text[/^\\ignr/] && text==firstText + text+=" " if text[text.length-1,1]!=" " + message+=text + @index=nextIndex + continue + end + end messageend="\1" end @@ -551,4 +578,6 @@ end end + @message_waiting=true # needed to allow parallel process events to work while + # a message is displayed message=_MAPINTL($game_map.map_id,message) if commands @@ -564,8 +593,11 @@ Kernel.pbMessage(message+messageend,nil) end + @message_waiting=false return true end def command_102 + @message_waiting=true command=Kernel.pbShowCommands(nil,@list[@index].parameters[0],@list[@index].parameters[1]) + @message_waiting=false @branch[@list[@index].indent] = command Input.update # Must call Input.update again to avoid extra triggers @@ -574,6 +606,8 @@ def command_103 varnumber=@list[@index].parameters[0] + @message_waiting=true $game_variables[varnumber]=Kernel.pbChooseNumberNew(nil,$game_variables[varnumber],@list[@index].parameters[1]) - Input.update # Must call Input.update again to avoid extra triggers + @message_waiting=false + Input.update # Must call Input.update again to avoid extra triggers return true end @@ -936,25 +970,4 @@ end -def pbRepositionMessageWindow - if $game_temp && $game_temp.in_battle && - !$scene.respond_to?("update_basic") - msgwindow.y=0 - elsif $game_system && $game_system.respond_to?("message_position") - case $game_system.message_position - when 0 # up - msgwindow.y=0 - when 1 # middle - msgwindow.y=(Graphics.height/2)-(msgwindow.height/2) - when 2 - msgwindow.y=(Graphics.height)-(msgwindow.height) - end - end - if $game_system && $game_system.respond_to?("message_frame") - if $game_system.message_frame != 0 - msgwindow.opacity = 0 - end - end -end - def isDarkWindowskin(windowskin) if !windowskin || windowskin.disposed? @@ -969,7 +982,7 @@ clr=windowskin.get_pixel(x,y) r+=clr.red; g+=clr.green; b+=clr.blue - x+=16 + x+=8 } - y+=16 + y+=8 } r/=256 @@ -985,7 +998,7 @@ clr=windowskin.get_pixel(x,y) r+=clr.red; g+=clr.green; b+=clr.blue - x+=8 + x+=4 } - y+=8 + y+=4 } r/=256 @@ -1068,4 +1081,62 @@ end +# internal function +def pbRepositionMessageWindow(msgwindow, linecount=2) + msgwindow.height=32*linecount+msgwindow.borderY + msgwindow.y=(Graphics.height)-(msgwindow.height) + if $game_temp && $game_temp.in_battle && + !$scene.respond_to?("update_basic") + msgwindow.y=0 + elsif $game_system && $game_system.respond_to?("message_position") + case $game_system.message_position + when 0 # up + msgwindow.y=0 + when 1 # middle + msgwindow.y=(Graphics.height/2)-(msgwindow.height/2) + when 2 + msgwindow.y=(Graphics.height)-(msgwindow.height) + end + end + if $game_system && $game_system.respond_to?("message_frame") + if $game_system.message_frame != 0 + msgwindow.opacity = 0 + end + end + if $game_message + case $game_message.background + when 1 # dim + msgwindow.opacity=0 + when 2 # transparent + msgwindow.opacity=0 + end + end +end + +# internal function +def pbUpdateMsgWindowPos(msgwindow,event,eventChanged=false) + if event + if eventChanged + msgwindow.resizeToFit2(msgwindow.text, + Graphics.width*2/3,msgwindow.height) + end + msgwindow.y=event.screen_y-48-msgwindow.height + if msgwindow.y<0 + msgwindow.y=event.screen_y+24 + end + msgwindow.x=event.screen_x-(msgwindow.width/2) + msgwindow.x=0 if msgwindow.x<0 + if msgwindow.x>Graphics.width-msgwindow.width + msgwindow.x=Graphics.width-msgwindow.width + end + else + curwidth=msgwindow.width + if curwidth!=Graphics.width + msgwindow.width=Graphics.width + msgwindow.width=Graphics.width + end + end +end + +# internal function def pbDisplayGoldWindow(msgwindow) moneyString="" @@ -1092,4 +1163,61 @@ end +def pbBGMCommand(param) + return if !param + if param.is_a?(String) + if param!="" + if $game_system && $game_system.respond_to?("bgm_play") + $game_system.bgm_play(RPG::AudioFile.new(param)) + elsif (RPG.const_defined?(:BGM) rescue false) + RPG::BGM.new(param).play + end + end + elsif param.is_a?(RPG::AudioFile) + if $game_system && $game_system.respond_to?("bgm_play") + $game_system.bgm_play(param) + else + Audio.se_play("Audio/BGM/"+param.name,param.volume,param.pitch) + end + end +end + +def pbMECommand(param) + return if !param + if param.is_a?(String) + if param!="" + if $game_system && $game_system.respond_to?("me_play") + $game_system.me_play(RPG::AudioFile.new(param)) + elsif (RPG.const_defined?(:ME) rescue false) + RPG::ME.new(param).play + end + end + elsif param.is_a?(RPG::AudioFile) + if $game_system && $game_system.respond_to?("me_play") + $game_system.me_play(param) + else + Audio.se_play("Audio/ME/"+param.name,param.volume,param.pitch) + end + end +end + +def pbSECommand(param) + return if !param + if param.is_a?(String) + if param!="" + if $game_system && $game_system.respond_to?("se_play") + $game_system.se_play(RPG::AudioFile.new(param)) + elsif (RPG.const_defined?(:SE) rescue false) + RPG::SE.new(param).play + end + end + elsif param.is_a?(RPG::AudioFile) + if $game_system && $game_system.respond_to?("se_play") + $game_system.se_play(param) + else + Audio.se_play("Audio/SE/"+param.name,param.volume,param.pitch) + end + end +end + def pbRecord(arg); end @@ -1118,4 +1246,5 @@ linecount=(Graphics.height>400) ? 3 : 2 ### Text replacement + text.gsub!(/\\\\/,"\5") if $game_actors text.gsub!(/\\[Nn]\[([1-8])\]/){ @@ -1170,5 +1299,5 @@ textchunks.push(text) for chunk in textchunks - chunk.gsub!(/\\\\/,"\\") + chunk.gsub!(/\005/,"\\") end textlen=0 @@ -1191,5 +1320,5 @@ facewindow.dispose if facewindow facewindow=PictureWindow.new("Graphics/Pictures/#{param}") - elsif control=="se" && controls[i][2]==0 + elsif control=="se" && i==0 startSE=param controls[i]=nil @@ -1210,5 +1339,5 @@ end if startSE!=nil - $game_system.se_play(pbStringToAudioFile(startSE)) if startSE!="" + pbSECommand(pbStringToAudioFile(startSE)) elsif sound pbPlayDecisionSE() @@ -1216,35 +1345,10 @@ delay=0 if commands ########## Position message window ############## - msgwindow.height=32*linecount+msgwindow.borderY - msgwindow.y=(Graphics.height)-(msgwindow.height) - if $game_temp && $game_temp.in_battle && - !$scene.respond_to?("update_basic") - msgwindow.y=0 - elsif $game_system && $game_system.respond_to?("message_position") - case $game_system.message_position - when 0 # up - msgwindow.y=0 - when 1 # middle - msgwindow.y=(Graphics.height/2)-(msgwindow.height/2) - when 2 - msgwindow.y=(Graphics.height)-(msgwindow.height) - end + pbRepositionMessageWindow(msgwindow,linecount) + if $game_message && $game_message.background==1 + msgback=IconSprite.new(0,msgwindow.y,msgwindow.viewport) + msgback.z=msgwindow.z-1 + msgback.setBitmap("Graphics/System/MessageBack") end - if $game_system && $game_system.respond_to?("message_frame") - if $game_system.message_frame != 0 - msgwindow.opacity = 0 - end - end - if $game_message - case $game_message.background - when 1 # dim - msgwindow.opacity=0 - msgback=IconSprite.new(0,msgwindow.y,msgwindow.viewport) - msgback.z=msgwindow.z-1 - msgback.setBitmap("Graphics/System/MessageBack") - when 2 # transparent - msgwindow.opacity=0 - end - end if facewindow pbPositionNearMsgWindow(facewindow,msgwindow,:left) @@ -1310,7 +1414,7 @@ autoresume=true elsif control=="se" # Play SE - $game_system.se_play(pbStringToAudioFile(param)) if param!="" + pbSECommand(pbStringToAudioFile(param)) elsif control=="me" # Play ME - $game_system.me_play(pbStringToAudioFile(param)) if param!="" + pbMECommand(pbStringToAudioFile(param)) end controls[i]=nil Changed: SpriteWindow --- Left +++ Right @@ -4,6 +4,8 @@ module MessageConfig FontName="Power Green" - # in Graphics/Windowskins/ - TextSkinName="frlgtextskin" + # in Graphics/Windowskins/ (specify nil to use + # the default windowskin) + TextSkinName=nil + #TextSkinName="001-Blue01" # full path to file ChoiceSkinName="skin1" @@ -233,5 +235,5 @@ return false end - def self.getPath?(filename,extensions=[]) + def self.getPath(filename,extensions=[]) return filename if !filename || filename=="" eachPath {|path| @@ -544,4 +546,28 @@ $PokemonSystem.textspeed=speed if $PokemonSystem end + + +######################## +######################## + +def pbStringToAudioFile(str) + # Converts a string to an audio file. Possible formats: + # filename volume and pitch 100 + # filename:volume pitch 100 + # filename:volume:pitch + if str[/^(.*)\:\s*(\d+)\s*\:\s*(\d+)\s*$/] + file=$1 + volume=$2.to_i + pitch=$3.to_i + return RPG::AudioFile.new(file,volume,pitch) + elsif str[/^(.*)\:\s*(\d+)\s*$/] + file=$1 + volume=$2.to_i + return RPG::AudioFile.new(file,volume,100) + else + return RPG::AudioFile.new(str,100,100) + end +end + def pbPlayDecisionSE() if $data_system && $data_system.respond_to?("decision_se") && @@ -2683,4 +2709,5 @@ def textspeed=(value) @frameskip=value + @frameskipChanged=true end def setText(value) @@ -2828,4 +2855,5 @@ @lastDrawnChar=-1 @fmtchars=[] + @frameskipChanged=false @frameskip=[3,2,1,-2][pbGetSystemTextSpeed] super(0,0,33,33) @@ -2880,5 +2908,5 @@ self.height=[dims[1]+self.borderY,maxheight].min @starting=oldstarting - self.text=self.text + redrawText end def resizeToFit(text,maxwidth=-1) @@ -2889,5 +2917,5 @@ self.height=dims[1]+self.borderY @starting=oldstarting - self.text=self.text + redrawText end def resizeHeightToFit(text,width=-1) @@ -2898,5 +2926,5 @@ self.height=dims[1]+self.borderY @starting=oldstarting - self.text=self.text + redrawText end def refresh @@ -2962,11 +2990,18 @@ end end - def update - super - if @pausesprite && @pausesprite.visible - @pausesprite.update + def redrawText + if !@letterbyletter + self.text=self.text + else + oldPosition=self.position + self.text=self.text + oldPosition=@numtextchars if oldPosition>@numtextchars + while self.position!=oldPosition + refresh + updateInternal + end end - if busy? - refresh + end + def updateInternal curcharskip=@frameskip<0 ? @frameskip.abs : 1 visiblelines=(self.height-self.borderY)/32 @@ -3019,5 +3054,16 @@ @linesdrawn=0 end + end + def update + super + if @pausesprite && @pausesprite.visible + @pausesprite.update end + if busy? + refresh if !@frameskipChanged + updateInternal + refresh if @frameskipChanged # needed to allow "textspeed=-999" to work seamlessly + end + @frameskipChanged=false end def allocPause Changed: DrawText --- Left +++ Right @@ -143,9 +143,14 @@ color=RgbToColor(param) shadow=nil - isdark=(color.red*0.299+color.green*0.587+color.blue*0.114) < 128 - if isdark - shadow=Color.new(color.red+64,color.green+64,color.blue+64) - else - shadow=Color.new(color.red-64,color.green-64,color.blue-64) + maxval=[color.red,color.green,color.blue].max + minval=[color.red,color.green,color.blue].min + lightness=(maxval+minval)/510 + if lightness<=112.0 # brighten + r=color.red+(255-color.red)/2 + g=color.green+(255-color.green)/2 + b=color.blue+(255-color.blue)/2 + shadow=Color.new(r,g,b,color.alpha) + else # darken + shadow=Color.new(color.red/2,color.green/2,color.blue/2,color.alpha) end return shadowctag(color,shadow) @@ -154,9 +159,14 @@ def shadowctagFromColor(color) shadow=nil - isdark=(color.red*0.299+color.green*0.587+color.blue*0.114) < 128 - if isdark - shadow=Color.new(color.red+64,color.green+64,color.blue+64) - else - shadow=Color.new(color.red-64,color.green-64,color.blue-64) + maxval=[color.red,color.green,color.blue].max + minval=[color.red,color.green,color.blue].min + lightness=(maxval+minval)/510 + if lightness<=112.0 # brighten + r=color.red+(255-color.red)/2 + g=color.green+(255-color.green)/2 + b=color.blue+(255-color.blue)/2 + shadow=Color.new(r,g,b,color.alpha) + else # darken + shadow=Color.new(color.red/2,color.green/2,color.blue/2,color.alpha) end return shadowctag(color,shadow) @@ -225,4 +235,6 @@ after the text. - Displays the icon X (in Graphics/Icons/). +Added 2009-9-12 + - Displays the text in the given opacity (0-255) In addition, the syntax supports the following: ' - Converted to "'". @@ -241,5 +253,5 @@ end -FORMATREGEXP=/<(\/?)([Cc]|[Cc][2]|[Ff][Nn]|[Bb][Rr]|[Ff][Ss]|[Ii]|[Bb]|[Uu]|[Ss]|[Ii][Cc][Oo][Nn]|[Ii][Mm][Gg]|[Aa][Cc]|[Aa][Rr]|[Aa][Ll]|[Rr])(\s*\=\s*([^>]*))?>/ +FORMATREGEXP=/<(\/?)([Cc]|[Cc][2]|[Oo]|[Ff][Nn]|[Bb][Rr]|[Ff][Ss]|[Ii]|[Bb]|[Uu]|[Ss]|[Ii][Cc][Oo][Nn]|[Ii][Mm][Gg]|[Aa][Cc]|[Aa][Rr]|[Aa][Ll]|[Rr])(\s*\=\s*([^>]*))?>/ def toUnformattedText(text) @@ -506,4 +518,5 @@ strikecount=0 rightalign=0 + opacitystack=[] oldfont=bitmap.font.clone defaultfontname=bitmap.font.name.clone @@ -552,4 +565,7 @@ colorstack.push([base,shadow]) end + elsif control=="o" + opacitystack.pop if endtag + opacitystack.push(param.sub(/\s+$/,"").to_i) if !endtag elsif control=="b" boldcount-=1 if endtag @@ -708,4 +724,12 @@ texty=(lineheight*y)+yDst+yStart colors=getLastParam(colorstack,defaultcolors) + opacity=getLastParam(opacitystack,255) + if opacity!=255 + colors=[ + Color.new(colors[0].red,colors[0].green,colors[0].blue, + colors[0].alpha*opacity/255), + colors[1] ? Color.new(colors[1].red,colors[1].green,colors[1].blue, + colors[1].alpha*opacity/255) : nil] + end oldx=x # Push character, textx will be calculated later Changed: PokemonUtilities --- Left +++ Right @@ -118,5 +118,4 @@ return ret end - def modulus(x,y) return x-(x/y).floor*y @@ -271,22 +270,4 @@ end -def pbStringToAudioFile(str) - # Converts a string to an audio file. Possible formats: - # filename volume and pitch 100 - # filename:volume pitch 100 - # filename:volume:pitch - if str[/^(.*)\:\s*(\d+)\s*\:\s*(\d+)\s*$/] - file=$1 - volume=$2.to_i - pitch=$3.to_i - return RPG::AudioFile.new(file,volume,pitch) - elsif str[/^(.*)\:\s*(\d+)\s*$/] - file=$1 - volume=$2.to_i - return RPG::AudioFile.new(file,volume,100) - else - return RPG::AudioFile.new(str,100,100) - end -end def pbIsWeekday(wdayVariable,*arg) @@ -321,9 +302,5 @@ def hasConst?(mod,constant) - begin - return mod.const_defined?(constant.to_sym) - rescue - return false - end + return mod.const_defined?(constant.to_sym) rescue false end Changed: PokemonAnimEditor --- Left +++ Right @@ -1829,4 +1829,7 @@ mouse[1]>=self.y&&mouse[1]canvas.animation.length @@ -2009,5 +2017,5 @@ newtext=sprintf("(%d,%d)",mouse[0],mouse[1]) if window.text!=newtext - window.text=nextext + window.text=newtext end if curve[0].visible && curve[3].visible && @@ -2030,5 +2038,5 @@ t=0.0 for i in 0...points.length - point=getCubicPoint(curve,t) + point=getCurvePoint(curve,t) points[i].x=point[0] points[i].y=point[1] @@ -2044,6 +2052,6 @@ points.clear if showline - path=cubicCurveToPointPath(curve,sliderwin2.value(0)) - File.open("pointpath.txt","wb"){|f| f.write(path.inspect) } + path=curveToPointPath(curve,sliderwin2.value(0)) + #File.open("pointpath.txt","wb"){|f| f.write(path.inspect) } for point in path points.push(PointSprite.new(point[0],point[1],canvas.viewport)) @@ -2103,5 +2111,5 @@ points.push(PointSprite.new(point[0],point[1],canvas.viewport)) end - File.open("pointpath.txt","wb"){|f| f.write(path.inspect) } + #File.open("pointpath.txt","wb"){|f| f.write(path.inspect) } sliderwin2.visible=true next Changed: Compiler --- Left +++ Right @@ -3234,5 +3234,5 @@ text+="\r\n" extraText=event.pages[1].list[j].parameters[0] - text+=extraText if extraText + text+=extraText if extraText && extraText.is_a?(String) j+=1 end Changed: EventScene --- Left +++ Right @@ -1,27 +1,4 @@ -def getCubicPoint(src,t) - x0=src[0].x; - y0=src[0].y; - cx0=src[1].x; - cy0=src[1].y; - cx1=src[2].x; - cy1=src[2].y; - x1=src[3].x; - y1=src[3].y; - x1=cx1+(x1-cx1)*t; - y1=cy1+(y1-cy1)*t; - x0=x0+(cx0-x0)*t; - y0=y0+(cy0-y0)*t; - cx0=cx0+(cx1-cx0)*t; - cy0=cy0+(cy1-cy0)*t; - cx1=cx0+(x1-cx0)*t; - cy1=cy0+(y1-cy0)*t; - cx0=x0+(cx0-x0)*t; - cy0=y0+(cy0-y0)*t; - cx=cx0+(cx1-cx0)*t; - cy=cy0+(cy1-cy0)*t; - return [cx,cy] -end def getCubicPoint2(src,t) Changed: BitmapCache --- Left +++ Right @@ -396,5 +396,5 @@ end def self.tile(filename, tile_id, hue) - return self.tileEx(filename, tile_id,hue) {|f| self.tileset(f,0,true) } + return self.tileEx(filename, tile_id,hue) {|f| self.tileset(f) } end def self.clear