Skip to content

Commit

Permalink
2.5.6 release (#1493)
Browse files Browse the repository at this point in the history
* Fixes #1492 Empty texts when default language is not english
  • Loading branch information
mayjak authored Apr 25, 2021
1 parent 52b7fdc commit b64d7e2
Show file tree
Hide file tree
Showing 70 changed files with 715 additions and 690 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.crashlytics.android.build_id" translatable="false">a9742e43-79dd-4bc9-8efc-634035f45d81</string></resources>
<?xml version="1.0" encoding="utf-8"?><resources><string name="com.crashlytics.android.build_id" translatable="false">b76cf6ec-2c58-443f-a130-43c0a6f95235</string></resources>
2 changes: 1 addition & 1 deletion unity/Assets/Resources/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5.5
2.5.6
2 changes: 1 addition & 1 deletion unity/Assets/Scripts/Content/DictionaryI18n.cs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ protected void ForceLoadAllLanguages()
GetLanguagesList().ForEach(AddRequiredLanguage);
}

private void AddRequiredLanguage(string value)
public void AddRequiredLanguage(string value)
{
if (requiredLanguages.Add(value))
{
Expand Down
13 changes: 12 additions & 1 deletion unity/Assets/Scripts/Content/LocalizationRead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,24 @@ public static class LocalizationRead
/// Change all dictionary languages
/// </summary>
/// <param name="newLang">string for new language</param>
public static void changeCurrentLangTo(string newLang)
public static void ChangeCurrentLangTo(string newLang)
{
foreach (DictionaryI18n d in dicts.Values)
{
d.currentLanguage = newLang;
}
}
/// <summary>
/// Add language that needs to be loaded
/// </summary>
/// <param name="newLang">force load a language</param>
public static void AddRequiredLanguage(string newLang)
{
foreach (DictionaryI18n d in dicts.Values)
{
d.AddRequiredLanguage(newLang);
}
}

private const int RECURSIVE_LIMIT = 20;

Expand Down
2 changes: 1 addition & 1 deletion unity/Assets/Scripts/Destroyer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void Destroy()
game.cc.minLimit = false;

// Clear up all data
game.quest = null;
game.CurrentQuest = null;
game.qed = null;
game.moraleDisplay = null;
if (game.tokenBoard.tc != null)
Expand Down
35 changes: 24 additions & 11 deletions unity/Assets/Scripts/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public ContentData cd
}

// Data for the current quest
public Quest quest;
private Quest quest;
// Canvas for UI components (fixed on screen)
public Canvas uICanvas;
// Canvas for board tiles (tilted, in game space)
Expand Down Expand Up @@ -102,6 +102,19 @@ public ContentData cd
private ContentLoader _contentLoader;
public ContentLoader ContentLoader => _contentLoader;

public Quest CurrentQuest
{
get => quest;
set
{
quest = value;
if (quest?.qd?.quest?.defaultLanguage != null)
{
LocalizationRead.AddRequiredLanguage(quest.qd.quest.defaultLanguage);
}
}
}

// Current language
public string currentLang;

Expand Down Expand Up @@ -129,7 +142,7 @@ public static Game Get()

internal string CurrentQuestPath()
{
return quest?.originalPath;
return CurrentQuest?.originalPath;
}

// Unity fires off this function
Expand Down Expand Up @@ -277,7 +290,7 @@ internal void StartQuest(QuestData.Quest q)
}

// Fetch all of the quest data and initialise the quest
quest = new Quest(q);
CurrentQuest = new Quest(q);

// Draw the hero icons, which are buttons for selection
heroCanvas.SetupUI();
Expand Down Expand Up @@ -314,12 +327,12 @@ public void EndSelection()
{
// Count up how many heros have been selected
int count = 0;
foreach (Quest.Hero h in Get().quest.heroes)
foreach (Quest.Hero h in Get().CurrentQuest.heroes)
{
if (h.heroData != null) count++;
}
// Starting morale is number of heros
quest.vars.SetValue("$%morale", count);
CurrentQuest.vars.SetValue("$%morale", count);
// This validates the selection then if OK starts first quest event
heroCanvas.EndSection();
}
Expand All @@ -338,10 +351,10 @@ public void QuestStartEvent()
stageUI = new NextStageButton();

// Start round events
quest.eManager.EventTriggerType("StartRound", false);
CurrentQuest.eManager.EventTriggerType("StartRound", false);
// Start the quest (top of stack)
quest.eManager.EventTriggerType("EventStart", false);
quest.eManager.TriggerEvent();
CurrentQuest.eManager.EventTriggerType("EventStart", false);
CurrentQuest.eManager.TriggerEvent();
}

