Pathoschild / SMAPI

The modding API for Stardew Valley.
https://smapi.io/
GNU Lesser General Public License v3.0
1.72k stars 259 forks source link

Mac/Linux support? #126

Closed LuciousLisa closed 7 years ago

LuciousLisa commented 7 years ago

Now that the game has become available to us non-Windows users, it would be appreciated a lot if SMAPI also offers support for these operating systems. Pretty please? :)

Covirt commented 7 years ago

I do agree. It seems to only work with Microsoft .NET Framework 4.6.1. I guess we just have to wait.

kozie commented 7 years ago

+1 here 👍

Katorone commented 7 years ago

+1 please.

MacLeek commented 7 years ago

Guys,I've managed to make it work on Mac.
Here's my fork
https://github.com/MacLeek/SMAPI
And instructions here https://www.reddit.com/r/StardewValley/comments/4ypp1a/so_this_is_the_smapi_for_mac/

kozie commented 7 years ago

I got an error tho, saying system.windows.forms could not be found when trying to run the StardewModdingAPI.bin.osx from terminal.

I checked out the original SMAPI, removed the xna refs and added the ones according to your instructions. Also removed the ref to system.windows.forms, altered to code according to your fork and built it. It seems to load up now but it's still throwing errors at me in terminal about system.* stuff.

It also seems that you added a project (stardew_mac) to your solution which is on your desktop. Is this something that can be removed or is it needed?

update

So i just checked out your fork, removed the system.windows.forms ref and fixed the refs from your instructions. Built with 'Release' and it seems to work now. Tho it still gives me errors when it's trying to load the mods.

02:54:13.721 PM] Invalid JSON (Manifest): /Users/koos/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/DailyQuest Anywhere/manifest.json 
System.TypeInitializationException: The type initializer for 'Newtonsoft.Json.Utilities.ConvertUtils' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly or one of its dependencies.
File name: 'System.Numerics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
  --- End of inner exception stack trace ---
  at Newtonsoft.Json.Serialization.DefaultContractResolver.IsJsonPrimitiveType (System.Type t) <0x10b099070 + 0x00017> in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.CreateContract (System.Type objectType) <0x10b098d20 + 0x00036> in <filename unknown>:0 
  at StardewModdingAPI.JsonResolver.CreateContract (System.Type objectType) <0x10b0a2180 + 0x001b4> in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.DefaultContractResolver.ResolveContract (System.Type type) <0x10b098910 + 0x0014d> in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.GetContractSafe (System.Type type) <0x10b0988b0 + 0x00048> in <filename unknown>:0 
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType, Boolean checkAdditionalContent) <0x10b0982c0 + 0x00076> in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.DeserializeInternal (Newtonsoft.Json.JsonReader reader, System.Type objectType) <0x10b097650 + 0x001a4> in <filename unknown>:0 
  at Newtonsoft.Json.JsonSerializer.Deserialize (Newtonsoft.Json.JsonReader reader, System.Type objectType) <0x10b097620 + 0x0001b> in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject (System.String value, System.Type type, Newtonsoft.Json.JsonSerializerSettings settings) <0x1056bda40 + 0x00106> in <filename unknown>:0 
  at Newtonsoft.Json.JsonConvert.DeserializeObject[T] (System.String value, Newtonsoft.Json.JsonSerializerSettings settings) <0x1056bd9c0 + 0x0003c> in <filename unknown>:0 
  at StardewModdingAPI.Config.LoadConfig[T] () <0x10b0a12e0 + 0x0023c> in <filename unknown>:0 
[02:54:13.747 PM] Failed to read mod manifest '/Users/koos/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS/Mods/DailyQuest Anywhere/manifest.json'. EntryDll is empty!

update 2

It seemed you also need to copy over System.Numerics.dll too for Newtonsoft.Json to be able to read the manifest files. I'm still playing around tho.

Could you clarify why you removed some code, like the threading code to start SDV, instead of fixing it? I mean, the SDV modding API seems to work with your code but the code removed was there for a purpose, right? ^_^

MacLeek commented 7 years ago

