Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: JoanMon on Mon 31/01/2022 05:17:40

Title: [SOLVED] Open web from Linux does not work.
Post by: JoanMon on Mon 31/01/2022 05:17:40
- AGS Editor .NET (Build 3.5.1.11)
- Bass Template
-----------------------------------------------------------------------------------
Hello, I've added to the main AGS folder "libagsshell.so" and "ags_shell.dll".

I opened the game and activated "ags_shell.dll" pulgin.
"libagsshell.so" does not appear in the project tree.

I've created a button in the game startup GUI and inserted the following code:

Code (ags) Select
function Button_OnClick(GUIControl *control, MouseButton button)
{
  if( System.OperatingSystem == eOSWindows ){
    ShellExecute("", "http://website.com", "");
  } else if( System.OperatingSystem == eOSLinux ){
    ShellExecute("", "", "xdg-open http://website.com");
  }
}


On Windows it works perfectly, but on Linux does not work.
Any suggestions as to what I might be doing wrong?
Thanks.
Title: Re: Open web from Linux does not work.
Post by: Khris on Mon 31/01/2022 08:57:22
*.dll is Windows only. Not sure what the current state here is but afaik, using a plugin on Linux only works inside a Win32 context, like VirtualBox or Wine.
Title: Re: Open web from Linux does not work.
Post by: Crimson Wizard on Mon 31/01/2022 14:12:27
Quote from: JoanMon on Mon 31/01/2022 05:17:40
Hello, I've added to the main AGS folder "libagsshell.so" and "ags_shell.dll".

TBH I was unaware the linux version of this plugin exists. But if it does, and suppose to work, note that you should add this libagsshell.so file in the Linux subfolder of the Editor's program folder.

The *.so files do not appear in the project tree, but if they are found - they will be copied to Compiled/Linux/libxxx of your game.
Title: Re: Open web from Linux does not work.
Post by: eri0o on Mon 31/01/2022 14:55:05
QuoteTBH I was unaware the linux version of this plugin exists.

Unfortunately I made it: https://github.com/ericoporto/agsshell

But I don't really like the implications of something as general as agsshel - it can run any command in your computer, so it could do bad things either by accidental coding or an evil developer.

I think the use case of opening a browser is rather common so I have been thinking about adding a System.OpenURL that would use SDL2 OpenURL if possible and do in a way that it can only use https/http urls - possibly through an enum, to really restrict what can be done.

Or also a simpler plugin, agsopenurl or something.
Title: Re: Open web from Linux does not work.
Post by: JoanMon on Wed 02/02/2022 00:05:04
Thanks for answering.
I add this "libagsshell.so" file in the Linux subfolder of the Editor's program folder, but it doesn't work.
Title: Re: Open web from Linux does not work.
Post by: eri0o on Wed 02/02/2022 01:47:03
I think it needs to be in a directory that ends with 64, with the other .so libraries.
Title: Re: Open web from Linux does not work.
Post by: JoanMon on Wed 02/02/2022 02:58:21
eri0o, I've already put it there, I've tried to put it in that folder, but it doesn't work.

(https://i.ibb.co/3rpLLj8/Warning.png)

I have also tried to put it in the compilation folder but it doesn't work.
Title: Re: Open web from Linux does not work.
Post by: Crimson Wizard on Wed 02/02/2022 03:12:15
According to the error message, the file must be called exactly "lib_agsshell.so"; in the first post you mentioned "libagsshell.so" without underscore. Please double check that the name.
IIRC the linux's library must be called exactly like the dll, bit with a "lib" prefix.
For example, if the dll is called "my_plugin.dll", the *.so should be "libmy_plugin.so".

Normally there should be 2 files, one for 32-bit and another for 64-bit linux, put in the Linux/lib32 and/or Linux/lib64 respectively.

Editor only checks for the plugin presence in its program folder, and ignores them in the game's Compiled folder.
Title: Re: Open web from Linux does not work.
Post by: JoanMon on Wed 02/02/2022 05:36:26
Thank you very much Crimson Wizard, now the game compiles correctly and add "libags_shell.so" automatically to the 32 and 64 bit libraries, but it still doesn't work.

Maybe there is something wrong in the Linux code?

Code (ags) Select
function JoanMonGames_OnClick(GUIControl *control, MouseButton button)
{
aClick.Play();
Wait(10);
  if( System.OperatingSystem == eOSWindows )
  {
  ShellExecute("", "https://joanmon-games.itch.io", "");
  }
  else if( System.OperatingSystem == eOSLinux ){
  ShellExecute("", "", "https://joanmon-games.itch.io");
  }
}
Title: Re: Open web from Linux does not work.
Post by: eri0o on Wed 02/02/2022 08:39:21
The correct pattern is the following, according to my notes in the repository above:

Code (ags) Select
if( System.OperatingSystem == eOSWindows ){
    ShellExecute("open", "rundll32.exe", "url.dll,FileProtocolHandler https://joanmon-games.itch.io");
  } else if( System.OperatingSystem == eOSLinux ){
    ShellExecute("", "", "xdg-open https://joanmon-games.itch.io");
  }


(I haven't actually tested, it's just what I noted down, so maybe I tested this in the past...)
Title: Re: Open web from Linux does not work.
Post by: JoanMon on Wed 02/02/2022 10:45:54
Thank you very much eri0o, with your code it works correctly.
Solved.