mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Rearranged some script files
This commit is contained in:
@@ -62,10 +62,12 @@ end
|
|||||||
#####################################
|
#####################################
|
||||||
# Works around a problem with FileTest.exist
|
# Works around a problem with FileTest.exist
|
||||||
# if directory contains accent marks
|
# if directory contains accent marks
|
||||||
def safeExists?(f)
|
if !defined?(safeExists?)
|
||||||
ret=false
|
def safeExists?(f)
|
||||||
File.open(f,"rb") { ret=true } rescue nil
|
ret=false
|
||||||
return ret
|
File.open(f,"rb") { ret=true } rescue nil
|
||||||
|
return ret
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -1,3 +1,42 @@
|
|||||||
|
class PictureOrigin
|
||||||
|
TopLeft = 0
|
||||||
|
Center = 1
|
||||||
|
TopRight = 2
|
||||||
|
BottomLeft = 3
|
||||||
|
LowerLeft = 3
|
||||||
|
BottomRight = 4
|
||||||
|
LowerRight = 4
|
||||||
|
Top = 5
|
||||||
|
Bottom = 6
|
||||||
|
Left = 7
|
||||||
|
Right = 8
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
class Processes
|
||||||
|
XY = 0
|
||||||
|
DeltaXY = 1
|
||||||
|
Z = 2
|
||||||
|
Curve = 3
|
||||||
|
Zoom = 4
|
||||||
|
Angle = 5
|
||||||
|
Tone = 6
|
||||||
|
Color = 7
|
||||||
|
Hue = 8
|
||||||
|
Opacity = 9
|
||||||
|
Visible = 10
|
||||||
|
BlendType = 11
|
||||||
|
SE = 12
|
||||||
|
Name = 13
|
||||||
|
Origin = 14
|
||||||
|
Src = 15
|
||||||
|
SrcSize = 16
|
||||||
|
CropBottom = 17
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def getCubicPoint2(src,t)
|
def getCubicPoint2(src,t)
|
||||||
x0 = src[0]; y0 = src[1]
|
x0 = src[0]; y0 = src[1]
|
||||||
cx0 = src[2]; cy0 = src[3]
|
cx0 = src[2]; cy0 = src[3]
|
||||||
@@ -31,29 +70,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Processes
|
#===============================================================================
|
||||||
XY = 0
|
# PictureEx
|
||||||
DeltaXY = 1
|
#===============================================================================
|
||||||
Z = 2
|
|
||||||
Curve = 3
|
|
||||||
Zoom = 4
|
|
||||||
Angle = 5
|
|
||||||
Tone = 6
|
|
||||||
Color = 7
|
|
||||||
Hue = 8
|
|
||||||
Opacity = 9
|
|
||||||
Visible = 10
|
|
||||||
BlendType = 11
|
|
||||||
SE = 12
|
|
||||||
Name = 13
|
|
||||||
Origin = 14
|
|
||||||
Src = 15
|
|
||||||
SrcSize = 16
|
|
||||||
CropBottom = 17
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PictureEx
|
class PictureEx
|
||||||
attr_accessor :x # x-coordinate
|
attr_accessor :x # x-coordinate
|
||||||
attr_accessor :y # y-coordinate
|
attr_accessor :y # y-coordinate
|
||||||
@@ -429,6 +448,9 @@ end
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
def setPictureSprite(sprite, picture, iconSprite=false)
|
def setPictureSprite(sprite, picture, iconSprite=false)
|
||||||
return if picture.frameUpdates.length==0
|
return if picture.frameUpdates.length==0
|
||||||
for i in 0...picture.frameUpdates.length
|
for i in 0...picture.frameUpdates.length
|
||||||
@@ -495,215 +517,3 @@ end
|
|||||||
def setPictureIconSprite(sprite, picture)
|
def setPictureIconSprite(sprite, picture)
|
||||||
setPictureSprite(sprite,picture,true)
|
setPictureSprite(sprite,picture,true)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PictureOrigin
|
|
||||||
TopLeft = 0
|
|
||||||
Center = 1
|
|
||||||
TopRight = 2
|
|
||||||
BottomLeft = 3
|
|
||||||
LowerLeft = 3
|
|
||||||
BottomRight = 4
|
|
||||||
LowerRight = 4
|
|
||||||
Top = 5
|
|
||||||
Bottom = 6
|
|
||||||
Left = 7
|
|
||||||
Right = 8
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pbTextBitmap(text, maxwidth=Graphics.width)
|
|
||||||
dims = []
|
|
||||||
tmp = Bitmap.new(maxwidth,Graphics.height)
|
|
||||||
pbSetSystemFont(tmp)
|
|
||||||
drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184))
|
|
||||||
return tmp
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PictureSprite < SpriteWrapper
|
|
||||||
def initialize(viewport, picture)
|
|
||||||
super(viewport)
|
|
||||||
@picture = picture
|
|
||||||
@pictureBitmap = nil
|
|
||||||
@customBitmap = nil
|
|
||||||
@customBitmapIsBitmap = true
|
|
||||||
@hue = 0
|
|
||||||
update
|
|
||||||
end
|
|
||||||
|
|
||||||
def dispose
|
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
# Doesn't free the bitmap
|
|
||||||
def setCustomBitmap(bitmap)
|
|
||||||
@customBitmap = bitmap
|
|
||||||
@customBitmapIsBitmap = @customBitmap.is_a?(Bitmap)
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
super
|
|
||||||
@pictureBitmap.update if @pictureBitmap
|
|
||||||
# If picture file name is different from current one
|
|
||||||
if @customBitmap && @picture.name==""
|
|
||||||
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
|
|
||||||
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
|
|
||||||
# Remember file name to instance variables
|
|
||||||
@picture_name = @picture.name
|
|
||||||
@hue = @picture.hue.to_i
|
|
||||||
# If file name is not empty
|
|
||||||
if @picture_name == ""
|
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
|
||||||
@pictureBitmap = nil
|
|
||||||
self.visible = false
|
|
||||||
return
|
|
||||||
end
|
|
||||||
# Get picture graphic
|
|
||||||
@pictureBitmap.dispose if @pictureBitmap
|
|
||||||
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
|
|
||||||
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
|
|
||||||
elsif @picture_name == ""
|
|
||||||
# Set sprite to invisible
|
|
||||||
self.visible = false
|
|
||||||
return
|
|
||||||
end
|
|
||||||
setPictureSprite(self,@picture)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class EventScene
|
|
||||||
attr_accessor :onCTrigger,:onBTrigger,:onUpdate
|
|
||||||
|
|
||||||
def initialize(viewport=nil)
|
|
||||||
@viewport = viewport
|
|
||||||
@onCTrigger = Event.new
|
|
||||||
@onBTrigger = Event.new
|
|
||||||
@onUpdate = Event.new
|
|
||||||
@pictures = []
|
|
||||||
@picturesprites = []
|
|
||||||
@usersprites = []
|
|
||||||
@disposed = false
|
|
||||||
end
|
|
||||||
|
|
||||||
def dispose
|
|
||||||
return if disposed?
|
|
||||||
for sprite in @picturesprites
|
|
||||||
sprite.dispose
|
|
||||||
end
|
|
||||||
for sprite in @usersprites
|
|
||||||
sprite.dispose
|
|
||||||
end
|
|
||||||
@onCTrigger.clear
|
|
||||||
@onBTrigger.clear
|
|
||||||
@onUpdate.clear
|
|
||||||
@pictures.clear
|
|
||||||
@picturesprites.clear
|
|
||||||
@usersprites.clear
|
|
||||||
@disposed = true
|
|
||||||
end
|
|
||||||
|
|
||||||
def disposed?
|
|
||||||
return @disposed
|
|
||||||
end
|
|
||||||
|
|
||||||
def addBitmap(x, y, bitmap)
|
|
||||||
# _bitmap_ can be a Bitmap or an AnimatedBitmap
|
|
||||||
# (update method isn't called if it's animated)
|
|
||||||
# EventScene doesn't take ownership of the passed-in bitmap
|
|
||||||
num = @pictures.length
|
|
||||||
picture = PictureEx.new(num)
|
|
||||||
picture.setXY(0,x,y)
|
|
||||||
picture.setVisible(0,true)
|
|
||||||
@pictures[num] = picture
|
|
||||||
@picturesprites[num] = PictureSprite.new(@viewport,picture)
|
|
||||||
@picturesprites[num].setCustomBitmap(bitmap)
|
|
||||||
return picture
|
|
||||||
end
|
|
||||||
|
|
||||||
def addLabel(x, y, width, text)
|
|
||||||
addBitmap(x,y,pbTextBitmap(text,width))
|
|
||||||
end
|
|
||||||
|
|
||||||
def addImage(x, y, name)
|
|
||||||
num = @pictures.length
|
|
||||||
picture = PictureEx.new(num)
|
|
||||||
picture.name = name
|
|
||||||
picture.setXY(0,x,y)
|
|
||||||
picture.setVisible(0,true)
|
|
||||||
@pictures[num] = picture
|
|
||||||
@picturesprites[num] = PictureSprite.new(@viewport,picture)
|
|
||||||
return picture
|
|
||||||
end
|
|
||||||
|
|
||||||
def addUserSprite(sprite)
|
|
||||||
@usersprites.push(sprite)
|
|
||||||
end
|
|
||||||
|
|
||||||
def getPicture(num)
|
|
||||||
return @pictures[num]
|
|
||||||
end
|
|
||||||
|
|
||||||
def wait(frames)
|
|
||||||
frames.times { update }
|
|
||||||
end
|
|
||||||
|
|
||||||
def pictureWait(extraframes=0)
|
|
||||||
loop do
|
|
||||||
hasRunning = false
|
|
||||||
for pic in @pictures
|
|
||||||
hasRunning = true if pic.running?
|
|
||||||
end
|
|
||||||
break if !hasRunning
|
|
||||||
update
|
|
||||||
end
|
|
||||||
extraframes.times { update }
|
|
||||||
end
|
|
||||||
|
|
||||||
def update
|
|
||||||
return if disposed?
|
|
||||||
Graphics.update
|
|
||||||
Input.update
|
|
||||||
for picture in @pictures
|
|
||||||
picture.update
|
|
||||||
end
|
|
||||||
for sprite in @picturesprites
|
|
||||||
sprite.update
|
|
||||||
end
|
|
||||||
for sprite in @usersprites
|
|
||||||
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
|
|
||||||
sprite.update
|
|
||||||
end
|
|
||||||
@onUpdate.trigger(self)
|
|
||||||
if Input.trigger?(Input::B)
|
|
||||||
@onBTrigger.trigger(self)
|
|
||||||
elsif Input.trigger?(Input::C)
|
|
||||||
@onCTrigger.trigger(self)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def main
|
|
||||||
while !disposed?
|
|
||||||
update
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def pbEventScreen(cls)
|
|
||||||
pbFadeOutIn {
|
|
||||||
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
|
||||||
viewport.z = 99999
|
|
||||||
PBDebug.logonerr {
|
|
||||||
cls.new(viewport).main
|
|
||||||
}
|
|
||||||
viewport.dispose
|
|
||||||
}
|
|
||||||
end
|
|
||||||
199
Data/Scripts/010_Scenes/002_EventScene.rb
Normal file
199
Data/Scripts/010_Scenes/002_EventScene.rb
Normal file
@@ -0,0 +1,199 @@
|
|||||||
|
class PictureSprite < SpriteWrapper
|
||||||
|
def initialize(viewport, picture)
|
||||||
|
super(viewport)
|
||||||
|
@picture = picture
|
||||||
|
@pictureBitmap = nil
|
||||||
|
@customBitmap = nil
|
||||||
|
@customBitmapIsBitmap = true
|
||||||
|
@hue = 0
|
||||||
|
update
|
||||||
|
end
|
||||||
|
|
||||||
|
def dispose
|
||||||
|
@pictureBitmap.dispose if @pictureBitmap
|
||||||
|
super
|
||||||
|
end
|
||||||
|
|
||||||
|
# Doesn't free the bitmap
|
||||||
|
def setCustomBitmap(bitmap)
|
||||||
|
@customBitmap = bitmap
|
||||||
|
@customBitmapIsBitmap = @customBitmap.is_a?(Bitmap)
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
super
|
||||||
|
@pictureBitmap.update if @pictureBitmap
|
||||||
|
# If picture file name is different from current one
|
||||||
|
if @customBitmap && @picture.name==""
|
||||||
|
self.bitmap = (@customBitmapIsBitmap) ? @customBitmap : @customBitmap.bitmap
|
||||||
|
elsif @picture_name != @picture.name || @picture.hue.to_i != @hue.to_i
|
||||||
|
# Remember file name to instance variables
|
||||||
|
@picture_name = @picture.name
|
||||||
|
@hue = @picture.hue.to_i
|
||||||
|
# If file name is not empty
|
||||||
|
if @picture_name == ""
|
||||||
|
@pictureBitmap.dispose if @pictureBitmap
|
||||||
|
@pictureBitmap = nil
|
||||||
|
self.visible = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
# Get picture graphic
|
||||||
|
@pictureBitmap.dispose if @pictureBitmap
|
||||||
|
@pictureBitmap = AnimatedBitmap.new(@picture_name, @hue)
|
||||||
|
self.bitmap = (@pictureBitmap) ? @pictureBitmap.bitmap : nil
|
||||||
|
elsif @picture_name == ""
|
||||||
|
# Set sprite to invisible
|
||||||
|
self.visible = false
|
||||||
|
return
|
||||||
|
end
|
||||||
|
setPictureSprite(self,@picture)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def pbTextBitmap(text, maxwidth=Graphics.width)
|
||||||
|
dims = []
|
||||||
|
tmp = Bitmap.new(maxwidth,Graphics.height)
|
||||||
|
pbSetSystemFont(tmp)
|
||||||
|
drawFormattedTextEx(tmp,0,0,maxwidth,text,Color.new(248,248,248),Color.new(168,184,184))
|
||||||
|
return tmp
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# EventScene
|
||||||
|
#===============================================================================
|
||||||
|
class EventScene
|
||||||
|
attr_accessor :onCTrigger,:onBTrigger,:onUpdate
|
||||||
|
|
||||||
|
def initialize(viewport=nil)
|
||||||
|
@viewport = viewport
|
||||||
|
@onCTrigger = Event.new
|
||||||
|
@onBTrigger = Event.new
|
||||||
|
@onUpdate = Event.new
|
||||||
|
@pictures = []
|
||||||
|
@picturesprites = []
|
||||||
|
@usersprites = []
|
||||||
|
@disposed = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def dispose
|
||||||
|
return if disposed?
|
||||||
|
for sprite in @picturesprites
|
||||||
|
sprite.dispose
|
||||||
|
end
|
||||||
|
for sprite in @usersprites
|
||||||
|
sprite.dispose
|
||||||
|
end
|
||||||
|
@onCTrigger.clear
|
||||||
|
@onBTrigger.clear
|
||||||
|
@onUpdate.clear
|
||||||
|
@pictures.clear
|
||||||
|
@picturesprites.clear
|
||||||
|
@usersprites.clear
|
||||||
|
@disposed = true
|
||||||
|
end
|
||||||
|
|
||||||
|
def disposed?
|
||||||
|
return @disposed
|
||||||
|
end
|
||||||
|
|
||||||
|
def addBitmap(x, y, bitmap)
|
||||||
|
# _bitmap_ can be a Bitmap or an AnimatedBitmap
|
||||||
|
# (update method isn't called if it's animated)
|
||||||
|
# EventScene doesn't take ownership of the passed-in bitmap
|
||||||
|
num = @pictures.length
|
||||||
|
picture = PictureEx.new(num)
|
||||||
|
picture.setXY(0,x,y)
|
||||||
|
picture.setVisible(0,true)
|
||||||
|
@pictures[num] = picture
|
||||||
|
@picturesprites[num] = PictureSprite.new(@viewport,picture)
|
||||||
|
@picturesprites[num].setCustomBitmap(bitmap)
|
||||||
|
return picture
|
||||||
|
end
|
||||||
|
|
||||||
|
def addLabel(x, y, width, text)
|
||||||
|
addBitmap(x,y,pbTextBitmap(text,width))
|
||||||
|
end
|
||||||
|
|
||||||
|
def addImage(x, y, name)
|
||||||
|
num = @pictures.length
|
||||||
|
picture = PictureEx.new(num)
|
||||||
|
picture.name = name
|
||||||
|
picture.setXY(0,x,y)
|
||||||
|
picture.setVisible(0,true)
|
||||||
|
@pictures[num] = picture
|
||||||
|
@picturesprites[num] = PictureSprite.new(@viewport,picture)
|
||||||
|
return picture
|
||||||
|
end
|
||||||
|
|
||||||
|
def addUserSprite(sprite)
|
||||||
|
@usersprites.push(sprite)
|
||||||
|
end
|
||||||
|
|
||||||
|
def getPicture(num)
|
||||||
|
return @pictures[num]
|
||||||
|
end
|
||||||
|
|
||||||
|
def wait(frames)
|
||||||
|
frames.times { update }
|
||||||
|
end
|
||||||
|
|
||||||
|
def pictureWait(extraframes=0)
|
||||||
|
loop do
|
||||||
|
hasRunning = false
|
||||||
|
for pic in @pictures
|
||||||
|
hasRunning = true if pic.running?
|
||||||
|
end
|
||||||
|
break if !hasRunning
|
||||||
|
update
|
||||||
|
end
|
||||||
|
extraframes.times { update }
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
return if disposed?
|
||||||
|
Graphics.update
|
||||||
|
Input.update
|
||||||
|
for picture in @pictures
|
||||||
|
picture.update
|
||||||
|
end
|
||||||
|
for sprite in @picturesprites
|
||||||
|
sprite.update
|
||||||
|
end
|
||||||
|
for sprite in @usersprites
|
||||||
|
next if !sprite || sprite.disposed? || !sprite.is_a?(Sprite)
|
||||||
|
sprite.update
|
||||||
|
end
|
||||||
|
@onUpdate.trigger(self)
|
||||||
|
if Input.trigger?(Input::B)
|
||||||
|
@onBTrigger.trigger(self)
|
||||||
|
elsif Input.trigger?(Input::C)
|
||||||
|
@onCTrigger.trigger(self)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def main
|
||||||
|
while !disposed?
|
||||||
|
update
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
def pbEventScreen(cls)
|
||||||
|
pbFadeOutIn {
|
||||||
|
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
|
||||||
|
viewport.z = 99999
|
||||||
|
PBDebug.logonerr {
|
||||||
|
cls.new(viewport).main
|
||||||
|
}
|
||||||
|
viewport.dispose
|
||||||
|
}
|
||||||
|
end
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user