void LoadTextures() { if (TextureReplacement.TryImportImage(baseTextureName, true, out baseTexture)) { baseSize = new Vector2(baseTexture.width, baseTexture.height); } }
protected override void Setup() { base.Setup(); // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("CreateCharChooseBio: Could not load native texture."); } // Create panel for window bioChoosePanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); bioChoosePanel.HorizontalAlignment = HorizontalAlignment.Center; bioChoosePanel.VerticalAlignment = VerticalAlignment.Middle; bioChoosePanel.BackgroundTexture = nativeTexture; bioChoosePanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; NativePanel.Components.Add(bioChoosePanel); // Create buttons chooseGenerate = DaggerfallUI.AddButton(chooseGenerateRect, bioChoosePanel); chooseGenerate.OnMouseClick += ChooseGenerate_OnMouseClick; chooseQuestions = DaggerfallUI.AddButton(chooseQuestionsRect, bioChoosePanel); chooseQuestions.OnMouseClick += ChooseQuestions_OnMouseClick; }
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 = GetText("exit"); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.GameSetupExit); 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 || Input.anyKey)) { currentStage = SetupStages.Options - 1; } moveNextStage = true; // Override cursor Texture2D tex; if (TextureReplacement.TryImportTexture("Cursor", true, out tex)) { Cursor.SetCursor(tex, Vector2.zero, CursorMode.Auto); Debug.Log("Cursor texture overridden by mods."); } }
/// <summary> /// Creates a simple texture from any base API image. /// </summary> public static Texture2D CreateFromAPIImage(BaseImageFile image, int record = 0, int frame = 0, int alphaIndex = -1, bool createMipMaps = false, bool makeNoLongerReadable = true) { // Override readable flag when user has set preference in material reader if (DaggerfallUnity.Instance.MaterialReader.ReadableTextures) { makeNoLongerReadable = false; } Texture2D texture; if (TextureReplacement.TryImportImage(image.FileName, out texture)) { return(texture); } if (TextureReplacement.TryImportCifRci(image.FileName, record, frame, out texture)) { return(texture); } DFSize sz; Color32[] colors = image.GetColor32(record, frame, alphaIndex, 0, out sz); texture = new Texture2D(sz.Width, sz.Height, TextureFormat.ARGB32, createMipMaps); texture.SetPixels32(colors); texture.Apply(createMipMaps, makeNoLongerReadable); return(texture); }
private void SetCursor(bool refresh = false) { int cursorWidth = 32; int cursorHeight = 32; if (TextureReplacement.TryImportTexture("Cursor", true, out Texture2D tex)) { CursorMode cursorMode = CursorMode.Auto; cursorWidth = tex.width; cursorHeight = tex.height; // Cases when true cursor size cannot be achieved using hardware accelerated cursor if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows && (cursorWidth > 32 || cursorHeight > 32)) { cursorMode = CursorMode.ForceSoftware; } Cursor.SetCursor(tex, Vector2.zero, cursorMode); Debug.Log("Cursor texture overridden by mods."); } else { Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto); } DaggerfallUnity.Settings.CursorWidth = cursorWidth; DaggerfallUnity.Settings.CursorHeight = cursorHeight; if (!refresh) { StateManager.OnStateChange += StateManager_OnStateChange; } }
private void CacheRecordSizesAndFrames(int textureArchive) { // Open texture file string path = Path.Combine(DaggerfallUnity.Instance.Arena2Path, TextureFile.IndexToFileName(textureArchive)); TextureFile textureFile = new TextureFile(path, FileUsage.UseMemory, true); // Cache size and scale for each record recordSizes = new Vector2[textureFile.RecordCount]; recordFrames = new int[textureFile.RecordCount]; for (int i = 0; i < textureFile.RecordCount; i++) { // Get size and scale of this texture DFSize size = textureFile.GetSize(i); DFSize scale = textureFile.GetScale(i); // Set start size Vector2 startSize; startSize.x = size.Width; startSize.y = size.Height; // Apply scale Vector2 finalSize; int xChange = (int)(size.Width * (scale.Width / BlocksFile.ScaleDivisor)); int yChange = (int)(size.Height * (scale.Height / BlocksFile.ScaleDivisor)); finalSize.x = (size.Width + xChange); finalSize.y = (size.Height + yChange); // Set optional scale TextureReplacement.SetBillboardScale(textureArchive, i, ref finalSize); // Store final size and frame count recordSizes[i] = finalSize * MeshReader.GlobalScale; recordFrames[i] = textureFile.GetFrameCount(i); } }
// Initialise. void Start() { playerMotor = GetComponent <PlayerMotor>(); if (!playerMotor) { throw new Exception("PlayerMotor not found."); } transportManager = GetComponent <TransportManager>(); if (!transportManager) { throw new Exception("TransportManager not found."); } transportManager.DrawHorse = false; playerMouseLook = GameManager.Instance.PlayerMouseLook; if (!playerMouseLook) { throw new Exception("PlayerMouseLook not found."); } GameManager.Instance.SpeedChanger.CanRun = CanRunUnlessRidingCart; // Setup appropriate neck textures if availiable. for (int i = 0; i < 4; i++) { TextureReplacement.TryImportCifRci(horseNeckTextureName, 0, i, false, out horseNeckTextures[i].texture); } for (int i = 0; i < 4; i++) { TextureReplacement.TryImportCifRci(cartNeckTextureName, 0, i, false, out cartNeckTextures[i].texture); } }
public static Texture2D GetTextureFromCifRci(string name, int record, out DFPosition offset, int frame = 0, TextureFormat format = TextureFormat.ARGB32) { offset = new DFPosition(); DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return(null); } CifRciFile cifRciFile = new CifRciFile(Path.Combine(dfUnity.Arena2Path, name), FileUsage.UseMemory, true); Texture2D texture = null; // Custom texture if (TextureReplacement.CustomCifExist(name, record, frame)) { texture = TextureReplacement.LoadCustomCif(name, record, frame); } // Daggerfall texture else { cifRciFile.LoadPalette(Path.Combine(dfUnity.Arena2Path, cifRciFile.PaletteName)); DFBitmap bitmap = cifRciFile.GetDFBitmap(record, frame); texture = new Texture2D(bitmap.Width, bitmap.Height, format, false); texture.SetPixels32(cifRciFile.GetColor32(bitmap, 0)); texture.Apply(false, true); } texture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; offset = cifRciFile.GetOffset(record); return(texture); }
void SetBackground(Button button, Color color, string textureName) { if (!TextureReplacement.TryCustomizeButton(ref button, textureName)) { button.BackgroundColor = color; } }
void LoadAssets() { compassTexture = DaggerfallUI.GetTextureFromImg(compassFilename); compassSize = TextureReplacement.GetSize(compassTexture, compassFilename, true); compassBoxTexture = DaggerfallUI.GetTextureFromImg(compassBoxFilename); compassBoxSize = TextureReplacement.GetSize(compassBoxTexture, compassBoxFilename, true); }
/// <summary> /// Sets new enemy type. /// </summary> /// <param name="dfUnity">DaggerfallUnity singleton. Required for content readers and settings.</param> /// <param name="enemyType">Enemy type.</param> public void SetEnemy(DaggerfallUnity dfUnity, MobileEnemy enemy, MobileReactions reaction) { // Initial enemy settings summary.Enemy = enemy; summary.EnemyState = MobileStates.Move; summary.Enemy.Reactions = reaction; // Load enemy content int archive = GetTextureArchive(); if (TextureReplacement.CustomTextureExist(archive, TextureReplacement.enemyDefaultRecord, TextureReplacement.enemyDefaultFrame)) { summary.CustomMaterial.isCustom = true; } else { summary.CustomMaterial.isCustom = false; } CacheRecordSizesAndFrames(dfUnity, archive); AssignMeshAndMaterial(dfUnity, archive); // Apply enemy state and update orientation lastOrientation = -1; ApplyEnemyState(); // Raise setup flag summary.IsSetup = true; }
void LoadTextures() { if (!TextureReplacement.TryImportImage(baseTextureName, true, out baseTexture)) { Debug.LogError("TravelOptions: Unable to load the base UI image."); } }
protected void SetupPathButtons() { // Paths buttons if (!TextureReplacement.TryImportImage(roadsOffName, true, out roadsOffTexture)) { return; } if (!TextureReplacement.TryImportImage(roadsOnName, true, out roadsOnTexture)) { return; } if (!TextureReplacement.TryImportImage(tracksOffName, true, out tracksOffTexture)) { return; } if (!TextureReplacement.TryImportImage(tracksOnName, true, out tracksOnTexture)) { return; } roadsButton = new Button(); roadsButton.Tag = path_roads; roadsButton.Position = roadsButtonPos; roadsButton.Size = new Vector2(roadsOnTexture.width, roadsOnTexture.height); roadsButton.OnMouseClick += PathTypeButton_OnMouseClick; NativePanel.Components.Add(roadsButton); tracksButton = new Button(); tracksButton.Tag = path_tracks; tracksButton.Position = tracksButtonPos; tracksButton.Size = new Vector2(tracksOnTexture.width, tracksOnTexture.height); tracksButton.OnMouseClick += PathTypeButton_OnMouseClick; NativePanel.Components.Add(tracksButton); }
protected override void Setup() { base.Setup(); if (TravelOptionsMod.Instance.ShipTravelPortsOnly) { // Towns filter button if (!TextureReplacement.TryImportImage(portsOffName, true, out portsOffTexture)) { return; } if (!TextureReplacement.TryImportImage(portsOnName, true, out portsOnTexture)) { return; } portsFilterButton = new Button(); portsFilterButton.Position = portFilterPos; portsFilterButton.Size = new Vector2(portsOffTexture.width, portsOffTexture.height); portsFilterButton.BackgroundTexture = portsOffTexture; portsFilterButton.OnMouseClick += PortsFilterButton_OnMouseClick; NativePanel.Components.Add(portsFilterButton); } if (TravelOptionsMod.Instance.RoadsIntegration) { SetupPathButtons(); UpdatePathButtons(); locationDotsPixelBuffer = new Color32[(int)regionTextureOverlayPanelRect.width * (int)regionTextureOverlayPanelRect.height * 25]; locationDotsTexture = new Texture2D((int)regionTextureOverlayPanelRect.width * 5, (int)regionTextureOverlayPanelRect.height * 5, TextureFormat.ARGB32, false); } }
public static Texture2D GetTextureFromImg(string name, out DFPosition offset, TextureFormat format = TextureFormat.ARGB32) { offset = new DFPosition(); DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return(null); } ImgFile imgFile = new ImgFile(Path.Combine(dfUnity.Arena2Path, name), FileUsage.UseMemory, true); Texture2D texture = null; // Custom texture if (TextureReplacement.CustomImageExist(name)) { texture = TextureReplacement.LoadCustomImage(name); } // Daggerfall texture else { imgFile.LoadPalette(Path.Combine(dfUnity.Arena2Path, imgFile.PaletteName)); texture = GetTextureFromImg(imgFile, format); } texture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; offset = imgFile.ImageOffset; return(texture); }
public static Texture2D GetTextureFromImg(string name, out DFPosition offset, TextureFormat format = TextureFormat.ARGB32, bool readOnly = true) { offset = new DFPosition(); DaggerfallUnity dfUnity = DaggerfallUnity.Instance; if (!dfUnity.IsReady) { return(null); } ImgFile imgFile = new ImgFile(Path.Combine(dfUnity.Arena2Path, name), FileUsage.UseMemory, readOnly); Texture2D texture; if (!TextureReplacement.TryImportImage(name, out texture)) { imgFile.LoadPalette(Path.Combine(dfUnity.Arena2Path, imgFile.PaletteName)); texture = GetTextureFromImg(imgFile, format, readOnly); } texture.filterMode = DaggerfallUI.Instance.GlobalFilterMode; offset = imgFile.ImageOffset; return(texture); }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("DaggerfallCourtWindow: Could not load native texture."); } // Native court panel courtPanel.HorizontalAlignment = HorizontalAlignment.Center; courtPanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); courtPanel.BackgroundTexture = nativeTexture; NativePanel.Components.Add(courtPanel); // Cancel any camera recoil RaiseOnCourtScreenEvent(); // Add days until freedom label daysUntilFreedomLabel = DaggerfallUI.AddTextLabel(DaggerfallUI.DefaultFont, new Vector2(156, 165), string.Empty, NativePanel); daysUntilFreedomLabel.TextColor = DaggerfallUI.DaggerfallPrisonDaysUntilFreedomColor; daysUntilFreedomLabel.ShadowColor = DaggerfallUI.DaggerfallPrisonDaysUntilFreedomShadowColor; daysUntilFreedomLabel.HorizontalAlignment = HorizontalAlignment.Center; playerEntity = GameManager.Instance.PlayerEntity; AllowCancel = false; }
private static void AssertAppletSizeValid(TextureReplacement repl, ImageSize size) { if (size.Width != repl.W || size.Height != repl.H) { throw new Exception($"The applet image size for {repl.NxThemeName} must be {repl.W}x{repl.H}"); } }
/// <summary> /// Gets terrain albedo texture array containing each terrain tile in a seperate array slice. /// </summary> /// <param name="archive">Archive index.</param> /// <param name="stayReadable">Texture should stay readable.</param> /// <param name="nonAlphaFormat">Non-alpha TextureFormat.</param> /// <returns>Texture2DArray or null</returns> public Texture2DArray GetTerrainAlbedoTextureArray( int archive, bool stayReadable = false, SupportedNonAlphaTextureFormats nonAlphaFormat = SupportedNonAlphaTextureFormats.RGB24) { // Load texture file and check count matches terrain tiles TextureFile textureFile = new TextureFile(Path.Combine(Arena2Path, TextureFile.IndexToFileName(archive)), FileUsage.UseMemory, true); int numSlices = 0; if (textureFile.RecordCount == 56) { numSlices = textureFile.RecordCount; } else { return(null); } Texture2DArray textureArray; if (TextureReplacement.CustomTextureExist(archive, 0, 0)) { Texture2D albedoMap = TextureReplacement.LoadCustomTexture(archive, 0, 0); textureArray = new Texture2DArray(albedoMap.width, albedoMap.height, numSlices, ParseTextureFormat(nonAlphaFormat), MipMaps); } else { textureArray = new Texture2DArray(textureFile.GetWidth(0), textureFile.GetWidth(1), numSlices, ParseTextureFormat(nonAlphaFormat), MipMaps); } // Rollout tiles into texture array for (int record = 0; record < textureFile.RecordCount; record++) { Color32[] albedo; if (TextureReplacement.CustomTextureExist(archive, record, 0)) { // Import custom texture Texture2D albedoMap = TextureReplacement.LoadCustomTexture(archive, record, 0); albedo = albedoMap.GetPixels32(); } else { // Create base image with gutter DFSize sz; albedo = textureFile.GetColor32(record, 0, -1, 0, out sz); } // Insert into texture array textureArray.SetPixels32(albedo, record, 0); } textureArray.Apply(true, !stayReadable); // Change settings for these textures textureArray.wrapMode = TextureWrapMode.Clamp; textureArray.anisoLevel = 8; return(textureArray); }
public void UpdateTextures() { Texture2D pictureTexture; if (Frame >= (new TextureFile(Path.Combine(arena2Path, string.Format("TEXTURE.{0:000}", Archive)), FileUsage.Undefined, true)).GetFrameCount(Record + AttackModeOffset)) { Frame = 0; } if (!TextureReplacement.TryImportTexture(Archive, Record + AttackModeOffset, Frame, out pictureTexture)) { pictureTexture = textureReader.GetTexture2D(Archive, Record + AttackModeOffset, Frame); } pictureTexture.filterMode = FilterMode.Point; UpdateImagePanel(pictureTexture, this); ApplyTexture(pictureTexture, this); void UpdateImagePanel(Texture2D inputTexture, TextureInfo inputTextureInfo) { imagePanel.Size = inputTextureInfo.maxTextureSize; imagePanel.Position = new Vector2(imagePanelBasePos[0] + ((imagePanelMaxSize[0] - imagePanel.Size[0]) / 2), imagePanelBasePos[1] + ((imagePanelMaxSize[0] - imagePanel.Size[1]) / 2)); } void ApplyTexture(Texture2D texture, TextureInfo inputTextureInfo) { bool doFlip; if (BestiaryMain.SettingEnableAllDirectionRotation) { if (inputTextureInfo.Flip && inputTextureInfo.Record != 0) { doFlip = true; } else { doFlip = false; } if (inputTextureInfo.Mirrored) { doFlip = !doFlip; } } else { doFlip = false; } if (doFlip) { imagePanel.BackgroundTexture = FlipTexture(DuplicateTexture(texture)); } else { imagePanel.BackgroundTexture = texture; } } }
public override void Update() { if (Enabled) { base.Update(); Size = TextureReplacement.GetSizeFromXml(compassBoxTexture, compassBoxFilename, Scale.x, Scale.y); } }
void SetBackground(Button button, Color color, string textureName) { #pragma warning disable 0618 if (!TextureReplacement.TryCustomizeButton(ref button, textureName)) { button.BackgroundColor = color; } #pragma warning restore 0618 }
public static IImageInfo AssertValidForApplet(TextureReplacement target, byte[] data) { var img = Util.ParseImage(data); img.AssertValidForApplet(); img.AssertAppletSizeValid(target); return(img); }
protected override void Setup() { // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); if (!nativeTexture) { throw new Exception("DaggerfallOptionsWindow: Could not load native texture."); } // Always dim background ParentPanel.BackgroundColor = ScreenDimColor; // Native options panel optionsPanel.HorizontalAlignment = HorizontalAlignment.Center; optionsPanel.Position = new Vector2(0, 40); optionsPanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); optionsPanel.BackgroundTexture = nativeTexture; NativePanel.Components.Add(optionsPanel); // Exit game Button exitButton = DaggerfallUI.AddButton(new Rect(101, 4, 45, 16), optionsPanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; // Continue Button continueButton = DaggerfallUI.AddButton(new Rect(76, 60, 70, 17), optionsPanel); continueButton.OnMouseClick += ContinueButton_OnMouseClick; // Save game Button saveButton = DaggerfallUI.AddButton(new Rect(4, 4, 45, 16), optionsPanel); //saveButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; saveButton.OnMouseClick += SaveButton_OnMouseClick; // Load game Button loadButton = DaggerfallUI.AddButton(new Rect(52, 4, 46, 16), optionsPanel); //loadButton.BackgroundColor = DaggerfallUI.DaggerfallUnityNotImplementedColor; loadButton.OnMouseClick += LoadButton_OnMouseClick; // Controls Button controlsButton = DaggerfallUI.AddButton(new Rect(5, 60, 70, 17), optionsPanel); controlsButton.OnMouseClick += ControlsButton_OnMouseClick; // Full screen Button fullScreenButton = DaggerfallUI.AddButton(new Rect(5, 47, 70, 8), optionsPanel); fullScreenButton.BackgroundColor = new Color(1, 0, 0, 0.5f); // Head bobbing Button headBobbingButton = DaggerfallUI.AddButton(new Rect(76, 47, 70, 8), optionsPanel); headBobbingButton.BackgroundColor = new Color(1, 0, 0, 0.5f); }
protected override void Setup() { if (IsSetup) { return; } base.Setup(); // Load native texture nativeTexture = DaggerfallUI.GetTextureFromImg(nativeImgName); nativeOverlayTexture = DaggerfallUI.GetTextureFromImg(nativeImgOverlayName); if (!nativeTexture || !nativeOverlayTexture) { throw new Exception("CreateCharSpecialAdvantage: Could not load native texture."); } // Create panel for window advantagePanel.Size = TextureReplacement.GetSize(nativeTexture, nativeImgName); advantagePanel.HorizontalAlignment = HorizontalAlignment.Left; advantagePanel.VerticalAlignment = VerticalAlignment.Top; advantagePanel.BackgroundTexture = nativeTexture; advantagePanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; NativePanel.Components.Add(advantagePanel); // Setup UI components font = DaggerfallUI.SmallFont; Panel buttonPanel = NativePanel; if (!isDisadvantages) // Adding this overlay makes it appear as Special Advantages instead of Disadvantages { overlayPanel.Size = TextureReplacement.GetSize(nativeOverlayTexture, nativeImgOverlayName); overlayPanel.HorizontalAlignment = HorizontalAlignment.Left; overlayPanel.VerticalAlignment = VerticalAlignment.Top; overlayPanel.BackgroundTexture = nativeOverlayTexture; overlayPanel.BackgroundTextureLayout = BackgroundLayout.StretchToFill; advantagePanel.Components.Add(overlayPanel); buttonPanel = overlayPanel; } addAdvantageButton = DaggerfallUI.AddButton(addAdvantageButtonRect, buttonPanel); addAdvantageButton.OnMouseClick += AddAdvantageButton_OnMouseClick; addAdvantageButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); exitButton = DaggerfallUI.AddButton(exitButtonRect, NativePanel); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.ClickSound = DaggerfallUI.Instance.GetAudioClip(SoundClips.ButtonClick); for (int i = 0; i < maxLabels; i++) { advantageLabels[i] = DaggerfallUI.AddTextLabel(font, new Vector2(8, 35 + i * labelSpacing), string.Empty, NativePanel); advantageLabels[i].OnMouseClick += AdvantageLabel_OnMouseClick; advantageLabels[i].Tag = -1; } UpdateLabels(); InitializeAdjustmentDict(); IsSetup = true; }
protected override void LoadTextures() { Texture2D tex; //TextureReplacement.TryImportTextureFromLooseFiles(Path.Combine(TexturesFolder, baseTextureName), false, false, true, out tex); TextureReplacement.TryImportTexture(baseTextureName, true, out tex); //Debug.Log("Texture is:" + tex.ToString()); baseTexture = tex; }
void LoadAssets() { compassTexture = DaggerfallUI.GetTextureFromImg(compassFilename); compassSize = TextureReplacement.GetSize(compassTexture, compassFilename, true); compassBoxTexture = DaggerfallUI.GetTextureFromImg(compassBoxFilename); compassBoxSize = TextureReplacement.GetSize(compassBoxTexture, compassBoxFilename, true); defaultTrackingIcon = Resources.Load <Texture2D>(trackingIconFilename); defaultTrackingIcon.filterMode = (FilterMode)DaggerfallUnity.Settings.GUIFilterMode; }
private bool TryImportTextureFromLooseFiles(string name, out Texture2D tex) { if (textureOverride) { return(TextureReplacement.TryImportTextureFromLooseFiles(Path.Combine(RealGrass.TexturesFolder, name), true, false, false, out tex)); } tex = null; return(false); }
/// <summary> /// Get a texture from resources with modding support. /// Size is read from xml or set as texture size. /// </summary> public static Texture2D GetTextureFromResources(string name, out Vector2 size) { Texture2D tex = GetTextureFromResources(name); if (!TextureReplacement.TryGetSize(name, out size)) { size = new Vector2(tex.width, tex.height); } return(tex); }
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 = GetText("exit"); exitButton.OnMouseClick += ExitButton_OnMouseClick; exitButton.Hotkey = DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.GameSetupExit); 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 || Input.anyKey)) { currentStage = SetupStages.Options - 1; } moveNextStage = true; int cursorWidth = 32; int cursorHeight = 32; // Apply joystick settings to input manager to keep consistency between the setup wizard and the game InputManager.Instance.JoystickCursorSensitivity = DaggerfallUnity.Settings.JoystickCursorSensitivity; InputManager.Instance.JoystickDeadzone = DaggerfallUnity.Settings.JoystickDeadzone; // Override cursor Texture2D tex; if (TextureReplacement.TryImportTexture("Cursor", true, out tex)) { CursorMode cursorMode = CursorMode.Auto; cursorWidth = tex.width; cursorHeight = tex.height; // Cases when true cursor size cannot be achieved using hardware accelerated cursor if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.Windows && (cursorWidth > 32 || cursorHeight > 32)) { cursorMode = CursorMode.ForceSoftware; } Cursor.SetCursor(tex, Vector2.zero, cursorMode); Debug.Log("Cursor texture overridden by mods."); } DaggerfallUnity.Settings.CursorWidth = cursorWidth; DaggerfallUnity.Settings.CursorHeight = cursorHeight; }