Generate Ren'Py Scripting v1.0 released!

I made a plugin that exports Ren’Py positional script given the Krita document’s layers’ properties! It uses the name syntax from the officially included batch exporter from GDQuest. I have examples in the manual.

3 Likes

I need help fixing one thing though: Currently, the calculator widget doesn’t update once a document is loaded, so to see the starting 100% dimensions, you have to change the spinbutton number. How do I get the signal for opening a document into my class?

Check out the Notifier class. There is imageCreated and viewCreated depending on your need. There is also activeViewChanged in Window if you need to adjust if the view is changed.

Side note: I suggest Python Developer Tools where you can see the entire Krita API and documentation.

1 Like

Thanks. That plugin is excellent.

I almost have it all figured out. Here’s what’s left:

    def __init__(self):
        super().__init__()
        self.setWindowTitle(self.title)
        self.createInterface()
        open_notifier.imageCreated.connect(self.updateScaleCalculation) # A
        open_notifier.imageCreated.connect(self.registerView)           # B
        #close_notifier.imageClosed.connect(self.wipeScaleCalculation)  # C
        self.mainWindow = None

    def registerView(self):
        self.mainWindow = KI.activeWindow()
        self.mainWindow.activeViewChanged.connect(self.updateScaleCalculation) # D

Signal A updates the numbers once a document is opened.
Signal B allows Signal D to work (since that’s right when the first view becomes available).
Signal C resets the numbers to 0 when a view is closed.
Signal D allows the numbers to update when the user switches between two different documents.

If only A, B, and D are used, then everything is well, except that closing the last document doesn’t reset the numbers to 0.

If C is used, then the numbers always reset to 0 whenever a document is closed (overwriting D’s result).

I tried doing a condition check for a document or a view in updateScaleCalculation() in order to call wipeScaleCalculation(), but that didn’t work because the document is still considered open at the moment it’s called. Even setting the close_notifier to this def shows this:

    def bang(self):
        msg = QMessageBox()
        msg.setGeometry(100, 200, 100, 100)
        msg.setText("B")
        if KI.activeDocument() == None:
            msg.setText("No Doc") # This never shows up.
        msg.exec_()

I checked the documentation on Notifier and Window, and there isn’t a signal for closing specifically the last view/document. What should I do?

You have option of viewClosed too. And make sure if there are any views open by checking the len of Window’s views()

1 Like
    def wasLast(self):
        if len(KI.activeWindow().views()) == 1:
            self.wipeScaleCalculation()

Looks a bit weird, but this does it. Thanks!

Now it’s at version 1.3.

The new feature is tentatively called “Rename Batch-Exported Files”.

The Batch Exporter exports all the images, with the suffix _@[scale] added, to a single folder called export.
This meant that to use the images in your Ren’Py project (in which you likely don’t want to have the scales in the file names), you would have to rename the files manually.

This new feature copies the smallest scale images to a new folder within export called x[scale]. In this folder, the images themselves have the suffix removed, so they are ready to cut and paste into your Ren’Py project (much like how the main scripting system works).