-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakeSong.cs
More file actions
228 lines (218 loc) · 7.97 KB
/
Copy pathMakeSong.cs
File metadata and controls
228 lines (218 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
using GH_Toolkit_Core.Audio;
using GH_Toolkit_Core.INI;
using GH_Toolkit_Core.MIDI;
using GH_Toolkit_Core.PAK;
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static GH_Toolkit_Core.Methods.CreateForGame;
using static GH_Toolkit_Core.QB.QBConstants;
namespace PAK_Compiler
{
internal class MakeSong
{
private string? Game;
private string? Platform;
private string? Folder;
private bool Gh3Plus;
private SongData SongData = new SongData();
private GhMetadata ghMetadata = new GhMetadata();
public MakeSong(string folder, string game, string platform)
{
game = game.ToUpper();
switch (game)
{
case GAME_GH3:
case GAME_GHA:
case GAME_GHWT:
case GAME_GHM:
case GAME_GHSH:
case GAME_GHGH:
case GAME_GHVH:
case GAME_GH5:
break;
case STRING_WOR:
case GAME_GHWOR_UPPER:
game = GAME_GHWOR;
break;
case GAME_GH3PLUS:
game = GAME_GH3;
Gh3Plus = platform == CONSOLE_PC;
break;
default:
Console.WriteLine("Invalid game option.");
Game = null;
return;
}
Game = game;
Platform = platform;
Folder = folder;
}
public async Task ProcessSong()
{
if (Game == null || Platform == null || Folder == null)
{
Console.WriteLine("Missing required arguments: ");
ShowHelpMenu();
return;
}
GetDataFromFolder();
await CreateSongPackage();
}
private async Task CreateSongPackage()
{
var songInfo = SongData.GetSongInfo();
string[] dlcName = { Game!, songInfo.Artist, songInfo.Title, songInfo.Year.ToString(), songInfo.Charter, songInfo.IsCover.ToString() };
var dlcNum = MakeConsoleChecksum(dlcName);
if (Platform! != CONSOLE_PC)
{
songInfo.Checksum = $"dlc{dlcNum}";
}
var metadata = new GhMetadata(songInfo);
var fileInfo = SongData.GetFilePathInfo();
if (!(fileInfo.DoesMidiExist))
{
if (!fileInfo.DoesChartExist)
{
Console.WriteLine("No MIDI or Chart note file found in folder.");
return;
}
fileInfo.SetMidiFile(fileInfo.GetChartFile());
}
var skaPath = fileInfo.DoesSkaExist ? fileInfo.SkaFiles : string.Empty;
var perfPath = fileInfo.DoesPerfExist ? fileInfo.PerfOverride : string.Empty;
var scriptPath = fileInfo.DoesSongScriptsExist ? fileInfo.SongScripts : string.Empty;
AudioCompiler audio;
var previewLength = songInfo.PreviewEndTime - songInfo.PreviewStartTime;
if (previewLength <= 0)
{
previewLength = 30000;
}
var bassExists = Path.Exists(fileInfo.Bass);
var bassPath = bassExists ? fileInfo.Bass : fileInfo.Rhythm;
if (Game == GAME_GH3 || Game == GAME_GHA)
{
audio = AudioCompiler.CreateGh3Compiler(
metadata.Checksum,
Folder,
"Compile",
Game,
songInfo.PreviewStartTime,
previewLength,
-7.0m,
1.0m,
1.0m,
fileInfo.DoesPreviewExist, // Custom Preview
false, // Coop Audio - Change this? Not sure if CH folders support co-op audio
fileInfo.Guitar,
bassPath,
fileInfo.BackingTracks.ToArray(),
fileInfo.Crowd,
fileInfo.Preview,
"",
"",
[""]
);
if (Platform == CONSOLE_PS2)
{
await audio.GH3AudioCompilePs2();
}
else
{
await audio.GH3AudioCompile();
}
}
else
{
if (Platform == CONSOLE_PS2)
{
throw new NotSupportedException("PS2 not supported for band games.");
}
var encrypt = !(Game == GAME_GHWT && Platform == CONSOLE_PC);
audio = AudioCompiler.CreateGhwtCompiler(
metadata.Checksum,
Folder,
"Compile",
Game,
songInfo.PreviewStartTime,
previewLength,
-7.0m,
1.0m,
1.0m,
fileInfo.DoesPreviewExist, // Custom Preview
fileInfo.Guitar,
bassPath,
fileInfo.Vocals,
fileInfo.KickDrum,
fileInfo.SnareDrum,
fileInfo.Cymbals,
fileInfo.Toms,
fileInfo.BackingTracks.ToArray(),
fileInfo.Crowd,
fileInfo.Preview
);
await audio.GHWTAudioCompile(encrypt);
}
var compiler = new SongPakCompiler(
midiPath: fileInfo.MidiFile,
savePath: Folder,
songName: metadata.Checksum,
game: Game,
gameConsole: Platform
)
{
SkaPath = skaPath,
PerfOverride = perfPath,
SongScripts = scriptPath,
SkaSource = songInfo.SkaSource,
VenueSource = songInfo.VenueSource,
HopoThreshold = metadata.HmxHopoThreshold,
Gh3Plus = Gh3Plus
};
compiler.Build();
var (pakFile, doubleKick, pakExpertPlus) = compiler.GetResults();
}
private void GetDataFromFolder()
{
SongData.SetFilePathInfo(iniParser.AssignFiles(Folder, Game));
// Get the data from the folder
string iniCheck = Path.Combine(Folder, "song.ini");
if (File.Exists(iniCheck))
{
var ini = iniParser.ReadIniFromPath(iniCheck);
string songSection = null;
// Check for the section in a case-insensitive manner
foreach (var section in ini.Sections)
{
if (string.Equals(section.SectionName, "song", StringComparison.OrdinalIgnoreCase))
{
songSection = section.SectionName; // This retains the original casing ("song" or "Song")
break;
}
}
// Proceed only if a matching section was found
if (songSection != null)
{
SongData.SetSongInfo(iniParser.ParseSongIni(ini, songSection));
}
}
}
private void CheckValidSongData()
{
}
public void ShowHelpMenu()
{
Console.WriteLine("Usage: makesong <folder> -g <game> -c <console>");
Console.WriteLine(" -g <game> - The game the song is for.");
Console.WriteLine(" -c <console> - The console to compile for.");
Console.WriteLine("Available games options:");
Console.WriteLine("GH3, GH3+, GHA, GHWT, GHM, GHSH, GHGH, GHVH, GH5, WOR, GHWOR");
Console.WriteLine("Available console options:");
Console.WriteLine("360, PC, PS2, PS3, WII");
}
}
}