From 1cf858d431b624e20ada9e6998f6d99313d3ae15 Mon Sep 17 00:00:00 2001 From: gryf Date: Thu, 5 May 2022 18:48:38 +0200 Subject: [PATCH] Fixed bitmap replacement. For the existing character in both palettes, but with different color, there was missing adding the actual replacement for the original one. In this patch it was fixed. Also, loops has been removed in favor of list comprehensions. --- wmdocklib/helpers.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/wmdocklib/helpers.py b/wmdocklib/helpers.py index 668b1c2..4730990 100644 --- a/wmdocklib/helpers.py +++ b/wmdocklib/helpers.py @@ -254,10 +254,10 @@ def merge_palettes(pal1, pal2, bitmap_list): all_chars = pal1.copy() all_chars.update(pal2) sub = get_unique_key(all_chars) - temp = [] - for line in bitmap_list: - temp.append(line.replace(new_char, sub)) - bitmap_list = temp + # remap clashing character to the new one + bitmap_list = [r.replace(new_char, sub) for r in bitmap_list] + # and now remap character with the one found in first palette + bitmap_list = [r.replace(char, new_char) for r in bitmap_list] pal2[sub] = pal2[new_char] pal2[new_char] = MARKER pal2[char] = MARKER @@ -274,10 +274,7 @@ def merge_palettes(pal1, pal2, bitmap_list): all_chars = pal1.copy() all_chars.update(pal2) sub = get_unique_key(all_chars) - temp = [] - for line in bitmap_list: - temp.append(line.replace(char, sub)) - bitmap_list = temp + bitmap_list = [r.replace(char, sub) for r in bitmap_list] pal2[sub] = color pal2[char] = MARKER rerun = True