0% found this document useful (0 votes)
105 views16 pages

SJPlugins Updater

The document contains code for a script updater that handles updating multiple plugins created by Luka S.J. It includes functions for reading files and directories, copying and deleting files, and mathematical functions. It also extends the Sprite class with additional methods like drawing rectangles, blurring, and coloring sprites.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
105 views16 pages

SJPlugins Updater

The document contains code for a script updater that handles updating multiple plugins created by Luka S.J. It includes functions for reading files and directories, copying and deleting files, and mathematical functions. It also extends the Sprite class with additional methods like drawing rectangles, blurring, and coloring sprites.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 16

# 1.1.

0
# DO NOT ALTER THIS NUMBER! YOU WILL BREAK YOUR SYSTEM!
#===============================================================================
# S.J. Plugins
# by Luka S.J.
# ----------------
# Updater Script
# ----------------
# The main master system used to globally handle all scripts made by Luka S.J.
# After the auto installation process, it keeps all the various plugins
# collectively stored in one neat place.
#
# Enjoy the scripts, and make sure to give credit when using them!
# (DO NOT ALTER THE NAMES OF THE INDIVIDUAL SCRIPT SECTIONS OR YOU WILL BREAK
# YOUR SYSTEM!)
#
# Collection of scripts used to automatically update all of the S.J. Plugins.
# DO NOT ALTER ANY PORTIONS OF THIS SCRIPT SECTION!
# Failing to do so may result in BREAKING YOUR GAME!
#-------------------------------------------------------------------------------
# ** Data Handlers
#-------------------------------------------------------------------------------
# Various functions used to locate folders and read folder contents
#===============================================================================
# Reads all files in a directory
#-------------------------------------------------------------------------------
def readAllFiles(directory,path=false)
files=[]
Dir.chdir(directory){Dir.glob("*"){|f|
file = (path) ? directory+"\\"+f : f
files.push(file)
}}
return files
end
#-------------------------------------------------------------------------------
# Reads files of certain format from a directory
#-------------------------------------------------------------------------------
def readDirectoryFiles(directory,formats)
files=[]
Dir.chdir(directory){
for i in 0...formats.length
Dir.glob(formats[i]){|f| files.push(f) }
end
}
return files
end
#-------------------------------------------------------------------------------
# Generates entire file/folder tree from a certain directory
#-------------------------------------------------------------------------------
def grabAllFiles(directory)
if FileTest.directory?(directory)
dirs = []
dirsf = [directory]
files = readAllFiles(directory,true)
length = 0
loop do
length = files.length
for file in files
if FileTest.directory?(file)
dirs.push(file)
dirsf.push(file)
files.delete(file)
end
end
dirs.uniq!
for dir in dirs
files+=readAllFiles(dir,true)
end
files.uniq!
break if length==files.length
end
dirsf.uniq!
n = files.length-1
for i in 0..n
files.delete_at(n-i) if FileTest.directory?(files[n-i])
end
files.reverse!
dirsf.reverse!
return [files,dirsf]
else
return [[],[]]
end
end
#-------------------------------------------------------------------------------
# Additional file manipulation methods
#-------------------------------------------------------------------------------
class File
#-----------------------------------------------------------------------------
# Generates an entire file tree to delete all files and folders inside folder
#-----------------------------------------------------------------------------
def self.deleteAny(file)
if FileTest.directory?(file)
files, dirs = grabAllFiles(file)
for file in files
self.delete(file) if FileTest.exist?(file)
end
for dir in dirs
Dir.rmdir(dir) if FileTest.exist?(dir)
end
else
self.delete(file)
end
end
#-----------------------------------------------------------------------------
# Copies files (with a suffix if necessary)
#-----------------------------------------------------------------------------
def self.copy(file, dest, suffix = true)
copy = File.basename(dest)
dir = File.dirname(dest)+"\\"
if FileTest.exist?(dir+copy) && suffix
ext = File.extname(copy)
base = File.basename(copy,".*")
copy = base+" - copy"+ext
i = 2
loop do
break if !FileTest.exist?(dir+copy)
copy = base+" - copy (#{i})"+ext
i+=1
end
end
dest = dir+copy
File.open(file, 'rb') {|r|
File.open(dest, 'wb') {|w|
while s = r.read(4096)
w.write s
end
}
}
end
end
#-------------------------------------------------------------------------------
# Mathematical functions
#-------------------------------------------------------------------------------
# generates a uniform polygon based on the number of points, radius (for x and y),
# angle and coordinates of its origin
def getPolygonPoints(n,rx=50,ry=50,a=0,tx=Graphics.width/2,ty=Graphics.height/2)
points = []
ang = 360/n
n.times do
b = a*(Math::PI/180)
r = rx*Math.cos(b).abs + ry*Math.sin(b).abs
x = tx + r*Math.cos(b)
y = ty - r*Math.sin(b)
points.push([x,y])
a += ang
end
return points
end

def randCircleCord(r,x=nil)
x = rand(r*2) if x.nil?
y1 = -Math.sqrt(r**2 - (x - r)**2)
y2 = Math.sqrt(r**2 - (x - r)**2)
return x, (rand(2)==0 ? y1.to_i : y2.to_i) + r
end
#-------------------------------------------------------------------------------
# Extensions for classes
#-------------------------------------------------------------------------------
# additional String functionality
class ::String
def starts_with?(char)
proc = self.scan(/./)
return (proc[0] == char) ? true : false
end
end
# additional Sprite functionality
class Sprite
attr_reader :storedBitmap
attr_accessor :speed
attr_accessor :toggle
attr_accessor :end_x
attr_accessor :end_y
attr_accessor :param

def drawRect(width,height,color)
self.bitmap = Bitmap.new(width,height)
self.bitmap.fill_rect(0,0,width,height,color)
end

def snapScreen
bmp = Graphics.snap_to_bitmap
width = self.viewport ? viewport.rect.width : Graphics.width
height = self.viewport ? viewport.rect.height : Graphics.height
x = self.viewport ? viewport.rect.x : 0
y = self.viewport ? viewport.rect.y : 0
self.bitmap = Bitmap.new(width,height)
self.bitmap.blt(0,0,bmp,Rect.new(x,y,width,height))
end

def skew(angle=90)
return false if !self.bitmap
angle=angle*(Math::PI/180)
bitmap=self.bitmap
rect=Rect.new(0,0,bitmap.width,bitmap.height)
width=rect.width+((rect.height-1)/Math.tan(angle))
self.bitmap=Bitmap.new(width,rect.height)
for i in 0...rect.height
y=rect.height-i
x=i/Math.tan(angle)
self.bitmap.blt(x+rect.x,y+rect.y,bitmap,Rect.new(0,y,rect.width,1))
end
end

def blur_sprite(blur_val=2,opacity=35)
bitmap = self.bitmap
self.bitmap = Bitmap.new(bitmap.width,bitmap.height)
self.bitmap.blt(0,0,bitmap,Rect.new(0,0,bitmap.width,bitmap.height))
x=0
y=0
for i in 1...(8 * blur_val)
dir = i % 8
x += (1 + (i / 8))*([0,6,7].include?(dir) ? -1 : 1)*([1,5].include?(dir) ?
0 : 1)
y += (1 + (i / 8))*([1,4,5,6].include?(dir) ? -1 : 1)*([3,7].include?(dir) ?
0 : 1)
self.bitmap.blt(x-blur_val,y+
(blur_val*2),bitmap,Rect.new(0,0,bitmap.width,bitmap.height),opacity)
end
end

