Skip to content

Conversation

to-fuu
Copy link

@to-fuu to-fuu commented Mar 6, 2025

Adds support for Macs builds and UnleahsedRecomp

Can be built from code using the following command

dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:UseAppHost=true -property:Configuration=Release -p:PublishSingleFile=true

image

image

TODO:

  • Fix the app's icon
  • Add support for other games
  • Add build commands to github workflows

@IsaacMarovitz
Copy link

This PR contains many unrelated changes to formatting as well as a version bump that are wholly out of scope. Additionally this conflicts with my PR #20. Changes regarding Unleashed Recompiled should not be merged before the official release. Things are not set in stone and stuff like the name of the bundle may be subject to change still, which would break functionality here.

@phamtheman69
Copy link

jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha ~ % cd /Users/jaydenpham/Downloads/HedgeModManager/Source/HedgeModManager.UI
jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha HedgeModManager.UI % dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:UseAppHost=true -property:Configuration=Release -p:PublishSingleFile=true
HedgeModManager.UI failed with 1 error(s) (0.0s)
/Users/jaydenpham/Downloads/HedgeModManager/Source/HedgeModManager.UI/HedgeModManager.UI.csproj : error MSB4057: The target "BundleApp" does not exist in the project.

Build failed with 1 error(s) in 0.5s
jaydenpham@Skibidi-toilet-ohio-gyatt-rizz-sigma-alpha HedgeModManager.UI %

do you know a fix? since you've already successfully built it do you think you could just drop the .app file?

@phamtheman69
Copy link

nevermind, I fixed it by using the command cd to go to the folder hedgemodmanager.ui, and then changing the terminal command to "dotnet publish -r osx-arm64 -c Release --self-contained true", which didn't create a .app file but it did give me what i needed to start the app with " ./HedgeModManager.UI".

@to-fuu
Copy link
Author

to-fuu commented Mar 7, 2025

This PR contains many unrelated changes to formatting as well as a version bump that are wholly out of scope. Additionally this conflicts with my PR #20. Changes regarding Unleashed Recompiled should not be merged before the official release. Things are not set in stone and stuff like the name of the bundle may be subject to change still, which would break functionality here.

  1. There isn't a version bump. Not sure why it looks that way but the version is the same as what's in the main branch now.
  2. Some formatting changes ,ade by Rider did get through. Can be fixed.
  3. I can't see how this would conflict with your PR, considering the only pieces of code you made are in 3 files that were not touched in this PR. Other than maybe the fact I'm using a different build method
  4. The PR itself does not have to be merged now. Yes the mac port of unleashed is not finalized, but the changes I made to mod loading and the run command have nothing to do with Unleahsed itself. Those are changes that have to made regardless of what the bundle will be named in the future. Commenting out the following line in ModdableGameLocator.cs will make Unleashed undetectable.
 { "Macos", new("UnleashedRecomp", "UnleashedRecomp") },

@to-fuu
Copy link
Author

to-fuu commented Mar 7, 2025

Status:

  • Removed dependency on Dotnet.Bundle for builds
  • Disabled detecting UnleashedRecom (line can be uncommented to re-enable)

@fred64k
Copy link

fred64k commented Mar 7, 2025

image

I got the mod manager to build, but it's saying it can't find games. Do I have to point to it in a config file or something?

@to-fuu
Copy link
Author

to-fuu commented Mar 7, 2025

image

I got the mod manager to build, but it's saying it can't find games. Do I have to point to it in a config file or something?

Keep in mind this only works with unleashed as of now

If you pulled the latest changes, you will find under HedgeModManager/ModdableGameLocator that line 136 is commented. You need to uncomment it before building.
Also make sure you have moved the game itself to the Application folder.

@IsaacMarovitz
Copy link

IsaacMarovitz commented Mar 7, 2025

There isn't a version bump. Not sure why it looks that way but the version is the same as what's in the main branch now.

