-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
902 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Milkitic.OsuPlayer | ||
{ | ||
public class Config | ||
{ | ||
public int Offset { get; set; } = 85; | ||
public VolumeControl Volume { get; set; } = new VolumeControl(); | ||
public int DesiredLatency { get; set; } = 80; | ||
} | ||
|
||
public class VolumeControl | ||
{ | ||
private float _main = 0.7f; | ||
private float _bgm = 1; | ||
private float _hs = 1; | ||
|
||
public float Main { get => _main; set => SetValue(ref _main, value); } | ||
public float Music { get => _bgm; set => SetValue(ref _bgm, value); } | ||
public float Hitsound { get => _hs; set => SetValue(ref _hs, value); } | ||
|
||
private static void SetValue(ref float source, float value) | ||
{ | ||
if (value < 0) source = 0; | ||
else if (value > 1) source = 1; | ||
else source = value; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Milkitic.OsuPlayer.Models; | ||
using Milkitic.OsuPlayer.Utils; | ||
using NAudio.Wave; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using Milkitic.OsuPlayer.Winforms; | ||
|
||
namespace Milkitic.OsuPlayer | ||
{ | ||
static class Core | ||
{ | ||
public static Config Config { get; set; } | ||
|
||
[STAThread] | ||
static void Main() | ||
{ | ||
var file = Domain.ConfigFile; | ||
if (!File.Exists(file)) | ||
{ | ||
CreateConfig(file); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
Config = JsonConvert.DeserializeObject<Config>(File.ReadAllText(file)); | ||
} | ||
catch (JsonException e) | ||
{ | ||
var result = MessageBox.Show(@"载入配置文件时失败,用默认配置覆盖继续打开吗?\r\n" + e.Message, | ||
AppDomain.CurrentDomain.FriendlyName, MessageBoxButtons.YesNo, MessageBoxIcon.Question); | ||
if (result == DialogResult.Yes) | ||
{ | ||
CreateConfig(file); | ||
} | ||
else | ||
return; | ||
} | ||
} | ||
|
||
Application.EnableVisualStyles(); | ||
Application.SetCompatibleTextRenderingDefault(false); | ||
Application.Run(new RenderForm()); | ||
|
||
SaveConfig(file); | ||
} | ||
|
||
private static void SaveConfig(string file) | ||
{ | ||
File.WriteAllText(file, JsonConvert.SerializeObject(Config)); | ||
} | ||
|
||
private static void CreateConfig(string file) | ||
{ | ||
Config = new Config(); | ||
File.WriteAllText(file, JsonConvert.SerializeObject(Config)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.