def getAvgColor(freq=2)
return Color.new(0,0,0,0) if !self.bitmap
bmp = self.bitmap
width = self.bitmap.width/freq
height = self.bitmap.height/freq
red = 0
green = 0
blue = 0
n = width*height
for x in 0...width
for y in 0...height
color = bmp.get_pixel(x*freq,y*freq)
if color.alpha > 0
red += color.red
green += color.green
blue += color.blue
end
end
end
avg = Color.new(red/n,green/n,blue/n)
return avg
end

def create_outline(color,thickness=2,hard=false)
return false if !self.bitmap
bmp = self.bitmap.clone
self.bitmap = Bitmap.new(bmp.width,bmp.height)
for x in 0...bmp.width-thickness
for y in 0...bmp.height
pixel = bmp.get_pixel(x,y)
if pixel.alpha > 0
for i in 1..thickness
c1 = bmp.get_pixel(x,y-i)
c2 = bmp.get_pixel(x,y+i)
c3 = bmp.get_pixel(x-i,y)
c4 = bmp.get_pixel(x+i,y)
self.bitmap.set_pixel(x,y-i,color) if c1.alpha <= 0
self.bitmap.set_pixel(x,y+i,color) if c2.alpha <= 0
self.bitmap.set_pixel(x-i,y,color) if c3.alpha <= 0
self.bitmap.set_pixel(x+i,y,color) if c4.alpha <= 0
end
end
end
end
self.bitmap.blt(0,0,bmp,Rect.new(0,0,bmp.width,bmp.height))
end

def colorize(color)
return false if !self.bitmap
bmp = self.bitmap.clone
self.bitmap = Bitmap.new(bmp.width,bmp.height)
for x in 0...bmp.width
for y in 0...bmp.height
pixel = bmp.get_pixel(x,y)
self.bitmap.set_pixel(x,y,color) if pixel.alpha > 0
end
end
end

def glow(color,opacity=35,keep=true)
return false if !self.bitmap
temp_bmp = self.bitmap.clone
self.colorize(color)
self.blur_sprite(3,opacity)
src = self.bitmap.clone
self.bitmap.clear
self.bitmap.stretch_blt(Rect.new(-0.005*src.width,-
0.015*src.height,src.width*1.01,1.02*src.height),src,Rect.new(0,0,src.width,src.hei
ght))
self.bitmap.blt(0,0,temp_bmp,Rect.new(0,0,temp_bmp.width,temp_bmp.height)) if
keep
end

def fuzz(color,opacity=35)
return false if !self.bitmap
self.colorize(color)
self.blur_sprite(3,opacity)
src = self.bitmap.clone
self.bitmap.clear
self.bitmap.stretch_blt(Rect.new(-0.005*src.width,-
0.015*src.height,src.width*1.01,1.02*src.height),src,Rect.new(0,0,src.width,src.hei
ght))
end

def memorize_bitmap(bitmap = nil)


@storedBitmap = bitmap if !bitmap.nil?
@storedBitmap = self.bitmap.clone if bitmap.nil?
end
def restore_bitmap
self.bitmap = @storedBitmap.clone
end

def toneAll(val)
self.tone.red += val
self.tone.green += val
self.tone.blue += val
end

def onlineBitmap(url)
pbDownloadToFile(url,"_temp.png")
return if !FileTest.exist?("_temp.png")
self.bitmap = pbBitmap("_temp")
File.delete("_temp.png")
end
end
# additional Bitmap functionality
class Bitmap
def drawCircle(color=Color.new(255,255,255),r=(self.width/2),tx=(self.width/
2),ty=(self.height/2),hollow=false)
self.clear
# basic circle formula
# (x - tx)**2 + (y - ty)**2 = r**2
for x in 0...self.width
y1 = -Math.sqrt(r**2 - (x - tx)**2).to_i + ty
y2 = Math.sqrt(r**2 - (x - tx)**2).to_i + ty
if hollow
self.set_pixel(x,y1,color)
self.set_pixel(x,y2,color)
else
for y in y1..y2
self.set_pixel(x,y,color)
end
end
end
end
end
#-------------------------------------------------------------------------------
# Class used for generating scrolling backgrounds (move animations)
#-------------------------------------------------------------------------------
class ScrollingSprite < Sprite
attr_accessor :speed
attr_accessor :direction
attr_accessor :vertical
def setBitmap(val,vertical=false,pulse=false)
@vertical = vertical
@pulse = pulse
@direction = 1 if @direction.nil?
@gopac = 1
@speed = 32 if @speed.nil?
val = pbBitmap(val) if val.is_a?(String)
if @vertical
bmp = Bitmap.new(val.width,val.height*2)
for i in 0...2
bmp.blt(0,val.height*i,val,Rect.new(0,0,val.width,val.height))
end
self.bitmap = bmp.clone
y = @direction > 0 ? 0 : val.height
self.src_rect.set(0,y,val.width,val.height)
else
bmp = Bitmap.new(val.width*2,val.height)
for i in 0...2
bmp.blt(val.width*i,0,val,Rect.new(0,0,val.width,val.height))
end
self.bitmap = bmp.clone
x = @direction > 0 ? 0 : val.width
self.src_rect.set(x,0,val.width,val.height)
end
end

def update
if @vertical
self.src_rect.y += @speed*@direction
self.src_rect.y = 0 if @direction > 0 && self.src_rect.y >=
self.src_rect.height
self.src_rect.y = self.src_rect.height if @direction < 0 && self.src_rect.y
<= 0
else
self.src_rect.x += @speed*@direction
self.src_rect.x = 0 if @direction > 0 && self.src_rect.x >=
self.src_rect.width
self.src_rect.x = self.src_rect.width if @direction < 0 && self.src_rect.x <=
0
end
if @pulse
self.opacity -= @gopac*@speed
@gopac *= -1 if self.opacity == 255 || self.opacity == 0
end
end

end
#-------------------------------------------------------------------------------
# Class used to render the background for the special S&M trainer battle
# animation
#-------------------------------------------------------------------------------
class RainbowSprite < Sprite
attr_accessor :speed
def setBitmap(val,speed = 1)
@val = val
@val = pbBitmap(val) if val.is_a?(String)
@speed = speed
self.bitmap = Bitmap.new(@val.width,@val.height)
self.bitmap.blt(0,0,@val,Rect.new(0,0,@val.width,@val.height))
@current_hue = 0
end

def update
self.bitmap.clear
self.bitmap.blt(0,0,@val,Rect.new(0,0,@val.width,@val.height))
self.bitmap.hue_change(@current_hue)
@current_hue += @speed
@current_hue = 0 if @current_hue >= 360
end
end
#-------------------------------------------------------------------------------
# Common UI handlers
#-------------------------------------------------------------------------------
class CommonButton < Sprite
def setButton(size="M",var=1,text="")
bmp = pbBitmap("Graphics/Pictures/Common/btn#{size}_#{var}")
pbSetSmallFont(bmp)
case size
when "M"
x, y, w, h = 46, 22, 92, 38
when "L"
x, y, w, h = 61, 22, 122, 38
end
color = self.darkenColor(bmp.get_pixel(x, y))
self.bitmap = Bitmap.new(bmp.width - 22, bmp.height)
pbSetSmallFont(self.bitmap)
self.bitmap.blt(0, 0, bmp, Rect.new(0, 0, bmp.width - 22, bmp.height))
pbDrawOutlineText(self.bitmap,2,2,w,h,text,Color.new(255,255,255),color,1)
end

