Skip to content

Commit

Permalink
Added "Clear" button
Browse files Browse the repository at this point in the history
Fixed missing textures from API model
Removed latest version check and version label.
  • Loading branch information
agaertner authored and dlamkins committed Oct 3, 2020
1 parent 2121e86 commit 23593cc
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 128 deletions.
9 changes: 3 additions & 6 deletions Controls/PlayerButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@ public class PlayerButton : DetailsButton
private readonly Texture2D PIXEL;
private readonly Texture2D SEPARATOR;

private BitmapFont _font;

private bool _isNew = true;

private CommonFields.Player _player;

public PlayerButton()
{
BORDER_SPRITE = BORDER_SPRITE ?? Content.GetTexture(@"controls/detailsbutton/605003");
Expand All @@ -33,6 +27,7 @@ public PlayerButton()
Size = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
}

private BitmapFont _font;
public BitmapFont Font
{
get => _font;
Expand All @@ -44,6 +39,7 @@ public BitmapFont Font
}
}

private CommonFields.Player _player;
public CommonFields.Player Player
{
get => _player;
Expand All @@ -54,6 +50,7 @@ public CommonFields.Player Player
}
}

private bool _isNew = true;
public bool IsNew
{
get => _isNew;
Expand Down
81 changes: 37 additions & 44 deletions KillProofModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ protected override void DefineSettings(SettingCollection settings)
private string SORTBY_TITLE;
private string SORTBY_RAID;
private string SORTBY_FRACTAL;
private string SmartPingMenuSettingDisplayName;
private string SmartPingMenuSettingDescription;
//private string SmartPingMenuSettingDisplayName;
//private string SmartPingMenuSettingDescription;
private string KillProofTabName;
private string NewVersionFound;
private string NotificationProfileAvailable;
Expand All @@ -115,11 +115,12 @@ protected override void DefineSettings(SettingCollection settings)
private string SmartPingMenuSendButtonTooltip;
private string SmartPingMenuRandomizeButtonTooltip;
private string SmartPingMenuRightclickSendMessage;
private string ClearButtonText;
private string ClearButtonTooltipText;
private void ChangeLocalization(object sender, EventArgs e)
{
SmartPingMenuSettingDisplayName = Properties.Resources.Kill_Proof_Smart_Ping_Menu;
SmartPingMenuSettingDescription = Properties.Resources.Quick_access_to_ping_kill_proofs_;
KillProofTabName = Properties.Resources.KillProof;
//SmartPingMenuSettingDisplayName = Properties.Resources.Kill_Proof_Smart_Ping_Menu;
//SmartPingMenuSettingDescription = Properties.Resources.Quick_access_to_ping_kill_proofs_;
NewVersionFound = Properties.Resources.A_new_version_of_the_KillProof_module_was_found_;
NotificationProfileAvailable = Properties.Resources.profile_available;
SmartPingMenuToggleCheckboxText = Properties.Resources.Show_Smart_Ping_Menu;
Expand All @@ -141,9 +142,11 @@ private void ChangeLocalization(object sender, EventArgs e)
SmartPingMenuSendButtonTooltip = Properties.Resources.Send_To_Chat_nLeft_Click__Only_send_code_up_to_a_stack_s_worth__250x____nRight_Click__Send_killproof_me_total_amount_;
SmartPingMenuRandomizeButtonTooltip = Properties.Resources.Random_token_from_selected_wing_when_pressing_Send_To_Chat__nLeft_Click__Toggle_nRight_Click__Iterate_wings;
SmartPingMenuRightclickSendMessage = Properties.Resources.Total___0__of__1___killproof_me__2__;
ClearButtonText = Properties.Resources.Clear;
ClearButtonTooltipText = Properties.Resources.Removes_profiles_of_players_which_are_not_in_squad_;

SORTBY_ALL = Properties.Resources.Everything;
SORTBY_KILLPROOF = Properties.Resources.KillProof;
SORTBY_KILLPROOF = Properties.Resources.Progress_Proofs;
SORTBY_TOKEN = Properties.Resources.Tokens;
SORTBY_TITLE = Properties.Resources.Titles;
SORTBY_RAID = Properties.Resources.Raid_Titles;
Expand Down Expand Up @@ -312,24 +315,6 @@ protected override void Unload()

#region Module Logic

private async Task<bool> IsLatestVersion()
{
var (responseSuccess, remoteManifest) =
await GetJsonResponse<Manifest>(
"https://raw.githubusercontent.com/blish-hud/KillProof-Module/master/manifest.json");
if (responseSuccess)
{
if (ModuleInstance.Version >= remoteManifest.Version)
return true;
Logger.Warn(NewVersionFound + ' ' + remoteManifest.Version.Clean());
}
else
{
Logger.Info("Failed to check for new version.");
}
return false;
}

#region Render Getters

private async void LoadTokenIcons()
Expand Down Expand Up @@ -539,7 +524,7 @@ private void PlayerAddedEvent(CommonFields.Player player)

if (optionalButton == null)
{
if (_displayedPlayers.Count() == MAX_PLAYERS) _displayedPlayers.Dequeue().Dispose();
if (_displayedPlayers.Count() == MAX_PLAYERS) _displayedPlayers.Dequeue()?.Dispose();

var playerButton = new PlayerButton
{
Expand Down Expand Up @@ -689,21 +674,7 @@ private Panel BuildHomePanel(WindowBase wndw)
ShowShadow = true,
Text = PoweredByText
};
var checkUpdate = Task.Run(() => IsLatestVersion());
checkUpdate.Wait();
var versionLabel = new Label
{
Parent = footer,
Size = footer.Size,
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Bottom,
StrokeText = true,
ShowShadow = true,
Text = checkUpdate.Result
? ModuleInstance.Version.Clean()
: UpdateAvailableVisitText,
TextColor = checkUpdate.Result ? Color.White : Color.Red
};

/* ###################
/ </FOOTER>
/ ################### */
Expand All @@ -717,6 +688,26 @@ private Panel BuildHomePanel(WindowBase wndw)
ShowTint = true
};

if (GameService.ArcDps.Loaded)
{
var clearButton = new StandardButton()
{
Parent = hPanel,
Size = new Point(100, 30),
Location = new Point(_squadPanel.Location.X + _squadPanel.Width - 100 - RIGHT_MARGIN, _squadPanel.Location.Y + _squadPanel.Height + BOTTOM_MARGIN),
Text = ClearButtonText,
BasicTooltipText = ClearButtonTooltipText
};
clearButton.Click += delegate
{
foreach (var c in _displayedPlayers.Where(c => c != null)
.Where(c
=> !GameService.ArcDps.Common.PlayersInSquad.Any(p
=> p.Value.AccountName.Equals(c.Player.AccountName))))
c.Dispose();
};
}

return hPanel;
}

Expand All @@ -732,8 +723,7 @@ private void MouseLeftSortButton(object sender, MouseEventArgs e)
bSortMethod.Size = new Point(32, 32);
}

private void FinishLoadingKillProofPanel(WindowBase wndw, Panel hPanel, CommonFields.Player player,
KillProof currentAccount)
private void FinishLoadingKillProofPanel(WindowBase wndw, Panel hPanel, CommonFields.Player player, KillProof currentAccount)
{
if (currentAccount != null)
{
Expand Down Expand Up @@ -990,7 +980,7 @@ private void FinishLoadingKillProofPanel(WindowBase wndw, Panel hPanel, CommonFi
{
Parent = _squadPanel,
Player = newPlayer,
Icon = GameService.Content.GetTexture("733268"),
Icon = GameService.Content.GetTexture("common/733268"),
Font = GameService.Content.GetFont(ContentService.FontFace.Menomonia,
ContentService.FontSize.Size16, ContentService.FontStyle.Regular),
IsNew = false
Expand Down Expand Up @@ -1156,12 +1146,15 @@ orderby player.IsNew descending
select player;

var pos = 0;
foreach (var e in sorted)
foreach (var e in sorted.Where(x => x != null))
{
var x = pos % 3;
var y = pos / 3;
e.Location = new Point(x * (e.Width + 8), y * (e.Height + 8));

if (e.Parent == null)
e.Parent = _squadPanel;

((Panel) e.Parent).VerticalScrollOffset = 0;
e.Parent.Invalidate();
if (e.Visible) pos++;
Expand Down
18 changes: 6 additions & 12 deletions Persistance/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ internal enum RaidWingEventType
internal class Resources
{
[JsonProperty("general_tokens")] public IList<Token> GeneralTokens { get; set; }
[JsonProperty("raids")] public IList<Raid> Raids { get; set; }
[JsonProperty("fractals")] public IList<Fractal> Fractals { get; set; }
[JsonProperty("fractals")] public IReadOnlyList<Token> Fractals { get; set; }
[JsonProperty("raids")] public IReadOnlyList<Raid> Raids { get; set; }

public Wing GetWing(int index)
{
Expand Down Expand Up @@ -66,7 +66,7 @@ private IEnumerable<Event> GetAllEvents()
public IEnumerable<Token> GetAllTokens()
{
return GeneralTokens
.Concat(Fractals.Where(fractal => fractal.Token != null).Select(fractal => fractal.Token))
.Concat(Fractals.Where(fractal => fractal != null).Select(fractal => fractal))
.Concat(GetAllEvents().Where(encounter => encounter.Token != null)
.Select(encounter => encounter.Token));
}
Expand Down Expand Up @@ -98,14 +98,14 @@ public Event GetEvent(string id)
internal class Raid
{
[JsonProperty("id")] public string Id { get; set; }
[JsonProperty("wings")] public IList<Wing> Wings { get; set; }
[JsonProperty("wings")] public IReadOnlyList<Wing> Wings { get; set; }
}

internal class Wing
{
[JsonProperty("id")] public string Id { get; set; }
[JsonProperty("map_id")] public int MapId { get; set; }
[JsonProperty("events")] public IList<Event> Events { get; set; }
[JsonProperty("events")] public IReadOnlyList<Event> Events { get; set; }

public IEnumerable<Token> GetTokens()
{
Expand All @@ -117,7 +117,7 @@ internal class Event
{
[JsonProperty("id")] public string Id { get; set; }
[JsonProperty("name")] public string Name { get; set; }
[JsonProperty("miniatures")] public IList<Miniature> Miniatures { get; set; }
[JsonProperty("miniatures")] public IReadOnlyList<Miniature> Miniatures { get; set; }
[JsonProperty("token")] public Token Token { get; set; }
[JsonConverter(typeof(StringEnumConverter)), JsonProperty("type")] public RaidWingEventType Type { get; set; }
}
Expand All @@ -136,10 +136,4 @@ public class Token
[JsonProperty("icon")] public string Icon { get; set; }
[JsonProperty("amount")] public int Amount { get; set; }
}

internal class Fractal
{
[JsonProperty("id")] public int Id { get; set; }
[JsonProperty("token")] public Token Token { get; set; }
}
}
Loading

0 comments on commit 23593cc

Please sign in to comment.