Author Topic: The web version of AGILE (https://agi.sierra.games)  (Read 17756 times)

0 Members and 1 Guest are viewing this topic.

Offline Collector

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #15 on: April 06, 2024, 01:00:43 PM »
One small thing that I noticed is that the folder browser gets pegged as a popup in Firefox. Odd in that a regular file/folder open dialog for uploading does not do this. That dialog looks like a normal Windows dialog and not a Java one. This does not occur on Chrome.
KQII Remake Pic

Offline doomlazer

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #16 on: April 06, 2024, 02:21:15 PM »
Nice! Was that on an iPhone, or an iPad? I guess it might work on both if it works on one.

iPhone, but should be the same browser on iPad.

Ah... not so nice. At what point does it stop working? Does it show the open file dialog? - Unfortunate that there are no errors logged. Usually browsers are quite good at logging errors for things that don't work. No error could be a clue though.

Does the save game feature work in Safari? The game import code uses something called OPFS to store the game data. Saved games uses the same OPFS feature. It looks like OPFS should be supported in Safari from 15.2 onwards.

The game import feature uses a kind of hack. It could be due to that. What it does is to use Javascript to dynamically create a file type input element and then uses JS to click it. It registers an onchange event listener on that element so that when the file(s) are uploaded, it then uses a FileReader to process them. FileReader API has been around for a long time, but not sure if all browsers are happy with that hack I'm using.

I could add some debug console logging, but I'll let you answer the above questions first, so I know where to focus.

It allows me to select a folder or zip file, but does nothing once chosen. If you want to add some logging in GetDialogHandler.java I'll try it again.

Edit: Saving/loading seems to work just fine. Maybe it something later in the import process?
« Last Edit: April 06, 2024, 05:13:21 PM by doomlazer »

Offline Charles

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #17 on: April 06, 2024, 05:20:00 PM »
Strange that it recognised it actually. I have only added detection for DOS versions of the games so far. I assume that the DIR file it uses to calculate the MD5 hash from is identical in that IIgs version of KQ3 to one of the DOS versions. I'm not sure when I would get around to supporting the other platforms. I don't think it would be for quite a while, but it is something I'll add to the list for when time allows.
Oh, that's surprising... it added it as King's Quest 3 [Apple IIgs], but now that I look at it, the text is White (not grey) but the thumbnail picture is still dimmed. Honestly I was surprised that it recognized the IIgs version at all, but now I'm even more surprised knowing you didn't purposefully code it to recognize it.

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #18 on: April 07, 2024, 02:20:54 AM »
Oh, that's surprising... it added it as King's Quest 3 [Apple IIgs], but now that I look at it, the text is White (not grey) but the thumbnail picture is still dimmed. Honestly I was surprised that it recognized the IIgs version at all, but now I'm even more surprised knowing you didn't purposefully code it to recognize it.

I think I know what happened. Was that the name of the folder that contained the files? If it can't detect the game, then it uses the folder name instead.

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #19 on: April 07, 2024, 02:39:19 AM »
One small thing that I noticed is that the folder browser gets pegged as a popup in Firefox. Odd in that a regular file/folder open dialog for uploading does not do this. That dialog looks like a normal Windows dialog and not a Java one. This does not occur on Chrome.

What do you mean by pegged as a popup? Do you have something installed in Firefox to prevent popups? Or is that happening by default in your installation of Firefox? If so, what version of FF is it? - I am not seeing this behaviour in Firefox myself, but it does worry me a bit in regards to the way I'm launching that open file dialog, that perhaps it will be seen as a popup for other people as well.

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #20 on: April 07, 2024, 03:29:20 AM »
It allows me to select a folder or zip file, but does nothing once chosen. If you want to add some logging in GetDialogHandler.java I'll try it again.

Edit: Saving/loading seems to work just fine. Maybe it something later in the import process?

When you say that it allows you to select a folder or zip file, do you mean the choice of option from the drop down in the "Please select the type of import" dialog? i.e. not the selection of the actual ZIP or folder within the open file dialog? Or do you mean that it shows the open file dialog, lets you select a folder or zip, but does nothing after that?

If it is the first scenario, then it could be that its getting blocked, perhaps even detected as a popup similar to what Collector described.

If it is the second scenario, then I have found this stackoverflow page that might be related, although it does appear to be mentioning only iOS Safari: https://stackoverflow.com/questions/47664777/javascript-file-input-onchange-not-working-ios-safari-only

It is unfortunate though, as I didn't really want to add the input element to the dom, although there is one person that says that simply changing the onchange to addEventListener was all that was required for them. For now, I'll add only the console logging, so that we can see where it gets up to. Hopefully that helps narrow it down.

I have just deployed the version with the console logging adding. Can you give it another go now and let me know what you see in the console? Thanks.
 

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #21 on: April 07, 2024, 03:32:55 AM »
I'd like to check it out.

@russdanner, how are you getting on? I'm interested in how it works on the Linux versions of the browsers. Any issues so far?
« Last Edit: April 07, 2024, 04:10:00 AM by lance.ewing »

Offline Collector

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #22 on: April 07, 2024, 08:27:03 AM »
It was the builtin popup blocker. Upgrading to the latest quit flagging it as a popup.
KQII Remake Pic

Offline doomlazer

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #23 on: April 07, 2024, 12:17:25 PM »
When you say that it allows you to select a folder or zip file, do you mean the choice of option from the drop down in the "Please select the type of import" dialog? i.e. not the selection of the actual ZIP or folder within the open file dialog? Or do you mean that it shows the open file dialog, lets you select a folder or zip, but does nothing after that?

If it is the first scenario, then it could be that its getting blocked, perhaps even detected as a popup similar to what Collector described.

If it is the second scenario, then I have found this stackoverflow page that might be related, although it does appear to be mentioning only iOS Safari: https://stackoverflow.com/questions/47664777/javascript-file-input-onchange-not-working-ios-safari-only

It is unfortunate though, as I didn't really want to add the input element to the dom, although there is one person that says that simply changing the onchange to addEventListener was all that was required for them. For now, I'll add only the console logging, so that we can see where it gets up to. Hopefully that helps narrow it down.

I have just deployed the version with the console logging adding. Can you give it another go now and let me know what you see in the console? Thanks.

Here is a short video capture so you can see what's happening: https://drive.google.com/file/d/1ynF57pzOToBCpV0fQLKBF9Gp5o97YUE9/view?usp=sharing

addEventListener ("load" in my case) has worked for me before with Safari, and I didn't need to appendChild to import.

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #24 on: April 07, 2024, 01:33:34 PM »
It was the builtin popup blocker. Upgrading to the latest quit flagging it as a popup.

Thanks. That's good to know. I may need to put some checks in up front that displays a message if it thinks that the browser needs to be updated, e.g. checking for the APIs that it is dependent on, such as the SharedArrayBuffer, Origin Private File System, and a few others. Not certain exactly what to check for in the case of this popup blocker though. Perhaps the simplest way would be to check the browser version for each browser. I'd need to work out what the minimum is in each case though. Do you know what version of Firefox you had before you upgraded?

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #25 on: April 07, 2024, 01:38:39 PM »
Here is a short video capture so you can see what's happening: https://drive.google.com/file/d/1ynF57pzOToBCpV0fQLKBF9Gp5o97YUE9/view?usp=sharing

addEventListener ("load" in my case) has worked for me before with Safari, and I didn't need to appendChild to import.

Thanks. That video seems to suggest that it is indeed the change event handler that isn't running. I have now changed it to use addEventListener rather than onchange. I've only made that change for now, i.e. haven't used appendChild yet. - Can you try again now?

Offline doomlazer

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #26 on: April 07, 2024, 01:54:55 PM »
Sorry, but it's the same behavior as before.

Edit: I'm hesitant to point to any of my own code, but this worked for me in Safari for loading view files:

Code: [Select]
function importFile() {
        var input = document.createElement('input');
        input.type = 'file';

        input.onchange = e => {
          var file = e.target.files[0];
          const reader = new FileReader();

          reader.addEventListener(
            "load",
            () => {
                 // Do stuff
              }
            },
            false,
          );
          if (file) {
            reader.readAsArrayBuffer(file);
          }
        }
        input.click();
      }
