public ScrollListWidget(
        WidgetGroup parentGroup, 
        WidgetFactory widgetFactory,
        ScrollListStyle style,
        float x, 
        float y)
        : base(parentGroup, style.Width, style.Height, x, y)
    {
        m_widgetFactory = widgetFactory;
        m_widgetList = new List<IWidget>();
        m_scrollIndex = 0;

        m_scrollFrame = new ImageWidget(this, style.Width, style.Height, style.Background, 0.0f, 0.0f);

        m_scrollUpButton =
            new ButtonWidget(this, style.ButtonStyle, 0, 0, "Previous");
        m_scrollUpButton.SetLocalPosition(
            m_scrollFrame.Width / 2 - m_scrollUpButton.Width / 2,
            BORDER_WIDTH);
        m_scrollUpButton.Visible = false;

        m_scrollDownButton =
            new ButtonWidget(this, style.ButtonStyle, 0, 0, "Next");
        m_scrollDownButton.SetLocalPosition(
            m_scrollUpButton.LocalX,
            m_scrollFrame.Height - m_scrollDownButton.Height - BORDER_WIDTH);
        m_scrollDownButton.Visible = false;
    }
Beispiel #2
0
		protected ButtonWidget(ButtonWidget other)
			: base(other)
		{
			ModRules = other.ModRules;

			Text = other.Text;
			Font = other.Font;
			BaseLine = other.BaseLine;
			TextColor = other.TextColor;
			TextColorDisabled = other.TextColorDisabled;
			Contrast = other.Contrast;
			ContrastColor = other.ContrastColor;
			Depressed = other.Depressed;
			Background = other.Background;
			VisualHeight = other.VisualHeight;
			GetText = other.GetText;
			GetColor = other.GetColor;
			GetColorDisabled = other.GetColorDisabled;
			GetContrastColor = other.GetContrastColor;
			OnMouseDown = other.OnMouseDown;
			Disabled = other.Disabled;
			IsDisabled = other.IsDisabled;
			Highlighted = other.Highlighted;
			IsHighlighted = other.IsHighlighted;

			OnMouseUp = mi => OnClick();
			OnKeyPress = _ => OnClick();

			TooltipTemplate = other.TooltipTemplate;
			TooltipText = other.TooltipText;
			GetTooltipText = other.GetTooltipText;
			TooltipContainer = other.TooltipContainer;
			tooltipContainer = Exts.Lazy(() =>
				Ui.Root.Get<TooltipContainerWidget>(TooltipContainer));
		}
Beispiel #3
0
        public CreditsMenu(rect_d bounds)
        {
            Bounds = bounds;

            ImageSequence cancelButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "NumPlayersCancelButton");
            ButtonWidget cancelGameButton = new ButtonWidget(400, 200, new ThreeImageButtonView(cancelButtonSequence.GetImageByIndex(0), cancelButtonSequence.GetImageByIndex(1), cancelButtonSequence.GetImageByIndex(2)));
            AddChild(cancelGameButton);
            cancelGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnCancelMenuButton);
        }
        public override bool OnMouseUp(Widget w, MouseInput mi)
        {
            // Main Menu root
            if (w.Id == "MAINMENU_BUTTON_JOIN")
            {
                var bg = Game.chrome.rootWidget.ShowMenu("JOINSERVER_BG");

                int height = 50;
                int width = 300;
                int i = 0;
                GameList = MasterServerQuery.GetGameList(Game.Settings.MasterServer).ToArray();

                bg.Children.RemoveAll(a => GameButtons.Contains(a));
                GameButtons.Clear();

                foreach (var game in GameList)
                {
                    ButtonWidget b = new ButtonWidget();
                    b.Bounds = new Rectangle(bg.Bounds.X + 20, bg.Bounds.Y + height, width, 25);
                    b.GetType().GetField("Id").SetValue(b, "JOIN_GAME_{0}".F(i));
                    b.GetType().GetField("Text").SetValue(b, "{0} ({1})".F(game.Name, game.Address));
                    b.GetType().GetField("Delegate").SetValue(b, "ServerBrowserDelegate");

                    bg.AddChild(b);
                    GameButtons.Add(b);

                    height += 35;
                }

                return true;
            }

            if (w.Id == "JOINSERVER_BUTTON_DIRECTCONNECT")
            {
                Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false;
                Game.JoinServer(Game.Settings.NetworkHost, Game.Settings.NetworkPort);
                return true;
            }

            if (w.Id.Substring(0, 10) == "JOIN_GAME_")
            {
                Game.chrome.rootWidget.GetWidget("JOINSERVER_BG").Visible = false;
                int index = int.Parse(w.Id.Substring(10));
                var game = GameList[index];
                Game.JoinServer(game.Address.Split(':')[0], int.Parse(game.Address.Split(':')[1]));
                return true;
            }

            if (w.Id == "JOINSERVER_BUTTON_CANCEL")
            {
                Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
                return true;
            }

            return false;
        }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="label"></param>
        public YesNoDialog(double x, double y, string label)
            : base(x, y, 120, 50, label)
        {
            yesButton = new ButtonWidget(5, 5, "Yes", 10, 1, 1, 2);
            noButton = new ButtonWidget(55, 5, "No", 10, 1, 1, 2);

            yesButton.ButtonClick += Yes;
            noButton.ButtonClick += No;

            AddChild(yesButton);
            AddChild(noButton);
        }
Beispiel #6
0
        void CycleStance(Player p, ButtonWidget bw)
        {
            if (p.World.LobbyInfo.GlobalSettings.LockTeams)
                return;	// team changes are banned

            var nextStance = GetNextStance((Stance)Enum.Parse(typeof(Stance), bw.Text));

            world.IssueOrder(new Order("SetStance", world.LocalPlayer.PlayerActor,
                new int2(p.Index, (int)nextStance), false));

            bw.Text = nextStance.ToString();
        }
Beispiel #7
0
        public PlayfieldView(rect_d bounds)
        {
            Bounds = bounds;

            backgroundImageSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "Map1Background");
            backgroundImage = backgroundImageSequence.GetImageByIndex(0);

            ImageSequence menuButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MenuButtonFromGame");
            ButtonWidget menuButton = new ButtonWidget(400, 12, new ThreeImageButtonView(menuButtonSequence.GetImageByIndex(0), menuButtonSequence.GetImageByIndex(1), menuButtonSequence.GetImageByIndex(2)));
            AddChild(menuButton);
            menuButton.ButtonClick += new ButtonWidget.ButtonEventHandler(EscapeMenu);

            playerViews[0] = new PlayerView(new rect_d(400, 300, 800, 600));
            playerViews[1] = new PlayerView(new rect_d(400, 0, 800, 300));
            playerViews[2] = new PlayerView(new rect_d(0, 300, 400, 600));
            playerViews[3] = new PlayerView(new rect_d(0, 0, 400, 300));
        }
 ButtonWidget Make(int dir, int y, string text, Action <Game, Widget> onClick)
 {
     return(ButtonWidget.Create(game, dir * 160, y, 301, 40, text,
                                Anchor.Centre, Anchor.Centre, titleFont, LeftOnly(onClick)));
 }
 ButtonWidget Make(int dir, int y, string text, SimpleClickHandler onClick)
 {
     return(ButtonWidget.Create(game, 300, text, titleFont, LeftOnly(onClick))
            .SetLocation(Anchor.Centre, Anchor.Centre, dir * 160, y));
 }
    public void Start()
    {
        float viewWidth = CHARACTER_PANEL_X + characterPanelStyle.BackgroundWidth;
        float viewHeight = Math.Max(SCROLL_LIST_Y + scrollListStyle.Width, CHARACTER_PANEL_Y + characterPanelStyle.BackgroundHeight);

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, viewWidth, viewHeight, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Game list
        m_characterScrollList =
            new ScrollListWidget(
                m_rootWidgetGroup,
                (ScrollListWidget parentGroup, object parameters) =>
                {
                    return new CharacterThumbnailWidget(
                        parentGroup,
                        characterThumbnailStyle,
                        parameters as CharacterData);
                },
                scrollListStyle,
                SCROLL_LIST_X, SCROLL_LIST_Y);

        // Character panel
        m_characterPanel = new CharacterPanelWidget(m_rootWidgetGroup, characterPanelStyle, CHARACTER_PANEL_X, CHARACTER_PANEL_Y);
        float panelWidth = m_characterPanel.Width - 2.0f * BORDER_WIDTH;

        // Create game button
        m_characterCreateButton = new ButtonWidget(m_characterPanel, buttonStyle, 0, 0, "Create");
        m_characterCreateButton.SetLocalPosition(
            BORDER_WIDTH + panelWidth / 3 - m_characterCreateButton.Width,
            m_characterPanel.Height - m_characterCreateButton.Height - 5);

        // Select game button
        m_characterSelectButton = new ButtonWidget(m_characterPanel, buttonStyle, 0, 0, "Select");
        m_characterSelectButton.SetLocalPosition(
            BORDER_WIDTH + (2 * panelWidth) / 3 - m_characterSelectButton.Width,
            m_characterPanel.Height - m_characterSelectButton.Height - 5);
        m_characterSelectButton.Visible = false;

        // Delete game button
        m_characterDeleteButton = new ButtonWidget(m_characterPanel, buttonStyle, 0, 0, "Delete");
        m_characterDeleteButton.SetLocalPosition(
            BORDER_WIDTH + (3 * panelWidth) / 3 - m_characterDeleteButton.Width,
            m_characterPanel.Height - m_characterDeleteButton.Height - 5);
        m_characterDeleteButton.Visible = false;

        // Initially hide all game data
        m_characterPanel.HideCharacterData();
    }
Beispiel #11
0
        public PrintDialogFrame(int ID, GUIHost host, PrinterView printerview, SpoolerConnection spooler_connection, PopupMessageBox message_box, ModelLoadingManager modelloadingmanager, SettingsManager settings, PrintDialogMainWindow printDialogWindow)
            : base(ID, printDialogWindow)
        {
            this.modelloadingmanager = modelloadingmanager;
            this.message_box         = message_box;
            this.spooler_connection  = spooler_connection;
            this.printerview         = printerview;
            settingsManager          = settings;
            this.host = host;
            CenterHorizontallyInParent = true;
            CenterVerticallyInParent   = true;
            SetSize(750, 550);
            var printdialog = Resources.printdialog;
            var xmlFrame    = new XMLFrame(ID)
            {
                RelativeWidth  = 1f,
                RelativeHeight = 1f
            };

            AddChildElement(xmlFrame);
            xmlFrame.Init(host, printdialog, new ButtonCallback(MyButtonCallback));
            mPrintQualityButtons = new Dictionary <PrintQuality, ButtonWidget>
            {
                { PrintQuality.Expert, (ButtonWidget)FindChildElement(111) },
                { PrintQuality.VeryHighQuality, (ButtonWidget)FindChildElement(116) },
                { PrintQuality.HighQuality, (ButtonWidget)FindChildElement(112) },
                { PrintQuality.MediumQuality, (ButtonWidget)FindChildElement(113) },
                { PrintQuality.FastPrint, (ButtonWidget)FindChildElement(114) },
                { PrintQuality.VeryFastPrint, (ButtonWidget)FindChildElement(115) },
                { PrintQuality.Custom, (ButtonWidget)FindChildElement(118) }
            };
            mFillDensityButtons = new Dictionary <FillQuality, ButtonWidget>
            {
                { FillQuality.ExtraHigh, (ButtonWidget)FindChildElement(220) },
                { FillQuality.High, (ButtonWidget)FindChildElement(221) },
                { FillQuality.Medium, (ButtonWidget)FindChildElement(222) },
                { FillQuality.Low, (ButtonWidget)FindChildElement(223) },
                { FillQuality.HollowThickWalls, (ButtonWidget)FindChildElement(224) },
                { FillQuality.HollowThinWalls, (ButtonWidget)FindChildElement(225) },
                { FillQuality.Solid, (ButtonWidget)FindChildElement(227) },
                { FillQuality.Custom, (ButtonWidget)FindChildElement(228) }
            };
            print_button            = (ButtonWidget)FindChildElement(401);
            quality_scroll_list     = (HorizontalLayoutScrollList)FindChildElement(110);
            density_scroll_list     = (HorizontalLayoutScrollList)FindChildElement(219);
            printQualityPrev_button = (ButtonWidget)FindChildElement(109);
            printQualityPrev_button.SetCallback(new ButtonCallback(MyButtonCallback));
            printQualityNext_button = (ButtonWidget)FindChildElement(117);
            printQualityNext_button.SetCallback(new ButtonCallback(MyButtonCallback));
            fillDensityPrev_button = (ButtonWidget)FindChildElement(218);
            fillDensityPrev_button.SetCallback(new ButtonCallback(MyButtonCallback));
            fillDensityNext_button = (ButtonWidget)FindChildElement(226);
            fillDensityNext_button.SetCallback(new ButtonCallback(MyButtonCallback));
            support_checkbutton       = (ButtonWidget)FindChildElement(301);
            support_everywhere        = (ButtonWidget)FindChildElement(303);
            support_printbedonly      = (ButtonWidget)FindChildElement(313);
            UseWaveBonding            = (ButtonWidget)FindChildElement(305);
            raft_checkbutton          = (ButtonWidget)FindChildElement(307);
            verifybed_checkbutton     = (ButtonWidget)FindChildElement(309);
            verifybed_text            = (TextWidget)FindChildElement(310);
            printQuality_editbox      = (EditBoxWidget)FindChildElement(108);
            fillDensity_editbox       = (EditBoxWidget)FindChildElement(217);
            enableskirt_checkbutton   = (ButtonWidget)FindChildElement(311);
            heatedBedButton_checkbox  = (ButtonWidget)FindChildElement(315);
            heatedBedButton_text      = (TextWidget)FindChildElement(316);
            untetheredButton_checkbox = (ButtonWidget)FindChildElement(317);
            sdOnlyButton_checkbox     = (ButtonWidget)FindChildElement(319);
            sdOnlyButton_text         = (TextWidget)FindChildElement(320);
            sdCheckboxesFrame         = (XMLFrame)FindChildElement(321);
            mPrintQualityButtons[PrintQuality.Custom].Visible = false;
            mFillDensityButtons[FillQuality.Custom].Visible   = false;
            LoadSettings();
        }