Odd, I think your branch needs a rebase

Some formatting changes ,ade by Rider did get through. Can be fixed.

FYI, I am pro a consistent formatting style but later using dotnet format, but just to keep this changeset properly scoped it shouldn't be included here.

I can't see how this would conflict with your PR, considering the only pieces of code you made are in 3 files that were not touched in this PR. Other than maybe the fact I'm using a different build method

I was mainly referring to the build method. I spoke to SuperSonic16 and afaik she would prefer if it was all contained within one PR. I'm happy to PR to your branch or vice versa.

The PR itself does not have to be merged now. Yes the mac port of unleashed is not finalized, but the changes I made to mod loading and the run command have nothing to do with Unleahsed itself. Those are changes that have to made regardless of what the bundle will be named in the future. Commenting out the following line in ModdableGameLocator.cs will make Unleashed undetectable.

I will need to review these changes closely; Unleashed Recomp is an outlier; all other Sonic games on macOS will need to be launched through Wine.

@IsaacMarovitz
Copy link

I've rebased my changes on main

if (SelectedGame.Game.ModLoaderConfiguration is ModLoaderConfiguration config)
await config.Save(Path.Combine(SelectedGame.Game.Root, "cpkredir.ini"));
{
// For macos, save under the user's Application Support directory.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*macOS

if (OperatingSystem.IsMacOS())
{
var appSupportDir = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
await config.Save(Path.Combine( appSupportDir,SelectedGame.Game.Executable, "cpkredir.ini"));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await config.Save(Path.Combine(appSupportDir, SelectedGame.Game.Executable, "cpkredir.ini"));

WorkingDirectory = Root,
UseShellExecute = true
});
// The command to launch macos apps is

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*macOS

});
// The command to launch macos apps is
// open -a path/to/my/app/appname
// When the app is inside the Application folder only the app's name is needed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, I think it would be better to opt for the full file path for specificity.

games.Add(game);
}
}
if (OperatingSystem.IsMacOS() && gameInfo.PlatformInfos.TryGetValue("Macos", out var macosDesktopInfo))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct Macos -> macOS