« Last Edit: April 07, 2024, 02:22:10 PM by doomlazer »

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #27 on: April 07, 2024, 02:47:01 PM »
Sorry, but it's the same behavior as before.

Edit: I'm hesitant to point to any of my own code, but this worked for me in Safari for loading view files:

Code: [Select]
function importFile() {
        var input = document.createElement('input');
        input.type = 'file';

        input.onchange = e => {
          var file = e.target.files[0];
          const reader = new FileReader();

          reader.addEventListener(
            "load",
            () => {
                 // Do stuff
              }
            },
            false,
          );
          if (file) {
            reader.readAsArrayBuffer(file);
          }
        }
        input.click();
      }

One difference I can see is that I'm using the loadend event, whereas you're using the load event. According to the docs, the difference is that loadend is called regardless of whether it was successful or not.

This seems irrelevant though, as my code doesn't appear to be getting as far as the equivalent of your load event hadler. I currently have an event listener on the FileReader for the loadend event, but that is added within the change event listener, the start or which is as follows:

Code: [Select]
        fileInputElem.addEventListener("change", function(event) {
            if (this.files.length === 0) {
                console.log('No files selected for import');
           
                // No file was selected, so nothing more to do.
                resultsHandler.@com.agifans.agile.gwt.GwtOpenFileResultsHandler::onFileResultsReady([Lcom/agifans/agile/gwt/GwtOpenFileResult;)([]);
            }
            else {
                console.log('File(s) were selected for import. Reading them now...');

...and then later on within the code of that 'change' event listener, it creates the FileReader and adds the loadend event handler. But looking at your video, it isn't logging the "File(s) were selected for import. Reading them now..." message, so that would mean that the 'change' event handler hasn't been executed yet, so it wouldn't be getting to the FileReader creation or associated event handler.

But if your code is working in Safari, there must be a clue in there somewhere. Let me look it over for other differences...  Hmmm, I can't seem to see anything that would explain why your onchange event handler is running and my one wasn't. I previously had it exactly as you have it, i.e. create the input file element then setting onchange, but that wasn't working, and now also the addEventListener equivalent isn't working.

Maybe there is something different about where our two bits of code are being executed from that makes Safari behave differently.

I can try a couple more things based on other suggestions I've seen in stackoverflow answers. I'll post back here in a bit after making the first of those (probably the appendChild change first, and if that doesn't work, then I'll try changing it to the blur event).

Edit: Just to double check my assumptions above, when you say the following:

Sorry, but it's the same behavior as before.

...were the console log messages also exactly the same? i.e. the "File(s) were selected for import. Reading them now..." message isn't logged? - I just realised I was commenting on the pre "addEventListener" version of the change event handler when referring to the console messages. What I might do before using appendChild is to change the load event of the FileReader to also use addEventListener, since I'm guessing I'll have an issue with that one as well.
« Last Edit: April 07, 2024, 03:14:01 PM by lance.ewing »

Offline lance.ewing

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #28 on: April 07, 2024, 03:34:49 PM »
What I might do before using appendChild is to change the load event of the FileReader to also use addEventListener, since I'm guessing I'll have an issue with that one as well.

I've just deployed that change. It is now using addEventListener for both the file input element change event, and now also the FileReader loadend event.

Offline doomlazer

Re: The web version of AGILE (https://agi.sierra.games)
« Reply #29 on: April 07, 2024, 04:09:58 PM »
...were the console log messages also exactly the same? i.e. the "File(s) were selected for import. Reading them now..." message isn't logged? - I just realised I was commenting on the pre "addEventListener" version of the change event handler when referring to the console messages. What I might do before using appendChild is to change the load event of the FileReader to also use addEventListener, since I'm guessing I'll have an issue with that one as well.

The console messages are still:
[Log] About to create input element of type file...
[Log] Finished creating input element of type file
[Log] File input element has been clicked.

It seems like the "change" event listener never triggers on Safari. Testing with my old project, changing "load" to "loadend" fires an event, but "change" never seems to. Isn't change just for radio buttons and checkboxes?

Instead of using an event listener for "change" in my project I do:

Code: [Select]
input.onchange = e => {
while you've got:

Code: [Select]
fileInputElem.addEventListener("change", function(event) {
I only use the eventlistener for "load" on the FileReader.
« Last Edit: April 07, 2024, 04:28:25 PM by doomlazer »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.059 seconds with 22 queries.