Skip to content

Commit

Permalink
fixed translations, used label instead of defname for displayed text
Browse files Browse the repository at this point in the history
  • Loading branch information
rheirman committed Dec 4, 2017
1 parent 7c58a54 commit cf583dc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions About/PublishedFileId.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1216999901
Binary file modified Assemblies/GiddyUpCore.dll
Binary file not shown.
6 changes: 4 additions & 2 deletions Source/Giddy-up-Core/AnimalRecord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ public class AnimalRecord
{
public bool isSelected = false;
public bool isException = false;
public AnimalRecord(bool isSelected, bool isException)
public String label = "";
public AnimalRecord(bool isSelected, bool isException, String label)
{
this.isException = isException;
this.isSelected = isSelected;
this.label = label;
}
public override string ToString()
{
return this.isSelected + "," + this.isException;
return this.isSelected + "," + this.isException + "," + this.label;
}
}

Expand Down
14 changes: 6 additions & 8 deletions Source/Giddy-up-Core/Base.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ public class Base : ModBase
public static SettingHandle<DictAnimalRecordHandler> animalSelecter;
public static SettingHandle<DictAnimalRecordHandler> drawSelecter;
internal static SettingHandle<String> tabsHandler;
internal static SettingHandle<int> accuracyPenalty;

internal static SettingHandle<float> bodySizeFilter;
private static Color highlight1 = new Color(0.5f, 0, 0, 0.1f);
String[] tabNames = { "GUC_tab1".Translate(), "GUC_tab2".Translate()};
Expand All @@ -43,8 +41,8 @@ public override void DefsLoaded()

tabsHandler = Settings.GetHandle<String>("tabs", "GUC_Tabs_Title".Translate(), "", "none");
bodySizeFilter = Settings.GetHandle<float>("bodySizeFilter", "GUC_BodySizeFilter_Title".Translate(), "GUC_BodySizeFilter_Description".Translate(), 0.8f);
animalSelecter = Settings.GetHandle<DictAnimalRecordHandler>("Animalselecter", "GUC_Animalselection_Title".Translate(), "GUC_Animalselection_Description".Translate(), null);
drawSelecter = Settings.GetHandle<DictAnimalRecordHandler>("drawSelecter", "GUC_Drawselection_Title".Translate(), "GUC_Drawselection_Description".Translate(), null);
animalSelecter = Settings.GetHandle<DictAnimalRecordHandler>("Animalselecter", "GUC_Animalselection_Title".Translate(), "GUC_Animalselection_Description".Translate(), getDefaultForAnimalSelecter(allAnimals));
drawSelecter = Settings.GetHandle<DictAnimalRecordHandler>("drawSelecter", "GUC_Drawselection_Title".Translate(), "GUC_Drawselection_Description".Translate(), getDefaultForDrawSelecter(allAnimals));


tabsHandler.CustomDrawer = rect => { return DrawUtility.CustomDrawer_Tabs(rect, tabsHandler, tabNames); };
Expand Down Expand Up @@ -80,12 +78,12 @@ private DictAnimalRecordHandler getDefaultForAnimalSelecter(List<ThingDef> allAn
float mass = animal.race.baseBodySize;
if (prop != null && prop.isException)
{
result.Add(animal.defName, new AnimalRecord(false, true));
result.Add(animal.defName, new AnimalRecord(false, true, animal.label));
}
else
{
bool shouldSelect = mass >= bodySizeFilter.Value;
result.Add(animal.defName, new AnimalRecord(shouldSelect, false));
result.Add(animal.defName, new AnimalRecord(shouldSelect, false, animal.label));
}
}
//result.Add("", new AnimalRecord(shouldSelect, false));
Expand All @@ -103,11 +101,11 @@ private DictAnimalRecordHandler getDefaultForDrawSelecter(List<ThingDef> allAnim
float mass = animal.race.baseBodySize;
if (prop != null && prop.drawFront)
{
result.Add(animal.defName, new AnimalRecord(true, true));
result.Add(animal.defName, new AnimalRecord(true, true, animal.label));
}
else
{
result.Add(animal.defName, new AnimalRecord(false, false));
result.Add(animal.defName, new AnimalRecord(false, false, animal.label));
}
}
//result.Add("", new AnimalRecord(shouldSelect, false));
Expand Down
10 changes: 9 additions & 1 deletion Source/Giddy-up-Core/DictAnimalRecordHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@ public override void FromString(string settingValue)
{
foreach (string str in settingValue.Split('|'))
{
inner.Add(str.Split(',')[0], new AnimalRecord(Convert.ToBoolean(str.Split(',')[1]), Convert.ToBoolean(str.Split(',')[2])));
string[] split = str.Split(',');
if(split.Count() < 4) //ensures that it works for users that still have old AnimalRecords saved.
{
inner.Add(str.Split(',')[0], new AnimalRecord(Convert.ToBoolean(str.Split(',')[1]), Convert.ToBoolean(str.Split(',')[2]), ""));
}
else
{
inner.Add(str.Split(',')[0], new AnimalRecord(Convert.ToBoolean(str.Split(',')[1]), Convert.ToBoolean(str.Split(',')[2]), str.Split(',')[3]));
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Giddy-up-Core/Utilities/DrawUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static bool DrawTileForAnimal(KeyValuePair<String, AnimalRecord> Animal,
GUI.DrawTexture(iconRect, TexUI.FastFillTex);
GUI.color = save;
Text.Anchor = TextAnchor.MiddleCenter;
Widgets.Label(iconRect, Animal.Key);
Widgets.Label(iconRect, (!Animal.Value.label.NullOrEmpty() ? Animal.Value.label : Animal.Key));
Text.Anchor = TextAnchor.UpperLeft;

if (Widgets.ButtonInvisible(iconRect, true))
Expand Down Expand Up @@ -206,7 +206,7 @@ internal static bool CustomDrawer_MatchingAnimals_active(Rect wholeRect, Setting
}
else
{
selection.Add(allAnimals[i].defName, new AnimalRecord(shouldSelect, false));
selection.Add(allAnimals[i].defName, new AnimalRecord(shouldSelect, false, allAnimals[i].label));
}
}

Expand Down
Binary file modified Source/Giddy-up-Core/obj/Debug/GiddyUpCore.dll
Binary file not shown.

0 comments on commit cf583dc

Please sign in to comment.