tile editor palette additional colors index fixes
authorfrank <if.self.end@gmail.com>
Sun, 7 Jul 2019 06:13:45 +0000 (02:13 -0400)
committerfrank <if.self.end@gmail.com>
Sun, 7 Jul 2019 06:13:45 +0000 (02:13 -0400)
PictureProcessing.py
config
lib/pgfw

index ea62a17..26b746e 100644 (file)
@@ -4,6 +4,7 @@ from random import random, randrange, choice, randint
 from glob import glob
 from array import array
 from sys import argv
+from operator import itemgetter
 
 from pygame import PixelArray, Surface, Color, joystick, version, mixer, draw
 from pygame.event import clear, Event
@@ -885,6 +886,7 @@ class Editor(GameChild):
             while True:
                 if index < 0:
                     level.path = join(new_levels_directory, "0" * self.ZFILL_FILE)
+                    makedirs(level.path)
                     break
                 elif directories[index].isdigit():
                     level.path = join(
@@ -944,6 +946,7 @@ class Editor(GameChild):
         x, y = self.brush_position
         color = self.get_full_palette()[self.palette_index]
         if original.get_at((x, y)) != color:
+            palette_length = len(self.get_full_palette())
             if self.current_level_is_default:
                 self.current_level_is_default = False
                 self.add_default_level()
@@ -952,6 +955,7 @@ class Editor(GameChild):
             scaled.fill(color, (x * scale, y * scale, scale, scale))
             self.get_current_level().set_preview()
             self.save_level()
+            self.palette_index = self.get_full_palette().index(color)
 
     def wrap_palette_index(self):
         count = self.get_palette_cell_count()
@@ -1212,9 +1216,10 @@ class Editor(GameChild):
             for x in range(0, tile.get_width()):
                 for y in range(0, tile.get_height()):
                     color = tile.get_at((x, y))
-                    if color not in colors and color not in self.default_palette and color not in self.added_colors:
+                    if color not in colors and color not in self.default_palette and \
+                            color not in self.added_colors:
                         colors.append(color)
-        return colors
+        return sorted(colors, key=itemgetter(0, 1, 2, 3))
 
 
 class MixableColor(Color):
diff --git a/config b/config
index 991aa7b..f3b692e 100644 (file)
--- a/config
+++ b/config
@@ -43,7 +43,7 @@ framerate = 100
 temp-directory = /tmp/
 
 [editor]
-enabled = no
+enabled = no 
 root-directory = resource/editor
 levels-directory = levels
 original-directory = original
index 750b14c..2bba3da 160000 (submodule)
--- a/lib/pgfw
+++ b/lib/pgfw
@@ -1 +1 @@
-Subproject commit 750b14c413a70372aa1e915a39c6177e0d651f86
+Subproject commit 2bba3da368e34f7b46504f2dba36b62b0e2c1205