News:

Wondering if this will always be free?  See why free is better.

Main Menu

[WIP] Mod Builder

Started by NanoSector, December 24, 2012, 08:05:46 PM

Previous topic - Next topic

NanoSector

Released 1.1. Although still buggy (and bug patches will be released), it now converts mod packages into projects ready to be edited using the Mod Editor. So insert any mod that you feel needs an edit and it'll be ready to be edited!
I also fixed a couple of bugs.

1.1.1 released immediately after which fixes a bug with update checking.

Happy modding!
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Adrek

Don't know if they are known bugs, but I'll report them anyway :)

If package ID contains underline, it's being removed after package is converted to MM format.
If in package-info.xml is readme 'inline' then it's not converted.
In operation edit window new lines are not parsed (all is in one line, however after saving package it looks fine)

And small suggestion - could you replace "Browse for folder" window with this one used by SMF in (for example) attachments select? It would be much easier to find desired folder :)
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

NanoSector

Quote from: phantomm on February 06, 2013, 02:21:54 PM
Don't know if they are known bugs, but I'll report them anyway :)

If package ID contains underline, it's being removed after package is converted to MM format.
Mod Manager removes everything from the ID except for letters and numbers. I don't know which characters are allowed in the package ID, but I can add _ to the regex.

QuoteIf in package-info.xml is readme 'inline' then it's not converted.
It should be... Can you send me a sample package or a link to the mod you downloaded?

QuoteIn operation edit window new lines are not parsed (all is in one line, however after saving package it looks fine)
Hmm that's a bug... I'll look into this. The same happens with readmes and custom code apparently.

QuoteAnd small suggestion - could you replace "Browse for folder" window with this one used by SMF in (for example) attachments select? It would be much easier to find desired folder :)
I've been trying to do this, but found no way to do this easily. This is a .NET limitation, sadly :(

Thanks :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

QuoteMod Manager removes everything from the ID except for letters and numbers. I don't know which characters are allowed in the package ID, but I can add _ to the regex.

It's actually very generous. SMF itself doesn't really care, the mod site doesn't like spaces but other than that, it just has to fit into 32 characters including the :.

Alphanumeric plus _ should really be it honestly.
Holder of controversial views, all of which my own.


NanoSector

Quote from: Arantor on February 07, 2013, 02:00:16 PM
QuoteMod Manager removes everything from the ID except for letters and numbers. I don't know which characters are allowed in the package ID, but I can add _ to the regex.

It's actually very generous. SMF itself doesn't really care, the mod site doesn't like spaces but other than that, it just has to fit into 32 characters including the :.

Alphanumeric plus _ should really be it honestly.
Thanks, I'll add _ to the regex in the next update.

Since I'm not a regex master, I would just replace this:
[^a-zA-Z0-9]

With this:
[^a-zA-Z0-9_]

Right?
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Pretty much. Hard to say without seeing the whole thing. Personally I wouldn't validate that it doesn't contain things it shouldn't, I'd validate it that it is valid as a whole.

/^[a-z0-9_]+:[a-z0-9_]+$/i and then validate the entire length as <= 32.
Holder of controversial views, all of which my own.


NanoSector

                string an = System.Text.RegularExpressions.Regex.Replace(authorName.Text, @"[^a-zA-Z0-9_]", "");
                string mn = System.Text.RegularExpressions.Regex.Replace(modName.Text, @"[^a-zA-Z0-9_]", "");
                modID.Text = an + ":" + mn;


It combines the author name and the mod title to the ID.

Should I check if the author name does not exceed 9 characters and that the title does not exceed 22 characters?
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Adrek

Quote from: Yoshi2889 on February 06, 2013, 03:02:01 PM
QuoteIf in package-info.xml is readme 'inline' then it's not converted.
It should be... Can you send me a sample package or a link to the mod you downloaded?

You have PM with URL to test package.
Polskie wsparcie SMF na simplemachines.org

the simplest solution is most likely the right one

Arantor

