Exemple #1
0
 private void NewDeckFlyoutClosedWithoutCreatingDeckHandler()
 {
     if (helpPopup != null && AllHelps.Tutorial == AllHelps.TutorialState.DeckCreation)
     {
         helpPopup.Show();
     }
 }
Exemple #2
0
 private void HelpPopupNextEventHandler()
 {
     helpPopup.Title = "Template";
     helpPopup.SubtitleVisibility = Visibility.Collapsed;
     helpPopup.Text = AllHelps.TEMPLATE_DEFINITION +
                      "\nPlease press on the \"Edit\" icon then choose \"Edit Templates\".";
     editModelButton.Click += EditModelButtonClickHandler;
     AllHelps.Tutorial      = AllHelps.TutorialState.Template;
     NoticeMe.Begin();
     helpPopup.Show();
 }
Exemple #3
0
 private void DeckCreationTutorialSetup()
 {
     mainPage.AddButton.Click += TutorialAddButtonClickHandler;
     NewDeckCreatedEvent      += TutorialNewDeckCreatedEvent;
     helpPopup = new HelpPopup();
     UIHelper.AddToGridInFull(mainGrid, helpPopup);
     helpPopup.Title    = "Create a Deck";
     helpPopup.SubTitle = "(A place to store your cards)";
     helpPopup.Text     = "To create a deck please press on the \"Add\" icon."
                          + " Choose any names you like and use \"Basic\" type."
                          + " Leave note type name blank if you want to reuse an old note type.";
     helpPopup.SetOffSet(0, DEFAULT_HELP_POPUP_VERTICAL_OFFSET);
     helpPopup.Show();
     mainPage.NoticeMe.Begin();
 }
Exemple #4
0
 private void SharedDeckTutorialSetup()
 {
     mainPage.SplitViewToggleButton.IsEnabled = true;
     mainPage.SplitViewToggleButton.Click    += TutorialSplitViewToggleButtonClick;
     helpPopup = new HelpPopup();
     UIHelper.AddToGridInFull(mainGrid, helpPopup);
     helpPopup.Title    = "Shared Decks";
     helpPopup.SubTitle = "(Sharing is caring)";
     helpPopup.Text     = "To download and import decks created by others, please press on the button at the top-left corner.\n"
                          + "(we are not responsible for these contents.)";
     helpPopup.SetOffSet(0, DEFAULT_HELP_POPUP_VERTICAL_OFFSET);
     mainPage.NoticeMe.Stop();
     UIHelper.SetStoryBoardTarget(mainPage.BlinkingBlue, mainPage.SplitViewToggleButton.Name);
     mainPage.NoticeMe.Begin();
     helpPopup.Show();
 }
