kaorahi / lizgoban

Leela Zero & KataGo visualizer
GNU General Public License v3.0
169 stars 28 forks source link

Request: Ability to default "open with" .sgf files with LizGoban #70

Open JamesMowery opened 3 years ago

JamesMowery commented 3 years ago

It would be great if, when you set .sgf files on your computer to open by default with LizGoban, if that actually worked as would be expected. When setting LizGoban to open .sgf files by default currently, nothing really happens after LizGoban opens up. It doesn't automatically load the .sgf file.

Thanks! Really loving the program so far! Happy it's updated to KataGo 1.9!

kaorahi commented 3 years ago

happy to hear you enjoy my program :)

Before examining how we can realize it, I'd like to confirm this: Are you using LizGoban 0.*.*.exe on Windows? If "no", please let me know your environment and how you launch lizgoban.

JamesMowery commented 3 years ago

No worries! I'm using LizGoban 0.6.2 with updated version of Windows 10, and just tried it this morning! Tried with both the prior version and new version of LizGoban.

This is what I see when I try to explicitly "open with" LizGoban...

https://drive.google.com/uc?id=1IWFjrzBlvI7hsgldZtIVryWsMXdBVp2F

As you can see, nothing has happened. It just opened the program as it normally would. I'd still need to go to File > Open SGF or drag the file in for it to actually open it.

Would just be very handy because the only reason I download .sgf files is to open them in LizGoban. So being able to set LizGoban as the default app and immediately open it up with the file loaded would save some time.

kaorahi commented 3 years ago

Ah, sorry. I just intended to confirm...

  1. Are you using Windows? (not Mac, Linux, etc.)
  2. Are you using *.exe? (not npm start, lizgoban_windows.vbs, etc.)

I'll study how to implement this feature.

JamesMowery commented 3 years ago

1.) Yes! Sorry for not showing the window chrome. Latest updated version of Windows 10 being used. 2.) Yup! Using the LizGoban 0.6.2.exe for the "Open With" command.

If it's helpful, it looks like Sabaki is also written with Electron. So perhaps the author of the program might be willing to help provide code to easily drop this in to implement the open with functionality.

Thanks so much!

kaorahi commented 3 years ago

Not so easy...

"Open with" itself seems to work for lizgoban. I get into trouble if I use "open with" when lizgoban is already running. There are two strategies in this case.

I prefer (B) strongly. But the standard way of (B) in Electron (requestSingleInstanceLock and second-instance) does not work well in my case. It goes like this:

  1. The second instance starts.
  2. The second instance checks "I am not first" and quits.
  3. As a side effect of Step 2, the first instance receives an event on this attempt.
  4. The first instance reacts to the attempt.

As Lizgoban*.exe is a compressed archive actually, Step 1 takes unbearably long time for extraction before its start.

qcgm1978 commented 9 months ago

Why not add Recent files menu item. It's easy to view and open recent opened files?

function get_recent_files() {
        const files = store.get('recent_files') || [];
        const item = files.map(file => ({
            label: file,
            click() { load_sgf_etc(file) }
        }))
        return item;
    }
    const file_menu = menu('File', [
        menu('Recent Files', get_recent_files()),
截屏2023-11-30 14 36 10
kaorahi commented 9 months ago

Hmm, the 'recent files' feature seems unrelated to this issue for me. Am I missing something?

qcgm1978 commented 9 months ago

I only want to know whether there's such feature in the project. I think they're the similar problems to me. Of course they are different features to others.

kaorahi commented 9 months ago

I see. Then let's move to the new issue #101.