Skip to content

Commit

Permalink
Merge branch 'mod' into oni-mod
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Sep 14, 2024
2 parents 559e849 + 9c14c49 commit 96e2eb9
Show file tree
Hide file tree
Showing 10 changed files with 358 additions and 266 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/build_dll.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ jobs:
uses: actions/checkout@v3

# Note: This uses the mono bundled with Ubuntu to build the project
- name: Compile project
- name: Compile Mod DLL
run: msbuild /p:Configuration=Release

- name: Compile standalone Higurashi Script Compiler
run: msbuild /p:Configuration=ScriptCompiler
429 changes: 212 additions & 217 deletions Assembly-CSharp.csproj

Large diffs are not rendered by default.

36 changes: 27 additions & 9 deletions Assets.Scripts.Core.AssetManagement/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ private bool CheckStreamingAssetsPathExists(string subFolder, string relativePat
/// Gets the path to an asset with the given name in the given artset, or null if none are found
/// </summary>
/// <returns>A path to an on-disk asset or null</returns>
public string PathToAssetWithName(string name, PathCascadeList artset)
private string PathToAssetWithName(string name, PathCascadeList artset, out string subFolderUsed)
{
int backgroundSetIndex = BurikoMemory.Instance.GetGlobalFlag("GBackgroundSet").IntValue();

Expand All @@ -232,6 +232,7 @@ public string PathToAssetWithName(string name, PathCascadeList artset)
{
if(CheckStreamingAssetsPathExists("OGBackgrounds", name, out string filePath))
{
subFolderUsed = "OGBackgrounds";
return filePath;
}
}
Expand All @@ -246,10 +247,12 @@ public string PathToAssetWithName(string name, PathCascadeList artset)

if (CheckStreamingAssetsPathExists(artSetPath, name, out string filePath))
{
subFolderUsed = artSetPath;
return filePath;
}
}

subFolderUsed = null;
return null;
}

Expand Down Expand Up @@ -467,25 +470,40 @@ public Texture2D LoadTexture(string textureName)
return LoadTexture(textureName, out _);
}

public Texture2D LoadTexture(string textureName, out string texturePath)
public string PathToAssetFromTextureNameNoExt(string textureNameNoExt) => PathToAssetFromTextureNameNoExt(textureNameNoExt, out _);

/// <summary>
/// Given the name of a texture (like "white" or "sprite/re2a_okoru_a1_0"), returns the path to the texture like
/// "D:/games/steam/steamapps/common/Higurashi When They Cry Hou - Ch.6 Tsumihoroboshi/HigurashiEp06_Data/StreamingAssets\CG\white.png")
/// The current language and current artset will determine which file extension/which subfolder the image will be taken from.
/// </summary>
public string PathToAssetFromTextureNameNoExt(string textureNameNoExt, out string subFolderUsed)
{
if (textureName == "windo_filter" && windowTexture != null)
{
texturePath = windowTexturePath;
return windowTexture;
}
string path = null;
subFolderUsed = null;

// Load path from current artset
if (path == null && !GameSystem.Instance.UseEnglishText)
{
path = PathToAssetWithName(textureName.ToLower() + "_j.png", CurrentArtset);
path = PathToAssetWithName(textureNameNoExt.ToLower() + "_j.png", CurrentArtset, out subFolderUsed);
}

if (path == null)
{
path = PathToAssetWithName(textureName.ToLower() + ".png", CurrentArtset);
path = PathToAssetWithName(textureNameNoExt.ToLower() + ".png", CurrentArtset,out subFolderUsed);
}

return path;
}