QuoteShould I check if the author name does not exceed 9 characters and that the title does not exceed 22 characters?

9 characters because that's all you need to fit in your own name?

No, you should do what I already suggested. Alphanumeric and _, at least one character in each, total string <= 32 in length.
Holder of controversial views, all of which my own.


NanoSector

Quote from: Arantor on February 07, 2013, 02:21:51 PM
QuoteShould I check if the author name does not exceed 9 characters and that the title does not exceed 22 characters?

9 characters because that's all you need to fit in your own name?
Heh, now that you say it... :P
I didn't even think of that, honestly.

QuoteNo, you should do what I already suggested. Alphanumeric and _, at least one character in each, total string <= 32 in length.
But what happens when the author name exceeds 32 characters?

Thanks phantomm :)
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

QuoteBut what happens when the author name exceeds 32 characters?

You misunderstand me.

The *entire string*, user:name has to be 32 or less characters. So validate the whole string is valid then check its entire length.
Holder of controversial views, all of which my own.


NanoSector

Quote from: Arantor on February 07, 2013, 02:35:48 PM
QuoteBut what happens when the author name exceeds 32 characters?

You misunderstand me.

The *entire string*, user:name has to be 32 or less characters. So validate the whole string is valid then check its entire length.
Yeah, I know, but when the authorname is something along the lines of "thisisaverylongusernamewithalotoftextinit" it will push the : and everything after it off the shelf.

I have the code ready...just that issue. I know it's not something I should be worried about (most names aren't that long) but it may get an issue.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

QuoteYeah, I know, but when the authorname is something along the lines of "thisisaverylongusernamewithalotoftextinit" it will push the : and everything after it off the shelf.

ARGH.

Then it will automatically fail by being too long anyway!

Quotebut it may get an issue.

Yes, the issue is that the user is trying to use a string that is too long. The rule is really simple: user + colon + mod name <= 32 characters. The length of the username is irrelevant; mod site doesn't care, package manager doesn't care. It just has to be under 32 characters in total.
Holder of controversial views, all of which my own.


NanoSector

                string an = System.Text.RegularExpressions.Regex.Replace(authorName.Text, @"[^a-zA-Z0-9_]", "");
                string mn = System.Text.RegularExpressions.Regex.Replace(modName.Text, @"[^a-zA-Z0-9_]", "");
                string tmpstr = (an + ":" + mn).Substring(0, 32);
                if (tmpstr.Length > 32)
                    tmpstr = tmpstr.Substring(0, 32);
                modID.Text = tmpstr;


That's what I have now. Works well, though is that what you mean?
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Um... how does no sound?

In PHP, it would be:
$packageid = $authorName . ':' . $modName;
if (preg_match('/[a-z0-9_]+:[a-z0-9_]+/i', $packageid) && strlen($packageid) <= 32)
{
  // do whatever you do with valid ones
}

Don't do this string cropping because you're completely missing the point of it.
Holder of controversial views, all of which my own.


NanoSector

No sounds good, I love getting one at times :)

Though when it's automatically generated I'll need to chop off some content, since it's supposed to be automatic. Not sure how I'll tackle the manual editing, since it's not as easy as "Don't allow the change in the textbox".
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Well... when users press the big shiny go button, validate it, if it fails, warn the user and abort the package generation. It's not that hard to do...
Holder of controversial views, all of which my own.


Matthew K.

That regex would throw out my username then which contains -.

NanoSector

Quote from: Arantor on February 07, 2013, 03:09:56 PM
Well... when users press the big shiny go button, validate it, if it fails, warn the user and abort the package generation. It's not that hard to do...
There's no go button, it's done in the Editor itself. The ID is not touched when converting a package.

@Labradoodle: If - is valid, I'll add it into the regex. Not sure what more I could add, open for suggestions.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

Arantor

Stop being literal.

Whatever process that occurs whereupon the id is collated, notify the user and abort the process.
Holder of controversial views, all of which my own.


Advertisement: