Esempio n. 1
0
        public static Outline AddOutline(Rect rect, Color color, Panel panel = null)
        {
            Outline outline = new Outline();
            outline.ScalingMode = Scaling.None;
            outline.Color = color;
            outline.Position = new Vector2(rect.x, rect.y);
            outline.Size = new Vector2(rect.width, rect.height);
            if (panel != null)
                panel.Components.Add(outline);

            return outline;
        }
        void AddControls()
        {
            saveImageButtons = new Button[saveImageButtonDims.Length];
            saveTextButtons = new Button[saveTextButtonDims.Length];
            for (int i = 0; i < saveImageButtonDims.Length; i++)
            {
                // Open save
                if (!saveGames.LazyOpenSave(i))
                {
                    DaggerfallUnity.LogMessage(string.Format("Could not lazy open save index {0}.", i), true);
                    continue;
                }

                // Get save texture
                Texture2D saveTexture = TextureReader.CreateFromAPIImage(saveGames.SaveImage);
                saveTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode;

                // Setup image button
                saveImageButtons[i] = DaggerfallUI.AddButton(saveImageButtonDims[i], NativePanel);
                saveImageButtons[i].BackgroundTexture = saveTexture;
                saveImageButtons[i].BackgroundTextureLayout = BackgroundLayout.ScaleToFit;
                saveImageButtons[i].Tag = i;
                saveImageButtons[i].OnMouseClick += SaveGame_OnMouseClick;
                saveImageButtons[i].OnMouseDoubleClick += SaveGame_OnMouseDoubleClick;

                // Setup text button
                saveTextButtons[i] = DaggerfallUI.AddButton(saveTextButtonDims[i], NativePanel);
                saveTextButtons[i].Label.Text = saveGames.SaveName;
                saveTextButtons[i].Tag = i;
                saveTextButtons[i].OnMouseClick += SaveGame_OnMouseClick;
                saveTextButtons[i].OnMouseDoubleClick += SaveGame_OnMouseDoubleClick;

                // Select first valid save game
                if (selectedSaveGame == -1)
                    selectedSaveGame = i;
            }

            // Setup outline
            outline = DaggerfallUI.AddOutline(outlineRects[0], DaggerfallUI.DaggerfallDefaultTextColor, NativePanel);
            if (selectedSaveGame == -1)
                outline.Enabled = false;
            else
                SelectSaveGame(selectedSaveGame);

            // Setup load game button
            if (selectedSaveGame >= 0)
            {
                Button loadGameButton = DaggerfallUI.AddButton(new Vector2(126, 5), new Vector2(68, 11), NativePanel);
                loadGameButton.OnMouseClick += LoadGameButton_OnMouseClick;
            }

            // Setup exit button
            DaggerfallUI.AddButton(new Vector2(133, 150), new Vector2(56, 19), WindowMessages.wmCloseWindow, NativePanel);

            //// TEMP: Look for quick save and add temp button
            //if (SaveLoadManager.Instance.HasQuickSave())
            //{
            //    Button quickLoadButton = new Button();
            //    quickLoadButton.HorizontalAlignment = HorizontalAlignment.Center;
            //    quickLoadButton.VerticalAlignment = VerticalAlignment.Middle;
            //    quickLoadButton.BackgroundColor = Color.gray;
            //    quickLoadButton.Label.Text = "Quick Load";
            //    quickLoadButton.Label.BackgroundColor = Color.gray;
            //    quickLoadButton.OnMouseClick += QuickLoadButton_OnMouseClick;
            //    quickLoadButton.Size = new Vector2(52, 10);
            //    NativePanel.Components.Add(quickLoadButton);
            //}
        }