protected override void Setup() { // Save panel savePanel.HorizontalAlignment = HorizontalAlignment.Center; savePanel.VerticalAlignment = VerticalAlignment.Middle; savePanel.Size = new Vector2(300, 160); DaggerfallUI.Instance.SetDaggerfallPopupStyle(DaggerfallUI.PopupStyle.Parchment, savePanel); NativePanel.Components.Add(savePanel); // Title TextLabel titleLabel = new TextLabel(); titleLabel.HorizontalAlignment = HorizontalAlignment.Center; titleLabel.VerticalAlignment = VerticalAlignment.Top; titleLabel.Text = HardStrings.saveGame; titleLabel.Font = DaggerfallUI.TitleFont; savePanel.Components.Add(titleLabel); // Child panels int top = 16; saveListPanel = DaggerfallUI.AddPanel(new Rect(0, top, 110, savePanel.Size.y - top), savePanel); saveListPanel.HorizontalAlignment = HorizontalAlignment.Left; saveListPanel.BackgroundColor = panelBackgroundColor; detailsPanel = DaggerfallUI.AddPanel(new Rect(110, top, 180, savePanel.Size.y - top), savePanel); detailsPanel.HorizontalAlignment = HorizontalAlignment.Right; detailsPanel.BackgroundColor = panelBackgroundColor; // Outlines DaggerfallUI.AddOutline(new Rect(0, 0, saveListPanel.Size.x, saveListPanel.Size.y), outlineColor, saveListPanel); DaggerfallUI.AddOutline(new Rect(0, 0, detailsPanel.Size.x, detailsPanel.Size.y), outlineColor, detailsPanel); }
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 = TextureLayout.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); } }