tModLoader v0.11.8.9
A mod to make and play Terraria mods
MapLegend.cs
Go to the documentation of this file.
1using System;
2using Terraria.Localization;
3using Terraria.Map;
4
5namespace Terraria.ModLoader
6{
7 //todo: further documentation
8 public class MapLegend
9 {
10 //change type of Lang.mapLegend to this class
11 private LocalizedText[] legend;
12
13 public MapLegend(int size) {
14 legend = new LocalizedText[size];
15 }
16
17 public int Length {
18 get {
19 return legend.Length;
20 }
21 }
22
23 internal void Resize(int newSize) {
24 Array.Resize(ref legend, newSize);
25 }
26
27 public LocalizedText this[int i] {
28 get {
29 return legend[i];
30 }
31 set {
32 legend[i] = value;
33 }
34 }
35 //in Terraria.Main.DrawInventory replace
36 // Lang.mapLegend[MapHelper.TileToLookup(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62], 0)]
37 // with Lang.mapLegend.FromType(Main.recipe[Main.availableRecipe[num60]].requiredTile[num62])
38 //in Terraria.Main.DrawInfoAccs replace Lang.mapLegend[MapHelper.TileToLookup(Main.player[Main.myPlayer].bestOre, 0)]
39 // with Lang.mapLegend.FromType(Main.player[Main.myPlayer].bestOre)
40 public LocalizedText FromType(int type) {
41 return this[MapHelper.TileToLookup(type, 0)];
42 }
43 //in Terraria.Main.DrawMap replace text = Lang.mapLegend[type]; with
44 // text = Lang.mapLegend.FromTile(Main.Map[num91, num92], num91, num92);
45 public string FromTile(MapTile mapTile, int x, int y) {
46 string name = legend[mapTile.Type].Value;
47 if (MapLoader.nameFuncs.ContainsKey(mapTile.Type)) {
48 name = MapLoader.nameFuncs[mapTile.Type](name, x, y);
49 }
50 return name;
51 }
52 }
53}
LocalizedText FromType(int type)
Definition: MapLegend.cs:40
LocalizedText[] legend
Definition: MapLegend.cs:11
string FromTile(MapTile mapTile, int x, int y)
Definition: MapLegend.cs:45