Beispiel #12
0
        public D2MissionBrowserLogic(Widget widget, ModData modData, World world, Action onStart, Action onExit)
        {
            this.modData          = modData;
            this.onStart          = onStart;
            Game.BeforeGameStart += OnGameStart;

            missionList = widget.Get <ScrollPanelWidget>("MISSION_LIST");

            headerTemplate = widget.Get <ScrollItemWidget>("HEADER");
            template       = widget.Get <ScrollItemWidget>("TEMPLATE");

            var title = widget.GetOrNull <LabelWidget>("MISSIONBROWSER_TITLE");

            if (title != null)
            {
                title.GetText = () => playingVideo != PlayingVideo.None ? selectedMap.Title : title.Text;
            }

            widget.Get("MISSION_INFO").IsVisible = () => selectedMap != null;

            //var previewWidget = widget.Get<MapPreviewWidget>("MISSION_PREVIEW");
            //previewWidget.Preview = () => selectedMap;
            //previewWidget.IsVisible = () => playingVideo == PlayingVideo.None;

            videoPlayer = widget.Get <WsaPlayerWidget>("MISSION_VIDEO");
            widget.Get("MISSION_BIN").IsVisible = () => playingVideo != PlayingVideo.None;
            fullscreenVideoPlayer = Ui.LoadWidget <BackgroundWidget>("FULLSCREEN_PLAYER", Ui.Root, new WidgetArgs {
                { "world", world }
            });

            descriptionPanel = widget.Get <ScrollPanelWidget>("MISSION_DESCRIPTION_PANEL");

            description     = descriptionPanel.Get <LabelWidget>("MISSION_DESCRIPTION");
            descriptionFont = Game.Renderer.Fonts[description.Font];

            difficultyButton = widget.Get <DropDownButtonWidget>("DIFFICULTY_DROPDOWNBUTTON");
            gameSpeedButton  = widget.GetOrNull <DropDownButtonWidget>("GAMESPEED_DROPDOWNBUTTON");

            startBriefingVideoButton          = widget.Get <ButtonWidget>("START_BRIEFING_VIDEO_BUTTON");
            stopBriefingVideoButton           = widget.Get <ButtonWidget>("STOP_BRIEFING_VIDEO_BUTTON");
            stopBriefingVideoButton.IsVisible = () => playingVideo == PlayingVideo.Briefing;
            stopBriefingVideoButton.OnClick   = () => StopVideo(videoPlayer);

            startInfoVideoButton          = widget.Get <ButtonWidget>("START_INFO_VIDEO_BUTTON");
            stopInfoVideoButton           = widget.Get <ButtonWidget>("STOP_INFO_VIDEO_BUTTON");
            stopInfoVideoButton.IsVisible = () => playingVideo == PlayingVideo.Info;
            stopInfoVideoButton.OnClick   = () => StopVideo(videoPlayer);

            CampaignWidget = widget.Get <CampaignWidget>("campaigndune");
            CampaignWidget.OnHouseChooseDelegate     = OnHouseChoose;
            CampaignWidget.OnMapRegionChooseDelegate = OnMapRegionChoose;
            CampaignWidget.DrawTextDelegate          = OnShowUserHelp;
            CampaignWidget.OnMentatProceedClick      = StartMissionClicked;
            CampaignWidget.OnExit = onExit;

            allPreviews = new List <MapPreview>();
            missionList.RemoveChildren();

            // Add a group for each campaign
            if (modData.Manifest.CampaignDB.Any())
            {
                var yaml = MiniYaml.Merge(modData.Manifest.CampaignDB.Select(
                                              m => MiniYaml.FromStream(modData.DefaultFileSystem.Open(m), m)));

                foreach (var kv in yaml)
                {
                    var missionMapPaths = kv.Value.Nodes.Select(n => n.Key).ToList();

                    var previews = modData.MapCache
                                   .Where(p => p.Status == MapStatus.Available)
                                   .Select(p => new
                    {
                        Preview = p,
                        Index   = missionMapPaths.IndexOf(Platform.UnresolvePath(p.Package.Name))
                    })
                                   .Where(x => x.Index != -1)
                                   .OrderBy(x => x.Index)
                                   .Select(x => x.Preview);

                    if (previews.Any())
                    {
                        CreateMissionGroup(kv.Key, previews);
                        allPreviews.AddRange(previews);
                    }
                }
            }

            // Add an additional group for loose missions
            var loosePreviews = modData.MapCache
                                .Where(p => p.Status == MapStatus.Available && p.Visibility.HasFlag(MapVisibility.MissionSelector) && !allPreviews.Any(a => a.Uid == p.Uid));

            if (loosePreviews.Any())
            {
                CreateMissionGroup("Missions", loosePreviews);
                allPreviews.AddRange(loosePreviews);
            }

            if (allPreviews.Any())
            {
                SelectMap(allPreviews.First());
            }

            // Preload map preview and rules to reduce jank
            new Thread(() =>
            {
                foreach (var p in allPreviews)
                {
                    p.GetMinimap();
                    p.PreloadRules();
                }
            }).Start();

            var startButton = widget.Get <ButtonWidget>("STARTGAME_BUTTON");

            startButton.OnClick    = StartMissionClicked;
            startButton.IsDisabled = () => selectedMap == null || selectedMap.InvalidCustomRules;

            widget.Get <ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                StopVideo(videoPlayer);
                Game.Disconnect();
                Ui.CloseWindow();
                onExit();
            };
            widget.Get <ButtonWidget>("StartCampaign").OnClick = () =>
            {
                CampaignWidget.ResetCampaign();
            };
            widget.Get <ButtonWidget>("CampaignNextLevel").OnClick = () =>
            {
                CampaignWidget.UpLevelDelegate();
            };
            widget.Get <ButtonWidget>("CampaignPrevLevel").OnClick = () =>
            {
                CampaignWidget.DownLevelDelegate();
            };
            //CampaignWidget.BindLevelOnMap(1);
        }
Beispiel #13
0
 protected override void InputOpened()
 {
     widgets[defaultIndex] = ButtonWidget.Create(game, 200, "Default value", titleFont, DefaultButtonClick)
                             .SetLocation(Anchor.Centre, Anchor.Centre, 0, 150);
 }
    public void Start()
    {
        // Create the root widget group
        m_rootWidgetGroup =
            new WidgetGroup(
                null,
                panelWidth, panelHeight,
                Screen.width/2 - panelWidth/2, Screen.height/2 - panelHeight/2);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Background for the game info
        new ImageWidget(m_rootWidgetGroup, panelWidth, panelHeight, panelTexture, 0.0f, 0.0f);

        // Character portraits
        m_portraits = new List<ImageWidget>();
        for (int portraitIndex = 0; portraitIndex < ClientGameConstants.GetPortraitCount(); portraitIndex++ )
        {
            ImageWidget portrait = new ImageWidget(
                m_rootWidgetGroup,
                portraitWidth, portraitHeight,
                Resources.Load<Texture>(ClientGameConstants.GetResourceNameForPicture((uint)portraitIndex)),
                PORTRAIT_X, PORTRAIT_Y);

            portrait.Visible = false;
            m_portraits.Add(portrait);
        }

        float statsX = PORTRAIT_X + portraitWidth + BORDER_WIDTH;
        float statsY = PORTRAIT_Y;

        // Character Name
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Name:");
        m_nameTextField =
            new TextEntryWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX + labelWidth, statsY, "");
        m_nameTextField.Restrict = @"[^0-9A-Za-z]";
        m_nameTextField.MaxLength = 12;

        // Character Gender
        statsY += labelHeight;
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Gender:");
        m_genderLabel = new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX+labelWidth, statsY, "");

        // Character Archetype
        statsY += labelHeight;
        new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX, statsY, "Archetype:");
        m_archetypeLabel = new LabelWidget(m_rootWidgetGroup, labelWidth, labelHeight, statsX + labelWidth, statsY, "");

        // Creation Status Label
        m_statusLabel = new LabelWidget(m_rootWidgetGroup, panelWidth, panelHeight, 0, panelHeight - labelHeight, "");
        m_statusLabel.Alignment = TextAnchor.UpperCenter;

        // Create Button
        m_createButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                panelWidth / 3 - buttonStyle.Width / 2, m_statusLabel.LocalY - buttonStyle.Height - 5,
                "Create");

        // Cancel Button
        m_cancelButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                (2*panelWidth) / 3 - buttonStyle.Width / 2, m_statusLabel.LocalY - buttonStyle.Height - 5,
                "Cancel");

        // Previous Portrait Button
        m_previousPortraitButton=
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                m_createButton.LocalX, m_createButton.LocalY - buttonStyle.Height - 5,
                "<");

        // Next Portrait Button
        m_nextPortraitButton =
            new ButtonWidget(
                m_rootWidgetGroup,
                buttonStyle,
                m_cancelButton.LocalX, m_cancelButton.LocalY - buttonStyle.Height - 5,
                ">");
    }
Beispiel #15
0
        public void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject printer = m_oSpoolerConnection.SelectedPrinter;

            switch (button.ID)
            {
            case 2:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                var num1 = (int)printer.AcquireLock(ar =>
                {
                    if (ar.CallResult == CommandResult.Failed_PrinterAlreadyLocked)
                    {
                        m_oMessagebox.AddMessageToQueue("Unable to calibrate the printer because it is being used by another process.");
                    }
                    else if (ar.CallResult != CommandResult.Success_LockAcquired)
                    {
                        m_oMessagebox.AddMessageToQueue("There was a problem sending data to the printer. Please try again");
                    }
                    else
                    {
                        printer.CalibrateBed(new M3D.Spooling.Client.AsyncCallback(ReleaseAfterOperation), (object)printer, PrinterObject.CalibrationType.CalibrateQuick_G30);
                    }
                }, printer);
                break;

            case 3:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                var num2 = (int)printer.AcquireLock(ar =>
                {
                    if (ar.CallResult == CommandResult.Failed_PrinterAlreadyLocked)
                    {
                        m_oMessagebox.AddMessageToQueue("Unable to calibrate the printer because it is being used by another process.");
                    }
                    else if (ar.CallResult != CommandResult.Success_LockAcquired)
                    {
                        m_oMessagebox.AddMessageToQueue("There was a problem sending data to the printer. Please try again");
                    }
                    else
                    {
                        printer.CalibrateBed(new M3D.Spooling.Client.AsyncCallback(ReleaseAfterOperation), (object)printer, PrinterObject.CalibrationType.CalibrateFull_G32);
                    }
                }, printer);
                break;

            case 4:
                var fileName = Paths.DebugLogPath(DateTime.Now.Ticks / 10000L);
                Form1.debugLogger.Print(fileName);
                break;

            case 5:
                if (printer.GetCurrentFilament() == null)
                {
                    m_oMessagebox.AddMessageToQueue("Please insert filament into your printer.");
                    break;
                }
                if (!printer.Info.extruder.Z_Valid || !printer.Info.calibration.Calibration_Valid)
                {
                    m_oMessagebox.AddMessageToQueue(Locale.GlobalLocale.T("T_PrinterViewError_NotCalibrated"));
                }

                ShowBusyIfPrinterIsWorking(true);
                var num3 = (int)printer.AcquireLock(new M3D.Spooling.Client.AsyncCallback(DoTestBorderPrintOnLock), printer);
                break;

            case 6:
                ShowGantryCalibrationG32Page();
                break;

            case 10:
                OnApplyBacklashSettings();
                break;

            case 11:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                m_oebwBacklashSpeed_edit.Text = printer.MyPrinterProfile.SpeedLimitConstants.DefaultBacklashSpeed.ToString();
                break;

            case 12:
                if (printer == null || printer.Info.InBootloaderMode)
                {
                    break;
                }

                m_oebwBacklashSpeed_edit.Text = printer.MyPrinterProfile.SpeedLimitConstants.FastestPossible.ToString();
                break;

            case 13:
                ShowBasicCalibrationPage(printer);
                break;

            case 16:
                OnApplyCalibrationOffset();
                break;
            }
        }
Beispiel #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="button"></param>
 private void No(ButtonWidget button)
 {
     Running = false;
     result  = false;
 }
 protected override void AddVerticalFrame()
 {
     ButtonWidget.Append($"\n@{Text}@\n");
 }
Beispiel #18
0
 ButtonWidget MakeClassic(int x, int y, string text, Action <Game, Widget> onClick)
 {
     return(ButtonWidget.Create(game, x, y, 401, 40, text,
                                Anchor.Centre, Anchor.Centre, titleFont, LeftOnly(onClick)));
 }
 protected override void AddHorizontalFrame()
 {
     ButtonWidget.Append('@', Text.Length + 2);
 }
Beispiel #20
0
        public override void Init()
        {
            var frame       = new Frame(1);
            var color4_1    = new Color4(0.35f, 0.35f, 0.35f, 1f);
            var color4_2    = new Color4(1f, 1f, 1f, 1f);
            var color4_3    = new Color4(246, 246, 246, byte.MaxValue);
            var color4_4    = new Color4(220, 220, 220, byte.MaxValue);
            var textWidget1 = new TextWidget(0)
            {
                Color         = color4_1,
                Text          = "Set new 3D Ink information by cheat code:",
                RelativeWidth = 1f,
                Size          = FontSize.Medium,
                Alignment     = QFontAlignment.Centre
            };

            textWidget1.SetPosition(0, 40);
            AddChildElement(textWidget1);
            var imageWidget = new ImageWidget(0);

            imageWidget.Init(Host, "extendedcontrols", 0.0f, 256f, 290f, 381f, 0.0f, 256f, 448f, 511f, 0.0f, 256f, 448f, 511f);
            imageWidget.Width  = 290;
            imageWidget.Height = 125;
            imageWidget.X      = 100;
            imageWidget.Y      = 40;
            imageWidget.CenterHorizontallyInParent = true;
            frame.AddChildElement(imageWidget);
            var textWidget2 = new TextWidget(1)
            {
                Text = "Enter cheat code or filament type:"
            };

            textWidget2.SetSize(150, 100);
            textWidget2.SetPositionRelative(0.25f, 0.6f);
            textWidget2.Color = color4_1;
            frame.AddChildElement(textWidget2);
            CheatEdit = new MultiBoxEditBoxWidget(13, null);
            CheatEdit.Init(Host, 3, 1);
            CheatEdit.SetSize(150, 32);
            CheatEdit.SetPositionRelative(0.55f, 0.75f);
            CheatEdit.Color = color4_1;
            CheatEdit.SetCallbackEnterKey(new MultiBoxEditBoxWidget.EditBoxCallback(CheatCodeEnterCallBack));
            frame.AddChildElement(CheatEdit);
            var buttonWidget1 = new ButtonWidget(11);

            buttonWidget1.Init(Host, "guicontrols", 896f, 192f, 959f, byte.MaxValue, 896f, 256f, 959f, 319f, 896f, 320f, 959f, 383f, 960f, 128f, 1023f, 191f);
            buttonWidget1.Size = FontSize.Medium;
            buttonWidget1.Text = "Cancel";
            buttonWidget1.SetGrowableWidth(4, 4, 32);
            buttonWidget1.SetGrowableHeight(4, 4, 32);
            buttonWidget1.SetSize(110, 40);
            buttonWidget1.SetPosition(20, -50);
            buttonWidget1.SetPositionRelative(0.025f, -1000f);
            buttonWidget1.SetCallback(new ButtonCallback(((Manage3DInkChildWindow)this).MyButtonCallback));
            AddChildElement(buttonWidget1);
            var buttonWidget2 = new ButtonWidget(12);

            buttonWidget2.Init(Host, "guicontrols", 896f, 192f, 959f, byte.MaxValue, 896f, 256f, 959f, 319f, 896f, 320f, 959f, 383f, 960f, 128f, 1023f, 191f);
            buttonWidget2.Size = FontSize.Medium;
            buttonWidget2.Text = "Next";
            buttonWidget2.SetGrowableWidth(4, 4, 32);
            buttonWidget2.SetGrowableHeight(4, 4, 32);
            buttonWidget2.SetSize(100, 32);
            buttonWidget2.SetPosition(400, -50);
            buttonWidget2.SetPositionRelative(0.8f, -1000f);
            buttonWidget2.SetCallback(new ButtonCallback(((Manage3DInkChildWindow)this).MyButtonCallback));
            AddChildElement(buttonWidget2);
            frame.BGColor     = color4_3;
            frame.BorderColor = color4_4;
            frame.SetSizeRelative(1f, 0.6f);
            frame.SetPositionRelative(0.0f, 0.15f);
            BGColor = color4_2;
            SetSizeRelative(1f, 0.9f);
            SetPositionRelative(0.0f, 0.05f);
            AddChildElement(frame);
        }
Beispiel #21
0
		public MainMenu(rect_d bounds)
		{
            Bounds = bounds;

            ImageSequence startButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuStartButton");
            ButtonWidget StartGameButton = new ButtonWidget(400, 310, new ThreeImageButtonView(startButtonSequence.GetImageByIndex(0), startButtonSequence.GetImageByIndex(1), startButtonSequence.GetImageByIndex(2)));
            AddChild(StartGameButton);
            StartGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnStartGameButton);

            ImageSequence creditsButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuCreditsButton");
            ButtonWidget creditsGameButton = new ButtonWidget(400, 230, new ThreeImageButtonView(creditsButtonSequence.GetImageByIndex(0), creditsButtonSequence.GetImageByIndex(1), creditsButtonSequence.GetImageByIndex(2)));
            AddChild(creditsGameButton);
            creditsGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnShowCreditsButton);

            ImageSequence exitButtonSequence = (ImageSequence)DataAssetCache.Instance.GetAsset(typeof(ImageSequence), "MainMenuExitButton");
            ButtonWidget exitGameButton = new ButtonWidget(400, 170, new ThreeImageButtonView(exitButtonSequence.GetImageByIndex(0), exitButtonSequence.GetImageByIndex(1), exitButtonSequence.GetImageByIndex(2)));
			AddChild(exitGameButton);
			exitGameButton.ButtonClick += new ButtonWidget.ButtonEventHandler(OnExitGameButton);
		}
Beispiel #22
0
 ButtonWidget MakeText(int x, int y, string text)
 {
     return(ButtonWidget.Create(game, 300, text, textFont, TextButtonClick)
            .SetLocation(Anchor.Centre, Anchor.Centre, x, y));
 }
Beispiel #23
0
    public void Start()
    {
        SessionData sessionData = SessionData.GetInstance();

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, gamePanelStyle.Width, gamePanelStyle.Height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Background for the game info
        ImageWidget gamePanel =
            new ImageWidget(
                m_rootWidgetGroup,
                gamePanelStyle.Width,
                gamePanelStyle.Height,
                gamePanelStyle.Background,
                0.0f, 0.0f);

        float statsLabelWidth = (gamePanel.Width - 2 * BORDER_WIDTH) / 2 - 3;
        float statsX = 10;
        float statsY = 10;

        // Owner Name
        LabelWidget ownerNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Owner Name:");
        ownerNameLabel.Alignment = TextAnchor.UpperRight;
        m_ownerNameLabel =
            new LabelWidget(
                m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT,
                statsX + statsLabelWidth, statsY, sessionData.UserName);
        m_ownerNameLabel.Text = "";

        // Game name
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget gameNameLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "Game Name:");
        gameNameLabel.Alignment = TextAnchor.UpperRight;
        m_gameNameTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX+statsLabelWidth, statsY, "");

        // IRC Server
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCServerLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Server:");
        IRCServerLabel.Alignment = TextAnchor.UpperRight;
        m_IRCServerTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX+statsLabelWidth, statsY, "");
        m_IRCServerTextField.Text = ServerConstants.DEFAULT_IRC_SERVER;

        // IRC Port
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCPortLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Port:");
        IRCPortLabel.Alignment = TextAnchor.UpperRight;
        m_IRCPortTextField = new TextEntryWidget(m_rootWidgetGroup,
            statsLabelWidth, STATS_LABEL_HEIGHT, statsX + statsLabelWidth, statsY, "");
        m_IRCPortTextField.Restrict = @"[^0-9]";
        m_IRCPortTextField.MaxLength = 6;
        m_IRCPortTextField.Text = ServerConstants.DEFAULT_IRC_PORT.ToString();

        // IRC Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Enabled:");
        IRCEnabledLabel.Alignment = TextAnchor.UpperRight;
        m_IRCEnabledToggle = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEnabledToggle.Enabled = true;

        // IRC Encryption Enabled
        statsY += STATS_LABEL_HEIGHT;
        LabelWidget IRCEncryptionEnabledLabel =
            new LabelWidget(m_rootWidgetGroup, statsLabelWidth, STATS_LABEL_HEIGHT, statsX, statsY, "IRC Encryption Enabled:");
        IRCEncryptionEnabledLabel.Alignment = TextAnchor.UpperRight;
        m_IRCEncryptionEnabledToggle = new CheckBoxWidget(m_rootWidgetGroup, chekBoxStyle, statsX + statsLabelWidth, statsY);
        m_IRCEncryptionEnabledToggle.Enabled = true;

        // Creation status
        m_statusLabel = new LabelWidget(m_rootWidgetGroup, gamePanel.Width, STATS_LABEL_HEIGHT, 0.0f, 0.0f, "");
        m_statusLabel.SetLocalPosition(0, gamePanel.Height - m_statusLabel.Height - BORDER_WIDTH);
        m_statusLabel.Alignment = TextAnchor.UpperCenter;

        // Create button
        m_createButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Create");
        m_createButton.SetLocalPosition(gamePanel.Width/3 - m_createButton.Width/2, m_statusLabel.LocalY - m_createButton.Height - 5);

        // Cancel button
        m_cancelButton = new ButtonWidget(m_rootWidgetGroup, buttonStyle, 0, 0, "Cancel");
        m_cancelButton.SetLocalPosition((2*gamePanel.Width)/3 - m_cancelButton.Width/2, m_statusLabel.LocalY - m_cancelButton.Height - 5);

        // Center the group info widgets
        m_rootWidgetGroup.SetLocalPosition(Screen.width / 2 - gamePanel.Width / 2, Screen.height / 2 - gamePanel.Height / 2);
    }
