AGS engine Mac OS X port

Started by JanetC, Mon 10/12/2012 19:12:16

Previous topic - Next topic

Manu

Quote from: Potajito on Wed 26/05/2021 14:55:27
As a side note, if you use itch.io's butler (the command line software to push builds), you can add the flag --fix-permissions (both for max and linux) so you don't have to do that manually.

I didn't know about the butler. I'm definitely going to use itl! Thank you!

Laura Hunt

#201
I just tried TheVolumeRemote's wrapper and it works beautifully, with one caveat: if I run the game fullscreen in my external monitor, which has a ratio of 16:9, the image gets stretched to fill the screen even though I've set screen_def to "scaling" in the cfg file. I wonder if there's another copy of the cfg file that gets created somewhere else, same as in Linux, or are multiple monitors a known issue with this port?


Quotewindowed=0
screen_def=scaling
game_scale_fs=max_round
game_scale_win=max_round

Crimson Wizard

#202
LauraHunt, ags currently does not detect multiple monitors correctly, maybe that's the part of the problem. Also, I would not use "scaling" in fullscreen, maybe it's best to use "max" to make it keep at current desktop resolution, and "proportional" for "game_scale_fs".

Laura Hunt

#203
Quote from: Crimson Wizard on Wed 26/05/2021 16:58:57
LauraHunt, ags currently does not detect multiple monitors correctly, maybe that's the part of the problem. Also, I would not use "scaling" in fullscreen, maybe it's best to use "max" to make it keep at current desktop resolution, and "proportional" for "game_scale_fs".

Hey CW, thanks, setting it to "proportional" seems to have fixed it. However, this mode is not listed here, which is what I was using for reference: https://github.com/adventuregamestudio/ags/blob/master/OPTIONS.md

Quotescreen_def = [string] - determines how display mode is deduced:

  • explicit - use screen_width and screen_height parameters;
  • scaling - sets equal to scaled game size;
  • max - sets equal to device/desktop size.

Maybe it would be useful to add it?

Edit: to clarify, what I did was leave game_scale_fs as "max_round", and set screen_def to "proportional", even though it's not listed as one of the possible parameters. Somehow seems to have worked.

Edit 2: Actually no, it didn't work. What DOES seem to work is to start the game in windowed mode and, once it's running, pressing Alt+Enter to go into fullscreen mode; then the game scales correctly. But running the game directly in fullscreen stretches the image to fill the screen instead.

Crimson Wizard

#204
screen_def cannot be "proportional", I was referring to game_scale_fs option. "screen_def" could be set to "max" that would use current desktop resolution.

The thing is that "screen_def = scaling" will try to set new display resolution to the integer scale of a game's size. Changing resolution itself may be problematic on some systems, but if proper resolution is not supported it will try to find nearest one which may be not what you want.

Laura Hunt

Quote from: Crimson Wizard on Wed 26/05/2021 17:47:00
screen_def cannot be "proportional", I was referring to game_scale_fs option. "screen_def" could be set to "max" that would use current desktop resolution.

Yeah sorry for the confusion, I realized that afterwards. Hope my second edit clarifies things, but to conclude: if you start the game in windowed mode with the "normal" parameters (screen_def=max, and max_round for both fs and windowed) and press alt+enter once the game is running, then it scales correctly on the second monitor. It's a workaround, at least.

eri0o

people,

I started to try to update the AGS Xcode project for MacOS and discovered that Xcode is super alien for me (I normally do MacOS through CLion using CMake). If some of the MacOS devs that occasionally appear here see this message, I made some initial work to get at least the libraries in a newer version and in a state they build and install, but I am stuck trying to understand how to add files in Xcode in a way the headers actually work. In case some Xcode expert wants to join and upgrade the projects, here is the initial work: https://github.com/ericoporto/ags/tree/macos-xcode-sdl2

Crimson Wizard

@LauraHunt, I just noticed that the MacOSX port does not create window sized like the Windows or Linux ports do, it has some different logic to this and likely not even using mode size from the config.

