Beispiel #1
0
        public override void Start()
        {
            name             = $"{Configuration.ResourcePrefix}LoadWindow";
            atlas            = UIUtil.DefaultAtlas;
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 180);
            canFocus         = true;

            _dragHandle                  = AddUIComponent <UIDragHandle>();
            _dragHandle.target           = parent;
            _dragHandle.relativePosition = Vector3.zero;

            _closeButton                  = AddUIComponent <UIButton>();
            _closeButton.size             = new Vector2(30f, 30f);
            _closeButton.text             = "X";
            _closeButton.textScale        = 0.9f;
            _closeButton.textColor        = new Color32(118, 123, 123, 255);
            _closeButton.focusedTextColor = new Color32(118, 123, 123, 255);
            _closeButton.hoveredTextColor = new Color32(140, 142, 142, 255);
            _closeButton.pressedTextColor = new Color32(99, 102, 102, 102);
            _closeButton.textPadding      = new RectOffset(8, 8, 8, 8);
            _closeButton.canFocus         = false;
            _closeButton.playAudioEvents  = true;
            _closeButton.relativePosition = new Vector3(width - _closeButton.width, 0);

            _importLabel                  = AddUIComponent <UILabel>();
            _importLabel.textScale        = 0.9f;
            _importLabel.text             = "Import";
            _importLabel.relativePosition = new Vector2(8, 8);
            _importLabel.SendToBack();

            // FastList
            _fastList = AddUIComponent <UIFastList>();
            _fastList.backgroundSprite = "UnlockingPanel";
            _fastList.width            = width - 16;
            _fastList.height           = 46 * 5;
            _fastList.canSelect        = true;
            _fastList.relativePosition = new Vector3(8, 28);

            _fastList.rowHeight = 46f;

            height           = _fastList.relativePosition.y + _fastList.height + 8;
            _dragHandle.size = size;
            absolutePosition = new Vector3(LoadWindowX.value, LoadWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            _modalEffect = GetUIView().panelsLibraryModalEffect;
            if (_modalEffect != null && !_modalEffect.isVisible)
            {
                _modalEffect.Show(false);
                ValueAnimator.Animate("ModalEffect", delegate(float val) { _modalEffect.opacity = val; },
                                      new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));
            }

            SubscribeToUiEvents();

            BringToFront();
            Focus();
        }
        public override void Start()
        {
            name             = $"{Configuration.ResourcePrefix}SaveWindow";
            atlas            = UIUtil.DefaultAtlas;
            backgroundSprite = "SubcategoriesPanel";
            size             = new Vector2(465, 180);
            canFocus         = true;

            _dragHandle                  = AddUIComponent <UIDragHandle>();
            _dragHandle.target           = parent;
            _dragHandle.relativePosition = Vector3.zero;

            _closeButton                  = AddUIComponent <UIButton>();
            _closeButton.size             = new Vector2(30f, 30f);
            _closeButton.text             = "X";
            _closeButton.textScale        = 0.9f;
            _closeButton.textColor        = new Color32(118, 123, 123, 255);
            _closeButton.focusedTextColor = new Color32(118, 123, 123, 255);
            _closeButton.hoveredTextColor = new Color32(140, 142, 142, 255);
            _closeButton.pressedTextColor = new Color32(99, 102, 102, 102);
            _closeButton.textPadding      = new RectOffset(8, 8, 8, 8);
            _closeButton.canFocus         = false;
            _closeButton.playAudioEvents  = true;
            _closeButton.relativePosition = new Vector3(width - _closeButton.width, 0);

            _exportLabel                  = AddUIComponent <UILabel>();
            _exportLabel.textScale        = 0.9f;
            _exportLabel.text             = "Export";
            _exportLabel.relativePosition = new Vector2(8, 8);
            _exportLabel.SendToBack();

            // Save Panel
            _savePanel                  = AddUIComponent <UIPanel>();
            _savePanel.atlas            = atlas;
            _savePanel.backgroundSprite = "GenericPanel";
            _savePanel.color            = new Color32(206, 206, 206, 255);
            _savePanel.size             = new Vector2(width - 16, 46);
            _savePanel.relativePosition = new Vector2(8, 28);

            // Input
            _fileNameInput                     = UIUtil.CreateTextField(_savePanel);
            _fileNameInput.padding.top         = 7;
            _fileNameInput.horizontalAlignment = UIHorizontalAlignment.Left;
            _fileNameInput.relativePosition    = new Vector3(8, 8);
            _fileNameInput.submitOnFocusLost   = true;

            // Save
            _saveButton = UIUtil.CreateUiButton(_savePanel, string.Empty, string.Empty, new Vector2(100, 30),
                                                string.Empty, true);
            _saveButton.name             = $"{Configuration.ResourcePrefix}SaveButton";
            _saveButton.text             = Locale.Get($"{Configuration.ResourcePrefix}TEXTS", "ExportButton");
            _saveButton.tooltip          = Locale.Get($"{Configuration.ResourcePrefix}TOOLTIPS", "ExportButton");
            _saveButton.relativePosition = new Vector3(_savePanel.width - _saveButton.width - 8, 8);

            _fileNameInput.size = new Vector2(_saveButton.relativePosition.x - 16f, 30f);

            // FastList
            _fastList = AddUIComponent <UIFastList>();
            _fastList.backgroundSprite = "UnlockingPanel";
            _fastList.width            = width - 16;
            _fastList.height           = 46 * 5;
            _fastList.canSelect        = true;
            _fastList.relativePosition = new Vector3(8, _savePanel.relativePosition.y + _savePanel.height + 8);
            _fastList.rowHeight        = 46f;

            height           = _fastList.relativePosition.y + _fastList.height + 8;
            _dragHandle.size = size;
            absolutePosition = new Vector3(SaveWindowX.value, SaveWindowY.value);
            MakePixelPerfect();

            RefreshFileList();

            _modalEffect = GetUIView().panelsLibraryModalEffect;
            if (_modalEffect != null && !_modalEffect.isVisible)
            {
                _modalEffect.Show(false);
                ValueAnimator.Animate("ModalEffect", delegate(float val) { _modalEffect.opacity = val; },
                                      new AnimatedFloat(0f, 1f, 0.7f, EasingType.CubicEaseOut));
            }

            SubscribeToUiEvents();

            BringToFront();
            _fileNameInput.Focus();
        }