Skip to content

Commit

Permalink
Merge pull request #124 from blish-hud/feat/events-common-requests
Browse files Browse the repository at this point in the history
Updated to Blish HUD v0.11.0+.  Added feature to move where notificat…
  • Loading branch information
dlamkins committed Oct 25, 2021
2 parents 2916f44 + aac65f1 commit 5aa7f68
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 35 deletions.
22 changes: 22 additions & 0 deletions Events Module/BasicSettingsView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Blish_HUD.Controls;
using Blish_HUD.Graphics.UI;
using Microsoft.Xna.Framework;

namespace Events_Module {
public class BasicSettingsView : View {

protected override void Build(Container buildPanel) {
var setPosition = new StandardButton() {
Text = "Set Notification Position",
Width = 196,
Location = new Point(32, 32),
Parent = buildPanel
};

setPosition.Click += SetPosition_Click;
}

private void SetPosition_Click(object sender, Blish_HUD.Input.MouseEventArgs e) => EventsModule.ModuleInstance.ShowSetNotificationPositions();

}
}
6 changes: 3 additions & 3 deletions Events Module/EventNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ private EventNotification(string title, AsyncTexture2D icon, string message, str

_icon = icon;

this.Opacity = 0f;
this.Size = new Point(NOTIFICATION_WIDTH, NOTIFICATION_HEIGHT);
this.Location = new Point(180, 60 + (NOTIFICATION_HEIGHT + 15) * _visibleNotifications);
this.Opacity = 0f;
this.Size = new Point(NOTIFICATION_WIDTH, NOTIFICATION_HEIGHT);
this.Location = new Point(EventsModule.ModuleInstance.NotificationPosition.X, EventsModule.ModuleInstance.NotificationPosition.Y + (NOTIFICATION_HEIGHT + 15) * _visibleNotifications);
this.BasicTooltipText = tooltipText;

string wrappedTitle = DrawUtil.WrapText(Content.DefaultFont14, title, this.Width - NOTIFICATION_HEIGHT - 20);
Expand Down
60 changes: 46 additions & 14 deletions Events Module/Events Module.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,18 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Compile Include="BasicSettingsView.cs" />
<Compile Include="EventNotification.cs" />
<Compile Include="EventsModule.cs" />
<Compile Include="Meta.cs" />
<Compile Include="NotificationMover.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="ScreenRegion.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.fr.resx" />
Expand All @@ -82,13 +85,15 @@
<ItemGroup>
<Reference Include="Adhesive, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Adhesive.2.0.1-alpha\lib\netstandard2.0\Adhesive.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="AsyncClipboardService, Version=1.7.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\AsyncClipboardService.1.7.1\lib\net45\AsyncClipboardService.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Blish HUD, Version=0.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\BlishHUD.0.7.0\lib\net472\Blish HUD.exe</HintPath>
<Reference Include="Blish HUD, Version=0.11.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\BlishHUD.0.11.0\lib\net472\Blish HUD.exe</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Expand All @@ -99,36 +104,51 @@
</Reference>
<Reference Include="Flurl, Version=2.8.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.2.8.2\lib\net40\Flurl.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Flurl.Http, Version=2.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Flurl.Http.2.4.2\lib\net46\Flurl.Http.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Gw2Sharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Gw2Sharp.1.0.0\lib\netstandard2.0\Gw2Sharp.dll</HintPath>
<Reference Include="Gapotchenko.FX, Version=2021.1.5.4096, Culture=neutral, PublicKeyToken=a750ee378eaf756f, processorArchitecture=MSIL">
<HintPath>..\packages\Gapotchenko.FX.2021.1.5\lib\net472\Gapotchenko.FX.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Gapotchenko.FX.Diagnostics.Process, Version=2021.1.5.4096, Culture=neutral, PublicKeyToken=a750ee378eaf756f, processorArchitecture=MSIL">
<HintPath>..\packages\Gapotchenko.FX.Diagnostics.Process.2021.1.5\lib\net472\Gapotchenko.FX.Diagnostics.Process.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Gapotchenko.FX.Threading, Version=2021.1.5.4096, Culture=neutral, PublicKeyToken=a750ee378eaf756f, processorArchitecture=MSIL">
<HintPath>..\packages\Gapotchenko.FX.Threading.2021.1.5\lib\net472\Gapotchenko.FX.Threading.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Humanizer, Version=2.6.0.0, Culture=neutral, PublicKeyToken=979442b78dfc278e, processorArchitecture=MSIL">
<HintPath>..\packages\Humanizer.Core.2.6.2\lib\netstandard2.0\Humanizer.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="MonoGame.Extended, Version=3.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Extended.3.7.0\lib\netstandard2.0\MonoGame.Extended.dll</HintPath>
<Reference Include="MonoGame.Framework, Version=3.8.0.1641, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\lib\net452\MonoGame.Framework.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="MonoGame.Framework, Version=3.7.1.189, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\lib\net45\MonoGame.Framework.dll</HintPath>
<Reference Include="protobuf-net, Version=3.0.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.3.0.101\lib\net461\protobuf-net.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="protobuf-net.Core, Version=3.0.0.0, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
<HintPath>..\packages\protobuf-net.Core.3.0.101\lib\net461\protobuf-net.Core.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
Expand Down Expand Up @@ -183,6 +203,11 @@
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System.Collections.Immutable, Version=1.2.5.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.7.1\lib\net461\System.Collections.Immutable.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
Expand All @@ -196,6 +221,11 @@
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System.Resources.Extensions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Resources.Extensions.5.0.0\lib\net461\System.Resources.Extensions.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -237,13 +267,15 @@
<UserProperties manifest_1json__JsonSchema="" />
</VisualStudio>
</ProjectExtensions>
<Import Project="..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\build\MonoGame.Framework.WindowsDX.targets" Condition="Exists('..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\build\MonoGame.Framework.WindowsDX.targets')" />
<Import Project="..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets" Condition="Exists('..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\build\MonoGame.Framework.WindowsDX.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MonoGame.Framework.WindowsDX.3.7.1.189\build\MonoGame.Framework.WindowsDX.targets'))" />
<Error Condition="!Exists('..\packages\BlishHUD.0.7.0\build\BlishHUD.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\BlishHUD.0.7.0\build\BlishHUD.targets'))" />
<Error Condition="!Exists('..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MonoGame.Framework.WindowsDX.3.8.0.1641\build\MonoGame.Framework.WindowsDX.targets'))" />
<Error Condition="!Exists('..\packages\System.Resources.Extensions.5.0.0\build\net461\System.Resources.Extensions.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\System.Resources.Extensions.5.0.0\build\net461\System.Resources.Extensions.targets'))" />
<Error Condition="!Exists('..\packages\BlishHUD.0.11.0\build\BlishHUD.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\BlishHUD.0.11.0\build\BlishHUD.targets'))" />
</Target>
<Import Project="..\packages\BlishHUD.0.7.0\build\BlishHUD.targets" Condition="Exists('..\packages\BlishHUD.0.7.0\build\BlishHUD.targets')" />
<Import Project="..\packages\System.Resources.Extensions.5.0.0\build\net461\System.Resources.Extensions.targets" Condition="Exists('..\packages\System.Resources.Extensions.5.0.0\build\net461\System.Resources.Extensions.targets')" />
<Import Project="..\packages\BlishHUD.0.11.0\build\BlishHUD.targets" Condition="Exists('..\packages\BlishHUD.0.11.0\build\BlishHUD.targets')" />
</Project>
40 changes: 33 additions & 7 deletions Events Module/EventsModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Threading.Tasks;
using Blish_HUD;
using Blish_HUD.Controls;
using Blish_HUD.Graphics.UI;
using Blish_HUD.Modules;
using Blish_HUD.Modules.Managers;
using Blish_HUD.Settings;
Expand Down Expand Up @@ -47,6 +48,8 @@ public class EventsModule : Module {
private SettingEntry<bool> _settingNotificationsEnabled;
private SettingEntry<bool> _settingChimeEnabled;

private SettingEntry<Point> _settingNotificationsPosition;

private Texture2D _textureWatch;
private Texture2D _textureWatchActive;

Expand All @@ -60,6 +63,11 @@ public bool ChimeEnabled {
set => _settingChimeEnabled.Value = value;
}

public Point NotificationPosition {
get => _settingNotificationsPosition.Value;
set => _settingNotificationsPosition.Value = value;
}

[ImportingConstructor]
public EventsModule([Import("ModuleParameters")] ModuleParameters moduleParameters) : base(moduleParameters) {
ModuleInstance = this;
Expand All @@ -71,6 +79,8 @@ protected override void DefineSettings(SettingCollection settings) {
_settingNotificationsEnabled = selfManagedSettings.DefineSetting(@"notificationsEnabled", true);
_settingChimeEnabled = selfManagedSettings.DefineSetting(@"chimeEnabled", true);

_settingNotificationsPosition = selfManagedSettings.DefineSetting("notificationPosition", new Point(180, 60));

_watchCollection = settings.AddSubCollection(@"Watching");
}

Expand All @@ -97,6 +107,20 @@ protected override void OnModuleLoaded(EventArgs e) {
base.OnModuleLoaded(e);
}

public override IView GetSettingsView() {
return new BasicSettingsView();
}

internal void ShowSetNotificationPositions() {
var tempSizeSetting = new SettingEntry<Point>() {
Value = new Point(280, 512)
};

var choseLocation = new NotificationMover(new ScreenRegion("Notifications", _settingNotificationsPosition, tempSizeSetting));
choseLocation.Parent = GameService.Graphics.SpriteScreen;
choseLocation.Size = GameService.Graphics.SpriteScreen.ContentRegion.Size;
}

private Panel BuildSettingPanel(Rectangle panelBounds) {
var etPanel = new Panel() {
CanScroll = false,
Expand Down Expand Up @@ -158,6 +182,8 @@ private Panel BuildSettingPanel(Rectangle panelBounds) {
eventPanel.FilterChildren<DetailsButton>(db => db.Text.ToLower().Contains(searchBox.Text.ToLower()));
};

eventPanel.SuspendLayout();

foreach (var meta in Meta.Events) {
var setting = _watchCollection.DefineSetting(@"watchEvent:" + meta.Name, true);

Expand Down Expand Up @@ -186,8 +212,6 @@ private Panel BuildSettingPanel(Rectangle panelBounds) {
Parent = es2,
};

Adhesive.Binding.CreateOneWayBinding(() => nextTimeLabel.Height, () => es2.ContentRegion, (rectangle => rectangle.Height), true);

if (!string.IsNullOrEmpty(meta.Wiki)) {
var glowWikiBttn = new GlowButton {
Icon = GameService.Content.GetTexture(@"102530"),
Expand Down Expand Up @@ -225,6 +249,8 @@ private Panel BuildSettingPanel(Rectangle panelBounds) {
};
}

eventPanel.ResumeLayout();

var toggleFollowBttn = new GlowButton() {
Icon = _textureWatch,
ActiveIcon = _textureWatchActive,
Expand Down Expand Up @@ -308,9 +334,11 @@ private void RepositionES() {

if (es.Visible) pos++;

// TODO: Just expose the panel to the module so that we don't have to do it this dumb way:
((Panel)es.Parent).VerticalScrollOffset = 0;
es.Parent.Invalidate();
if (es.Parent != null) {
// TODO: Just expose the panel to the module so that we don't have to do it this dumb way:
((Panel)es.Parent).VerticalScrollOffset = 0;
es.Parent.Invalidate();
}
}
}

Expand Down Expand Up @@ -378,8 +406,6 @@ protected override void Unload() {

GameService.Overlay.UserLocaleChanged -= ChangeLocalization;
GameService.Overlay.BlishHudWindow.RemoveTab(_eventsTab);
_displayedEvents.ForEach(de => de.Dispose());
_displayedEvents.Clear();
}

private IList<string> GetOrderedNextUpEventNames() {
Expand Down
6 changes: 3 additions & 3 deletions Events Module/Meta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Events_Module {
[JsonObject]
public class Meta {

private static readonly Logger Logger = Logger.GetLogger(typeof(Meta));
private static readonly Logger Logger = Logger.GetLogger<Meta>();

[JsonObject]
public struct Phase {
Expand Down Expand Up @@ -181,7 +181,7 @@ public static async Task Load(ContentsManager cm) {

if (!string.IsNullOrEmpty(meta._wikiEn)) {
var pageEn = new Uri(meta._wikiEn).Segments.Last();
var task = interwikiLinks(pageEn).ContinueWith(async v => meta._wikiLinks = await v);
var task = GetInterwikiLinks(pageEn).ContinueWith(async v => meta._wikiLinks = await v);
wikiTasks.Add(task);
}
}
Expand All @@ -196,7 +196,7 @@ public static async Task Load(ContentsManager cm) {
}

[Localizable(false)]
private static async Task<Dictionary<string, string>> interwikiLinks(string page) {
private static async Task<Dictionary<string, string>> GetInterwikiLinks(string page) {
var url = "https://wiki.guildwars2.com"
.AppendPathSegment("api.php")
.SetQueryParams(new {
Expand Down
Loading

0 comments on commit 5aa7f68

Please sign in to comment.