def darkenColor(color=nil,amt=0.6)
return nil if color.nil?
red = color.red - color.red*amt
green = color.green - color.green*amt
blue = color.blue - color.blue*amt
return Color.new(red,green,blue)
end
end
#-------------------------------------------------------------------------------
# Misc scripting utilities
#-------------------------------------------------------------------------------
def pbBitmap(name)
if !pbResolveBitmap(name).nil?
bmp = BitmapCache.load_bitmap(name)
else
p "Image located at '#{name}' was not found!" if $DEBUG
bmp = Bitmap.new(1,1)
end
return bmp
end
#-------------------------------------------------------------------------------
# F12 Soft-resetting fix
#-------------------------------------------------------------------------------
if defined?(SOFTRESETFIX) && SOFTRESETFIX
unless $f12_fix.nil?
game_name = "Game"
if $DEBUG
Thread.new{system(game_name+" debug")}
else
Thread.new{system(game_name)}
end
exit
end
$f12_fix = true
end
#===============================================================================
# New methods used to inject new code into Scripts.rxdata
#-------------------------------------------------------------------------------
# Backs up your current scripts to prevent any permanent damage
#-------------------------------------------------------------------------------
def backupScriptData(file_name = nil)
if file_name.nil?
ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
scripts_filename = "\0" * 256
ini.call('Game', 'Scripts', '', scripts_filename, 256, '.\\Game.ini')
scripts_filename.delete!("\0")
else
scripts_filename = file_name
end
File.copy(scripts_filename, scripts_filename+".bak",false)
end
#-------------------------------------------------------------------------------
# Returns all possible data read from the game's scripts
#-------------------------------------------------------------------------------
def getScriptData(file_name = nil)
# Backs up the Scripts
backupScriptData(file_name)
# Gets Scripts filename from the .ini file
if file_name.nil?
ini = Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
scripts_filename = "\0" * 256
ini.call('Game', 'Scripts', '', scripts_filename, 256, '.\\Game.ini')
scripts_filename.delete!("\0")
else
scripts_filename = file_name
end