Beispiel #24
0
        public AssetBrowserLogic(Widget widget, Action onExit, World world)
        {
            panel = widget;

            var sourceDropdown = panel.Get <DropDownButtonWidget>("SOURCE_SELECTOR");

            sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown);
            sourceDropdown.GetText     = () =>
            {
                var name = AssetSource != null ? AssetSource.Name : "All Packages";
                if (name.Length > 15)
                {
                    name = "..." + name.Substring(name.Length - 15);
                }

                return(name);
            };

            AssetSource = FileSystem.MountedFolders.First();

            spriteImage = panel.Get <ShpImageWidget>("SPRITE");

            filenameInput            = panel.Get <TextFieldWidget>("FILENAME_INPUT");
            filenameInput.Text       = spriteImage.Image + ".shp";
            filenameInput.OnEnterKey = () => LoadAsset(filenameInput.Text);

            frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER");
            frameSlider.MaximumValue = (float)spriteImage.FrameCount;
            frameSlider.Ticks        = spriteImage.FrameCount + 1;
            frameSlider.OnChange    += x => { spriteImage.Frame = (int)Math.Round(x); };
            frameSlider.GetValue     = () => spriteImage.Frame;

            panel.Get <LabelWidget>("FRAME_COUNT").GetText = () => "{0}/{1}".F(spriteImage.Frame, spriteImage.FrameCount);

            playButton         = panel.Get <ButtonWidget>("BUTTON_PLAY");
            playButton.OnClick = () =>
            {
                spriteImage.LoopAnimation = true;
                playButton.Visible        = false;
                pauseButton.Visible       = true;
            };
            pauseButton         = panel.Get <ButtonWidget>("BUTTON_PAUSE");
            pauseButton.OnClick = () =>
            {
                spriteImage.LoopAnimation = false;
                playButton.Visible        = true;
                pauseButton.Visible       = false;
            };

            panel.Get <ButtonWidget>("BUTTON_STOP").OnClick = () =>
            {
                spriteImage.LoopAnimation = false;
                frameSlider.Value         = 0;
                spriteImage.Frame         = 0;
                playButton.Visible        = true;
                pauseButton.Visible       = false;
            };

            panel.Get <ButtonWidget>("BUTTON_NEXT").OnClick = () => { spriteImage.RenderNextFrame(); };
            panel.Get <ButtonWidget>("BUTTON_PREV").OnClick = () => { spriteImage.RenderPreviousFrame(); };

            panel.Get <ButtonWidget>("LOAD_BUTTON").OnClick = () =>
            {
                LoadAsset(filenameInput.Text);
            };

            assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST");
            template  = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE");
            PopulateAssetList();

            var palette = (WidgetUtils.ActiveModId() == "d2k") ? "d2k.pal" : "egopal.pal";

            panel.Get <ButtonWidget>("EXPORT_BUTTON").OnClick = () =>
            {
                var ExtractGameFiles = new string[][]
                {
                    new string[] { "--extract", WidgetUtils.ActiveModId(), palette, "--userdir" },
                    new string[] { "--extract", WidgetUtils.ActiveModId(), "{0}.shp".F(spriteImage.Image), "--userdir" },
                };

                var ExportToPng = new string[][]
                {
                    new string[] { "--png", Platform.SupportDir + "{0}.shp".F(spriteImage.Image), Platform.SupportDir + palette },
                };

                var ImportFromPng = new string[][] { };

                var args = new WidgetArgs()
                {
                    { "ExtractGameFiles", ExtractGameFiles },
                    { "ExportToPng", ExportToPng },
                    { "ImportFromPng", ImportFromPng }
                };

                Ui.OpenWindow("CONVERT_ASSETS_PANEL", args);
            };

            panel.Get <ButtonWidget>("EXTRACT_BUTTON").OnClick = () =>
            {
                var ExtractGameFilesList = new List <string[]>();
                var ExportToPngList      = new List <string[]>();

                ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), palette, "--userdir" });

                foreach (var shp in AvailableShps)
                {
                    ExtractGameFilesList.Add(new string[] { "--extract", WidgetUtils.ActiveModId(), shp, "--userdir" });
                    ExportToPngList.Add(new string[] { "--png", Platform.SupportDir + shp, Platform.SupportDir + palette });
                    Console.WriteLine(Platform.SupportDir + shp);
                }

                var ExtractGameFiles = ExtractGameFilesList.ToArray();
                var ExportToPng      = ExportToPngList.ToArray();
                var ImportFromPng    = new string[][] { };

                var args = new WidgetArgs()
                {
                    { "ExtractGameFiles", ExtractGameFiles },
                    { "ExportToPng", ExportToPng },
                    { "ImportFromPng", ImportFromPng }
                };

                Ui.OpenWindow("CONVERT_ASSETS_PANEL", args);
            };


            panel.Get <ButtonWidget>("IMPORT_BUTTON").OnClick = () =>
            {
                var imageSizeInput = panel.Get <TextFieldWidget>("IMAGE_SIZE_INPUT");
                var imageFilename  = panel.Get <TextFieldWidget>("IMAGE_FILENAME_INPUT");

                var ExtractGameFiles = new string[][] { };
                var ExportToPng      = new string[][] { };
                var ImportFromPng    = new string[][]
                {
                    new string[] { "--shp", Platform.SupportDir + imageFilename.Text, imageSizeInput.Text },
                };

                var args = new WidgetArgs()
                {
                    { "ExtractGameFiles", ExtractGameFiles },
                    { "ExportToPng", ExportToPng },
                    { "ImportFromPng", ImportFromPng }
                };

                Ui.OpenWindow("CONVERT_ASSETS_PANEL", args);
            };

            panel.Get <ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
        }
Beispiel #25
0
        public SettingsLogic(Widget widget, Action onExit, WorldRenderer worldRenderer, Dictionary <string, MiniYaml> logicArgs)
        {
            panelContainer = widget.Get("PANEL_CONTAINER");
            var panelTemplate = panelContainer.Get <ContainerWidget>("PANEL_TEMPLATE");

            panelContainer.RemoveChild(panelTemplate);

            tabContainer = widget.Get("TAB_CONTAINER");
            tabTemplate  = tabContainer.Get <ButtonWidget>("BUTTON_TEMPLATE");
            tabContainer.RemoveChild(tabTemplate);

            if (logicArgs.TryGetValue("ButtonStride", out var buttonStrideNode))
            {
                buttonStride = FieldLoader.GetValue <int2>("ButtonStride", buttonStrideNode.Value);
            }

            if (logicArgs.TryGetValue("Panels", out var settingsPanels))
            {
                panels = settingsPanels.ToDictionary(kv => kv.Value);

                foreach (var panel in panels)
                {
                    var container = panelTemplate.Clone() as ContainerWidget;
                    container.Id = panel.Key;
                    panelContainer.AddChild(container);

                    Game.LoadWidget(worldRenderer.World, panel.Key, container, new WidgetArgs()
                    {
                        { "registerPanel", (Action <string, string, Func <Widget, Func <bool> >, Func <Widget, Action> >)RegisterSettingsPanel },
                        { "panelID", panel.Key },
                        { "label", panel.Value }
                    });
                }
            }

            widget.Get <ButtonWidget>("BACK_BUTTON").OnClick = () =>
            {
                needsRestart |= leavePanelActions[activePanel]();
                var current = Game.Settings;
                current.Save();

                Action closeAndExit = () => { Ui.CloseWindow(); onExit(); };
                if (needsRestart)
                {
                    Action restart = () =>
                    {
                        var external = Game.ExternalMods[ExternalMod.MakeKey(Game.ModData.Manifest)];
                        Game.SwitchToExternalMod(external, null, closeAndExit);
                    };

                    ConfirmationDialogs.ButtonPrompt(
                        title: "Restart Now?",
                        text: "Some changes will not be applied until\nthe game is restarted. Restart now?",
                        onConfirm: restart,
                        onCancel: closeAndExit,
                        confirmText: "Restart Now",
                        cancelText: "Restart Later");
                }
                else
                {
                    closeAndExit();
                }
            };

            widget.Get <ButtonWidget>("RESET_BUTTON").OnClick = () =>
            {
                Action reset = () =>
                {
                    resetPanelActions[activePanel]();
                    Game.Settings.Save();
                };

                ConfirmationDialogs.ButtonPrompt(
                    title: $"Reset \"{panels[activePanel]}\"",
                    text: "Are you sure you want to reset\nall settings in this panel?",
                    onConfirm: reset,
                    onCancel: () => { },
                    confirmText: "Reset",
                    cancelText: "Cancel");
            };
        }
 ButtonWidget Make(int x, int y, string text, int width,
                   Font font, SimpleClickHandler onClick)
 {
     return(ButtonWidget.Create(game, width, text, font, LeftOnly(onClick))
            .SetLocation(Anchor.Centre, Anchor.Centre, x, y));
 }
Beispiel #27
0
 protected virtual void UpdateEntry(ButtonWidget widget, string text)
 {
     widget.SetText(text);
 }
Beispiel #28
0
        public Square(ComponentPlayer player, int id, TerrainRaycastResult?Point1, SubsystemTerrain subsystemTerrain)
        {
            m_subsystemTerrain = subsystemTerrain;
            Point       = Point1;
            id1         = id;
            this.player = player;
            WidgetsManager.LoadWidgetContents(this, this, ContentManager.Get <XElement>("WE/DialogsWE/SquareDialog"));

            m_title = this.Children.Find <LabelWidget>("Square_Dialog.Title", true);

            Mode      = this.Children.Find <LabelWidget>("Square_Dialog.Mode", true);
            mPosition = this.Children.Find <LabelWidget>("Square_Dialog.Pos", true);

            Icon_select = this.Children.Find <ButtonWidget>("Square_Dialog.Icon_select", true);

            mselect_pos = this.Children.Find <ButtonWidget>("Square_Dialog.Select_pos", true);

            m_radius = this.Children.Find <SliderWidget>("Square_Dialog.Slider1", true);
            m_lenght = this.Children.Find <SliderWidget>("Square_Dialog.Slider2", true);

            plusButton  = this.Children.Find <ButtonWidget>("Square_Dialog.Button4", true);
            minusButton = this.Children.Find <ButtonWidget>("Square_Dialog.Button3", true);

            lenght_plusButton  = this.Children.Find <ButtonWidget>("Square_Dialog.Button2", true);
            lenght_minusButton = this.Children.Find <ButtonWidget>("Square_Dialog.Button1", true);



            mSelect_mode = this.Children.Find <ButtonWidget>("Square_Dialog.Select_mode", true);

            m_okButton     = this.Children.Find <ButtonWidget>("Square_Dialog.OK", true);
            m_cancelButton = this.Children.Find <ButtonWidget>("Square_Dialog.Cancel", true);

            this.m_blockIconWidget = this.Children.Find <BlockIconWidget>("Square_Dialog.Icon", true);


            m_title.Text = "Square";

            //switch_mode.Text = "Holow";

            //m_blockIconWidget.Value

            mPosition.Text = "Flat";
            Mode.Text      = "Hollow";


            m_radius.MinValue = 1f;
            m_radius.MaxValue = 100;
            m_radius.Value    = 1f;

            m_lenght.MinValue = 1f;
            m_lenght.MaxValue = 100;
            m_lenght.Value    = 1f;

            m_blockIconWidget.Value = id;

            names.Add("Soild");
            names.Add("Hollow");

            names_pos.Add("Flat");
            names_pos.Add("Pos_X");
            names_pos.Add("Pos_Y");


            foreach (string category in names)
            {
                m_categories.Add(new Category()
                {
                    Name = category,
                });
            }

            foreach (string category in names_pos)
            {
                m_categories_pos.Add(new Category()
                {
                    Name = category,
                });
            }
        }
Beispiel #29
0
 ButtonWidget Make(int x, string text, ClickHandler onClick)
 {
     return(ButtonWidget.Create(game, 40, text, font, onClick)
            .SetLocation(Anchor.Centre, Anchor.Centre, x, 0));
 }