public Texture2D LoadTexture(string textureName, out string texturePath)
{
if (textureName == "windo_filter" && windowTexture != null)
{
texturePath = windowTexturePath;
return windowTexture;
}
string path = PathToAssetFromTextureNameNoExt(textureName);

if (path == null)
{
Expand Down
12 changes: 10 additions & 2 deletions Assets.Scripts.Core.Scene/SceneController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,9 +1084,17 @@ public void MODLipSyncStart(int character, int audiolayer, string audiofile, Aud
StartCoroutine(MODLipSyncCoroutine);
}

private bool MODSkipImage(string backgroundfilename)
private bool MODSkipImage(string textureName)
{
if(Buriko.BurikoMemory.Instance.GetGlobalFlag("GHideCG").IntValue() == 1 && backgroundfilename.Contains("scene/"))
// We only want to skip Console CGs (in the "CG" folder), so ignore images not in the "CG" folder.
AssetManager.Instance.PathToAssetFromTextureNameNoExt(textureName, out string subFolderUsed);
if (subFolderUsed == null || subFolderUsed != "CG")
{
return false;
}

// In the game script, Console CG names always start with "scene/" folder, like "scene/303c"
if (Buriko.BurikoMemory.Instance.GetGlobalFlag("GHideCG").IntValue() == 1 && textureName.StartsWith("scene/"))
{
return true;
}
Expand Down
12 changes: 11 additions & 1 deletion BGICompiler.Compiler/LoggerWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@ public static void LogError(object message)
print("ERROR", message);
}

public static void LogException(Exception exception)
{
print("EXCEPTION", exception);
}

private static void print(string level, object message)
{
Console.WriteLine($"[{level}] {message}", message);
Console.WriteLine($"[{level}] {message}");
}
#else
public static void Log(object message)
Expand All @@ -39,6 +44,11 @@ public static void LogError(object message)
{
UnityEngine.Debug.Log(message);
}

public static void LogException(Exception exception)
{
UnityEngine.Debug.LogException(exception);
}
#endif
}
}
35 changes: 12 additions & 23 deletions MOD.Scripts.AssetManager/MODAssetManager.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#define USE_DATE

using Newtonsoft.Json;
using MOD.Scripts.Core.MODXMLWrapper;
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using BGICompiler.Compiler.Logger;

