Skip to content

Commit

Permalink
Added new banner item on main menu, and updated formatting on new ver…
Browse files Browse the repository at this point in the history
…sion item. Incremented version to 0.3.
  • Loading branch information
pnwparksfan committed Apr 5, 2020
1 parent e93add4 commit 7ff596a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 11 deletions.
4 changes: 3 additions & 1 deletion LiveLights/EntryPoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace LiveLights
internal class EntryPoint
{
public static GithubVersionCheck VersionCheck;
public static Version CurrentFileVersion;

private static void Main()
{
Expand All @@ -34,6 +35,7 @@ private static void Main()
}

AssemblyName pluginInfo = Assembly.GetExecutingAssembly().GetName();
CurrentFileVersion = pluginInfo.Version;
Game.LogTrivial($"Loaded {pluginInfo.Name} {pluginInfo.Version}");
if(Settings.MenuKey != Keys.None)
{
Expand All @@ -45,7 +47,7 @@ private static void Main()

if(Settings.CheckForUpdates)
{
VersionCheck = new GithubVersionCheck("pnwparksfan", "rph-live-lights", 25194022);
VersionCheck = new GithubVersionCheck("pnwparksfan", "rph-live-lights", 25207902);
Game.LogTrivial($"Latest release on github: {VersionCheck.LatestRelease?.TagName}");
if (VersionCheck.IsUpdateAvailable())
{
Expand Down
32 changes: 24 additions & 8 deletions LiveLights/Menu/VehicleMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace LiveLights.Menu
{
Expand All @@ -23,11 +24,23 @@ static VehicleMenu()
Menu.MouseControlsEnabled = false;
Menu.AllowCameraMovement = true;

BannerItem = new UIMenuItem("LiveLights by PNWParksFan", $"LiveLights was created by ~g~PNWParksFan~w~ using the RPH emergency lighting SDK. If you found this plugin useful and made something cool with it, ~y~please mention it in your credits/readme~w~. If you'd like to say thanks, you can donate to support my various modding projects at ~b~parksmods.com/donate~w~ and get member-exclusive perks. Press Enter to learn more!");
BannerItem.SetRightLabel("v" + EntryPoint.CurrentFileVersion.ToString());
BannerItem.SetLeftBadge(UIMenuItem.BadgeStyle.Heart);
BannerItem.BackColor = Color.Black;
BannerItem.ForeColor = Color.LightSkyBlue;
BannerItem.HighlightedBackColor = Color.LightSkyBlue;
BannerItem.Activated += OnBannerClicked;
Menu.AddItem(BannerItem);

if(EntryPoint.VersionCheck?.IsUpdateAvailable() == true)
{
UpdateItem = new UIMenuItem("Update Available", $"Version ~y~{EntryPoint.VersionCheck.LatestRelease.TagName}~w~ is available for download. Press ~b~Enter~w~ to download ~y~{EntryPoint.VersionCheck.LatestRelease.Name}~w~.");
UpdateItem.SetRightLabel("~o~" + EntryPoint.VersionCheck.LatestRelease.TagName);
UpdateItem.SetLeftBadge(UIMenuItem.BadgeStyle.Alert);
UpdateItem.BackColor = Color.Black;
UpdateItem.ForeColor = Color.LightSkyBlue;
UpdateItem.HighlightedBackColor = Color.LightSkyBlue;
Menu.AddItem(UpdateItem);
UpdateItem.Activated += OnUpdateClicked;
}
Expand All @@ -52,28 +65,30 @@ static VehicleMenu()
Menu.RefreshIndex();

if(UpdateItem != null)
{
Menu.CurrentSelection = 2;
} else
{
Menu.CurrentSelection = 1;
}
}

private static void OnBannerClicked(UIMenu sender, UIMenuItem selectedItem)
{
selectedItem.OpenUrl("https://parksmods.com/donate/");
}

private static void OnUpdateClicked(UIMenu sender, UIMenuItem selectedItem)
{
string url = EntryPoint.VersionCheck.LatestRelease.HtmlUrl;
if (!string.IsNullOrWhiteSpace(url))
{
System.Diagnostics.Process.Start(url);
sender.Visible = false;
NativeFunction.Natives.SET_FRONTEND_ACTIVE(true);
}
selectedItem.OpenUrl(EntryPoint.VersionCheck.LatestRelease.HtmlUrl);
}

public static void Refresh()
{
bool validVehicle = Vehicle.Exists();
foreach (UIMenuItem menuItem in Menu.MenuItems)
{
if(menuItem != UpdateItem)
if(menuItem != UpdateItem && menuItem != BannerItem)
{
menuItem.Enabled = validVehicle;
}
Expand Down Expand Up @@ -164,5 +179,6 @@ private static void OnNonEditableConfigSelected(UIMenu sender, UIMenuItem select
public static UIMenuItem SirenConfigItem { get; }
public static UIMenuRefreshableCheckboxItem EmergencyLightsOnItem { get; }
public static UIMenuRefreshableCheckboxItem SirenAudioOnItem { get; }
public static UIMenuItem BannerItem { get; }
}
}
4 changes: 2 additions & 2 deletions LiveLights/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("0.2.*")]
[assembly: AssemblyVersion("0.3.*")]
// This is required for Octokit to check the version against github
[assembly: AssemblyInformationalVersion("0.2 Beta")]
[assembly: AssemblyInformationalVersion("0.3 Beta")]
// [assembly: AssemblyVersion("1.0.0.0")]
// [assembly: AssemblyFileVersion("1.0.0.0")]
10 changes: 10 additions & 0 deletions LiveLights/Utils/MenuItems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -601,5 +601,15 @@ public static void AddAfterYield(this MenuPool pool, UIMenu menu)
pool.Add(menu);
});
}

public static void OpenUrl(this UIMenuItem item, string url)
{
if (!string.IsNullOrWhiteSpace(url))
{
System.Diagnostics.Process.Start(url);
item.Parent.Visible = false;
NativeFunction.Natives.SET_FRONTEND_ACTIVE(true);
}
}
}
}

0 comments on commit 7ff596a

Please sign in to comment.