Beispiel #30
0
        public LibraryView(int ID, Element2D parent, GLControl glControl, GUIHost host, MessagePopUp infobox, ModelLoadingManager model_loading_manager)
            : base(ID, parent)
        {
            bUpdateWhenNotVisible        = true;
            m_gui_host                   = host;
            Sprite.texture_height_pixels = 1024;
            Sprite.texture_width_pixels  = 1024;
            m_gui_host.SetFontProperty(FontSize.VeryLarge, 20f);
            m_gui_host.SetFontProperty(FontSize.Large, 14f);
            m_gui_host.SetFontProperty(FontSize.Medium, 11f);
            m_gui_host.SetFontProperty(FontSize.Small, 8f);
            RelativeX      = 0.51f;
            RelativeY      = 0.11f;
            RelativeWidth  = 0.423f;
            RelativeHeight = 0.83f;
            var imageWidget1 = new ImageWidget(1008, null);

            imageWidget1.Init(host, "extendedcontrols3", 3f, 288f, 84f, 374f, 3f, 288f, 84f, 374f, 3f, 288f, 84f, 374f);
            imageWidget1.Text           = "Remove From List";
            imageWidget1.Color          = new Color4(0.5f, 0.5f, 0.5f, 1f);
            imageWidget1.VAlignment     = TextVerticalAlignment.Bottom;
            imageWidget1.TextAreaHeight = 32;
            imageWidget1.ImageAreaWidth = 80;
            imageWidget1.SetSize(80, 115);
            imageWidget1.Visible = false;
            AddChildElement(imageWidget1);
            imageWidget1.SetPosition(-12, -115);
            var imageWidget2 = new ImageWidget(1009, null);

            imageWidget2.Init(host, "extendedcontrols3", 92f, 285f, 173f, 346f, 92f, 285f, 173f, 346f, 92f, 285f, 173f, 346f);
            imageWidget2.Text           = "Save";
            imageWidget2.Color          = new Color4(0.5f, 0.5f, 0.5f, 1f);
            imageWidget2.VAlignment     = TextVerticalAlignment.Bottom;
            imageWidget2.TextAreaHeight = 20;
            imageWidget2.ImageAreaWidth = 81;
            imageWidget2.SetSize(81, 85);
            imageWidget2.Visible = false;
            AddChildElement(imageWidget2);
            imageWidget2.SetPosition(-12, -240);
            search_filter = "";
            var editBoxWidget = new EditBoxWidget(1001, null);

            editBoxWidget.Init(host, "guicontrols", 513f, 0.0f, 608f, 63f);
            editBoxWidget.SetGrowableWidth(40, 16, 64);
            editBoxWidget.Size  = FontSize.Large;
            editBoxWidget.Color = new Color4(0.71f, 0.71f, 0.71f, 1f);
            editBoxWidget.SetTextWindowBorders(48, 16, 22, 16);
            editBoxWidget.SetToolTipRegion(0, 48, 0, 60);
            editBoxWidget.ToolTipMessage = host.Locale.T("T_TOOLTIP_SEARCH");
            editBoxWidget.Hint           = m_gui_host.Locale.T("T_SEARCH");
            tabsFrame = new HorizontalLayout(0, null)
            {
                FixedColumnWidth = true,
                BorderWidth      = 0,
                BorderHeight     = 0,
                RelativeWidth    = 1f
            };
            navigation      = new Frame(0, null);
            navigation_left = new ButtonWidget(1005, null)
            {
                Text   = "",
                X      = 16,
                Y      = 0,
                Width  = 32,
                Height = 32
            };
            navigation_left.SetCallback(new ButtonCallback(MyButtonCallback));
            navigation_left.Init(host, "guicontrols", 608f, 0.0f, 639f, 31f, 640f, 0.0f, 671f, 31f, 672f, 0.0f, 703f, 31f, 704f, 0.0f, 735f, 31f);
            navigation_right = new ButtonWidget(1006, null)
            {
                Text   = "",
                X      = -48,
                Y      = 0,
                Width  = 32,
                Height = 32
            };
            navigation_right.SetCallback(new ButtonCallback(MyButtonCallback));
            navigation_right.Init(host, "guicontrols", 608f, 32f, 639f, 63f, 640f, 32f, 671f, 63f, 672f, 32f, 703f, 63f, 704f, 32f, 735f, 63f);
            pagebuttons = new ButtonWidget[32];
            for (var ID1 = 1032; ID1 <= 1063; ++ID1)
            {
                var index = ID1 - 1032;
                pagebuttons[index] = new ButtonWidget(ID1, null)
                {
                    Text   = "",
                    X      = 48 + (ID1 - 1032) * 24,
                    Y      = 8,
                    Width  = 16,
                    Height = 16
                };
                pagebuttons[index].SetCallback(new ButtonCallback(MyButtonCallback));
                pagebuttons[index].Init(host, "guicontrols", 448f, 192f, 463f, 208f, 480f, 192f, 495f, 208f, 464f, 192f, 479f, 208f);
                pagebuttons[index].DontMove  = true;
                pagebuttons[index].GroupID   = 1;
                pagebuttons[index].ClickType = ButtonType.Checkable;
                pagebuttons[index].Visible   = false;
                navigation.AddChildElement(pagebuttons[index]);
            }
            navigation.AddChildElement(navigation_left);
            navigation.AddChildElement(navigation_right);
            LibraryGrid = new GridLayout(1)
            {
                ColumnWidth  = 130,
                RowHeight    = 150,
                BorderWidth  = 0,
                BorderHeight = 0
            };
            var verticalLayout = new VerticalLayout(0)
            {
                RelativeHeight = 1f,
                RelativeWidth  = 1f,
                BorderHeight   = 10
            };

            verticalLayout.AddChildElement(editBoxWidget, 0, 64 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(tabsFrame, 1, 64 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(navigation, 2, 32 + verticalLayout.BorderHeight);
            verticalLayout.AddChildElement(LibraryGrid, 3, -1);
            AddChildElement(verticalLayout);
            library_status = new TextWidget(1007)
            {
                Text           = m_gui_host.Locale.T("T_NOMODELS"),
                Size           = FontSize.VeryLarge,
                Alignment      = QFontAlignment.Centre,
                RelativeHeight = 1f,
                RelativeWidth  = 1f,
                X     = 0,
                Y     = 0,
                Color = new Color4(0.9922f, 0.3765f, 0.2471f, 1f)
            };
            AddChildElement(library_status);
            recentModelsTab = new RecentModelTab(this, model_loading_manager, infobox, glControl);
            ButtonWidget buttonWidget = AddTabButton(host, recentModelsTab, LibraryView.TabButtonStyle.Left, m_gui_host.Locale.T("T_RECENT_MODELS"), 1002);

            recentPrintsTab = new RecentPrintsTab(this, model_loading_manager);
            AddTabButton(host, recentPrintsTab, LibraryView.TabButtonStyle.Right, m_gui_host.Locale.T("T_RECENT_PRINTS"), 1004);
            var num = 1;

            buttonWidget.SetChecked(num != 0);
            ShowView(true);
            viewstate = ViewState.Active;
        }
Beispiel #31
0
        public IngameMenuLogic(Widget widget, ModData modData, World world, Action onExit, WorldRenderer worldRenderer,
                               IngameInfoPanel initialPanel, Dictionary <string, MiniYaml> logicArgs)
        {
            this.modData       = modData;
            this.world         = world;
            this.worldRenderer = worldRenderer;
            this.onExit        = onExit;

            var buttonHandlers = new Dictionary <string, Action>
            {
                { "ABORT_MISSION", CreateAbortMissionButton },
                { "RESTART", CreateRestartButton },
                { "SURRENDER", CreateSurrenderButton },
                { "LOAD_GAME", CreateLoadGameButton },
                { "SAVE_GAME", CreateSaveGameButton },
                { "MUSIC", CreateMusicButton },
                { "SETTINGS", CreateSettingsButton },
                { "RESUME", CreateResumeButton },
                { "SAVE_MAP", CreateSaveMapButton },
                { "EXIT_EDITOR", CreateExitEditorButton }
            };

            isSinglePlayer = !world.LobbyInfo.GlobalSettings.Dedicated && world.LobbyInfo.NonBotClients.Count() == 1;

            menu = widget.Get("INGAME_MENU");
            mpe  = world.WorldActor.TraitOrDefault <MenuPaletteEffect>();
            mpe?.Fade(mpe.Info.MenuEffect);

            menu.Get <LabelWidget>("VERSION_LABEL").Text = modData.Manifest.Metadata.Version;

            buttonContainer = menu.Get("MENU_BUTTONS");
            buttonTemplate  = buttonContainer.Get <ButtonWidget>("BUTTON_TEMPLATE");
            buttonContainer.RemoveChild(buttonTemplate);
            buttonContainer.IsVisible = () => !hideMenu;

            if (logicArgs.TryGetValue("ButtonStride", out var buttonStrideNode))
            {
                buttonStride = FieldLoader.GetValue <int2>("ButtonStride", buttonStrideNode.Value);
            }

            var scriptContext = world.WorldActor.TraitOrDefault <LuaScript>();

            hasError = scriptContext != null && scriptContext.FatalErrorOccurred;

            if (logicArgs.TryGetValue("Buttons", out var buttonsNode))
            {
                var buttonIds = FieldLoader.GetValue <string[]>("Buttons", buttonsNode.Value);
                foreach (var button in buttonIds)
                {
                    if (buttonHandlers.TryGetValue(button, out var createHandler))
                    {
                        createHandler();
                    }
                }
            }

            // Recenter the button container
            if (buttons.Count > 0)
            {
                var expand = (buttons.Count - 1) * buttonStride;
                buttonContainer.Bounds.X      -= expand.X / 2;
                buttonContainer.Bounds.Y      -= expand.Y / 2;
                buttonContainer.Bounds.Width  += expand.X;
                buttonContainer.Bounds.Height += expand.Y;
            }

            var panelRoot = widget.GetOrNull("PANEL_ROOT");

            if (panelRoot != null && world.Type != WorldType.Editor)
            {
                Action <bool> requestHideMenu = h => hideMenu = h;
                var           gameInfoPanel   = Game.LoadWidget(world, "GAME_INFO_PANEL", panelRoot, new WidgetArgs()
                {
                    { "initialPanel", initialPanel },
                    { "hideMenu", requestHideMenu }
                });

                gameInfoPanel.IsVisible = () => !hideMenu;
            }
        }
Beispiel #32
0
        public AssetBrowserLogic(Widget widget, Action onExit, World world)
        {
            panel = widget;

            var sourceDropdown = panel.Get <DropDownButtonWidget>("SOURCE_SELECTOR");

            sourceDropdown.OnMouseDown = _ => ShowSourceDropdown(sourceDropdown);
            sourceDropdown.GetText     = () =>
            {
                var name = assetSource != null?assetSource.Name.Replace(Platform.SupportDir, "^") : "All Packages";

                if (name.Length > 15)
                {
                    name = "..." + name.Substring(name.Length - 15);
                }

                return(name);
            };

            assetSource = FileSystem.MountedFolders.First();

            spriteWidget = panel.Get <ShpImageWidget>("SPRITE");

            currentPalette = world.WorldActor.TraitsImplementing <PaletteFromFile>().First(p => p.Name == spriteWidget.Palette);

            var paletteDropDown = panel.Get <DropDownButtonWidget>("PALETTE_SELECTOR");

            paletteDropDown.OnMouseDown = _ => ShowPaletteDropdown(paletteDropDown, world);
            paletteDropDown.GetText     = () => currentPalette.Name;

            var colorPreview = panel.Get <ColorPreviewManagerWidget>("COLOR_MANAGER");

            colorPreview.Color = Game.Settings.Player.Color;

            var color = panel.Get <DropDownButtonWidget>("COLOR");

            color.IsDisabled  = () => currentPalette.Name != colorPreview.Palette;
            color.OnMouseDown = _ => ShowColorDropDown(color, colorPreview, world);
            var block = panel.Get <ColorBlockWidget>("COLORBLOCK");

            block.GetColor = () => Game.Settings.Player.Color.RGB;

            filenameInput            = panel.Get <TextFieldWidget>("FILENAME_INPUT");
            filenameInput.OnEnterKey = () => LoadAsset(filenameInput.Text);

            frameSlider = panel.Get <SliderWidget>("FRAME_SLIDER");
            frameSlider.MaximumValue = (float)spriteWidget.FrameCount;
            frameSlider.Ticks        = spriteWidget.FrameCount + 1;
            frameSlider.IsVisible    = () => spriteWidget.FrameCount > 0;
            frameSlider.OnChange    += x => { spriteWidget.Frame = (int)Math.Round(x); };
            frameSlider.GetValue     = () => spriteWidget.Frame;

            panel.Get <LabelWidget>("FRAME_COUNT").GetText = () => "{0} / {1}".F(spriteWidget.Frame + 1, spriteWidget.FrameCount + 1);

            playButton         = panel.Get <ButtonWidget>("BUTTON_PLAY");
            playButton.OnClick = () =>
            {
                spriteWidget.LoopAnimation = true;
                playButton.Visible         = false;
                pauseButton.Visible        = true;
            };
            pauseButton         = panel.Get <ButtonWidget>("BUTTON_PAUSE");
            pauseButton.OnClick = () =>
            {
                spriteWidget.LoopAnimation = false;
                playButton.Visible         = true;
                pauseButton.Visible        = false;
            };

            panel.Get <ButtonWidget>("BUTTON_STOP").OnClick = () =>
            {
                spriteWidget.LoopAnimation = false;
                frameSlider.Value          = 0;
                spriteWidget.Frame         = 0;
                playButton.Visible         = true;
                pauseButton.Visible        = false;
            };

            panel.Get <ButtonWidget>("BUTTON_NEXT").OnClick = () => { spriteWidget.RenderNextFrame(); };
            panel.Get <ButtonWidget>("BUTTON_PREV").OnClick = () => { spriteWidget.RenderPreviousFrame(); };

            panel.Get <ButtonWidget>("LOAD_BUTTON").OnClick = () =>
            {
                LoadAsset(filenameInput.Text);
            };

            assetList = panel.Get <ScrollPanelWidget>("ASSET_LIST");
            template  = panel.Get <ScrollItemWidget>("ASSET_TEMPLATE");
            PopulateAssetList();

            panel.Get <ButtonWidget>("CLOSE_BUTTON").OnClick = () => { Ui.CloseWindow(); onExit(); };
        }
Beispiel #33
0
        public ServerListLogic(Widget widget, ModData modData, Action <GameServer> onJoin)
        {
            this.modData = modData;
            this.onJoin  = onJoin;

            services = modData.Manifest.Get <WebServices>();

            incompatibleVersionColor       = ChromeMetrics.Get <Color>("IncompatibleVersionColor");
            incompatibleGameColor          = ChromeMetrics.Get <Color>("IncompatibleGameColor");
            incompatibleProtectedGameColor = ChromeMetrics.Get <Color>("IncompatibleProtectedGameColor");
            protectedGameColor             = ChromeMetrics.Get <Color>("ProtectedGameColor");
            waitingGameColor             = ChromeMetrics.Get <Color>("WaitingGameColor");
            incompatibleWaitingGameColor = ChromeMetrics.Get <Color>("IncompatibleWaitingGameColor");
            gameStartedColor             = ChromeMetrics.Get <Color>("GameStartedColor");
            incompatibleGameStartedColor = ChromeMetrics.Get <Color>("IncompatibleGameStartedColor");

            serverList     = widget.Get <ScrollPanelWidget>("SERVER_LIST");
            headerTemplate = serverList.Get <ScrollItemWidget>("HEADER_TEMPLATE");
            serverTemplate = serverList.Get <ScrollItemWidget>("SERVER_TEMPLATE");

            noticeContainer = widget.GetOrNull("NOTICE_CONTAINER");
            if (noticeContainer != null)
            {
                noticeContainer.IsVisible = () => showNotices;
                noticeContainer.Get("OUTDATED_VERSION_LABEL").IsVisible   = () => services.ModVersionStatus == ModVersionStatus.Outdated;
                noticeContainer.Get("UNKNOWN_VERSION_LABEL").IsVisible    = () => services.ModVersionStatus == ModVersionStatus.Unknown;
                noticeContainer.Get("PLAYTEST_AVAILABLE_LABEL").IsVisible = () => services.ModVersionStatus == ModVersionStatus.PlaytestAvailable;
            }

            var noticeWatcher = widget.Get <LogicTickerWidget>("NOTICE_WATCHER");

            if (noticeWatcher != null && noticeContainer != null)
            {
                var containerHeight = noticeContainer.Bounds.Height;
                noticeWatcher.OnTick = () =>
                {
                    var show = services.ModVersionStatus != ModVersionStatus.NotChecked && services.ModVersionStatus != ModVersionStatus.Latest;
                    if (show != showNotices)
                    {
                        var dir = show ? 1 : -1;
                        serverList.Bounds.Y      += dir * containerHeight;
                        serverList.Bounds.Height -= dir * containerHeight;
                        showNotices = show;
                    }
                };
            }

            joinButton = widget.GetOrNull <ButtonWidget>("JOIN_BUTTON");
            if (joinButton != null)
            {
                joinButton.IsVisible  = () => currentServer != null;
                joinButton.IsDisabled = () => !currentServer.IsJoinable;
                joinButton.OnClick    = () => onJoin(currentServer);
                joinButtonY           = joinButton.Bounds.Y;
            }

            // Display the progress label over the server list
            // The text is only visible when the list is empty
            var progressText = widget.Get <LabelWidget>("PROGRESS_LABEL");

            progressText.IsVisible = () => searchStatus != SearchStatus.Hidden;
            progressText.GetText   = ProgressLabelText;

            var gs = Game.Settings.Game;
            Action <MPGameFilters> toggleFilterFlag = f =>
            {
                gs.MPGameFilters ^= f;
                Game.Settings.Save();
                RefreshServerList();
            };

            var filtersButton = widget.GetOrNull <DropDownButtonWidget>("FILTERS_DROPDOWNBUTTON");

            if (filtersButton != null)
            {
                // HACK: MULTIPLAYER_FILTER_PANEL doesn't follow our normal procedure for dropdown creation
                // but we still need to be able to set the dropdown width based on the parent
                // The yaml should use PARENT_RIGHT instead of DROPDOWN_WIDTH
                var filtersPanel = Ui.LoadWidget("MULTIPLAYER_FILTER_PANEL", filtersButton, new WidgetArgs());
                filtersButton.Children.Remove(filtersPanel);

                var showWaitingCheckbox = filtersPanel.GetOrNull <CheckboxWidget>("WAITING_FOR_PLAYERS");
                if (showWaitingCheckbox != null)
                {
                    showWaitingCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Waiting);
                    showWaitingCheckbox.OnClick   = () => toggleFilterFlag(MPGameFilters.Waiting);
                }

                var showEmptyCheckbox = filtersPanel.GetOrNull <CheckboxWidget>("EMPTY");
                if (showEmptyCheckbox != null)
                {
                    showEmptyCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Empty);
                    showEmptyCheckbox.OnClick   = () => toggleFilterFlag(MPGameFilters.Empty);
                }

                var showAlreadyStartedCheckbox = filtersPanel.GetOrNull <CheckboxWidget>("ALREADY_STARTED");
                if (showAlreadyStartedCheckbox != null)
                {
                    showAlreadyStartedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Started);
                    showAlreadyStartedCheckbox.OnClick   = () => toggleFilterFlag(MPGameFilters.Started);
                }

                var showProtectedCheckbox = filtersPanel.GetOrNull <CheckboxWidget>("PASSWORD_PROTECTED");
                if (showProtectedCheckbox != null)
                {
                    showProtectedCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Protected);
                    showProtectedCheckbox.OnClick   = () => toggleFilterFlag(MPGameFilters.Protected);
                }

                var showIncompatibleCheckbox = filtersPanel.GetOrNull <CheckboxWidget>("INCOMPATIBLE_VERSION");
                if (showIncompatibleCheckbox != null)
                {
                    showIncompatibleCheckbox.IsChecked = () => gs.MPGameFilters.HasFlag(MPGameFilters.Incompatible);
                    showIncompatibleCheckbox.OnClick   = () => toggleFilterFlag(MPGameFilters.Incompatible);
                }

                filtersButton.IsDisabled  = () => searchStatus == SearchStatus.Fetching;
                filtersButton.OnMouseDown = _ =>
                {
                    filtersButton.RemovePanel();
                    filtersButton.AttachPanel(filtersPanel);
                };
            }

            var reloadButton = widget.GetOrNull <ButtonWidget>("RELOAD_BUTTON");

            if (reloadButton != null)
            {
                reloadButton.IsDisabled = () => searchStatus == SearchStatus.Fetching;
                reloadButton.OnClick    = RefreshServerList;

                var reloadIcon = reloadButton.GetOrNull <ImageWidget>("IMAGE_RELOAD");
                if (reloadIcon != null)
                {
                    var disabledFrame = 0;
                    var disabledImage = "disabled-" + disabledFrame.ToString();
                    reloadIcon.GetImageName = () => searchStatus == SearchStatus.Fetching ? disabledImage : reloadIcon.ImageName;

                    var reloadTicker = reloadIcon.Get <LogicTickerWidget>("ANIMATION");
                    if (reloadTicker != null)
                    {
                        reloadTicker.OnTick = () =>
                        {
                            disabledFrame = searchStatus == SearchStatus.Fetching ? (disabledFrame + 1) % 12 : 0;
                            disabledImage = "disabled-" + disabledFrame.ToString();
                        };
                    }
                }
            }

            var playersLabel = widget.GetOrNull <LabelWidget>("PLAYER_COUNT");

            if (playersLabel != null)
            {
                var playersText = new CachedTransform <int, string>(c => c == 1 ? "1 Player Online" : c.ToString() + " Players Online");
                playersLabel.IsVisible = () => playerCount != 0;
                playersLabel.GetText   = () => playersText.Update(playerCount);
            }

            mapPreview = widget.GetOrNull <MapPreviewWidget>("SELECTED_MAP_PREVIEW");
            if (mapPreview != null)
            {
                mapPreview.Preview = () => currentMap;
            }

            var mapTitle = widget.GetOrNull <LabelWithTooltipWidget>("SELECTED_MAP");

            if (mapTitle != null)
            {
                var font  = Game.Renderer.Fonts[mapTitle.Font];
                var title = new CachedTransform <MapPreview, string>(m =>
                {
                    var truncated = WidgetUtils.TruncateText(m.Title, mapTitle.Bounds.Width, font);

                    if (m.Title != truncated)
                    {
                        mapTitle.GetTooltipText = () => m.Title;
                    }
                    else
                    {
                        mapTitle.GetTooltipText = null;
                    }

                    return(truncated);
                });

                mapTitle.GetText = () =>
                {
                    if (currentMap == null)
                    {
                        return("No Server Selected");
                    }

                    if (currentMap.Status == MapStatus.Searching)
                    {
                        return("Searching...");
                    }

                    if (currentMap.Class == MapClassification.Unknown)
                    {
                        return("Unknown Map");
                    }

                    return(title.Update(currentMap));
                };
            }

            var ip = widget.GetOrNull <LabelWidget>("SELECTED_IP");

            if (ip != null)
            {
                ip.IsVisible = () => currentServer != null;
                ip.GetText   = () => currentServer.Address;
            }

            var status = widget.GetOrNull <LabelWidget>("SELECTED_STATUS");

            if (status != null)
            {
                status.IsVisible = () => currentServer != null;
                status.GetText   = () => GetStateLabel(currentServer);
                status.GetColor  = () => GetStateColor(currentServer, status);
            }

            var modVersion = widget.GetOrNull <LabelWidget>("SELECTED_MOD_VERSION");

            if (modVersion != null)
            {
                modVersion.IsVisible = () => currentServer != null;
                modVersion.GetColor  = () => currentServer.IsCompatible ? modVersion.TextColor : incompatibleVersionColor;

                var font    = Game.Renderer.Fonts[modVersion.Font];
                var version = new CachedTransform <GameServer, string>(s => WidgetUtils.TruncateText(s.ModLabel, modVersion.Bounds.Width, font));
                modVersion.GetText = () => version.Update(currentServer);
            }

            var players = widget.GetOrNull <LabelWidget>("SELECTED_PLAYERS");

            if (players != null)
            {
                players.IsVisible = () => currentServer != null && (clientContainer == null || !currentServer.Clients.Any());
                players.GetText   = () => PlayersLabel(currentServer);
            }

            clientContainer = widget.GetOrNull("CLIENT_LIST_CONTAINER");
            if (clientContainer != null)
            {
                clientList           = Ui.LoadWidget("MULTIPLAYER_CLIENT_LIST", clientContainer, new WidgetArgs()) as ScrollPanelWidget;
                clientList.IsVisible = () => currentServer != null && currentServer.Clients.Any();
                clientHeader         = clientList.Get <ScrollItemWidget>("HEADER");
                clientTemplate       = clientList.Get <ScrollItemWidget>("TEMPLATE");
                clientList.RemoveChildren();
            }

            lanGameLocations = new List <BeaconLocation>();
            try
            {
                lanGameProbe = new Probe("OpenRALANGame");
                lanGameProbe.BeaconsUpdated += locations => lanGameLocations = locations;
                lanGameProbe.Start();
            }
            catch (Exception ex)
            {
                Log.Write("debug", "BeaconLib.Probe: " + ex.Message);
            }

            RefreshServerList();
        }
        public ButtonTooltipWithDescHighlightLogic(Widget widget, ButtonWidget button, Dictionary <string, MiniYaml> logicArgs)
        {
            var label      = widget.Get <LabelWidget>("LABEL");
            var font       = Game.Renderer.Fonts[label.Font];
            var text       = button.GetTooltipText();
            var labelWidth = font.Measure(text).X;
            var key        = button.Key.GetValue();

            label.GetText       = () => text;
            label.Bounds.Width  = labelWidth;
            widget.Bounds.Width = 2 * label.Bounds.X + labelWidth;

            if (key.IsValid())
            {
                var hotkey = widget.Get <LabelWidget>("HOTKEY");
                hotkey.Visible = true;

                var hotkeyLabel = "({0})".F(key.DisplayString());
                hotkey.GetText  = () => hotkeyLabel;
                hotkey.Bounds.X = labelWidth + 2 * label.Bounds.X;

                widget.Bounds.Width = hotkey.Bounds.X + label.Bounds.X + font.Measure(hotkeyLabel).X;
            }

            var desc = button.GetTooltipDesc();

            if (!string.IsNullOrEmpty(desc))
            {
                var descTemplate   = widget.Get <LabelWidget>("DESC");
                var highlightColor = FieldLoader.GetValue <Color>("Highlight", logicArgs["Highlight"].Value);
                widget.RemoveChild(descTemplate);

                var descFont   = Game.Renderer.Fonts[descTemplate.Font];
                var descWidth  = 0;
                var descOffset = descTemplate.Bounds.Y;

                foreach (var l in desc.Split(new[] { "\\n" }, StringSplitOptions.None))
                {
                    var line      = l;
                    var lineWidth = 0;
                    var xOffset   = descTemplate.Bounds.X;

                    while (line.Length > 0)
                    {
                        var highlightStart = line.IndexOf('{');
                        var highlightEnd   = line.IndexOf('}', 0);

                        if (highlightStart > 0 && highlightEnd > highlightStart)
                        {
                            if (highlightStart > 0)
                            {
                                // Normal line segment before highlight
                                var lineNormal      = line.Substring(0, highlightStart);
                                var lineNormalWidth = descFont.Measure(lineNormal).X;
                                var lineNormalLabel = (LabelWidget)descTemplate.Clone();
                                lineNormalLabel.GetText      = () => lineNormal;
                                lineNormalLabel.Bounds.X     = descTemplate.Bounds.X + lineWidth;
                                lineNormalLabel.Bounds.Y     = descOffset;
                                lineNormalLabel.Bounds.Width = lineNormalWidth;
                                widget.AddChild(lineNormalLabel);

                                lineWidth += lineNormalWidth;
                            }

                            // Highlight line segment
                            var lineHighlight      = line.Substring(highlightStart + 1, highlightEnd - highlightStart - 1);
                            var lineHighlightWidth = descFont.Measure(lineHighlight).X;
                            var lineHighlightLabel = (LabelWidget)descTemplate.Clone();
                            lineHighlightLabel.GetText      = () => lineHighlight;
                            lineHighlightLabel.GetColor     = () => highlightColor;
                            lineHighlightLabel.Bounds.X     = descTemplate.Bounds.X + lineWidth;
                            lineHighlightLabel.Bounds.Y     = descOffset;
                            lineHighlightLabel.Bounds.Width = lineHighlightWidth;
                            widget.AddChild(lineHighlightLabel);

                            lineWidth += lineHighlightWidth;
                            line       = line.Substring(highlightEnd + 1);
                        }
                        else
                        {
                            // Final normal line segment
                            var lineLabel = (LabelWidget)descTemplate.Clone();
                            var width     = descFont.Measure(line).X;
                            lineLabel.GetText  = () => line;
                            lineLabel.Bounds.X = descTemplate.Bounds.X + lineWidth;
                            lineLabel.Bounds.Y = descOffset;
                            widget.AddChild(lineLabel);

                            lineWidth += width;
                            break;
                        }
                    }

                    descWidth = Math.Max(descWidth, lineWidth);

                    descOffset += descTemplate.Bounds.Height;
                }

                widget.Bounds.Width   = Math.Max(widget.Bounds.Width, descTemplate.Bounds.X * 2 + descWidth);
                widget.Bounds.Height += descOffset - descTemplate.Bounds.Y + descTemplate.Bounds.X;
            }
        }
