void OkButtonClick(Game game, Widget widget)
        {
            string text = inputWidget.GetText();

            if (text.Length == 0)
            {
                MakeDescWidget("Please enter a filename");
                return;
            }
            string file = Path.ChangeExtension(text, ".cw");

            text = Path.Combine(Program.AppDirectory, "maps");
            text = Path.Combine(text, file);

            if (File.Exists(text))
            {
                buttons[1] = ButtonWidget.Create(game, 0, 90, 260, 30, "Overwrite existing?",
                                                 Anchor.Centre, Anchor.Centre, titleFont, OverwriteButtonClick);
            }
            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;
                RemoveOverwriteButton();
            }
        }
예제 #2
0
        void SaveChangesClick(Game game, Widget widget)
        {
            if (curHotkey.BaseKey != Key.Unknown)
            {
                hotkeys.AddHotkey(curHotkey.BaseKey, curHotkey.Flags,
                                  currentAction.GetText(), curHotkey.MoreInput);
                hotkeys.UserAddedHotkey(curHotkey.BaseKey, curHotkey.Flags,
                                        curHotkey.MoreInput, currentAction.GetText());
            }

            for (int i = 0; i < numButtons; i++)
            {
                Set(i);
            }
            DisposeEditingWidgets();
        }
        void ChangeSetting()
        {
            string text = inputWidget.GetText();

            if (inputWidget.Validator.IsValidValue(text))
            {
                targetWidget.SetValue(game, text);
            }
            if (inputWidget != null)
            {
                inputWidget.Dispose();
            }
            widgets[widgets.Length - 2] = null;
            inputWidget = null;
            UpdateDescription(targetWidget);
            targetWidget = null;

            int okayIndex = widgets.Length - 1;

            if (widgets[okayIndex] != null)
            {
                widgets[okayIndex].Dispose();
            }
            widgets[okayIndex] = null;
            InputClosed();
        }
        void ChangeSetting()
        {
            string text = inputWidget.GetText();

            if (inputWidget.Validator.IsValidValue(text))
            {
                targetWidget.SetValue(game, text);
            }
            inputWidget.Dispose();
            inputWidget = null;
            UpdateDescription(targetWidget);
            targetWidget = null;

            buttons[okayIndex].Dispose();
            buttons[okayIndex] = null;
            InputClosed();
        }