wizzomafizzo / tapto

Launch games using physical objects
GNU General Public License v3.0
64 stars 9 forks source link

feat(): Add a delay for exit game and do not exit from the menu core - untested yet - #43

Closed asturur closed 2 months ago

asturur commented 2 months ago

This pr adds a new configuration option exit_game_delay in seconds. When we remove a card we flip a boolean candidateForRemove to true and we keep track at what time the card was removed. If a new card gets scanned we flip candidateForRemove to false. Otherwise when we go to the condition for exiting the game we do a time elapsed check before exiting.

We also had to add a reference of the latest launched card, that can't be the activeCard, because that represent the card that was on the reader the poll loop before.

What we want to improve with this PR

Possible improvements

asturur commented 2 months ago

Made some testing:

sigboe commented 2 months ago

@asturur Hey in chat you said you wanted to add new settings your self to see how its done. I was gonna explain it in chat. But thought I'd just push part of the change, so it is easier to explain.

If you see commit https://github.com/wizzomafizzo/tapto/pull/43/commits/894f678c017e20fd5d69212d80996c90acd7b6d0 the bash function called _Settings() launches other functions. I added some names and descriptions, but feel free to change the text, just make sure it's not cut off.

Then just look at the functions like example _soundSetting() which changes a bolean value with the default being no (yes disabling the sound) so you can just copy that function, and change it to be exit_game, so its simple to use that as a template.

For the delay amount, and the blocklist you need to be more creative, but I can help in chat or here

asturur commented 2 months ago

@asturur Hey in chat you said you wanted to add new settings your self to see how its done. I was gonna explain it in chat. But thought I'd just push part of the change, so it is easier to explain.

If you see commit 894f678 the bash function called _Settings() launches other functions. I added some names and descriptions, but feel free to change the text, just make sure it's not cut off.

Then just look at the functions like example _soundSetting() which changes a bolean value with the default being no (yes disabling the sound) so you can just copy that function, and change it to be exit_game, so its simple to use that as a template.

For the delay amount, and the blocklist you need to be more creative, but I can help in chat or here

i wanted to do it myself to learn/test 😀

asturur commented 2 months ago

I ll try to make it work following this starting template

asturur commented 2 months ago

Logs example

{"level":"info","time":1712753141,"message":"TapTo v2.0"}
{"level":"info","time":1712753141,"message":"config path = /media/fat/Scripts/tapto.ini"}
{"level":"info","time":1712753141,"message":"app path = /media/fat/Scripts/tapto.sh"}
{"level":"info","time":1712753141,"message":"connection_string = "}
{"level":"info","time":1712753141,"message":"allow_commands = false"}
{"level":"info","time":1712753141,"message":"disable_sounds = false"}
{"level":"info","time":1712753141,"message":"probe_device = true"}
{"level":"info","time":1712753141,"message":"exit_game = true"}
{"level":"info","time":1712753141,"message":"exit_game_blocklist = []"}
{"level":"info","time":1712753141,"message":"debug = false"}
{"level":"info","time":1712753142,"message":"TapTo v2.0"}
{"level":"info","time":1712753142,"message":"config path = /media/fat/Scripts/tapto.ini"}
{"level":"info","time":1712753142,"message":"app path = /media/fat/Scripts/tapto.sh"}
{"level":"info","time":1712753142,"message":"connection_string = "}
{"level":"info","time":1712753142,"message":"allow_commands = false"}
{"level":"info","time":1712753142,"message":"disable_sounds = false"}
{"level":"info","time":1712753142,"message":"probe_device = true"}
{"level":"info","time":1712753142,"message":"exit_game = true"}
{"level":"info","time":1712753142,"message":"exit_game_blocklist = []"}
{"level":"info","time":1712753142,"message":"debug = false"}
{"level":"info","time":1712753142,"message":"starting tapto service"}
{"level":"info","time":1712753142,"message":"starting tracker"}
{"level":"info","time":1712753142,"message":"loaded 2426 name mappings"}
{"level":"info","time":1712753142,"message":"starting file watcher"}
{"level":"info","time":1712753142,"message":"starting tracker ticker"}
{"level":"info","time":1712753142,"message":"loaded 0 entries from database"}
{"level":"info","time":1712753142,"message":"reader not connected, attempting connection...."}
{"level":"info","time":1712753142,"message":"probing for serial devices"}
{"level":"info","time":1712753143,"message":"trying pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"}
{"level":"info","time":1712753143,"message":"success using serial: pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"}
{"level":"info","time":1712753143,"message":"connecting to device: pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"}
{"level":"info","time":1712753143,"message":"successful connect after 0 tries"}
{"level":"info","time":1712753143,"message":"connection protocol: pn532_uart"}
{"level":"info","time":1712753143,"message":"device name: pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"}
{"level":"info","time":1712753143,"message":"opened connection: pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 pn532_uart:/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0"}
{"level":"info","time":1712753185,"message":"found token UID: 04bd74215f6180"}
{"level":"info","time":1712753185,"message":"NTAG detected"}
{"level":"info","time":1712753186,"message":"decoded text NDEF: /media/fat/_Arcade/_alternatives/_The NewZealand Story/The NewZealand Story (US, old version) (P0-041A PCB).mra"}
{"level":"info","time":1712753186,"message":"launching with text: /media/fat/_Arcade/_alternatives/_The NewZealand Story/The NewZealand Story (US, old version) (P0-041A PCB).mra"}
{"level":"info","time":1712753190,"message":"core started: tnzsuo (0s)"}
{"level":"info","time":1712753203,"message":"card removed"}
{"level":"info","time":1712753205,"message":"found token UID: 04bd74215f6180"}
{"level":"info","time":1712753205,"message":"NTAG detected"}
{"level":"info","time":1712753205,"message":"decoded text NDEF: /media/fat/_Arcade/_alternatives/_The NewZealand Story/The NewZealand Story (US, old version) (P0-041A PCB).mra"}
{"level":"info","time":1712753205,"message":"Card was removed but inserted back"}
{"level":"info","time":1712753230,"message":"card removed"}
{"level":"info","time":1712753231,"message":"found token UID: 04b76a1f5f6181"}
{"level":"info","time":1712753231,"message":"NTAG detected"}
{"level":"warn","time":1712753231,"message":"no text NDEF found"}
{"level":"info","time":1712753233,"message":"found token UID: 04bd74215f6180"}
{"level":"info","time":1712753233,"message":"NTAG detected"}
{"level":"info","time":1712753233,"message":"decoded text NDEF: /media/fat/_Arcade/_alternatives/_The NewZealand Story/The NewZealand Story (US, old version) (P0-041A PCB).mra"}
{"level":"info","time":1712753233,"message":"Card was removed but inserted back"}
{"level":"info","time":1712753265,"message":"card removed"}
{"level":"info","time":1712753265,"message":"found token UID: 04dc9f1d5f6181"}
{"level":"info","time":1712753265,"message":"NTAG detected"}
{"level":"info","time":1712753266,"message":"decoded text NDEF: /media/fat/_Arcade/Out Run (sitdown-upright, Rev B).mra"}
{"level":"info","time":1712753266,"message":"launching with text: /media/fat/_Arcade/Out Run (sitdown-upright, Rev B).mra"}
{"level":"info","time":1712753270,"message":"core stopped: tnzsuo (80s)"}
{"level":"info","time":1712753270,"message":"core started: outrun (0s)"}
{"level":"info","time":1712753281,"message":"card removed"}
{"level":"info","time":1712753288,"message":"core stopped: outrun (18s)"}
asturur commented 2 months ago

Added test build tapto.sh.zip