-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathForm1.cs
More file actions
81 lines (67 loc) · 2.94 KB
/
Form1.cs
File metadata and controls
81 lines (67 loc) · 2.94 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SaberSongSpeed {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
mapTextBox.MaxLength = int.MaxValue;
}
private void convertButton_Click(object sender, EventArgs e) {
string[] multiplierLines = multiplierInput.Lines;
float multiplier;
try {
if (multiplierLines.Length > 0) {
if (!float.TryParse(multiplierLines[0], out multiplier)) {
infoLabel.Text = "Your multiplier value is invalid! You must use a valid decimal number (above zero).";
return;
}
} else {
infoLabel.Text = "Your multiplier value is invalid! You must use a valid decimal number (above zero).";
return;
}
} catch (Exception ex) {
Console.WriteLine(ex.ToString());
infoLabel.Text = "Your multiplier value is invalid! You must use a valid decimal number (above zero).";
return;
}
string[] maps = mapTextBox.Lines;
if (maps.Length < 1) {
infoLabel.Text = "You must include the map data you wish to convert!";
return;
}
try {
string[] newMaps = new string[maps.Length];
for (int i = 0; i < maps.Length; i++) {
string[] subMap = maps[i].Split('{');
for (int j = 0; j < subMap.Length; j++) {
string s = subMap[j];
if (s.StartsWith("\"_time\":")) {
s = s.Split(',')[0].Split(':')[1];
float t = float.Parse(s);
subMap[j] = subMap[j].Replace("time\":" + t, "time\":" + (t / multiplier));
if (subMap[j].Contains("_duration")) {
s = subMap[j].Split(':')[4].Split(',')[0];
t = float.Parse(s);
subMap[j] = subMap[j].Replace("duration\":" + t, "duration\":" + (t / multiplier));
}
//Console.WriteLine(s);
}
}
newMaps[i] = string.Join("{", subMap);
}
mapTextBox.Lines = newMaps;
infoLabel.Text = "Done!";
} catch (Exception ex) {
infoLabel.Text = "There was an error during conversion!";
Console.WriteLine(ex.ToString());
}
}
}
}