YingFengTingYu / PopStudio_Old

A project to convert many kinds of files used in PopCap Games.
Apache License 2.0
104 stars 12 forks source link

Can't select folder #4

Closed nineteendo closed 2 years ago

nineteendo commented 2 years ago

So I was trying to compare the speed of PopStudio with PyVZ2 which I just updated to v1.2.0 (https://github.com/Nineteendo/PVZ2tools). But I noticed I can't select folders. Could you please support that such that I can compare?

YingFengTingYu commented 2 years ago

Maybe you can enter the folder path directly.

nineteendo commented 2 years ago

Doesn't work. (Also with / at the end) Screenshot 2022-06-27 at 13 35 58

YingFengTingYu commented 2 years ago

RTON decoding and encoding just supports single file. If you want to decode or encode all RTON in a folder, you need to use Lua Script function. There's the code to decode all RTON in a folder

local filepath = "/Users/..."; -- Enter your folder path local files = rainy.getfiles(filepath); for i=1,#files do local a = string.lower(rainy.getfileextension(files[i])); local b = rainy.getfilenamewithoutextension(files[i]); if a == ".rton" then rainy.decoderton(files[i], rainy.formatpath(rainy.getfilepath(files[i]) .. "\" .. b .. ".json"), 0); if delete then rainy.deletefile(files[i]); end end end

nineteendo commented 2 years ago

Line 7 is incomplete. Executing error: ')' expected (to close '(' at line 7) near '.'

YingFengTingYu commented 2 years ago

Change "\" to "\\"

nineteendo commented 2 years ago

But I can't see how long that took. It's very quick though.

YingFengTingYu commented 2 years ago

Use this code:

local time_begin = os.time(); local filepath = "D:\rsb资源\phone_v4_android"; -- Enter your folder path local files = rainy.getfiles(filepath); for i=1,#files do local a = string.lower(rainy.getfileextension(files[i])); local b = rainy.getfilenamewithoutextension(files[i]); if a == ".rton" then rainy.decoderton(files[i], rainy.formatpath(rainy.getfilepath(files[i]) .. "/" .. b .. ".json"), 0); if delete then rainy.deletefile(files[i]); end end end local time_end = os.time(); print("It takes " .. time_end - time_begin .. " seconds to decode.")

nineteendo commented 2 years ago

How is your tool 5 times faster in doing that? Multithreading? Does that have something to do with using a different output folder? Your tool: It takes 1.568983793258667 seconds to decode. My tool: finished unpacking in 0:00:08.367731 Code: https://github.com/Nineteendo/PVZ2tools/blob/master/OBBEdit/libraries/pyvz2rton.py

YingFengTingYu commented 2 years ago

I'm not sure. I don't use multithreading when decoding RTON. I only use multithreading to ensure UI response. Do you transcode ASCII/UTF8 string to unicode string and then write it into json? My tool does not transcode ASCII/UTF8 string to unicode string. This step takes up a lot of time.

nineteendo commented 2 years ago

So first of all I'm using Python (which is not very fast) And this is likely very slow: json.dumps(self.parse_text(fp), ensure_ascii = self.ensureAscii).encode() With this extra functions:

def parse_number(self, fp):
        num = fp.read(1)[0]
        result = num & 0x7f
        i = 128
        while num > 127:
            num = fp.read(1)[0]
            result += i * (num & 0x7f)
            i *= 128
        return result

def parse_text(self, fp):
    # types 81, 90
        byte = fp.read(self.parse_number(fp))
        try:
            return byte.decode()
        except Exception:
            return byte.decode('latin-1')
nineteendo commented 2 years ago

Would you please add folder support to the next update? And do you have Discord? (https://discord.gg/CVZdcGKVSw) I would like to discuss PyVZ2.

YingFengTingYu commented 2 years ago

Maybe I'll add it in the next update. I have some difficulties in registering Discord. It indicates that I need to verify my mobile phone, but no text message is sent. Maybe my region doesn't support using it.

nineteendo commented 2 years ago

Strange, because my server shouldn't require it. I could maybe try turning off all restrictions?

Screenshot 2022-06-27 at 14 27 25
YingFengTingYu commented 2 years ago

Now I've successfully enterred this channel. Thanks.

nineteendo commented 2 years ago

I have send you a direct message. And you can follow the development of my tool in #pyvz2-github

nineteendo commented 2 years ago

Have you implemented it?

YingFengTingYu commented 2 years ago

Have you implemented it?

I'm doing it. And it will be added in the next version.