Skip to content

Commit a0b0746

Browse files
committed
feat: 增加查看游戏版本号和CCM版本信息
1 parent f5164a0 commit a0b0746

21 files changed

Lines changed: 219 additions & 5 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ ChuChartManager/wwwroot/
1717
pnpm-lock.yaml
1818

1919
# 其他
20-
.sisyphus
20+
.sisyphus
21+
.codegraph

AppMain.g.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
public class Class1
4+
{
5+
public Class1()
6+
{
7+
}
8+
}
9+
// Auto-generated file. Do not modify manually.
10+
namespace MaiChartManager;
11+
12+
public partial class AppMain
13+
{
14+
public const string Version = "26.2";
15+
}

ChuChartManager/AppMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace ChuChartManager;
22

3-
public static class AppMain
3+
public partial class AppMain
44
{
55
public static Browser? BrowserWin { get; set; }
66
public static OobeBrowser? OobeBrowserWin { get; set; }

ChuChartManager/AppMain.g.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Auto-generated file. Do not modify manually.
2+
namespace ChuChartManager;
3+
4+
public partial class AppMain
5+
{
6+
public const string Version = "0"; // 推送tag前再填
7+
}

ChuChartManager/ChuChartManager.csproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,23 @@
1111
<StartupObject>ChuChartManager.Program</StartupObject>
1212
<ApplicationHighDpiMode>PerMonitorV2</ApplicationHighDpiMode>
1313
<ApplicationIcon>icon.ico</ApplicationIcon>
14+
<PackageLicenseFile>LICENSE</PackageLicenseFile>
15+
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
16+
<InvariantGlobalization>false</InvariantGlobalization>
17+
<NoWarn>NU1605</NoWarn>
18+
<CETCompat>false</CETCompat>
1419
</PropertyGroup>
1520
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
1621
<OutputType>Exe</OutputType>
1722
</PropertyGroup>
23+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
24+
<Optimize>true</Optimize>
25+
</PropertyGroup>
1826
<ItemGroup>
27+
<None Include="..\LICENSE">
28+
<Link>LICENSE</Link>
29+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
30+
</None>
1931
<None Include="icon.ico" CopyToOutputDirectory="PreserveNewest" />
2032
<None Include="tools\ugctool.exe" CopyToOutputDirectory="PreserveNewest" />
2133
<None Include="Resources\template_music.acb" CopyToOutputDirectory="PreserveNewest" />
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace ChuChartManager.Controllers;
4+
5+
[ApiController]
6+
[Route("api/[controller]/[action]")]
7+
public class AppVersionController : ControllerBase
8+
{
9+
public record AppVersionResult(string Version, int GameVersion, string GameVersionStr);
10+
11+
[HttpGet]
12+
public ActionResult<AppVersionResult> GetAppVersion()
13+
{
14+
return Ok(new AppVersionResult(
15+
AppMain.Version,
16+
StaticSettings.GameVersion,
17+
StaticSettings.GameVersionStr
18+
));
19+
}
20+
}

ChuChartManager/Controllers/ConfigController.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public ActionResult SetGamePath([FromBody] string gamePath)
3838
var scanner = new MusicScanner(gamePath);
3939
scanner.ScanAll();
4040
StaticSettings.Scanner = scanner;
41+
StaticSettings.ReadGameVersion();
4142

4243
return Ok();
4344
}
@@ -97,6 +98,7 @@ public ActionResult InitializeGameData()
9798
var scanner = new MusicScanner(StaticSettings.GamePath);
9899
scanner.ScanAll();
99100
StaticSettings.Scanner = scanner;
101+
StaticSettings.ReadGameVersion();
100102
return Ok();
101103
}
102104

ChuChartManager/Controllers/OptionController.cs

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace ChuChartManager.Controllers;
77
[Route("api/[controller]/[action]")]
88
public class OptionController(MusicScannerService scannerService) : ControllerBase
99
{
10-
public record OptionDirInfo(string DirName, int MusicCount, bool IsCustom);
10+
public record OptionDirInfo(string DirName, int MusicCount, bool IsCustom, string Version);
1111
public record ConflictEntry(int MusicId, string MusicName, string Dir, string ConflictDir);
1212

1313
[HttpGet]
@@ -26,7 +26,8 @@ public ActionResult<List<OptionDirInfo>> GetOptionDirs()
2626
var markPath = Path.Combine(StaticSettings.GamePath, "bin", "option", source, "CustomChartsMark.txt");
2727
isCustom = System.IO.File.Exists(markPath);
2828
}
29-
return new OptionDirInfo(source, musicCount, isCustom);
29+
var version = ReadOptVersion(source);
30+
return new OptionDirInfo(source, musicCount, isCustom, version);
3031
}).ToList();
3132

3233
return Ok(result);
@@ -208,4 +209,43 @@ private static void CopyDirectory(string source, string dest)
208209
foreach (var dir in Directory.GetDirectories(source))
209210
CopyDirectory(dir, Path.Combine(dest, Path.GetFileName(dir)));
210211
}
212+
213+
private static string ReadOptVersion(string dirName)
214+
{
215+
var path = ResolveOptRoot(dirName);
216+
if (path == null) return "";
217+
var confPath = Path.Combine(path, "data.conf");
218+
if (!System.IO.File.Exists(confPath)) return "";
219+
220+
try
221+
{
222+
int major = 0, minor = 0, release = 0;
223+
foreach (var line in System.IO.File.ReadLines(confPath))
224+
{
225+
if (line.StartsWith("VerMajor")) major = int.Parse(line.Split('=')[1].Trim());
226+
if (line.StartsWith("VerMinor")) minor = int.Parse(line.Split('=')[1].Trim());
227+
if (line.StartsWith("VerRelease")) release = int.Parse(line.Split('=')[1].Trim());
228+
}
229+
var version = major > 0 ? $"{major}.{minor:D2}" : "";
230+
if (version.Length > 0 && release != 0)
231+
version += "-" + ReleaseToLetters(release);
232+
return version;
233+
}
234+
catch
235+
{
236+
return "";
237+
}
238+
}
239+
240+
private static string ReleaseToLetters(int release)
241+
{
242+
var result = "";
243+
while (release > 0)
244+
{
245+
release--;
246+
result = (char)('A' + release % 26) + result;
247+
release /= 26;
248+
}
249+
return result;
250+
}
211251
}

ChuChartManager/Front/src/App.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Settings from '@/views/Settings.vue'
1717
import Oobe from '@/views/Oobe/index'
1818
import { ensureBackendUrl } from '@/api'
1919
import { loadLocaleFromBackend } from '@/locales'
20-
import { updateOptionDirs, sidebarActive } from '@/store/refs'
20+
import { updateOptionDirs, sidebarActive, updateAppVersion } from '@/store/refs'
2121
2222
const hash = window.location.hash.replace('#', '')
2323
const isOobeWindow = hash === 'oobe' || hash === 'mode-select'
@@ -30,6 +30,7 @@ onMounted(async () => {
3030
await ensureBackendUrl()
3131
await loadLocaleFromBackend()
3232
updateOptionDirs()
33+
updateAppVersion()
3334
ready.value = true
3435
})
3536

ChuChartManager/Front/src/api/option.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export interface OptionDirInfo {
44
dirName: string
55
musicCount: number
66
isCustom: boolean
7+
version: string
78
}
89

910
export interface ConflictEntry {

0 commit comments

Comments
 (0)