mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-09 14:14:59 +00:00
Refactored animation editor code into a single module
This commit is contained in:
@@ -127,6 +127,16 @@ module Enumerable
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#===============================================================================
|
||||||
|
# Collision testing
|
||||||
|
#===============================================================================
|
||||||
|
class Rect < Object
|
||||||
|
def contains?(cx, cy)
|
||||||
|
return cx >= self.x && cx < self.x + self.width &&
|
||||||
|
cy >= self.y && cy < self.y + self.height
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# class File
|
# class File
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ module GameData
|
|||||||
extend ClassMethodsSymbols
|
extend ClassMethodsSymbols
|
||||||
include InstanceMethods
|
include InstanceMethods
|
||||||
|
|
||||||
# @param other [Symbol, String, self]
|
# @param area [Symbol, String, self]
|
||||||
# @param version [Integer]
|
# @param version [Integer]
|
||||||
# @return [self]
|
# @return [self]
|
||||||
def self.try_get(area, version = 0)
|
def self.try_get(area, version = 0)
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#===============================================================================
|
module BattleAnimationEditor
|
||||||
# Controls
|
module_function
|
||||||
#===============================================================================
|
|
||||||
class Window_Menu < Window_CommandPokemon
|
#===============================================================================
|
||||||
|
# Controls
|
||||||
|
#===============================================================================
|
||||||
|
class Window_Menu < Window_CommandPokemon
|
||||||
def initialize(commands, x, y)
|
def initialize(commands, x, y)
|
||||||
tempbitmap = Bitmap.new(32, 32)
|
tempbitmap = Bitmap.new(32, 32)
|
||||||
w = 0
|
w = 0
|
||||||
@@ -32,16 +35,16 @@ class Window_Menu < Window_CommandPokemon
|
|||||||
rc = Rect.new(0, 32 * (i - toprow), self.contents.width, 32)
|
rc = Rect.new(0, 32 * (i - toprow), self.contents.width, 32)
|
||||||
rc.x += self.x + self.leftEdge
|
rc.x += self.x + self.leftEdge
|
||||||
rc.y += self.y + self.topEdge
|
rc.y += self.y + self.topEdge
|
||||||
return i if rc.contains(mousepos[0], mousepos[1])
|
return i if rc.contains?(mousepos[0], mousepos[1])
|
||||||
end
|
end
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Clipboard
|
# Clipboard
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
module Clipboard
|
module Clipboard
|
||||||
@data = nil
|
@data = nil
|
||||||
@typekey = ""
|
@typekey = ""
|
||||||
|
|
||||||
@@ -58,74 +61,12 @@ module Clipboard
|
|||||||
@data = Marshal.dump(data)
|
@data = Marshal.dump(data)
|
||||||
@typekey = key
|
@typekey = key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Collision testing
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Rect < Object
|
def pbTrackPopupMenu(commands)
|
||||||
def contains(x, y)
|
|
||||||
return x >= self.x && x < self.x + self.width &&
|
|
||||||
y >= self.y && y < self.y + self.height
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
#===============================================================================
|
|
||||||
#
|
|
||||||
#===============================================================================
|
|
||||||
def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
|
|
||||||
return false if !sprite || sprite.disposed?
|
|
||||||
return false if !sprite.bitmap
|
|
||||||
return false if !sprite.visible
|
|
||||||
return false if sprite.bitmap.disposed?
|
|
||||||
width = sprite.src_rect.width
|
|
||||||
height = sprite.src_rect.height
|
|
||||||
if wholecanvas
|
|
||||||
xwidth = 0
|
|
||||||
xheight = 0
|
|
||||||
else
|
|
||||||
xwidth = width - 64
|
|
||||||
xheight = height - 64
|
|
||||||
width = 64 if width > 64 && !usealpha
|
|
||||||
height = 64 if height > 64 && !usealpha
|
|
||||||
end
|
|
||||||
width = sprite.bitmap.width if width > sprite.bitmap.width
|
|
||||||
height = sprite.bitmap.height if height > sprite.bitmap.height
|
|
||||||
if usealpha
|
|
||||||
spritex = sprite.x - (sprite.ox * sprite.zoom_x)
|
|
||||||
spritey = sprite.y - (sprite.oy * sprite.zoom_y)
|
|
||||||
width *= sprite.zoom_x
|
|
||||||
height *= sprite.zoom_y
|
|
||||||
else
|
|
||||||
spritex = sprite.x - sprite.ox
|
|
||||||
spritey = sprite.y - sprite.oy
|
|
||||||
spritex += xwidth / 2
|
|
||||||
spritey += xheight / 2
|
|
||||||
end
|
|
||||||
if !(x >= spritex && x <= spritex + width && y >= spritey && y <= spritey + height)
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
if usealpha
|
|
||||||
# TODO: This should account for sprite.angle as well
|
|
||||||
bitmapX = sprite.src_rect.x
|
|
||||||
bitmapY = sprite.src_rect.y
|
|
||||||
bitmapX += sprite.ox
|
|
||||||
bitmapY += sprite.oy
|
|
||||||
bitmapX += (x - sprite.x) / sprite.zoom_x if sprite.zoom_x > 0
|
|
||||||
bitmapY += (y - sprite.y) / sprite.zoom_y if sprite.zoom_y > 0
|
|
||||||
bitmapX = bitmapX.round
|
|
||||||
bitmapY = bitmapY.round
|
|
||||||
if sprite.mirror
|
|
||||||
xmirror = bitmapX - sprite.src_rect.x
|
|
||||||
bitmapX = sprite.src_rect.x + 192 - xmirror
|
|
||||||
end
|
|
||||||
color = sprite.bitmap.get_pixel(bitmapX, bitmapY)
|
|
||||||
return false if color.alpha == 0
|
|
||||||
end
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
def pbTrackPopupMenu(commands)
|
|
||||||
mousepos = Mouse.getMousePos
|
mousepos = Mouse.getMousePos
|
||||||
return -1 if !mousepos
|
return -1 if !mousepos
|
||||||
menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1])
|
menuwindow = Window_Menu.new(commands, mousepos[0], mousepos[1])
|
||||||
@@ -151,12 +92,12 @@ def pbTrackPopupMenu(commands)
|
|||||||
end
|
end
|
||||||
menuwindow.dispose
|
menuwindow.dispose
|
||||||
return -1
|
return -1
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Sprite sheet scrolling bar
|
# Sprite sheet scrolling bar
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class AnimationWindow < Sprite
|
class AnimationWindow < Sprite
|
||||||
attr_reader :animbitmap
|
attr_reader :animbitmap
|
||||||
attr_reader :start
|
attr_reader :start
|
||||||
attr_reader :selected
|
attr_reader :selected
|
||||||
@@ -262,14 +203,14 @@ class AnimationWindow < Sprite
|
|||||||
swatchrects.push(Rect.new(arrowwidth + (i * 96) + self.x, self.y, 96, 96))
|
swatchrects.push(Rect.new(arrowwidth + (i * 96) + self.x, self.y, 96, 96))
|
||||||
end
|
end
|
||||||
NUMFRAMES.times do |i|
|
NUMFRAMES.times do |i|
|
||||||
next if !swatchrects[i].contains(mousepos[0], mousepos[1])
|
next if !swatchrects[i].contains?(mousepos[0], mousepos[1])
|
||||||
@selected = @start + i
|
@selected = @start + i
|
||||||
@changed = true
|
@changed = true
|
||||||
refresh
|
refresh
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0], mousepos[1])
|
if left.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 750
|
if repeattime > 750
|
||||||
@start -= 3
|
@start -= 3
|
||||||
else
|
else
|
||||||
@@ -279,7 +220,7 @@ class AnimationWindow < Sprite
|
|||||||
refresh
|
refresh
|
||||||
end
|
end
|
||||||
# Right arrow
|
# Right arrow
|
||||||
if right.contains(mousepos[0], mousepos[1])
|
if right.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 750
|
if repeattime > 750
|
||||||
@start += 3
|
@start += 3
|
||||||
else
|
else
|
||||||
@@ -289,12 +230,12 @@ class AnimationWindow < Sprite
|
|||||||
refresh
|
refresh
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class CanvasAnimationWindow < AnimationWindow
|
class CanvasAnimationWindow < AnimationWindow
|
||||||
def animbitmap
|
def animbitmap
|
||||||
return @canvas.animbitmap
|
return @canvas.animbitmap
|
||||||
end
|
end
|
||||||
@@ -303,12 +244,12 @@ class CanvasAnimationWindow < AnimationWindow
|
|||||||
@canvas = canvas
|
@canvas = canvas
|
||||||
super(x, y, width, height, viewport)
|
super(x, y, width, height, viewport)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Cel sprite
|
# Cel sprite
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class InvalidatableSprite < Sprite
|
class InvalidatableSprite < Sprite
|
||||||
def initialize(viewport = nil)
|
def initialize(viewport = nil)
|
||||||
super(viewport)
|
super(viewport)
|
||||||
@invalid = false
|
@invalid = false
|
||||||
@@ -340,12 +281,12 @@ class InvalidatableSprite < Sprite
|
|||||||
# Redraws the sprite. This method should not check whether
|
# Redraws the sprite. This method should not check whether
|
||||||
# the sprite is invalid, to allow it to be explicitly called.
|
# the sprite is invalid, to allow it to be explicitly called.
|
||||||
def refresh; end
|
def refresh; end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class SpriteFrame < InvalidatableSprite
|
class SpriteFrame < InvalidatableSprite
|
||||||
attr_reader :id
|
attr_reader :id
|
||||||
attr_reader :locked
|
attr_reader :locked
|
||||||
attr_reader :selected
|
attr_reader :selected
|
||||||
@@ -409,12 +350,12 @@ class SpriteFrame < InvalidatableSprite
|
|||||||
@contents.blt(16, 0, @iconbitmap.bitmap, bmrect)
|
@contents.blt(16, 0, @iconbitmap.bitmap, bmrect)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Canvas
|
# Canvas
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class AnimationCanvas < Sprite
|
class AnimationCanvas < Sprite
|
||||||
attr_reader :viewport
|
attr_reader :viewport
|
||||||
attr_reader :sprites
|
attr_reader :sprites
|
||||||
attr_reader :currentframe # Currently active frame
|
attr_reader :currentframe # Currently active frame
|
||||||
@@ -785,6 +726,58 @@ class AnimationCanvas < Sprite
|
|||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pbSpriteHitTest(sprite, x, y, usealpha = true, wholecanvas = false)
|
||||||
|
return false if !sprite || sprite.disposed?
|
||||||
|
return false if !sprite.bitmap
|
||||||
|
return false if !sprite.visible
|
||||||
|
return false if sprite.bitmap.disposed?
|
||||||
|
width = sprite.src_rect.width
|
||||||
|
height = sprite.src_rect.height
|
||||||
|
if wholecanvas
|
||||||
|
xwidth = 0
|
||||||
|
xheight = 0
|
||||||
|
else
|
||||||
|
xwidth = width - 64
|
||||||
|
xheight = height - 64
|
||||||
|
width = 64 if width > 64 && !usealpha
|
||||||
|
height = 64 if height > 64 && !usealpha
|
||||||
|
end
|
||||||
|
width = sprite.bitmap.width if width > sprite.bitmap.width
|
||||||
|
height = sprite.bitmap.height if height > sprite.bitmap.height
|
||||||
|
if usealpha
|
||||||
|
spritex = sprite.x - (sprite.ox * sprite.zoom_x)
|
||||||
|
spritey = sprite.y - (sprite.oy * sprite.zoom_y)
|
||||||
|
width *= sprite.zoom_x
|
||||||
|
height *= sprite.zoom_y
|
||||||
|
else
|
||||||
|
spritex = sprite.x - sprite.ox
|
||||||
|
spritey = sprite.y - sprite.oy
|
||||||
|
spritex += xwidth / 2
|
||||||
|
spritey += xheight / 2
|
||||||
|
end
|
||||||
|
if !(x >= spritex && x <= spritex + width && y >= spritey && y <= spritey + height)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
if usealpha
|
||||||
|
# TODO: This should account for sprite.angle as well
|
||||||
|
bitmapX = sprite.src_rect.x
|
||||||
|
bitmapY = sprite.src_rect.y
|
||||||
|
bitmapX += sprite.ox
|
||||||
|
bitmapY += sprite.oy
|
||||||
|
bitmapX += (x - sprite.x) / sprite.zoom_x if sprite.zoom_x > 0
|
||||||
|
bitmapY += (y - sprite.y) / sprite.zoom_y if sprite.zoom_y > 0
|
||||||
|
bitmapX = bitmapX.round
|
||||||
|
bitmapY = bitmapY.round
|
||||||
|
if sprite.mirror
|
||||||
|
xmirror = bitmapX - sprite.src_rect.x
|
||||||
|
bitmapX = sprite.src_rect.x + 192 - xmirror
|
||||||
|
end
|
||||||
|
color = sprite.bitmap.get_pixel(bitmapX, bitmapY)
|
||||||
|
return false if color.alpha == 0
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
def updateInput
|
def updateInput
|
||||||
cel = currentCel
|
cel = currentCel
|
||||||
mousepos = Mouse.getMousePos
|
mousepos = Mouse.getMousePos
|
||||||
@@ -840,7 +833,7 @@ class AnimationCanvas < Sprite
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if Input.triggerex?(:P) || Input.repeatex?(:P) # Properties
|
if Input.triggerex?(:P) || Input.repeatex?(:P) # Properties
|
||||||
pbCellProperties(self)
|
BattleAnimationEditor.pbCellProperties(self)
|
||||||
@dirty[@currentcel] = true
|
@dirty[@currentcel] = true
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -909,8 +902,8 @@ class AnimationCanvas < Sprite
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
updateInput
|
updateInput
|
||||||
# @testscreen.update
|
# @testscreen.update
|
||||||
# self.bitmap=@testscreen.bitmap
|
# self.bitmap=@testscreen.bitmap
|
||||||
if @currentframe < @animation.length
|
if @currentframe < @animation.length
|
||||||
PBAnimation::MAX_SPRITES.times do |i|
|
PBAnimation::MAX_SPRITES.times do |i|
|
||||||
next if !@dirty[i]
|
next if !@dirty[i]
|
||||||
@@ -935,12 +928,12 @@ class AnimationCanvas < Sprite
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Window classes
|
# Window classes
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class BitmapDisplayWindow < SpriteWindow_Base
|
class BitmapDisplayWindow < SpriteWindow_Base
|
||||||
attr_reader :bitmapname
|
attr_reader :bitmapname
|
||||||
attr_reader :hue
|
attr_reader :hue
|
||||||
|
|
||||||
@@ -987,12 +980,12 @@ class BitmapDisplayWindow < SpriteWindow_Base
|
|||||||
self.contents.stretch_blt(dest, bmap, src)
|
self.contents.stretch_blt(dest, bmap, src)
|
||||||
bmap.dispose
|
bmap.dispose
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class AnimationNameWindow
|
class AnimationNameWindow
|
||||||
def initialize(canvas, x, y, width, height, viewport = nil)
|
def initialize(canvas, x, y, width, height, viewport = nil)
|
||||||
@canvas = canvas
|
@canvas = canvas
|
||||||
@oldname = nil
|
@oldname = nil
|
||||||
@@ -1015,4 +1008,5 @@ class AnimationNameWindow
|
|||||||
def refresh; @window.refresh; end
|
def refresh; @window.refresh; end
|
||||||
def dispose; @window.dispose; end
|
def dispose; @window.dispose; end
|
||||||
def disposed; @window.disposed?; end
|
def disposed; @window.disposed?; end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#===============================================================================
|
module BattleAnimationEditor
|
||||||
#
|
module_function
|
||||||
#===============================================================================
|
|
||||||
module ShadowText
|
#===============================================================================
|
||||||
|
#
|
||||||
|
#===============================================================================
|
||||||
|
module ShadowText
|
||||||
def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0)
|
def shadowtext(bitmap, x, y, w, h, t, disabled = false, align = 0)
|
||||||
width = bitmap.text_size(t).width
|
width = bitmap.text_size(t).width
|
||||||
case align
|
case align
|
||||||
@@ -14,12 +17,12 @@ module ShadowText
|
|||||||
disabled ? Color.new(208, 208, 200) : Color.new(96, 96, 96),
|
disabled ? Color.new(208, 208, 200) : Color.new(96, 96, 96),
|
||||||
Color.new(208, 208, 200))
|
Color.new(208, 208, 200))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class UIControl
|
class UIControl
|
||||||
include ShadowText
|
include ShadowText
|
||||||
attr_accessor :bitmap
|
attr_accessor :bitmap
|
||||||
attr_accessor :label
|
attr_accessor :label
|
||||||
@@ -90,12 +93,12 @@ class UIControl
|
|||||||
self.validate
|
self.validate
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Label < UIControl
|
class Label < UIControl
|
||||||
def text=(value)
|
def text=(value)
|
||||||
self.label = value
|
self.label = value
|
||||||
refresh
|
refresh
|
||||||
@@ -107,12 +110,12 @@ class Label < UIControl
|
|||||||
size = bitmap.text_size(self.label).width
|
size = bitmap.text_size(self.label).width
|
||||||
shadowtext(bitmap, self.x + 4, self.y, size, self.height, self.label, @disabled)
|
shadowtext(bitmap, self.x + 4, self.y, size, self.height, self.label, @disabled)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Button < UIControl
|
class Button < UIControl
|
||||||
attr_accessor :label
|
attr_accessor :label
|
||||||
|
|
||||||
def initialize(label)
|
def initialize(label)
|
||||||
@@ -128,12 +131,12 @@ class Button < UIControl
|
|||||||
rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2)
|
rect = Rect.new(self.x + 1, self.y + 1, self.width - 2, self.height - 2)
|
||||||
rect = toAbsoluteRect(rect)
|
rect = toAbsoluteRect(rect)
|
||||||
if Input.trigger?(Input::MOUSELEFT) &&
|
if Input.trigger?(Input::MOUSELEFT) &&
|
||||||
rect.contains(mousepos[0], mousepos[1]) && !@captured
|
rect.contains?(mousepos[0], mousepos[1]) && !@captured
|
||||||
@captured = true
|
@captured = true
|
||||||
self.invalidate
|
self.invalidate
|
||||||
end
|
end
|
||||||
if Input.release?(Input::MOUSELEFT) && @captured
|
if Input.release?(Input::MOUSELEFT) && @captured
|
||||||
self.changed = true if rect.contains(mousepos[0], mousepos[1])
|
self.changed = true if rect.contains?(mousepos[0], mousepos[1])
|
||||||
@captured = false
|
@captured = false
|
||||||
self.invalidate
|
self.invalidate
|
||||||
end
|
end
|
||||||
@@ -164,12 +167,12 @@ class Button < UIControl
|
|||||||
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Checkbox < Button
|
class Checkbox < Button
|
||||||
attr_reader :checked
|
attr_reader :checked
|
||||||
|
|
||||||
def curvalue
|
def curvalue
|
||||||
@@ -217,7 +220,6 @@ class Checkbox < Button
|
|||||||
shadowtext(bitmap, x + 36, y, size, height, self.label, @disabled)
|
shadowtext(bitmap, x + 36, y, size, height, self.label, @disabled)
|
||||||
# Draw outline
|
# Draw outline
|
||||||
color = Color.new(120, 120, 120)
|
color = Color.new(120, 120, 120)
|
||||||
bitmap.fill_rect(x + 1, y + 1, width - 2, height - 2, color)
|
|
||||||
bitmap.fill_rect(x + 1, y + 1, width - 2, 1, color)
|
bitmap.fill_rect(x + 1, y + 1, width - 2, 1, color)
|
||||||
bitmap.fill_rect(x + 1, y + 1, 1, height - 2, color)
|
bitmap.fill_rect(x + 1, y + 1, 1, height - 2, color)
|
||||||
bitmap.fill_rect(x + 1, y + height - 2, width - 2, 1, color)
|
bitmap.fill_rect(x + 1, y + height - 2, width - 2, 1, color)
|
||||||
@@ -226,12 +228,12 @@ class Checkbox < Button
|
|||||||
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class TextField < UIControl
|
class TextField < UIControl
|
||||||
attr_accessor :label
|
attr_accessor :label
|
||||||
attr_reader :text
|
attr_reader :text
|
||||||
|
|
||||||
@@ -362,12 +364,12 @@ class TextField < UIControl
|
|||||||
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
ret = Rect.new(x + 1, y + 1, width - 2, height - 2)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class Slider < UIControl
|
class Slider < UIControl
|
||||||
attr_reader :minvalue
|
attr_reader :minvalue
|
||||||
attr_reader :maxvalue
|
attr_reader :maxvalue
|
||||||
attr_reader :curvalue
|
attr_reader :curvalue
|
||||||
@@ -421,7 +423,7 @@ class Slider < UIControl
|
|||||||
oldvalue = self.curvalue
|
oldvalue = self.curvalue
|
||||||
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0], mousepos[1])
|
if left.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 3000
|
if repeattime > 3000
|
||||||
self.curvalue -= 10
|
self.curvalue -= 10
|
||||||
elsif repeattime > 1500
|
elsif repeattime > 1500
|
||||||
@@ -434,7 +436,7 @@ class Slider < UIControl
|
|||||||
self.invalidate
|
self.invalidate
|
||||||
end
|
end
|
||||||
# Right arrow
|
# Right arrow
|
||||||
if right.contains(mousepos[0], mousepos[1])
|
if right.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 3000
|
if repeattime > 3000
|
||||||
self.curvalue += 10
|
self.curvalue += 10
|
||||||
elsif repeattime > 1500
|
elsif repeattime > 1500
|
||||||
@@ -476,12 +478,12 @@ class Slider < UIControl
|
|||||||
self.disabled || self.curvalue == self.maxvalue)
|
self.disabled || self.curvalue == self.maxvalue)
|
||||||
@rightarrow = Rect.new(x, y, rightarrows.width, height)
|
@rightarrow = Rect.new(x, y, rightarrows.width, height)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class OptionalSlider < Slider
|
class OptionalSlider < Slider
|
||||||
def initialize(label, minvalue, maxvalue, curvalue)
|
def initialize(label, minvalue, maxvalue, curvalue)
|
||||||
@slider = Slider.new(label, minvalue, maxvalue, curvalue)
|
@slider = Slider.new(label, minvalue, maxvalue, curvalue)
|
||||||
@checkbox = Checkbox.new("")
|
@checkbox = Checkbox.new("")
|
||||||
@@ -569,12 +571,12 @@ class OptionalSlider < Slider
|
|||||||
@slider.height = self.height
|
@slider.height = self.height
|
||||||
@slider.disabled = !@checkbox.checked
|
@slider.disabled = !@checkbox.checked
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class ArrayCountSlider < Slider
|
class ArrayCountSlider < Slider
|
||||||
def maxvalue
|
def maxvalue
|
||||||
return @array.length - 1
|
return @array.length - 1
|
||||||
end
|
end
|
||||||
@@ -583,12 +585,12 @@ class ArrayCountSlider < Slider
|
|||||||
@array = array
|
@array = array
|
||||||
super(label, 0, canvas.animation.length - 1, 0)
|
super(label, 0, canvas.animation.length - 1, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class FrameCountSlider < Slider
|
class FrameCountSlider < Slider
|
||||||
def maxvalue
|
def maxvalue
|
||||||
return @canvas.animation.length
|
return @canvas.animation.length
|
||||||
end
|
end
|
||||||
@@ -597,12 +599,12 @@ class FrameCountSlider < Slider
|
|||||||
@canvas = canvas
|
@canvas = canvas
|
||||||
super(_INTL("Frame:"), 1, canvas.animation.length, 0)
|
super(_INTL("Frame:"), 1, canvas.animation.length, 0)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class FrameCountButton < Button
|
class FrameCountButton < Button
|
||||||
def label
|
def label
|
||||||
return _INTL("Total Frames: {1}", @canvas.animation.length)
|
return _INTL("Total Frames: {1}", @canvas.animation.length)
|
||||||
end
|
end
|
||||||
@@ -611,12 +613,12 @@ class FrameCountButton < Button
|
|||||||
@canvas = canvas
|
@canvas = canvas
|
||||||
super(self.label)
|
super(self.label)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class TextSlider < UIControl
|
class TextSlider < UIControl
|
||||||
attr_reader :minvalue
|
attr_reader :minvalue
|
||||||
attr_reader :maxvalue
|
attr_reader :maxvalue
|
||||||
attr_reader :curvalue
|
attr_reader :curvalue
|
||||||
@@ -673,7 +675,7 @@ class TextSlider < UIControl
|
|||||||
oldvalue = self.curvalue
|
oldvalue = self.curvalue
|
||||||
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
repeattime = Input.time?(Input::MOUSELEFT) / 1000
|
||||||
# Left arrow
|
# Left arrow
|
||||||
if left.contains(mousepos[0], mousepos[1])
|
if left.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 3000
|
if repeattime > 3000
|
||||||
self.curvalue -= 10
|
self.curvalue -= 10
|
||||||
elsif repeattime > 1500
|
elsif repeattime > 1500
|
||||||
@@ -685,7 +687,7 @@ class TextSlider < UIControl
|
|||||||
self.invalidate
|
self.invalidate
|
||||||
end
|
end
|
||||||
# Right arrow
|
# Right arrow
|
||||||
if right.contains(mousepos[0], mousepos[1])
|
if right.contains?(mousepos[0], mousepos[1])
|
||||||
if repeattime > 3000
|
if repeattime > 3000
|
||||||
self.curvalue += 10
|
self.curvalue += 10
|
||||||
elsif repeattime > 1500
|
elsif repeattime > 1500
|
||||||
@@ -731,12 +733,12 @@ class TextSlider < UIControl
|
|||||||
self.disabled || self.curvalue == self.maxvalue)
|
self.disabled || self.curvalue == self.maxvalue)
|
||||||
@rightarrow = Rect.new(x, y, rightarrows.width, height)
|
@rightarrow = Rect.new(x, y, rightarrows.width, height)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class OptionalTextSlider < TextSlider
|
class OptionalTextSlider < TextSlider
|
||||||
def initialize(label, options, curval)
|
def initialize(label, options, curval)
|
||||||
@slider = TextSlider.new(label, options, curval)
|
@slider = TextSlider.new(label, options, curval)
|
||||||
@checkbox = Checkbox.new("")
|
@checkbox = Checkbox.new("")
|
||||||
@@ -824,12 +826,12 @@ class OptionalTextSlider < TextSlider
|
|||||||
@slider.height = self.height
|
@slider.height = self.height
|
||||||
@slider.disabled = !@checkbox.checked
|
@slider.disabled = !@checkbox.checked
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class ControlWindow < SpriteWindow_Base
|
class ControlWindow < SpriteWindow_Base
|
||||||
attr_reader :controls
|
attr_reader :controls
|
||||||
|
|
||||||
def initialize(x, y, width, height)
|
def initialize(x, y, width, height)
|
||||||
@@ -862,7 +864,7 @@ class ControlWindow < SpriteWindow_Base
|
|||||||
return false if i < 0 || i >= @controls.length
|
return false if i < 0 || i >= @controls.length
|
||||||
rc = Rect.new(@controls[i].parentX, @controls[i].parentY,
|
rc = Rect.new(@controls[i].parentX, @controls[i].parentY,
|
||||||
@controls[i].width, @controls[i].height)
|
@controls[i].width, @controls[i].height)
|
||||||
return rc.contains(mousepos[0], mousepos[1])
|
return rc.contains?(mousepos[0], mousepos[1])
|
||||||
end
|
end
|
||||||
|
|
||||||
def addControl(control)
|
def addControl(control)
|
||||||
@@ -926,4 +928,5 @@ class ControlWindow < SpriteWindow_Base
|
|||||||
return false if i < 0
|
return false if i < 0
|
||||||
return @controls[i].curvalue
|
return @controls[i].curvalue
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
#===============================================================================
|
module BattleAnimationEditor
|
||||||
# Paths and interpolation
|
module_function
|
||||||
#===============================================================================
|
|
||||||
class ControlPointSprite < Sprite
|
#===============================================================================
|
||||||
|
# Paths and interpolation
|
||||||
|
#===============================================================================
|
||||||
|
class ControlPointSprite < Sprite
|
||||||
attr_accessor :dragging
|
attr_accessor :dragging
|
||||||
|
|
||||||
def initialize(red, viewport = nil)
|
def initialize(red, viewport = nil)
|
||||||
@@ -46,12 +49,12 @@ class ControlPointSprite < Sprite
|
|||||||
self.bitmap.dispose
|
self.bitmap.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class PointSprite < Sprite
|
class PointSprite < Sprite
|
||||||
def initialize(x, y, viewport = nil)
|
def initialize(x, y, viewport = nil)
|
||||||
super(viewport)
|
super(viewport)
|
||||||
self.bitmap = Bitmap.new(2, 2)
|
self.bitmap = Bitmap.new(2, 2)
|
||||||
@@ -64,12 +67,12 @@ class PointSprite < Sprite
|
|||||||
self.bitmap.dispose
|
self.bitmap.dispose
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class PointPath
|
class PointPath
|
||||||
include Enumerable
|
include Enumerable
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@@ -174,21 +177,21 @@ class PointPath
|
|||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def catmullRom(p1, p2, p3, p4, t)
|
def catmullRom(p1, p2, p3, p4, t)
|
||||||
# p1=prevPoint, p2=startPoint, p3=endPoint, p4=nextPoint, t is from 0 through 1
|
# p1=prevPoint, p2=startPoint, p3=endPoint, p4=nextPoint, t is from 0 through 1
|
||||||
t2 = t * t
|
t2 = t * t
|
||||||
t3 = t2 * t
|
t3 = t2 * t
|
||||||
return 0.5 * ((2 * p2) + (t * (p3 - p1)) +
|
return 0.5 * ((2 * p2) + (t * (p3 - p1)) +
|
||||||
(t2 * ((2 * p1) - (5 * p2) + (4 * p3) - p4)) +
|
(t2 * ((2 * p1) - (5 * p2) + (4 * p3) - p4)) +
|
||||||
(t3 * (p4 - (3 * p3) + (3 * p2) - p1)))
|
(t3 * (p4 - (3 * p3) + (3 * p2) - p1)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def getCatmullRomPoint(src, t)
|
def getCatmullRomPoint(src, t)
|
||||||
x = 0, y = 0
|
x = 0, y = 0
|
||||||
t *= 3.0
|
t *= 3.0
|
||||||
if t < 1.0
|
if t < 1.0
|
||||||
@@ -204,13 +207,13 @@ def getCatmullRomPoint(src, t)
|
|||||||
y = catmullRom(src[1].y, src[2].y, src[3].y, src[3].y, t)
|
y = catmullRom(src[1].y, src[2].y, src[3].y, src[3].y, t)
|
||||||
end
|
end
|
||||||
return [x, y]
|
return [x, y]
|
||||||
end
|
end
|
||||||
|
|
||||||
def getCurvePoint(src, t)
|
def getCurvePoint(src, t)
|
||||||
return getCatmullRomPoint(src, t)
|
return getCatmullRomPoint(src, t)
|
||||||
end
|
end
|
||||||
|
|
||||||
def curveToPointPath(curve, numpoints)
|
def curveToPointPath(curve, numpoints)
|
||||||
return nil if numpoints < 2
|
return nil if numpoints < 2
|
||||||
path = PointPath.new
|
path = PointPath.new
|
||||||
step = 1.0 / (numpoints - 1)
|
step = 1.0 / (numpoints - 1)
|
||||||
@@ -221,9 +224,9 @@ def curveToPointPath(curve, numpoints)
|
|||||||
t += step
|
t += step
|
||||||
end
|
end
|
||||||
return path
|
return path
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbDefinePath(canvas)
|
def pbDefinePath(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.addSlider(_INTL("Number of frames:"), 2, 500, 20)
|
sliderwin2.addSlider(_INTL("Number of frames:"), 2, 500, 20)
|
||||||
@@ -338,7 +341,7 @@ def pbDefinePath(canvas)
|
|||||||
points.clear
|
points.clear
|
||||||
if showline
|
if showline
|
||||||
path = curveToPointPath(curve, sliderwin2.value(0))
|
path = curveToPointPath(curve, sliderwin2.value(0))
|
||||||
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
||||||
path.each do |point|
|
path.each do |point|
|
||||||
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
|
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
|
||||||
end
|
end
|
||||||
@@ -397,11 +400,11 @@ def pbDefinePath(canvas)
|
|||||||
path.each do |point|
|
path.each do |point|
|
||||||
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
|
points.push(PointSprite.new(point[0], point[1], canvas.viewport))
|
||||||
end
|
end
|
||||||
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
||||||
sliderwin2.visible = true
|
sliderwin2.visible = true
|
||||||
next
|
next
|
||||||
elsif sliderwin2.changed?(okbutton) && path
|
elsif sliderwin2.changed?(okbutton) && path
|
||||||
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
# File.open("pointpath.txt","wb") { |f| f.write(path.inspect) }
|
||||||
neededsize = canvas.currentframe + sliderwin2.value(0)
|
neededsize = canvas.currentframe + sliderwin2.value(0)
|
||||||
if neededsize > canvas.animation.length
|
if neededsize > canvas.animation.length
|
||||||
canvas.animation.resize(neededsize)
|
canvas.animation.resize(neededsize)
|
||||||
@@ -429,4 +432,5 @@ def pbDefinePath(canvas)
|
|||||||
points.clear
|
points.clear
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,27 +1,30 @@
|
|||||||
################################################################################
|
module BattleAnimationEditor
|
||||||
# Importing and exporting
|
module_function
|
||||||
################################################################################
|
|
||||||
def pbRgssChdir(dir)
|
|
||||||
RTP.eachPathFor(dir) { |path| Dir.chdir(path) { yield } }
|
|
||||||
end
|
|
||||||
|
|
||||||
def tryLoadData(file)
|
################################################################################
|
||||||
|
# Importing and exporting
|
||||||
|
################################################################################
|
||||||
|
def pbRgssChdir(dir)
|
||||||
|
RTP.eachPathFor(dir) { |path| Dir.chdir(path) { yield } }
|
||||||
|
end
|
||||||
|
|
||||||
|
def tryLoadData(file)
|
||||||
begin
|
begin
|
||||||
return load_data(file)
|
return load_data(file)
|
||||||
rescue
|
rescue
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def dumpBase64Anim(s)
|
def dumpBase64Anim(s)
|
||||||
return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/, "\r\n")
|
return [Zlib::Deflate.deflate(Marshal.dump(s))].pack("m").gsub(/\n/, "\r\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
def loadBase64Anim(s)
|
def loadBase64Anim(s)
|
||||||
return Marshal.restore(Zlib::Inflate.inflate(s.unpack("m")[0]))
|
return Marshal.restore(Zlib::Inflate.inflate(s.unpack("m")[0]))
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbExportAnim(animations)
|
def pbExportAnim(animations)
|
||||||
filename = pbMessageFreeText(_INTL("Enter a filename."), "", false, 32)
|
filename = pbMessageFreeText(_INTL("Enter a filename."), "", false, 32)
|
||||||
if filename != ""
|
if filename != ""
|
||||||
begin
|
begin
|
||||||
@@ -39,9 +42,9 @@ def pbExportAnim(animations)
|
|||||||
pbMessage(_INTL("It's a text file, so it can be transferred to others easily."))
|
pbMessage(_INTL("It's a text file, so it can be transferred to others easily."))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbImportAnim(animations, canvas, animwin)
|
def pbImportAnim(animations, canvas, animwin)
|
||||||
animfiles = []
|
animfiles = []
|
||||||
pbRgssChdir(".") { animfiles.concat(Dir.glob("*.anm")) }
|
pbRgssChdir(".") { animfiles.concat(Dir.glob("*.anm")) }
|
||||||
cmdwin = pbListWindow(animfiles, 320)
|
cmdwin = pbListWindow(animfiles, 320)
|
||||||
@@ -78,12 +81,12 @@ def pbImportAnim(animations, canvas, animwin)
|
|||||||
end
|
end
|
||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Format conversion
|
# Format conversion
|
||||||
################################################################################
|
################################################################################
|
||||||
def pbConvertAnimToNewFormat(textdata)
|
def pbConvertAnimToNewFormat(textdata)
|
||||||
needconverting = false
|
needconverting = false
|
||||||
textdata.length.times do |i|
|
textdata.length.times do |i|
|
||||||
next if !textdata[i]
|
next if !textdata[i]
|
||||||
@@ -120,9 +123,9 @@ def pbConvertAnimToNewFormat(textdata)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return needconverting
|
return needconverting
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbConvertAnimsToNewFormat
|
def pbConvertAnimsToNewFormat
|
||||||
pbMessage(_INTL("Will convert animations now."))
|
pbMessage(_INTL("Will convert animations now."))
|
||||||
count = 0
|
count = 0
|
||||||
animations = pbLoadBattleAnimations
|
animations = pbLoadBattleAnimations
|
||||||
@@ -140,4 +143,5 @@ def pbConvertAnimsToNewFormat
|
|||||||
$game_temp.battle_animations_data = nil
|
$game_temp.battle_animations_data = nil
|
||||||
end
|
end
|
||||||
pbMessage(_INTL("{1} animations converted to new format.", count))
|
pbMessage(_INTL("{1} animations converted to new format.", count))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,29 +1,32 @@
|
|||||||
#===============================================================================
|
module BattleAnimationEditor
|
||||||
# Mini battle scene
|
module_function
|
||||||
#===============================================================================
|
|
||||||
class MiniBattler
|
#===============================================================================
|
||||||
|
# Mini battle scene
|
||||||
|
#===============================================================================
|
||||||
|
class MiniBattler
|
||||||
attr_accessor :index
|
attr_accessor :index
|
||||||
attr_accessor :pokemon
|
attr_accessor :pokemon
|
||||||
|
|
||||||
def initialize(index); self.index = index; end
|
def initialize(index); self.index = index; end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#
|
#
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
class MiniBattle
|
class MiniBattle
|
||||||
attr_accessor :battlers
|
attr_accessor :battlers
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@battlers = []
|
@battlers = []
|
||||||
4.times { |i| @battlers[i] = MiniBattler.new(i) }
|
4.times { |i| @battlers[i] = MiniBattler.new(i) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Pop-up menus for buttons in bottom menu
|
# Pop-up menus for buttons in bottom menu
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbSelectAnim(canvas, animwin)
|
def pbSelectAnim(canvas, animwin)
|
||||||
animfiles = []
|
animfiles = []
|
||||||
pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) }
|
pbRgssChdir(File.join("Graphics", "Animations")) { animfiles.concat(Dir.glob("*.png")) }
|
||||||
cmdwin = pbListWindow(animfiles, 320)
|
cmdwin = pbListWindow(animfiles, 320)
|
||||||
@@ -60,9 +63,9 @@ def pbSelectAnim(canvas, animwin)
|
|||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
ctlwin.dispose
|
ctlwin.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbChangeMaximum(canvas)
|
def pbChangeMaximum(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 4)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 4)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.addSlider(_INTL("Frames:"), 1, 1000, canvas.animation.length)
|
sliderwin2.addSlider(_INTL("Frames:"), 1, 1000, canvas.animation.length)
|
||||||
@@ -83,9 +86,9 @@ def pbChangeMaximum(canvas)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbAnimName(animation, cmdwin)
|
def pbAnimName(animation, cmdwin)
|
||||||
window = ControlWindow.new(320, 128, 320, 32 * 4)
|
window = ControlWindow.new(320, 128, 320, 32 * 4)
|
||||||
window.z = 99999
|
window.z = 99999
|
||||||
window.addControl(TextField.new(_INTL("New Name:"), animation.name))
|
window.addControl(TextField.new(_INTL("New Name:"), animation.name))
|
||||||
@@ -109,9 +112,9 @@ def pbAnimName(animation, cmdwin)
|
|||||||
window.dispose
|
window.dispose
|
||||||
Input.text_input = false
|
Input.text_input = false
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbAnimList(animations, canvas, animwin)
|
def pbAnimList(animations, canvas, animwin)
|
||||||
commands = []
|
commands = []
|
||||||
animations.length.times do |i|
|
animations.length.times do |i|
|
||||||
animations[i] = PBAnimation.new if !animations[i]
|
animations[i] = PBAnimation.new if !animations[i]
|
||||||
@@ -177,12 +180,12 @@ def pbAnimList(animations, canvas, animwin)
|
|||||||
helpwindow.dispose
|
helpwindow.dispose
|
||||||
maxsizewindow.dispose
|
maxsizewindow.dispose
|
||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Pop-up menus for individual cels
|
# Pop-up menus for individual cels
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbChooseNum(cel)
|
def pbChooseNum(cel)
|
||||||
ret = cel
|
ret = cel
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5)
|
||||||
sliderwin2.z = 99999
|
sliderwin2.z = 99999
|
||||||
@@ -205,9 +208,9 @@ def pbChooseNum(cel)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSetTone(cel, previewsprite)
|
def pbSetTone(cel, previewsprite)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
||||||
sliderwin2.z = 99999
|
sliderwin2.z = 99999
|
||||||
sliderwin2.addSlider(_INTL("Red Offset:"), -255, 255, cel[AnimFrame::TONERED])
|
sliderwin2.addSlider(_INTL("Red Offset:"), -255, 255, cel[AnimFrame::TONERED])
|
||||||
@@ -235,9 +238,9 @@ def pbSetTone(cel, previewsprite)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSetFlash(cel, previewsprite)
|
def pbSetFlash(cel, previewsprite)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 320)
|
||||||
sliderwin2.z = 99999
|
sliderwin2.z = 99999
|
||||||
sliderwin2.addSlider(_INTL("Red:"), 0, 255, cel[AnimFrame::COLORRED])
|
sliderwin2.addSlider(_INTL("Red:"), 0, 255, cel[AnimFrame::COLORRED])
|
||||||
@@ -265,9 +268,9 @@ def pbSetFlash(cel, previewsprite)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCellProperties(canvas)
|
def pbCellProperties(canvas)
|
||||||
cel = canvas.currentCel.clone # Clone cell, in case operation is canceled
|
cel = canvas.currentCel.clone # Clone cell, in case operation is canceled
|
||||||
return if !cel
|
return if !cel
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 16)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 16)
|
||||||
@@ -365,12 +368,12 @@ def pbCellProperties(canvas)
|
|||||||
previewsprite.dispose
|
previewsprite.dispose
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
# Pop-up menus for buttons in right hand menu
|
# Pop-up menus for buttons in right hand menu
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
def pbTimingList(canvas)
|
def pbTimingList(canvas)
|
||||||
commands = []
|
commands = []
|
||||||
cmdNewSound = -1
|
cmdNewSound = -1
|
||||||
cmdNewBG = -1
|
cmdNewBG = -1
|
||||||
@@ -498,16 +501,16 @@ def pbTimingList(canvas)
|
|||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
framewindow.dispose
|
framewindow.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSelectSE(canvas, audio)
|
def pbSelectSE(canvas, audio)
|
||||||
filename = (audio.name != "") ? audio.name : ""
|
filename = (audio.name != "") ? audio.name : ""
|
||||||
displayname = (filename != "") ? filename : _INTL("<user's cry>")
|
displayname = (filename != "") ? filename : _INTL("<user's cry>")
|
||||||
animfiles = []
|
animfiles = []
|
||||||
ret = false
|
ret = false
|
||||||
pbRgssChdir(File.join("Audio", "SE", "Anim")) do
|
pbRgssChdir(File.join("Audio", "SE", "Anim")) do
|
||||||
animfiles.concat(Dir.glob("*.wav"))
|
animfiles.concat(Dir.glob("*.wav"))
|
||||||
# animfiles.concat(Dir.glob("*.mp3"))
|
# animfiles.concat(Dir.glob("*.mp3"))
|
||||||
animfiles.concat(Dir.glob("*.ogg"))
|
animfiles.concat(Dir.glob("*.ogg"))
|
||||||
animfiles.concat(Dir.glob("*.wma"))
|
animfiles.concat(Dir.glob("*.wma"))
|
||||||
end
|
end
|
||||||
@@ -533,9 +536,8 @@ def pbSelectSE(canvas, audio)
|
|||||||
Input.update
|
Input.update
|
||||||
cmdwin.update
|
cmdwin.update
|
||||||
maxsizewindow.update
|
maxsizewindow.update
|
||||||
if maxsizewindow.changed?(3) && animfiles.length > 0 # Play Sound
|
if maxsizewindow.changed?(3) && animfiles.length > 0 && filename != "" # Play Sound
|
||||||
fname = (cmdwin.index == 0) ? "Cries/000" : "Anim/" + filename
|
pbSEPlay(RPG::AudioFile.new("Anim/" + filename, maxsizewindow.value(1), maxsizewindow.value(2)))
|
||||||
pbSEPlay(RPG::AudioFile.new(fname, maxsizewindow.value(1), maxsizewindow.value(2)))
|
|
||||||
end
|
end
|
||||||
pbSEStop if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound
|
pbSEStop if maxsizewindow.changed?(4) && animfiles.length > 0 # Stop Sound
|
||||||
if maxsizewindow.changed?(5) # OK
|
if maxsizewindow.changed?(5) # OK
|
||||||
@@ -557,9 +559,9 @@ def pbSelectSE(canvas, audio)
|
|||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
maxsizewindow.dispose
|
maxsizewindow.dispose
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbSelectBG(canvas, timing)
|
def pbSelectBG(canvas, timing)
|
||||||
filename = timing.name
|
filename = timing.name
|
||||||
cmdErase = -1
|
cmdErase = -1
|
||||||
animfiles = []
|
animfiles = []
|
||||||
@@ -568,9 +570,9 @@ def pbSelectBG(canvas, timing)
|
|||||||
pbRgssChdir(File.join("Graphics", "Animations")) do
|
pbRgssChdir(File.join("Graphics", "Animations")) do
|
||||||
animfiles.concat(Dir.glob("*.png"))
|
animfiles.concat(Dir.glob("*.png"))
|
||||||
animfiles.concat(Dir.glob("*.gif"))
|
animfiles.concat(Dir.glob("*.gif"))
|
||||||
# animfiles.concat(Dir.glob("*.jpg"))
|
# animfiles.concat(Dir.glob("*.jpg"))
|
||||||
# animfiles.concat(Dir.glob("*.jpeg"))
|
# animfiles.concat(Dir.glob("*.jpeg"))
|
||||||
# animfiles.concat(Dir.glob("*.bmp"))
|
# animfiles.concat(Dir.glob("*.bmp"))
|
||||||
end
|
end
|
||||||
animfiles.uniq!
|
animfiles.uniq!
|
||||||
animfiles.sort! { |a, b| a.downcase <=> b.downcase }
|
animfiles.sort! { |a, b| a.downcase <=> b.downcase }
|
||||||
@@ -619,9 +621,9 @@ def pbSelectBG(canvas, timing)
|
|||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
maxsizewindow.dispose
|
maxsizewindow.dispose
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbEditBG(canvas, timing)
|
def pbEditBG(canvas, timing)
|
||||||
ret = false
|
ret = false
|
||||||
maxsizewindow = ControlWindow.new(0, 0, 320, 32 * 11)
|
maxsizewindow = ControlWindow.new(0, 0, 320, 32 * 11)
|
||||||
maxsizewindow.addSlider(_INTL("Duration:"), 0, 50, timing.duration)
|
maxsizewindow.addSlider(_INTL("Duration:"), 0, 50, timing.duration)
|
||||||
@@ -674,9 +676,9 @@ def pbEditBG(canvas, timing)
|
|||||||
end
|
end
|
||||||
maxsizewindow.dispose
|
maxsizewindow.dispose
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCopyFrames(canvas)
|
def pbCopyFrames(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 6)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 6)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
||||||
@@ -721,9 +723,9 @@ def pbCopyFrames(canvas)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbClearFrames(canvas)
|
def pbClearFrames(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 5)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
||||||
@@ -749,9 +751,9 @@ def pbClearFrames(canvas)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbTweening(canvas)
|
def pbTweening(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 10)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 10)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.opacity = 200
|
sliderwin2.opacity = 200
|
||||||
@@ -826,9 +828,9 @@ def pbTweening(canvas)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbCellBatch(canvas)
|
def pbCellBatch(canvas)
|
||||||
sliderwin1 = ControlWindow.new(0, 0, 300, 32 * 5)
|
sliderwin1 = ControlWindow.new(0, 0, 300, 32 * 5)
|
||||||
sliderwin1.viewport = canvas.viewport
|
sliderwin1.viewport = canvas.viewport
|
||||||
sliderwin1.opacity = 200
|
sliderwin1.opacity = 200
|
||||||
@@ -891,9 +893,9 @@ def pbCellBatch(canvas)
|
|||||||
end
|
end
|
||||||
sliderwin1.dispose
|
sliderwin1.dispose
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbEntireSlide(canvas)
|
def pbEntireSlide(canvas)
|
||||||
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 7)
|
sliderwin2 = ControlWindow.new(0, 0, 320, 32 * 7)
|
||||||
sliderwin2.viewport = canvas.viewport
|
sliderwin2.viewport = canvas.viewport
|
||||||
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
sliderwin2.addSlider(_INTL("First Frame:"), 1, canvas.animation.length, 1)
|
||||||
@@ -923,9 +925,9 @@ def pbEntireSlide(canvas)
|
|||||||
end
|
end
|
||||||
sliderwin2.dispose
|
sliderwin2.dispose
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
def pbAnimEditorHelpWindow
|
def pbAnimEditorHelpWindow
|
||||||
helptext = "" +
|
helptext = "" +
|
||||||
"To add a cel to the scene, click on the canvas. The selected cel will have a black " +
|
"To add a cel to the scene, click on the canvas. The selected cel will have a black " +
|
||||||
"frame. After a cel is selected, you can modify its properties using the keyboard:\n" +
|
"frame. After a cel is selected, you can modify its properties using the keyboard:\n" +
|
||||||
@@ -943,12 +945,13 @@ def pbAnimEditorHelpWindow
|
|||||||
break if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
|
break if Input.trigger?(Input::BACK) || Input.trigger?(Input::USE)
|
||||||
end
|
end
|
||||||
cmdwin.dispose
|
cmdwin.dispose
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#=============================================================================
|
||||||
# Main
|
# Main
|
||||||
#===============================================================================
|
#=============================================================================
|
||||||
def animationEditorMain(animation)
|
def animationEditorMain(animation)
|
||||||
|
echoln animation.selected
|
||||||
viewport = Viewport.new(0, 0, Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288)
|
viewport = Viewport.new(0, 0, Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288)
|
||||||
viewport.z = 99999
|
viewport.z = 99999
|
||||||
# Canvas
|
# Canvas
|
||||||
@@ -1109,7 +1112,7 @@ def animationEditorMain(animation)
|
|||||||
indexes = [2, 1, 3, 4] # Keeping backwards compatibility
|
indexes = [2, 1, 3, 4] # Keeping backwards compatibility
|
||||||
positions.length.times do |i|
|
positions.length.times do |i|
|
||||||
selected = "[ ]"
|
selected = "[ ]"
|
||||||
selected = "[x]" if animation[animation.selected].position == indexes[i]
|
selected = "[X]" if animation[animation.selected].position == indexes[i]
|
||||||
positions[i] = sprintf("%s %s", selected, positions[i])
|
positions[i] = sprintf("%s %s", selected, positions[i])
|
||||||
end
|
end
|
||||||
pos = pbShowCommands(nil, positions, -1)
|
pos = pbShowCommands(nil, positions, -1)
|
||||||
@@ -1148,6 +1151,7 @@ def animationEditorMain(animation)
|
|||||||
bottomwindow.dispose
|
bottomwindow.dispose
|
||||||
viewport.dispose
|
viewport.dispose
|
||||||
RPG::Cache.clear
|
RPG::Cache.clear
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
@@ -1162,7 +1166,7 @@ def pbAnimationEditor
|
|||||||
end
|
end
|
||||||
Graphics.resize_screen(Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288)
|
Graphics.resize_screen(Settings::SCREEN_WIDTH + 288, Settings::SCREEN_HEIGHT + 288)
|
||||||
pbSetResizeFactor(1)
|
pbSetResizeFactor(1)
|
||||||
animationEditorMain(animation)
|
BattleAnimationEditor.animationEditorMain(animation)
|
||||||
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
|
Graphics.resize_screen(Settings::SCREEN_WIDTH, Settings::SCREEN_HEIGHT)
|
||||||
pbSetResizeFactor($PokemonSystem.screensize)
|
pbSetResizeFactor($PokemonSystem.screensize)
|
||||||
$game_map&.autoplay
|
$game_map&.autoplay
|
||||||
|
|||||||
@@ -558,7 +558,7 @@ def pbExportAllAnimations
|
|||||||
safename = anim.name.gsub(/\W/, "_")
|
safename = anim.name.gsub(/\W/, "_")
|
||||||
Dir.mkdir("Animations/#{safename}") rescue nil
|
Dir.mkdir("Animations/#{safename}") rescue nil
|
||||||
File.open("Animations/#{safename}/#{safename}.anm", "wb") do |f|
|
File.open("Animations/#{safename}/#{safename}.anm", "wb") do |f|
|
||||||
f.write(dumpBase64Anim(anim))
|
f.write(BattleAnimationEditor.dumpBase64Anim(anim))
|
||||||
end
|
end
|
||||||
if anim.graphic && anim.graphic != ""
|
if anim.graphic && anim.graphic != ""
|
||||||
graphicname = RTP.getImagePath("Graphics/Animations/" + anim.graphic)
|
graphicname = RTP.getImagePath("Graphics/Animations/" + anim.graphic)
|
||||||
@@ -626,13 +626,13 @@ def pbImportAllAnimations
|
|||||||
pbSafeCopyFile(image, RTP.getImagePath("Graphics/Animations/" + File.basename(image)), "Graphics/Animations/" + File.basename(image))
|
pbSafeCopyFile(image, RTP.getImagePath("Graphics/Animations/" + File.basename(image)), "Graphics/Animations/" + File.basename(image))
|
||||||
end
|
end
|
||||||
Dir.glob(folder + "/*.anm") do |f|
|
Dir.glob(folder + "/*.anm") do |f|
|
||||||
textdata = loadBase64Anim(IO.read(f)) rescue nil
|
textdata = BattleAnimationEditor.loadBase64Anim(IO.read(f)) rescue nil
|
||||||
if textdata.is_a?(PBAnimation)
|
if textdata.is_a?(PBAnimation)
|
||||||
index = pbAllocateAnimation(animations, textdata.name)
|
index = pbAllocateAnimation(animations, textdata.name)
|
||||||
missingFiles = []
|
missingFiles = []
|
||||||
textdata.name = File.basename(folder) if textdata.name == ""
|
textdata.name = File.basename(folder) if textdata.name == ""
|
||||||
textdata.id = -1 # This is not an RPG Maker XP animation
|
textdata.id = -1 # This is not an RPG Maker XP animation
|
||||||
pbConvertAnimToNewFormat(textdata)
|
BattleAnimationEditor.pbConvertAnimToNewFormat(textdata)
|
||||||
if textdata.graphic && textdata.graphic != "" &&
|
if textdata.graphic && textdata.graphic != "" &&
|
||||||
!safeExists?(folder + "/" + textdata.graphic) &&
|
!safeExists?(folder + "/" + textdata.graphic) &&
|
||||||
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
|
!FileTest.image_exist?("Graphics/Animations/" + textdata.graphic)
|
||||||
|
|||||||
Reference in New Issue
Block a user