Many more Rubocop-inspired code improvements

This commit is contained in:
Maruno17
2021-12-18 19:06:22 +00:00
parent d17fc40a47
commit 13a238cc6a
107 changed files with 651 additions and 652 deletions

View File

@@ -134,11 +134,12 @@ DebugMenuCommands.register("togglewallpapers", {
end
paperscmd = pbShowCommands(nil, paperscmds, -1, paperscmd)
break if paperscmd < 0
if paperscmd == 0 # Unlock all
case paperscmd
when 0 # Unlock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = true
end
elsif paperscmd == 1 # Lock all
when 1 # Lock all
for i in PokemonStorage::BASICWALLPAPERQTY...w.length
unlockarray[i] = false
end
@@ -715,9 +716,10 @@ DebugMenuCommands.register("setbadges", {
end
badgecmd = pbShowCommands(nil, badgecmds, -1, badgecmd)
break if badgecmd < 0
if badgecmd == 0 # Give all
case badgecmd
when 0 # Give all
24.times { |i| $player.badges[i] = true }
elsif badgecmd == 1 # Remove all
when 1 # Remove all
24.times { |i| $player.badges[i] = false }
else
$player.badges[badgecmd - 2] = !$player.badges[badgecmd - 2]

View File

@@ -61,15 +61,17 @@ class SpriteWindow_DebugVariables < Window_DrawableCommand
def shadowtext(x, y, w, h, t, align = 0, colors = 0)
width = self.contents.text_size(t).width
if align == 1 # Right aligned
case align
when 1 # Right aligned
x += (w - width)
elsif align == 2 # Centre aligned
when 2 # Centre aligned
x += (w / 2) - (width / 2)
end
base = Color.new(12 * 8, 12 * 8, 12 * 8)
if colors == 1 # Red
case colors
when 1 # Red
base = Color.new(168, 48, 56)
elsif colors == 2 # Green
when 2 # Green
base = Color.new(0, 144, 0)
end
pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8))
@@ -160,14 +162,15 @@ def pbDebugVariables(mode)
break
end
current_id = right_window.index + 1
if mode == 0 # Switches
case mode
when 0 # Switches
if Input.trigger?(Input::USE)
pbPlayDecisionSE
$game_switches[current_id] = !$game_switches[current_id]
right_window.refresh
$game_map.need_refresh = true
end
elsif mode == 1 # Variables
when 1 # Variables
if Input.repeat?(Input::LEFT)
pbDebugSetVariable(current_id, -1)
right_window.refresh
@@ -175,14 +178,17 @@ def pbDebugVariables(mode)
pbDebugSetVariable(current_id, 1)
right_window.refresh
elsif Input.trigger?(Input::ACTION)
if $game_variables[current_id] == 0
case $game_variables[current_id]
when 0
$game_variables[current_id] = ""
elsif $game_variables[current_id] == ""
when ""
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(Numeric)
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(String)
$game_variables[current_id] = ""
else
if $game_variables[current_id].is_a?(Numeric)
$game_variables[current_id] = 0
elsif $game_variables[current_id].is_a?(String)
$game_variables[current_id] = ""
end
end
right_window.refresh
$game_map.need_refresh = true
@@ -366,15 +372,17 @@ class SpriteWindow_DebugRoamers < Window_DrawableCommand
def shadowtext(t, x, y, w, h, align = 0, colors = 0)
width = self.contents.text_size(t).width
if align == 1
case align
when 1
x += (w - width) # Right aligned
elsif align == 2
when 2
x += (w / 2) - (width / 2) # Centre aligned
end
base = Color.new(12 * 8, 12 * 8, 12 * 8)
if colors == 1
case colors
when 1
base = Color.new(168, 48, 56) # Red
elsif colors == 2
when 2
base = Color.new(0, 144, 0) # Green
end
pbDrawShadowText(self.contents, x, y, [width, w].max, h, t, base, Color.new(26 * 8, 26 * 8, 25 * 8))

View File

@@ -64,7 +64,6 @@ module FilenameUpdater
end
next if !changed
mapData.saveMap(id)
any_changed = true
ret.push(_INTL("Map {1}: '{2}' was modified and saved.", id, mapData.mapinfos[id].name))
end
Console.echo_done(true)
@@ -74,7 +73,6 @@ module FilenameUpdater
def rename_files
Console.echo_h1 "Updating file names and locations"
change_record = []
changed = false
# Add underscore to berry plant charsets
if rename_berry_plant_charsets
Console.echo_warn _INTL("Berry plant charset files were renamed.")

View File

@@ -187,9 +187,10 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand
def shadowtext(x, y, w, h, t, align = 0, colors = 0)
width = self.contents.text_size(t).width
if align == 1 # Right aligned
case align
when 1 # Right aligned
x += w - width
elsif align == 2 # Centre aligned
when 2 # Centre aligned
x += (w - width) / 2
end
base_color = BASE_TEXT_COLOR
@@ -213,7 +214,8 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand
rect = drawCursor(index, rect)
# Get value's text to draw
variable_text = variable.to_s
if variable_data[:default] == -1 # Battler
case variable_data[:default]
when -1 # Battler
if variable >= 0
battler_name = @battle.battlers[variable].name
battler_name = "-" if nil_or_empty?(battler_name)
@@ -221,7 +223,7 @@ class SpriteWindow_DebugBattleFieldEffects < Window_DrawableCommand
else
variable_text = _INTL("[None]")
end
elsif variable_data[:default] == nil # Move, item
when nil # Move, item
variable_text = _INTL("[None]") if !variable
end
# Draw text