var gameSimple = new GameSimple(
"Macos", macosDesktopInfo.ID, gameInfo.ID,
"/Applications", macosDesktopInfo.Executable, "Macos", ""

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to be careful assuming /Applications. Things can also be installed to ~/Applications

mkdir "$APP_NAME/Contents/Resources"

# Create Info.plist inside the bundle
cat > "$APP_NAME/Contents/Info.plist" << EOF

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would prefer if this was actually a file in the repo instead of being cat'd out

Copy link
Author

@to-fuu to-fuu Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was so in github workflows, the version and bundle name can be passed as arguments. Though I don't disagree

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like this to be in its own file if it can be easily done. Maybe you could look into string substitution, I think some people had used the sed command.

docs/BUILDING.md Outdated
```
```bash
cd macos
/bin/bash macos/generate-bundle.bash com.hedge_dev.hedgemodmanager 8.0.3

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of macOS Catalina, zsh is the default shell on Mac

docs/BUILDING.md Outdated

## 2. Build the project

### Macos

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macos -> macOS

}
if (OperatingSystem.IsMacOS() && gameInfo.PlatformInfos.TryGetValue("Macos", out var macosDesktopInfo))
{
// The root is actually not necessary on macos

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel like there should still be a root here as by default the data for unleashed is held in "~/Library/Application Support/UnleashedRecomp", and having the mod folder there makes it more similar to other platforms. maybe try something like this

Suggested change
// The root is actually not necessary on macos
string root = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Library", "Application Support", "UnleashedRecomp");
if (Directory.Exists(root))
{
var gameSimple = new GameSimple(
"Macos", macosDesktopInfo.ID, gameInfo.ID,
root, macosDesktopInfo.Executable,
"Macos", "", ""
);
var game = new ModdableGameGeneric(gameSimple)
{
SupportsDirectLaunch = true,
SupportsLauncher = false,
Is64Bit = gameInfo.Is64Bit
};
game.ModDatabase.SupportsCodeCompilation = gameInfo.SupportsCodes;
games.Add(game);
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense.
Will try the changes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that Application Support should be accessed using Environment.SpecialFolder.ApplicationData

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I tried to pull and build the project, it didn't work right. It wouldn't save config files or be able to boot the game. I tried fixing the code myself, but it still had trouble detecting mods and saving.

The suggested fixes above worked, and HMM runs great for me.

Copy link
Member

@thesupersonic16 thesupersonic16 Mar 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made changes to GameSimple, though it should be simple to work around for macOS. What I changed is making it work a bit more like running a command instead of executable and arguments.

Also please change all the Macos to macOS or MacOS, I think using the proper capitalisation would be good here.

@adoobly
Copy link

adoobly commented Mar 7, 2025

my terminal says command not found dotnet what do i do

@to-fuu
Copy link
Author

to-fuu commented Mar 7, 2025

As of the latest commit, uri schemes are now supported on macos

image

@adoobly
Copy link

adoobly commented Mar 7, 2025

is there a .app download?

@FlipTheFox
Copy link

@adoobly you need to install dotnet and then run ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/ in a new terminal window

@to-fuu
Copy link
Author

to-fuu commented Mar 20, 2025

@thesupersonic16
For now changed the code to work with the new changes made to GameSimple. Move the .icns file and created an info.plist under /macos and used sed to update the version.
I will look at combining arm64 and x86 builds into one bundle.

Copy link
Member

@thesupersonic16 thesupersonic16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have made some comments and some change requests. Please reply to the comments.

Also make sure to update build-project.yml aswell.

@to-fuu
Copy link
Author

to-fuu commented Mar 20, 2025

I have made some comments and some change requests. Please reply to the comments.

Also make sure to update build-project.yml aswell.

I'll go through the change requests.
Will update the build file once I figure out how to bundle the builds for both architectures together (Still haven't had time to look at it)

@to-fuu
Copy link
Author

to-fuu commented Mar 23, 2025

@thesupersonic16 Reverted the change to saving cpkredir.ini as the root path now points to the application support dir.
For now I guess we can wait for the mac port to be released, update the bundle name and test again

@IsaacMarovitz
Copy link

@thesupersonic16 Reverted the change to saving cpkredir.ini as the root path now points to the application support dir.

For now I guess we can wait for the mac port to be released, update the bundle name and test again

Check your PRs on your fork

@phamtheman69
Copy link

Adds support for Macs builds and UnleahsedRecomp

Can be built from code using the following command

dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -p:UseAppHost=true -property:Configuration=Release -p:PublishSingleFile=true

image

image TODO:
  • Fix the app's icon
  • Add support for other games
  • Add build commands to github workflows

When do you think support for other games will be added? Hedgemodmanager 7/8 beta don't work through crossover

@thesupersonic16
Copy link
Member

I believe it's the mod loaders that don't work with crossover. There is an issue on the HMM 7 repo about that. Ideally a standard needs to be made for this as I never heard macOS having a Steam client that runs the games. After that is worked out, code could be added to setup whatever is needed get the games running with the mod loaders.

I really do not want HMM 8 to have code designed just to run under wine/crossover.

@MarioMastr
Copy link

macOS support has been merged into the main repo of UnleashedRecomp, I hope to see this PR cleaned up and merged soon to accompany that

@thesupersonic16
Copy link
Member

I cannot work on macOS support without having a machine that runs it. I am currently waiting for when this PR is ready for another review.

@to-fuu
Copy link
Author

to-fuu commented Aug 12, 2025

I will try to pick up where I left this weekend

@thesupersonic16
Copy link
Member

You also have a PR on your repo, so you may want to look into that aswell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants