コード例 #1
0
        private void SpawnDialog()
        {
            if (multi_dialog != null)
            {
                if (ClampToScreen())
                {
                    multi_dialog.dialogRect.Set(MainGUIWindowPos.x, MainGUIWindowPos.y, width, height);
                }

                popup_dialog = PopupDialog.SpawnPopupDialog(multi_dialog, false, HighLogic.UISkin, false, "");
                popup_dialog.onDestroy.AddListener(new UnityAction(OnPopupDialogDestroy));
                popup_dialog.SetDraggable(true);
            }
        }
コード例 #2
0
        private void DrawPopupStuff()
        {
            LoadNewImage();

            //If showing window, image exists, and no popup exists currently
            if (isShowingWindow == true)
            {
                if (myPopupDialog == null && imageOfSun != null)
                {
                    //Release the kraken
                    myPopupDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.3f, 0.3f),
                                                                 new Vector2(0.3f, 0.3f),
                                                                 new MultiOptionDialog(
                                                                     "Solar STEREO Image",
                                                                     "",
                                                                     "Solar STEREO Image",
                                                                     HighLogic.UISkin,
                                                                     new Rect(0.25f, 0.25f, imageOfSun.width / 2, imageOfSun.height / 2),
                                                                     new DialogGUIBase[]
                    {
                        new DialogGUIImage(new Vector2(1, imageOfSun.height / 2),
                                           new Vector2(0, 0), new Color(1, 1, 1, 1), imageOfSun),

                        new DialogGUIFlexibleSpace(),

                        new DialogGUIHorizontalLayout(
                            ),

                        new DialogGUIButton("close",
                                            delegate
                        {
                            isShowingWindow = false;
                            imageOfSun      = GameDatabase.Instance.GetTexture(blackImage, false);
                        },
                                            true)
                    }
                                                                     ),
                                                                 false,
                                                                 HighLogic.UISkin);
                }
                myPopupDialog.SetDraggable(true);
            }
            else
            {
                myPopupDialog.Dismiss();
                imageOfSun = GameDatabase.Instance.GetTexture(blackImage, false);
            }
        }
コード例 #3
0
    public void ViewPhoto()
    {
        Vector2 size;
        Texture composite = photo.GetComposite();

        if (composite.width > 720)
        {
            size.x = 720;
            size.y = 720 * composite.height / composite.width;
        }
        else
        {
            size.x = composite.width;
            size.y = composite.height;
        }

        MultiOptionDialog multiOptionDialog =
            new MultiOptionDialog(
                "Popup",
                "This is gonna look great!",
                isPanorama ? "View panorama" : "View photo",
                HighLogic.UISkin,
                size.x + 20,
                new DialogGUIBase[]
        {
            new DialogGUIImage(size,
                               new Vector2(0.0f, 0.0f), Color.white, composite),
            dialogStatus = new DialogGUILabel("Not enough data"),
            new DialogGUIButton("Prepare transmission", delegate { TransmitData(); }, false),
            new DialogGUIButton("Close", delegate { dialog.Dismiss(); }, true)
            // new DialogGUIFlexibleSpace(),
        });

        dialog = PopupDialog.SpawnPopupDialog(multiOptionDialog,
                                              false,
                                              HighLogic.UISkin,
                                              false);
        dialog.SetDraggable(true);

        SetStatus(status);
    }
コード例 #4
0
        /// <summary>
        /// Build and return the not-spawned dialog
        /// </summary>
        private PopupDialog spawnDialog()
        {
            /* This dialog looks like below
             * -----------------------
             * |        TITLE        |
             * |---------------------|
             * |                     |
             * |       CONTENT       |
             * |                     |
             * |---------------------|
             * |       [CLOSE]   [XX]|
             * -----------------------
             */

            List <DialogGUIBase> dialogComponentList;

            //content
            List <DialogGUIBase> contentComponentList = drawContentComponents();

            if (contentComponentList == null)
            {
                dialogComponentList = new List <DialogGUIBase>(1);
            }
            else
            {
                dialogComponentList = new List <DialogGUIBase>(contentComponentList.Count + 1);
                dialogComponentList.AddRange(contentComponentList);
            }

            //close button and some info
            DialogGUIBase[] footer;
            if (!showVersion && showCloseButton)
            {
                footer = new DialogGUIBase[]
                {
                    new DialogGUIFlexibleSpace(),
                    new DialogGUIButton(dismissButtonText, dismiss),
                    new DialogGUIFlexibleSpace()
                };
                dialogComponentList.Add(new DialogGUIHorizontalLayout(footer));
            }
            else if (showVersion && !showCloseButton)
            {
                footer = new DialogGUIBase[]
                {
                    new DialogGUIFlexibleSpace(),
                    new DialogGUILabel(GameUtils.Version, false, false)
                };
                dialogComponentList.Add(new DialogGUIHorizontalLayout(footer));
            }
            else if (showVersion && showCloseButton)
            {
                footer = new DialogGUIBase[]
                {
                    new DialogGUIFlexibleSpace(),
                    new DialogGUIButton(dismissButtonText, dismiss),
                    new DialogGUIFlexibleSpace(),
                    new DialogGUILabel(GameUtils.Version, false, false)
                };
                dialogComponentList.Add(new DialogGUIHorizontalLayout(footer));
            }

            //Spawn the dialog
            MultiOptionDialog moDialog = new MultiOptionDialog(this.dialogHandler, // unique name for every dialog
                                                               "",
                                                               dialogTitle,
                                                               HighLogic.UISkin,
                                                               new Rect(normalizedCenterX, normalizedCenterY, windowWidth, windowHeight),
                                                               dialogComponentList.ToArray());

            moDialog.OnUpdate = OnUpdate;
            moDialog.OnResize = OnResize;

            PopupDialog newDialog = PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f),
                                                                 new Vector2(0.5f, 0.5f),
                                                                 moDialog,
                                                                 false,                  // persistAcrossScreen
                                                                 HighLogic.UISkin,
                                                                 blockBackgroundInputs); // isModal

            newDialog.SetDraggable(draggable);
            return(newDialog);
        }