public void PlayDefaultQuestMusic()
Expand All @@ -354,7 +367,7 @@ private List<string> GetDefaultQuestMusic()
{
List<string> music = new List<string>();
//If default quest music has been turned off do not add any audio files to the list
if (quest.defaultMusicOn)
if (CurrentQuest.defaultMusicOn)
{
// Start quest music
foreach (AudioData ad in cd.Values<AudioData>())
Expand Down Expand Up @@ -411,9 +424,9 @@ void Update()
qed.RightClick();
}

if (quest != null)
if (CurrentQuest != null)
{
quest.Update();
CurrentQuest.Update();
}

if (Input.GetKey("right alt") || Input.GetKey("left alt"))
Expand Down
2 changes: 1 addition & 1 deletion unity/Assets/Scripts/GameStateManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public static void EditCurrentQuest()

private static bool GetCurrentQuestPath(Game game, out string currentQuestPath)
{
currentQuestPath = game.quest?.originalPath;
currentQuestPath = game.CurrentQuest?.originalPath;
if (currentQuestPath == null)
{
return false;
Expand Down
6 changes: 3 additions & 3 deletions unity/Assets/Scripts/Quest/ActivateDialogMoM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ override public void CreateWindow(bool singleStep = false)
// ability text
string textKey = monster.currentActivation.effect.Replace("\\n", "\n");
// Add this to the log
Game.Get().quest.log.Add(new Quest.LogEntry(textKey.Replace("\n", "\\n")));
Game.Get().CurrentQuest.log.Add(new Quest.LogEntry(textKey.Replace("\n", "\\n")));
ui = new UIElement();
ui.SetLocation(10, offset, UIScaler.GetWidthUnits() - 20, 4);
ui.SetText(textKey);
Expand Down Expand Up @@ -77,7 +77,7 @@ public void CreateAttackWindow()
new UIElementBorder(ui);

// Add this to the log
Game.Get().quest.log.Add(new Quest.LogEntry(monster.currentActivation.masterActions.Replace("\n", "\\n")));
Game.Get().CurrentQuest.log.Add(new Quest.LogEntry(monster.currentActivation.masterActions.Replace("\n", "\\n")));

offset += 4.5f;

Expand Down Expand Up @@ -113,7 +113,7 @@ public void CreateMoveWindow()
new UIElementBorder(ui);

// Add this to the log
Game.Get().quest.log.Add(new Quest.LogEntry(monster.currentActivation.move.Replace("\n", "\\n")));
Game.Get().CurrentQuest.log.Add(new Quest.LogEntry(monster.currentActivation.move.Replace("\n", "\\n")));

offset += 4.5f;

Expand Down
4 changes: 2 additions & 2 deletions unity/Assets/Scripts/Quest/ChangePhaseWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public static void DisplayTransitionWindow(Quest.MoMPhase phase)
if (phase == Quest.MoMPhase.investigator)
{
// Draw pictures of investigators for investigator phase
float offset = (game.quest.GetHeroCount() - 1) * (-1 * offset_size / 2) - (offset_size / 2);
float offset = (game.CurrentQuest.GetHeroCount() - 1) * (-1 * offset_size / 2) - (offset_size / 2);
UIElement ui = null;
foreach (Quest.Hero h in game.quest.heroes)
foreach (Quest.Hero h in game.CurrentQuest.heroes)
{
if (h.heroData != null)
{
Expand Down
50 changes: 25 additions & 25 deletions unity/Assets/Scripts/Quest/DialogWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public DialogWindow(EventManager.Event e)
if (!eventData.qEvent.heroListName.Equals(""))
{
// Try to find the event
if (!game.quest.heroSelection.ContainsKey(eventData.qEvent.heroListName))
if (!game.CurrentQuest.heroSelection.ContainsKey(eventData.qEvent.heroListName))
{
ValkyrieDebug.Log("Warning: Hero selection in event: " + eventData.qEvent.sectionName + " from event " + eventData.qEvent.heroListName + " with no data.");
game.quest.log.Add(new Quest.LogEntry("Warning: Hero selection in event: " + eventData.qEvent.sectionName + " from event " + eventData.qEvent.heroListName + " with no data.", true));
game.CurrentQuest.log.Add(new Quest.LogEntry("Warning: Hero selection in event: " + eventData.qEvent.sectionName + " from event " + eventData.qEvent.heroListName + " with no data.", true));
}
else
{
// Get selection data from other event
foreach (Quest.Hero h in game.quest.heroSelection[eventData.qEvent.heroListName])
foreach (Quest.Hero h in game.CurrentQuest.heroSelection[eventData.qEvent.heroListName])
{
h.selected = true;
}
Expand All @@ -49,7 +49,7 @@ public DialogWindow(EventManager.Event e)
{
if (eventData.qEvent.quotaVar.Length > 0)
{
quota = Mathf.RoundToInt(game.quest.vars.GetValue(eventData.qEvent.quotaVar));
quota = Mathf.RoundToInt(game.CurrentQuest.vars.GetValue(eventData.qEvent.quotaVar));
}
CreateQuotaWindow();
}
Expand Down Expand Up @@ -95,7 +95,7 @@ public void CreateWindow()
}


var varManager = Game.Get().quest.vars;
var varManager = Game.Get().CurrentQuest.vars;

int num = 0;
foreach (EventButton eb in buttons)
Expand Down Expand Up @@ -224,9 +224,9 @@ public void DrawItem()

Game game = Game.Get();

if (!game.quest.itemSelect.ContainsKey(item)) return;
if (!game.CurrentQuest.itemSelect.ContainsKey(item)) return;

var selectedItemData = game.cd.Get<ItemData>(game.quest.itemSelect[item]);
var selectedItemData = game.cd.Get<ItemData>(game.CurrentQuest.itemSelect[item]);
Texture2D tex = ContentData.FileToTexture(selectedItemData.image);
Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect);

Expand Down Expand Up @@ -258,22 +258,22 @@ public void onQuota()
Game game = Game.Get();
if (eventData.qEvent.quotaVar.Length > 0)
{
game.quest.vars.SetValue(eventData.qEvent.quotaVar, quota);
game.CurrentQuest.vars.SetValue(eventData.qEvent.quotaVar, quota);
onButton(0);
return;
}

if (game.quest.eventQuota.ContainsKey(eventData.qEvent.sectionName))
if (game.CurrentQuest.eventQuota.ContainsKey(eventData.qEvent.sectionName))
{
game.quest.eventQuota[eventData.qEvent.sectionName] += quota;
game.CurrentQuest.eventQuota[eventData.qEvent.sectionName] += quota;
}
else
{
game.quest.eventQuota.Add(eventData.qEvent.sectionName, quota);
game.CurrentQuest.eventQuota.Add(eventData.qEvent.sectionName, quota);
}
if (game.quest.eventQuota[eventData.qEvent.sectionName] >= eventData.qEvent.quota)
if (game.CurrentQuest.eventQuota[eventData.qEvent.sectionName] >= eventData.qEvent.quota)
{
game.quest.eventQuota.Remove(eventData.qEvent.sectionName);
game.CurrentQuest.eventQuota.Remove(eventData.qEvent.sectionName);
onButton(0);
}
else
Expand All @@ -286,9 +286,9 @@ public void onQuota()
public void onCancel()
{
Destroyer.Dialog();
Game.Get().quest.eManager.currentEvent = null;
Game.Get().CurrentQuest.eManager.currentEvent = null;
// There may be a waiting event
Game.Get().quest.eManager.TriggerEvent();
Game.Get().CurrentQuest.eManager.TriggerEvent();
}

public void onButton(int num)
Expand All @@ -303,17 +303,17 @@ public void onButton(int num)
// If the user started this event button is undoable
if (eventData.qEvent.cancelable)
{
game.quest.Save();
game.CurrentQuest.Save();
}

// Add this to the log
game.quest.log.Add(new Quest.LogEntry(text.Replace("\n", "\\n")));
game.CurrentQuest.log.Add(new Quest.LogEntry(text.Replace("\n", "\\n")));

// Add this to the eventList
game.quest.eventList.Add(eventData.qEvent.sectionName);
game.CurrentQuest.eventList.Add(eventData.qEvent.sectionName);

// Event manager handles the aftermath
game.quest.eManager.EndEvent(num);
game.CurrentQuest.eManager.EndEvent(num);
}

// Check that the correct number of heroes are selected
Expand All @@ -324,7 +324,7 @@ public bool checkHeroes()
heroList = new List<Quest.Hero>();

// List all selected heroes
foreach (Quest.Hero h in game.quest.heroes)
foreach (Quest.Hero h in game.CurrentQuest.heroes)
{
if (h.selected)
{
Expand All @@ -337,18 +337,18 @@ public bool checkHeroes()
if (eventData.qEvent.minHeroes > heroList.Count) return false;

// Clear selection
foreach (Quest.Hero h in game.quest.heroes)
foreach (Quest.Hero h in game.CurrentQuest.heroes)
{
h.selected = false;
}

// If this event has previous selected heroes clear the data
if (game.quest.heroSelection.ContainsKey(eventData.qEvent.sectionName))
if (game.CurrentQuest.heroSelection.ContainsKey(eventData.qEvent.sectionName))
{
game.quest.heroSelection.Remove(eventData.qEvent.sectionName);
game.CurrentQuest.heroSelection.Remove(eventData.qEvent.sectionName);
}
// Add this selection to the quest
game.quest.heroSelection.Add(eventData.qEvent.sectionName, heroList);
game.CurrentQuest.heroSelection.Add(eventData.qEvent.sectionName, heroList);

// Update hero image state
game.heroCanvas.UpdateStatus();
Expand All @@ -372,7 +372,7 @@ public EventButton(QuestButtonData buttonData)
// Check format is valid
if ((colorRGB.Length != 7 && colorRGB.Length != 9) || (colorRGB[0] != '#'))
{
Game.Get().quest.log.Add(new Quest.LogEntry("Warning: Button color must be in #RRGGBB format or a known name", true));
Game.Get().CurrentQuest.log.Add(new Quest.LogEntry("Warning: Button color must be in #RRGGBB format or a known name", true));
}

// Hexadecimal to float convert (0x00-0xFF -> 0.0-1.0)
Expand Down
Loading

0 comments on commit b64d7e2

Please sign in to comment.