public static Button AddTextButton(Rect rect, string text, Panel panel = null) { Button button = new UserInterface.Button(); button.Position = new Vector2(rect.x, rect.y); button.Size = new Vector2(rect.width, rect.height); button.Outline.Enabled = true; button.Label.HorizontalAlignment = HorizontalAlignment.Center; button.Label.ShadowPosition = Vector2.zero; button.Label.Text = text; if (panel != null) { panel.Components.Add(button); } return(button); }
public FacePicker() { // Face display panel faceDisplayPanel.Position = new Vector2(247, 25); faceDisplayPanel.Size = new Vector2(64, 40); this.Components.Add(faceDisplayPanel); // Face panel facePanel.HorizontalAlignment = HorizontalAlignment.Center; facePanel.VerticalAlignment = VerticalAlignment.Middle; faceDisplayPanel.Components.Add(facePanel); // Previous/Next buttons prevFaceButton = DaggerfallUI.AddButton(new Rect(245, 69, 42, 9), this); prevFaceButton.OnMouseClick += PrevFaceButton_OnMouseClick; nextFaceButton = DaggerfallUI.AddButton(new Rect(287, 69, 26, 9), this); nextFaceButton.OnMouseClick += NextFaceButton_OnMouseClick; }
protected override void Setup() { // Main panel mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.VerticalAlignment = VerticalAlignment.Middle; mainPanel.Size = mainPanelSize; mainPanel.Outline.Enabled = true; mainPanel.BackgroundColor = mainPanelBackgroundColor; NativePanel.Components.Add(mainPanel); // Prompt promptLabel.ShadowPosition = Vector2.zero; promptLabel.Position = new Vector2(4, 4); mainPanel.Components.Add(promptLabel); // Name panel Panel namePanel = new Panel(); namePanel.Position = new Vector2(4, 12); namePanel.Size = new Vector2(272, 9); namePanel.Outline.Enabled = true; namePanel.BackgroundColor = namePanelBackgroundColor; mainPanel.Components.Add(namePanel); // Name input saveNameTextBox.Position = new Vector2(2, 2); saveNameTextBox.MaxCharacters = 26; saveNameTextBox.OnType += SaveNameTextBox_OnType; namePanel.Components.Add(saveNameTextBox); // Save panel Panel savesPanel = new Panel(); savesPanel.Position = new Vector2(4, 25); savesPanel.Size = new Vector2(100, 141); savesPanel.Outline.Enabled = true; mainPanel.Components.Add(savesPanel); // Save list savesList.Position = new Vector2(2, 2); savesList.Size = new Vector2(91, 129); savesList.TextColor = savesListTextColor; savesList.BackgroundColor = savesListBackgroundColor; savesList.ShadowPosition = Vector2.zero; savesList.RowsDisplayed = 16; savesList.OnScroll += SavesList_OnScroll; savesList.OnSelectItem += SavesList_OnSelectItem; savesList.OnMouseDoubleClick += SaveLoadEventHandler; savesPanel.Components.Add(savesList); // Save scroller savesScroller.Position = new Vector2(94, 2); savesScroller.Size = new Vector2(5, 129); savesScroller.DisplayUnits = 16; savesScroller.OnScroll += SavesScroller_OnScroll; savesPanel.Components.Add(savesScroller); // Save/Load button goButton.Position = new Vector2(108, 150); goButton.Size = new Vector2(40, 16); goButton.Label.ShadowColor = Color.black; goButton.BackgroundColor = saveButtonBackgroundColor; goButton.Outline.Enabled = true; goButton.OnMouseClick += SaveLoadEventHandler; mainPanel.Components.Add(goButton); // Switch to classic save window button switchClassicButton.Position = new Vector2(172, 150); switchClassicButton.Size = new Vector2(40, 16); switchClassicButton.Label.Text = "Classic"; //switchClassicButton.Label.TextColor = new Color(0.6f, 0.3f, 0.6f); switchClassicButton.Label.ShadowColor = Color.black; switchClassicButton.BackgroundColor = new Color(0.2f, 0.2f, 0); switchClassicButton.Outline.Enabled = true; switchClassicButton.OnMouseClick += SwitchClassicButton_OnMouseClick; mainPanel.Components.Add(switchClassicButton); // Cancel button Button cancelButton = new Button(); cancelButton.Position = new Vector2(236, 150); cancelButton.Size = new Vector2(40, 16); cancelButton.Label.Text = "Cancel"; cancelButton.Label.ShadowColor = Color.black; cancelButton.BackgroundColor = cancelButtonBackgroundColor; cancelButton.Outline.Enabled = true; cancelButton.OnMouseClick += CancelButton_OnMouseClick; mainPanel.Components.Add(cancelButton); // Screenshot panel screenshotPanel.Position = new Vector2(108, 25); screenshotPanel.Size = new Vector2(168, 95); screenshotPanel.BackgroundTextureLayout = BackgroundLayout.ScaleToFit; screenshotPanel.BackgroundColor = savesListBackgroundColor; screenshotPanel.Outline.Enabled = true; mainPanel.Components.Add(screenshotPanel); // Info panel Panel infoPanel = new Panel(); infoPanel.Position = new Vector2(108, 122); infoPanel.Size = new Vector2(168, 26); mainPanel.Components.Add(infoPanel); // Save version saveVersionLabel.ShadowColor = Color.black; saveVersionLabel.Position = new Vector2(1, 1); saveVersionLabel.TextColor = saveFolderColor; screenshotPanel.Components.Add(saveVersionLabel); // Save folder saveFolderLabel.ShadowColor = Color.black; saveFolderLabel.HorizontalAlignment = HorizontalAlignment.Right; saveFolderLabel.Position = new Vector2(0, 1); saveFolderLabel.TextColor = saveFolderColor; screenshotPanel.Components.Add(saveFolderLabel); // Time labels saveTimeLabel.ShadowPosition = Vector2.zero; saveTimeLabel.HorizontalAlignment = HorizontalAlignment.Center; saveTimeLabel.Position = new Vector2(0, 0); infoPanel.Components.Add(saveTimeLabel); gameTimeLabel.ShadowPosition = Vector2.zero; gameTimeLabel.HorizontalAlignment = HorizontalAlignment.Center; gameTimeLabel.Position = new Vector2(0, 9); infoPanel.Components.Add(gameTimeLabel); // Delete save button deleteSaveButton.Position = new Vector2(0, 132); deleteSaveButton.Size = new Vector2(98, 8); deleteSaveButton.HorizontalAlignment = HorizontalAlignment.Center; deleteSaveButton.Label.Text = "Delete Save"; deleteSaveButton.Label.ShadowColor = Color.black; deleteSaveButton.BackgroundColor = namePanelBackgroundColor; deleteSaveButton.Outline.Enabled = false; deleteSaveButton.OnMouseClick += DeleteSaveButton_OnMouseClick; savesPanel.Components.Add(deleteSaveButton); // Switch character button switchCharButton.Position = new Vector2(216, 2); switchCharButton.Size = new Vector2(60, 8); switchCharButton.Label.Text = "Switch Char"; switchCharButton.Label.ShadowColor = Color.black; switchCharButton.BackgroundColor = saveButtonBackgroundColor; switchCharButton.OnMouseClick += SwitchCharButton_OnMouseClick; mainPanel.Components.Add(switchCharButton); }
void SetupActionButtons() { wagonButton = DaggerfallUI.AddButton(wagonButtonRect, NativePanel); wagonButton.OnMouseClick += WagonButton_OnMouseClick; infoButton = DaggerfallUI.AddButton(infoButtonRect, NativePanel); infoButton.OnMouseClick += InfoButton_OnMouseClick; equipButton = DaggerfallUI.AddButton(equipButtonRect, NativePanel); equipButton.OnMouseClick += EquipButton_OnMouseClick; removeButton = DaggerfallUI.AddButton(removeButtonRect, NativePanel); removeButton.OnMouseClick += RemoveButton_OnMouseClick; useButton = DaggerfallUI.AddButton(useButtonRect, NativePanel); useButton.OnMouseClick += UseButton_OnMouseClick; goldButton = DaggerfallUI.AddButton(goldButtonRect, NativePanel); goldButton.OnMouseClick += GoldButton_OnMouseClick; //goldButton.BackgroundColor = new Color(1, 0, 0, 0.5f); }
// Updates red/green state of scroller buttons void UpdateListScrollerButtons(int index, int count, Button upButton, Button downButton) { // Update up button if (index > 0) upButton.BackgroundTexture = greenUpArrow; else upButton.BackgroundTexture = redUpArrow; // Update down button if (index < (count - listDisplayUnits)) downButton.BackgroundTexture = greenDownArrow; else downButton.BackgroundTexture = redDownArrow; // No items above or below if (count <= listDisplayUnits) { upButton.BackgroundTexture = redUpArrow; downButton.BackgroundTexture = redDownArrow; } }
void SetupTabPageButtons() { weaponsAndArmorButton = DaggerfallUI.AddButton(weaponsAndArmorRect, NativePanel); weaponsAndArmorButton.OnMouseClick += WeaponsAndArmor_OnMouseClick; magicItemsButton = DaggerfallUI.AddButton(magicItemsRect, NativePanel); magicItemsButton.OnMouseClick += MagicItems_OnMouseClick; clothingAndMiscButton = DaggerfallUI.AddButton(clothingAndMiscRect, NativePanel); clothingAndMiscButton.OnMouseClick += ClothingAndMisc_OnMouseClick; ingredientsButton = DaggerfallUI.AddButton(ingredientsRect, NativePanel); ingredientsButton.OnMouseClick += Ingredients_OnMouseClick; }
void SetupScrollButtons() { localItemsUpButton = DaggerfallUI.AddButton(localItemsUpButtonRect, NativePanel); localItemsUpButton.BackgroundTexture = redUpArrow; localItemsUpButton.OnMouseClick += LocalItemsUpButton_OnMouseClick; localItemsDownButton = DaggerfallUI.AddButton(localItemsDownButtonRect, NativePanel); localItemsDownButton.BackgroundTexture = redDownArrow; localItemsDownButton.OnMouseClick += LocalItemsDownButton_OnMouseClick; remoteItemsUpButton = DaggerfallUI.AddButton(remoteItemsUpButtonRect, NativePanel); remoteItemsUpButton.BackgroundTexture = redUpArrow; remoteItemsUpButton.OnMouseClick += RemoteItemsUpButton_OnMouseClick; remoteItemsDownButton = DaggerfallUI.AddButton(remoteItemsDownButtonRect, NativePanel); remoteItemsDownButton.BackgroundTexture = redDownArrow; remoteItemsDownButton.OnMouseClick += RemoteItemsDownButton_OnMouseClick; }
protected override void Setup() { // Load all the textures used by rest interface LoadTextures(); // Hide world while resting ParentPanel.BackgroundColor = Color.black; // Create interface panel mainPanel.HorizontalAlignment = HorizontalAlignment.Center; mainPanel.BackgroundTexture = baseTexture; mainPanel.Position = new Vector2(0, 50); mainPanel.Size = new Vector2(baseTexture.width, baseTexture.height); NativePanel.Components.Add(mainPanel); // Create buttons whileButton = DaggerfallUI.AddButton(whileButtonRect, mainPanel); whileButton.OnMouseClick += WhileButton_OnMouseClick; healedButton = DaggerfallUI.AddButton(healedButtonRect, mainPanel); healedButton.OnMouseClick += HealedButton_OnMouseClick; loiterButton = DaggerfallUI.AddButton(loiterButtonRect, mainPanel); loiterButton.OnMouseClick += LoiterButton_OnMouseClick; // Setup counter panel counterPanel.Position = new Vector2(counterPanelRect.x, counterPanelRect.y); counterPanel.Size = new Vector2(counterPanelRect.width, counterPanelRect.height); counterPanel.HorizontalAlignment = HorizontalAlignment.Center; counterPanel.Enabled = false; NativePanel.Components.Add(counterPanel); // Setup counter text Panel counterTextPanel = DaggerfallUI.AddPanel(counterTextPanelRect, counterPanel); counterLabel.Position = new Vector2(0, 2); counterLabel.HorizontalAlignment = HorizontalAlignment.Center; counterTextPanel.Components.Add(counterLabel); // Stop button stopButton = DaggerfallUI.AddButton(stopButtonRect, counterPanel); stopButton.OnMouseClick += StopButton_OnMouseClick; }
void SetupButtons() { beginButton = DaggerfallUI.AddButton(beginButtonRect, NativePanel ); beginButton.OnMouseClick += BeginButtonOnClickHandler; exitButton = DaggerfallUI.AddButton(exitButtonRect, NativePanel); exitButton.OnMouseClick += ExitButtonOnClickHandler; speedToggleButton = DaggerfallUI.AddButton(speedButtonRect, NativePanel); speedToggleButton.OnMouseClick += SpeedButtonOnClickHandler; transportModeToggleButton = DaggerfallUI.AddButton(transportButtonRect, NativePanel); transportModeToggleButton.OnMouseClick += TransportModeButtonOnClickHandler; innToggleButton = DaggerfallUI.AddButton(innsButtonRect, NativePanel); innToggleButton.OnMouseClick += SleepModeButtonOnClickHandler; campOutToggleButton = DaggerfallUI.AddButton(campoutButtonRect, NativePanel); campOutToggleButton.OnMouseClick += SleepModeButtonOnClickHandler; }
protected override void Setup() { AllowCancel = false; LoadResources(); // Add exit button Button exitButton = new Button(); exitButton.Size = new Vector2(20, 9); exitButton.HorizontalAlignment = HorizontalAlignment.Center; exitButton.VerticalAlignment = VerticalAlignment.Bottom; exitButton.BackgroundColor = new Color(0.2f, 0.2f, 0.2f, 0.6f); exitButton.Outline.Enabled = true; exitButton.Label.Text = exitButtonText; exitButton.OnMouseClick += ExitButton_OnMouseClick; NativePanel.Components.Add(exitButton); // If actually validated and we just want to see settings then move direct to settings page if (DaggerfallUnity.Instance.IsPathValidated && DaggerfallUnity.Settings.ShowOptionsAtStart) { currentStage = SetupStages.Options - 1; } moveNextStage = true; }
void ShowOptionsPanel() { // Disable previous stage resolutionPanel.Enabled = false; // Create backdrop if (!backdropCreated) CreateBackdrop(); // Add options panel optionsPanel.Outline.Enabled = true; optionsPanel.BackgroundColor = backgroundColor; optionsPanel.HorizontalAlignment = HorizontalAlignment.Center; //optionsPanel.VerticalAlignment = VerticalAlignment.Middle; optionsPanel.Position = new Vector2(0, 8); optionsPanel.Size = new Vector2(318, 165); NativePanel.Components.Add(optionsPanel); // Add options title text TextLabel titleLabel = new TextLabel(); titleLabel.Text = "Options"; titleLabel.Position = new Vector2(0, 2); titleLabel.HorizontalAlignment = HorizontalAlignment.Center; optionsPanel.Components.Add(titleLabel); // Add settings path text TextLabel settingsPathLabel = new TextLabel(); settingsPathLabel.Text = DaggerfallUnity.Settings.PersistentDataPath; settingsPathLabel.Position = new Vector2(0, 170); settingsPathLabel.HorizontalAlignment = HorizontalAlignment.Center; settingsPathLabel.ShadowPosition = Vector2.zero; settingsPathLabel.TextColor = Color.gray; settingsPathLabel.BackgroundColor = backgroundColor; optionsPanel.Components.Add(settingsPathLabel); // Setup options checkboxes float x = 8; optionPos = 20; alwayShowOptions = AddOption(x, "Always show this window", "Always show this window on startup\rOtherwise use settings.ini to configure", DaggerfallUnity.Settings.ShowOptionsAtStart); vsync = AddOption(x, "Vertical Sync", "Sync FPS with monitor refresh", DaggerfallUnity.Settings.VSync); swapHealthAndFatigue = AddOption(x, "Swap Health & Fatigue", "Swap health & fatigue bar colors", DaggerfallUnity.Settings.SwapHealthAndFatigueColors); invertMouseVertical = AddOption(x, "Invert Mouse", "Invert mouse-look vertical", DaggerfallUnity.Settings.InvertMouseVertical); mouseSmoothing = AddOption(x, "Mouse Smoothing", "Smooth mouse-look sampling", DaggerfallUnity.Settings.MouseLookSmoothing); leftHandWeapons = AddOption(x, "Left Hand Weapons", "Draw weapons on left side of screen", GetLeftHandWeapons()); playerNudity = AddOption(x, "Player Nudity", "Allow nudity on paper doll", DaggerfallUnity.Settings.PlayerNudity); // Setup mods checkboxes x = 165; optionPos = 20; enhancedSky = AddOption(x, "Enhanced Sky (LypyL)", "Enhanced sky with lunar cycles", DaggerfallUnity.Settings.LypyL_EnhancedSky); distantTerrain = AddOption(x, "Distant Terrain (Nystul)", "Enhanced and distant terrain", DaggerfallUnity.Settings.Nystul_IncreasedTerrainDistance); realtimeReflections = AddOption(x, "Realtime Reflections (Nystul)", "Realtime reflections on water and select surfaces", DaggerfallUnity.Settings.Nystul_RealtimeReflections); tallGrass = AddOption(x, "Tall Grass (Uncanny_Valley)", "Animated tall grass", DaggerfallUnity.Settings.UncannyValley_RealGrass); flyingBirds = AddOption(x, "Flying Birds (Uncanny Valley)", "Animated flying birds", DaggerfallUnity.Settings.UncannyValley_BirdsInDaggerfall); // Add mod note string modNote = "Note: Enabling mods can increase performance requirements"; TextLabel modNoteLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(0, 115), modNote, optionsPanel); modNoteLabel.HorizontalAlignment = HorizontalAlignment.Center; modNoteLabel.ShadowPosition = Vector2.zero; // Confirm button Button optionsConfirmButton = new Button(); optionsConfirmButton.Position = new Vector2(0, optionsPanel.InteriorHeight - 15); optionsConfirmButton.Size = new Vector2(40, 12); optionsConfirmButton.Outline.Enabled = true; optionsConfirmButton.Label.Text = "Play"; optionsConfirmButton.BackgroundColor = new Color(0.0f, 0.5f, 0.0f, 0.4f); optionsConfirmButton.HorizontalAlignment = HorizontalAlignment.Center; optionsConfirmButton.OnMouseClick += OptionsConfirmButton_OnMouseClick; optionsPanel.Components.Add(optionsConfirmButton); // Restart button Button restartButton = new Button(); restartButton.Size = new Vector2(45, 12); restartButton.Label.Text = "< Restart"; restartButton.Label.ShadowPosition = Vector2.zero; restartButton.Label.TextColor = Color.gray; restartButton.ToolTip = defaultToolTip; restartButton.ToolTipText = "Restart setup from beginning"; restartButton.VerticalAlignment = VerticalAlignment.Top; restartButton.HorizontalAlignment = HorizontalAlignment.Left; restartButton.OnMouseClick += RestartButton_OnMouseClick; optionsPanel.Components.Add(restartButton); if (DaggerfallUnity.Settings.LypyL_ModSystem) { Button ShowModsButton = new Button(); ShowModsButton.Label.Text = "Mods"; ShowModsButton.Position = new Vector2(0, optionsConfirmButton.Position.y); ShowModsButton.HorizontalAlignment = HorizontalAlignment.Left; ShowModsButton.Size = optionsConfirmButton.Size; ShowModsButton.BackgroundColor = optionsConfirmButton.BackgroundColor; ShowModsButton.Label.TextColor = optionsConfirmButton.Label.TextColor; ShowModsButton.Outline.Enabled = true; optionsPanel.Components.Add(ShowModsButton); ShowModsButton.OnMouseClick += ModsButton_OnOnMouseBlick; } }
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); } }
/// <summary> /// initial window setup of the automap window /// </summary> protected override void Setup() { ImgFile imgFile = null; DFBitmap bitmap = null; if (isSetup) // don't setup twice! return; initGlobalResources(); // initialize gameobjectAutomap, daggerfallAutomap and layerAutomap // Load native texture imgFile = new ImgFile(Path.Combine(DaggerfallUnity.Instance.Arena2Path, nativeImgName), FileUsage.UseMemory, false); imgFile.LoadPalette(Path.Combine(DaggerfallUnity.Instance.Arena2Path, imgFile.PaletteName)); bitmap = imgFile.GetDFBitmap(); nativeTexture = new Texture2D(bitmap.Width, bitmap.Height, TextureFormat.ARGB32, false); nativeTexture.SetPixels32(imgFile.GetColor32(bitmap, 0)); nativeTexture.Apply(false, false); // make readable nativeTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; if (!nativeTexture) throw new Exception("DaggerfallAutomapWindow: Could not load native texture (AMAP00I0.IMG)."); // Load alternative Grid Icon (3D View Grid graphics) imgFile = new ImgFile(Path.Combine(DaggerfallUnity.Instance.Arena2Path, nativeImgNameGrid3D), FileUsage.UseMemory, false); imgFile.LoadPalette(Path.Combine(DaggerfallUnity.Instance.Arena2Path, imgFile.PaletteName)); bitmap = imgFile.GetDFBitmap(); Texture2D nativeTextureGrid3D = new Texture2D(bitmap.Width, bitmap.Height, TextureFormat.ARGB32, false); nativeTextureGrid3D.SetPixels32(imgFile.GetColor32(bitmap, 0)); nativeTextureGrid3D.Apply(false, false); // make readable nativeTextureGrid3D.filterMode = DaggerfallUI.Instance.GlobalFilterMode; if (!nativeTextureGrid3D) throw new Exception("DaggerfallAutomapWindow: Could not load native texture (AMAP01I0.IMG)."); pixelsGrid3D = nativeTextureGrid3D.GetPixels(0, 0, 27, 19); // Cut out 2D View Grid graphics from background image pixelsGrid2D = nativeTexture.GetPixels(78, nativeTexture.height - 171 - 19, 27, 19); // store background graphics from from background image backgroundOriginal = nativeTexture.GetPixels(0, 29, nativeTexture.width, nativeTexture.height - 29); backgroundAlternative1 = new Color[backgroundOriginal.Length]; for (int i = 0; i < backgroundOriginal.Length; ++i) { backgroundAlternative1[i].r = 0.0f; backgroundAlternative1[i].g = 0.0f; backgroundAlternative1[i].b = 0.0f; backgroundAlternative1[i].a = 1.0f; } backgroundAlternative2 = new Color[backgroundOriginal.Length]; for (int i = 0; i < backgroundOriginal.Length; ++i) { backgroundAlternative2[i].r = 0.2f; backgroundAlternative2[i].g = 0.1f; backgroundAlternative2[i].b = 0.3f; backgroundAlternative2[i].a = 1.0f; } backgroundAlternative3 = new Color[backgroundOriginal.Length]; for (int i = 0; i < backgroundOriginal.Length; ++i) { backgroundAlternative3[i].r = 0.3f; backgroundAlternative3[i].g = 0.1f; backgroundAlternative3[i].b = 0.2f; backgroundAlternative3[i].a = 1.0f; } // Always dim background ParentPanel.BackgroundColor = ScreenDimColor; // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; oldPositionNativePanel = NativePanel.Rectangle; // dummyPanelAutomap is used to get correct size for panelRenderAutomap Rect rectDummyPanelAutomap = new Rect(); rectDummyPanelAutomap.position = new Vector2(1, 1); rectDummyPanelAutomap.size = new Vector2(318, 169); dummyPanelAutomap = DaggerfallUI.AddPanel(rectDummyPanelAutomap, NativePanel); // Setup automap render panel (into this the level geometry is rendered) - use dummyPanelAutomap to get size Rect positionPanelRenderAutomap = dummyPanelAutomap.Rectangle; panelRenderAutomap = DaggerfallUI.AddPanel(positionPanelRenderAutomap, ParentPanel); panelRenderAutomap.AutoSize = AutoSizeModes.None; panelRenderAutomap.OnMouseScrollUp += PanelAutomap_OnMouseScrollUp; panelRenderAutomap.OnMouseScrollDown += PanelAutomap_OnMouseScrollDown; panelRenderAutomap.OnMouseDown += PanelAutomap_OnMouseDown; panelRenderAutomap.OnMouseUp += PanelAutomap_OnMouseUp; panelRenderAutomap.OnRightMouseDown += PanelAutomap_OnRightMouseDown; panelRenderAutomap.OnRightMouseUp += PanelAutomap_OnRightMouseUp; // Grid button (toggle 2D <-> 3D view) gridButton = DaggerfallUI.AddButton(new Rect(78, 171, 27, 19), NativePanel); gridButton.OnMouseClick += GridButton_OnMouseClick; gridButton.OnRightMouseClick += GridButton_OnRightMouseClick; gridButton.OnMouseScrollUp += GridButton_OnMouseScrollUp; gridButton.OnMouseScrollDown += GridButton_OnMouseScrollDown; gridButton.ToolTip = defaultToolTip; gridButton.ToolTipText = "left click: switch between 2D top view and 3D view (hotkey: space key)\rright click: reset rotation center to player position (hotkey: control+backspace)\rmouse wheel up while over this button: increase perspective (only 3D mode)\rmouse wheel down while over this button: decrease perspective (only 3D mode)"; gridButton.ToolTip.ToolTipDelay = toolTipDelay; // forward button forwardButton = DaggerfallUI.AddButton(new Rect(105, 171, 21, 19), NativePanel); forwardButton.OnMouseDown += ForwardButton_OnMouseDown; forwardButton.OnMouseUp += ForwardButton_OnMouseUp; forwardButton.OnRightMouseDown += ForwardButton_OnRightMouseDown; forwardButton.OnRightMouseUp += ForwardButton_OnRightMouseUp; forwardButton.ToolTip = defaultToolTip; forwardButton.ToolTipText = "left click: move viewpoint forward (hotkey: up arrow)\rright click: move rotation center axis forward (hotkey: control+up arrow)"; forwardButton.ToolTip.ToolTipDelay = toolTipDelay; // backward button backwardButton = DaggerfallUI.AddButton(new Rect(126, 171, 21, 19), NativePanel); backwardButton.OnMouseDown += BackwardButton_OnMouseDown; backwardButton.OnMouseUp += BackwardButton_OnMouseUp; backwardButton.OnRightMouseDown += BackwardButton_OnRightMouseDown; backwardButton.OnRightMouseUp += BackwardButton_OnRightMouseUp; backwardButton.ToolTip = defaultToolTip; backwardButton.ToolTipText = "left click: move viewpoint backwards (hotkey: down arrow)\rright click: move rotation center axis backwards (hotkey: control+down arrow)"; backwardButton.ToolTip.ToolTipDelay = toolTipDelay; // left button leftButton = DaggerfallUI.AddButton(new Rect(149, 171, 21, 19), NativePanel); leftButton.OnMouseDown += LeftButton_OnMouseDown; leftButton.OnMouseUp += LeftButton_OnMouseUp; leftButton.OnRightMouseDown += LeftButton_OnRightMouseDown; leftButton.OnRightMouseUp += LeftButton_OnRightMouseUp; leftButton.ToolTip = defaultToolTip; leftButton.ToolTipText = "left click: move viewpoint to the left (hotkey: left arrow)\rright click: move rotation center axis to the left (hotkey: control+left arrow)"; leftButton.ToolTip.ToolTipDelay = toolTipDelay; // right button rightButton = DaggerfallUI.AddButton(new Rect(170, 171, 21, 19), NativePanel); rightButton.OnMouseDown += RightButton_OnMouseDown; rightButton.OnMouseUp += RightButton_OnMouseUp; rightButton.OnRightMouseDown += RightButton_OnRightMouseDown; rightButton.OnRightMouseUp += RightButton_OnRightMouseUp; rightButton.ToolTip = defaultToolTip; rightButton.ToolTipText = "left click: move viewpoint to the right (hotkey: right arrow)\rright click: move rotation center axis to the right (hotkey: control+right arrow)"; rightButton.ToolTip.ToolTipDelay = toolTipDelay; // rotate left button rotateLeftButton = DaggerfallUI.AddButton(new Rect(193, 171, 21, 19), NativePanel); rotateLeftButton.OnMouseDown += RotateLeftButton_OnMouseDown; rotateLeftButton.OnMouseUp += RotateLeftButton_OnMouseUp; rotateLeftButton.OnRightMouseDown += RotateLeftButton_OnRightMouseDown; rotateLeftButton.OnRightMouseUp += RotateLeftButton_OnRightMouseUp; rotateLeftButton.ToolTip = defaultToolTip; rotateLeftButton.ToolTipText = "left click: rotate dungeon model to the left (hotkey: alt+right arrow)\rright click: rotate camera view to the left (hotkey: shift+right arrow)"; rotateLeftButton.ToolTip.ToolTipDelay = toolTipDelay; // rotate right button rotateRightButton = DaggerfallUI.AddButton(new Rect(214, 171, 21, 19), NativePanel); rotateRightButton.OnMouseDown += RotateRightButton_OnMouseDown; rotateRightButton.OnMouseUp += RotateRightButton_OnMouseUp; rotateRightButton.OnRightMouseDown += RotateRightButton_OnRightMouseDown; rotateRightButton.OnRightMouseUp += RotateRightButton_OnRightMouseUp; rotateRightButton.ToolTip = defaultToolTip; rotateRightButton.ToolTipText = "left click: rotate dungeon model to the right (hotkey: alt+right arrow)\rright click: rotate camera view to the right (hotkey: shift+right arrow)"; rotateRightButton.ToolTip.ToolTipDelay = toolTipDelay; // upstairs button upstairsButton = DaggerfallUI.AddButton(new Rect(237, 171, 21, 19), NativePanel); upstairsButton.OnMouseDown += UpstairsButton_OnMouseDown; upstairsButton.OnMouseUp += UpstairsButton_OnMouseUp; upstairsButton.OnRightMouseDown += UpstairsButton_OnRightMouseDown; upstairsButton.OnRightMouseUp += UpstairsButton_OnRightMouseUp; upstairsButton.ToolTip = defaultToolTip; upstairsButton.ToolTipText = "left click: increase viewpoint (hotkey: page up)\rright click: increase slice level (hotkey: control+page up)\r\rhint: different render modes may show hidden geometry:\rhotkey F2: cutout mode\rhotkey F3: wireframe mode\rhotkey F4: transparent mode\rswitch between modes with return key"; upstairsButton.ToolTip.ToolTipDelay = toolTipDelay; // downstairs button downstairsButton = DaggerfallUI.AddButton(new Rect(258, 171, 21, 19), NativePanel); downstairsButton.OnMouseDown += DownstairsButton_OnMouseDown; downstairsButton.OnMouseUp += DownstairsButton_OnMouseUp; downstairsButton.OnRightMouseDown += DownstairsButton_OnRightMouseDown; downstairsButton.OnRightMouseUp += DownstairsButton_OnRightMouseUp; downstairsButton.ToolTip = defaultToolTip; downstairsButton.ToolTipText = "left click: decrease viewpoint (hotkey: page down)\rright click: decrease slice level (hotkey: control+page down)\r\rhint: different render modes may show hidden geometry:\rhotkey F2: cutout mode\rhotkey F3: wireframe mode\rhotkey F4: transparent mode\rswitch between modes with return key"; downstairsButton.ToolTip.ToolTipDelay = toolTipDelay; // Exit button Button exitButton = DaggerfallUI.AddButton(new Rect(281, 171, 28, 19), NativePanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; // dummyPanelCompass is used to get correct size for compass Rect rectDummyPanelCompass = new Rect(); rectDummyPanelCompass.position = new Vector2(3, 172); rectDummyPanelCompass.size = new Vector2(76, 17); dummyPanelCompass = DaggerfallUI.AddPanel(rectDummyPanelCompass, NativePanel); dummyPanelCompass.OnMouseClick += Compass_OnMouseClick; dummyPanelCompass.OnRightMouseClick += Compass_OnRightMouseClick; dummyPanelCompass.ToolTip = defaultToolTip; dummyPanelCompass.ToolTipText = "left click: toggle focus (hotkey: tab)\rred beacon: player, green beacon: entrance, blue beacon: rotation center\r\rright click: reset view (hotkey: backspace)"; dummyPanelCompass.ToolTip.ToolTipDelay = toolTipDelay; // compass compass = new HUDCompass(); Vector2 scale = NativePanel.LocalScale; compass.Position = dummyPanelCompass.Rectangle.position; compass.Scale = scale; NativePanel.Components.Add(compass); isSetup = true; }
// Initial button setup void SetupButtons() { // Exit button exitButton = DaggerfallUI.AddButton(new Rect(278, 175, 39, 22), NativePanel); exitButton.OnMouseClick += ExitButtonClickHandler; // Find button Texture2D findButtonTexture = DaggerfallUI.GetTextureFromImg(findAtButtonImgName, new Rect(0, 0, 45, 11)); findButton = DaggerfallUI.AddButton(new Rect(3, 175, findButtonTexture.width, findButtonTexture.height), NativePanel); findButton.BackgroundTexture = findButtonTexture; findButton.Enabled = false; findButton.OnMouseClick += FindlocationButtonClickHandler; // I'm At button Texture2D atButtonTexture = DaggerfallUI.GetTextureFromImg(findAtButtonImgName, new Rect(0, 11, 45, 11)); atButton = DaggerfallUI.AddButton(new Rect(3, 186, findButtonTexture.width, findButtonTexture.height), NativePanel); atButton.BackgroundTexture = atButtonTexture; atButton.OnMouseClick += AtButtonClickHandler; // Dungeons filter button dungeonsFilterButton.Position = new Vector2(50, 175); dungeonsFilterButton.Size = new Vector2(dungeonsFilterButtonSrcRect.width, dungeonsFilterButtonSrcRect.height); NativePanel.Components.Add(dungeonsFilterButton); // Temples filter button templesFilterButton.Position = new Vector2(50, 186); templesFilterButton.Size = new Vector2(templesFilterButtonSrcRect.width, templesFilterButtonSrcRect.height); NativePanel.Components.Add(templesFilterButton); // Homes filter button homesFilterButton.Position = new Vector2(149, 175); homesFilterButton.Size = new Vector2(homesFilterButtonSrcRect.width, homesFilterButtonSrcRect.height); NativePanel.Components.Add(homesFilterButton); // Towns filter button townsFilterButton.Position = new Vector2(149, 186); townsFilterButton.Size = new Vector2(townsFilterButtonSrcRect.width, townsFilterButtonSrcRect.height); NativePanel.Components.Add(townsFilterButton); // Horizontal arrow button horizontalArrowButton.Position = new Vector2(231, 176); horizontalArrowButton.Size = new Vector2(leftArrowTexture.width, leftArrowTexture.height); horizontalArrowButton.Enabled = false; NativePanel.Components.Add(horizontalArrowButton); horizontalArrowButton.OnMouseClick += HorizontalArrowButtonClickHander; // Vertical arrow button verticalArrowButton.Position = new Vector2(254, 176); verticalArrowButton.Size = new Vector2(upArrowTexture.width, upArrowTexture.height); verticalArrowButton.Enabled = false; NativePanel.Components.Add(verticalArrowButton); verticalArrowButton.OnMouseClick += VerticalArrowButtonClickHander; }
void SetupControl() { dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) return; // Load highlight texture ImgFile imgFile = new ImgFile(Path.Combine(dfUnity.Arena2Path, highlightImgName), FileUsage.UseMemory, true); imgFile.LoadPalette(Path.Combine(dfUnity.Arena2Path, imgFile.PaletteName)); highlightTexture = TextureReader.CreateFromAPIImage(imgFile, 0, 0, 0); highlightTexture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; // Add buttons Vector2 buttonPos = new Vector2(0, 0); Vector2 buttonSize = new Vector2(66, 9); for (int i = 0; i < 5; i++) { selectButtons[i] = new Button(); this.Components.Add(selectButtons[i]); selectButtons[i].Position = buttonPos; selectButtons[i].Size = buttonSize; selectButtons[i].Tag = i; selectButtons[i].OnMouseClick += ReflexButton_OnMouseClick; buttonPos.y += buttonSize.y; } // Set size of this panel Size = new Vector2(66, 45); // Set starting value PlayerReflexes = PlayerReflexes.Average; }
public static Button AddButton(Vector2 position, Vector2 size, Panel panel = null) { Button button = new Button(); button.Position = position; button.Size = size; if (panel != null) panel.Components.Add(button); return button; }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) throw new Exception("CreateCharNameSelect: Could not load native texture."); // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Text edit box textBox.Position = new Vector2(100, 5); textBox.Size = new Vector2(214, 7); NativePanel.Components.Add(textBox); // OK button okButton = DaggerfallUI.AddButton(new Rect(263, 172, 39, 22), NativePanel); okButton.OnMouseClick += OkButton_OnMouseClick; }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) throw new Exception("CreateCharFaceSelect: Could not load native texture."); // Setup native panel background NativePanel.BackgroundTexture = nativeTexture; // Add face picker NativePanel.Components.Add(facePicker); // OK button okButton = DaggerfallUI.AddButton(new Rect(263, 172, 39, 22), NativePanel); okButton.OnMouseClick += OkButton_OnMouseClick; }