Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target .NET 5 and fix clickable links #27

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions ModUpdateMenu/README.md

This file was deleted.

4 changes: 1 addition & 3 deletions StardewMods.sln
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GiantCropRing", "GiantCropR
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HoldToBreakGeodes", "HoldToBreakGeodes\HoldToBreakGeodes.csproj", "{D5882AA8-4299-4A16-8E36-8C3FB5C30231}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModUpdateMenu", "ModUpdateMenu\ModUpdateMenu.csproj", "{8A3C9F04-DA76-4636-A82E-418A341A87BC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnofficialModUpdateMenu", "UnofficialModUpdateMenu\UnofficialModUpdateMenu.csproj", "{8A3C9F04-DA76-4636-A82E-418A341A87BC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NoCrows", "NoCrows\NoCrows.csproj", "{64090A36-BDC4-401D-911B-5C6A5DD147E3}"
EndProject
Expand Down Expand Up @@ -70,8 +70,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HatsOnCats", "HatsOnCats\Ha
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BetterWorkbenches", "BetterWorkbenches\BetterWorkbenches.csproj", "{359174FF-E351-4B83-9825-7EC16E9190E9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BobberDistance", "BobberDistance\BobberDistance.csproj", "{D9A78F16-4826-43E5-A2B5-0001F0637F45}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FloweryTools", "FloweryTools\FloweryTools.csproj", "{A65A9570-E318-4546-BAD0-60E953722590}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WindEffects", "WindEffects\WindEffects.csproj", "{42DE7351-807C-40C2-B62F-CBFC50A502A9}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ internal class UpdateButton : INotifiable

public UpdateButton(IModHelper helper)
{
Texture2D buttonTexture = helper.Content.Load<Texture2D>("assets/updateButton.png");
this.statusTexture = helper.Content.Load<Texture2D>("assets/statusIcons.png");
Texture2D buttonTexture = helper.ModContent.Load<Texture2D>("assets/updateButton.png");
this.statusTexture = helper.ModContent.Load<Texture2D>("assets/statusIcons.png");

this.updateButton = new ClickableTextureComponent(
new Rectangle(36, Game1.viewport.Height - 150 - 48, 81, 75), buttonTexture, new Rectangle(0, 0, 27, 25),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public override void draw(SpriteBatch b)
if (this.SMAPIText != null)
{
IClickableMenu.drawTextureBox(b, Game1.mouseCursors, new Rectangle(473, 36, 24, 24), 20, ((IClickableMenu)this).height - 25 - this.SMAPIHeight / 2, (int)(this.SMAPIWidth * 1.09), (int)(this.SMAPIHeight * 1.5) + 5, Color.White, 4f, true);
SpriteText.drawString(b, this.SMAPIText, 50, ((IClickableMenu)this).height - 30, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, this.SMAPIText, 50, ((IClickableMenu)this).height - 30, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);
}

int startX = (int)centeringOnScreen.X + 32;
Expand All @@ -93,19 +93,19 @@ public override void draw(SpriteBatch b)
xOffset += this.GetColumnWidth(j);

if (i != 0)
SpriteText.drawString(b, UpdateMenu.HeaderDivider, startX + xOffset - this.headerDividerDimensions.X, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, UpdateMenu.HeaderDivider, startX + xOffset - this.headerDividerDimensions.X, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);

string headerText = UpdateMenu.sections[i] +
(this.currentSortColumn == i ? (this.currentSortDirection == 0 ? " A" : " V") : "");
xOffset += (int)(width / 2) - SpriteText.getWidthOfString(UpdateMenu.sections[i]) / 2;
SpriteText.drawString(b, headerText, startX + xOffset, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, headerText, startX + xOffset, startY, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);
}

SpriteText.drawString(b, this.modDivider, startX, startY + 32, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, this.modDivider, startX, startY + 32, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);

if (!this.notified)
{
SpriteText.drawString(b, $"{UpdateMenu.UpdateProgress}{this.GetDots(this.numDots)}", startX + this.width / 2 - this.updateProgressDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.updateProgressDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, $"{UpdateMenu.UpdateProgress}{this.GetDots(this.numDots)}", startX + this.width / 2 - this.updateProgressDimensions.X, startY + (((IClickableMenu)this).height - 100) / 2 - this.updateProgressDimensions.Y, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.Yellow);
}
else if (this.statuses == null)
{
Expand All @@ -125,9 +125,9 @@ public override void draw(SpriteBatch b)

if (modName != status.ModName)
modName = modName.Substring(0, modName.Length - 3) + "...";
SpriteText.drawString(b, modName, startX, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, status.UpdateStatus.ToString(), startX + (int)this.GetColumnWidth(0), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", UpdateMenu.GetColorForStatus(status));
SpriteText.drawString(b, status.UpdateURLType, startX + (int)this.GetColumnWidth(0) + (int)this.GetColumnWidth(1), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", 4);
SpriteText.drawString(b, modName, startX, yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);
SpriteText.drawString(b, status.UpdateStatus.ToString(), startX + (int)this.GetColumnWidth(0), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", GetColorForStatus(status));
SpriteText.drawString(b, status.UpdateURLType, startX + (int)this.GetColumnWidth(0) + (int)this.GetColumnWidth(1), yOffset, 9999, -1, 9999, 1f, 0.88f, false, -1, "", Color.White);
yOffset += 64;
}

Expand Down Expand Up @@ -187,7 +187,12 @@ public override void receiveLeftClick(int x, int y, bool playSound = true)
{
try
{
Process.Start("https://smapi.io");
var ps = new ProcessStartInfo("https://smapi.io")
{
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
}
catch
{
Expand Down Expand Up @@ -289,7 +294,7 @@ private void ComponentHovered(ModStatus which, int offset)
break;

case 2:
this.hoverText = which.UpdateURLType != "???" ? $"Click to go to: ^{which.UpdateURL}" : "Unknown update link.";
this.hoverText = which.UpdateURL != null ? $"Click to go to: ^{which.UpdateURL}" : "Unknown update link.";
break;
}

Expand Down Expand Up @@ -383,15 +388,20 @@ private void ComponentClicked(ModStatus which, int offset)
}
else if (offset == 2)
{
Game1.playSound("bigSelect");
if (which.UpdateURLType != "???")
try
{
Process.Start(which.UpdateURL);
}
catch
try
{
var ps = new ProcessStartInfo(which.UpdateURL)
{
}
UseShellExecute = true,
Verb = "open"
};
Process.Start(ps);
Game1.playSound("bigSelect");
}
catch
{
Game1.playSound("toyPiano");
}
}
}

Expand Down Expand Up @@ -557,7 +567,7 @@ private static Point GetDimensions(string input)
return new Point((int)(p.X * (2 + (input.Contains("^") ? 0.1 : 0))), p.Y * 2);
}

private static int GetColorForStatus(ModStatus status)
private static Microsoft.Xna.Framework.Color GetColorForStatus(ModStatus status)
{
switch (status.UpdateStatus)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public override void Entry(IModHelper helper)
internal void NotifySMAPI(ISemanticVersion version)
{
//Debug Info
//this.Monitor.Log($"SMAPI: {version}");
this.Monitor.Log($"SMAPI: {version}");
this.menu.NotifySMAPI(version);
this.button.NotifySMAPI(version);
}
Expand Down Expand Up @@ -102,10 +102,12 @@ private void OnGameLaunched(object sender, GameLaunchedEventArgs e)

try
{
//this.Monitor.Log(statusRetriever.GetSMAPIUpdateVersion().ToString());
this.NotifySMAPI(statusRetriever.GetSMAPIUpdateVersion());
}
catch
catch (Exception ex)
{
this.Monitor.Log($"Exception{ex}");
this.NotifySMAPI(null);
}

Expand Down
10 changes: 10 additions & 0 deletions UnofficialModUpdateMenu/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Unofficial Mod Update Menu, now updated for 1.6!

How to use:
Install Smapi:
Copy this file into your 'Mods' folder: [ModUpdateMenu.zip](https://github.com/Dphill10827/StardewMods/files/14670049/ModUpdateMenu.zip)


## How it works

Adds a menu to the title screen accessible by a new button which displays info about mod status. Mod updates are taken from the update checks SMAPI does. This is an updated version for Stardew 1.6 that allows users to click links again.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.4.1</Version>
<TargetFramework>net452</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<Version>1.0.0</Version>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="3.3.0" />
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.0.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"Name": "Mod Update Menu",
"Name": "Unofficial Mod Update Menu",
"Author": "Cat",
"Version": "1.6.0",
"Version": "2.6.0-unofficial-1",
"Description": "Shows an in game menu on the title screen about mods that need updates.",
"UniqueID": "cat.modupdatemenu",
"EntryDll": "ModUpdateMenu.dll",
"MinimumApiVersion": "3.6.0",
"UpdateKeys": [ "Nexus:2536" ]
"MinimumApiVersion": "4.0.0",
"UpdateKeys": [ "GitHub:Dphill10827/UnofficialModUpdateMenu" ]
}