Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Pidgeot opened this issue Apr 4, 2020 · 0 comments
Open
Assignees

Comments

@Pidgeot
Copy link
Owner

Pidgeot commented Apr 4, 2020

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:

  • My code added to core/graphics, including PIL importing
  • Interface created in tkgui/graphics - maybe a Canvas in a messagebox?
  • Enable the colors-retrieval function (relies on core/colors)
  • Pass the correct tileset (currently just hardcoded for testing)
  • Write a plan each to display for FONT and GRAPHICS_FONT
  • Check the way colors are added conforms to DF
  • (optional) Also handle colors from the raws.

[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:

  • Some tilesets don't seem to work, e.g. curses_640x300 and curses_square_16x16 (causes TypeError: an integer is required when paste is called). Not sure why; haven't checked thoroughly
  • This tileset should be great for comparing with DF rendering.
  • With PIL, you can save as PNG as well - PIL_image.save('preview.png', format='PNG') - this allows truecolor graphics, which is pretty much going to be necessary
  • You don't actually need to save to a file, you can just import ImageTk and use self.TK_image = ImageTk.PhotoImage(PIL_image) to show the image.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant