Killed off RGSS, deleted font installer code

This commit is contained in:
Maruno17
2020-11-22 16:17:46 +00:00
parent 6158e42635
commit f362b7f847
17 changed files with 73 additions and 283 deletions

View File

@@ -5,19 +5,14 @@ def mkxp?
end
def pbSetWindowText(string)
if mkxp?
System.set_window_title(string || System.game_title)
else
Win32API.SetWindowText(string || "RGSS Player")
end
System.set_window_title(string || System.game_title)
end
class Bitmap
if mkxp?
alias mkxp_draw_text draw_text
def draw_text(x, y, width, height, text, align = 0)
height = text_size(text).height
mkxp_draw_text(x, y, width, height, text, align)
end
alias mkxp_draw_text draw_text
def draw_text(x, y, width, height, text, align = 0)
height = text_size(text).height
mkxp_draw_text(x, y, width, height, text, align)
end
end

View File

@@ -16,48 +16,17 @@ if true # Disables using Alt+Enter to go fullscreen
regHotKey.call(0, 1, 1, 0x0D)
end
if mkxp?
# This kinda puts most of SpriteResizer out of business
def pbSetResizeFactor(factor)
if !$ResizeInitialized
Graphics.resize_screen(SCREEN_WIDTH, SCREEN_HEIGHT)
$ResizeInitialized = true
end
if factor < 0 || factor == 3
Graphics.fullscreen = true if !Graphics.fullscreen
else
Graphics.fullscreen = false if Graphics.fullscreen
Graphics.scale = factor
Graphics.center
end
def pbSetResizeFactor(factor)
if !$ResizeInitialized
Graphics.resize_screen(SCREEN_WIDTH, SCREEN_HEIGHT)
$ResizeInitialized = true
end
else
def pbSetResizeFactor(factor=1,norecalc=false)
factor = [0.5,1.0,2.0,-1][factor] if !norecalc
(factor<0) ? pbConfigureFullScreen : pbConfigureWindowedScreen(factor)
end
end
def pbSetResizeFactor2(factor,force=false)
if $ResizeFactor!=factor || force
$ResizeFactor = factor
$ResizeFactorMul = (factor*100).to_i
pbRefreshResizeFactor if $ResizeFactorSet
end
$ResizeFactorSet = true
$ResizeBorder.refresh if $HaveResizeBorder
begin
if Graphics.haveresizescreen
Graphics.oldresizescreen(
(Graphics.width+$ResizeOffsetX*2)*factor,
(Graphics.height+$ResizeOffsetY*2)*factor
)
end
Win32API.SetWindowPos(
(Graphics.width+$ResizeOffsetX*2)*factor,
(Graphics.height+$ResizeOffsetY*2)*factor
)
rescue
if factor < 0 || factor == 3
Graphics.fullscreen = true if !Graphics.fullscreen
else
Graphics.fullscreen = false if Graphics.fullscreen
Graphics.scale = factor
Graphics.center
end
end
@@ -86,6 +55,31 @@ def pbRefreshResizeFactor
}
end
# Unused
def pbSetResizeFactor2(factor,force=false)
if $ResizeFactor!=factor || force
$ResizeFactor = factor
$ResizeFactorMul = (factor*100).to_i
pbRefreshResizeFactor if $ResizeFactorSet
end
$ResizeFactorSet = true
$ResizeBorder.refresh if $HaveResizeBorder
begin
if Graphics.haveresizescreen
Graphics.oldresizescreen(
(Graphics.width+$ResizeOffsetX*2)*factor,
(Graphics.height+$ResizeOffsetY*2)*factor
)
end
Win32API.SetWindowPos(
(Graphics.width+$ResizeOffsetX*2)*factor,
(Graphics.height+$ResizeOffsetY*2)*factor
)
rescue
end
end
# Unused
def pbConfigureFullScreen
params = Win32API.fillScreen
fullgamew = gamew = SCREEN_WIDTH
@@ -117,6 +111,7 @@ def pbConfigureFullScreen
pbSetResizeFactor2(factor,true)
end
# Unused
def pbConfigureWindowedScreen(value)
border = $PokemonSystem ? $PokemonSystem.border : 0
$ResizeOffsetX = [0,BORDER_WIDTH][border]
@@ -189,37 +184,7 @@ module Graphics
end
end
if mkxp?
@@haveresizescreen = true
else
class << self
begin
x = @@haveresizescreen
rescue NameError # If exception is caught, the class
if !method_defined?(:oldresizescreen) # variable wasn't defined yet
begin
alias oldresizescreen resize_screen
@@haveresizescreen = true
rescue
@@haveresizescreen = false
end
else
@@haveresizescreen = false
end
end
def haveresizescreen
@@haveresizescreen
end
end
def self.resize_screen(w,h)
@@width = w
@@height = h
pbSetResizeFactor($ResizeFactor,true)
end
end
@@haveresizescreen = true
@@deletefailed = false
def self.snap_to_bitmap(resize=true)