@kozie The stardew_mac is the project which I decompiled from stardewvalley.exe for easier debugging,I just forgot to remove it and also system.windows.forms.
I mainly removed the code which was not used in current version like forms and other variables.
For the threading part,I found with the original code the game window is not active and I can not move my mouse and click a button although the game is actually running.After several attempts, when I made the game running in the main thread and also start the console thread, I found it worked.
Actually I'm really new to c# programming,just started a week a ago and only know some basic grammer:stuck_out_tongue: So if I ever misunderstood something,please point it out.

kozie commented 7 years ago

Sounds quite logical ^_^

I hope that the maintainers of the project are seeing this and will take actions.

also, how did you manage to decompile the exe?

xubiod commented 7 years ago

can linux support be made please? my only computer that can run the game has ubuntu. +10 to whoever makes a linux port of this

kozie commented 7 years ago

I got an Ubuntu 14.04 box running with Vagrant. It seems to work quite nice so i might try using that if no one else will do :)

I'm a bit dissapointed tho that no word has come from the official maintainers yet. @ClxS ?

ClxS commented 7 years ago

I don't really have enough time to add official OSX/Linux support at the moment, especially since I have very little experience with either. I'd recommend checking out the forks from people who've added the support themselves, like MacLeek's. I haven't heard of any natively compatible version that works without WINE though - I imagine it'll be quite a lot of work to make that possible.

kozie commented 7 years ago

I have a linux version which seems to work :) (@xubiod @ClxS @MacLeek)

It can be downloaded from my dropbox (https://dl.dropboxusercontent.com/u/3946199/sdv/StardewModdingAPI_linux_x86_64.zip).

To run it from steam i guess you have to edit the file StardewValley and change the last few lines from StardewValley.bin.x86_64 to StardewModdingAPI.bin.x86_64.

x3ro commented 7 years ago

Hi @kozie, do you mind sharing how you managed to build it? Can you share instructions and, if necessary, the source changes?

kozie commented 7 years ago

Hi @x3ro, i did not do much extra using @MacLeek's instructions and repo.

I just opened his solution in monodev, removed the windows.system.form stuff, added the correct references for SDV and MonoGame framework and built using 'Release'. Copied over the necessary files over to the SDV folder and it worked ^_^

Covirt commented 7 years ago

I have been trying to install CJB Cheat Menu (don't judge me :) but I keep getting :

image

kozie commented 7 years ago

You might want to try to recompile the plugin if the source is available tho. Could be that alternate packages are needed for the "missing classes".

I tried a quick search but couldn't find any signs of source links. You might want to consider reaching out to the dev (http://community.playstarbound.com/threads/smapi-0-40-0-in-game-cheat-menu-v1-12-09-apr-2016.108004/).

Cheers

pietrondo commented 7 years ago

+1 linux.. . I have tried with wine but problem because I use linux native client.

pietrondo commented 7 years ago

@kozie the file in your dropbox folder are exe..

kozie commented 7 years ago

Yep, that's right. As are the official SDV binary files for Linux and MacOs themselves.

On Tue, Sep 20, 2016, 4:41 PM Pietro notifications@github.com wrote:

@kozie https://github.com/kozie the file in your dropbox folder are exe..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cjsu/SMAPI/issues/126#issuecomment-248322019, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHQDvadsMosqtpp3EUb_6MTT2_H7VQ5ks5qr_CngaJpZM4JeO_h .

pietrondo commented 7 years ago

@kozie ok. work (sorry) but I need to recompile every mod? I have tried to download a mod but it can't work!

kozie commented 7 years ago

I haven't tried much but some seem to work out of the box and some won't.

Out of experience, I think that most mods need to be recompiled.

It would be much better if SMAPI would've had something like LUA so only SMAPI would've been made crossplatform and all mods would be the same :)

On Tue, Sep 20, 2016, 5:43 PM Pietro notifications@github.com wrote:

@kozie https://github.com/kozie ok. work (sorry) but I need to recompile every mod? I have tried to download a mod but it can't work!

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cjsu/SMAPI/issues/126#issuecomment-248341696, or mute the thread https://github.com/notifications/unsubscribe-auth/AAHQDgJHE820sSjypd76iQ2LoIyOZzaJks5qr_8hgaJpZM4JeO_h .

pietrondo commented 7 years ago

okk.. how can I compile them.. I have tried with LookupAnything but it give me errors like: Framework/Targets/GenericTarget.cs(99,100): error CS0246: The type or namespace nameTexture2D' could not be found. Are you missing an assembly reference? `

Pathoschild commented 7 years ago

Hi @pietrondo. I'm the developer of Lookup Anything; I stumbled across this thread looking into Linux support. :)

Before compiling the mod, you need to update the path to the game directory. The README in the latest release has a section about compiling the mod which may help. I don't have Linux myself, but I'd be happy to upload a Linux build to Nexus Mods if you can compile it. If there are code changes required, feel free to submit a pull request.

pietrondo commented 7 years ago

@Pathoschild thx But I don't find in the LookupAnything.csproj

pietrondo commented 7 years ago

@Pathoschild found it.. (i have updated my github version of the mod)

euan-reid commented 7 years ago

I guess with 1.1 this is going to be more than a little bit different, and hopefully easier to implement?

vizv commented 7 years ago

Here is my fork trying to change minimum amount of code to make it works for Linux. I don't own a Mac, so sorry :P

https://github.com/vizv/SMAPI/releases

vizv commented 7 years ago

@Pathoschild Also your LookupAnything, a really awesome mod!

https://github.com/vizv/LookupAnything/releases

euan-reid commented 7 years ago

@vizv While you're on a roll, odds of tackling Timespeed or an equivalent? ;)

Pathoschild commented 7 years ago

@vizv: that's awesome, especially open-sourcing your Linux/Mac version of SMAPI. Thanks!

I'm working on an open-source guide to modding; I'll get some Linux/Mac players to beta-test Lookup Anything for a while, and if everything checks out I'll link your download as the main SMAPI for Linux/Mac. I think we can get the ball rolling on Linux/Mac mods. :)

vizv commented 7 years ago

Just port another mod I use: NPC Map Locations.

https://github.com/vizv/StardewValleyMods

@ReidE96 I'd try that. @Pathoschild If I can borrow a Mac tomorrow I'll try to compile it in OS X. I have test it around with these two mods and I do experience lagging sometimes, but it's playable.

euan-reid commented 7 years ago

@vizv Shiny! Happy to help with compiling things on Mac if there's a quick buildenv setup guide I can grab ahold of, though I'm not going to have a lot of time to test stability during play just now.

vizv commented 7 years ago

@ReidE96 tomkrizan already got a working release here, I just tested it:

https://github.com/tomkrizan/TimeSpeed/releases

euan-reid commented 7 years ago

Oh, awesome! Guess the next task then is to get things merged into mainline with some platform-detecting conditionals so it's not per-OS installs :D

euan-reid commented 7 years ago

@vizv Alrighty, just tried running on Mac, crashes out immediately over System.Windows.Forms - not sure if there's a rogue check, or Monogame doesn't want to play as nicely on Mac. Gonna go grepping and see what I find.

euan-reid commented 7 years ago

@vizv Looks like it's pathing on the tweaked SMAPI. Mac is ~\Library\Application Support\Steam\SteamApps\common\Stardew Valley\Contents\MacOS\ for the game folder, rather than ~.local\share\Steam[etc]

vizv commented 7 years ago

@ReidE96 I'm new for C# and monodevelop (just installed it for two days and have no C# development experience), not sure how to fix it in OS X. But if you got monodevelop for OS X, go to reference and fix the broken references by selecting dll/exe assemblies, it might fix the compiling issue.

euan-reid commented 7 years ago

@vizv 'Fraid I don't have it installed, but if I can find time tomorrow I'll do so. Should hopefully be an easy fix!

pietrondo commented 7 years ago

thx.. but for example: how Can I add this mod http://www.nexusmods.com/stardewvalley/mods/541/ ? thx

Pietro Capriata

http://www.pietrocapriata.me

CONFIDENTIALITY DISCLAIMER Le informazioni contenute in questo messaggio di posta elettronica e negli allegati sono riservate e confidenziali e ne sono vietate la lettura, l'uso, la copia, la comunicazione e la diffusione in qualunque modo eseguite. Qualora lei non fosse la persona destinataria del messaggio, la invitiamo ad eliminarlo, dando gentilmente comunicazione al mittente tramite e-mail di ritorno.

The information contained in this email message and any files transmitted with it are confidential and privileged and any reading, processing, distribution or copy of this material is strictly prohibited, in any form. If you are not the intended recipient of this message, please immediately delete it, giving the relevant communication to the sender by reply e-mail.

On Sun, Oct 16, 2016 at 12:23 PM, rumangerst notifications@github.com wrote:

@vizv https://github.com/vizv Thank you for making this port! Seems to work (at least it starts). Although for me the game refuses to exit (must kill it).

I updated the SMAPI example https://github.com/rumangerst/SilVerPLuM/tree/master/examples with your linux release. Compiles and works for me.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/cjsu/SMAPI/issues/126#issuecomment-254038802, or mute the thread https://github.com/notifications/unsubscribe-auth/AFzIljnfEKsdo6wZNv3D4eDewKADiXlYks5q0fstgaJpZM4JeO_h .

euan-reid commented 7 years ago

@pietrondo You have to compile it for mono instead of .net - vizv posted a link above to a version working with this version of SMAPI (https://github.com/tomkrizan/TimeSpeed/releases)

euan-reid commented 7 years ago

@pietrondo Sorry, copied the wrong link, https://github.com/vizv/LookupAnything/releases was the one I meant

vizv commented 7 years ago

@pietrondo I have already release the Linux version, https://github.com/vizv/LookupAnything/releases, just drop to your Mods directory.

pietrondo commented 7 years ago

thx!

vizv commented 7 years ago

@ReidE96 I borrowed a Mac last night, but unfortunately it compiles but not work correctly. One of the problem is System.Windows.Forms not working correctly in OS X, which I have masked them in the code. Then it compiles and run, I can see the graphics and game screen but I can't click anything. Commands in console works but cursor always busy when pointing to the game screen. There a one error message on the console says something about late swap not supported.

Guess OS X needs a little more tweaks, I gave up. Maybe refer to MacLeek's fork see how to get everything working.

Pathoschild commented 7 years ago

I spent a few days working on this, and here's my progress so far.

This is still experimental; let me know if you have any problems following the guides.

The next versions of Chests Anywhere and Lookup Anything will be officially released on all platforms, and I'll be working with mod authors to transition them to crossplatform mods.

x3ro commented 7 years ago

@ClxS: I don't really have enough time to add official OSX/Linux support at the moment, especially since I have very little experience with either.

Would you be open to having contributors supply PRs for the necessary changes? I think that it'd be hugely beneficial to the modding community if there weren't different SMAPI versions/releases for different platforms, as that would make it even harder to write mods for all platforms.

alexb5dh commented 7 years ago

@Pathoschild, thanks for the package. It greatly simplifies cross-platform building.

Does copying game binaries to ouput directory is necessary? Adding <Private>false</Private> to each <Reference> should prevent this. You can then zip mod from output as build step with the help of MSBuild Extension Pack.

Pathoschild commented 7 years ago

@alexb5dh Thanks for the suggestion! The latest 1.2 release marks the imported dependencies private.

I'll hold off on zipping the mod automatically for now. The MSBuild Extension Pack uses a compiled DLL and they make no mention of crossplatform compatibility, so it's likely Windows-only. It's also a large project, so I wouldn't want to require it just for one thing. (The mod developer is free to add their own task to do it, of course.)

Pathoschild commented 7 years ago

@vizv your SMAPI for Linux release has a different internal version (0.40.0 1.1) than the official build (0.40.0 1.1-3), which complicates version checks in mods. Could you upload a new build that matches the official version?

vizv commented 7 years ago

@Pathoschild I'll look into that.

Pathoschild commented 7 years ago

Chests Anywhere and Lookup Anything are now officially supported on Linux, Mac, and Windows!

Next is SMAPI itself.