Skip to content

Commit

Permalink
v2.0.0.2 - Finished transitioning to UIZoomHelpers
Browse files Browse the repository at this point in the history
* Finished transitioning to UIZoomHelpers
* Fixed hologram preview zoom
  • Loading branch information
hamstar0 committed Jun 11, 2020
1 parent 217eb89 commit 0edab1e
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Emitters/Definitions/EmitterDefinition_Draw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion Emitters/Definitions/HologramDefinition_Draw_Tile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 4 additions & 2 deletions Emitters/Definitions/SoundEmitterDefinition_Draw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion Emitters/Items/HologramItem_SaveLoad.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 14 additions & 4 deletions Emitters/UI/UIHologramEditorDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}


////////////////
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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) ) {
Expand Down
1 change: 0 additions & 1 deletion Emitters/UI/UIHologramEditorDialog_UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ partial class UIHologramEditorDialog : UIDialog {
////////////////

public void SwitchTab( HologramUITab tab ) {

if( this.IsTabBeingSet ) { return; }
this.IsTabBeingSet = true;

Expand Down

0 comments on commit 0edab1e

Please sign in to comment.