From 0edab1e42e99364d47406e011ce317df907d1512 Mon Sep 17 00:00:00 2001 From: hamstar0 Date: Thu, 11 Jun 2020 00:22:22 -0700 Subject: [PATCH] v2.0.0.2 - Finished transitioning to UIZoomHelpers * Finished transitioning to UIZoomHelpers * Fixed hologram preview zoom --- Emitters/Definitions/EmitterDefinition_Draw.cs | 3 ++- .../HologramDefinition_Draw_Tile.cs | 4 +++- .../Definitions/SoundEmitterDefinition_Draw.cs | 6 ++++-- Emitters/Items/HologramItem_SaveLoad.cs | 2 +- Emitters/UI/UIHologramEditorDialog.cs | 18 ++++++++++++++---- Emitters/UI/UIHologramEditorDialog_UI.cs | 1 - 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Emitters/Definitions/EmitterDefinition_Draw.cs b/Emitters/Definitions/EmitterDefinition_Draw.cs index 816f140..ba4599b 100644 --- a/Emitters/Definitions/EmitterDefinition_Draw.cs +++ b/Emitters/Definitions/EmitterDefinition_Draw.cs @@ -24,7 +24,8 @@ public void Draw( SpriteBatch sb, int tileX, int tileY, bool isOnScreen ) { public void DrawEmitterTile( SpriteBatch sb, int tileX, int tileY ) { Vector2 wldPos = new Vector2( tileX << 4, tileY << 4 ); - Vector2 scr = UIHelpers.ConvertToScreenPosition( wldPos ); + //Vector2 scr = UIHelpers.ConvertToScreenPosition( wldPos ); + Vector2 scr = UIZoomHelpers.ApplyZoomFromScreenCenter( wldPos - Main.screenPosition, null, false, null, null ); sb.Draw( texture: EmittersMod.Instance.EmitterTex, diff --git a/Emitters/Definitions/HologramDefinition_Draw_Tile.cs b/Emitters/Definitions/HologramDefinition_Draw_Tile.cs index 5c5c725..90f6bdf 100644 --- a/Emitters/Definitions/HologramDefinition_Draw_Tile.cs +++ b/Emitters/Definitions/HologramDefinition_Draw_Tile.cs @@ -8,7 +8,9 @@ namespace Emitters.Definitions { public partial class HologramDefinition : BaseEmitterDefinition { public void DrawHologramTile( SpriteBatch sb, int tileX, int tileY ) { - Vector2 scr = UIHelpers.ConvertToScreenPosition( new Vector2( tileX << 4, tileY << 4 ) ); + var wldPos = new Vector2( tileX << 4, tileY << 4 ); + //Vector2 scr = UIHelpers.ConvertToScreenPosition( wldPos ); + Vector2 scr = UIZoomHelpers.ApplyZoomFromScreenCenter( wldPos - Main.screenPosition, null, false, null, null ); Texture2D tex = EmittersMod.Instance.HologramTex; sb.Draw( diff --git a/Emitters/Definitions/SoundEmitterDefinition_Draw.cs b/Emitters/Definitions/SoundEmitterDefinition_Draw.cs index 5953a5c..07763ed 100644 --- a/Emitters/Definitions/SoundEmitterDefinition_Draw.cs +++ b/Emitters/Definitions/SoundEmitterDefinition_Draw.cs @@ -21,11 +21,13 @@ public void Draw( SpriteBatch sb, int tileX, int tileY, bool isOnScreen ) { //////////////// public void DrawSoundEmitterTile( SpriteBatch sb, int tileX, int tileY ) { - Vector2 scr = UIHelpers.ConvertToScreenPosition( new Vector2(tileX<<4, tileY<<4) ); + var wldPos = new Vector2( tileX << 4, tileY << 4 ); + //Vector2 scr = UIHelpers.ConvertToScreenPosition( wldPos ); + Vector2 scrPos = UIZoomHelpers.ApplyZoomFromScreenCenter( wldPos - Main.screenPosition, null, false, null, null ); sb.Draw( texture: EmittersMod.Instance.SoundEmitterTex, - position: scr, + position: scrPos, sourceRectangle: null, color: Color.White, rotation: 0f, diff --git a/Emitters/Items/HologramItem_SaveLoad.cs b/Emitters/Items/HologramItem_SaveLoad.cs index 83505d5..18a6635 100644 --- a/Emitters/Items/HologramItem_SaveLoad.cs +++ b/Emitters/Items/HologramItem_SaveLoad.cs @@ -48,7 +48,7 @@ public override void Load( TagCompound tag ) { int shaderType = 0; if( tag.ContainsKey("HologramShaderType") ) { - shoaderType = tag.GetInt( "HologramShaderType" ); + shaderType = tag.GetInt( "HologramShaderType" ); } float shaderTime = 1f; diff --git a/Emitters/UI/UIHologramEditorDialog.cs b/Emitters/UI/UIHologramEditorDialog.cs index ddc7101..7f0384d 100644 --- a/Emitters/UI/UIHologramEditorDialog.cs +++ b/Emitters/UI/UIHologramEditorDialog.cs @@ -5,6 +5,7 @@ using HamstarHelpers.Classes.UI.Elements; using HamstarHelpers.Classes.UI.Elements.Slider; using HamstarHelpers.Classes.UI.Theme; +using HamstarHelpers.Helpers.Debug; using Emitters.Definitions; using Emitters.Helpers.UI; @@ -83,7 +84,9 @@ partial class UIHologramEditorDialog : UIDialog { //////////////// - public UIHologramEditorDialog() : base( UITheme.Vanilla, 600, 500 ) { } + public UIHologramEditorDialog() : base( UITheme.Vanilla, 600, 500 ) { + this.OriginPercentVertical = 0f; + } //////////////// @@ -114,8 +117,15 @@ public override void Recalculate() { break; } - this.SetTopPosition( this.FullDialogHeight * -0.5f, 0.5f, 0f ); - this.OuterContainer?.Height.Set( (this.FullDialogHeight - this.MainTabHeight) + tabHeight, 0f ); + this.SetTopPosition( + pixels: this.FullDialogHeight * -0.5f, + percent: 0.5f, + originPercent: 0f + ); + this.OuterContainer?.Height.Set( + pixels: (this.FullDialogHeight - this.MainTabHeight) + tabHeight, + precent: 0f + ); base.Recalculate(); } @@ -143,7 +153,7 @@ public override void Draw( SpriteBatch sb ) { this.CachedHologramDef = def; var mouseScr = new Vector2( Main.mouseX, Main.mouseY ); - mouseScr = UIZoomHelpers.ApplyZoomFromScreenCenter( mouseScr, null, true, null, null ); + mouseScr = UIZoomHelpers.ApplyZoomFromScreenCenter( mouseScr, false, true, null, null ); var mouseWld = mouseScr + Main.screenPosition; if( def.AnimateHologram(mouseWld, true) ) { diff --git a/Emitters/UI/UIHologramEditorDialog_UI.cs b/Emitters/UI/UIHologramEditorDialog_UI.cs index c329a8f..1310b41 100644 --- a/Emitters/UI/UIHologramEditorDialog_UI.cs +++ b/Emitters/UI/UIHologramEditorDialog_UI.cs @@ -12,7 +12,6 @@ partial class UIHologramEditorDialog : UIDialog { //////////////// public void SwitchTab( HologramUITab tab ) { - if( this.IsTabBeingSet ) { return; } this.IsTabBeingSet = true;