scripts = load_data(scripts_filename)
names = []
codes = []
# Reads all the currently existing scripts, and stores them for later
manipulation
for script in scripts
id, name, code = script
next if id.nil?
code = Zlib::Inflate.inflate(code)
code.gsub!(/\t/) {' '}
names.push(name)
codes.push(code)
end
return names, codes, scripts_filename
end
#-------------------------------------------------------------------------------
# Returns one specific script from the game's scripts
#-------------------------------------------------------------------------------
def getSpecificScript(name = "Main")
# Fetches all the necessary Scripts data
names, codes, scripts_filename = getScriptData
# Gets the location index of script from name
if name.is_a?(String)
index = names.index(name)
elsif name.is_a?(Numeric)
index = name
else
return # failsafe
end
# Returns selected script
return codes[index]
end
#-------------------------------------------------------------------------------
# Returns one specific script Name from the game's scripts
#-------------------------------------------------------------------------------
def getScriptNameContaining(string = "")
# Fetches all the necessary Scripts data
names, codes, scripts_filename = getScriptData
j = 0
for i in 0...names.length
j = i
break if codes[i].include?(string)
end
# Returns script's name
return names[j] == "Main" ? nil : names[j]
end
#-------------------------------------------------------------------------------
# Checks whether or not a certain script name exists
#-------------------------------------------------------------------------------
def scriptExists?(name = "Main")
# Fetches all the necessary Scripts data
names, codes, scripts_filename = getScriptData
# Whether or not the script exists
return names.include?(name)
end
#-------------------------------------------------------------------------------
# Injects a new custom script directly above main
#-------------------------------------------------------------------------------
def injectCustomScript(script_name = "", file_name = nil, offset = 0)
# Fetches all the necessary Scripts data
names, codes, scripts_filename = getScriptData
# Loads up the main Scripts file
scripts_file = File.open(scripts_filename, "rb")
f = Marshal.load(scripts_file)
scripts_file.close
# Injects the new plugin system into Scripts.rxdata
if file_name.nil?
code = ''
elsif FileTest.exist?(file_name)
if File.extname(file_name) == ".rxdata"
code = decryptScript(file_name)
code.gsub!(/\t/) {' '}
else
script = File.open(file_name, "r+")
code = script.read
code.gsub!(/\t/) {' '}
script.close
end
elsif file_name.is_a?(String)
code = file_name
code.gsub!(/\t/) {' '}
end
name = script_name
i = names.length - (1 + offset)
i -= 1 if names[i] == "Main"
names.insert(i, name)
codes.insert(i, code)
# Encrypts all the necessary scripts into original format
for i in 0...codes.length
name = names[i]
code = codes[i]
z = Zlib::Deflate.new(6)
data = z.deflate(code, Zlib::FINISH)
f[i] = [i] if f[i].nil?
f[i][1] = name
f[i][2] = data
end
# Writes the new set of scripts to the main Scripts file
data = File.open(scripts_filename, "wb")
Marshal.dump(f[0, codes.length], data)
data.close
end
#-------------------------------------------------------------------------------
# Replaces an already existing script with a new version
#-------------------------------------------------------------------------------
def injectSpecificScript(script_name = "", file_name = nil, offset = 0)
# Fetches all the necessary Scripts data
names, codes, scripts_filename = getScriptData
# Loads up the main Scripts file
scripts_file = File.open(scripts_filename, "rb")
f = Marshal.load(scripts_file)
scripts_file.close
# Injects the new plugin system into Scripts.rxdata
if file_name.nil?
code = ''
elsif FileTest.exist?(file_name)
if File.extname(file_name) == ".rxdata"
code = decryptScript(file_name)
code.gsub!(/\t/) {' '}
else
script = File.open(file_name, "r+")
code = script.read
code.gsub!(/\t/) {' '}
script.close
end
elsif file_name.is_a?(String)
code = file_name
code.gsub!(/\t/) {' '}
end
name = script_name
i = names.index(script_name)
names[i] = name
codes[i] = code
# Encrypts all the necessary scripts into original format
for i in 0...codes.length
name = names[i]
code = codes[i]
z = Zlib::Deflate.new(6)
data = z.deflate(code, Zlib::FINISH)
f[i] = [i] if f[i].nil?
f[i][1] = name
f[i][2] = data
end
# Writes the new set of scripts to the main Scripts file
data = File.open(scripts_filename, "wb")
Marshal.dump(f[0, codes.length], data)
data.close
end
#-------------------------------------------------------------------------------
# Encrypts any readable input into .rxdata
#-------------------------------------------------------------------------------
def encryptScript(file_name = nil)
return if file_name.nil?
# Gets name of file and its directory
name = File.basename(file_name, ".*")
dir = File.dirname(file_name)
dir+="/"
dir = "" if dir == "./"
# Starts the encryption of the script
script = File.open(file_name, "r+")
code = script.read
code.gsub!(/\t/) {' '}
script.close
z = Zlib::Deflate.new(6)
data = z.deflate(code, Zlib::FINISH)
# Saves data to file
File.open("#{dir}#{name}.rxdata", "wb") {|f|
Marshal.dump(data, f)
}
end
#-------------------------------------------------------------------------------
# Decrypts the .rxdata and returns a readable output
#-------------------------------------------------------------------------------
def decryptScript(file_name = nil)
return if file_name.nil?
# Gets name of file and its directory
name = File.basename(file_name, ".*")
dir = File.dirname(file_name)
# Starts the decryption of the script
script = load_data(file_name)
code = Zlib::Inflate.inflate(script)
code.gsub!(/\t/) {' '}
return code
end
#===============================================================================
# Main function used to update the entire system
#===============================================================================
def beginAutoUpdate
# master file containing all the update details
master = pbDownloadToString("http://pastebin.com/raw/EjV2xApK")
return if master == ""
# individual script URLs and names
script_urls = [
"http://pastebin.com/raw/9jRPAmhW",
"http://pastebin.com/raw/q2VJM1xs",
"http://pastebin.com/raw/N8Ze8Hmj",
"http://pastebin.com/raw/BLN9yJZL",
"http://pastebin.com/raw/bXwZmAuM",
"http://pastebin.com/raw/tZJyBZYJ",
"http://pastebin.com/raw/DJQpX32H",
"http://pastebin.com/raw/jYcFkz1D",
"http://pastebin.com/raw/wRi5TvVn",
"http://pastebin.com/raw/wTX2Y1bH",
"http://pastebin.com/raw/JrHQSWc4",
"http://pastebin.com/raw/mcc91UEU",
"http://pastebin.com/raw/06KgA0Pw",
"http://pastebin.com/raw/b6hNzA9s",
"http://pastebin.com/raw/g2TwPr2D"
]
script_names = [
"EliteBattle_Battle",
"EliteBattle_Scene",
"EliteBattle_Animations",
"EliteBattle_UI",
"EliteBattle_Sprites",
"EliteBattle_BitmapWrapper",
"EliteBattle_EntryAnimations",
"EliteBattle_MoveAnimations",
"Resource_UltimateTitleScreen",
"Resource_EasyMouseSystem",
"Resource_SmartDownload",
"Resource_FancyBadges",
"Resource_WorldTournament",
"Resource_TradeExpert",
"SJPlugins_Updater"
]
# formatting of the master doc
lines = master.split("\r\n")
versions = []
files = []
k = -1
for i in 0...lines.length
line = lines[i]
if line.include?("[") && line.include?("]")
k += 1
files.push([])
line.gsub!("[") {|s| ""}
line.gsub!("]") {|s| ""}
temp = line.split(".")
for j in 0...temp.length
temp[j] = temp[j].to_i
end
temp.push(0) if temp.length < 3
versions.push(temp) unless line.starts_with?("#") || line == ""
else
files[k].push(line) unless line.starts_with?("#") || line == ""
end
end
# gets the current version of EBS installed
current = getSpecificScript("SJPlugins_Updater").split("\n")[0].gsub("#") {|s|
""}
current = current.split(".")
for i in 0...current.length
current[i] = current[i].to_i
end
current.push(0) if current.length < 3
# processes all the necessary files
to_download = []
for i in 0...versions.length
need = false
if current[0] < versions[i][0]
need = true
elsif current[1] < versions[i][1] && current[0] <= versions[i][0]
need = true
elsif current[2] < versions[i][2] && current[1] <= versions[i][1] && current[0]
<= versions[i][0]
need = true
end
if need
for file in files[i]
next if !file == "SJPlugins_Updater" && script_names.include?(file)
to_download.push(file)
end
end
end
to_download.uniq!
return if to_download.length < 1
Kernel.pbMessage("The system has detected that one or more of your plugins are
out of date.")
return if !Kernel.pbConfirmMessage("Would you like to update your plugins?")
to_download.push("SJPlugins_Updater") if !to_download.include?
("SJPlugins_Updater")
# logs the master file into a changelog
File.open("changelog.txt","wb") {|w| w.write(master)}
# creates a temporary progress bar
viewport = Viewport.new(0,0,Graphics.width,Graphics.height)
viewport.z = 999999

bar = Sprite.new(@viewport)
bar.bitmap = Bitmap.new(Graphics.width,34)
pbSetSystemFont(bar.bitmap)
# begins the downloading of all the files
Dir.mkdir("./_temp") if !FileTest.directory?("./_temp")
m = 0
for download in to_download
width = ((m*1.000)/to_download.length)*Graphics.width
bar.bitmap.clear
bar.bitmap.fill_rect(0,0,Graphics.width,34,Color.new(255,255,255))
bar.bitmap.fill_rect(0,0,Graphics.width,32,Color.new(0,0,0))
bar.bitmap.fill_rect(0,0,width,32,Color.new(25*4,90*2,25*4))
text =
[["#{m}/#{to_download.length}",Graphics.width/2,2,2,Color.new(255,255,255),nil]]
pbDrawTextPositions(bar.bitmap,text)
if script_names.include?(download)
index = script_names.index(download)
pbDownloadToFile(script_urls[index],"./_temp/#{download}")
else
url, dest = download.split(",")
if dest == "script"
code = pbDownloadToString(url)
eval(code)
else
dirs = dest.split("/"); dirs.delete_at(dirs.length-1)
s = ""
for dir in dirs
s += dir+"/"
Dir.mkdir(s) if !FileTest.directory?(s)
end
pbDownloadToFile(url,dest)
end
end
m += 1
Graphics.update
end
# applies any scripts if necessary
reads = readAllFiles("./_temp")
for read in reads
injectSpecificScript(read,"./_temp/#{read}") if scriptExists?(read)
end
bar.dispose
viewport.dispose
# deletes temporary files
File.deleteAny("./_temp")
# finishes up the update
Kernel.pbMessage("Update complete!")
Kernel.pbMessage("All the update information has been logged into
changelog.txt.")
Kernel.pbMessage("Please restart (without saving) your open RMXP Project for the
changes to take effect.")
exit
end

class PokemonLoad
alias loadWhenAutoUpdating pbStartLoadScreen unless self.method_defined?
(:loadWhenAutoUpdating)
def pbStartLoadScreen(*args)
beginAutoUpdate if $DEBUG && !Input.press?(Input::C)
return loadWhenAutoUpdating(*args)
end
end
#===============================================================================
# Don't touch these
# Used to configure the system for potential DS styles (leftovers)
#-----------------------------------------------------
VIEWPORT_HEIGHT = DEFAULTSCREENHEIGHT
VIEWPORT_OFFSET = 0
if VIEWPORT_OFFSET==0
if defined?(SCREEN_HEIGHT) # PEDS v2 (Venom12)
VIEWPORT_HEIGHT = SCREEN_HEIGHT
VIEWPORT_OFFSET = DEFAULTSCREENHEIGHT - SCREEN_HEIGHT*2
elsif defined?(SCREENDUALHEIGHT) # PEBW v3 (KleinStudio)
VIEWPORT_HEIGHT = DEFAULTSCREENHEIGHT
VIEWPORT_OFFSET = SCREENDUALHEIGHT - DEFAULTSCREENHEIGHT*2
end
end
DS_STYLE = (VIEWPORT_OFFSET > 0)
# Other system config
#-----------------------------------------------------
INCLUDEGEN6 = respond_to?(:pbForceEvo) ? true : false
EFFECTMESSAGES = false if INCLUDEGEN6
$memDebug = $DEBUG
$DEBUG = false if defined?(PLAY_ON_DEBUG) && (PLAY_ON_DEBUG || (Time.now.mon == 4
&& Time.now.day == 1))
#===============================================================================
# Returns the version of Pokemon Essentials running
#-------------------------------------------------------------------------------
def checkEssentialsVersion
if defined?(DUALSCREENHEIGHT)
version = "BW Kit"
elsif defined?(PokeBattle_Pokemon) && PokeBattle_Pokemon.method_defined?
(:hasAbility?)
version = 16.2
elsif defined?(PokemonBag) && PokemonBag.method_defined?(:pbHasItem?)
version = 16.1
elsif defined?(ItemIconSprite)
version = 16.0
elsif defined?(PokeBattle_Trainer) && PokeBattle_Trainer.method_defined?
(:firstParty)
version = 15.1
elsif defined?(pbEnterNPCName)
version = 15.0
else
version = "(unknown)"
end
return version
end
# misc version checks
ESSENTIALS_VERSION = checkEssentialsVersion
def isVersion15?
return false if ESSENTIALS_VERSION == "(unknown)"
return true if ESSENTIALS_VERSION.is_a?(String) && ESSENTIALS_VERSION == "BW Kit"
v = ESSENTIALS_VERSION.floor
return (v == 15)
end

def isVersion16?
return false if ESSENTIALS_VERSION == "(unknown)"
return false if ESSENTIALS_VERSION.is_a?(String)
v = ESSENTIALS_VERSION.floor
return (v == 16)
end

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy