forked from NotMichaelChen/ctb_calc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
100 lines (85 loc) · 3.31 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using BeatmapInfo;
using CustomExceptions;
using DebugTools;
using DifficultyProcessor;
//TODO: Overhaul exception system
public class Program
{
public static void Main(string[] args)
{
Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location));
DebugController debugger = new DebugController();
//Load in custom beatmaps if specified
args = debugger.LoadCustom(args);
//Display a message if no files are specified
if(args.Length == 0)
{
Console.WriteLine("CTB Difficulty Analyzer");
Console.WriteLine("Just drag your beatmap (.osu file) onto this program to measure difficulty");
Console.WriteLine("Press any key to exit...");
}
//Otherwise try to run the program, and catch and display any exceptions that arise
else
{
Console.WriteLine("Calculating...");
SortedList<double, string> beatmaps = new SortedList<double, string>();
List<DiffCalc> calculators = new List<DiffCalc>();
Stopwatch timer = new Stopwatch();
try
{
int count = 0;
foreach(string name in args)
{
timer.Start();
Beatmap map = new Beatmap(name);
DiffCalc calc;
try
{
calc = new DiffCalc(map);
}
catch(InvalidBeatmapException)
{
//Skip this beatmap if it's not a standard or ctb map, but only if
//it was loaded through debug
if(debugger.IsLoadCustom())
continue;
else
throw;
}
string title = calc.GetBeatmapTitle() + ": \t";
double difficulty = calc.GetDifficulty();
timer.Stop();
title += timer.ElapsedMilliseconds;
beatmaps[difficulty] = title;
calculators.Add(calc);
timer.Reset();
count++;
Console.Write(Math.Round((double)count * 100 / args.Length) + "%\r");
}
Console.WriteLine("\n");
for(int i = beatmaps.Count - 1; i >= 0; i--)
{
string[] titleandtime = beatmaps.Values[i].Split('\t');
Console.WriteLine(titleandtime[0] + beatmaps.Keys[i]);
Console.WriteLine("Calculation Time (ms): " + titleandtime[1] + "\n");
}
debugger.WriteDebug(calculators.ToArray());
Console.WriteLine("\nDone.");
}
catch(Exception e)
{
Console.WriteLine(e);
}
finally
{
//Just in case the timer is still running
timer.Stop();
}
}
Console.ReadKey();
}
}