Beispiel #35
0
        private void Init(GUIHost host, SpoolerConnection spooler_connection, Updater softwareUpdater)
        {
            this.host = host;
            Init(host, "guicontrols", 640f, 320f, 704f, 383f, 41, 8, 64, 37, 8, 64);
            SetSize(792, 356);
            var textWidget = new TextWidget(0);

            textWidget.SetPosition(50, 2);
            textWidget.SetSize(500, 35);
            textWidget.Text      = "Settings";
            textWidget.Alignment = QFontAlignment.Left;
            textWidget.Size      = FontSize.Large;
            textWidget.Color     = new Color4(0.5f, 0.5f, 0.5f, 1f);
            AddChildElement(textWidget);
            var yposition1 = 35;

            Sprite.pixel_perfect = true;
            CreateTabButton(2, "T_SettingsTab_UserInterfaceOptions", yposition1);
            var yposition2 = yposition1 + 64;

            CreateTabButton(5, "T_SettingsTab_Calibration", yposition2);
            var yposition3 = yposition2 + 64;

            CreateTabButton(3, "T_SettingsTab_ExpertControls", yposition3);
            var yposition4 = yposition3 + 64;

            CreateTabButton(4, "T_SettingsTab_FilamentOptions", yposition4);
            var yposition5 = yposition4 + 64;

            CreateTabButton(6, "  Pro/Micro+\n  Features", yposition5);
            CreateTabButton(7, "T_SettingsTab_About", yposition5 + 64);
            var buttonWidget = new ButtonWidget(8)
            {
                X = -40,
                Y = 4
            };

            buttonWidget.SetSize(32, 32);
            buttonWidget.Text          = "";
            buttonWidget.TextColor     = new Color4(0.5f, 0.5f, 0.5f, 1f);
            buttonWidget.TextDownColor = new Color4(1f, 1f, 1f, 1f);
            buttonWidget.TextOverColor = new Color4(0.161f, 0.79f, 0.95f, 1f);
            buttonWidget.Alignment     = QFontAlignment.Left;
            buttonWidget.Init(host, "guicontrols", 704f, 320f, 735f, 351f, 736f, 320f, 767f, 351f, 704f, 352f, 735f, 383f);
            buttonWidget.DontMove = true;
            buttonWidget.SetCallback(new ButtonCallback(MyButtonCallback));
            AddChildElement(buttonWidget);
            tab_frame = new Frame(9)
            {
                X = 191,
                Y = 35
            };
            AddChildElement(tab_frame);
            CreateAppearanceFrame(host, softwareUpdater, messagebox);
            CreateManualControlsFrame(host, spooler_connection, settingsManager);
            CreateFilamentProfilesFrame(host, spooler_connection);
            CreateProFeaturesFrame(host, spooler_connection);
            CreateCalibrationFrame(host, spooler_connection);
            CreateAboutFrame(host);
            about_frame.Visible  = true;
            about_frame.Enabled  = true;
            active_frame         = about_frame;
            Sprite.pixel_perfect = false;
            Visible = false;
        }
Beispiel #36
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="button"></param>
 private void No(ButtonWidget button)
 {
     Running = false;
     result = false;
 }
Beispiel #37
0
        public void MyButtonCallback(ButtonWidget button)
        {
            PrinterObject selectedPrinter = SelectedPrinter;
            var           filament        = (FilamentSpool)null;

            if (selectedPrinter != null)
            {
                filament = selectedPrinter.GetCurrentFilament();
            }

            switch (button.ID)
            {
            case 109:
                --quality_scroll_list.StartIndex;
                break;

            case 111:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY5");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.Expert, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 112:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY1");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.HighQuality, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 113:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY2");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.MediumQuality, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 114:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY3");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.FastPrint, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 115:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY4");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.VeryFastPrint, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 116:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY6");
                if (!syncing)
                {
                    SlicerSettings.SetPrintQuality(PrintQuality.VeryHighQuality, filament, CurrentJobDetails.slicer_objects.Count);
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 117:
                ++quality_scroll_list.StartIndex;
                break;

            case 118:
                printQuality_editbox.Text = host.Locale.T("T_PRINTQUALITY7");
                if (string.IsNullOrEmpty(printQuality_editbox.Text))
                {
                    printQuality_editbox.Text = "Custom";
                }

                quality_scroll_list.GotoChild(button.ID);
                break;

            case 218:
                --density_scroll_list.StartIndex;
                break;

            case 220:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY1");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.ExtraHigh);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 221:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY2");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.High);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 222:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY3");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.Medium);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 223:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY4");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.Low);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 224:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY5");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.HollowThickWalls);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 225:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY6");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.HollowThinWalls);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 226:
                ++density_scroll_list.StartIndex;
                break;

            case 227:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY7");
                if (!syncing)
                {
                    SlicerSettings.SetFillQuality(FillQuality.Solid);
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 228:
                fillDensity_editbox.Text = host.Locale.T("T_FILLDENSITY8");
                if (string.IsNullOrEmpty(fillDensity_editbox.Text))
                {
                    fillDensity_editbox.Text = "Custom";
                }

                density_scroll_list.GotoChild(button.ID);
                break;

            case 301:
                if (syncing)
                {
                    break;
                }

                SetSupportEnabledControls(false);
                if (support_checkbutton.Checked)
                {
                    support_everywhere.Enabled   = true;
                    support_printbedonly.Enabled = true;
                    support_printbedonly.Checked = true;
                    SlicerSettings.EnableSupport(SupportType.LineSupport);
                    break;
                }
                SlicerSettings.DisableSupport();
                break;

            case 303:
                if (syncing || !support_everywhere.Checked)
                {
                    break;
                }

                SlicerSettings.EnableSupport(SupportType.LineSupportEveryWhere);
                break;

            case 307:
                if (syncing)
                {
                    break;
                }

                if (button.Checked)
                {
                    SlicerSettings.EnableRaft(filament);
                    break;
                }
                SlicerSettings.DisableRaft();
                break;

            case 311:
                if (syncing)
                {
                    break;
                }

                if (button.Checked)
                {
                    SlicerSettings.EnableSkirt();
                    break;
                }
                SlicerSettings.DisableSkirt();
                break;

            case 313:
                if (syncing || !support_printbedonly.Checked)
                {
                    break;
                }

                SlicerSettings.EnableSupport(SupportType.LineSupport);
                break;

            case 401:
            case 404:
                if (printerview.ModelLoaded)
                {
                    SaveSettings();
                    OnPrintButtonPressed(button.ID == 404);
                    break;
                }
                message_box.AddMessageToQueue(Locale.GlobalLocale.T("T_PrinterViewError_NoModel"));
                break;

            case 402:
                PrintDialogWindow.CloseWindow();
                break;

            case 403:
                ResetSettings();
                LoadSettings();
                break;

            case 501:
                OpenAdvancedPrintSettingsDialog();
                break;
            }
        }
Beispiel #38
0
    public void Start()
    {
        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the background
        m_backgroundGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_backgroundTiles = null;
        m_wallTiles = null;
        m_backgroundObjectTiles = null;

        // Create the foreground object group
        m_entityGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create the foreground tile group
        m_foregroundGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);
        m_foregroundObjectTiles = null;

        // Create the foreground UI
        m_foregroundUIGroup = new WidgetGroup(m_rootWidgetGroup, Screen.width, Screen.height, 0.0f, 0.0f);

        // Create game button
        m_logoutButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, 0, 0, "Logout");

        // Create the event navigation buttons
        {
            float layoutX = 0;
            float layoutY = Screen.height - buttonStyle.Height;

            m_firstEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<<");

            layoutX += m_firstEventButton.Width;
            m_previousEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "<");

            layoutX += m_previousEventButton.Width;
            m_playPauseEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, "||");

            layoutX += m_playPauseEventButton.Width;
            m_nextEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">");

            layoutX += m_nextEventButton.Width;
            m_lastEventButton = new ButtonWidget(m_foregroundUIGroup, buttonStyle, layoutX, layoutY, ">>");
        }
    }
Beispiel #39
0
    public void Start()
    {
        float viewWidth = GAME_PANEL_X + gamePanelStyle.Width;
        float viewHeight = Math.Max(SCROLL_LIST_Y + scrollListStyle.Width, GAME_PANEL_Y + gamePanelStyle.Height);

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, viewWidth, viewHeight, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        // Game list
        m_gameScrollList =
            new ScrollListWidget(
                m_rootWidgetGroup,
                (ScrollListWidget parentGroup, object parameters) =>
                {
                    return new GameThumbnailWidget(
                        parentGroup,
                        gameThumbnailStyle,
                        parameters as GameResponseEntry,
                        0.0f, 0.0f);
                },
                scrollListStyle,
                SCROLL_LIST_X, SCROLL_LIST_Y);

        // Game panel
        m_gamePanel = new GamePanelWidget(m_rootWidgetGroup, gamePanelStyle, GAME_PANEL_X, GAME_PANEL_Y);
        float panelWidth= m_gamePanel.Width - 2.0f * BORDER_WIDTH;

        // Create game button
        m_gameCreateButton = new ButtonWidget(m_gamePanel, buttonStyle, 0, 0, "Create");
        m_gameCreateButton.SetLocalPosition(
            BORDER_WIDTH + panelWidth/3 - m_gameCreateButton.Width,
            m_gamePanel.Height - m_gameCreateButton.Height - 5);

        // Select game button
        m_gameSelectButton = new ButtonWidget(m_gamePanel, buttonStyle, 0, 0, "Select");
        m_gameSelectButton.SetLocalPosition(
            BORDER_WIDTH + (2*panelWidth)/3 - m_gameSelectButton.Width,
            m_gamePanel.Height - m_gameSelectButton.Height - 5);
        m_gameSelectButton.Visible = false;

        // Delete game button
        m_gameDeleteButton = new ButtonWidget(m_gamePanel, buttonStyle, 0, 0, "Delete");
        m_gameDeleteButton.SetLocalPosition(
            BORDER_WIDTH + (3*panelWidth)/3 - m_gameDeleteButton.Width,
            m_gamePanel.Height - m_gameSelectButton.Height - 5);
        m_gameDeleteButton.Visible = false;

        // Initially hide all game data
        m_gamePanel.HideGameData();
    }