class MODCompileRequiredDetector
public class MODCompileRequiredDetector
{
private class ScriptInfo
public class ScriptInfo
{
public string name;
public string name { get; set; }
#if USE_DATE
public DateTime lastWriteTime;
public DateTime lastWriteTime { get; set; }
#endif
public long length;
public string md5String;
public long length { get; set; }
public string md5String { get; set; }

public static ScriptInfo TryGetOrNull(string path)
{
Expand Down Expand Up @@ -55,16 +55,14 @@ public static ScriptInfo TryGetOrNull(string path)
readonly Dictionary<string, ScriptInfo> oldTxtInfoDictionary;
readonly Dictionary<string, ScriptInfo> newTxtInfoDictionary;
readonly List<string> successfullyCompiledScriptNameList;
readonly JsonSerializer jsonSerializer;
readonly string txtInfoDictionaryPath;

public MODCompileRequiredDetector(string destDir)
{
oldTxtInfoDictionary = new Dictionary<string, ScriptInfo>();
newTxtInfoDictionary = new Dictionary<string, ScriptInfo>();
successfullyCompiledScriptNameList = new List<string>();
jsonSerializer = new JsonSerializer();
txtInfoDictionaryPath = Path.Combine(destDir, "txtInfoDictionary.json");
txtInfoDictionaryPath = Path.Combine(destDir, "txtInfoDictionary.xml");
}

public void Load()
Expand All @@ -73,16 +71,11 @@ public void Load()
{
if (File.Exists(txtInfoDictionaryPath))
{
using (StreamReader sw = new StreamReader(txtInfoDictionaryPath))
using (JsonReader reader = new JsonTextReader(sw))
List<ScriptInfo> scriptInfoList = MODXMLWrapper.Deserialize<List<ScriptInfo>>(txtInfoDictionaryPath);
foreach (ScriptInfo info in scriptInfoList)
{
List<ScriptInfo> scriptInfoList = jsonSerializer.Deserialize<List<ScriptInfo>>(reader);
foreach (ScriptInfo info in scriptInfoList)
{
oldTxtInfoDictionary[info.name] = info;
}
oldTxtInfoDictionary[info.name] = info;
}

}
}
catch (Exception e)
Expand All @@ -108,11 +101,7 @@ public void Save()
}

// save scriptInfoDictionary to file as at least one .txt file has changed and succesfully been compiled
using (StreamWriter sw = new StreamWriter(txtInfoDictionaryPath))
using (JsonTextWriter writer = new JsonTextWriter(sw))
{
jsonSerializer.Serialize(writer, txtInfoToSave);
}
MODXMLWrapper.Serialize(txtInfoDictionaryPath, txtInfoToSave);
}

// Save to memory that a .txt file has been compiled or has already been compiled in the past
Expand Down
10 changes: 5 additions & 5 deletions MOD.Scripts.Core/MODLocalizationData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public partial class Loc
public static string MODMenuNormal_27 => Get("MODMenuNormal_27", "Enables opening videos\n\nNOTE: Once the opening video plays the first time, will automatically switch to 'Launch + In-Game'\n\nWe have setup openings this way to avoid spoilers.");
public static string MODMenuNormal_28 => Get("MODMenuNormal_28", "Launch + In-Game");
public static string MODMenuNormal_29 => Get("MODMenuNormal_29", "WARNING: There is usually no need to set this manually.\n\nIf openings are enabled, the first time you reach an opening while playing the game, this flag will be set automatically\n\nThat is, after the opening is played the first time, from then on openings will play every time the game launches");
public static string MODMenuNormal_30 => Get("MODMenuNormal_30", "Show/Hide CGs");
public static string MODMenuNormal_31 => Get("MODMenuNormal_31", "Show CGs");
public static string MODMenuNormal_32 => Get("MODMenuNormal_32", "Shows CGs (You probably want this enabled for Console ADV/NVL mode)");
public static string MODMenuNormal_33 => Get("MODMenuNormal_33", "Hide CGs");
public static string MODMenuNormal_34 => Get("MODMenuNormal_34", "Disables all CGs (mainly for use with the Original/Ryukishi preset)");
public static string MODMenuNormal_30 => Get("MODMenuNormal_30", "Console CGs");
public static string MODMenuNormal_31 => Get("MODMenuNormal_31", "Show Console CGs");
public static string MODMenuNormal_32 => Get("MODMenuNormal_32", "Shows Console CGs (You want this enabled for Console ADV/NVL mode)\n\nDoes not impact Mangagamer or OG CGs.");
public static string MODMenuNormal_33 => Get("MODMenuNormal_33", "Hide Console CGs");
public static string MODMenuNormal_34 => Get("MODMenuNormal_34", "Disables Console CGs (for use with the Original/Ryukishi preset)\n\nDoes not impact Mangagamer or OG CGs.");
public static string MODMenuNormal_35 => Get("MODMenuNormal_35", "Background Style");
public static string MODMenuNormal_36 => Get("MODMenuNormal_36", "Console BGs");
public static string MODMenuNormal_37 => Get("MODMenuNormal_37", "Use Console backgrounds");
Expand Down
45 changes: 45 additions & 0 deletions MOD.Scripts.Core/MODXMLWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using BGICompiler.Compiler.Logger;

namespace MOD.Scripts.Core.MODXMLWrapper
{
internal class MODXMLWrapper
{
static public void Serialize<T>(string outputPath, T objectToSerialize)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
TextWriter writer = new StreamWriter(outputPath);
serializer.Serialize(writer, objectToSerialize);
writer.Close();
}

static private void serializer_UnknownNode(object sender, XmlNodeEventArgs e)
{
Debug.Log("MODXMLWrapper - Unknown Node:" + e.Name + "\t" + e.Text);
}

static private void serializer_UnknownAttribute(object sender, XmlAttributeEventArgs e)
{
Debug.Log("MODXMLWrapper - Unknown attribute " + e.Attr.Name + "='" + e.Attr.Value + "'");
}

static public T Deserialize<T>(string inputPath)
{
XmlSerializer serializer = new XmlSerializer(typeof(T));

serializer.UnknownNode += new
XmlNodeEventHandler(serializer_UnknownNode);
serializer.UnknownAttribute += new
XmlAttributeEventHandler(serializer_UnknownAttribute);

FileStream fs = new FileStream(inputPath, FileMode.Open);

return (T)serializer.Deserialize(fs);
}
}
}
6 changes: 3 additions & 3 deletions MOD.Scripts.UI/MODMenuNormal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public MODMenuNormal(MODMenu modMenu, MODMenuAudioOptions audioOptionsMenu)
new GUIContent(Loc.MODMenuNormal_28, Loc.MODMenuNormal_29), //Launch + In-Game | WARNING: There is usually no need to set this manually.\n\nIf openings are enabled, the first time you reach an opening while playing the game, this flag will be set automatically\n\nThat is, after the opening is played the first time, from then on openings will play every time the game launches
});

