Skip to content

Commit

Permalink
Merge branch 'mod' into tata-mod
Browse files Browse the repository at this point in the history
  • Loading branch information
drojf committed Jan 24, 2023
2 parents e6d285d + e6b498e commit c8e0196
Show file tree
Hide file tree
Showing 18 changed files with 277 additions and 51 deletions.
1 change: 1 addition & 0 deletions Assets.Scripts.Core.Buriko/BurikoMemory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public BurikoMemory()
variableReference.Add("GStretchBackgrounds", 527);
variableReference.Add("GBackgroundSet", 528);
variableReference.Add("GAudioSet", 529);
variableReference.Add("GRyukishiMode43Aspect", 530);

// 611 - 619 used for additional chapter progress info
SetGlobalFlag("GMessageSpeed", 60);
Expand Down
2 changes: 1 addition & 1 deletion Assets.Scripts.Core.Buriko/BurikoScriptFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,6 @@ private BurikoVariable OperationSelect()
}
gameSystem.DisplayChoices(stringList, num);
gameSystem.ExecuteActions();
gameSystem.AddWait(new Wait(1f, WaitTypes.WaitForTime, null));
return null;
}

Expand Down Expand Up @@ -1931,6 +1930,7 @@ private BurikoVariable OperationSetScreenAspect()
SetOperationType("SetScreenAspect");
string s = ReadVariable().StringValue();
float newratio = 1f / float.Parse(s, CultureInfo.InvariantCulture);
gameSystem.SetDefaultAspect(newratio);
gameSystem.UpdateAspectRatio(newratio);
return BurikoVariable.Null;
}
Expand Down
46 changes: 36 additions & 10 deletions Assets.Scripts.Core.Scene/Layer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,16 +334,42 @@ private void EnsureCorrectlySizedMesh(int width, int height, LayerAlignment alig
bool stretchToFit = false;
if (texturePath != null)
{
// We want to clamp sprites to 4:3 if you are using the OG backgrounds, and you are not stretching the background
ryukishiClamp = isBustShot &&
Buriko.BurikoMemory.Instance.GetGlobalFlag("GBackgroundSet").IntValue() == 1 && // Using OG Backgrounds AND
Buriko.BurikoMemory.Instance.GetGlobalFlag("GStretchBackgrounds").IntValue() == 0 && // Not stretching backgrounds AND
(texturePath.Contains("sprite/") ||
texturePath.Contains("sprite\\") ||
texturePath.Contains("portrait/") ||
texturePath.Contains("portrait\\")); // Is a sprite or portrait image. I don't think we can rely only on isBustShot, as sometimes non-sprites are drawn with isBustShot

stretchToFit = Buriko.BurikoMemory.Instance.GetGlobalFlag("GStretchBackgrounds").IntValue() == 1 && texturePath.Contains("OGBackgrounds");
bool isSpriteOrPortrait = texturePath.Contains("sprite/") ||
texturePath.Contains("sprite\\") ||
texturePath.Contains("portrait/") ||
texturePath.Contains("portrait\\");

if (Buriko.BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
// When using true 4:3 mode, we don't need to clamp the sprites, as they are automatically cut off by the viewport
ryukishiClamp = false;

// When using true 4:3 aspect mode, any 16:9 images (except for sprites) should be squished to 4:3.
// This make sure any text or other images don't get cut off
// We could letter-box the images, but in some cases whatever is behind the image may show up? Not sure.
stretchToFit = !isSpriteOrPortrait;

// Do not stretch if the image is more than 5% off a 16:9 aspect ratio.
// Likely these are special images like credits images or effect images.
float targetAspect = 16f / 9f;
float imageAspect = (float)width / (float)height;
Debug.Log($"{texturePath}: aspect: {imageAspect} ref: {targetAspect}");
if(imageAspect > targetAspect * 1.05 || imageAspect < targetAspect * .95f)
{
stretchToFit = false;
}
}
else
{
// We want to clamp sprites to 4:3 if you are using the OG backgrounds, and you are not stretching the background
ryukishiClamp = isBustShot &&
Buriko.BurikoMemory.Instance.GetGlobalFlag("GBackgroundSet").IntValue() == 1 && // Using OG Backgrounds AND
Buriko.BurikoMemory.Instance.GetGlobalFlag("GStretchBackgrounds").IntValue() == 0 && // Not stretching backgrounds AND
isSpriteOrPortrait; // Is a sprite or portrait image. I don't think we can rely only on isBustShot, as sometimes non-sprites are drawn with isBustShot

// When using old backgrounds with stretch backgrounds enabled, stretch old 4:3 backgrounds to 16:9 to fill the screen
stretchToFit = Buriko.BurikoMemory.Instance.GetGlobalFlag("GStretchBackgrounds").IntValue() == 1 && texturePath.Contains("OGBackgrounds");
}
}

if (mesh == null ||
Expand Down
15 changes: 12 additions & 3 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.AssetManagement;
using MOD.Scripts.Core;
using MOD.Scripts.Core.Scene;
using System;
Expand Down Expand Up @@ -874,7 +875,7 @@ private IEnumerator MODBakedLipSync(string path, int character, ulong coroutineI
streamReader.Close();
for (int k = 0; k < exparray.Length; k++)
{
if (!MODSystem.instance.modSceneController.MODLipSyncAnimationStillActive(character, coroutineId))
if (!MODSystem.instance.modSceneController.MODLipSyncAnimationStillActive(character, coroutineId) || !MODSystem.instance.modSceneController.MODLipSyncIsEnabled())
{
break;
}
Expand Down Expand Up @@ -927,7 +928,7 @@ private IEnumerator MODComputedLipSync(int character, int audiolayer, AudioClip
for (int chunk = 0; chunk < 10 * numChunks; chunk++)
{
// Forcibly stop the lipsync animation if it's not meant to be playing at this time?
if (!MODSystem.instance.modSceneController.MODLipSyncAnimationStillActive(character, coroutineId))
if (!MODSystem.instance.modSceneController.MODLipSyncAnimationStillActive(character, coroutineId) || !MODSystem.instance.modSceneController.MODLipSyncIsEnabled())
{
break;
}
Expand Down Expand Up @@ -1031,7 +1032,15 @@ public IEnumerator MODDrawLipSync(int character, int audiolayer, string audiofil
}
}

MODSystem.instance.modSceneController.MODLipSyncProcess(character, exp4, coroutineId);
// Most of the time we want to reset the sprite back to the 'default' pose when lipsync finishes (even if the
// lipsync option is already 'disabled') to prevent having a character with their mouth stuck open.
//
// However, if artset is changed while lipsync in progress (for example to OG sprites), then we don't want to
// overwrite the OG sprite's texture with the Console texture.
if(AssetManager.Instance.CurrentArtsetIndex == 0)
{
MODSystem.instance.modSceneController.MODLipSyncProcess(character, exp4, coroutineId);
}
}

public void MODLipSyncStart(int character, int audiolayer, string audiofile, AudioClip audioClip)
Expand Down
1 change: 1 addition & 0 deletions Assets.Scripts.Core.TextWindow/TextController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ public void ClearText()
englishtext = string.Empty;
japanesetext = string.Empty;
txt = string.Empty;
gameSystem.MainUIController.HideCarret();
AudioController.Instance.ClearVoiceQueue();
}

Expand Down
20 changes: 19 additions & 1 deletion Assets.Scripts.Core/GameSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ public bool IsFullscreen

private bool hasBrokenWindowResize;

private float defaultAspect;

private float _configMenuFontSize = 0;
public float ConfigMenuFontSize
{
Expand Down Expand Up @@ -341,9 +343,25 @@ public void PostLoading()
MainUIController.InitializeModMenu(this);
}

public void SetDefaultAspect(float defaultAspect)
{
this.defaultAspect = defaultAspect;
}

public void UpdateAspectRatio() => UpdateAspectRatio(defaultAspect);

public void UpdateAspectRatio(float newratio)
{
AspectRatio = newratio;

if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
AspectRatio = 4f / 3f;
}

// Text window may need to be resized to fit different screen size due to aspect ratio change
MODActions.SetTextWindowAppearance((MODActions.ModPreset)MODActions.GetADVNVLRyukishiModeFromFlags(), showInfoToast: false);

if (!IsFullscreen)
{
int width = Mathf.RoundToInt((float)Screen.height * AspectRatio);
Expand Down Expand Up @@ -487,7 +505,7 @@ public void CloseChoiceIfExists()
public void LeaveChoices()
{
PopStateStack();
AddWait(new Wait(0.5f, WaitTypes.WaitForTime, delegate
AddWait(new Wait(ChoiceButton.fadeTime, WaitTypes.WaitForTime, delegate
{
ChoiceController.Destroy();
ChoiceController = null;
Expand Down
24 changes: 20 additions & 4 deletions Assets.Scripts.UI.Choice/ChoiceButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ public class ChoiceButton : MonoBehaviour

public UITweener ColorTweener;

private float fadeInTime = 0.5f;
public static float fadeTime = .25f;
private float tweenTimer;

// This prevents the user selecting a choice before the choices are fully loaded
private float fadeInTime = fadeTime/2;

private ClickCallback clickCallback;

Expand Down Expand Up @@ -43,7 +47,8 @@ private void FadeToAlpha(float alpha)
{
LeanTween.cancel(base.gameObject);
Color color = ButtonTextMesh.color;
LeanTween.value(base.gameObject, UpdateAlpha, color.a, alpha, fadeInTime);
tweenTimer = fadeTime;
LeanTween.value(base.gameObject, UpdateAlpha, color.a, alpha, tweenTimer);
}

private void OnClick()
Expand All @@ -60,7 +65,7 @@ private void OnClick()

private void OnHover(bool ishover)
{
if (GameSystem.Instance.GameState == GameState.ChoiceScreen)
if (GameSystem.Instance.GameState == GameState.ChoiceScreen && isEnabled)
{
if (ishover)
{
Expand Down Expand Up @@ -116,7 +121,18 @@ private void Start()

private void Update()
{
fadeInTime -= Time.deltaTime;
if(tweenTimer > 0)
{
tweenTimer -= Time.deltaTime;
}

if(fadeInTime > 0)
{
fadeInTime -= Time.deltaTime;
}
}

public float GetFontSize() => ButtonTextMesh.fontSize;
public void SetFontSize(float fontSize) => ButtonTextMesh.fontSize = fontSize;
}
}
4 changes: 4 additions & 0 deletions Assets.Scripts.UI.Choice/ChoiceController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ public void Create(List<string> optstrings, int count)
}
ChoiceButton component = gameObject2.GetComponent<ChoiceButton>();
component.ChangeText(optstrings[i]);
if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
component.SetFontSize(component.GetFontSize() * .75f);
}
component.SetCallback(this, delegate
{
GameSystem.Instance.ScriptSystem.SetFlag("SelectResult", id);
Expand Down
12 changes: 6 additions & 6 deletions Assets.Scripts.UI.Config/ConfigSlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ private void Set()
switch (base.name) // All slider labels match original order, functionality in comment
{
case "0-TextSpeed": // Window Opacity:
num = (int)(GameSystem.Instance.MessageWindowOpacity * 100f);
num = BurikoMemory.Instance.GetGlobalFlag("GWindowOpacity").IntValue();
break;
case "1-AutoSpeed": // Voice Volume:
num = (int)(GameSystem.Instance.AudioController.VoiceVolume * 100f);
num = BurikoMemory.Instance.GetGlobalFlag("GVoiceVolume").IntValue();
break;
case "2-AutoPageSpeed": // BGM Volume
num = (int)(GameSystem.Instance.AudioController.BGMVolume * 100f);
num = BurikoMemory.Instance.GetGlobalFlag("GBGMVolume").IntValue();
break;
case "3-WindowOpacity": // SE Volume
num = (int)(GameSystem.Instance.AudioController.SoundVolume * 100f);
num = BurikoMemory.Instance.GetGlobalFlag("GSEVolume").IntValue();
break;
case "4-BGMVolume": // Text / Auto text speed
num = GameSystem.Instance.TextController.TextSpeed;
num = BurikoMemory.Instance.GetGlobalFlag("GMessageSpeed").IntValue();
break;
case "5-SEVolume": // Auto Page Speed
num = GameSystem.Instance.TextController.AutoPageSpeed;
num = BurikoMemory.Instance.GetGlobalFlag("GAutoAdvSpeed").IntValue();
break;
}
slider.value = (float)num / 100f;
Expand Down
4 changes: 4 additions & 0 deletions MOD.Scripts.UI/MODActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public static void SetGraphicsPreset(ModPreset setting, bool showInfoToast = tru
{
MODMainUIController mODMainUIController = new MODMainUIController();

// Always reset experimental 4:3 mode when setting any preset
BurikoMemory.Instance.SetGlobalFlag("GRyukishiMode43Aspect", 0);
GameSystem.Instance.UpdateAspectRatio();

BurikoMemory.Instance.GetCustomFlagPresetInstance().DisablePresetAndSavePresetToMemory();
if (setting == ModPreset.Console)
{
Expand Down
27 changes: 27 additions & 0 deletions MOD.Scripts.UI/MODMainUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,12 @@ public void RyukishiGuiPositionLoad(int posx, int posy)

public void WideGuiPositionStore()
{
if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
RyukishiGuiPositionStore();
return;
}

GameSystem.Instance.MainUIController.UpdateGuiPosition(WideModeGuiPosX, WideModeGuiPosY);
}

Expand Down Expand Up @@ -250,6 +256,14 @@ public void ADVModeSettingStore()
int aDVModeCharSpacing = ADVModeCharSpacing;
int aDVModeLineSpacing = ADVModeLineSpacing;
int aDVModeFontSize = ADVModeFontSize;

if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
aDVModeWindowPosX = RyukishiModeWindowPosX - 20;
aDVModeWindowSizeX = RyukishiModeWindowSizeX - 60;
aDVModeFontSize = ADVModeFontSize * 85 / 100;
}

GameSystem.Instance.TextController.NameFormat = aDVModeNameFormat;
GameSystem.Instance.MainUIController.SetWindowPos(aDVModeWindowPosX, aDVModeWindowPosY);
GameSystem.Instance.MainUIController.SetWindowSize(aDVModeWindowSizeX, aDVModeWindowSizeY);
Expand All @@ -275,6 +289,13 @@ public void NVLModeSettingStore()
int nVLModeCharSpacing = NVLModeCharSpacing;
int nVLModeLineSpacing = NVLModeLineSpacing;
int nVLModeFontSize = NVLModeFontSize;

if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
nVLModeWindowPosX = RyukishiModeWindowPosX;
nVLModeWindowSizeX = RyukishiModeWindowSizeX - 100;
}

GameSystem.Instance.TextController.NameFormat = nVLModeNameFormat;
GameSystem.Instance.MainUIController.SetWindowPos(nVLModeWindowPosX, nVLModeWindowPosY);
GameSystem.Instance.MainUIController.SetWindowSize(nVLModeWindowSizeX, nVLModeWindowSizeY);
Expand All @@ -287,6 +308,12 @@ public void NVLModeSettingStore()

public void NVLADVModeSettingStore()
{
if (BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
RyukishiModeSettingStore();
return;
}

string nVLADVModeNameFormat = NVLADVModeNameFormat;
int nVLADVModeWindowPosX = NVLADVModeWindowPosX;
int nVLADVModeWindowPosY = NVLADVModeWindowPosY;
Expand Down
13 changes: 11 additions & 2 deletions MOD.Scripts.UI/MODMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ private void OnGUIConfigMenuButton(string text, float? alpha, Action action)

// Position the top-left x so the button is aligned with the config menu background, with a small margin
float xOffset = Screen.width / 8 + Screen.width / 64;

// Reposition button in 4:3 mode otherwise it would overlap the settings text
if(BurikoMemory.Instance.GetGlobalFlag("GRyukishiMode43Aspect").IntValue() != 0)
{
xOffset = 7 * Screen.width / 128;
}

// Position the top-left y to vertically center the button
float yOffset = Screen.height / 2 - areaHeight/2;

Expand Down Expand Up @@ -344,8 +351,10 @@ public void OnGUIFragment()
{
float totalAreaWidth = styleManager.Group.menuWidth;

float areaWidth = Mathf.Round(totalAreaWidth * 9/16);
float toolTipWidth = Mathf.Round(totalAreaWidth * 7/16);
float toolTipSubtraction = totalAreaWidth * styleManager.Group.toolTipShrinkage;

float areaWidth = Mathf.Round(totalAreaWidth * 9/16) + toolTipSubtraction;
float toolTipWidth = Mathf.Round(totalAreaWidth * 7/16) - toolTipSubtraction;

float areaHeight = styleManager.Group.menuHeight;

Expand Down
20 changes: 19 additions & 1 deletion MOD.Scripts.UI/MODMenuAudioOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,31 @@ public void OnBeforeMenuVisible()
ReloadMenu();
}

public void OnGUI(bool hideLabel=false)
public void OnGUI(bool setupMenu=false)
{
bool hideLabel = setupMenu;

Label("The patch supports different Background Music (BGM) and Sound Effects(SE). Please click the button below for more information.");

// Add extra spacing on setup menu so it looks nicer
if(setupMenu)
{
GUILayout.Space(20);
}

if (Button(new GUIContent("Open BGM/SE FAQ: 07th-mod.com/wiki/Higurashi/BGM-SE-FAQ/", "Click here to open the Background Music (BGM) and Sound Effects (SE) FAQ in your browser.\n\nThe BGM/SE FAQ contains information on the settings below.")))
{
Application.OpenURL("https://07th-mod.com/wiki/Higurashi/BGM-SE-FAQ/");
}

GUILayout.Space(20);

if (setupMenu)
{
Label("To continue, please choose a BGM/SE option below (hover button for info).\n" +
"You can change this option later via the mod menu.");
}

if (MODAudioSet.Instance.HasAudioSetsDefined())
{
// Set GAltBGM, GAltSE, GAltBGMFlow, GAltSEFlow to the same value. In the future we may set them to different values.
Expand Down
5 changes: 1 addition & 4 deletions MOD.Scripts.UI/MODMenuAudioSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ public void OnBeforeMenuVisible()

public void OnGUI()
{
Label("The patch supports different BGM/SE types, they can vary what you will hear and when. Choose the one that feels most appropriate for your experience.\n\n" +
"You can change this at any time via the mod menu.");

audioOptions.OnGUI(hideLabel: true);
audioOptions.OnGUI(setupMenu: true);

GUILayout.Space(20);

Expand Down
Loading

0 comments on commit c8e0196

Please sign in to comment.