Beispiel #40
0
        void LayoutDialog(Widget bg)
        {
            bg.Children.RemoveAll(w => controls.Contains(w));
            controls.Clear();

            var y = 50;
            var margin = 20;
            var labelWidth = (bg.Bounds.Width - 3 * margin) / 3;

            var ts = new LabelWidget
            {
                Bold = true,
                Bounds = new Rectangle(margin + labelWidth + 10, y, labelWidth, 25),
                Text = "Their Stance",
                Align = LabelWidget.TextAlign.Left,
            };

            bg.AddChild(ts);
            controls.Add(ts);

            var ms = new LabelWidget
            {
                Bold = true,
                Bounds = new Rectangle(margin + 2 * labelWidth + 20, y, labelWidth, 25),
                Text = "My Stance",
                Align = LabelWidget.TextAlign.Left,
            };

            bg.AddChild(ms);
            controls.Add(ms);

            y += 35;

            foreach (var p in world.players.Values.Where(a => a != world.LocalPlayer && !a.NonCombatant))
            {
                var pp = p;
                var label = new LabelWidget
                {
                    Bounds = new Rectangle(margin, y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_{0}".F(p.Index),
                    Text = p.PlayerName,
                    Align = LabelWidget.TextAlign.Left,
                    Bold = true,
                };

                bg.AddChild(label);
                controls.Add(label);

                var theirStance = new LabelWidget
                {
                    Bounds = new Rectangle( margin + labelWidth + 10, y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_THEIR_{0}".F(p.Index),
                    Text = p.PlayerName,
                    Align = LabelWidget.TextAlign.Left,
                    Bold = false,

                    GetText = () => pp.Stances[ world.LocalPlayer ].ToString(),
                };

                bg.AddChild(theirStance);
                controls.Add(theirStance);

                var myStance = new ButtonWidget
                {
                    Bounds = new Rectangle( margin + 2 * labelWidth + 20,  y, labelWidth, 25),
                    Id = "DIPLOMACY_PLAYER_LABEL_MY_{0}".F(p.Index),
                    Text = world.LocalPlayer.Stances[ pp ].ToString(),
                };

                myStance.OnMouseUp = mi => { CycleStance(pp, myStance); return true; };

                bg.AddChild(myStance);
                controls.Add(myStance);

                y += 35;
            }
        }
Beispiel #41
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="button"></param>
 private void Yes(ButtonWidget button)
 {
     Running = false;
     result  = true;
 }
 ButtonWidget Make(int y, string text, ClickHandler onClick)
 {
     return(ButtonWidget.Create(game, 400, text, titleFont, onClick)
            .SetLocation(Anchor.Centre, Anchor.Centre, 0, y));
 }
Beispiel #43
0
        public void Init(GUIHost host)
        {
            X                    = 0;
            Y                    = 0;
            RelativeWidth        = 1f;
            RelativeHeight       = 1f;
            calibration_settings = new ButtonWidget(0, null)
            {
                Text          = "Calibration",
                TextColor     = new Color4(0.71f, 0.71f, 0.71f, 1f),
                TextOverColor = new Color4(1f, 1f, 1f, 1f),
                TextDownColor = new Color4(1f, 1f, 1f, 1f),
                Size          = FontSize.Medium
            };
            calibration_settings.SetCallback(new ButtonCallback(MyButtonCallback));
            calibration_settings.Init(host, "guicontrols", 513f, 64f, 575f, sbyte.MaxValue, 513f, 128f, 575f, 191f, 513f, 192f, 575f, byte.MaxValue);
            calibration_settings.SetGrowableWidth(16, 16, 48);
            calibration_settings.DontMove = true;
            calibration_settings.SetPosition(10, 10);
            calibration_settings.SetSize(200, 32);
            calibration_settings.ClickType = ButtonType.Checkable;
            calibration_settings.GroupID   = 1234;
            advancedcalibration_button     = new ButtonWidget(1, null)
            {
                Text          = "Advanced Calibration",
                TextColor     = new Color4(0.71f, 0.71f, 0.71f, 1f),
                TextOverColor = new Color4(1f, 1f, 1f, 1f),
                TextDownColor = new Color4(1f, 1f, 1f, 1f),
                Size          = FontSize.Medium
            };
            advancedcalibration_button.SetCallback(new ButtonCallback(MyButtonCallback));
            advancedcalibration_button.Init(host, "guicontrols", 576f, 64f, 639f, sbyte.MaxValue, 576f, 128f, 639f, 191f, 576f, 192f, 639f, byte.MaxValue);
            advancedcalibration_button.SetGrowableWidth(16, 16, 48);
            advancedcalibration_button.DontMove  = true;
            advancedcalibration_button.ClickType = ButtonType.Checkable;
            advancedcalibration_button.GroupID   = 1234;
            advancedcalibration_button.SetPosition(210, 10);
            advancedcalibration_button.SetSize(200, 32);
            AddChildElement(calibration_settings);
            AddChildElement(advancedcalibration_button);
            var frame = new Frame(3)
            {
                X              = 0,
                Y              = 50,
                RelativeWidth  = 1f,
                RelativeHeight = 0.85f,
                Enabled        = true,
                IgnoreMouse    = false
            };

            advanced_calibration_tab = new AdvancedCalibrationTab(1001, main_controller, messagebox, spooler_connection);
            advanced_calibration_tab.Init(host);
            advanced_calibration_tab.Visible        = false;
            advanced_calibration_tab.Enabled        = false;
            advanced_calibration_tab.RelativeWidth  = 1f;
            advanced_calibration_tab.RelativeHeight = 1f;
            advanced_calibration_tab.BGColor        = new Color4(246, 246, 246, byte.MaxValue);
            advanced_calibration_tab.BorderColor    = new Color4(220, 220, 220, byte.MaxValue);
            frame.AddChildElement(advanced_calibration_tab);
            calibration_tab = new CatScreenTab(1002, main_controller, spooler_connection, messagebox);
            calibration_tab.Init(host);
            calibration_tab.Visible        = true;
            calibration_tab.Enabled        = true;
            calibration_tab.RelativeWidth  = 1f;
            calibration_tab.RelativeHeight = 1f;
            frame.AddChildElement(calibration_tab);
            calibration_tab.BGColor     = new Color4(246, 246, 246, byte.MaxValue);
            calibration_tab.BorderColor = new Color4(220, 220, 220, byte.MaxValue);
            AddChildElement(frame);
            calibration_settings.SetChecked(true);
            active_frame = calibration_tab;
        }
Beispiel #44
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="button"></param>
 private void Yes(ButtonWidget button)
 {
     Running = false;
     result = true;
 }
Beispiel #45
0
 public override void MyButtonCallback(ButtonWidget button)
 {
 }
Beispiel #46
0
    public void Start()
    {
        bool isLocalServerRunning = AsyncRPGServer.GetInstance().IsServerActive();

        Screen.showCursor = true;

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the widget group to hold the login panel
        m_loginPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);

        // Background for the game info
        new ImageWidget(
            m_loginPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        // Username and Password - Left Aligned
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning = loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading = loginPanelStyle.gamePanelStyle.WidgetSpacing;

            // Server
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Server:"));
            m_serverText =
                cursor.Advance(
                    new TextEntryWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.textEntryStyle,
                        cursor.X, cursor.Y,
                        "localhost"));
            m_serverText.Visible = !isLocalServerRunning;
            m_localHostLabel     =
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    m_serverText.Width, m_serverText.Height,
                    m_serverText.LocalX, m_serverText.LocalY,
                    "localhost");
            m_localHostLabel.Visible = isLocalServerRunning;
            cursor.NewLine();

            // Local hosted check box
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Host Server:"));
            m_localHostCheckBox =
                cursor.Advance(
                    new CheckBoxWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.checkBoxStyle,
                        cursor.X, cursor.Y));
            m_localHostCheckBox.Enabled = isLocalServerRunning;
            cursor.NewLine();

            // Username
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Username:"******"test" : ""));
            cursor.NewLine();

            // Password
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Password:"******"password" : ""));
            m_passwordText.IsPassword = true;
            cursor.NewLine();
        }

        // Buttons - Centered along the bottom
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.Width / 2
                - loginPanelStyle.gamePanelStyle.WidgetSpacing / 2
                - loginPanelStyle.buttonStyle.Width,
                loginPanelStyle.gamePanelStyle.Height
                - loginPanelStyle.buttonStyle.Height
                - loginPanelStyle.labelStyle.Height
                - loginPanelStyle.gamePanelStyle.BorderWidth
                - loginPanelStyle.gamePanelStyle.WidgetSpacing);

            m_createAccountButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "New Account"));
            m_createAccountButton.Visible = false;

            m_loginButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "Login"));
            m_loginButton.Visible = true;

            cursor.NewLine();

            m_loginStatusLabel =
                cursor.Advance(
                    new LabelWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.gamePanelStyle.Width
                        - 2.0f * loginPanelStyle.gamePanelStyle.BorderWidth,
                        loginPanelStyle.labelStyle.Height,
                        cursor.X, cursor.Y,
                        ""));
        }

        // Server Status Panel
        m_serverPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);
        m_serverPanelWidgetGroup.Visible = false;

        // Background for the game info
        new ImageWidget(
            m_serverPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        {
            float contentCenter       = loginPanelStyle.gamePanelStyle.Width / 2.0f;
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                0.0f,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning = loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading = loginPanelStyle.gamePanelStyle.WidgetSpacing;

            LabelWidget topLabel =
                cursor.Advance(
                    new LabelWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.labelStyle,
                        contentCenter - loginPanelStyle.labelStyle.Width / 2.0f, cursor.Y,
                        "[Server]"));
            topLabel.Alignment = TextAnchor.UpperCenter;
            cursor.NewLine();

            m_serverStatusText =
                cursor.Advance(
                    new ScrollTextWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.scrollTextStyle,
                        contentCenter - loginPanelStyle.scrollTextStyle.Width / 2.0f, cursor.Y,
                        ""));
            cursor.NewLine();

            m_serverOkButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        contentCenter - loginPanelStyle.buttonStyle.Width / 2.0f, cursor.Y,
                        "Ok"));
            m_serverOkButton.Visible = false;
        }
    }
Beispiel #47
0
    public void Start()
    {
        bool isLocalServerRunning= AsyncRPGServer.GetInstance().IsServerActive();
        Screen.showCursor = true;

        // Create the root widget group
        m_rootWidgetGroup = new WidgetGroup(null, Screen.width, Screen.height, 0.0f, 0.0f);
        m_rootWidgetGroup.SetWidgetEventListener(this);

        m_widgetEventDispatcher = new WidgetEventDispatcher();
        m_widgetEventDispatcher.Start(m_rootWidgetGroup);

        // Create the widget group to hold the login panel
        m_loginPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);

        // Background for the game info
        new ImageWidget(
            m_loginPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        // Username and Password - Left Aligned
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning= loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading= loginPanelStyle.gamePanelStyle.WidgetSpacing;

            // Server
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Server:"));
            m_serverText =
                cursor.Advance(
                    new TextEntryWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.textEntryStyle,
                        cursor.X, cursor.Y,
                        "localhost"));
            m_serverText.Visible= !isLocalServerRunning;
            m_localHostLabel=
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    m_serverText.Width, m_serverText.Height,
                    m_serverText.LocalX, m_serverText.LocalY,
                    "localhost");
            m_localHostLabel.Visible= isLocalServerRunning;
            cursor.NewLine();

            // Local hosted check box
            cursor.Advance(
                new LabelWidget(
                m_loginPanelWidgetGroup,
                loginPanelStyle.labelStyle,
                cursor.X, cursor.Y,
                "Host Server:"));
            m_localHostCheckBox=
                cursor.Advance(
                    new CheckBoxWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.checkBoxStyle,
                        cursor.X, cursor.Y));
            m_localHostCheckBox.Enabled = isLocalServerRunning;
            cursor.NewLine();

            // Username
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Username:"******"test" : ""));
            cursor.NewLine();

            // Password
            cursor.Advance(
                new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.labelStyle,
                    cursor.X, cursor.Y,
                    "Password:"******"password" : ""));
            m_passwordText.IsPassword= true;
            cursor.NewLine();
        }

        // Buttons - Centered along the bottom
        {
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                loginPanelStyle.gamePanelStyle.Width/2
                - loginPanelStyle.gamePanelStyle.WidgetSpacing/2
                - loginPanelStyle.buttonStyle.Width,
                loginPanelStyle.gamePanelStyle.Height
                - loginPanelStyle.buttonStyle.Height
                - loginPanelStyle.labelStyle.Height
                - loginPanelStyle.gamePanelStyle.BorderWidth
                - loginPanelStyle.gamePanelStyle.WidgetSpacing);

            m_createAccountButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "New Account"));
            m_createAccountButton.Visible= false;

            m_loginButton =
                cursor.Advance(
                    new ButtonWidget(
                        m_loginPanelWidgetGroup,
                        loginPanelStyle.buttonStyle,
                        cursor.X, cursor.Y,
                        "Login"));
            m_loginButton.Visible= true;

            cursor.NewLine();

            m_loginStatusLabel=
                cursor.Advance(
                    new LabelWidget(
                    m_loginPanelWidgetGroup,
                    loginPanelStyle.gamePanelStyle.Width
                    - 2.0f*loginPanelStyle.gamePanelStyle.BorderWidth,
                    loginPanelStyle.labelStyle.Height,
                    cursor.X, cursor.Y,
                    ""));
        }

        // Server Status Panel
        m_serverPanelWidgetGroup =
            new WidgetGroup(
                m_rootWidgetGroup,
                loginPanelStyle.gamePanelStyle.Width, loginPanelStyle.gamePanelStyle.Height,
                Screen.width / 2 - loginPanelStyle.gamePanelStyle.Width / 2,
                Screen.height / 2 - loginPanelStyle.gamePanelStyle.Height / 2);
        m_serverPanelWidgetGroup.Visible= false;

        // Background for the game info
        new ImageWidget(
            m_serverPanelWidgetGroup,
            loginPanelStyle.gamePanelStyle.Width,
            loginPanelStyle.gamePanelStyle.Height,
            loginPanelStyle.gamePanelStyle.Background,
            0.0f, 0.0f);

        {
            float contentCenter= loginPanelStyle.gamePanelStyle.Width / 2.0f;
            WidgetLayoutCursor cursor = new WidgetLayoutCursor(
                0.0f,
                loginPanelStyle.gamePanelStyle.BorderWidth
                + loginPanelStyle.gamePanelStyle.WidgetSpacing);
            cursor.Kerning= loginPanelStyle.gamePanelStyle.WidgetSpacing;
            cursor.Leading= loginPanelStyle.gamePanelStyle.WidgetSpacing;

            LabelWidget topLabel=
                cursor.Advance(
                    new LabelWidget(
                        m_serverPanelWidgetGroup,
                        loginPanelStyle.labelStyle,
                        contentCenter - loginPanelStyle.labelStyle.Width / 2.0f, cursor.Y,
                        "[Server]"));
            topLabel.Alignment= TextAnchor.UpperCenter;
            cursor.NewLine();

            m_serverStatusText=
                cursor.Advance(
                    new ScrollTextWidget(
                    m_serverPanelWidgetGroup,
                    loginPanelStyle.scrollTextStyle,
                    contentCenter - loginPanelStyle.scrollTextStyle.Width / 2.0f, cursor.Y,
                    ""));
            cursor.NewLine();

            m_serverOkButton=
                cursor.Advance(
                    new ButtonWidget(
                    m_serverPanelWidgetGroup,
                    loginPanelStyle.buttonStyle,
                    contentCenter - loginPanelStyle.buttonStyle.Width / 2.0f, cursor.Y,
                    "Ok"));
            m_serverOkButton.Visible= false;
        }
    }