Skip to content

Commit

Permalink
Bugfix beta brynhildr 2.1.0b (#23)
Browse files Browse the repository at this point in the history
* #111 
- Fix issue with descent end screen not showing up: set a background image for end screen in Descent
- use originalPath in the stats: the quest name can change for quests with multiple scenarios so it's better to use the originalPath
- remove some logs
- scenario should not use default directory name
Only scenario with original names will get the rating screen at the end of the game, and can push stats. Current scenario using EditorScenario should be warned to change their scenario name.
-  only support packages

* #859 [MoM] Do not display button bar in the editor

* #893 Do not display autosave slot even when no saves exists yet

* #891 Fix Tokens being covered by object after save/load or undo

The type Dictionary<T1, T2> used to store the list of board items does not retain order.
The class OrderedDictionary does not exist unfortunately.
So add a 'sister' List of object name, and use this to write the savegame.

* Fix  #841:
Issue : I found if you are in the horror phase and open an item to inspect it. When you finish that event it ends the phase
  Fix :
  A new test has been added : if in horror phase and monster > 0, then do not end the round.
  In that case you will need to press next phase button to end the round (as you should).

  Please note I also have enabled the use of all elements during horror phase except for tokens, otherwise UI element can block the screen : they will be displayed, but you won't be able to remove them.
  I checked this, and this is the behavior of the official game app : you can use items during that phase.

* Fix  #892 Monster breaks investigator phase
Double check the validity of monster events before sending the event. By checking this, we can now directly go to horror phase and not get stuck in monster phase.
Fix tested with normal monsters, custom monsters, custominvalid monsters and combination of the three

*  #218 Log is inaccessible during Mythos Phase
Access to logs is now authorized

* FIX / EVO #842 #809 New load / save system bugfix and rework
- Make sure we don't get stuck in monster phase (this should never happen)
- Quest is now saved in save files only when required
- Quest is now saved in a separate thread to avoid long end of turn (new class ZipManager)
- Improve pre-loading of savegame list, create a preload directory in Temp directory for this
- secure path construction for quest within quest
- remove useless information in savefile and quest structure
- Do not try to extract when loading a scenario not packaged
- Remove old code
- fix missing new line in savegame for duration
- Fix issue where quest list screen would not appear when no quests have ever been downloaded
- Fix loading twice quest data
- fix issue with android extraction in subfolder
- clean code, remove logs, add interesting logs

* Cleanup code

* Small fix on French translation

* Cleanup on Path creation
  • Loading branch information
BenRQ committed Oct 7, 2018
1 parent 283d9af commit 08449f1
Show file tree
Hide file tree
Showing 25 changed files with 471 additions and 232 deletions.
54 changes: 43 additions & 11 deletions unity/Assets/Scripts/Content/ContentData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public static string ContentPath()
/// The path as a string without a trailing '/'.</returns>
public static string ImportPath()
{
return Game.AppData() + "/" + Game.Get().gameType.TypeName() + "/import";
return GameTypePath + Path.DirectorySeparatorChar + "import";
}

/// <summary>
Expand Down Expand Up @@ -85,6 +85,38 @@ public static string TempValyriePath
}
}

public static string GameTypePath
{
get
{
return Path.Combine(Game.AppData() , Game.Get().gameType.TypeName());
}
}

public static string ValkyrieLoadPath
{
get
{
return Path.Combine(TempValyriePath, "Load");
}
}

public static string ValkyriePreloadPath
{
get
{
return Path.Combine(TempValyriePath, "Preload");
}
}

public static string ValkyrieLoadQuestPath
{
get
{
return Path.Combine(ValkyrieLoadPath, "quest");
}
}

