Пример #1
0
        void ShowResolutionPanel()
        {
            // Disable previous stage
            browserPanel.Enabled = false;

            // Get resolutions
            initialResolution    = Screen.currentResolution;
            availableResolutions = DaggerfallUI.GetDistinctResolutions();

            // Create backdrop
            if (!backdropCreated)
            {
                CreateBackdrop();
            }

            // Add resolution panel
            resolutionPanel.Outline.Enabled     = true;
            resolutionPanel.BackgroundColor     = backgroundColor;
            resolutionPanel.HorizontalAlignment = HorizontalAlignment.Left;
            resolutionPanel.VerticalAlignment   = VerticalAlignment.Middle;
            resolutionPanel.Size = new Vector2(120, 175);
            NativePanel.Components.Add(resolutionPanel);

            // Add resolution title text
            TextLabel resolutionTitleLabel = new TextLabel();

            resolutionTitleLabel.Text     = GetText("resolution");
            resolutionTitleLabel.Position = new Vector2(0, 2);
            //resolutionTitleLabel.ShadowPosition = Vector2.zero;
            resolutionTitleLabel.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionPanel.Components.Add(resolutionTitleLabel);

            // Add resolution picker
            resolutionList.BackgroundColor     = new Color(0.1f, 0.1f, 0.1f, 0.5f);
            resolutionList.TextColor           = unselectedTextColor;
            resolutionList.SelectedTextColor   = selectedTextColor;
            resolutionList.ShadowPosition      = Vector2.zero;
            resolutionList.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionList.RowsDisplayed       = 8;
            resolutionList.RowAlignment        = HorizontalAlignment.Center;
            resolutionList.Position            = new Vector2(0, 12);
            resolutionList.Size = new Vector2(80, 62);
            resolutionList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            resolutionList.SelectedShadowColor    = Color.black;
            resolutionList.OnMouseClick          += ResolutionList_OnMouseClick;
            resolutionList.OnScroll += ResolutionList_OnScroll;
            resolutionPanel.Components.Add(resolutionList);

            // Add resolution scrollbar
            resolutionScroller.Position  = new Vector2(100, 12);
            resolutionScroller.Size      = new Vector2(5, 62);
            resolutionScroller.OnScroll += ResolutionScroller_OnScroll;
            resolutionPanel.Components.Add(resolutionScroller);

            // Add resolutions
            for (int i = 0; i < availableResolutions.Length; i++)
            {
                string item = string.Format("{0}x{1}", availableResolutions[i].width, availableResolutions[i].height);
                resolutionList.AddItem(item);

                if (availableResolutions[i].width == initialResolution.width &&
                    availableResolutions[i].height == initialResolution.height)
                {
                    resolutionList.SelectedIndex = i;
                }
            }
            resolutionList.ScrollToSelected();

            // Setup scroller
            resolutionScroller.DisplayUnits    = 8;
            resolutionScroller.TotalUnits      = resolutionList.Count;
            resolutionScroller.BackgroundColor = resolutionList.BackgroundColor;

            // Add fullscreen checkbox
            fullscreenCheckbox.Label.Text           = GetText("fullscreen");
            fullscreenCheckbox.Label.ShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            fullscreenCheckbox.Label.ShadowColor    = Color.black;
            fullscreenCheckbox.Position             = new Vector2(0, 76);
            fullscreenCheckbox.HorizontalAlignment  = HorizontalAlignment.Center;
            fullscreenCheckbox.IsChecked            = Screen.fullScreen;
            fullscreenCheckbox.CheckBoxColor        = selectedTextColor;
            fullscreenCheckbox.Label.TextColor      = selectedTextColor;
            fullscreenCheckbox.OnToggleState       += FullscreenCheckbox_OnToggleState;
            resolutionPanel.Components.Add(fullscreenCheckbox);

            // Add quality title text
            TextLabel qualityTitleLabel = new TextLabel();

            qualityTitleLabel.Text     = GetText("quality");
            qualityTitleLabel.Position = new Vector2(0, 92);
            //qualityTitleLabel.ShadowPosition = Vector2.zero;
            qualityTitleLabel.HorizontalAlignment = HorizontalAlignment.Center;
            resolutionPanel.Components.Add(qualityTitleLabel);

            // Add quality picker
            qualityList.BackgroundColor     = new Color(0.1f, 0.1f, 0.1f, 0.5f);
            qualityList.TextColor           = unselectedTextColor;
            qualityList.SelectedTextColor   = selectedTextColor;
            qualityList.ShadowPosition      = Vector2.zero;
            qualityList.HorizontalAlignment = HorizontalAlignment.Center;
            qualityList.RowsDisplayed       = 6;
            qualityList.RowAlignment        = HorizontalAlignment.Center;
            qualityList.Position            = new Vector2(0, 102);
            qualityList.Size = new Vector2(85, 46);
            qualityList.SelectedShadowPosition = DaggerfallUI.DaggerfallDefaultShadowPos;
            qualityList.SelectedShadowColor    = Color.black;
            qualityList.OnMouseClick          += QualityList_OnMouseClick;
            resolutionPanel.Components.Add(qualityList);
            foreach (var name in QualitySettings.names)
            {
                qualityList.AddItem(name);
            }
            qualityList.SelectedIndex = DaggerfallUnity.Settings.QualityLevel;

            // Test/confirm button
            testText = GetText("testText");
            okText   = GetText("okText");
            testOrConfirmButton.Position            = new Vector2(0, 160);
            testOrConfirmButton.Size                = new Vector2(40, 12);
            testOrConfirmButton.Outline.Enabled     = true;
            testOrConfirmButton.Label.Text          = testText;
            testOrConfirmButton.BackgroundColor     = new Color(0.0f, 0.5f, 0.0f, 0.4f);
            testOrConfirmButton.HorizontalAlignment = HorizontalAlignment.Center;
            testOrConfirmButton.OnMouseClick       += ResolutionTestOrConfirmButton_OnMouseClick;
            resolutionPanel.Components.Add(testOrConfirmButton);
        }