saltyhotdog / BattletechIssueTracker

Public issue tracker to communicate with modders and HBS.
MIT License
6 stars 0 forks source link

Document Modding on MacOS #2

Closed janxious closed 6 years ago

janxious commented 6 years ago

Why do you need help?

All the tutorials on using mods in Battletech are written from the perspective of being in Windows. So we end up with tool recommendations that don't work. Directory structure of Mac application bundle is similar but different enough to need separate documentation. While most people probably are using Windows, it does have a Mac port and making the process of installing mods on Mac will allow for more people to play and extend the game.

What do you need help with?

I can write down how to get things going with BTML and how to get a basic dev env working, but more work could be done finding out •if• the edges are as sharp as I think they are. Specifically getting BTML injector to work is currently a programming task inside VS. There's also exploration that could be done making dnSpy working under wine. Things that don't work (ilspy) should be documented.

What should the helper do to help you

Review the premises I've presented and see if your knowledge of mono/dotnet/etc. can make the process better and easier for new people.

What is your ideal outcome of receiving this help

We end up with a step-by-step guide to getting at least developers able to develop mods on MacOS.

Leave any additional comments here

dnSpy sounds really nice.

janxious commented 6 years ago

Here's my outline so far


Modding on a Mac

Document:

janxious commented 6 years ago

Modding on a Mac

  1. Install git and setup for github [1] [2] This will allow you to download source code of various mods and will be helpful if you want to create your own mods.
  2. Download Visual Studio Community [1] This will be required to get BTML to work.
  3. Download the latest release of BattleTechModLoader. [1] You want the one that is BTML-vX.X.X
  4. Unzip that file and copy the 0Harmony.dll and BattleTechModLoader.dll files to your BTech Managed folder. This is where things become different from windows. The folder is going to be located at: /Users/<yourusername>/Library/Application Support/Steam/steamapps/common/BATTLETECH/BattleTech.app/Contents/Resources/Data/Managed/ You can quickly get to folders in Finder by hitting command+shift+g. I suggest pinning the Resources folder in Finder, because we'll be in there a lot looking at logs and replacing DLLs and various other things. Pinning can be done by dragging the folder into your favorites list in Finder.
    screen shot 2018-05-25 at 12 27 09 pm
  5. Clone the BTML project into a local directory on your computer. I opened Iterm (terminal.app works too). I keep projects in ~/projects, so for me that looked like:
    > cd projects
    > git clone git@github.com:Mpstark/BattleTechModLoader.git
  6. Now open Visual Studio and then open the .sln file in your new directory (~/projects/BattleTechModLoader/BattleTechModLoader.sln).
  7. The thing we need to compile is the Injector project. If you try to build it, you will get an error about an invalid language version. We need to target a lower language version. Right click on BattleTechModLoaderInjector and under the "Build" settings, change the C# language version to 7.1.
    screen shot 2018-05-25 at 1 39 06 pm You'll need to follow the same steps for the "BattleTechModLoader" project.
  8. Now we need to update some assembly references. We want to target the ones in the local Managedfolder. We will match all the references we see in the project with those so everything will compile
    screen shot 2018-05-25 at 2 05 38 pm
    screen shot 2018-05-25 at 2 05 46 pm
    screen shot 2018-05-25 at 2 06 27 pm
  9. Now Build All Projects (command+b). If you see errors (not warnings), something in the previous steps has gone wrong.
    screen shot 2018-05-25 at 3 14 19 pm
  10. In the BattleTechModLoaderInjector project, open the options dialog once again and go to the Run -> Configuration -> Default tab. In the "Run in Directory" setting, set it to your Managed folder.
    screen shot 2018-05-25 at 3 16 26 pm
  11. Now we do the last step to have BTML enabled for our BTech game. Choose Release from the Active Configuration dropdown (or Project menu), and then hit the run button.
    screen shot 2018-05-25 at 3 17 58 pm
    screen shot 2018-05-25 at 3 18 10 pm
  12. Tada! Okay, almost done.
  13. Remember /Users/<yourusername>/Library/Application Support/Steam/steamapps/common/BATTLETECH/BattleTech.app/Contents/Resources/? We need to make a Mods folder inside that.
    screen shot 2018-05-25 at 3 22 20 pm
  14. To test that we did everything correctly, I recommend the very simplest mod. Grab the Version mod DLL. [1] Put it into your new Mods folder, and then launch the game. When you start the game and get past the intro movie, in the bottom left of your screen you should see a version number and " w/ BTML". If you do that means BTML is enabled, working, and you are ready to use or make mods to your heart's content.

Additional Notes

ffaristocrat commented 6 years ago

You don't need to recompile for OSX - it runs just fine with mono. The main issue is that the System.Core.dll for BattleTech is an older .NET release that ends up conflicting with the loader. If you take it out of the way, the injector works.

Here are the steps to get it working. I've tested it with the current release of BattleTech on OSX (1.0.4-280D) and the current release of BTML (0.2.1).

  1. Install homebrew if you don't have it already
  2. Copy the injector & the DLLs to BattleTech.app/Contents/Resources/Data/Managed
  3. Open up Terminal
  4. brew install mono
  5. cd "Library/Application Support/Steam/SteamApps/common/BATTLETECH/BattleTech.app/Contents/Resources/Data/Managed"
  6. mv System.Core.dll System.Core.dll.temp
  7. mono BattleTechModLoaderInjector.exe
  8. mv System.Core.dll.temp System.Core.dll
  9. cd ../..
  10. mkdir Mods

Then put ModTek and anything else you're using for modding there.

App bundles are pain to navigate to so I highly suggest making the Contents folder a favorite so you can just jump to it.

ffaristocrat commented 6 years ago

This is probably simple enough that a bash script could just be provided.

janxious commented 6 years ago

I tried everything there except this step mv System.Core.dll System.Core.dll.temp, so that may be the critical piece.

janxious commented 6 years ago

Debug can be enabled by this, theoretically:

: defaults write ~/Library/Preferences/unity.Harebrained\ Schemes.BattleTech.plist last_debug_state 1

Then other steps work from https://www.reddit.com/r/BattleTechMods/comments/8ep5gb/did_anyone_manage_to_enable_debug_mode/

janxious commented 6 years ago

I consider this documented enough for my purposes. There are several writeups on reddit and other places for this, so closing, since this was largely a TODO for me originally anyway.