Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
* Added better UI sprite for glow cartridges
  • Loading branch information
hamstar0 committed Jun 28, 2018
1 parent 598a727 commit d5c7225
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 36 deletions.
18 changes: 9 additions & 9 deletions Items/ColorCartridgeItem_Def.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ partial class ColorCartridgeItem : ModItem {
public const int Width = 12;
public const int Height = 16;

public static Texture2D OverlayTex { get; internal set; }
public static Texture2D CartridgeTex { get; internal set; }
public static Texture2D ColorOverlayTex { get; internal set; }
public static Texture2D ColorCartridgeTex { get; internal set; }

static ColorCartridgeItem() {
ColorCartridgeItem.OverlayTex = null;
ColorCartridgeItem.CartridgeTex = null;
ColorCartridgeItem.ColorOverlayTex = null;
ColorCartridgeItem.ColorCartridgeTex = null;
}


Expand Down Expand Up @@ -50,13 +50,13 @@ public override void SetStaticDefaults() {
"Make cartridges with paint at a paint mixer" + '\n' +
"Blend cartidges together at a paint mixer" );

if( ColorCartridgeItem.OverlayTex == null ) {
ColorCartridgeItem.OverlayTex = this.mod.GetTexture( "Items/ColorCartridgeItem_Color" );
ColorCartridgeItem.CartridgeTex = this.mod.GetTexture( "Items/ColorCartridgeItem" );
if( ColorCartridgeItem.ColorCartridgeTex == null ) {
ColorCartridgeItem.ColorCartridgeTex = this.mod.GetTexture( "Items/ColorCartridgeItem" );
ColorCartridgeItem.ColorOverlayTex = this.mod.GetTexture( "Items/ColorCartridgeItem_Color" );

Promises.AddModUnloadPromise( () => {
ColorCartridgeItem.OverlayTex = null;
ColorCartridgeItem.CartridgeTex = null;
ColorCartridgeItem.ColorOverlayTex = null;
ColorCartridgeItem.ColorCartridgeTex = null;
} );
}
}
Expand Down
4 changes: 2 additions & 2 deletions Items/ColorCartridgeItem_Draw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static Color GetCapacityColor( float percent ) {

public override void PostDrawInInventory( SpriteBatch sb, Vector2 pos, Rectangle frame, Color draw_color, Color item_color, Vector2 origin, float scale ) {
var mymod = (BetterPaintMod)this.mod;
Texture2D tex = ColorCartridgeItem.OverlayTex;
Texture2D tex = ColorCartridgeItem.ColorOverlayTex;

sb.Draw( tex, pos, frame, this.MyColor, 0f, default(Vector2), scale, SpriteEffects.None, 0f );

Expand All @@ -32,7 +32,7 @@ public override void PostDrawInInventory( SpriteBatch sb, Vector2 pos, Rectangle
public override void PostDrawInWorld( SpriteBatch sb, Color light_color, Color alpha_color, float rotation, float scale, int whoAmI ) {
var mymod = (BetterPaintMod)this.mod;
var pos = new Vector2( this.item.position.X - Main.screenPosition.X, this.item.position.Y - Main.screenPosition.Y );
Texture2D overlay_tex = ColorCartridgeItem.OverlayTex;
Texture2D overlay_tex = ColorCartridgeItem.ColorOverlayTex;

sb.Draw( overlay_tex, pos, light_color.MultiplyRGBA( this.MyColor ) );
}
Expand Down
Binary file modified Items/GlowCartridgeItem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 13 additions & 13 deletions Items/GlowCartridgeItem_Def.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ partial class GlowCartridgeItem : ModItem {
public const int Width = 12;
public const int Height = 16;

public static Texture2D CartridgeTex { get; internal set; }
public static Texture2D OverlayTex { get; internal set; }
public static Texture2D GlowMask1Tex { get; internal set; }
public static Texture2D GlowCartridgeTex { get; internal set; }
public static Texture2D ColorOverlayTex { get; internal set; }
public static Texture2D GlowMaskTex { get; internal set; }


static GlowCartridgeItem() {
GlowCartridgeItem.CartridgeTex = null;
GlowCartridgeItem.OverlayTex = null;
GlowCartridgeItem.GlowMask1Tex = null;
GlowCartridgeItem.GlowCartridgeTex = null;
GlowCartridgeItem.ColorOverlayTex = null;
GlowCartridgeItem.GlowMaskTex = null;
}


Expand Down Expand Up @@ -54,15 +54,15 @@ public override void SetStaticDefaults() {
"Produces glow-in-the-dark paint" + '\n' +
"Craft with cartidges and glowing spores at a paint mixer" );

if( GlowCartridgeItem.OverlayTex == null ) {
GlowCartridgeItem.CartridgeTex = this.mod.GetTexture( "Items/GlowCartridgeItem" );
GlowCartridgeItem.OverlayTex = this.mod.GetTexture( "Items/GlowCartridgeItem_Color" );
GlowCartridgeItem.GlowMask1Tex = this.mod.GetTexture( "Items/GlowCartridgeItem_Glow1" );
if( GlowCartridgeItem.GlowCartridgeTex == null ) {
GlowCartridgeItem.GlowCartridgeTex = this.mod.GetTexture( "Items/GlowCartridgeItem" );
GlowCartridgeItem.ColorOverlayTex = this.mod.GetTexture( "Items/GlowCartridgeItem_Color" );
GlowCartridgeItem.GlowMaskTex = this.mod.GetTexture( "Items/GlowCartridgeItem_Glow1" );

Promises.AddModUnloadPromise( () => {
GlowCartridgeItem.CartridgeTex = null;
GlowCartridgeItem.OverlayTex = null;
GlowCartridgeItem.GlowMask1Tex = null;
GlowCartridgeItem.GlowCartridgeTex = null;
GlowCartridgeItem.ColorOverlayTex = null;
GlowCartridgeItem.GlowMaskTex = null;
} );
}
}
Expand Down
8 changes: 4 additions & 4 deletions Items/GlowCartridgeItem_Draw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace BetterPaint.Items {
partial class GlowCartridgeItem : ModItem {
public override void PostDrawInInventory( SpriteBatch sb, Vector2 pos, Rectangle frame, Color draw_color, Color item_color, Vector2 origin, float scale ) {
var mymod = (BetterPaintMod)this.mod;
Texture2D color_tex = GlowCartridgeItem.OverlayTex;
Texture2D glow1_tex = GlowCartridgeItem.GlowMask1Tex;
Texture2D color_tex = GlowCartridgeItem.ColorOverlayTex;
Texture2D glow1_tex = GlowCartridgeItem.GlowMaskTex;

sb.Draw( color_tex, pos, frame, this.MyColor, 0f, default(Vector2), scale, SpriteEffects.None, 0f );
sb.Draw( glow1_tex, pos, frame, this.MyColor * 0.5f, 0f, default( Vector2 ), scale, SpriteEffects.None, 0f );
Expand All @@ -21,8 +21,8 @@ public override void PostDrawInInventory( SpriteBatch sb, Vector2 pos, Rectangle

public override void PostDrawInWorld( SpriteBatch sb, Color light_color, Color alpha_color, float rotation, float scale, int whoAmI ) {
var mymod = (BetterPaintMod)this.mod;
Texture2D color_tex = GlowCartridgeItem.OverlayTex;
Texture2D glow1_tex = GlowCartridgeItem.GlowMask1Tex;
Texture2D color_tex = GlowCartridgeItem.ColorOverlayTex;
Texture2D glow1_tex = GlowCartridgeItem.GlowMaskTex;

var pos = new Vector2( this.item.position.X - Main.screenPosition.X, this.item.position.Y - Main.screenPosition.Y );

Expand Down
21 changes: 13 additions & 8 deletions UI/PaintBlasterUI/PaintBlasterUI_DrawPaints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,25 @@ public IDictionary<int, float> DrawColorPalette( BetterPaintMod mymod, SpriteBat

public Texture2D GetPaintTexture( BetterPaintMod mymod, int item_type ) {
if( item_type == mymod.ItemType<ColorCartridgeItem>() ) {
return ColorCartridgeItem.CartridgeTex;
return ColorCartridgeItem.ColorCartridgeTex;
} else if( item_type == mymod.ItemType<GlowCartridgeItem>() ) {
return GlowCartridgeItem.CartridgeTex;
return GlowCartridgeItem.GlowCartridgeTex;
} else if( ItemIdentityHelpers.Paints.Item2.Contains( item_type ) ) {
return Main.itemTexture[item_type];
} else {
throw new NotImplementedException();
}
}

public Texture2D GetPaintOverlayTexture( BetterPaintMod mymod, int item_type ) {
public Texture2D GetPaintOverlayTexture( BetterPaintMod mymod, int item_type, out bool has_glow ) {
if( item_type == mymod.ItemType<ColorCartridgeItem>() ) {
return ColorCartridgeItem.OverlayTex;
has_glow = false;
return ColorCartridgeItem.ColorOverlayTex;
} else if( item_type == mymod.ItemType<GlowCartridgeItem>() ) {
return GlowCartridgeItem.OverlayTex;
has_glow = true;
return GlowCartridgeItem.ColorOverlayTex;
} else if( ItemIdentityHelpers.Paints.Item2.Contains( item_type ) ) {
has_glow = false;
return null;
} else {
throw new NotImplementedException();
Expand All @@ -90,8 +93,9 @@ public Texture2D GetPaintOverlayTexture( BetterPaintMod mymod, int item_type ) {
////////////////

public Rectangle DrawColorIcon( BetterPaintMod mymod, SpriteBatch sb, int item_type, Color color, float amount_percent, int stack, int x, int y, double palette_angle, double angle_step, bool is_selected ) {
bool has_glow;
Texture2D cart_tex = this.GetPaintTexture( mymod, item_type );
Texture2D over_tex = this.GetPaintOverlayTexture( mymod, item_type );
Texture2D over_tex = this.GetPaintOverlayTexture( mymod, item_type, out has_glow );

bool is_hover = this.IsHoveringIcon( palette_angle, angle_step );

Expand All @@ -101,12 +105,13 @@ public Rectangle DrawColorIcon( BetterPaintMod mymod, SpriteBatch sb, int item_t

sb.Draw( cart_tex, rect, Color.White * color_mul );
if( over_tex != null ) {
sb.Draw( over_tex, rect, color * color_mul );
sb.Draw( over_tex, rect, (has_glow ? color : color * color_mul) );
}

if( is_hover ) {
Color text_color = ColorCartridgeItem.GetCapacityColor( amount_percent );
Color label_color = Color.White * PaintBlasterUI.HoveredScale;
Color label_color = has_glow ? Color.GreenYellow * PaintBlasterUI.HoveredScale
: Color.White * PaintBlasterUI.HoveredScale;
Color bg_color = Color.Black * PaintBlasterUI.HoveredScale;

Utils.DrawBorderStringFourWay( sb, Main.fontMouseText, "Capacity:", Main.mouseX, Main.mouseY-16, label_color, bg_color, default( Vector2 ), 1f );
Expand Down

0 comments on commit d5c7225

Please sign in to comment.