View File

@@ -387,11 +387,11 @@ def pbSetSystemFont(bitmap)
fontname = MessageConfig.pbGetSystemFontName
bitmap.font.name = fontname
if fontname == "Pokemon FireLeaf" || fontname == "Power Red and Green"
bitmap.font.size = mkxp? ? 27 : 29
bitmap.font.size = 27
elsif fontname == "Pokemon Emerald Small" || fontname == "Power Green Small"
bitmap.font.size = mkxp? ? 29 : 25
bitmap.font.size = 29
else
bitmap.font.size = mkxp? ? 29 : 31
bitmap.font.size = 29
end
end
@@ -404,7 +404,7 @@ end
# Sets a bitmap's font to the system narrow font.
def pbSetNarrowFont(bitmap)
bitmap.font.name = pbNarrowFontName
bitmap.font.size = mkxp? ? 29 : 31
bitmap.font.size = 29
end
#===============================================================================

View File

@@ -71,7 +71,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
def resizeHeightToFit(text,width=-1) # width is current window width
dims=resizeToFitInternal(text,width)
self.width=width<0 ? Graphics.width : width
self.height = dims[1] + self.borderY - (mkxp? ? 4 : 0)
self.height = dims[1] + self.borderY - 4
refresh
end
@@ -1227,7 +1227,7 @@ class Window_CommandPokemon < Window_DrawableCommand
def drawItem(index,_count,rect)
pbSetSystemFont(self.contents) if @starting
rect=drawCursor(index,rect)
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,
@commands[index],self.baseColor,self.shadowColor)
end
end
@@ -1331,7 +1331,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
dims=[]
getAutoDims(commands,dims,width)
self.width=dims[0]
self.height=dims[1] - (mkxp? ? 6 : 0)
self.height=dims[1] - 6
end
def itemCount
@@ -1343,7 +1343,7 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
rect=drawCursor(index,rect)
if toUnformattedText(@commands[index]).gsub(/\n/,"")==@commands[index]
# Use faster alternative for unformatted text without line breaks
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,
@commands[index],self.baseColor,self.shadowColor)
else
chars=getFormattedText(

View File

@@ -168,7 +168,7 @@ end
def getFormattedTextFast(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight,
newlineBreaks=true,explicitBreaksOnly=false)
yDst += 4 if mkxp?
yDst += 4
x=y=0
characters=[]
textchunks=[]
@@ -422,7 +422,7 @@ _drawFormattedChars_ function.
def getFormattedText(bitmap,xDst,yDst,widthDst,heightDst,text,lineheight=32,
newlineBreaks=true,explicitBreaksOnly=false,
collapseAlignments=false)
yDst += 4 if mkxp?
yDst += 4
dummybitmap=nil
if !bitmap || bitmap.disposed? # allows function to be called with nil bitmap
dummybitmap=Bitmap.new(1,1)
@@ -890,7 +890,7 @@ end
#===============================================================================
def getLineBrokenChunks(bitmap,value,width,dims,plain=false)
x=0
y=mkxp? ? 4: 0
y=4
ret=[]
if dims
dims[0]=0
@@ -1109,7 +1109,7 @@ def pbDrawShadowText(bitmap,x,y,width,height,string,baseColor,shadowColor=nil,al
return if !bitmap || !string
width=(width<0) ? bitmap.text_size(string).width+1 : width
height=(height<0) ? bitmap.text_size(string).height+1 : height
y += -2 if mkxp?
y += -2
if shadowColor && shadowColor.alpha>0
bitmap.font.color=shadowColor
bitmap.draw_text(x+2,y,width,height,string,align)
@@ -1157,7 +1157,7 @@ def pbDrawTextPositions(bitmap,textpos)
for i in textpos
textsize = bitmap.text_size(i[0])
x = i[1]
y = i[2] + (mkxp? ? 6 : 0)
y = i[2] + 6
if i[3]==true || i[3]==1 # right align
x -= textsize.width
elsif i[3]==2 # centered

View File

@@ -49,16 +49,16 @@ class Window_CharacterEntry < Window_DrawableCommand
def drawItem(index,_count,rect)
rect=drawCursor(index,rect)
if index==@charset.length # -1
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,"[ ]",
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,"[ ]",
self.baseColor,self.shadowColor)
elsif index==@charset.length+1 # -2
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,@othercharset,
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,@othercharset,
self.baseColor,self.shadowColor)
elsif index==@charset.length+2 # -3
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,_INTL("OK"),
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,_INTL("OK"),
self.baseColor,self.shadowColor)
else
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,@charset[index],
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,@charset[index],
self.baseColor,self.shadowColor)
end
end

View File

@@ -17,9 +17,9 @@ class Window_DexesList < Window_CommandPokemon
def drawItem(index,count,rect)
super(index,count,rect)
if index>=0 && index<@commands2.length
pbDrawShadowText(self.contents,rect.x+254,rect.y + (mkxp? ? 6 : 0),64,rect.height,
pbDrawShadowText(self.contents,rect.x+254,rect.y + 6,64,rect.height,
sprintf("%d",@commands2[index][0]),self.baseColor,self.shadowColor,1)
pbDrawShadowText(self.contents,rect.x+350,rect.y + (mkxp? ? 6 : 0),64,rect.height,
pbDrawShadowText(self.contents,rect.x+350,rect.y + 6,64,rect.height,
sprintf("%d",@commands2[index][1]),self.baseColor,self.shadowColor,1)
allseen = (@commands2[index][0]>=@commands2[index][2])
allown = (@commands2[index][1]>=@commands2[index][2])

View File

@@ -45,7 +45,7 @@ class Window_Pokedex < Window_DrawableCommand
else
text = sprintf("%03d ----------",indexNumber)
end
pbDrawShadowText(self.contents,rect.x+36,rect.y+6 + (mkxp? ? 6 : 0),rect.width,rect.height,
pbDrawShadowText(self.contents,rect.x+36,rect.y+6 + 6,rect.width,rect.height,
text,self.baseColor,self.shadowColor)
end

View File

@@ -122,7 +122,7 @@ class Window_CommandPokemonColor < Window_CommandPokemon
base = Color.new(0,80,160)
shadow = Color.new(128,192,240)
end
pbDrawShadowText(self.contents,rect.x,rect.y + (mkxp? ? 6 : 0),rect.width,rect.height,
pbDrawShadowText(self.contents,rect.x,rect.y + 6,rect.width,rect.height,
@commands[index],base,shadow)
end
end

View File

@@ -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

View File

@@ -331,7 +331,7 @@ class Window_PokemonOption < Window_DrawableCommand
rect = drawCursor(index,rect)
optionname = (index==@options.length) ? _INTL("Cancel") : @options[index].name
optionwidth = rect.width*9/20
text_y = rect.y + (mkxp? ? 6 : 0)
text_y = rect.y + 6
pbDrawShadowText(self.contents,rect.x,text_y,optionwidth,rect.height,optionname,
@nameBaseColor,@nameShadowColor)
return if index==@options.length

View File

@@ -413,7 +413,7 @@ class PokemonBoxSprite < SpriteWrapper
pbSetSystemFont(@contents)
widthval = @contents.text_size(boxname).width
xval = 162-(widthval/2)
pbDrawShadowText(@contents,xval,8 + (mkxp? ? 6 : 0),widthval,32,
pbDrawShadowText(@contents,xval,8 + 6,widthval,32,
boxname,Color.new(248,248,248),Color.new(40,48,48))
@refreshBox = false
end
@@ -537,7 +537,7 @@ class PokemonBoxPartySprite < SpriteWrapper
def refresh
@contents.blt(0,0,@boxbitmap.bitmap,Rect.new(0,0,172,352))
pbDrawTextPositions(self.bitmap,[
[_INTL("Back"),86,242 - (mkxp? ? 2 : 0),2,Color.new(248,248,248),Color.new(80,80,80),1]
[_INTL("Back"),86,240,2,Color.new(248,248,248),Color.new(80,80,80),1]
])
xvalues = [18,90,18,90,18,90]
@@ -1385,8 +1385,8 @@ class PokemonStorageScene
buttonbase = Color.new(248,248,248)
buttonshadow = Color.new(80,80,80)
pbDrawTextPositions(overlay,[
[_INTL("Party: {1}",(@storage.party.length rescue 0)),270,328 - (mkxp? ? 2 : 0),2,buttonbase,buttonshadow,1],
[_INTL("Exit"),446,328 - (mkxp? ? 2 : 0),2,buttonbase,buttonshadow,1],
[_INTL("Party: {1}",(@storage.party.length rescue 0)),270,326,2,buttonbase,buttonshadow,1],
[_INTL("Exit"),446,326,2,buttonbase,buttonshadow,1],
])
pokemon = nil
if @screen.pbHeldPokemon

View File

@@ -98,11 +98,7 @@ def pbScreenCapture
filestart = sprintf("%s.%03d",filestart,(t.to_f-t.to_i)*1000) # milliseconds
capturefile = RTP.getSaveFileName(sprintf("%s.png",filestart))
if capturefile && safeExists?("rubyscreen.dll")
if mkxp?
Graphics.screenshot(capturefile)
else
Graphics.snap_to_bitmap(false).saveToPng(capturefile)
end
Graphics.screenshot(capturefile)
pbSEPlay("Pkmn exp full") if FileTest.audio_exist?("Audio/SE/Pkmn exp full")
end
end

View File

@@ -105,7 +105,7 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
idWidth = totalWidth*15/100
nameWidth = totalWidth*65/100
statusWidth = totalWidth*20/100
text_y = rect.y + (mkxp? ? 6 : 0)
text_y = rect.y + 6
self.shadowtext(rect.x,text_y,idWidth,rect.height,id_text)
self.shadowtext(rect.x+idWidth,text_y,nameWidth,rect.height,name,0,(codeswitch) ? 1 : 0)
self.shadowtext(rect.x+idWidth+nameWidth,text_y,statusWidth,rect.height,status,1,colors)
@@ -427,7 +427,7 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
else
status = "[NOT ROAMING][Switch #{pkmn[2]} is off]"
end
text_y = rect.y + (mkxp? ? 6 : 0)
text_y = rect.y + 6
self.shadowtext(name,rect.x,text_y,nameWidth,rect.height)
self.shadowtext(status,rect.x+nameWidth,text_y,statusWidth,rect.height,1,statuscolor)
end

View File

@@ -668,7 +668,7 @@ module Compiler
if !$INEDITOR && LANGUAGES.length>=2
pbLoadMessages("Data/"+LANGUAGES[$PokemonSystem.language][1])
end
pbSetWindowText(nil) if mkxp?
pbSetWindowText(nil)
end
def main
@@ -730,28 +730,6 @@ module Compiler
pbSaveAllData
mustCompile = true
end
# Check data files and PBS files, and recompile if any PBS file was edited
# more recently than the data files were last created
if !mkxp?
for i in 0...dataFiles.length
begin
File.open("Data/#{dataFiles[i]}") { |file|
latestDataTime = [latestDataTime,file.mtime.to_i].max
}
rescue SystemCallError
mustCompile = true
end
end
for i in 0...textFiles.length
begin
File.open("PBS/#{textFiles[i]}") { |file|
latestTextTime = [latestTextTime,file.mtime.to_i].max
}
rescue SystemCallError
end
end
mustCompile |= (latestTextTime>=latestDataTime)
end
# Should recompile if holding Ctrl
Input.update
mustCompile = true if Input.press?(Input::CTRL)

BIN
Game.exe

Binary file not shown.

Binary file not shown.