Uses incremental page numbering for the comics manager
ClosedPublic

Authored by ragnarb on Feb 4 2018, 12:24 AM.

Details

Summary

This patch changes how pages are numbered in the Comics Manager. Each time you create a new page, a page counter is incremented and stored in the comicConfig.json. This means that if you create pages 1,2 and 3, and then delete page 2 and 3, then create another page, it will be numbered 4.

The way it was before, it would look at the "pages" list in the comicConfig.json, and go for the next free page number, even if that already existed on disk. In the example above, you would wind up restoring page 2 when trying to add a new page, after deleting pages 2 and 3.

There is still a possible minor corner case (with either method) where pages can get messed up, and that is when you import pages that conflict with existing pages, or what would be the name of future pages. I'll write another patch to prevent overwriting existing pages on import, that should fix this.

Test Plan
  1. Load the Comics Manager python plug-in
  2. Create a new comic
  3. Add, import, remove and move pages around
  4. cat the content of the comicConfig.json to see the changes.

Diff Detail

Repository
R37 Krita
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ragnarb requested review of this revision.Feb 4 2018, 12:24 AM
ragnarb created this revision.

The way it was before, it would look at the "pages" list in the comicConfig.json, and go for the next free page number, even if that already existed on disk. In the example above, you would wind up restoring page 2 when trying to add a new page, after deleting pages 2 and 3.

This was actually deliberate. My logic was that... if people deleted a page from the list, this would add it back, because to the inexperienced user, getting items back into the pages list would have been more difficult, and if they really wanted to delete the file, they'd delete it from the folder.

Though, admittedly, I am not sure if it still needs to be there given old pages can be readded, on the other hand it does alert people that the page hadn t been deleted from disk... Hm... I am not sure now.

Yes, I noticed that it was intentional when I read the comments in the code, but I first thought it was a bug when I tried the Comics Manager.

The way it is currently, you can't really delete pages, and then create new ones. For instance if you have pages 1,2,3,4 and 5, and delete pages 2 and 5, then add two new pages, it will simply restore pages 2 and 5, so you wind up with pages 1,3,4,2 and 5. If you actually wanted two blank pages, you would have to go into the pages folder and remove pages 2 and 5 manually, so that they don't get restored when adding pages. In addition, you already implemented "Add Existing Pages", which can be used when you want to restore deleted pages when needed.

For a real world example I've just finished the thumbnail/rough/stick figure stage of a 110 page comic book in Clip Studio Paint, which involves moving pages around, deleting and adding pages and trying different solutions, and Clip Studio Paint basically does the same approach as this patch. Every time you add a new page , the page number is incremented, so even if I only have 110 pages in the book, the last page file is numbered 172. This means I've actually discarded 62 pages along the way. If this was the Comics Manager plug-in, in it's current state, I would either have to add 62 pages, before I got a blank one, and then re-delete those 62 pages or manually delete those pages from the "pages" folder.

(not that CSP is perfect as after you've reached around 30 pages or so manipulating pages takes ages...at 100 pages it takes close to a minute to add, remove or move a page). :)

I do plan to do my next comic in Krita, I just need to finish penciling and inking those 110 pages before I can get started on it.

woltherav accepted this revision.Feb 18 2018, 12:42 PM

Alright, considering there's 'add existing page', I think people will survive.

I'll push it for you. If you give a email today(sunday), I can properly attribute you as the commit author. (Otherwise I'll just write a thank-you)

This revision is now accepted and ready to land.Feb 18 2018, 12:42 PM
This revision was automatically updated to reflect the committed changes.