From 94af1314638f90c487017ffd1e9a63444a55507a Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Thu, 30 Jun 2022 00:36:14 +0200 Subject: [PATCH 01/12] switched music paths to ensure windows compatibility --- pokete_classes/audio.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pokete_classes/audio.py b/pokete_classes/audio.py index ace03c0c..c350dff9 100644 --- a/pokete_classes/audio.py +++ b/pokete_classes/audio.py @@ -1,6 +1,7 @@ """This manages audio playback""" import multiprocessing +from pathlib import Path try: from playsound import playsound except ModuleNotFoundError: @@ -8,13 +9,13 @@ from .settings import settings -MUSIC_PATH = __file__.replace("pokete_classes/audio.py", 'assets/music/') +MUSIC_PATH = Path(__file__).parent.parent / 'assets' / 'music' def audio_fn(song, play_audio): """plays a song in loop""" while play_audio: - playsound(MUSIC_PATH + song) + playsound(MUSIC_PATH / song) class Audio: From f44716ddfa8fca1458c1fee5f2ea01174560202a Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Thu, 30 Jun 2022 22:36:15 +0200 Subject: [PATCH 02/12] minor path change Co-authored-by: Mustafa Quraish --- pokete_classes/audio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokete_classes/audio.py b/pokete_classes/audio.py index c350dff9..5e49754e 100644 --- a/pokete_classes/audio.py +++ b/pokete_classes/audio.py @@ -9,7 +9,7 @@ from .settings import settings -MUSIC_PATH = Path(__file__).parent.parent / 'assets' / 'music' +MUSIC_PATH = Path(__file__).parents[1] / 'assets' / 'music' def audio_fn(song, play_audio): From fc137f44f1e205289b6be66fe5b964aa310c056d Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 15:18:40 +0200 Subject: [PATCH 03/12] fixed sound I now went through the pain of setting up a windows vm and finly fixing audio for windows --- README.md | 2 +- pokete_classes/audio.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f771f4e7..0bdd14ef 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ For Windows and OSX: ```shell git clone https://github.com/lxgr-linux/pokete.git -pip install scrap_engine pynput playsound pygobject +pip install scrap_engine pynput playsound==1.2.2 ``` To run just execute `pokete.py`. diff --git a/pokete_classes/audio.py b/pokete_classes/audio.py index 5e49754e..4fc252f5 100644 --- a/pokete_classes/audio.py +++ b/pokete_classes/audio.py @@ -15,7 +15,7 @@ def audio_fn(song, play_audio): """plays a song in loop""" while play_audio: - playsound(MUSIC_PATH / song) + playsound(str(MUSIC_PATH / song)) class Audio: From 9731775cb91372d3032bef855344dd20ada9d1fe Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 16:29:23 +0200 Subject: [PATCH 04/12] Added OSX compatibility --- README.md | 4 ++-- pokete.py | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0bdd14ef..1ef3340b 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Pokete is a small terminal based game in the style of a very popular and old game by Gamefreak. ## Installation -For Linux just do this: +For Linux, BSD, OSX etc. just do this: ```shell # pip install scrap_engine playsound pygobject $ git clone https://github.com/lxgr-linux/pokete.git @@ -38,7 +38,7 @@ Or you can just run the AppImage from the release page. NOTE: In that case you first have to create the `~/.cache/pokete/` folder. -For Windows and OSX: +For Windows: ```shell git clone https://github.com/lxgr-linux/pokete.git diff --git a/pokete.py b/pokete.py index 45258d6d..f1c216eb 100755 --- a/pokete.py +++ b/pokete.py @@ -1390,7 +1390,16 @@ def map_additions(): if __name__ == "__main__": do_logging, load_mods, force_pynput = parse_args(sys.argv) # deciding on wich input to use - if sys.platform == "linux" and not force_pynput: + if sys.platform == "win32" or force_pynput: + from pynput.keyboard import Listener + + + def recogniser(): + """Gets keyboard input from pynput""" + while True: + with Listener(on_press=on_press) as listener: + listener.join() + else: import tty import termios import select @@ -1422,15 +1431,6 @@ def recogniser(): ) if ord(char) == 3: reset_terminal() - else: - from pynput.keyboard import Listener - - - def recogniser(): - """Gets keyboard input from pynput""" - while True: - with Listener(on_press=on_press) as listener: - listener.join() print("\033[?1049h") From b08b0b8d903f6959b2243310ab2227b731f373d0 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 16:45:14 +0200 Subject: [PATCH 05/12] Added msvcrt --- pokete.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/pokete.py b/pokete.py index f1c216eb..519e0cb3 100755 --- a/pokete.py +++ b/pokete.py @@ -1391,14 +1391,27 @@ def map_additions(): do_logging, load_mods, force_pynput = parse_args(sys.argv) # deciding on wich input to use if sys.platform == "win32" or force_pynput: - from pynput.keyboard import Listener + import msvcrt def recogniser(): """Gets keyboard input from pynput""" - while True: - with Listener(on_press=on_press) as listener: - listener.join() + while True: + rlist, _, _ = select.select([msvcrt.getwch()], [], [], 0.1) + if rlist: + char = msvcrt.getwch() + _ev.set( + { + ord(char): f"{char.rstrip()}", + 13: "Key.enter", + 127: "Key.backspace", + 32: "Key.space", + 27: "Key.esc", + 3: "exit", + }[ord(char)] + ) + if ord(char) == 3: + reset_terminal() else: import tty import termios From b256560eb3169d2617ca36399341713aae826401 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 16:49:30 +0200 Subject: [PATCH 06/12] maybe fixed windows input --- pokete.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pokete.py b/pokete.py index 519e0cb3..c3a733f7 100755 --- a/pokete.py +++ b/pokete.py @@ -1396,9 +1396,8 @@ def map_additions(): def recogniser(): """Gets keyboard input from pynput""" - while True: - rlist, _, _ = select.select([msvcrt.getwch()], [], [], 0.1) - if rlist: + while True: + if msvcrt.kbhit(): char = msvcrt.getwch() _ev.set( { From c53c76475ec5beb9c7a000838ef3a2ede0a8f656 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 17:02:35 +0200 Subject: [PATCH 07/12] added backspace to windows --- pokete.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pokete.py b/pokete.py index c3a733f7..e059db14 100755 --- a/pokete.py +++ b/pokete.py @@ -1404,6 +1404,7 @@ def recogniser(): ord(char): f"{char.rstrip()}", 13: "Key.enter", 127: "Key.backspace", + 8: "Key.backspace", 32: "Key.space", 27: "Key.esc", 3: "exit", From 33fc2cc393ab039d05cc3e96760e279f4fd9e698 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 17:09:11 +0200 Subject: [PATCH 08/12] removed pynput --- README.md | 2 +- pokete.py | 9 ++++----- pokete_general_use_fns.py | 6 +----- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1ef3340b..ad4e980c 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ For Windows: ```shell git clone https://github.com/lxgr-linux/pokete.git -pip install scrap_engine pynput playsound==1.2.2 +pip install scrap_engine playsound==1.2.2 ``` To run just execute `pokete.py`. diff --git a/pokete.py b/pokete.py index e059db14..aeb6ae64 100755 --- a/pokete.py +++ b/pokete.py @@ -820,7 +820,7 @@ def on_press(key): def reset_terminal(): """Resets the terminals state""" - if sys.platform == "linux" and not force_pynput: + if sys.platform == "linux": termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) @@ -1388,9 +1388,9 @@ def map_additions(): # Actual code execution ####################### if __name__ == "__main__": - do_logging, load_mods, force_pynput = parse_args(sys.argv) + do_logging, load_mods = parse_args(sys.argv) # deciding on wich input to use - if sys.platform == "win32" or force_pynput: + if sys.platform == "win32": import msvcrt @@ -1410,8 +1410,7 @@ def recogniser(): 3: "exit", }[ord(char)] ) - if ord(char) == 3: - reset_terminal() + else: import tty import termios diff --git a/pokete_general_use_fns.py b/pokete_general_use_fns.py index 770c1e26..74cb9825 100644 --- a/pokete_general_use_fns.py +++ b/pokete_general_use_fns.py @@ -62,7 +62,6 @@ def print_help(path): --log : Enables logging --help : Shows this help --no_mods : Disables mods - --force_pynput : Forces the usage of pynput as a keyboard input backend Homepage: https://github.com/lxgr-linux/pokete @@ -82,14 +81,11 @@ def parse_args(args): Tuple of do_logging and load_mods""" do_logging = False load_mods = True - force_pynput = False for arg in args[1:]: if arg == "--log": do_logging = True elif arg == "--no_mods": load_mods = False - elif arg == "--force_pynput": - force_pynput = True elif arg == "--help": print_help(args[0]) sys.exit(0) @@ -97,7 +93,7 @@ def parse_args(args): print(f":: Error: '{arg}' is not a valid option! See '--help' for \ options.") sys.exit(1) - return do_logging, load_mods, force_pynput + return do_logging, load_mods if __name__ == "__main__": From fbb93c9438d24ff5db6b8db9790ba43b6db6cb69 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 17:09:48 +0200 Subject: [PATCH 09/12] ... --- pokete.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pokete.py b/pokete.py index aeb6ae64..c107dd6b 100755 --- a/pokete.py +++ b/pokete.py @@ -811,13 +811,6 @@ def read_save(): return _si -def on_press(key): - """Sets the input to either a character like 'a' or '1', or Key.enter, Key.backspace, Key.space, Key.esc, exit - ARGS: - key: Key object _ev is set from""" - _ev.set(str(key).strip("'")) - - def reset_terminal(): """Resets the terminals state""" if sys.platform == "linux": From 7429a49960f497218c1bc16dae7579c40582dd80 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Fri, 22 Jul 2022 17:17:46 +0200 Subject: [PATCH 10/12] Removed pynput from pipfile --- Pipfile | 5 ++--- Pipfile.lock | 57 ++++++++++++---------------------------------------- 2 files changed, 15 insertions(+), 47 deletions(-) diff --git a/Pipfile b/Pipfile index 72acfa84..037f084a 100644 --- a/Pipfile +++ b/Pipfile @@ -5,9 +5,8 @@ name = "pypi" [packages] scrap-engine = ">=1.2.0" -pynput = {version = ">=1.7.6", sys_platform = "!= 'linux'"} -playsound = "*" -pygobject = "*" +playsound = "1.2.2" +pygobject = {version = "*", sys_platform = "== 'linux'"} [dev-packages] pylint = "*" diff --git a/Pipfile.lock b/Pipfile.lock index 3268f0f4..2e9dc313 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "8561aacc14033bb3586b5cf62752463bd8fd8cde03e97cadb445e69eda8e6639" + "sha256": "bbffb8ad1c59b9c0759afd52651d68f10b82019575a4795fc34dc1247b6c2b84" }, "pipfile-spec": 6, "requires": { @@ -23,37 +23,6 @@ "index": "pypi", "version": "==1.3.0" }, - "pycairo": { - "hashes": [ - "sha256:251907f18a552df938aa3386657ff4b5a4937dde70e11aa042bc297957f4b74b", - "sha256:26b72b813c6f9d495f71057eab89c13e70a21c92360e9265abc049e0a931fa39", - "sha256:31e1c4850db03201d33929cbe1905ce1b33202683ebda7bb0d4dba489115066b", - "sha256:4357f20a6b1de8f1e8072a74ff68ab4c9a0ae698cd9f5c0f2b2cdd9b28b635f6", - "sha256:44a2ecf34968de07b3b9dfdcdbccbd25aa3cab267200f234f84e81481a73bbf6", - "sha256:6d37375aab9f2bb6136f076c19815d72108383baae89fbc0d6cb8e5092217d02", - "sha256:70936b19f967fa3cb3cd200c2608911227fa5d09dae21c166f64bc15e714ee41", - "sha256:dace6b356c476de27f8e1522428ac21a799c225703f746e2957d441f885dcb6c", - "sha256:f63c153a9ea3d21aff85e2caeee4b0c5d566b2368b4ed64826020d12953d76a4" - ], - "markers": "python_version >= '3.7'", - "version": "==1.21.0" - }, - "pygobject": { - "hashes": [ - "sha256:80d6a3ad1630e9d1edf31b9e9fad9a894c57e18545a3c95ef0044ac4042b8620" - ], - "index": "pypi", - "version": "==3.42.1" - }, - "pynput": { - "hashes": [ - "sha256:19861b2a0c430d646489852f89500e0c9332e295f2c020e7c2775e7046aa2e2f", - "sha256:264429fbe676e98e9050ad26a7017453bdd08768adb25cafb918347cf9f1eb4a", - "sha256:3a5726546da54116b687785d38b1db56997ce1d28e53e8d22fc656d8b92e533c" - ], - "markers": "sys_platform != 'linux'", - "version": "==1.7.6" - }, "scrap-engine": { "hashes": [ "sha256:767ffdc312b550777771cdc9a350a9f6dca73855259dd1fe7197c8736e38cac1" @@ -65,11 +34,11 @@ "develop": { "astroid": { "hashes": [ - "sha256:4f933d0bf5e408b03a6feb5d23793740c27e07340605f236496cd6ce552043d6", - "sha256:ba33a82a9a9c06a5ceed98180c5aab16e29c285b828d94696bf32d6015ea82a9" + "sha256:86b0a340a512c65abf4368b80252754cda17c02cdbbd3f587dddf98112233e7b", + "sha256:bb24615c77f4837c707669d16907331374ae8a964650a66999da3f5ca68dc946" ], "markers": "python_full_version >= '3.6.2'", - "version": "==2.11.6" + "version": "==2.11.7" }, "dill": { "hashes": [ @@ -148,19 +117,19 @@ }, "pylint": { "hashes": [ - "sha256:482f1329d4b6b9e52599754a2e502c0ed91ebdfd0992a2299b7fa136a6c12349", - "sha256:592d0a4d2ffa8e33020209d255827c5a310499cdc023d156187bc677d86bd495" + "sha256:487ce2192eee48211269a0e976421f334cf94de1806ca9d0a99449adcdf0285e", + "sha256:fabe30000de7d07636d2e82c9a518ad5ad7908590fe135ace169b44839c15f90" ], "index": "pypi", - "version": "==2.14.2" + "version": "==2.14.5" }, "setuptools": { "hashes": [ - "sha256:5a844ad6e190dccc67d6d7411d119c5152ce01f7c76be4d8a1eaa314501bba77", - "sha256:bf8a748ac98b09d32c9a64a995a6b25921c96cc5743c1efa82763ba80ff54e91" + "sha256:0d33c374d41c7863419fc8f6c10bfe25b7b498aa34164d135c622e52580c6b16", + "sha256:c04b44a57a6265fe34a4a444e965884716d34bae963119a76353434d6f18e450" ], "markers": "python_version >= '3.7'", - "version": "==62.4.0" + "version": "==63.2.0" }, "tomli": { "hashes": [ @@ -172,11 +141,11 @@ }, "tomlkit": { "hashes": [ - "sha256:0f4050db66fd445b885778900ce4dd9aea8c90c4721141fde0d6ade893820ef1", - "sha256:71ceb10c0eefd8b8f11fe34e8a51ad07812cb1dc3de23247425fbc9ddc47b9dd" + "sha256:1c5bebdf19d5051e2e1de6cf70adfc5948d47221f097fcff7a3ffc91e953eaf5", + "sha256:61901f81ff4017951119cd0d1ed9b7af31c821d6845c8c477587bbdcd5e5854e" ], "markers": "python_version >= '3.6' and python_version < '4.0'", - "version": "==0.11.0" + "version": "==0.11.1" }, "wrapt": { "hashes": [ From 7723b78eadb883b97dbe5fbb639531125377b15a Mon Sep 17 00:00:00 2001 From: lxgr-linux <64218491+lxgr-linux@users.noreply.github.com> Date: Sat, 23 Jul 2022 17:24:01 +0200 Subject: [PATCH 11/12] Update pokete.py Co-authored-by: MaFeLP <60669873+MaFeLP@users.noreply.github.com> --- pokete.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pokete.py b/pokete.py index 05f04592..dbd20ed8 100755 --- a/pokete.py +++ b/pokete.py @@ -1389,7 +1389,7 @@ def map_additions(): def recogniser(): - """Gets keyboard input from pynput""" + """Gets keyboard input from msvcrt, the Microsoft Visual C++ Runtime""" while True: if msvcrt.kbhit(): char = msvcrt.getwch() From 0e48d4b1ee37af3be54762d01694f47c859a3b66 Mon Sep 17 00:00:00 2001 From: lxgr-linux Date: Sun, 24 Jul 2022 00:03:40 +0200 Subject: [PATCH 12/12] added OSX install notes --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6522c6d0..246392bb 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Pokete is a small terminal based game in the style of a very popular and old game by Gamefreak. ## Installation -For Linux, BSD, OSX etc. just do this: +For Linux, BSD etc. just do this: ```shell # pip install scrap_engine playsound pygobject $ git clone https://github.com/lxgr-linux/pokete.git @@ -38,6 +38,12 @@ Or you can just run the AppImage from the release page. NOTE: In that case you first have to create the `~/.cache/pokete/` folder. +For OSX: +```shell +# pip install scrap_engine playsound pyobjc +$ git clone https://github.com/lxgr-linux/pokete.git +$ ./pokete/pokete.py +``` For Windows: ```shell