Skip to content

Commit

Permalink
Config-related fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
gardenappl committed Jul 29, 2018
1 parent 26f8420 commit 9b4f623
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 27 deletions.
8 changes: 4 additions & 4 deletions Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,12 @@ public static void Load()
else
GoldensMisc.Log("Old config folder still cotains some files/directories. They will not get deleted.");
}
SetDefaults();
if(!ReadConfig())
{
SetDefaults();
GoldensMisc.Log("Failed to read config file! Creating config...");
SaveConfig();
GoldensMisc.Log("Failed to read config file!");
}
SaveConfig();
}

public static void SetDefaults()
Expand Down Expand Up @@ -153,7 +153,7 @@ public static void SetDefaults()
MechanicsRodOften = true;
ChestVacuum = true;
}

public static bool ReadConfig()
{
if(Configuration.Load())
Expand Down
38 changes: 22 additions & 16 deletions GoldensMisc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public override void Load()
Instance = this; //apparently you get some problems with Mod Reloading if you put this in the constructor
FKtModSettingsLoaded = ModLoader.GetMod("FKTModSettings") != null;
VanillaTweaksLoaded = ModLoader.GetMod("VanillaTweaks") != null;

if(!Main.dedServ)
{
if(FKtModSettingsLoaded)
Config.LoadFKConfig();

MiscGlowMasks.Load();
if(Config.CellPhoneResprite)
{
Expand All @@ -62,34 +62,40 @@ public override void Load()
}
// SkyManager.Instance["GoldensMisc:Laputa"] = new LaputaSky();

GameShaders.Armor.BindShader<ArmorShaderData>(ItemType<MatrixDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(0f, 1.0f, 0.2f);
GameShaders.Armor.BindShader<ArmorShaderData>(ItemType<VirtualDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(1f, 0.1f, 0.1f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<CobaltDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.4f, 0.7f, 1.2f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<PalladiumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.2f, 0.5f, 0.3f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<MythrilDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.3f, 0.8f, 0.8f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<OrichalcumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.3f, 1.1f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<AdamantiteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.4f, 0.6f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<TitaniumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 0.7f, 0.7f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<ChlorophyteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 1.1f, 0.1f);

if(Config.ExtraDyes)
{
GameShaders.Armor.BindShader<ArmorShaderData>(ItemType<MatrixDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(0f, 1.0f, 0.2f);
GameShaders.Armor.BindShader<ArmorShaderData>(ItemType<VirtualDye>(), new ArmorShaderData(Main.PixelShaderRef, "ArmorPhase")).UseImage("Images/Misc/noise").UseColor(1f, 0.1f, 0.1f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<CobaltDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.4f, 0.7f, 1.2f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<PalladiumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.2f, 0.5f, 0.3f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<MythrilDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.3f, 0.8f, 0.8f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<OrichalcumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.3f, 1.1f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<AdamantiteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(1.1f, 0.4f, 0.6f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<TitaniumDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 0.7f, 0.7f);
GameShaders.Armor.BindShader<ReflectiveArmorShaderData>(ItemType<ChlorophyteDye>(), new ReflectiveArmorShaderData(Main.PixelShaderRef, "ArmorReflectiveColor")).UseColor(0.5f, 1.1f, 0.1f);
}
WormholeUI = new UIWormhole();
WormholeUI.Activate();
MiscUserInterface = new UserInterface();
MiscUserInterface.SetState(WormholeUI);
}
AddProjectile("MagicSpearMiniAlt", new MagicSpearMini());
if(Config.SpearofJustice)
{
AddProjectile("MagicSpearMiniAlt", new MagicSpearMini());
}
}

public override void PostSetupContent()
{
var hotkeysMod = ModLoader.GetMod("HelpfulHotkeys");
if(hotkeysMod != null)
if(hotkeysMod != null && Config.WormholeMirror)
{
hotkeysMod.Call("RegisterRecallItem", ItemType<WormholeDoubleMirror>());
hotkeysMod.Call("RegisterRecallItem", ItemType<WormholeIceMirror>());
hotkeysMod.Call("RegisterRecallItem", ItemType<WormholeCellPhone>());
}
GetTile<Tiles.ChestVacuum>().SetDefaultsPostContent();
if(Config.ChestVacuum)
GetTile<Tiles.ChestVacuum>().SetDefaultsPostContent();
}

public override void Unload()
Expand Down Expand Up @@ -124,7 +130,7 @@ public override void PreSaveAndQuit()
{
if(FKtModSettingsLoaded && !Main.dedServ)
Config.SaveConfig();

UIWormhole.Close();
}

Expand Down
5 changes: 5 additions & 0 deletions Projectiles/AutofisherBobber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public override string Texture
get { return "Terraria/Projectile_" + ProjectileID.BobberMechanics; }
}

public override bool Autoload(ref string name)
{
return Config.Autofisher;
}

public override void SetDefaults()
{
projectile.width = 14;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/GasterBlaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ int SoundCounter
set { projectile.localAI[0] = value; }
}
bool FirstSpawn = true;


public override bool Autoload(ref string name)
{
return Config.GasterBlaster;
}

public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 2;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/GasterLaser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ float BeamLength
set { projectile.ai[0] = value; }
}
Vector2 endPoint;


public override bool Autoload(ref string name)
{
return Config.GasterBlaster;
}

public override void SetDefaults()
{
projectile.netImportant = true;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/MagicSpear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
namespace GoldensMisc.Projectiles
{
public class MagicSpear : ModProjectile
{
{
public override bool Autoload(ref string name)
{
return Config.SpearofJustice;
}

public override void SetDefaults()
{
projectile.scale = 1.3f;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/MagicSpearMini.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ bool undying
get { return projectile.ai[0] > 0; }
set { projectile.ai[0] = value ? 1 : 0; }
}


public override bool Autoload(ref string name)
{
return Config.SpearofJustice;
}

public override void SetDefaults()
{
projectile.width = 14;
Expand Down
5 changes: 5 additions & 0 deletions Projectiles/OrbofLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ namespace GoldensMisc.Projectiles
{
public class OrbofLight : ModProjectile
{
public override bool Autoload(ref string name)
{
return Config.AncientOrb;
}

public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 1;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/RedBullet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ int DustDelay
get { return (int)projectile.localAI[0]; }
set { projectile.localAI[0] = value; }
}


public override bool Autoload(ref string name)
{
return Config.DemonCrown;
}

public override string Texture
{
get
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/RedCrystal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ int DustDelay
}

const float TargetDist = 450f;


public override bool Autoload(ref string name)
{
return Config.DemonCrown;
}

public override void SetStaticDefaults()
{
Main.projFrames[projectile.type] = 2;
Expand Down
7 changes: 6 additions & 1 deletion Projectiles/UndyingSpear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
namespace GoldensMisc.Projectiles
{
public class UndyingSpear : ModProjectile
{
{
public override bool Autoload(ref string name)
{
return Config.SpearofJustice;
}

public override void SetDefaults()
{
projectile.scale = 1.3f;
Expand Down
5 changes: 5 additions & 0 deletions Tiles/AutofisherTE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class AutofisherTE : ModTileEntity
int bobberProj = -1;
int FishingCooldown = 300;

public override bool Autoload(ref string name)
{
return Config.Autofisher;
}

public override bool ValidTile(int i, int j)
{
var tile = Main.tile[i, j];
Expand Down
5 changes: 5 additions & 0 deletions Tiles/ChestVacuumTE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public class ChestVacuumTE : ModTileEntity
public bool SmartStack = false;
const float PickupRadiusSq = 160f * 160f;

public override bool Autoload(ref string name)
{
return Config.ChestVacuum;
}

public override bool ValidTile(int i, int j)
{
var tile = Main.tile[i, j];
Expand Down

0 comments on commit 9b4f623

Please sign in to comment.