void DoSave(Widget widget, MouseButton mouseBtn, string ext) { if (mouseBtn != MouseButton.Left) { return; } string text = inputWidget.GetText(); if (text.Length == 0) { MakeDescWidget("&ePlease enter a filename"); return; } string file = Path.ChangeExtension(text, ext); text = Path.Combine(Program.AppDirectory, "maps"); text = Path.Combine(text, file); if (File.Exists(text) && widget.Metadata == null) { ((ButtonWidget)widget).SetText("&cOverwrite existing?"); ((ButtonWidget)widget).Metadata = true; } else { // NOTE: We don't immediately save here, because otherwise the 'saving...' // will not be rendered in time because saving is done on the main thread. MakeDescWidget("Saving.."); textPath = text; RemoveOverwrites(); } }
void SaveChangesClick(Game game, Widget widget) { if (origHotkey.BaseKey != Key.Unknown) { hotkeys.RemoveHotkey(origHotkey.BaseKey, origHotkey.Flags); hotkeys.UserRemovedHotkey(origHotkey.BaseKey, origHotkey.Flags); } MenuInputWidget input = (MenuInputWidget)widgets[actionI]; if (curHotkey.BaseKey != Key.Unknown) { hotkeys.AddHotkey(curHotkey.BaseKey, curHotkey.Flags, input.GetText(), curHotkey.StaysOpen); hotkeys.UserAddedHotkey(curHotkey.BaseKey, curHotkey.Flags, curHotkey.StaysOpen, input.GetText()); } game.Gui.SetNewScreen(new HotkeyListScreen(game)); }
void ChangeSetting() { string text = inputWidget.GetText(); if (inputWidget.Validator.IsValidValue(text)) { targetWidget.SetValue(game, text); } DisposeWidgets(); UpdateDescription(targetWidget); targetWidget = null; InputClosed(); }