/// <summary>
/// Seach the provided path for all content packs and read meta data.</summary>
/// <param name="path">Path to search for content packs.</param>
Expand Down Expand Up @@ -156,23 +188,23 @@ public ContentData(string path)
public void PopulatePackList(string path)
{
// All packs must have a content_pack.ini, otherwise ignore
if (File.Exists(path + "/content_pack.ini"))
if (File.Exists(path + Path.DirectorySeparatorChar + "content_pack.ini"))
{
ContentPack pack = new ContentPack();

// Get all data from the file
IniData d = IniRead.ReadFromIni(path + "/content_pack.ini");
IniData d = IniRead.ReadFromIni(path + Path.DirectorySeparatorChar + "content_pack.ini");
// Todo: better error handling
if (d == null)
{
ValkyrieDebug.Log("Failed to get any data out of " + path + "/content_pack.ini!");
ValkyrieDebug.Log("Failed to get any data out of " + path + Path.DirectorySeparatorChar + "content_pack.ini!");
Application.Quit();
}

pack.name = d.Get("ContentPack", "name");
if (pack.name.Equals(""))
{
ValkyrieDebug.Log("Failed to get name data out of " + path + "/content_pack.ini!");
ValkyrieDebug.Log("Failed to get name data out of " + path + Path.DirectorySeparatorChar + "content_pack.ini!");
Application.Quit();
}

Expand All @@ -186,7 +218,7 @@ public void PopulatePackList(string path)
}
else
{
pack.image = path + "/" + d.Get("ContentPack", "image");
pack.image = path + Path.DirectorySeparatorChar + d.Get("ContentPack", "image");
}

// Black description isn't fatal
Expand All @@ -206,14 +238,14 @@ public void PopulatePackList(string path)
// Get all the other ini files in the pack
List<string> files = new List<string>();
// content_pack file is included
files.Add(path + "/content_pack.ini");
files.Add(path + Path.DirectorySeparatorChar + "content_pack.ini");

// No extra files is valid
if (d.Get("ContentPackData") != null)
{
foreach (string file in d.Get("ContentPackData").Keys)
{
files.Add(path + "/" + file);
files.Add(path + Path.DirectorySeparatorChar + file);
}
}
// Save list of files
Expand All @@ -233,7 +265,7 @@ public void PopulatePackList(string path)
{
dictFiles.Add(id, new List<string>());
}
dictFiles[id].Add(path + "/" + file);
dictFiles[id].Add(path + Path.DirectorySeparatorChar + file);
}
}
// Save list of files
Expand Down Expand Up @@ -1228,7 +1260,7 @@ public MonsterData(string name, Dictionary<string, string> content, string path)
}
else
{
imagePlace = path + "/" + content["imageplace"];
imagePlace = path + Path.DirectorySeparatorChar + content["imageplace"];
}
}
else // No image is a valid condition
Expand Down Expand Up @@ -1513,7 +1545,7 @@ public AudioData(string name, Dictionary<string, string> content, string path) :
}
else
{
file = path + "/" + content["file"];
file = path + Path.DirectorySeparatorChar + content["file"];
}
}
}
Expand Down
46 changes: 17 additions & 29 deletions unity/Assets/Scripts/Content/QuestData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ public class QuestData
// Location of the quest.ini file
public string questPath = "";

// Original package filename, this is required for quest with multiple quest
public string package_filename = "";

// Dictionary of items to rename on reading
public Dictionary<string, string> rename;

Expand All @@ -36,7 +33,7 @@ public class QuestData
// Create from quest loader entry
public QuestData(QuestData.Quest q)
{
questPath = q.path + "/quest.ini";
questPath = q.path + Path.DirectorySeparatorChar + "quest.ini";
LoadQuestData();
}

Expand All @@ -47,14 +44,6 @@ public QuestData(string path)
LoadQuestData();
}

// Read all data files and populate components for quest and save original package name (required for quest loaded from inside a quest)
public QuestData(string path, string package_filename)
{
questPath = path;
this.package_filename = package_filename;
LoadQuestData();
}

// Populate data
public void LoadQuestData()
{
Expand Down Expand Up @@ -112,7 +101,7 @@ public void LoadQuestData()
if (file != null && file.Length > 0)
{
// path is relative to the main file (absolute not supported)
localizationFiles.Add(Path.GetDirectoryName(questPath) + "/" + file);
localizationFiles.Add(Path.GetDirectoryName(questPath) + Path.DirectorySeparatorChar + file);
}
}
}
Expand All @@ -129,18 +118,6 @@ public void LoadQuestData()
}
LocalizationRead.AddDictionary("qst", qstDict);

// if package filename is already set, it means we are already in another quest: do not overwrite with data from sub-quest
if (package_filename == "") {
if (questIniData.Get("Package", "filename") != "")
{
package_filename = questIniData.Get("Package", "filename");
}
else
{
ValkyrieDebug.Log("Quest is not an archive");
}
}

foreach (string f in iniFiles)
{
string fullPath = Path.Combine(Path.GetDirectoryName(questPath), f);
Expand Down Expand Up @@ -1618,7 +1595,7 @@ public string GetImagePath()
// this will use the base monster type
return "";
}
return path + "/" + imagePath;
return path + Path.DirectorySeparatorChar + imagePath;
}
public string GetImagePlacePath()
{
Expand All @@ -1627,7 +1604,7 @@ public string GetImagePlacePath()
// this will use the base monster type
return "";
}
return path + "/" + imagePlace;
return path + Path.DirectorySeparatorChar + imagePlace;
}

// Save to string (editor)
Expand Down Expand Up @@ -1958,7 +1935,18 @@ public class Quest
public Quest(string pathIn)
{
path = pathIn;
Dictionary<string, string> iniData = IniRead.ReadFromIni(path + "/quest.ini", "Quest");
if (path.EndsWith("\\") || path.EndsWith("/"))
{
path = path.Substring(0, path.Length - 1);
}

Dictionary<string, string> iniData = IniRead.ReadFromIni(path + Path.DirectorySeparatorChar + "quest.ini", "Quest");
if (iniData == null)
{
ValkyrieDebug.Log("Could not load the quest.ini file in " + path + Path.DirectorySeparatorChar + "quest.ini");
valid = false;
return;
}

// do not parse the content of a quest from another game type
if (iniData.ContainsKey("type") && iniData["type"] != Game.Get().gameType.TypeName())
Expand All @@ -1968,7 +1956,7 @@ public Quest(string pathIn)
}

//Read the localization data
Dictionary<string, string> localizationData = IniRead.ReadFromIni(path + "/quest.ini", "QuestText");
Dictionary<string, string> localizationData = IniRead.ReadFromIni(path + Path.DirectorySeparatorChar + "quest.ini", "QuestText");

localizationDict = new DictionaryI18n(defaultLanguage);
foreach (string file in localizationData.Keys)
Expand Down
12 changes: 5 additions & 7 deletions unity/Assets/Scripts/Content/QuestDownload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class QuestDownload : MonoBehaviour
public Game game;
List<RemoteQuest> remoteQuests;
IniData localManifest;
Dictionary<string, Texture2D> textures;

/// <summary>
/// Download required files then draw screen
Expand All @@ -25,7 +24,6 @@ void Start()
{
new LoadingScreen(new StringKey("val", "DOWNLOAD_LIST").Translate());
game = Game.Get();
textures = new Dictionary<string, Texture2D>();
remoteQuests = new List<RemoteQuest>();
string remoteManifest = GetServerLocation() + "manifest.ini";
StartCoroutine(Download(remoteManifest, DownloadManifest));
Expand All @@ -38,7 +36,7 @@ void Start()
public static string GetServerLocation()
{
string[] text = File.ReadAllLines(ContentData.ContentPath() + "../text/download.txt");
return text[0] + Game.Get().gameType.TypeName() + "/";
return text[0] + Game.Get().gameType.TypeName() + Path.DirectorySeparatorChar;
}

/// <summary>
Expand Down Expand Up @@ -113,7 +111,7 @@ public void DrawList()

if (!formatOK) continue;

bool exists = File.Exists(saveLocation() + "/" + file);
bool exists = File.Exists(saveLocation() + Path.DirectorySeparatorChar + file);
bool update = true;
if (exists)
{
Expand Down Expand Up @@ -372,7 +370,7 @@ public void DrawList()

string file = kv.Key + ".valkyrie";
// Size is 1.2 to be clear of characters with tails
if (File.Exists(saveLocation() + "/" + file))
if (File.Exists(saveLocation() + Path.DirectorySeparatorChar + file))
{
ui = new UIElement(scrollArea.GetScrollTransform());
ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 8, 1.2f);
Expand Down Expand Up @@ -430,7 +428,7 @@ public void Selection(RemoteQuest rq)
/// <param file="file">File name to delete</param>
public void Delete(string file)
{
string toDelete = saveLocation() + "/" + file;
string toDelete = saveLocation() + Path.DirectorySeparatorChar + file;
File.Delete(toDelete);
Destroyer.Dialog();
DrawList();
Expand All @@ -445,7 +443,7 @@ public void Save(RemoteQuest rq)
QuestLoader.mkDir(saveLocation());

// Write to disk
using (BinaryWriter writer = new BinaryWriter(File.Open(saveLocation() + "/" + rq.name + ".valkyrie", FileMode.Create)))
using (BinaryWriter writer = new BinaryWriter(File.Open(saveLocation() + Path.DirectorySeparatorChar + rq.name + ".valkyrie", FileMode.Create)))
{
writer.Write(download.bytes);
writer.Close();
Expand Down
Loading

0 comments on commit 08449f1

Please sign in to comment.