Skip to content

Commit

Permalink
fixed time error, added playfield outline
Browse files Browse the repository at this point in the history
  • Loading branch information
ThereGoesMySanity committed Aug 28, 2020
1 parent 4524fda commit 9e1b19e
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 36 deletions.
2 changes: 2 additions & 0 deletions OsuMissAnalyzer/MissAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ private Bitmap DrawHitObject(int num, Rectangle area)
replayFramesEnd++)
{
}
p.Color = Color.Black;
g.DrawRectangle(p, Rectangle.Round(ScaleToRect(new RectangleF(Scale(bounds.Location, -1), new SizeF(512, 384)), bounds, area)));
p.Color = Color.Gray;
for (int q = hitObjectsEnd - 1; q > hitObjectsStart; q--)
{
Expand Down
28 changes: 21 additions & 7 deletions OsuMissAnalyzer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,28 @@ public static void Main(string[] args)
}

Options options = new Options("options.cfg");
ReplayLoader replayLoader = new ReplayLoader();
replayLoader.Load(replay, beatmap);
if (replayLoader.Replay == null || replayLoader.Beatmap == null) return;
try
{
ReplayLoader replayLoader = new ReplayLoader();
if (!replayLoader.Load(replay, beatmap)) return;
if (replayLoader.Replay == null || replayLoader.Beatmap == null)
{
ShowErrorDialog("Couldn't find " + (replayLoader.Replay == null ? "replay" : "beatmap"));
}

missAnalyzer = new MissAnalyzer(replayLoader);
controller = new MissWindowController(missAnalyzer, replayLoader);
window = new MissWindow(controller);
Application.Run(window);
missAnalyzer = new MissAnalyzer(replayLoader);
controller = new MissWindowController(missAnalyzer, replayLoader);
window = new MissWindow(controller);
Application.Run(window);
} catch (Exception e)
{
ShowErrorDialog(e.Message);
File.WriteAllText("exception.log", e.ToString());
}
}
public static void ShowErrorDialog(string message)
{
MessageBox.Show(message, "Error");
}

}
Expand Down
57 changes: 30 additions & 27 deletions OsuMissAnalyzer/ReplayLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ public bool Load(string replayFile, string beatmapFile)
Debug.Print("Loading Replay file...");

Replay = replayFile == null ? LoadReplay() : new Replay(replayFile, true, false);
if (Replay == null) return false;
if (Replay == null)
return false;

Debug.Print("Loaded replay {0}", Replay.Filename);
Debug.Print("Loading Beatmap file...");

Beatmap = beatmapFile == null ? LoadBeatmap(Replay) : new Beatmap(beatmapFile);
if (Beatmap == null) return false;
if (Beatmap == null)
return false;

Debug.Print("Loaded beatmap {0}", Beatmap.Filename);
Debug.Print("Analyzing... ");
Expand All @@ -39,8 +41,7 @@ public bool Load(string replayFile, string beatmapFile)

if (ReplayAnalyzer.misses.Count == 0)
{
Debug.Print("There is no miss in this replay. ");
Console.ReadLine();
Program.ShowErrorDialog("There is no miss in this replay.");
return false;
}
return true;
Expand Down Expand Up @@ -81,6 +82,7 @@ public Replay LoadReplay()
}
}
}
if (r == null) Program.ShowErrorDialog("Couldn't find replay");
return r;
}

Expand All @@ -91,33 +93,34 @@ public Beatmap LoadBeatmap(Replay r, bool dialog = true)
{
b = Options.Opts.OsuDb.GetBeatmap(r.MapHash);
}
else
if (b == null)
{
b = getBeatmapFromHash(Directory.GetCurrentDirectory(), false);
if (b == null)
}
if (b == null)
{
if (Options.Opts.Settings.ContainsKey("songsdir"))
{
if (Options.Opts.Settings.ContainsKey("songsdir"))
{
b = getBeatmapFromHash(Options.Opts.Settings["songsdir"]);
}
else if (Options.Opts.Settings.ContainsKey("osudir")
&& File.Exists(Path.Combine(Options.Opts.Settings["osudir"], "Songs"))
)
{
b = getBeatmapFromHash(Path.Combine(Options.Opts.Settings["osudir"], "Songs"));
}
else if (dialog)
b = getBeatmapFromHash(Options.Opts.Settings["songsdir"]);
}
else if (Options.Opts.Settings.ContainsKey("osudir")
&& File.Exists(Path.Combine(Options.Opts.Settings["osudir"], "Songs"))
)
{
b = getBeatmapFromHash(Path.Combine(Options.Opts.Settings["osudir"], "Songs"));
}
}
if (b == null && dialog)
{
Program.ShowErrorDialog("Couldn't find beatmap automatically");
using (OpenFileDialog fd = new OpenFileDialog())
{
fd.Title = "Choose beatmap";
fd.Filter = "osu! beatmaps (*.osu)|*.osu";
DialogResult d = fd.ShowDialog();
if (d == DialogResult.OK)
{
using (OpenFileDialog fd = new OpenFileDialog())
{
fd.Title = "Choose beatmap";
fd.Filter = "osu! beatmaps (*.osu)|*.osu";
DialogResult d = fd.ShowDialog();
if (d == DialogResult.OK)
{
b = new Beatmap(fd.FileName);
}
}
b = new Beatmap(fd.FileName);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion OsuMissAnalyzer/UI/ReplayListItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public string[] ToRows()
{
return new string[] { (beatmap?.ToString() ?? "Unknown beatmap") + " "
+ (replay.Mods != 0? "+" + replay.Mods.ToString() + " " : "")
, TimeUtils.ToLongString(DateTime.Now - replay.PlayTime) + " ago"
, TimeUtils.ToLongString(DateTime.Now.ToUniversalTime() - replay.PlayTime.ToUniversalTime()) + " ago"
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion OsuMissAnalyzer/Utils/MathUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static PointF flip(PointF p, float s, bool hr)
/// <param name="p1">The point.</param>
/// <param name="rect">The bounding rectangle to subtract from</param>
/// <param name="hr">Whether or not Hard Rock is on.</param>
public static PointF pSub(PointF p1, RectangleF rect, bool hr)
public static PointF pSub(PointF p1, RectangleF rect, bool hr = false)
{
PointF p = PointF.Subtract(p1, new SizeF(rect.Location));
return flip(p, rect.Width, hr);
Expand Down

0 comments on commit 9e1b19e

Please sign in to comment.