Skip to content

Commit

Permalink
Merge branch 'mod' into tsumi-mod
Browse files Browse the repository at this point in the history
# Conflicts:
#	Assets.Scripts.Core.Scene/SceneController.cs
#	Assets.Scripts.UI.Config/ConfigManager.cs
  • Loading branch information
drojf committed Mar 17, 2024
2 parents 86677ab + ced9302 commit 029941d
Show file tree
Hide file tree
Showing 17 changed files with 483 additions and 37 deletions.
2 changes: 2 additions & 0 deletions Assembly-CSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,14 @@
<Compile Include="MOD.Scripts.UI.ChapterJump\MODChapterJumpController.cs" />
<Compile Include="MOD.Scripts.UI.Tips\MODTipsController.cs" />
<Compile Include="MOD.Scripts.UI\MODCustomFlagPreset.cs" />
<Compile Include="MOD.Scripts.UI\MODFontAdjuster.cs" />
<Compile Include="MOD.Scripts.UI\MODKeyboardShortcuts.cs" />
<Compile Include="MOD.Scripts.UI\MODMainUIController.cs" />
<Compile Include="MOD.Scripts.UI\MODMenu.cs" />
<Compile Include="MOD.Scripts.UI\MODActions.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuAudioOptions.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuAudioSetup.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuFontConfig.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuSupport.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuModuleInterface.cs" />
<Compile Include="MOD.Scripts.UI\MODMenuNormal.cs" />
Expand Down
13 changes: 9 additions & 4 deletions Assets.Scripts.Core.Buriko/BurikoSaveManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,15 @@ private void GetSaveData(int slot, string path)
throw new FileLoadException("Save file does not appear to be valid! Invalid header.");
}
int num = binaryReader.ReadInt32();
if (num != 1)
{
throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
}
// Note: On 01-01-2024, Ch.8 removed the save version check, so that saves with a version other than 1
// could be loaded. Currently, there are only two versions 1 (initial version) and 2 (priority included in save file)
//
// Please note that this means older versions of the DLL won't be able to load new saves, so you won't be able to
// downgrade DLL version and keep your save after this.
// if (num != 1)
// {
// throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
// }
saveEntry2.Time = DateTime.FromBinary(binaryReader.ReadInt64());
string textJp = binaryReader.ReadString();
string text = saveEntry2.Text = binaryReader.ReadString();
Expand Down
24 changes: 22 additions & 2 deletions Assets.Scripts.Core.Buriko/BurikoScriptFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2854,8 +2854,7 @@ private BurikoVariable OperationMODSetMainFontOutlineWidth()
{
SetOperationType("MODSetMainFontOutlineWidth");
int width = ReadVariable().IntValue();
GameSystem.Instance.OutlineWidth = width / 100f;
GameSystem.Instance.MainUIController.TextWindow.outlineWidth = GameSystem.Instance.OutlineWidth;
MODFontAdjuster.SetFontOutlineWidth(width/100f);
return BurikoVariable.Null;
}

Expand Down Expand Up @@ -3015,6 +3014,27 @@ public BurikoVariable OperationMODGenericCall()
}
break;

case "NormalFontWeight":
if(int.TryParse(callParameters, out int normalFontWeightPercent))
{
MODFontAdjuster.SetNormalFontWeight(normalFontWeightPercent / 100.0f);
}
break;

case "BoldFontWeight":
if (int.TryParse(callParameters, out int boldFontWeightPercent))
{
MODFontAdjuster.SetBoldFontWeight(boldFontWeightPercent / 100.0f);
}
break;

case "FaceDilate":
if (int.TryParse(callParameters, out int faceDilate))
{
MODFontAdjuster.SetFaceDilation(faceDilate / 100.0f);
}
break;

default:
Logger.Log($"WARNING: Unknown ModGenericCall ID '{callID}'");
break;
Expand Down
7 changes: 5 additions & 2 deletions Assets.Scripts.Core.Buriko/BurikoScriptSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class BurikoScriptSystem : IScriptInterpreter

public bool FlowWasReached { get; private set; }

public static int SaveVersion = 1;

