Skip to content

Commit

Permalink
Misc: Break down "info text" information even more & small cleanup (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Piotrekol committed Aug 30, 2020
1 parent e5fdfbd commit b4ec134
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 101 deletions.
12 changes: 7 additions & 5 deletions App/Initalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void Run(string[] args)
}
catch (Exception e)
{
UserDialogs.OkMessageBox("Warning","osu! scores database could not be loaded. Score related searches will not work in this session."+ Environment.NewLine + Environment.NewLine + e);
UserDialogs.OkMessageBox("Warning", "osu! scores database could not be loaded. Score related searches will not work in this session." + Environment.NewLine + Environment.NewLine + e);
}

BeatmapUtils.OsuSongsDirectory = OsuFileIo.OsuSettings.CustomBeatmapDirectoryLocation;
Expand Down Expand Up @@ -110,15 +110,17 @@ public void Run(string[] args)

private void SetTextData(IInfoTextModel model)
{
model.SetBeatmapCount(LoadedBeatmaps.Count);
model.BeatmapCount = LoadedBeatmaps.Count;
CollectionsManager.LoadedCollections.CollectionChanged += (s, a) =>
{
model.SetCollectionCount(CollectionsManager.CollectionsCount, CollectionsManager.BeatmapsInCollectionsCount);
model.SetMissingMapSetsCount(CollectionsManager.MissingMapSetsCount);
model.CollectionsCount = CollectionsManager.CollectionsCount;
model.BeatmapsInCollectionsCount = CollectionsManager.BeatmapsInCollectionsCount;
model.MissingMapSetsCount = CollectionsManager.MissingMapSetsCount;
model.UnknownMapCount = CollectionsManager.UnknownMapCount;
};
LoadedBeatmaps.CollectionChanged += (s, a) =>
{
model.SetBeatmapCount(LoadedBeatmaps.Count);
model.BeatmapCount = LoadedBeatmaps.Count;
};
}