Exemple #5
0
    private void OnGUI()
    {
        if (FeaturesFetch == null)
        {
            FeaturesFetch = new WWW("https://qkrisi.xyz/ktane/kmplugins");
            return;
        }
        if (DownloadedPlugins == null)
        {
            LoadPlugins();
        }
        if (Event.current.type == EventType.Repaint)
        {
            time += Time.deltaTime;
            if (time >= 3)
            {
                time = 0;
                if (++dots == 4)
                {
                    dots = 1;
                }
            }
        }
        try
        {
            if (!FeaturesFetch.isDone || Features != null && Features.Any(f => f.Handler != null && !f.Handler.Ready))
            {
                EditorGUILayout.HelpBox("Fetching plugins for the KTaNE Modkit" + new String('.', dots), MessageType.Info, true);
                return;
            }
            if (!String.IsNullOrEmpty(FeaturesFetch.error))
            {
                EditorGUILayout.HelpBox("Network error: " + FeaturesFetch.error, MessageType.Error, true);
                if (GUILayout.Button("Retry"))
                {
                    Reset();
                }
                return;
            }

            FeatureInfo Downloading = null;
            float       height      = position.height - 45;
            if (Features != null && !Features.Any(f => f.Handler == null))
            {
                Downloading = Features.FirstOrDefault(f => f.Handler != null && !f.Handler.Downloader.Ready);
                if (Downloading != null)
                {
                    var progress = Downloading.Handler.Downloader.Progress;
                    EditorGUI.ProgressBar(new Rect(0, 0, position.width, ProgressBarHeight), progress.Progress,
                                          String.Format("Downloading {0} {1}", Downloading.Name, progress.ConvertedProgress));
                    GUILayout.Space(ProgressBarHeight);
                    height -= ProgressBarHeight;
                }
            }
            else
            {
                Features = JsonConvert.DeserializeObject <FeatureInfo[]>(FeaturesFetch.text);
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandWidth(false), GUILayout.Width(FeatureButtonWidth));
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            if (GUILayout.Button("Refresh", GUILayout.Width(RefreshButtonWidth)))
            {
                Reset();
                goto finish;
            }
            EditorGUILayout.EndHorizontal();
            ScrollPos = EditorGUILayout.BeginScrollView(ScrollPos, GUILayout.Height(height), GUILayout.Width(FeatureButtonWidth + 20));
            foreach (var feature in Features)
            {
                CreateFeatureButton(feature);
            }
            EditorGUILayout.EndScrollView();
            if (LinkButton("Adding plugins"))
            {
                if (HelpWindow == null)
                {
                    HelpWindow          = GetWindow <HelpPopup>(true, "Adding plugins", true);
                    HelpWindow.position = new Rect(Screen.width / 2 - 250, Screen.height / 2 - 50, 500, 100);
                    HelpWindow.Show();
                }
                else
                {
                    HelpWindow.Focus();
                }
            }
            EditorGUILayout.EndVertical();
            if (CurrentFeature != null && CurrentFeature.Handler != null)
            {
                EditorGUILayout.BeginVertical(EditorStyles.helpBox, GUILayout.ExpandWidth(false),
                                              GUILayout.Width(position.width - FeatureButtonWidth - 40));
                GUILayout.Label(String.Format("<i>{0} (By {1})</i>", CurrentFeature.Name, CurrentFeature.Author), RichStyle);
                EditorGUILayout.BeginHorizontal();
                var AffectedFiles = new string[0];
                try
                {
                    AffectedFiles = CurrentFeature.Handler.Downloader.AffectedFiles;
                }
                catch {}
                GUI.enabled = Downloading == null;
                var downloadedPlugin = DownloadedPlugins.FirstOrDefault(p => p.Name == CurrentFeature.Name);
                if (downloadedPlugin == null)
                {
                    CurrentFeature.Handler.Draw();
                    if (GUILayout.Button("Install", GUILayout.Width(DownloadButtonWidth)))
                    {
                        DownloadedPlugins.Add(CurrentFeature.Handler.Download());
                    }
                    SavePlugins();
                }
                else
                {
                    GUILayout.Label("<color=green>✓</color> Installed" + (String.IsNullOrEmpty(downloadedPlugin.Info)
                            ? ""
                            : String.Format(" ({0})", downloadedPlugin.Info)), RichStyle, GUILayout.ExpandWidth(false));
                    GUILayout.Space(5);
                    if (GUILayout.Button("Remove", GUILayout.Width(DownloadButtonWidth)))
                    {
                        foreach (var file in downloadedPlugin.Files)
                        {
                            var ModkitPath = Path.Combine(DataPath, file);
                            if (CurrentFeature.Integration)
                            {
                                var Backup = Path.Combine(BackupPath, file);
                                if (File.Exists(Backup))
                                {
                                    File.Copy(Backup, ModkitPath, true);
                                    continue;
                                }
                                if (Directory.Exists(Backup))
                                {
                                    EnsureAbsoluteDirectoryExists(ModkitPath);
                                    CopyFilesRecursively(new DirectoryInfo(Backup), new DirectoryInfo(ModkitPath));
                                    continue;
                                }
                            }
                            Remove(ModkitPath);
                        }
                        DownloadedPlugins.Remove(downloadedPlugin);
                        SavePlugins();
                    }
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
                GUILayout.Space(10);
                GUILayout.Label(CurrentFeature.Description, RichStyle);
                GUILayout.Space(10);
                if (CurrentFeature.Links != null)
                {
                    GUILayout.Label("<i>Links:</i>", RichStyle);
                    foreach (var pair in CurrentFeature.Links)
                    {
                        if (LinkButton(pair.Key))
                        {
                            Application.OpenURL(pair.Value);
                        }
                    }
                    GUILayout.Space(10);
                }
                GUILayout.Label("<i>Files or directories created/modified:</i>\n-" + String.Join("\n-", AffectedFiles), RichStyle);
            }
            else
            {
                GUILayout.BeginVertical();
            }
finish:
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndHorizontal();
        }
        catch (ArgumentException)
        {
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Exemple #6
0
    public override void _UnhandledInput(InputEvent e)
    {
        if (_player == null ||
            _deityPopup.Visible ||
            _characterPopup.Visible ||
            _helpPopup.Visible ||
            _alterPopup.Visible ||
            _messagePopup.Visible)
        {
            return;
        }

        if (e is InputEventKey key && key.Pressed)
        {
            switch (key.Scancode)
            {
            case (int)KeyList.Escape:
                if (_player.HP < 1)
                {
                    Globals.Reset();
                    GetTree().ChangeScene("res://TitleScene.tscn");
                }
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Tab:
                _deityPopup.Show();
                foreach (var a in _level.Agents)
                {
                    GD.Print($"{a.DisplayName} {a.HP}/{a.HPMax} {a.AP}+{a.APRegeneration}");
                }
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.M:
                _messagePopup.Show(_level, _player);
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.G:
                _nextPlayerCommand = new PickupItem();
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Left:
                _nextPlayerCommand = new MoveBy(-1, 0);
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Right:
                _nextPlayerCommand = new MoveBy(1, 0);
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Up:
                _nextPlayerCommand = new MoveBy(0, -1);
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Down:
                _nextPlayerCommand = new MoveBy(0, 1);
                GetTree().SetInputAsHandled();
                break;

            case (int)KeyList.Period:
                _nextPlayerCommand = new MoveBy(0, 0);
                GetTree().SetInputAsHandled();
                break;
            }
            switch ((char)key.Unicode)
            {
            case '?':
                _helpPopup.Show();
                GetTree().SetInputAsHandled();
                break;

            case '@':
                _characterPopup.Show(_player);
                GetTree().SetInputAsHandled();
                break;
            }
        }

        UpdateUI();
    }