You mentioned that the problem occurs on the "external monitor", does it also happen on the main monitor (I'm not sure what your setup is).


Laura Hunt

#208
Quote from: Crimson Wizard on Mon 31/05/2021 18:44:51
@LauraHunt, I just noticed that the MacOSX port does not create window sized like the Windows or Linux ports do, it has some different logic to this and likely not even using mode size from the config.

You mentioned that the problem occurs on the "external monitor", does it also happen on the main monitor (I'm not sure what your setup is).

I'm using a 15-inch MacBook Pro (2880x1800) and an external 24-inch Dell (1920x1080). The issue does not happen on the laptop display, but it might be because both the game (320x200) and the display have a ratio of 16:10.

Still, the behaviour is always the same: if I start the game in windowed mode and then switch to fullscreen, the image scales correctly on the external display without any stretching (but if I quit while in fullscreen mode and then start the game again at some other time, it will once more stretch to fill the screen, so the best thing to do is switch to windowed mode before quitting).

Interestingly, if I run the game in windowed mode, the cfg file that's located in the user's Saved Games profile folder sets itself to "scaling". If I run the game in fullscreen mode, the cfg sets itself to "max".


Crimson Wizard

#209
Quote from: Laura Hunt on Mon 31/05/2021 19:30:33
Still, the behaviour is always the same: if I start the game in windowed mode and then switch to fullscreen, the image scales correctly on the external display without any stretching (but if I quit while in fullscreen mode and then start the game again at some other time, it will once more stretch to fill the screen, so the best thing to do is switch to windowed mode before quitting).

When switching modes it uses different algorithm than on startup for MacOSX port, which may be related.
When you startup in mode A engine remembers its settings, so switch forth and back will return to same settings. But when you start in mode B and switch to mode A later, these settings will be taken from "defaults" instead.

Quote from: Laura Hunt on Mon 31/05/2021 19:30:33
Interestingly, if I run the game in windowed mode, the cfg file that's located in the user's Saved Games profile folder sets itself to "scaling". If I run the game in fullscreen mode, the cfg sets itself to "max".

This is how default settings work for these modes, for fullscreen it's "max" which means current desktop size, and for windowed it's "scaling" which means take game size and scale by a integer factor.

I think it could use the main monitor for determining the desktop size. But this does not explain why it improves on switching modes.

PS. Also, in the latest version I disabled saving config by engine itself, so it will not longer change these settings in config file.

Manu

I just refreshed my Mac wrapper with a new version of the game, just copying the .exe and the .tra and renaming the exe "game.ags". Unfortunately, the app does not even open. I can see the icon on the dock, and it shuts down immediately. If I put the old game back, it's working. Is it possible that the wrapper 3.5.0 is not compatible with AGS 3.5.1 ? If not, what else could be the reason?

bx83

emabolo, TheVolumeRemote should generate a new wrapper for 3.5.1, or produce a tutorial on how to compile the 3.5.1 code into a Mac engine so I no longer have to bother him by proxy, HINT HINT HINT ;P

Manu

Quote from: bx83 on Thu 17/06/2021 14:37:25
emabolo, TheVolumeRemote should generate a new wrapper for 3.5.1, or produce a tutorial on how to compile the 3.5.1 code into a Mac engine so I no longer have to bother him by proxy, HINT HINT HINT ;P

I have no desire to install Xcode, it's too much for my Mac, it will probably destroy it :)
I'll be waiting for the new wrapper, thanks a lot to the developers!

Crimson Wizard

Quote from: emabolo on Thu 17/06/2021 09:10:30
I just refreshed my Mac wrapper with a new version of the game, just copying the .exe and the .tra and renaming the exe "game.ags". Unfortunately, the app does not even open. I can see the icon on the dock, and it shuts down immediately. If I put the old game back, it's working. Is it possible that the wrapper 3.5.0 is not compatible with AGS 3.5.1 ? If not, what else could be the reason?

Could you clarify, what is the "wrapper" and what versions are wrapper and the game files? I may be confused by the above description.

I don't know if related, but I did a small change for 3.5.1. macos port:

Quote
- When looking for game files engine will no longer use hardcoded filename, will search for any compatible pack file instead.

bx83

It's a compiled version of the Mac (3.5.0) engine; not really a wrapper. Well, in the sense it wraps a system-agnostic version of the game (say the windows exe file) as a Mac .app?...

Crimson Wizard

I think mac port should write a log? If you enable logging in config file, or from command line (if you can run this port from cmd line on your mac), then you may know more information on what is happening.

If I understand correctly, the log should be inside a game files subfolder, same place where it puts saves to.

How to configure log is described in the OPTIONS.md file in our repository (scroll down for command line options).
Here's one from 3.5.1: https://github.com/adventuregamestudio/ags/blob/release-3.5.1/OPTIONS.md
and older one from 3.5.0: https://github.com/adventuregamestudio/ags/blob/release-3.5.0/OPTIONS.md

Manu

Quote from: Crimson Wizard on Wed 23/06/2021 13:33:08
I think mac port should write a log? If you enable logging in config file, or from command line (if you can run this port from cmd line on your mac), then you may know more information on what is happening.


Posting this here for completeness even if we spoke on Discord.

The crash was generated by System.SaveConfigToFile() which is in fact an API available only on 3.5.1, while I was using the Mac "wrapper" created by TheVolumeRemote with version 3.5.0 (downloaded here: https://www.adventuregamestudio.co.uk/forums/index.php?topic=47264.msg636631416#msg636631416).

In the meantime, I learned how to compile the game on Mac with the latest version of AGS starting from the source code. I will post a step-by-step guide soon, it's quite easy in the end.



Hobbes

Emabolo, wow, such a guide sounds great. Looking forward to it!

Manu

#218
This is a small guide for all the people that would like to compile AGS and create a macOS version of their AGS game starting from scratch. I'm posting this guide here, but if you think it should be somewhere else, let me know.

Consider that the easiest solution to create a mac OS version of your game is to use the pre-made wrapper created by TheVolumeRemote: https://www.adventuregamestudio.co.uk/forums/index.php?topic=47264.msg636631416#msg636631416
With this wrapper, you can simply copy your game assets into the Resources folder, and it's done.

But if you want, you can do it from scratch following the small guide below. The main advantage is that as soon as there is a new version of AGS, e.g., 3.5.1.8, you can build your game with the latest version of the engine without waiting for the new wrapper.

It's pretty easy if you have some familiarity with the Mac terminal. And you don't need to install 50GB of XCode, just CMake. See details in the spoiler below.

Spoiler

PRE-REQUISITES


  • Download and Install CMake
    Download CMake from https://cmake.org/download/ - Choose "macOS 10.13 or later"
    Copy the app to your Applications folder. Launch it.
    Now open the Mac Terminal and type:
    PATH="/Applications/CMake.app/Contents/bin":"$PATH"


  • Download and Install Xcode Command Line Tools
    (not Xcode, just the command line tools).
    Go here: https://developer.apple.com/download/all/?q=command%20line and choose a version, for example "Command Line Tools for Xcode 12.5.1"
    Download the dmg and install it (unless you already have it, of course).

  • Download a free app called Image2Icon
    You will find it here https://img2icnsapp.com or on the Mac App Store.

NOW BUILD THE AGS APP:

  • Download the latest version of the AGS source code.
    Go here: https://github.com/adventuregamestudio/ags/releases
    and download the file "Source Code (zip)"


  • Unzip the archive somewhere (for example /Users/yourname/src/)
    You will obtain a folder like this:
    /Users/yourname/src/ags-v.3.5.1.8

  • Copy the game resources:
    Delete all the files inside this folder "/Users/yourname/src/ags-v.3.5.1.8/OSX/Resources/"
    Go to the Compiled/Data directory of your AGS game, and copy all the files you find there, to the folder you have emptied  "/Users/yourname/src/ags-v.3.5.1.8/OSX/Resources/"


  • Create the game icon
    Open Image2Icon, drag and drop a square image representing your game icon into the app, and choose "Export -> ICNS.
    Call the file "ags.icns". Copy this file into "/Users/yourname/src/ags-v.3.5.1.8/OSX/Resources/"

  • Build the game
    in the terminal, enter the OSX folder:
    "cd /Users/yourname/src/ags-v.3.5.1.8/OSX/"

    then type:
    cmake -DCMAKE_BUILD_TYPE=Release ..

    this will take a while. Once it's done, type:
    make

Final steps


  • If everything went well, you will have in the OSX folder a new app, called AGS.app
    rename it with "mv AGS.app MyGame.app" (where "MyGame" is the name of your game, better not to use spaces)

  • Enter MyGame.app/Contents/ and search for a file called Info.plist.
    Edit it with a text editor, like Sublime text, and change a few lines,
    CFBundleIdentifier = invent a unique id, for example: com.myname.mygame
    CFBundleName = My Game
    you can also change CFBundleVersion to add your game version and NSHumanReadableCopyright to specify the copyright.

  • Try the game.
    The game app (eg. MyGame.app) is inside the OSX folder. I suggest you zip it so that you are sure you will always keep the original version.
    Then drag and drop MyGame.app somewhere else (eg. Desktop).
    Double click the app to launch it.

DISTRIBUTING THE APP
You can simply upload to itch.io the ZIP file you created before.
Unfortunately, unless you are enrolled in the Apple Developer Program (99 eur/year) you won't be able to sign the app. This means when you distribute your game, people will receive several warnings.

You should instruct your users to do this:

  • download the zip file
  • extract the zip file and move the .app to Applications
  • right-click the game icon in Applications and select Open. It will open a window with some buttons. If there is no "open" button, close the window, don't do anything.
  • right click again on the game icon. This time you will see an open button.

In case I decide to pay for the Apple Developer program I will let you know how to sign the app :)
[close]

Hobbes

#219
Hi Manu, would it be OK if I added this to the AGS Wiki? It would be a great resource for people to keep an eye on. And then if the procedure changes, we can always update the wiki page.

Thanks for doing this!

It works a treat by the way! I just compiled my game from scratch using the latest AGS version   source code. I imagine this is how the wrapper is also created?

SMF spam blocked by CleanTalk