Expand Down
12 changes: 5 additions & 7 deletions App/Interfaces/Controls/IInfoTextModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ namespace App.Interfaces
{
public interface IInfoTextModel
{
void SetBeatmapCount(int beatmapCount);
void SetCollectionCount(int collectionsCount, int beatmapsInCollectionsCount);
void SetMissingMapSetsCount(int missingBeatmapsCount);
int BeatmapCount { get; }
int BeatmapsInCollectionsCount { get; }
int MissingMapSetsCount { get; }
int CollectionsCount { get; }
int BeatmapCount { get; set; }
int BeatmapsInCollectionsCount { get; set; }
int MissingMapSetsCount { get; set; }
int CollectionsCount { get; set; }
int UnknownMapCount { get; set; }
IUpdateModel GetUpdater();
void EmitUpdateTextClicked();
event EventHandler CountsUpdated;
Expand Down
75 changes: 54 additions & 21 deletions App/Models/Controls/InfoTextModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,48 +5,81 @@ namespace App.Models
{
public class InfoTextModel : IInfoTextModel
{
private int _beatmapCount;
private int _beatmapsInCollectionsCount;
private int _missingMapSetsCount;
private int _collectionsCount;
private int _unknownMapCount;

public InfoTextModel(IUpdateModel updateModel)
{
UpdateModel = updateModel;
}

public int BeatmapCount { get; set; }
public int BeatmapsInCollectionsCount { get; set; }
public int MissingMapSetsCount { get; set; }
public int CollectionsCount { get; set; }
private IUpdateModel UpdateModel { get; }
public IUpdateModel GetUpdater()
public int BeatmapCount
{
return UpdateModel;
get => _beatmapCount;
set
{
_beatmapCount = value;
OnCountsUpdated();
}
}

public void EmitUpdateTextClicked()
public int BeatmapsInCollectionsCount
{
UpdateTextClicked?.Invoke(this, EventArgs.Empty);
get => _beatmapsInCollectionsCount;
set
{
_beatmapsInCollectionsCount = value;
OnCountsUpdated();
}
}

public event EventHandler CountsUpdated;
public event EventHandler UpdateTextClicked;
public int MissingMapSetsCount
{
get => _missingMapSetsCount;
set
{
_missingMapSetsCount = value;
OnCountsUpdated();
}
}

public void SetBeatmapCount(int beatmapCount)
public int CollectionsCount
{
BeatmapCount = beatmapCount;
OnCountsUpdated();
get => _collectionsCount;
set
{
_collectionsCount = value;
OnCountsUpdated();
}
}

public void SetCollectionCount(int collectionsCount, int beatmapsInCollectionsCount)
public int UnknownMapCount
{
CollectionsCount = collectionsCount;
BeatmapsInCollectionsCount = beatmapsInCollectionsCount;
OnCountsUpdated();
get => _unknownMapCount;
set
{
_unknownMapCount = value;
OnCountsUpdated();
}
}

public void SetMissingMapSetsCount(int missingBeatmapsCount)
private IUpdateModel UpdateModel { get; }
public IUpdateModel GetUpdater()
{
return UpdateModel;
}

public void EmitUpdateTextClicked()
{
MissingMapSetsCount = missingBeatmapsCount;
OnCountsUpdated();
UpdateTextClicked?.Invoke(this, EventArgs.Empty);
}

public event EventHandler CountsUpdated;
public event EventHandler UpdateTextClicked;

protected virtual void OnCountsUpdated()
{
CountsUpdated?.Invoke(this, EventArgs.Empty);
Expand Down
7 changes: 2 additions & 5 deletions App/Presenters/Controls/InfoTextPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using App.Interfaces;
using GuiComponents.Interfaces;

Expand Down Expand Up @@ -41,10 +41,7 @@ private void ViewOnUpdateTextClicked(object sender, EventArgs eventArgs)

private void ModelOnCountsUpdated(object sender, EventArgs eventArgs)
{
_view.BeatmapLoaded = string.Format(LoadedBeatmaps, Model.BeatmapCount);
_view.CollectionsLoaded = string.Format(LoadedCollections, Model.CollectionsCount);
_view.BeatmapsInCollections = string.Format(LoadedCollectionsBeatmaps, Model.BeatmapsInCollectionsCount);
_view.BeatmapsMissing = string.Format(MissingBeatmaps, Model.MissingMapSetsCount);
_view.CollectionManagerStatus = $"Loaded {Model.BeatmapCount} beatmaps && {Model.CollectionsCount} collections with {Model.BeatmapsInCollectionsCount} beatmaps. Missing {Model.MissingMapSetsCount} downloadable map sets. {Model.UnknownMapCount} unknown maps.";
SetUpdateText();
}

Expand Down
4 changes: 2 additions & 2 deletions CollectionManagerDll/DataTypes/Mods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public enum Mods
K1 = 1 << 26,
K3 = 1 << 27,
K2 = 1 << 28,
Sv2 = 1 << 29, //Score V2
Lm = 1 << 30, //Last mod
Sv2 = 1 << 29,
Lm = 1 << 30,
SpeedChanging = Dt | Ht | Nc,
MapChanging = Hr | Ez | SpeedChanging
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ public class CollectionsManagerWithCounts : CollectionsManager
{
private readonly HashSet<string> _missingBeatmapHashes = new HashSet<string>();
private readonly HashSet<int> _downloadableMapSetIds = new HashSet<int>();
public int MissingMapSetsCount => _missingBeatmapHashes.Count + DownloadableBeatmapsCount;
public int DownloadableBeatmapsCount => _downloadableMapSetIds.Count;
public int MissingMapSetsCount => _downloadableMapSetIds.Count;
public int UnknownMapCount => _missingBeatmapHashes.Count;
public int BeatmapsInCollectionsCount { get; private set; }
public int CollectionsCount => LoadedCollections.Count;

public CollectionsManagerWithCounts(Beatmaps loadedBeatmaps) : base(loadedBeatmaps)
{
}


protected override void AfterCollectionsEdit()
{
var beatmapCount = 0;
Expand Down
5 changes: 1 addition & 4 deletions Common/Interfaces/Controls/IInfoTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ public interface IInfoTextView
{
bool ColorUpdateText { set; }
string UpdateText { set; }
string BeatmapLoaded { set; }
string CollectionsLoaded { set; }
string BeatmapsInCollections { set; }
string BeatmapsMissing { set; }
string CollectionManagerStatus { set; }

event EventHandler UpdateTextClicked;
}
Expand Down
62 changes: 12 additions & 50 deletions GuiComponents/Controls/InfoTextView.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions GuiComponents/Controls/InfoTextView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ public bool ColorUpdateText
}

public string UpdateText { set { label_UpdateText.Text = value; } }
public string BeatmapLoaded { set { label_LoadedBeatmaps.Text = value; } }
public string CollectionsLoaded { set { label_LoadedCollections.Text = value; } }
public string BeatmapsInCollections { set { label_BeatmapsInCollections.Text = value; } }
public string BeatmapsMissing { set { label_beatmapsMissing.Text = value; } }
public string CollectionManagerStatus { set { label_CollectionManagerStatus.Text = value; } }

public event EventHandler UpdateTextClicked;
}
Expand Down

0 comments on commit b4ec134

Please sign in to comment.