forked from tModLoader/tModLoader
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Direct port of "Added support for Modded Builder Toggles", tModLoader…
…#2511 (tModLoader#3731) * Direct port of "Added support for Modded Builder Toggles", tModLoader#2511 Co-Authored-By: Kirtle <[email protected]> * Convert to file-scoped namespaces Co-Authored-By: Kirtle <[email protected]> * Save and load modded builder toggles, doc updates * Update ExampleBuilderToggle.cs * Remove GlobalBuilderToggle, it's impossible to use correctly with multiple mods * Localize, custom hover icon support * Move a patch to .TML.cs --------- Co-authored-by: Kirtle <[email protected]>
- Loading branch information
Showing
16 changed files
with
829 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using Microsoft.Xna.Framework; | ||
using Terraria; | ||
using Terraria.Localization; | ||
using Terraria.ModLoader; | ||
|
||
namespace ExampleMod.Content | ||
{ | ||
// The examples in this file don't actually affect anything, they just show typical approaches for the BuilderToggle half of the effect. | ||
// A full example would have code doing something, such as drawing an overlay, after checking ModContent.GetInstance<YourBuilderToggle>().Active and ModContent.GetInstance<YourBuilderToggle>().CurrentState. | ||
// That code is highly dependent on what you want to accomplish. | ||
|
||
public class ExampleBuilderToggle : BuilderToggle | ||
{ | ||
public override bool Active() => Main.LocalPlayer.HeldItem.IsAir; | ||
|
||
public override int NumberOfStates => 4; | ||
public override string DisplayValue() { | ||
string text = "Color: "; | ||
string[] textMessages = new[] { "Red", "Blue", "Green", "Yellow" }; | ||
|
||
return text + textMessages[CurrentState]; | ||
} | ||
|
||
public override Color DisplayColorTexture() { | ||
Color[] colors = new[] { Color.Red, Color.Blue, Color.Green, Color.Yellow }; | ||
|
||
return colors[CurrentState]; | ||
} | ||
} | ||
|
||
public class ExampleBuilderToggleDimmedLight : BuilderToggle | ||
{ | ||
public static LocalizedText OnText { get; private set; } | ||
public static LocalizedText OffText { get; private set; } | ||
|
||
public override string Texture => "ExampleMod/Content/ExampleBuilderToggle"; | ||
public override bool Active() => true; | ||
public override int NumberOfStates => 2; | ||
|
||
public override void SetStaticDefaults() { | ||
OnText = this.GetLocalization(nameof(OnText)); | ||
OffText = this.GetLocalization(nameof(OffText)); | ||
} | ||
|
||
public override string DisplayValue() { | ||
return CurrentState == 0 ? OnText.Value : OffText.Value; | ||
} | ||
|
||
public override Color DisplayColorTexture() { | ||
return CurrentState == 0 ? Color.White : new Color(127, 127, 127); | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
en-US, 504/504, 100%, missing 0 | ||
ru-RU, 6/504, 1%, missing 498 | ||
zh-Hans, 1/504, 0%, missing 503 | ||
en-US, 506/506, 100%, missing 0 | ||
ru-RU, 6/506, 1%, missing 500 | ||
zh-Hans, 1/506, 0%, missing 505 |
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
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
Oops, something went wrong.