Skip to content

Commit 8640a2c

Browse files
committed
Load BGM name/descriptions from game script
1 parent 718b1f7 commit 8640a2c

File tree

8 files changed

+45
-9
lines changed

8 files changed

+45
-9
lines changed

Assets.Scripts.Core.Buriko/BurikoScriptFile.cs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2731,16 +2731,22 @@ public BurikoVariable OperationMODAddSEset()
27312731
return BurikoVariable.Null;
27322732
}
27332733

2734+
/// <summary>
2735+
/// Note: Tabs are not supported for descriptions and will be stripped out.
2736+
/// This is so that you can write multiple line strings in the game script without tabs appearing in the output.
2737+
/// </summary>
27342738
public BurikoVariable OperationMODAddAudioset()
27352739
{
27362740
SetOperationType("MODAddAudioSet");
27372741
string nameEN = ReadVariable().StringValue();
2742+
string descriptionEN = ReadVariable().StringValue();
27382743
string nameJP = ReadVariable().StringValue();
2744+
string descriptionJP = ReadVariable().StringValue();
27392745
int altBGM = ReadVariable().IntValue();
27402746
int altBGMflow = ReadVariable().IntValue();
27412747
int altSE = ReadVariable().IntValue();
27422748
int altSEFlow = ReadVariable().IntValue();
2743-
MODAudioSet.Instance.AddAudioSet(new AudioSet(nameEN, nameJP, altBGM, altBGMflow, altSE, altSEFlow));
2749+
MODAudioSet.Instance.AddAudioSet(new AudioSet(nameEN, nameJP, MODUtility.StripTabs(descriptionEN), MODUtility.StripTabs(descriptionJP), altBGM, altBGMflow, altSE, altSEFlow));
27442750

27452751
return BurikoVariable.Null;
27462752
}

BGICompiler.Compiler/OperationHandler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public void FillParamValues()
177177
paramLookup.Add("ModFadeOutBGM", new OpType(BurikoOperations.ModFadeOutBGM, "iibi"));
178178
paramLookup.Add("ModAddBGMset", new OpType(BurikoOperations.ModAddBGMset, "sss"));
179179
paramLookup.Add("ModAddSEset", new OpType(BurikoOperations.ModAddSEset, "sss"));
180-
paramLookup.Add("ModAddAudioset", new OpType(BurikoOperations.ModAddAudioset, "ssiiii"));
180+
paramLookup.Add("ModAddAudioset", new OpType(BurikoOperations.ModAddAudioset, "ssssiiii"));
181181
paramLookup.Add("ModGenericCall", new OpType(BurikoOperations.ModGenericCall, "ss"));
182182
}
183183

MOD.Scripts.Core.Audio/MODAudioSet.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,27 @@ class AudioSet
1111
{
1212
public readonly string nameEN;
1313
public readonly string nameJP;
14+
public readonly string descriptionEN;
15+
public readonly string descriptionJP;
1416
public readonly int altBGM;
1517
public readonly int altBGMFlow;
1618
public readonly int altSE;
1719
public readonly int altSEFlow;
1820

19-
public AudioSet(string nameEN, string nameJP, int altBGM, int altBGMFlow, int altSE, int altSEFlow)
21+
public AudioSet(string nameEN, string nameJP, string descriptionEN, string descriptionJP, int altBGM, int altBGMFlow, int altSE, int altSEFlow)
2022
{
2123
this.nameEN = nameEN;
2224
this.nameJP = nameJP;
25+
this.descriptionEN = descriptionEN;
26+
this.descriptionJP = descriptionJP;
2327
this.altBGM = altBGM;
2428
this.altBGMFlow = altBGMFlow;
2529
this.altSE = altSE;
2630
this.altSEFlow = altSEFlow;
2731
}
32+
33+
public string Name(bool getJapanese) => getJapanese ? nameJP : nameEN;
34+
public string Description(bool getJapanese) => getJapanese ? descriptionJP : descriptionEN;
2835
}
2936

3037
class MODAudioSet
@@ -86,6 +93,8 @@ public string GetAudioSetNameFromZeroIndexed(int zeroBasedIndex)
8693
return zeroBasedIndex < audioSets.Count ? audioSets[zeroBasedIndex].nameEN : $"Unknown BGM/SE {zeroBasedIndex}";
8794
}
8895