public static BurikoScriptSystem Instance
{
get;
Expand Down Expand Up @@ -238,7 +240,7 @@ public void TakeSaveSnapshot(string text = "")
using (BinaryWriter binaryWriter = new BinaryWriter(memoryStream))
{
binaryWriter.Write("MGSV".ToCharArray(0, 4));
binaryWriter.Write(1);
binaryWriter.Write(2);
binaryWriter.Write(DateTime.Now.ToBinary());
if (text == string.Empty)
{
Expand Down Expand Up @@ -359,8 +361,9 @@ public void LoadGame(int slotnum)
int num = binaryReader.ReadInt32();
if (num != 1)
{
throw new FileLoadException("Save file does not appear to be valid! Invalid version number.");
SaveVersion = num;
}
Debug.Log("Loading save from version: " + num);
binaryReader.ReadInt64();
string text = binaryReader.ReadString();
string text2 = binaryReader.ReadString();
Expand Down
16 changes: 13 additions & 3 deletions Assets.Scripts.Core.Scene/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,17 @@ public class Layer : MonoBehaviour

public bool FadingOut;

private float startRange;
private float startRange
{
get;
set;
}

private float targetRange;
private float targetRange
{
get;
set;
}

public Vector3 targetPosition = new Vector3(0f, 0f, 0f);

Expand Down Expand Up @@ -660,6 +668,7 @@ public void FadeTo(float alpha, float time)
iTween.Stop(base.gameObject);
startRange = targetRange;
targetRange = alpha;
targetAlpha = alpha;
iTween.ValueTo(base.gameObject, iTween.Hash("from", startRange, "to", targetRange, "time", time, "onupdate", "SetRange", "oncomplete", "FinishFade"));
}

Expand Down Expand Up @@ -776,6 +785,7 @@ public void ReloadTexture()

public void ReleaseTextures()
{
FadingOut = false;
if (!(primary == null))
{
ReleaseSecondaryTexture();
Expand All @@ -791,7 +801,6 @@ public void ReleaseTextures()
Object.Destroy(mesh);
mesh = null;
meshFilter.mesh = null;
FadingOut = false;
shaderType = 0;
targetAngle = 0f;
}
Expand Down Expand Up @@ -893,6 +902,7 @@ public void Serialize(BinaryWriter br)
br.Write(targetAlpha);
br.Write((int)alignment);
br.Write(shaderType);
br.Write(Priority);
}

private void Awake()
Expand Down
51 changes: 43 additions & 8 deletions Assets.Scripts.Core.Scene/SceneController.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Assets.Scripts.Core.Buriko;
using Assets.Scripts.Core.AssetManagement;
using MOD.Scripts.Core;
using MOD.Scripts.Core.Scene;
Expand Down Expand Up @@ -151,20 +152,37 @@ private void SetLayerActiveOnBothScenes(Layer layer)

public void ControlMotionOfSprite(int layer, MtnCtrlElement[] motions, int style)
{
Layer layer2 = GetLayer(layer);
layer2.ControlLayerMotion(motions);
Layer ifInUse = GetIfInUse(layer);
if (ifInUse == null)
{
Debug.LogWarning("Attempting to call ControlMotionOfSprite on layer " + layer + " but it is not active in the scene.");
}
else
{
ifInUse.ControlLayerMotion(motions);
}
}

public void MoveSprite(int layer, int x, int y, int z, int angle, int easetype, float alpha, float wait, bool isblocking)
{
Layer layer2 = GetLayer(layer);
layer2.MoveLayer(x, y, z, alpha, easetype, wait, isblocking, adjustAlpha: true);
layer2.SetAngle((float)angle, wait);
Layer ifInUse = GetIfInUse(layer);
if (ifInUse == null)
{
Debug.LogWarning("Attempting to call MoveSprite on layer " + layer + " but it is not active in the scene.");
return;
}
ifInUse.MoveLayer(x, y, z, alpha, easetype, wait, isblocking, adjustAlpha: true);
ifInUse.SetAngle(angle, wait);
}

public void MoveSpriteEx(int layer, string filename, Vector3[] points, float alpha, float time, bool isblocking)
{
Layer i = GetLayer(layer);
Layer i = GetIfInUse(layer);
if (i == null)
{
Debug.LogWarning("Attempting to call MoveSpriteEx on layer " + layer + " but it is not active in the scene.");
return;
}
if (filename != string.Empty)
{
i.CrossfadeLayer(filename, time, isblocking);
Expand All @@ -189,10 +207,17 @@ public void DrawBustshot(int layer, string textureName, int x, int y, int z, int
gameSystem.RegisterAction(delegate
{
Layer layer2 = GetLayer(layer);
int iterationCount = 0;
while (layer2.FadingOut)
{
layer2.HideLayer();
layer2 = GetLayer(layer);
iterationCount++;
if (iterationCount > 20)
{
Debug.LogWarning("We're trying to hide bustshot " + layer + " for DrawBustshot but for some reason it's stuck in a fading out state.");
break;
}
}
if (!move)
{
Expand Down Expand Up @@ -748,6 +773,10 @@ public void DeSerializeScene(MemoryStream ms)
binaryReader.ReadSingle();
binaryReader.ReadInt32();
binaryReader.ReadInt32();
if (BurikoScriptSystem.SaveVersion > 1)
{
binaryReader.ReadInt32();
}
DrawScene(backgroundfilename, 0.3f);
if (binaryReader.ReadBoolean())
{
Expand All @@ -757,6 +786,7 @@ public void DeSerializeScene(MemoryStream ms)
binaryReader.ReadSingle();
binaryReader.ReadInt32();
binaryReader.ReadInt32();
binaryReader.ReadInt32();
DrawFace(texture, 0f, isblocking: false);
}
for (int i = 0; i < 64; i++)
Expand All @@ -773,13 +803,18 @@ public void DeSerializeScene(MemoryStream ms)
float alpha = binaryReader.ReadSingle();
int num = binaryReader.ReadInt32();
int type = binaryReader.ReadInt32();
int priority = i;
if (BurikoScriptSystem.SaveVersion > 1)
{
priority = binaryReader.ReadInt32();
}
if (i != 50)
{
bool isBustshot = num != 0;
Layer layer = GetLayer(i);
UpdateLayerMask(layer, i);
UpdateLayerMask(layer, priority);
layer.DrawLayer(textureName, (int)position.x, (int)position.y, 0, null, alpha, isBustshot, type, 0f, isBlocking: false);
layer.SetPriority(i);
layer.SetPriority(priority);
layer.RestoreScaleAndPosition(scale, position);
}
}
Expand Down
10 changes: 9 additions & 1 deletion Assets.Scripts.UI.Config/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Assets.Scripts.Core;
using System;
using MOD.Scripts.UI;
using System.Collections;
using UnityEngine;

Expand Down Expand Up @@ -63,11 +64,18 @@ private IEnumerator DoOpen(int offscreen)
GameSystem.Instance.MainUIController.FadeOut(0.3f, false);
GameSystem.Instance.SceneController.HideFace(0.3f);
GameSystem.Instance.ExecuteActions();
if (GameSystem.Instance.ConfigMenuFontSize > 0)
RefreshFontSettings();
}

public void RefreshFontSettings()
{
if (GameSystem.Instance.ConfigMenuFontSize > 0 && panel != null)
{
foreach (TextRefresher text in Panel.GetComponentsInChildren<TextRefresher>())
{
text.SetFontWeight(MODFontAdjuster.GetNormalFontWeight());
text.SetFontSize(GameSystem.Instance.ConfigMenuFontSize);
text.SetFontOutlineWidth(GameSystem.Instance.OutlineWidth);
}
}
yield break;
Expand Down
1 change: 1 addition & 0 deletions Assets.Scripts.UI/MainUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -778,5 +778,6 @@ private static void GUIUnclickableTextArea(Rect rect, string text)
GUI.Label(rect, text, GUI.skin.textArea);
}


}
}
14 changes: 14 additions & 0 deletions MOD.Scripts.Core.Scene/MODLipsyncCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public static bool GetLastDrawInformation(int character, out LastDrawInformation

public static void SetLastDrawInformation(int character, int layer, string baseTextureName)
{
// Ignore any 'null' texture and print error message
if(baseTextureName == null)
{
MODLogger.Log($"WARNING: LastDrawInformationManager.SetLastDrawInformation called with baseTextureName = null (character: {character} layer: {layer})", true);
return;
}

if (character < lastDrawInformation.Length)
{
lastDrawInformation[character] = new LastDrawInformation(layer, baseTextureName);
Expand Down Expand Up @@ -218,6 +225,13 @@ public static bool LoadOrUseCache(Texture2D maybeBaseTexture, int character, out
return false;
}

// If the baseTextureName is null, we won't know what texture to load, so just give up
if(info.baseTextureName == null)
{
textureGroup = null;
return false;
}

if (cache.TryGetValue(info.baseTextureName, out TextureGroup cachedTextures))
{
DebugLog($"LoadOrUseCache() - Cache hit on [{info.baseTextureName}]");
Expand Down
Loading

0 comments on commit 029941d

Please sign in to comment.