-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,013 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
using Microsoft.Xna.Framework; | ||
using ModdersToolkit.UIElements; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Terraria; | ||
|
||
namespace ModdersToolkit.Tools.Dusts | ||
{ | ||
class FloatDataRangeProperty | ||
{ | ||
internal float min = 0f; | ||
internal float max = 5f; | ||
private float data = 1f; | ||
internal float Data | ||
{ | ||
get { return data; } | ||
set | ||
{ | ||
data = value; | ||
range.input.SetText(data.ToString("0.00")); | ||
} | ||
} | ||
|
||
public UIRange range; | ||
|
||
public FloatDataRangeProperty(string label, float defaultValue, float min, float max) | ||
{ | ||
data = defaultValue; | ||
this.min = min; | ||
this.max = max; | ||
range = new UIRange(label, () => (Data - min) / (max - min), (s) => { Data = (s * (max - min) + min); }, ValidateInput); | ||
//range.Top.Set(top, 0f); | ||
range.Width.Set(0, 1f); | ||
Data = data; | ||
} | ||
|
||
private void ValidateInput() | ||
{ | ||
float result; | ||
if (float.TryParse(range.input.Text, out result)) | ||
{ | ||
Data = result; | ||
} | ||
else | ||
{ | ||
Data = data; | ||
} | ||
} | ||
} | ||
|
||
class IntDataRangeProperty | ||
{ | ||
internal int max = 5; | ||
private int data = 1; | ||
internal int Data | ||
{ | ||
get { return data; } | ||
set | ||
{ | ||
data = value; | ||
range.input.SetText(data.ToString()); | ||
} | ||
} | ||
|
||
public UIRange range; | ||
|
||
public IntDataRangeProperty(string label, int defaultValue, int max, bool fine = false) | ||
{ | ||
data = defaultValue; | ||
this.max = max; | ||
range = new UIRange(label, () => (float)Data / max, (s) => { Data = (int)(s * max); }, ValidateInput, fine); | ||
range.intDataRangeProperty = this; | ||
//range.Top.Set(top, 0f); | ||
range.Width.Set(0, 1f); | ||
Data = data; | ||
} | ||
|
||
private void ValidateInput() | ||
{ | ||
int result; | ||
if (int.TryParse(range.input.Text, out result)) | ||
{ | ||
Data = result; | ||
} | ||
else | ||
{ | ||
Data = data; | ||
} | ||
} | ||
} | ||
|
||
class ColorDataRangeProperty | ||
{ | ||
private Color data = Color.White; | ||
internal Color Data | ||
{ | ||
get { return data; } | ||
set | ||
{ | ||
data = value; | ||
//range.input.SetText($"{data.R}-{data.G}-{data.B}"); | ||
range.input.SetText(data.Hex3()); | ||
} | ||
} | ||
|
||
public UIRange range; | ||
|
||
public ColorDataRangeProperty(string label) | ||
{ | ||
//Main.hslToRgb(amount, 1f, 0.5f) | ||
range = new UIRange(label, () => Main.rgbToHsl(Data).X, (s) => { Data = Main.hslToRgb(s, 1f, 0.5f); }, ValidateInput); | ||
range.Width.Set(0, 1f); | ||
range.slider.SetHueMode(true); | ||
Data = data; | ||
} | ||
|
||
private void ValidateInput() | ||
{ | ||
//int result; | ||
//if (int.TryParse(range.input.Text, out result)) | ||
//{ | ||
// Data = result; | ||
//} | ||
//else | ||
//{ | ||
// Data = data; | ||
//} | ||
Data = data; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using Microsoft.Xna.Framework; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Terraria; | ||
using Terraria.Graphics.Shaders; | ||
using Terraria.ModLoader; | ||
using Terraria.UI; | ||
|
||
namespace ModdersToolkit.Tools.Dusts | ||
{ | ||
class DustTool : Tool | ||
{ | ||
//internal static UserInterface userInterface; | ||
internal static DustUI dustUI; | ||
internal override void Initialize() | ||
{ | ||
toggleTooltip = "Click to toggle Dust Tool"; | ||
} | ||
|
||
// should ui even initialize during load? are static members nulled out on reload? | ||
internal override void ClientInitialize() | ||
{ | ||
userInterface = new UserInterface(); | ||
//dustUI = new DustUI(userInterface); | ||
//dustUI.Activate(); | ||
//userInterface.SetState(dustUI); | ||
} | ||
//internal override void ScreenResolutionChanged() | ||
//{ | ||
// userInterface.Recalculate(); | ||
//} | ||
//internal override void UIUpdate() | ||
//{ | ||
// if (visible) | ||
// { | ||
// userInterface.Update(Main._drawInterfaceGameTime); | ||
// } | ||
//} | ||
internal override void UIDraw() | ||
{ | ||
if (visible) | ||
{ | ||
dustUI.Draw(Main.spriteBatch); | ||
//if (showProjectileHitboxes) drawProjectileHitboxes(); | ||
} | ||
} | ||
|
||
internal static int shaderCount; | ||
internal static int dustCount; | ||
internal override void PostSetupContent() | ||
{ | ||
if (!Main.dedServ) | ||
{ | ||
int count = 0; | ||
ArmorShaderData shader; | ||
do | ||
{ | ||
shader = GameShaders.Armor.GetSecondaryShader(count + 1, Main.LocalPlayer); | ||
count++; | ||
} while (shader != null); | ||
shaderCount = count - 1; | ||
|
||
count = Terraria.ID.DustID.Count; | ||
ModDust dust; | ||
while (true) | ||
{ | ||
dust = ModDust.GetDust(count); | ||
if (dust == null) break; | ||
count++; | ||
} | ||
dustCount = count; | ||
|
||
dustUI = new DustUI(userInterface); | ||
dustUI.Activate(); | ||
userInterface.SetState(dustUI); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.