More aligning of code

This commit is contained in:
Maruno17
2021-12-19 12:19:08 +00:00
parent 13a238cc6a
commit 33781493f4
121 changed files with 977 additions and 838 deletions

View File

@@ -522,24 +522,19 @@ class Window
@cursorbitmap.clear
@sprites["cursor"].bitmap = @cursorbitmap
@sprites["cursor"].src_rect.set(0, 0, width, height)
rect = Rect.new(margin, margin,
width - fullmargin, height - fullmargin)
rect = Rect.new(margin, margin, width - fullmargin, height - fullmargin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[8])
@cursorbitmap.blt(0, 0, @_windowskin, cursorrects[4]) # top left
@cursorbitmap.blt(width - margin, 0, @_windowskin, cursorrects[5]) # top right
@cursorbitmap.blt(0, height - margin, @_windowskin, cursorrects[6]) # bottom right
@cursorbitmap.blt(width - margin, height - margin, @_windowskin, cursorrects[7]) # bottom left
rect = Rect.new(margin, 0,
width - fullmargin, margin)
rect = Rect.new(margin, 0, width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[0])
rect = Rect.new(0, margin,
margin, height - fullmargin)
rect = Rect.new(0, margin, margin, height - fullmargin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[1])
rect = Rect.new(width - margin, margin,
margin, height - fullmargin)
rect = Rect.new(width - margin, margin, margin, height - fullmargin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[2])
rect = Rect.new(margin, height - margin,
width - fullmargin, margin)
rect = Rect.new(margin, height - margin, width - fullmargin, margin)
@cursorbitmap.stretch_blt(rect, @_windowskin, cursorrects[3])
else
@sprites["cursor"].visible = false
@@ -553,8 +548,7 @@ class Window
@sprites["side#{i}"].src_rect.set(0, 0, dwidth, dheight)
@sidebitmaps[i].clear
if sideRects[i].width > 0 && sideRects[i].height > 0
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
@_windowskin, sideRects[i])
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect, @_windowskin, sideRects[i])
end
end
backwidth = @width - 4

View File

@@ -618,8 +618,7 @@ class SpriteWindow < Window
@sprites["corner1"].src_rect.set(cx, 0, endX, startY)
@sprites["corner2"].src_rect.set(0, cy, startX, endY)
@sprites["corner3"].src_rect.set(cx, cy, endX, endY)
backRect = Rect.new(@skinrect.x, @skinrect.y,
@skinrect.width, @skinrect.height)
backRect = Rect.new(@skinrect.x, @skinrect.y, @skinrect.width, @skinrect.height)
blindsRect = nil
sideRects = [
Rect.new(startX, 0, @skinrect.width, startY), # side0 (top)
@@ -753,10 +752,10 @@ class SpriteWindow < Window
if (@compat & CompatBits::StretchSides) > 0 && @skinformat == 0
# Compatibility mode: Stretch sides
@sidebitmaps[i].stretch_blt(@sprites["side#{i}"].src_rect,
@_windowskin, sideRects[i])
@_windowskin, sideRects[i])
else
tileBitmap(@sidebitmaps[i], @sprites["side#{i}"].src_rect,
@_windowskin, sideRects[i])
@_windowskin, sideRects[i])
end
end
end

View File

@@ -52,7 +52,7 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
dims = [0, 0]
cwidth = maxwidth < 0 ? Graphics.width : maxwidth
getLineBrokenChunks(self.contents, text,
cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true)
cwidth - self.borderX - SpriteWindow_Base::TEXTPADDING, dims, true)
return dims
end
@@ -99,10 +99,10 @@ class Window_UnformattedTextPokemon < SpriteWindow_Base
def refresh
self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
self.height - self.borderY)
self.height - self.borderY)
self.contents.clear
drawTextEx(self.contents, 0, 4, self.contents.width, 0,
@text.gsub(/\r/, ""), @baseColor, @shadowColor)
@text.gsub(/\r/, ""), @baseColor, @shadowColor)
end
end
@@ -234,7 +234,7 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
dims = [0, 0]
cwidth = (maxwidth < 0) ? Graphics.width : maxwidth
chars = getFormattedTextForDims(self.contents, 0, 0,
cwidth - self.borderX - 2 - 6, -1, text, @lineHeight, true)
cwidth - self.borderX - 2 - 6, -1, text, @lineHeight, true)
for ch in chars
dims[0] = [dims[0], ch[1] + ch[3]].max
dims[1] = [dims[1], ch[2] + ch[4]].max
@@ -309,8 +309,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
if @letterbyletter
@fmtchars = []
fmt = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
for ch in fmt
chx = ch[1] + ch[3]
@@ -337,8 +337,8 @@ class Window_AdvancedTextPokemon < SpriteWindow_Base
fmt.clear
else
@fmtchars = getFormattedText(self.contents, 0, 0,
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
self.width - self.borderX - SpriteWindow_Base::TEXTPADDING, -1,
shadowctag(@baseColor, @shadowColor) + value, 32, true)
@oldfont = self.contents.font.clone
for ch in @fmtchars
chx = ch[1] + ch[3]
@@ -660,7 +660,7 @@ class Window_InputNumberPokemon < SpriteWindow_Base
def refresh
self.contents = pbDoEnsureBitmap(self.contents,
self.width - self.borderX, self.height - self.borderY)
self.width - self.borderX, self.height - self.borderY)
pbSetSystemFont(self.contents)
self.contents.clear
s = sprintf("%0*d", @digits_max, @number.abs)
@@ -1226,7 +1226,7 @@ class Window_CommandPokemon < Window_DrawableCommand
pbSetSystemFont(self.contents) if @starting
rect = drawCursor(index, rect)
pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height,
@commands[index], self.baseColor, self.shadowColor)
@commands[index], self.baseColor, self.shadowColor)
end
end
@@ -1248,8 +1248,8 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
def textWidth(bitmap, text)
dims = [nil, 0]
chars = getFormattedText(bitmap, 0, 0,
Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16,
-1, text, self.rowHeight, true, true)
Graphics.width - self.borderX - SpriteWindow_Base::TEXTPADDING - 16,
-1, text, self.rowHeight, true, true)
for ch in chars
dims[0] = dims[0] ? [dims[0], ch[1]].min : ch[1]
dims[1] = [dims[1], ch[1] + ch[3]].max
@@ -1342,11 +1342,10 @@ class Window_AdvancedCommandPokemon < Window_DrawableCommand
if toUnformattedText(@commands[index]).gsub(/\n/, "") == @commands[index]
# Use faster alternative for unformatted text without line breaks
pbDrawShadowText(self.contents, rect.x, rect.y, rect.width, rect.height,
@commands[index], self.baseColor, self.shadowColor)
@commands[index], self.baseColor, self.shadowColor)
else
chars = getFormattedText(
self.contents, rect.x, rect.y + 4, rect.width, rect.height,
@commands[index], rect.height, true, true)
chars = getFormattedText(self.contents, rect.x, rect.y + 4, rect.width, rect.height,
@commands[index], rect.height, true, true)
drawFormattedChars(self.contents, chars)
end
end

View File

@@ -136,11 +136,11 @@ class AnimatedSprite < SpriteWrapper
end
if @animbitmap.width % framewidth != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame width ({2}) [Bitmap={3}]",
@animbitmap.width, framewidth, animname)
@animbitmap.width, framewidth, animname)
end
if @animbitmap.height % frameheight != 0
raise _INTL("Bitmap's height ({1}) is not a multiple of frame height ({2}) [Bitmap={3}]",
@animbitmap.height, frameheight, animname)
@animbitmap.height, frameheight, animname)
end
@framecount = framecount
@framewidth = framewidth
@@ -167,7 +167,7 @@ class AnimatedSprite < SpriteWrapper
end
if @animbitmap.width % framecount != 0
raise _INTL("Bitmap's width ({1}) is not a multiple of frame count ({2}) [Bitmap={3}]",
@animbitmap.width, framewidth, animname)
@animbitmap.width, framewidth, animname)
end
@framecount = framecount
@framewidth = @animbitmap.width / @framecount

View File

@@ -31,7 +31,7 @@ def colorToRgb32(color)
return sprintf("%02X%02X%02X", color.red.to_i, color.green.to_i, color.blue.to_i)
else
return sprintf("%02X%02X%02X%02X",
color.red.to_i, color.green.to_i, color.blue.to_i, color.alpha.to_i)
color.red.to_i, color.green.to_i, color.blue.to_i, color.alpha.to_i)
end
end
@@ -163,10 +163,9 @@ def getFormattedTextForDims(bitmap, xDst, yDst, widthDst, heightDst, text, lineh
if newlineBreaks
text2.gsub!(/<(\/?)(br)(\s*\=\s*([^>]*))?>/i, "\n")
end
return getFormattedText(
bitmap, xDst, yDst, widthDst, heightDst,
text2, lineheight, newlineBreaks,
explicitBreaksOnly, true)
return getFormattedText(bitmap, xDst, yDst, widthDst, heightDst,
text2, lineheight, newlineBreaks,
explicitBreaksOnly, true)
end
def getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
@@ -412,7 +411,7 @@ def getFormattedText(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight =
end
if controls.length == 0
ret = getFormattedTextFast(bitmap, xDst, yDst, widthDst, heightDst, text, lineheight,
newlineBreaks, explicitBreaksOnly)
newlineBreaks, explicitBreaksOnly)
dummybitmap.dispose if dummybitmap
return ret
end
@@ -1051,7 +1050,7 @@ def drawSingleFormattedChar(bitmap, ch)
end
if ch[10] # underline
bitmap.fill_rect(ch[1], ch[2] + ch[4] - 4 - [(ch[4] - bitmap.font.size) / 2, 0].max - 2,
ch[3] - 2, 2, ch[8])
ch[3] - 2, 2, ch[8])
end
if ch[11] # strikeout
bitmap.fill_rect(ch[1], ch[2] + (ch[4] / 2) - 4, ch[3] - 2, 2, ch[8])
@@ -1088,7 +1087,7 @@ end
def drawTextEx(bitmap, x, y, width, numlines, text, baseColor, shadowColor)
normtext = getLineBrokenChunks(bitmap, text, width, nil, true)
renderLineBrokenChunksWithShadow(bitmap, x, y, normtext, numlines * 32,
baseColor, shadowColor)
baseColor, shadowColor)
end
def drawFormattedTextEx(bitmap, x, y, width, text, baseColor = nil, shadowColor = nil, lineheight = 32)

View File

@@ -713,9 +713,9 @@ def pbMessage(message, commands = nil, cmdIfCancel = 0, skin = nil, defaultCmd =
msgwindow = pbCreateMessageWindow(nil, skin)
if commands
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
proc { |msgwindow|
next Kernel.pbShowCommands(msgwindow, commands, cmdIfCancel, defaultCmd, &block)
}, &block)
else
pbMessageDisplay(msgwindow, message, &block)
end
@@ -735,9 +735,9 @@ end
def pbMessageChooseNumber(message, params, &block)
msgwindow = pbCreateMessageWindow(nil, params.messageSkin)
ret = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next pbChooseNumber(msgwindow, params, &block)
}, &block)
proc { |msgwindow|
next pbChooseNumber(msgwindow, params, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return ret
end
@@ -878,9 +878,9 @@ end
def pbMessageFreeText(message, currenttext, passwordbox, maxlength, width = 240, &block)
msgwindow = pbCreateMessageWindow
retval = pbMessageDisplay(msgwindow, message, true,
proc { |msgwindow|
next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block)
}, &block)
proc { |msgwindow|
next pbFreeText(msgwindow, currenttext, passwordbox, maxlength, width, &block)
}, &block)
pbDisposeMessageWindow(msgwindow)
return retval
end

View File

@@ -173,7 +173,7 @@ class Window_TextEntry < SpriteWindow_Base
def refresh
self.contents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
self.height - self.borderY)
self.height - self.borderY)
bitmap = self.contents
bitmap.clear
x = 0
@@ -333,7 +333,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def getTextChars
if !@textchars
@textchars = getLineBrokenText(self.contents, @helper.text,
self.contents.width, nil)
self.contents.width, nil)
end
return @textchars
end
@@ -503,7 +503,7 @@ class Window_MultilineTextEntry < SpriteWindow_Base
def refresh
newContents = pbDoEnsureBitmap(self.contents, self.width - self.borderX,
self.height - self.borderY)
self.height - self.borderY)
@textchars = nil if self.contents != newContents
self.contents = newContents
bitmap = self.contents