yellowstonegames / SquidLib

Useful tools for roguelike, role-playing, strategy, and other grid-based games in Java. Feedback is welcome!
Other
448 stars 46 forks source link

SquidLayers palette only partially uses position 0 and 1 for defaulting characters #175

Closed SquidPony closed 7 years ago

SquidPony commented 7 years ago

Turns out that not all of the methods work as expected when not passing in a color.

This should be adjusted so all of the SquidLayers methods of adding text respect the first two positions in the palette as default colors so that it's consistent.

As a side note, the SquidLayers class having an int position driving array for a palette seems really weird. Beyond having a default front and back color, I don't think SquidLayers itself should do any color management. If color palette management isn't really a game-specific thing (which I think it is) then a subclass of SquidLayers for additional palette management options would make more sense than the current implementation.

SquidPony commented 7 years ago

Basically I would expect the first line here to also cover the need to do the next two:

layers.setPalette(Arrays.asList(new Color[]{SColor.KIMONO_STORAGE, SColor.LIGHT_KHAKI}));

layers.getBackgroundLayer().setDefaultForeground(SColor.LIGHT_KHAKI); layers.getForegroundLayer().setDefaultForeground(SColor.KIMONO_STORAGE);

tommyettinger commented 7 years ago

I agree that the palette usage is weird. I'm in favor of breaking compatibility on it since we (well, you, I forgot about this) only recently added the ability to change the palette. As such, the palettes weren't terribly useful for most games... The main reason they exist is for squidlib-util to have some kind of standard way to say "this is a wall, this is some water, they have different colors", but that should be in squidlib (for display) anyway, and probably in code that can be customized.

I'll start tinkering with this. I think this will involve removing all of the palette-based put() methods, so I'd encourage you to remove any usage of them (you can track the palette yourself and get Colors from it with ints in the same way, then pass those Colors to SquidLayers). I don't know if other people are using the palettes much, but from what I've seen they aren't very practical and I doubt they have much usage.

tommyettinger commented 7 years ago

Fixed by removing all palette code in SquidLayers and SquidPanel; it was frequently unnecessary when a Color could be fetched yourself from an array or List of Colors for a palette that you control. For making a 2D Color array from a 2D char array, we have MapUtility in the display module, which should replace the indexed-palette-2D-array generating functions in DungeonUtility. We do need to update any demos that use the (strange) old palette-based way that are outside of the main SquidLib repo. This includes the sample with SquidSetup, which will be more of an undertaking since I'd like to rewrite SquidSetup to use czyzby's GdxSetup as a base. I'll close this for now because the palettes are NO MORE, but I may open up other issues to update related demos.