radioHideCG = new MODRadio(Loc.MODMenuNormal_30, new GUIContent[] //Show/Hide CGs
radioHideCG = new MODRadio(Loc.MODMenuNormal_30, new GUIContent[] //Console CGs
{
new GUIContent(Loc.MODMenuNormal_31, Loc.MODMenuNormal_32), //Show CGs | Shows CGs (You probably want this enabled for Console ADV/NVL mode)
new GUIContent(Loc.MODMenuNormal_33, Loc.MODMenuNormal_34), //Hide CGs | Disables all CGs (mainly for use with the Original/Ryukishi preset)
new GUIContent(Loc.MODMenuNormal_31, Loc.MODMenuNormal_32), //Show Console CGs | Shows Console CGs (You want this enabled for Console ADV/NVL mode)\n\nDoes not impact Mangagamer or OG CGs.
new GUIContent(Loc.MODMenuNormal_33, Loc.MODMenuNormal_34), //Hide Console CGs | Disables Console CGs (for use with the Original/Ryukishi preset)\n\nDoes not impact Mangagamer or OG CGs.
});

radioBackgrounds = new MODRadio(Loc.MODMenuNormal_35, new GUIContent[]{ //Background Style
Expand Down
34 changes: 29 additions & 5 deletions tools/localization.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
"text": "ddd MMM dd, yyyy h:mm tt",
"comment": "The 'text' field sets the displayed date time format for save files, for example 'ddd MMM dd, yyyy h:mm tt'. See https://github.com/07th-mod/higurashi-assembly/issues/109 for more details."
},
"HouPlusWideMenuButtons": {
"text": "-1.0",
"comment": "To enable, set to the opacity you want for the title menu button when it is hovered, eg '0.5'. For Hou+ the main menu contains one is very wide (button hovered), and one only is as long as the english text (button not hovered). Translators may be unable to fit the text in the short UI file, so I've added a mode which only uses the long button, and uses the engine to give a fade effect when you hover the button. Setting a negative value uses the normal menu."
},
"ExampleEntry": {
"text": "This text will displayed by default.",
"textJP": "This text will be displayed when the language is changed to Japanese in-game.",
Expand Down Expand Up @@ -159,19 +163,19 @@
"text": "WARNING: There is usually no need to set this manually.\n\nIf openings are enabled, the first time you reach an opening while playing the game, this flag will be set automatically\n\nThat is, after the opening is played the first time, from then on openings will play every time the game launches"
},
"MODMenuNormal_30": {
"text": "Show/Hide CGs"
"text": "Console CGs"
},
"MODMenuNormal_31": {
"text": "Show CGs"
"text": "Show Console CGs"
},
"MODMenuNormal_32": {
"text": "Shows CGs (You probably want this enabled for Console ADV/NVL mode)"
"text": "Shows Console CGs (You want this enabled for Console ADV/NVL mode)\n\nDoes not impact Mangagamer or OG CGs."
},
"MODMenuNormal_33": {
"text": "Hide CGs"
"text": "Hide Console CGs"
},
"MODMenuNormal_34": {
"text": "Disables all CGs (mainly for use with the Original/Ryukishi preset)"
"text": "Disables Console CGs (for use with the Original/Ryukishi preset)\n\nDoes not impact Mangagamer or OG CGs."
},
"MODMenuNormal_35": {
"text": "Background Style"
Expand Down Expand Up @@ -675,6 +679,26 @@
},
"MODMenuSupportCompileFailed_24": {
"text": "It is NOT RECOMMENDED to continue playing despite this error. The game may seem to be OK, but once you reach the script which failed to compile, the game may restart, or you may get severe graphical glitches or skip forward in the story unexpectedly."
},
"MusicBoxRepeat": {
"text": "Repeat",
"textJP": "1曲リピート",
"comment": "Music box button (hou+)"
},
"MusicBoxShuffle": {
"text": "Shuffle",
"textJP": "気まぐれ演奏",
"comment": "Music box button (hou+)"
},
"MusicBoxPlayAll": {
"text": "PlayAll",
"textJP": "全曲演奏",
"comment": "Music box button (hou+)"
},
"MusicBoxTitle": {
"text": "[Title]",
"textJP": "【Title】",
"comment": "Music box button (hou+)"
}
}
}

0 comments on commit 96e2eb9

Please sign in to comment.