2020-04-18 22:24:48 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Diagnostics;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
using Microsoft.WindowsAPICodePack.Dialogs;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
|
|
|
|
namespace VoxCharger
|
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
public enum ConvertMode
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
Converter = 0,
|
|
|
|
|
Importer = 1,
|
|
|
|
|
BulkConverter = 2,
|
|
|
|
|
BulkImporter = 3
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
public partial class ConverterForm : Form
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
private enum SoundFxType
|
|
|
|
|
{
|
|
|
|
|
Chip,
|
|
|
|
|
Long,
|
|
|
|
|
Laser
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
public Camera.WorkType Work { get; set; }
|
|
|
|
|
public bool SlamImpact { get; set; } = false;
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class SoundFxOption
|
|
|
|
|
{
|
|
|
|
|
public SoundFxType Type { get; set; }
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return Name;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static readonly Image DummyJacket = VoxCharger.Properties.Resources.jk_dummy_s;
|
|
|
|
|
public static string LastBackground { get; private set; } = "88";
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
private readonly CameraEffectOption[] _cameraOptions =
|
|
|
|
|
{
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
Work = Camera.WorkType.Realize,
|
|
|
|
|
Name = "Realize"
|
|
|
|
|
},
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
Work = Camera.WorkType.Rotation,
|
|
|
|
|
Name = "CAM_RotX"
|
|
|
|
|
},
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
Work = Camera.WorkType.Radian,
|
|
|
|
|
Name = "CAM_Radian"
|
|
|
|
|
},
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
Work = Camera.WorkType.Tilt,
|
|
|
|
|
Name = "Tilt / Tilt Mode"
|
|
|
|
|
},
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
Work = Camera.WorkType.LaneClear,
|
|
|
|
|
Name = "LaneY"
|
|
|
|
|
},
|
|
|
|
|
new CameraEffectOption
|
|
|
|
|
{
|
|
|
|
|
SlamImpact = true,
|
|
|
|
|
Name = "Slam Impact"
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private readonly SoundFxOption[] _sfxOptions =
|
|
|
|
|
{
|
|
|
|
|
new SoundFxOption
|
|
|
|
|
{
|
|
|
|
|
Type = SoundFxType.Chip,
|
|
|
|
|
Name = "Chip"
|
|
|
|
|
},
|
|
|
|
|
new SoundFxOption
|
|
|
|
|
{
|
|
|
|
|
Type = SoundFxType.Long,
|
|
|
|
|
Name = "Long"
|
|
|
|
|
},
|
|
|
|
|
new SoundFxOption
|
|
|
|
|
{
|
|
|
|
|
Type = SoundFxType.Laser,
|
|
|
|
|
Name = "Laser"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private string _target;
|
|
|
|
|
private string _defaultAscii;
|
|
|
|
|
private ConvertMode _mode;
|
|
|
|
|
private Dictionary<Difficulty, ChartInfo> _charts = new Dictionary<Difficulty, ChartInfo>();
|
|
|
|
|
private Ksh.Exporter _exporter;
|
|
|
|
|
private bool _updatingAllEffects = false;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
public VoxHeader Result { get; private set; } = null;
|
|
|
|
|
public VoxHeader[] ResultSet { get; private set; } = new VoxHeader[0];
|
2020-04-19 10:02:55 +02:00
|
|
|
|
public Ksh.ParseOption Options { get; private set; } = new Ksh.ParseOption();
|
2020-04-19 14:13:12 +02:00
|
|
|
|
public Action Action { get; private set; } = null;
|
|
|
|
|
public Dictionary<string, Action> ActionSet { get; private set; } = new Dictionary<string, Action>();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
public ConverterForm(string path, ConvertMode convert)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_target = path;
|
|
|
|
|
_mode = convert;
|
|
|
|
|
|
|
|
|
|
foreach (var camOpt in _cameraOptions)
|
|
|
|
|
CameraEffectsCheckedListBox.Items.Add(camOpt, camOpt.Work == Camera.WorkType.Realize ? CheckState.Indeterminate : CheckState.Checked);
|
|
|
|
|
|
|
|
|
|
foreach (var sfxOpt in _sfxOptions)
|
|
|
|
|
SoundEffectsCheckedListBox.Items.Add(sfxOpt, true);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
// Cancerous code to adjust layout depending what this form going to be
|
2023-01-06 14:58:29 +01:00
|
|
|
|
if (_mode == ConvertMode.Converter)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
MusicCodeLabel.Visible = false;
|
|
|
|
|
InfVerLabel.Visible = false;
|
|
|
|
|
BackgroundLabel.Visible = false;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
BackgroundDropDown.Enabled = BackgroundDropDown.Visible = false;
|
|
|
|
|
MusicGroupBox.Enabled = MusicGroupBox.Visible = false;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
LevelGroupBox.Enabled = LevelGroupBox.Visible = false;
|
|
|
|
|
AsciiTextBox.Enabled = AsciiTextBox.Visible = false;
|
|
|
|
|
AsciiAutoCheckBox.Enabled = AsciiAutoCheckBox.Visible = false;
|
|
|
|
|
VersionDropDown.Enabled = VersionDropDown.Visible = false;
|
|
|
|
|
InfVerDropDown.Enabled = InfVerDropDown.Visible = false;
|
|
|
|
|
|
|
|
|
|
int componentHeight = AsciiTextBox.Height + VersionDropDown.Height + BackgroundDropDown.Height;
|
|
|
|
|
OptionsGroupBox.Location = LevelGroupBox.Location;
|
|
|
|
|
OptionsGroupBox.Height -= componentHeight;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Height -= LevelGroupBox.Height + componentHeight + MusicGroupBox.Height;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Text = "Convert Music";
|
2020-04-18 22:24:48 +02:00
|
|
|
|
ProcessConvertButton.Text = "Convert";
|
2023-01-06 14:58:29 +01:00
|
|
|
|
PathTextBox.Text = _target;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
return;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
2023-01-06 14:58:29 +01:00
|
|
|
|
else if (_mode == ConvertMode.BulkImporter)
|
2020-04-19 14:13:12 +02:00
|
|
|
|
{
|
|
|
|
|
MusicCodeLabel.Visible = false;
|
|
|
|
|
LevelGroupBox.Enabled = LevelGroupBox.Visible = false;
|
|
|
|
|
AsciiTextBox.Enabled = AsciiTextBox.Visible = false;
|
|
|
|
|
AsciiAutoCheckBox.Enabled = AsciiAutoCheckBox.Visible = false;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
MusicGroupBox.Enabled = MusicGroupBox.Visible = false;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
int componentHeight = AsciiTextBox.Height;
|
|
|
|
|
OptionsGroupBox.Location = LevelGroupBox.Location;
|
|
|
|
|
OptionsGroupBox.Height -= componentHeight;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Height -= LevelGroupBox.Height + MusicGroupBox.Height + componentHeight;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
MusicGroupBox.Anchor = AnchorStyles.Top | AnchorStyles.Left;
|
|
|
|
|
PreviewTimePicker.Value = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, 0, 0);
|
|
|
|
|
MusicFormatDropDown.SelectedIndex = 0;
|
|
|
|
|
MusicFormatDropDown.Enabled = false;
|
|
|
|
|
|
|
|
|
|
PathTextBox.Text = _target;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
BackgroundDropDown.SelectedItem = LastBackground;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
VersionDropDown.SelectedIndex = 5;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
InfVerDropDown.SelectedIndex = 0;
|
|
|
|
|
ProcessConvertButton.Text = "Add";
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnConverterFormLoad(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
if (_mode != ConvertMode.Importer)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var main = new Ksh();
|
2023-01-06 14:58:29 +01:00
|
|
|
|
main.Parse(_target);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
Result = main.ToHeader();
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Result.Id = AssetManager.GetNextMusicId();
|
|
|
|
|
Result.Ascii = _defaultAscii = AsciiTextBox.Text = Path.GetFileName(Path.GetDirectoryName(_target));
|
|
|
|
|
_exporter = new Ksh.Exporter(main);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
for (int i = 1; Directory.Exists(AssetManager.GetMusicPath(Result)); i++)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (i >= 100)
|
|
|
|
|
break; // seriously? stupid input get stupid output
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Result.Ascii = $"{_defaultAscii}{i:D2}";
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_defaultAscii = AsciiTextBox.Text = Result.Ascii;
|
|
|
|
|
_charts[main.Difficulty] = new ChartInfo(main, main.ToLevelHeader(), _target);
|
|
|
|
|
LoadJacket(_charts[main.Difficulty]);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
// Try to locate another difficulty
|
2023-01-06 14:58:29 +01:00
|
|
|
|
foreach (var lv in Ksh.Exporter.GetCharts(Path.GetDirectoryName(_target), main.Title))
|
2020-04-19 14:13:12 +02:00
|
|
|
|
{
|
|
|
|
|
// Don't replace main file, there might 2 files with similar meta or another stupid cases
|
|
|
|
|
if (lv.Key != main.Difficulty)
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_charts[lv.Key] = lv.Value;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
UpdateLevels();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
2020-04-19 10:02:55 +02:00
|
|
|
|
$"Failed to load ksh chart.\n{ex.Message}",
|
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
2020-04-18 22:24:48 +02:00
|
|
|
|
MessageBoxIcon.Error
|
|
|
|
|
);
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
DialogResult = DialogResult.Cancel;
|
2020-04-19 10:02:55 +02:00
|
|
|
|
Close();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnAsciiAutoCheckBoxCheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
AsciiTextBox.ReadOnly = AsciiAutoCheckBox.Checked;
|
|
|
|
|
if (AsciiTextBox.ReadOnly)
|
2023-01-06 14:58:29 +01:00
|
|
|
|
AsciiTextBox.Text = _defaultAscii;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBackgroundDropDownSelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
LastBackground = BackgroundDropDown.SelectedItem.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnInfVerDropDownSelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
if (!_charts.ContainsKey(Difficulty.Infinite))
|
2020-04-18 22:24:48 +02:00
|
|
|
|
InfEditButton.Text = "--";
|
|
|
|
|
else
|
|
|
|
|
InfEditButton.Text = InfVerDropDown.SelectedItem.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnLevelEditButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var browser = new OpenFileDialog())
|
|
|
|
|
{
|
|
|
|
|
browser.Filter = "KShoot Mania Chart|*.ksh";
|
|
|
|
|
browser.CheckFileExists = true;
|
|
|
|
|
|
|
|
|
|
if (browser.ShowDialog() != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var control = (Button)sender;
|
|
|
|
|
if (!Enum.TryParse(control.Tag.ToString(), out Difficulty diff))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var chart = new Ksh();
|
|
|
|
|
chart.Parse(browser.FileName);
|
|
|
|
|
chart.Difficulty = diff; // make sure to replace diff
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_charts[diff] = new ChartInfo(chart, chart.ToLevelHeader(), browser.FileName);
|
|
|
|
|
UpdateLevels();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
$"Failed to load ksh chart.\n{ex.Message}",
|
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
private void OnSoundEffectsCheckBoxCheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (SoundEffectsCheckBox.CheckState == CheckState.Indeterminate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_updatingAllEffects = true;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < SoundEffectsCheckedListBox.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (SoundEffectsCheckedListBox.GetItemCheckState(i) == CheckState.Indeterminate)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
SoundEffectsCheckedListBox.SetItemChecked(i, SoundEffectsCheckBox.Checked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updatingAllEffects = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCameraEffectsCheckBoxCheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (CameraEffectsCheckBox.CheckState == CheckState.Indeterminate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_updatingAllEffects = true;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < CameraEffectsCheckedListBox.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (CameraEffectsCheckedListBox.GetItemCheckState(i) == CheckState.Indeterminate)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
CameraEffectsCheckedListBox.SetItemChecked(i, CameraEffectsCheckBox.Checked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_updatingAllEffects = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSoundEffectsCheckedListBoxItemCheck(object sender, ItemCheckEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_updatingAllEffects || e.CurrentValue == CheckState.Indeterminate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool value = e.NewValue == CheckState.Checked || e.NewValue == CheckState.Indeterminate;
|
|
|
|
|
for (int i = 0; i < SoundEffectsCheckedListBox.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != e.Index && SoundEffectsCheckedListBox.GetItemChecked(i) != value)
|
|
|
|
|
{
|
|
|
|
|
SoundEffectsCheckBox.CheckState = CheckState.Indeterminate;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SoundEffectsCheckBox.CheckState = value ? CheckState.Checked : CheckState.Unchecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCameraEffectsCheckedListBoxItemCheck(object sender, ItemCheckEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (_updatingAllEffects || e.CurrentValue == CheckState.Indeterminate)
|
|
|
|
|
{
|
|
|
|
|
if (e.CurrentValue == CheckState.Indeterminate)
|
|
|
|
|
e.NewValue = CheckState.Indeterminate;
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool value = e.NewValue == CheckState.Checked || e.NewValue == CheckState.Indeterminate;
|
|
|
|
|
for (int i = 0; i < CameraEffectsCheckedListBox.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i != e.Index && CameraEffectsCheckedListBox.GetItemChecked(i) != value)
|
|
|
|
|
{
|
|
|
|
|
CameraEffectsCheckBox.CheckState = CheckState.Indeterminate;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CameraEffectsCheckBox.CheckState = value ? CheckState.Checked : CheckState.Unchecked;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMappingButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("Custom mapping for Sound & Camera Effects is not supported (yet).",
|
|
|
|
|
"Coming Soon™", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnMusicFormatDropDownSelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
// Not Implemented
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBrowseMainToolButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnBrowseSecondaryToolButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
using (var browser = new OpenFileDialog())
|
|
|
|
|
{
|
|
|
|
|
browser.Filter = $"{PreviewOffsetLabel.Text.Replace(".exe", string.Empty)} | {PreviewOffsetLabel.Text}";
|
|
|
|
|
browser.CheckFileExists = true;
|
|
|
|
|
browser.Title = "Browse Converter";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-18 22:24:48 +02:00
|
|
|
|
private void OnHelpButtonClicked(object sender, CancelEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
e.Cancel = true;
|
|
|
|
|
using (var help = new HelpForm())
|
|
|
|
|
help.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCancelConvertButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
DialogResult = DialogResult.Cancel;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnProcessConvertButtonClick(object sender, EventArgs e)
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
bool slamImpact = true;
|
|
|
|
|
var cameraOpts = new Dictionary<Camera.WorkType, bool>();
|
|
|
|
|
for (int i = 0; i < CameraEffectsCheckedListBox.Items.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
if (!(CameraEffectsCheckedListBox.Items[i] is CameraEffectOption opt))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (opt.SlamImpact)
|
|
|
|
|
slamImpact = CameraEffectsCheckedListBox.GetItemChecked(i);
|
|
|
|
|
else
|
|
|
|
|
cameraOpts[opt.Work] = CameraEffectsCheckedListBox.GetItemChecked(i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Options = new Ksh.ParseOption
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
RealignOffset = RealignOffsetCheckBox.Checked,
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Camera = new Ksh.ParseOption.CameraOptions
|
|
|
|
|
{
|
|
|
|
|
SlamImpact = slamImpact,
|
|
|
|
|
EnabledWorks = cameraOpts
|
|
|
|
|
},
|
|
|
|
|
SoundFx = new Ksh.ParseOption.SoundFxOptions
|
|
|
|
|
{
|
|
|
|
|
Chip = SoundEffectsCheckedListBox.GetItemChecked(0),
|
|
|
|
|
Long = SoundEffectsCheckedListBox.GetItemChecked(1),
|
|
|
|
|
Laser = SoundEffectsCheckedListBox.GetItemChecked(2),
|
|
|
|
|
},
|
|
|
|
|
Track = new Ksh.ParseOption.TrackOptions
|
|
|
|
|
{
|
|
|
|
|
EnabledLaserTracks = new Dictionary<Event.LaserTrack, bool>
|
|
|
|
|
{
|
|
|
|
|
{ Event.LaserTrack.Left, TrackVolLCheckBox.Checked },
|
|
|
|
|
{ Event.LaserTrack.Right, TrackVolRCheckBox.Checked }
|
|
|
|
|
},
|
|
|
|
|
EnabledButtonTracks = new Dictionary<Event.ButtonTrack, bool>
|
|
|
|
|
{
|
|
|
|
|
{ Event.ButtonTrack.A, TrackButtonACheckBox.Checked },
|
|
|
|
|
{ Event.ButtonTrack.B, TrackButtonBCheckBox.Checked },
|
|
|
|
|
{ Event.ButtonTrack.C, TrackButtonCCheckBox.Checked },
|
|
|
|
|
{ Event.ButtonTrack.D, TrackButtonDCheckBox.Checked },
|
|
|
|
|
{ Event.ButtonTrack.FxL, TrackFXLCheckBox.Checked },
|
|
|
|
|
{ Event.ButtonTrack.FxR, TrackFXRCheckBox.Checked }
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Act as converter
|
2023-01-06 14:58:29 +01:00
|
|
|
|
switch (_mode)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
case ConvertMode.Converter: SingleConvert(); break;
|
|
|
|
|
case ConvertMode.BulkConverter: BulkConvert(); break;
|
|
|
|
|
case ConvertMode.Importer: SingleImport(); break;
|
|
|
|
|
case ConvertMode.BulkImporter: BulkImport(); break;
|
|
|
|
|
}
|
2020-04-19 10:02:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
private void SingleImport()
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Assign metadata
|
|
|
|
|
Result.Ascii = AsciiTextBox.Text;
|
|
|
|
|
Result.BackgroundId = short.Parse((BackgroundDropDown.SelectedItem ?? "0").ToString().Split(' ')[0]);
|
|
|
|
|
Result.Version = (GameVersion)(VersionDropDown.SelectedIndex + 1);
|
2023-01-06 14:58:29 +01:00
|
|
|
|
Result.InfVersion = InfVerDropDown.SelectedIndex == 0 ? InfiniteVersion.Mxm : (InfiniteVersion)(InfVerDropDown.SelectedIndex + 1);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
Result.GenreId = 16;
|
|
|
|
|
Result.Levels = new Dictionary<Difficulty, VoxLevelHeader>();
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
if (Result.BpmMin != Result.BpmMax && _exporter.Source.MusicOffset % 48 != 0 && Options.RealignOffset)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
// You've been warned!
|
|
|
|
|
var prompt = MessageBox.Show(
|
|
|
|
|
"Adapting music offset could break this chart.\n" +
|
|
|
|
|
"Do you want to continue?",
|
|
|
|
|
"Warning",
|
|
|
|
|
MessageBoxButtons.YesNo,
|
|
|
|
|
MessageBoxIcon.Warning
|
|
|
|
|
);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
if (prompt == DialogResult.No)
|
2020-04-19 10:02:55 +02:00
|
|
|
|
return;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
if (Directory.Exists(AssetManager.GetMusicPath(Result)) || AssetManager.Headers.Any(h => h.Ascii == Result.Ascii))
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
2023-01-06 14:58:29 +01:00
|
|
|
|
$"Music Code {Result.CodeName} is already taken.\nTry configure \"Music Code\" manually.",
|
2020-04-18 22:24:48 +02:00
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
var importOptions = new AudioImportOptions
|
|
|
|
|
{
|
|
|
|
|
Format = AudioFormat.Iidx,
|
|
|
|
|
PreviewOffset = PreviewTimePicker.Value.Minute * 60 + PreviewTimePicker.Value.Second
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_exporter.Export(Result, _charts, Options, importOptions);
|
|
|
|
|
Action = _exporter.Action;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
$"Failed to import ksh chart.\n{ex.Message}",
|
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error
|
|
|
|
|
);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
// Eliminate non-existent files
|
2023-01-06 14:58:29 +01:00
|
|
|
|
foreach (var chart in _charts.Values.ToArray())
|
2020-04-19 14:13:12 +02:00
|
|
|
|
{
|
|
|
|
|
if (!File.Exists(chart.FileName))
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_charts.Remove(chart.Header.Difficulty);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
// Reload jacket
|
2023-01-06 14:58:29 +01:00
|
|
|
|
UpdateLevels();
|
2020-04-19 14:13:12 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
private void BulkImport()
|
|
|
|
|
{
|
|
|
|
|
var output = new List<VoxHeader>();
|
|
|
|
|
var actions = new Dictionary<string, Action>();
|
|
|
|
|
var errors = new List<string>();
|
|
|
|
|
using (var loader = new LoadingForm())
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
loader.SetAction(dialog =>
|
2020-04-19 14:13:12 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
var directories = Directory.GetDirectories(_target);
|
2020-04-19 14:39:32 +02:00
|
|
|
|
int current = 0;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
foreach (string dir in directories)
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
dialog.SetStatus($"Processing {Path.GetFileName(dir)}..");
|
|
|
|
|
dialog.SetProgress((current + 1 / (float)directories.Length) * 100f);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var files = Directory.GetFiles(dir, "*.ksh");
|
|
|
|
|
if (files.Length == 0)
|
|
|
|
|
continue;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
string fn = files[0];
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 10:02:55 +02:00
|
|
|
|
try
|
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var ksh = new Ksh();
|
|
|
|
|
ksh.Parse(fn, Options);
|
|
|
|
|
|
|
|
|
|
var header = ksh.ToHeader();
|
2023-01-06 14:58:29 +01:00
|
|
|
|
header.Id = AssetManager.GetNextMusicId() + current++;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
header.BackgroundId = short.Parse((BackgroundDropDown.SelectedItem ?? "0").ToString().Split(' ')[0]);
|
|
|
|
|
header.Version = (GameVersion)(VersionDropDown.SelectedIndex + 1);
|
2023-01-06 14:58:29 +01:00
|
|
|
|
header.InfVersion = InfVerDropDown.SelectedIndex == 0 ? InfiniteVersion.Mxm : (InfiniteVersion)(InfVerDropDown.SelectedIndex + 1);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
header.GenreId = 16;
|
|
|
|
|
header.Levels = new Dictionary<Difficulty, VoxLevelHeader>();
|
|
|
|
|
|
|
|
|
|
string ascii = Path.GetFileName(Path.GetDirectoryName(fn));
|
|
|
|
|
if (AssetManager.Headers.Any(v => v.Ascii == ascii) || // Duplicate header with same ascii
|
|
|
|
|
Directory.Exists(AssetManager.GetMusicPath(header)) || // Asset that use the ascii is already exists
|
|
|
|
|
output.Any(h => h.Ascii == ascii)) // Output with same ascii is already exists
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var charts = Ksh.Exporter.GetCharts(Path.GetDirectoryName(fn), header.Title);
|
|
|
|
|
var exporter = new Ksh.Exporter(ksh);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
header.Ascii = ascii;
|
|
|
|
|
exporter.Export(header, charts, Options);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
output.Add(header);
|
|
|
|
|
actions.Add(ascii, exporter.Action);
|
2020-04-19 10:02:55 +02:00
|
|
|
|
}
|
2020-04-19 14:13:12 +02:00
|
|
|
|
catch (Exception ex)
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
string err = $"Failed attempt to convert ksh file: {Path.GetFileName(fn)} ({ex.Message})";
|
|
|
|
|
errors.Add(err);
|
|
|
|
|
Debug.WriteLine(err);
|
2020-04-19 10:02:55 +02:00
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
dialog.Complete();
|
2020-04-19 14:13:12 +02:00
|
|
|
|
});
|
2020-04-19 10:02:55 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
loader.ShowDialog();
|
2020-04-19 10:02:55 +02:00
|
|
|
|
}
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
if (errors.Count != 0)
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
string message = "Failed to import one or more charts:";
|
|
|
|
|
foreach (string err in errors)
|
|
|
|
|
message += $"\n{err}";
|
|
|
|
|
|
2020-04-19 10:02:55 +02:00
|
|
|
|
MessageBox.Show(
|
2020-04-19 14:13:12 +02:00
|
|
|
|
message,
|
|
|
|
|
"Warning",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Warning
|
2020-04-19 10:02:55 +02:00
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
ResultSet = output.ToArray();
|
|
|
|
|
ActionSet = actions;
|
|
|
|
|
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
private void SingleConvert()
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
try
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
// Single convert
|
|
|
|
|
using (var browser = new SaveFileDialog())
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
browser.Filter = "Sound Voltex Chart File|*.vox|All Files|*.*";
|
|
|
|
|
if (browser.ShowDialog() != DialogResult.OK)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var ksh = new Ksh();
|
2023-01-06 14:58:29 +01:00
|
|
|
|
ksh.Parse(_target, Options);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
|
|
|
|
|
var vox = new VoxChart();
|
|
|
|
|
vox.Import(ksh);
|
|
|
|
|
vox.Serialize(browser.FileName);
|
|
|
|
|
|
2020-04-19 10:02:55 +02:00
|
|
|
|
MessageBox.Show(
|
2020-04-19 14:13:12 +02:00
|
|
|
|
"Chart has been converted successfully",
|
|
|
|
|
"Information",
|
2020-04-19 10:02:55 +02:00
|
|
|
|
MessageBoxButtons.OK,
|
2020-04-19 14:13:12 +02:00
|
|
|
|
MessageBoxIcon.Information
|
2020-04-19 10:02:55 +02:00
|
|
|
|
);
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
DialogResult = DialogResult.OK;
|
2020-04-19 10:02:55 +02:00
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
$"Failed to convert ksh chart.\n{ex.Message}",
|
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Error
|
|
|
|
|
);
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
private void BulkConvert()
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var errors = new List<string>();
|
2023-01-06 14:58:29 +01:00
|
|
|
|
using (var browser = new CommonOpenFileDialog())
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
browser.IsFolderPicker = true;
|
|
|
|
|
browser.Multiselect = false;
|
|
|
|
|
|
|
|
|
|
if (browser.ShowDialog() != CommonFileDialogResult.Ok)
|
2020-04-19 14:13:12 +02:00
|
|
|
|
return;
|
2023-01-06 14:58:29 +01:00
|
|
|
|
|
|
|
|
|
string outputDir = browser.FileName;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
using (var loader = new LoadingForm())
|
2020-04-19 10:02:55 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
loader.SetAction(dialog =>
|
2020-04-19 14:13:12 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
var directories = Directory.GetDirectories(_target);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
int progress = 0;
|
|
|
|
|
foreach (string dir in directories)
|
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
dialog.SetStatus($"Processing {Path.GetFileName(dir)}..");
|
|
|
|
|
dialog.SetProgress((progress++ / (float)directories.Length) * 100f);
|
2020-04-19 14:13:12 +02:00
|
|
|
|
foreach (var fn in Directory.GetFiles(dir, "*.ksh"))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
// Determine output path
|
|
|
|
|
string path = Path.Combine(
|
2023-01-06 14:58:29 +01:00
|
|
|
|
$"{outputDir}",
|
2020-04-19 14:13:12 +02:00
|
|
|
|
$"{Path.GetFileName(dir)}\\"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Create output folder if it's not exists
|
|
|
|
|
Directory.CreateDirectory(path);
|
|
|
|
|
string output = Path.Combine(path, Path.GetFileName(fn.Replace(".ksh", ".vox")));
|
2020-04-19 10:02:55 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
// If you happen to read the source, you're probably looking for these boring lines
|
|
|
|
|
var ksh = new Ksh();
|
|
|
|
|
ksh.Parse(fn, Options);
|
2020-04-19 10:02:55 +02:00
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
var vox = new VoxChart();
|
|
|
|
|
vox.Import(ksh);
|
|
|
|
|
vox.Serialize(output);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
string err = $"Failed attempt to convert ksh file: {Path.GetFileName(fn)} ({ex.Message})";
|
|
|
|
|
errors.Add(err);
|
|
|
|
|
Debug.WriteLine(err);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
dialog.Complete();
|
2020-04-19 14:13:12 +02:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
loader.ShowDialog();
|
2020-04-19 10:02:55 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-19 14:13:12 +02:00
|
|
|
|
if (errors.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
"Chart has been converted successfully",
|
|
|
|
|
"Information",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Information
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string message = "Failed to convert one or more charts:";
|
|
|
|
|
foreach (string err in errors)
|
|
|
|
|
message += $"\n{err}";
|
|
|
|
|
|
|
|
|
|
MessageBox.Show(
|
|
|
|
|
message,
|
|
|
|
|
"Error",
|
|
|
|
|
MessageBoxButtons.OK,
|
|
|
|
|
MessageBoxIcon.Warning
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DialogResult = DialogResult.OK;
|
|
|
|
|
Close();
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
2020-04-19 10:02:55 +02:00
|
|
|
|
|
2020-04-18 22:24:48 +02:00
|
|
|
|
private void LoadJacket(ChartInfo info)
|
|
|
|
|
{
|
|
|
|
|
var chart = info.Source;
|
|
|
|
|
if (chart == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PictureBox pictureBox = null;
|
|
|
|
|
string tag = ((int)chart.Difficulty).ToString();
|
|
|
|
|
foreach (var control in LevelGroupBox.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (control is PictureBox p && p.Tag.ToString() == tag)
|
|
|
|
|
{
|
|
|
|
|
pictureBox = p;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pictureBox == null)
|
|
|
|
|
return;
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
string filename = Path.Combine(Path.GetDirectoryName(info.FileName) ?? "", chart.JacketFileName);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
if (!File.Exists(filename))
|
|
|
|
|
{
|
|
|
|
|
pictureBox.Image = DummyJacket;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using (var image = Image.FromFile(filename))
|
|
|
|
|
pictureBox.Image = new Bitmap(image);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
pictureBox.Image = DummyJacket;
|
|
|
|
|
Debug.WriteLine("Failed load ksh jacket: {0} ({1})", filename, ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
private void UpdateLevels()
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
|
|
|
|
var buttons = new List<Button>();
|
|
|
|
|
foreach (var control in LevelGroupBox.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (control is Button button)
|
|
|
|
|
buttons.Add(button);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (Difficulty diff in Enum.GetValues(typeof(Difficulty)))
|
|
|
|
|
{
|
|
|
|
|
Button button = null;
|
|
|
|
|
string tag = ((int)diff).ToString();
|
|
|
|
|
foreach (var bt in buttons)
|
|
|
|
|
{
|
|
|
|
|
if (bt.Tag.ToString() == tag)
|
|
|
|
|
{
|
|
|
|
|
button = bt;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
if (!_charts.ContainsKey(diff) || _charts[diff] == null)
|
2020-04-18 22:24:48 +02:00
|
|
|
|
{
|
2023-01-06 14:58:29 +01:00
|
|
|
|
_charts.Remove(diff);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
if (button != null)
|
|
|
|
|
button.Text = "--";
|
|
|
|
|
|
|
|
|
|
foreach (var control in LevelGroupBox.Controls)
|
|
|
|
|
{
|
|
|
|
|
if (control is PictureBox picture && picture.Tag.ToString() == tag)
|
|
|
|
|
{
|
|
|
|
|
picture.Image = DummyJacket;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (button != null)
|
|
|
|
|
{
|
|
|
|
|
switch (diff)
|
|
|
|
|
{
|
2020-04-19 14:13:12 +02:00
|
|
|
|
case Difficulty.Novice: button.Text = "NOV"; break;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
case Difficulty.Advanced: button.Text = "ADV"; break;
|
2020-04-19 14:13:12 +02:00
|
|
|
|
case Difficulty.Exhaust: button.Text = "EXH"; break;
|
2020-04-18 22:24:48 +02:00
|
|
|
|
default:
|
|
|
|
|
button.Text = InfVerDropDown.SelectedItem.ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 14:58:29 +01:00
|
|
|
|
LoadJacket(_charts[diff]);
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 14:58:29 +01:00
|
|
|
|
|
|
|
|
|
private void OnPreviewTimePickerValueChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (PreviewTimePicker.Value.Minute == 59)
|
|
|
|
|
PreviewTimePicker.Value = PreviewTimePicker.Value.AddMinutes(1);
|
|
|
|
|
else if (PreviewTimePicker.Value.Minute >= 11)
|
|
|
|
|
PreviewTimePicker.Value = PreviewTimePicker.Value.AddMinutes(-1);
|
|
|
|
|
|
|
|
|
|
if (PreviewTimePicker.Value.Minute == 10)
|
|
|
|
|
PreviewTimePicker.Value = PreviewTimePicker.Value.AddSeconds(-PreviewTimePicker.Value.Second);
|
|
|
|
|
}
|
2020-04-18 22:24:48 +02:00
|
|
|
|
}
|
|
|
|
|
}
|