96+
public List<AudioSet> GetAudioSets() => audioSets;
97+
8998
public string GetBGMFlowName(int altBGMFlow)
9099
{
91100
return altBGMFlow < bgmFlowNames.Count ? bgmFlowNames[altBGMFlow] : $"Unknown BGM/SE {altBGMFlow}";

MOD.Scripts.Core/MODUtility.cs

+2
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,6 @@ public static Platform GetPlatform()
106106
return Platform.Windows;
107107
}
108108
}
109+
110+
public static string StripTabs(string s) => s.Replace("\t", "");
109111
}

MOD.Scripts.UI/MODMenuAudioOptions.cs

+12-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using MOD.Scripts.Core.Audio;
22
using System;
33
using System.Collections.Generic;
4+
using System.Linq;
45
using System.Text;
56
using UnityEngine;
67

@@ -17,12 +18,18 @@ public MODMenuAudioOptions(MODMenuCommon c, MODStyleManager styleManager)
1718
this.c = c;
1819
hasBGMSEOptions = MODActions.HasMusicToggle();
1920

20-
this.radioBGMSESet = new MODRadio("Choose BGM/SE (Hotkey: 2)", new GUIContent[]
21+
this.radioBGMSESet = new MODRadio("Choose BGM/SE (Hotkey: 2)", new GUIContent[] { }, styleManager);
22+
}
23+
24+
public void OnBeforeMenuVisible()
25+
{
26+
if (this.radioBGMSESet.GetContents().Length == 0)
2127
{
22-
new GUIContent("New BGM/SE", "Use the new BGM/SE introduced by MangaGamer in the April 2019 update."),
23-
new GUIContent("Original BGM/SE", "Use the original BGM/SE from the Japanese version of the game. This option was previously known as 'BGM/SE fix'.\n\n" +
24-
"Note that this not only changes which audio files are played, but also when BGM starts to play/stops playing, in certain cases."),
25-
}, styleManager);
28+
bool japanese = c.GetGlobal("GLanguage") == 0;
29+
this.radioBGMSESet.SetContents(
30+
MODAudioSet.Instance.GetAudioSets().Select(x => new GUIContent(x.Name(japanese), x.Description(japanese))).ToArray()
31+
);
32+
}
2633
}
2734

2835
public void OnGUI()

MOD.Scripts.UI/MODMenuAudioSetup.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ public MODMenuAudioSetup(MODMenu modMenu, MODMenuCommon c, MODMenuAudioOptions a
1818
this.audioOptions = audioOptions;
1919
}
2020

21-
public void OnBeforeMenuVisible() {}
21+
public void OnBeforeMenuVisible()
22+
{
23+
audioOptions.OnBeforeMenuVisible();
24+
}
2225

2326
public void OnGUI()
2427
{

MOD.Scripts.UI/MODMenuNormal.cs

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ public void OnBeforeMenuVisible() {
227227
this.radioArtSet.SetContents(descriptions);
228228

229229
resolutionMenu.OnBeforeMenuVisible();
230+
audioOptionsMenu.OnBeforeMenuVisible();
230231
}
231232

232233
private void OnGUIRestoreSettings(MODMenuCommon w)

MOD.Scripts.UI/MODRadio.cs

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ public MODRadio(string label, GUIContent[] radioContents, MODStyleManager styleM
3434
public int? OnGUIFragment(int displayedRadio)
3535
{
3636
GUILayout.Label(this.label, styleManager.Group.label);
37+
38+
if(radioContents.Length == 0)
39+
{
40+
GUILayout.Label("MODRadio Error: this radio has no options!", styleManager.Group.label);
41+
}
42+
3743
int i = GUILayout.SelectionGrid(displayedRadio, radioContents, itemsPerRow, styleManager.Group.modMenuSelectionGrid);
3844
if (i != displayedRadio)
3945
{
@@ -48,5 +54,7 @@ public void SetContents(GUIContent[] content)
4854
{
4955
this.radioContents = content;
5056
}
57+
58+
public GUIContent[] GetContents() => this.radioContents;
5159
}
5260
}

0 commit comments

Comments
 (0)