/// <summary> /// Generic error dialog. /// </summary> void baddog() { string info = "Labels have a max length of 16 characters, a" + Environment.NewLine + "min length of 1 character, and may contain" + Environment.NewLine + "only alphanumeric or underscore characters."; using (var f = new InfoDialog(Globals.Error, info)) f.ShowDialog(this); }
/// <summary> /// Opens a dialog to edit a Locale's languageid. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void contextclick_EditLocale(object sender, EventArgs e) { var parent = (GffData.Field)SelectedNode.Parent.Tag; if (parent.localeflags != LocaleDialog.Loc_ALL) { var field = (GffData.Field)SelectedNode.Tag; GffData.Locale locale; locale = parent.Locales[(int)field.localeid]; _langid = locale.langid; _langf = locale.F; using (var f = new LocaleDialog(parent.localeflags, true)) { if (f.ShowDialog(this) == DialogResult.OK && (locale.langid != _langid || locale.F != _langf)) { LocaleDialog.ClearLocaleFlag(ref parent.localeflags, locale.langid, locale.F); field.label = GffData.Locale.GetLanguageString(locale.langid = _langid, locale.F = _langf); ((Sortable)SelectedNode)._label = field.label; LocaleDialog.SetLocaleFlag(ref parent.localeflags, _langid, _langf); SelectedNode.Text = GeneralGFF.ConstructNodetext(field, locale); _f.GffData.Changed = true; _f.GffData = _f.GffData; } } } else { using (var f = new InfoDialog(Globals.Error, "All locales are taken.")) f.ShowDialog(this); } }
/// <summary> /// Opens a dialog to edit a Field's Label. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void contextclick_EditLabel(object sender, EventArgs e) { using (var f = new LabelDialog(((GffData.Field)SelectedNode.Tag).label)) { if (f.ShowDialog(this) == DialogResult.OK) { var field = (GffData.Field)SelectedNode.Tag; if (field.label != f.tb_Label.Text) { bool abort = false; var parent = (GffData.Field)SelectedNode.Parent.Tag; if (parent == null || // ie. 'parent' is TopLevelStruct parent.type == FieldTypes.Struct) { for (int i = 0; i != SelectedNode.Parent.Nodes.Count; ++i) { if (SelectedNode.Parent.Nodes[i] != SelectedNode && ((Sortable)SelectedNode.Parent.Nodes[i])._label == f.tb_Label.Text) { using (var g = new InfoDialog(Globals.Error, "Duplicate labels detected.")) g.ShowDialog(this); abort = true; break; } } } if (!abort) { field.label = (((Sortable)SelectedNode)._label = f.tb_Label.Text); SelectedNode.Text = GeneralGFF.ConstructNodetext(field); _f.GffData.Changed = true; _f.GffData = _f.GffData; } } } } }
/// <summary> /// Adds a Locale to a CExoLocString Field. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void contextclick_AddLocale(object sender, EventArgs e) { var field = (GffData.Field)SelectedNode.Tag; if (field.localeflags != LocaleDialog.Loc_ALL) { using (var f = new LocaleDialog(field.localeflags)) { if (f.ShowDialog(this) == DialogResult.OK) { var locale = new GffData.Locale(); locale.local = String.Empty; LocaleDialog.SetLocaleFlag(ref field.localeflags, locale.langid = _langid, locale.F = _langf); if (field.Locales == null) { field.Locales = new List <GffData.Locale>(); } var fieldloc = new GffData.Field(); fieldloc.type = FieldTypes.locale; fieldloc.label = GffData.Locale.GetLanguageString(_langid, _langf); fieldloc.localeid = (uint)field.Locales.Count; field.Locales.Add(locale); AddField(fieldloc, locale); } } } else { using (var f = new InfoDialog(Globals.Error, "All locales are taken.")) f.ShowDialog(this); } }
/// <summary> /// A generic error dialog. /// </summary> /// <param name="er"></param> internal static void error(string er) { using (var f = new InfoDialog(Globals.Error, er)) f.ShowDialog(); }
protected override void OnFormClosing(FormClosingEventArgs e) { if (DialogResult == DialogResult.OK && e.CloseReason != CloseReason.WindowsShutDown && e.CloseReason != CloseReason.TaskManagerClosing) { TreeList tl = ((GeneralGFF)Owner)._tl; string error = null; if (String.IsNullOrEmpty(tb_var.Text)) { error = "The variable label cannot be null."; tb_var.Select(); } else if (String.IsNullOrEmpty(tb_val.Text)) { error = "The variable value cannot be null."; tb_val.Select(); } else if (tl.CheckVariableForRedundancy(_varType, tb_var.Text)) { error = "That variable label+type already exists."; tb_var.Select(); } else { switch (_varType) { case Type_non: // not stable in toolset. Disabled error = "Type is not stable in toolset. Disabled"; break; case Type_INT: { int result; if (!Int32.TryParse(tb_val.Text, out result)) { error = "That is not a valid value."; } break; } case Type_FLOAT: { float result; if (!Single.TryParse(tb_val.Text, out result)) { error = "That is not a valid value."; } break; } // case Type_STRING: // is okay. // break; case Type_UINT: { uint result; if (!UInt32.TryParse(tb_val.Text, out result)) { error = "That is not a valid value."; } break; } case Type_LOCATION: // not stable in toolset. Disabled error = "Type is not stable in toolset. Disabled"; break; } } if (error != null) { e.Cancel = true; using (var f = new InfoDialog(Globals.Error, error)) f.ShowDialog(this); } else { tl._varLabel = tb_var.Text; tl._varValue = tb_val.Text; tl._varType = _varType; // uh ... } } }