Skip to content

Commit

Permalink
Rework book reader UI to use LocalizedBook data
Browse files Browse the repository at this point in the history
Book reader UI now only consumes LocalizedBook input. Classic book files are loaded as a fallback if localized file not found.
Removed LabelFormatter and reworked this functionality back into book reader.
Added /font, /color, /scale markup to string > RSC converter. These markup codes only supported in book reader.
Fixed OpenBook not checking file exists before trying to open so it can fallback to classic.
  • Loading branch information
Interkarma committed Nov 30, 2022
1 parent 45a5ee9 commit edd2a77
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 330 deletions.
6 changes: 5 additions & 1 deletion Assets/Scripts/API/TextFile.cs
Expand Up @@ -93,7 +93,7 @@ public static Token CreateFormatToken(Formatting format)
/// <summary>
/// Special Text Resource formatting bytes.
/// http://www.uesp.net/wiki/Daggerfall:Text_Record_Format
/// This is a work in progress.
/// New custom codes to be 0x100 and above
/// </summary>
public enum Formatting
{
Expand Down Expand Up @@ -122,6 +122,10 @@ public enum Formatting
SubrecordSeparator = 0xff,
EndOfRecord = 0xfe,

// Custom codes
Color = 0x100,
Scale = 0x101,

Nothing = 0xffff,
}

Expand Down
18 changes: 6 additions & 12 deletions Assets/Scripts/Game/LocalizedBook.cs
Expand Up @@ -120,9 +120,14 @@ public bool OpenLocalizedBookFile(string filename)
if (!fileNoExt.EndsWith(localizedFilenameSuffix))
filename = fileNoExt + localizedFilenameSuffix + fileExtension;

// Attempt to load file from StreamingAssets/Text/Books
// TODO: Also seek localized book file from mods

// Get path to localized book file and check it exists
string path = Path.Combine(Application.streamingAssetsPath, textFolderName, booksFolderName, filename);
if (!File.Exists(path))
return false;

// Attempt to load file from StreamingAssets/Text/Books
string[] lines = File.ReadAllLines(path);
if (lines == null || lines.Length == 0)
return false;
Expand Down Expand Up @@ -252,15 +257,4 @@ string ConvertTokensToString(TextFile.Token[] tokens)

return text;
}

/// <summary>
/// Convert book markup back to tokens.
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
TextFile.Token[] ConvertStringToTokens(string input)
{
// TODO:
return null;
}
}
270 changes: 0 additions & 270 deletions Assets/Scripts/Game/UserInterface/LabelFormatter.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Assets/Scripts/Game/UserInterface/LabelFormatter.cs.meta

This file was deleted.

0 comments on commit edd2a77

Please sign in to comment.