[SOLVED] Open web from Linux does not work.

Started by JoanMon, Mon 31/01/2022 05:17:40

Previous topic - Next topic

JoanMon

- 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
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.

Khris

*.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.

Crimson Wizard

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.

eri0o

#3
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.

JoanMon

Thanks for answering.
I add this "libagsshell.so" file in the Linux subfolder of the Editor's program folder, but it doesn't work.

eri0o

I think it needs to be in a directory that ends with 64, with the other .so libraries.

JoanMon

eri0o, I've already put it there, I've tried to put it in that folder, but it doesn't work.



I have also tried to put it in the compilation folder but it doesn't work.

Crimson Wizard

#7
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.

JoanMon

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
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");
  }
}

eri0o

#9
The correct pattern is the following, according to my notes in the repository above:

Code: ags
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...)

JoanMon

Thank you very much eri0o, with your code it works correctly.
Solved.

SMF spam blocked by CleanTalk