Flag Editing in the Zone Editor

There’s a ton of things in the MUD engine that use flags. Rather than go through and create a separate dialog box to edit each batch of flags, I’ve come up with a way that just lets me tell the flag editor dialog what type of flags it’s using and it will fetch them and populate itself. That means it only takes a few lines of code to be able to edit the flags on a mob/object/room/shop/exit/etc.

Here’s an example:

private void btnEditExtraFlags_Click( object sender, EventArgs e )
{
int value = 0;
bool parsed = Int32.TryParse( txtExtraFlags.Text, out value );
FlagEditor editor = new FlagEditor( FlagType.item_flags, value, 0 );
DialogResult result = editor.ShowDialog();
if( result == DialogResult.OK )
{
txtExtraFlags.Text = editor.Value.ToString();
}
}

This means that something that would have been an entire class (probably >150 lines of code for each set of flags) is now reduced to <10 lines of code per item.

Here’s the resulting dialog:

Flag Editor Screenshot

There’s a fair amount of behind-the-scenes code, but it’s still pretty easy and efficient.  With this change I’m pretty far along on the zone editor.  Sometime in early March I hope to be able to create a working mini-zone with it.  After I declare it usable I’ll make it available for download.