Pidgeot / python-lnp

Cross-platform re-implementation of the Lazy Newb Pack launcher.
ISC License
65 stars 10 forks source link

Show a preview of a graphics pack including tileset, colors, and graphics #141

Open Pidgeot opened 4 years ago

Pidgeot commented 4 years ago

Here's a proof of concept.

The idea is to add a preview option to graphics packs, and tileset configuration within them. Ultimately it could also replace the current colorscheme preview.

A few things need to be done for basic PyLNP integration:

[Issue created by PeridexisErrant: 2015-01-29] [Last updated on bitbucket: 2015-05-13]

[Comment created by Pidgeot: 2015-05-13] Initial implementation pushed in commit 36f2df2, created pull request #49 for discussion of further refinement. Most notably, TWBT emulation is still missing.

[Comment created by Pidgeot: 2015-04-13] preview_wanderlust.png

That's basic drawing done - still need to hook everything into the UI so the right tilesets get used, updates happen live, etc.

It took 0.141 seconds to draw that, by the way; I think that's perfectly acceptable for this purpose.

[Comment created by PeridexisErrant: 2015-04-13] Looks great!

[Comment created by Pidgeot: 2015-04-13] The TypeError happens because the images I referred to are using a palette - they're not in a format that can be used with a mask (it needs to be RGBA or greyscale). Also, these images seem to use palette index 0 to indicate transparency. I've fixed that by adding a bit of code to catch these files, convert them to RGBA, and then apply a mask generated from the paletted image data.

curses_preview.png

I still need to figure out how to get PIL to do the right coloration. The calculation itself is quite straightforward, but I've not yet figured out how to get PIL to do it - worst case, I'll have to resort to calculating it manually (and then I have to hope it doesn't get too slow).

[Comment created by PeridexisErrant: 2015-02-05] Awesome that it's happening!

No idea where the TypeError comes in. I started this while travelling, so CLA was simply the nice ascii set I had locally; the color-adding system I've got is apparently correct for tiles that don't have native color (which should be preserved). Unfortunately I couldn't get PhotoImage to work, hence the ugly gif-based workaround.

[Comment created by Pidgeot: 2015-02-05] This is going to be on my todo-list for 1.0. I have a pretty good idea about how I'm going to tackle it; the main thing I have to do is figure out how to read and write the individual pixels (that will be required for rendering)

I do not, however, expect to do any work on this at least until I've had my CPU replaced.

Some minor notes, in case you do more work yourself: