mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2026-01-22 06:06:01 +00:00
Killed off RGSS, deleted font installer code
This commit is contained in:
@@ -257,7 +257,6 @@ class PokemonLoadScreen
|
||||
$game_system = Game_System.new
|
||||
$PokemonSystem = PokemonSystem.new if !$PokemonSystem
|
||||
savefile = RTP.getSaveFileName("Game.rxdata")
|
||||
FontInstaller.install
|
||||
data_system = pbLoadRxData("Data/System")
|
||||
mapfile = sprintf("Data/Map%03d.rxdata",data_system.start_map_id)
|
||||
if data_system.start_map_id==0 || !pbRgssExists?(mapfile)
|
||||
@@ -480,146 +479,3 @@ class PokemonLoadScreen
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
# Font installer
|
||||
################################################################################
|
||||
module FontInstaller
|
||||
# filenames of fonts to be installed
|
||||
Filenames = [
|
||||
'pkmnem.ttf',
|
||||
'pkmnemn.ttf',
|
||||
'pkmnems.ttf',
|
||||
'pkmnrs.ttf',
|
||||
'pkmndp.ttf',
|
||||
'pkmnfl.ttf'
|
||||
]
|
||||
# names (not filenames) of fonts to be installed
|
||||
Names = [
|
||||
'Power Green',
|
||||
'Power Green Narrow',
|
||||
'Power Green Small',
|
||||
'Power Red and Blue',
|
||||
'Power Clear',
|
||||
'Power Red and Green'
|
||||
]
|
||||
# whether to notify player (via pop-up message) that fonts were installed
|
||||
Notify = true
|
||||
# location of fonts (relative to game folder)
|
||||
Source = 'Fonts/'
|
||||
|
||||
def self.getFontFolder
|
||||
fontfolder = MiniRegistry.get(MiniRegistry::HKEY_CURRENT_USER,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders","Fonts")
|
||||
return fontfolder+"\\" if fontfolder
|
||||
if ENV['SystemRoot']
|
||||
return ENV['SystemRoot'] + '\\Fonts\\'
|
||||
elsif ENV['windir']
|
||||
return ENV['windir'] + '\\Fonts\\'
|
||||
else
|
||||
return '\\Windows\\Fonts\\'
|
||||
end
|
||||
end
|
||||
|
||||
AFR = Win32API.new('gdi32', 'AddFontResource', ['P'], 'L')
|
||||
WPS = Win32API.new('kernel32', 'WriteProfileString', ['P'] * 3, 'L')
|
||||
SM = Win32API.new('user32', 'PostMessage', ['L'] * 4, 'L')
|
||||
WM_FONTCHANGE = 0x001D
|
||||
HWND_BROADCAST = 0xffff
|
||||
|
||||
def self.copy_file(src,dest)
|
||||
File.open(src,'rb') { |r|
|
||||
File.open(dest,'wb') { |w|
|
||||
while s = r.read(4096)
|
||||
w.write s
|
||||
end
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
def self.pbResolveFont(name)
|
||||
RTP.eachPathFor(Source+name) { |file|
|
||||
return file if safeExists?(file)
|
||||
}
|
||||
return Source+name
|
||||
end
|
||||
|
||||
def self.install
|
||||
success = []
|
||||
# Check if all fonts already exist
|
||||
filesExist = true
|
||||
dest = self.getFontFolder
|
||||
for i in 0...Names.size
|
||||
filesExist = false if !safeExists?(dest + Filenames[i])
|
||||
end
|
||||
return if filesExist
|
||||
# Check if all source fonts exist
|
||||
exist = true
|
||||
for i in 0...Names.size
|
||||
if !RTP.exists?(Source + Filenames[i])
|
||||
exist = false
|
||||
break
|
||||
end
|
||||
end
|
||||
return if !exist # Exit if not all source fonts exist
|
||||
pbMessage(_INTL("One or more fonts used in this game do not exist on the system.\1"))
|
||||
pbMessage(_INTL("The game can be played, but the look of the game's text will not be optimal."))
|
||||
failed = false
|
||||
for i in 0...Filenames.size
|
||||
f = Filenames[i]
|
||||
if safeExists?(dest + f) && !Font.exist?(Names[i])
|
||||
File.delete(dest + f) rescue nil
|
||||
end
|
||||
# check if already installed...
|
||||
if not safeExists?(dest + f)
|
||||
# check to ensure font is in specified location...
|
||||
if RTP.exists?(Source + f)
|
||||
# copy file to fonts folder
|
||||
succeeded = false
|
||||
begin
|
||||
copy_file(pbResolveFont(f), dest + f)
|
||||
# add font resource
|
||||
AFR.call(dest + f)
|
||||
# add entry to win.ini/registry
|
||||
WPS.call('Fonts', Names[i] + ' (TrueType)', f)
|
||||
succeeded = safeExists?(dest + f)
|
||||
rescue SystemCallError
|
||||
# failed
|
||||
succeeded = false
|
||||
end
|
||||
if succeeded
|
||||
success.push(Names[i])
|
||||
else
|
||||
failed = true
|
||||
end
|
||||
end
|
||||
else
|
||||
success.push(Names[i]) # assume success
|
||||
end
|
||||
end
|
||||
if success.length>0 # one or more fonts successfully installed
|
||||
SM.call(HWND_BROADCAST,WM_FONTCHANGE,0,0)
|
||||
if Notify
|
||||
fonts = ''
|
||||
success.each do |f|
|
||||
fonts << f << ', '
|
||||
end
|
||||
if failed
|
||||
pbMessage(_INTL("Some of the fonts were successfully installed.\1"))
|
||||
pbMessage(_INTL("To install the other fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel.\1"))
|
||||
else
|
||||
pbMessage(_INTL("The fonts were successfully installed.\1"))
|
||||
end
|
||||
if pbConfirmMessage(_INTL("Would you like to restart the game and apply the changes?"))
|
||||
a = Thread.new { system('Game') }
|
||||
exit
|
||||
end
|
||||
end
|
||||
else
|
||||
# No fonts were installed.
|
||||
pbMessage(_INTL("To install the necessary fonts, copy the files in this game's Fonts folder to the Fonts folder in Control Panel."))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user