Fix unused variables and loop variables
This commit is contained in:
parent
addfe0c2e5
commit
1d6cd6138f
18 changed files with 26 additions and 28 deletions
|
|
@ -475,7 +475,7 @@ class CollisionLord:
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"Resolve overlaps between all relevant world objects."
|
"Resolve overlaps between all relevant world objects."
|
||||||
for i in range(self.iterations):
|
for _ in range(self.iterations):
|
||||||
# filter shape lists for anything out of room etc
|
# filter shape lists for anything out of room etc
|
||||||
valid_dynamic_shapes = []
|
valid_dynamic_shapes = []
|
||||||
for shape in self.dynamic_shapes:
|
for shape in self.dynamic_shapes:
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class EditCommand:
|
||||||
for frame in self.tile_commands.values():
|
for frame in self.tile_commands.values():
|
||||||
for layer in frame.values():
|
for layer in frame.values():
|
||||||
for column in layer.values():
|
for column in layer.values():
|
||||||
for tile in column.values():
|
for _tile in column.values():
|
||||||
commands += 1
|
commands += 1
|
||||||
return commands
|
return commands
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1082,7 +1082,7 @@ class GameObject:
|
||||||
steps = int(total_move_dist / step_dist)
|
steps = int(total_move_dist / step_dist)
|
||||||
# start stepping from beginning of this frame's move distance
|
# start stepping from beginning of this frame's move distance
|
||||||
self.x, self.y = self.last_x, self.last_y
|
self.x, self.y = self.last_x, self.last_y
|
||||||
for i in range(steps):
|
for _ in range(steps):
|
||||||
self.x += dir_x * step_dist
|
self.x += dir_x * step_dist
|
||||||
self.y += dir_y * step_dist
|
self.y += dir_y * step_dist
|
||||||
collisions = self.get_collisions()
|
collisions = self.get_collisions()
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ class CrawlTopDownView(GameObject):
|
||||||
# make a copy of original layer to color for visibility, hide original
|
# make a copy of original layer to color for visibility, hide original
|
||||||
self.art.duplicate_layer(0)
|
self.art.duplicate_layer(0)
|
||||||
self.art.layers_visibility[0] = False
|
self.art.layers_visibility[0] = False
|
||||||
for frame, layer, x, y in TileIter(self.art):
|
for _frame, layer, x, y in TileIter(self.art):
|
||||||
if layer == 0:
|
if layer == 0:
|
||||||
continue
|
continue
|
||||||
# set all tiles undiscovered
|
# set all tiles undiscovered
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class Fireplace(GameObject):
|
||||||
self.weighted_chars = sorted(chars, key=weights.__getitem__)
|
self.weighted_chars = sorted(chars, key=weights.__getitem__)
|
||||||
# spawn initial particles
|
# spawn initial particles
|
||||||
self.particles = []
|
self.particles = []
|
||||||
for i in range(self.target_particles):
|
for _ in range(self.target_particles):
|
||||||
p = FireParticle(self)
|
p = FireParticle(self)
|
||||||
self.particles.append(p)
|
self.particles.append(p)
|
||||||
# help screen
|
# help screen
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ class Petal:
|
||||||
tiles = []
|
tiles = []
|
||||||
angle = 0
|
angle = 0
|
||||||
resolution = 30
|
resolution = 30
|
||||||
for i in range(resolution):
|
for _ in range(resolution):
|
||||||
angle += math.radians(90.0 / resolution)
|
angle += math.radians(90.0 / resolution)
|
||||||
x = round(math.cos(angle) * self.radius)
|
x = round(math.cos(angle) * self.radius)
|
||||||
y = round(math.sin(angle) * self.radius)
|
y = round(math.sin(angle) * self.radius)
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ class ImageConverter:
|
||||||
def update(self):
|
def update(self):
|
||||||
if time.time() < self.start_time + self.start_delay:
|
if time.time() < self.start_time + self.start_delay:
|
||||||
return
|
return
|
||||||
for i in range(self.tiles_per_tick):
|
for _ in range(self.tiles_per_tick):
|
||||||
x_start, y_start = self.x * self.char_w, self.y * self.char_h
|
x_start, y_start = self.x * self.char_w, self.y * self.char_h
|
||||||
x_end, y_end = x_start + self.char_w, y_start + self.char_h
|
x_end, y_end = x_start + self.char_w, y_start + self.char_h
|
||||||
block = self.src_array[y_start:y_end, x_start:x_end]
|
block = self.src_array[y_start:y_end, x_start:x_end]
|
||||||
|
|
@ -198,8 +198,8 @@ class ImageConverter:
|
||||||
color_counts += [(color, counts[i])]
|
color_counts += [(color, counts[i])]
|
||||||
color_counts.sort(key=lambda item: item[1], reverse=True)
|
color_counts.sort(key=lambda item: item[1], reverse=True)
|
||||||
combos = []
|
combos = []
|
||||||
for color1, count1 in color_counts:
|
for color1, _count1 in color_counts:
|
||||||
for color2, count2 in color_counts:
|
for color2, _count2 in color_counts:
|
||||||
if color1 == color2:
|
if color1 == color2:
|
||||||
continue
|
continue
|
||||||
# fg/bg color swap SHOULD be allowed
|
# fg/bg color swap SHOULD be allowed
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,6 @@ def export_still_image(app, art, out_filename, crt=True, scale=1, bg_color=None)
|
||||||
if not src_img:
|
if not src_img:
|
||||||
return False
|
return False
|
||||||
src_img.save(out_filename, "PNG")
|
src_img.save(out_filename, "PNG")
|
||||||
output_format = "32-bit w/ alpha"
|
|
||||||
else:
|
else:
|
||||||
# else convert to current palette.
|
# else convert to current palette.
|
||||||
# as with aniGIF export, use arbitrary color for transparency
|
# as with aniGIF export, use arbitrary color for transparency
|
||||||
|
|
|
||||||
|
|
@ -28,10 +28,8 @@ class PaletteLord:
|
||||||
):
|
):
|
||||||
return
|
return
|
||||||
self.last_check = self.app.get_elapsed_time()
|
self.last_check = self.app.get_elapsed_time()
|
||||||
changed = None
|
|
||||||
for palette in self.app.palettes:
|
for palette in self.app.palettes:
|
||||||
if palette.has_updated():
|
if palette.has_updated():
|
||||||
changed = palette.filename
|
|
||||||
try:
|
try:
|
||||||
palette.load_image()
|
palette.load_image()
|
||||||
self.app.log(
|
self.app.log(
|
||||||
|
|
|
||||||
|
|
@ -101,10 +101,12 @@ class TileRenderable:
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
"for debug purposes, return a concise unique name"
|
"for debug purposes, return a concise unique name"
|
||||||
i = 0
|
for idx, r in enumerate(self.art.renderables):
|
||||||
for i, r in enumerate(self.art.renderables):
|
|
||||||
if r is self:
|
if r is self:
|
||||||
|
i = idx
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
return "{} {} {}".format(self.art.get_simple_name(), self.__class__.__name__, i)
|
return "{} {} {}".format(self.art.get_simple_name(), self.__class__.__name__, i)
|
||||||
|
|
||||||
def create_buffers(self):
|
def create_buffers(self):
|
||||||
|
|
@ -546,7 +548,6 @@ class TileRenderable:
|
||||||
if not self.app.show_hidden_layers and not self.art.layers_visibility[i]:
|
if not self.app.show_hidden_layers and not self.art.layers_visibility[i]:
|
||||||
continue
|
continue
|
||||||
layer_start = i * layer_size
|
layer_start = i * layer_size
|
||||||
layer_end = layer_start + layer_size
|
|
||||||
# for active art, dim all but active layer based on UI setting
|
# for active art, dim all but active layer based on UI setting
|
||||||
if (
|
if (
|
||||||
not self.app.game_mode
|
not self.app.game_mode
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,6 @@ class DebugLineRenderable(WorldLineRenderable):
|
||||||
def add_lines(self, new_verts, new_colors=None):
|
def add_lines(self, new_verts, new_colors=None):
|
||||||
"add lines to the current ones"
|
"add lines to the current ones"
|
||||||
line_items = len(self.vert_array)
|
line_items = len(self.vert_array)
|
||||||
lines = int(line_items / self.vert_items)
|
|
||||||
# if new_verts is a list of tuples, unpack into flat list
|
# if new_verts is a list of tuples, unpack into flat list
|
||||||
if type(new_verts[0]) is tuple:
|
if type(new_verts[0]) is tuple:
|
||||||
new_verts_unpacked = []
|
new_verts_unpacked = []
|
||||||
|
|
|
||||||
6
ui.py
6
ui.py
|
|
@ -287,10 +287,12 @@ class UI:
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_active_art_by_filename(self, art_filename):
|
def set_active_art_by_filename(self, art_filename):
|
||||||
i = 0
|
for idx, art in enumerate(self.app.art_loaded_for_edit):
|
||||||
for i, art in enumerate(self.app.art_loaded_for_edit):
|
|
||||||
if art_filename == art.filename:
|
if art_filename == art.filename:
|
||||||
|
i = idx
|
||||||
break
|
break
|
||||||
|
else:
|
||||||
|
i = 0
|
||||||
new_active_art = self.app.art_loaded_for_edit.pop(i)
|
new_active_art = self.app.art_loaded_for_edit.pop(i)
|
||||||
self.app.art_loaded_for_edit.insert(0, new_active_art)
|
self.app.art_loaded_for_edit.insert(0, new_active_art)
|
||||||
new_active_renderable = self.app.edit_renderables.pop(i)
|
new_active_renderable = self.app.edit_renderables.pop(i)
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ class AddLayerDialog(UIDialog):
|
||||||
if not valid_name:
|
if not valid_name:
|
||||||
return False, self.name_exists_error
|
return False, self.name_exists_error
|
||||||
try:
|
try:
|
||||||
z = float(self.field_texts[1])
|
float(self.field_texts[1])
|
||||||
except Exception:
|
except Exception:
|
||||||
return False, self.invalid_z_error
|
return False, self.invalid_z_error
|
||||||
return True, None
|
return True, None
|
||||||
|
|
@ -684,7 +684,7 @@ class SetLayerZDialog(UIDialog):
|
||||||
|
|
||||||
def is_input_valid(self):
|
def is_input_valid(self):
|
||||||
try:
|
try:
|
||||||
z = float(self.field_texts[0])
|
float(self.field_texts[0])
|
||||||
except Exception:
|
except Exception:
|
||||||
return False, self.invalid_z_error
|
return False, self.invalid_z_error
|
||||||
return True, None
|
return True, None
|
||||||
|
|
@ -745,7 +745,7 @@ class PaletteFromFileDialog(UIDialog):
|
||||||
src_filename = self.field_texts[0]
|
src_filename = self.field_texts[0]
|
||||||
palette_filename = self.field_texts[1]
|
palette_filename = self.field_texts[1]
|
||||||
colors = int(self.field_texts[2])
|
colors = int(self.field_texts[2])
|
||||||
new_pal = PaletteFromFile(self.ui.app, src_filename, palette_filename, colors)
|
PaletteFromFile(self.ui.app, src_filename, palette_filename, colors)
|
||||||
self.dismiss()
|
self.dismiss()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -176,7 +176,7 @@ class ChooserDialog(UIDialog):
|
||||||
# os.access(new_dir, os.R_OK) seems to always return True,
|
# os.access(new_dir, os.R_OK) seems to always return True,
|
||||||
# so try/catch listdir instead
|
# so try/catch listdir instead
|
||||||
try:
|
try:
|
||||||
l = os.listdir(new_dir)
|
os.listdir(new_dir)
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
line = "No permission to access {}!".format(os.path.abspath(new_dir))
|
line = "No permission to access {}!".format(os.path.abspath(new_dir))
|
||||||
self.ui.message_line.post_line(line, error=True)
|
self.ui.message_line.post_line(line, error=True)
|
||||||
|
|
|
||||||
|
|
@ -143,7 +143,7 @@ class ImportCommand(ConsoleCommand):
|
||||||
)
|
)
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(filename):
|
||||||
console.ui.app.log("Couldn't find file {}".format(filename))
|
console.ui.app.log("Couldn't find file {}".format(filename))
|
||||||
importer = importer_class(console.ui.app, filename)
|
importer_class(console.ui.app, filename)
|
||||||
|
|
||||||
|
|
||||||
class ExportCommand(ConsoleCommand):
|
class ExportCommand(ConsoleCommand):
|
||||||
|
|
@ -162,7 +162,7 @@ class ExportCommand(ConsoleCommand):
|
||||||
console.ui.app.log(
|
console.ui.app.log(
|
||||||
"Couldn't find exporter class {}".format(exporter_classname)
|
"Couldn't find exporter class {}".format(exporter_classname)
|
||||||
)
|
)
|
||||||
exporter = exporter_class(console.ui.app, filename)
|
exporter_class(console.ui.app, filename)
|
||||||
|
|
||||||
|
|
||||||
class PaletteFromImageCommand(ConsoleCommand):
|
class PaletteFromImageCommand(ConsoleCommand):
|
||||||
|
|
|
||||||
|
|
@ -431,7 +431,7 @@ class ToolPopup(UIElement):
|
||||||
# charset renderable location will be set in update()
|
# charset renderable location will be set in update()
|
||||||
charset = self.ui.active_art.charset
|
charset = self.ui.active_art.charset
|
||||||
palette = self.ui.active_art.palette
|
palette = self.ui.active_art.palette
|
||||||
cqw, cqh = (
|
_cqw, cqh = (
|
||||||
self.charset_swatch.art.quad_width,
|
self.charset_swatch.art.quad_width,
|
||||||
self.charset_swatch.art.quad_height,
|
self.charset_swatch.art.quad_height,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,6 @@ class TextTool(UITool):
|
||||||
self.input_active = False
|
self.input_active = False
|
||||||
self.ui.tool_settings_changed = True
|
self.ui.tool_settings_changed = True
|
||||||
if self.cursor:
|
if self.cursor:
|
||||||
x, y = int(self.cursor.x) + 1, int(-self.cursor.y) + 1
|
|
||||||
self.cursor.finish_paint()
|
self.cursor.finish_paint()
|
||||||
# self.ui.message_line.post_line('Finished text entry at %s, %s' % (x, y))
|
# self.ui.message_line.post_line('Finished text entry at %s, %s' % (x, y))
|
||||||
self.ui.message_line.post_line("Finished text entry.")
|
self.ui.message_line.post_line("Finished text entry.")
|
||||||
|
|
|
||||||
|
|
@ -216,9 +216,9 @@ def world_to_screen(app, world_x, world_y, world_z):
|
||||||
# viewport tuple order should be same as glGetFloatv(GL_VIEWPORT)
|
# viewport tuple order should be same as glGetFloatv(GL_VIEWPORT)
|
||||||
viewport = (0, 0, app.window_width, app.window_height)
|
viewport = (0, 0, app.window_width, app.window_height)
|
||||||
try:
|
try:
|
||||||
x, y, z = GLU.gluProject(world_x, world_y, world_z, vm, pjm, viewport)
|
x, y, _z = GLU.gluProject(world_x, world_y, world_z, vm, pjm, viewport)
|
||||||
except Exception:
|
except Exception:
|
||||||
x, y, z = 0, 0, 0
|
x, y = 0, 0
|
||||||
app.log("GLU.gluProject failed!")
|
app.log("GLU.gluProject failed!")
|
||||||
# does Z mean anything here?
|
# does Z mean anything here?
|
||||||
return x, y
|
return x, y
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue