-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only show PewPew games in the menu #3
base: master
Are you sure you want to change the base?
Conversation
This excludes e.g. boot.py and webrepl_cfg.py, which are usually present on ESP8266 boards, but not useful to launch from the menu.
To be honest, I would prefer to not look into the files. How about just having a I'm also thinking about not having the games run their code on import, but instead have something like a |
A The disadvantage of a “games” directory is that the WebREPL HTML client only allows putting files in the root (or I haven’t figured out how to use subdirectories yet – |
I wasn't aware about that limitation of the webrepl client. Let's consider our options:
|
I was wrong about the WebREPL – it sends files using a relative destination path, so they end up in the current directory, and you can Of the options you list, the dedicated directory sounds like the simplest and least restricting or inconvenient solution, apart from looking at the file content. I’m curious, what is it that you don’t like about looking into the files? I don’t insist on using Why do we have to compile a custom firmware? I certainly haven’t, so far. Is that a difference between ESP8266 (which I am using) and SAMD platforms? |
Sorry for the delay, I was travelling and couldn't answer. You are right, you don't have to compile your own firmware with the current generation of PewPew boards — I confused it with µGame, which needs a small part written in C. So the extension option is not viable. I'm not sure what is my problem with looking at the contents — it just that opening and reading every single file seems wrong. We could probably look at a hashbang at the beginning of the file, or something similar. It still doesn't feel right, but that's how all the desktop file managers do that... I think that a separate metadata file is the best way to go with respect to flexibility and future development. You can put a user-friendly game name in it, some additional information like author and copyright, maybe even an icon, and the entry point for starting the game (what file to import and what function to call). The down side is that then you would need two files for creating a new game, but I'm not sure it's that bad? |
It seemed like less of a hassle for developers and users to have the metadata and the Python code in the same file, but you are right, it has disadvantages too – can’t filter by name extension, doesn’t work with compiled files. I don’t have a strong opinion on this, go with what you think works best. Most importantly, choose what fits best into your vision of the PewPew/µGame ecosystem. You obviously have the better overview there than I do. |
@cwalther we might need to think about another way to do such thing since the change you're proposing in this PR might have some drawback, think for a moment that someone has a comment on the >>> a = "import pewpew # importing pewpew module. "
>>> a.strip()
'import pewpew # importing pewpew module.'
>>> a.strip() == "import pewpew"
False Maybe it is safer to use regex when verifying if the "game" has that Regards. |
I wouldn’t consider it too much to ask of people to have the magic line be exactly |
We should also think about excluding dot-files from the menu. When saving a file |
On the ESP8266, in addition to any PewPew games, I have files boot.py and webrepl_cfg.py in the filesystem root. There may be other libraries too. These all show up in the PewPew menu (menu.py), even though launching them as games makes no sense.
The attached commit filters the directory listing to files that are recognized as PewPew games by checking whether one of their first two lines is
import pew
. Specifying that it must be the first line would make the code even simpler, but this is currently not satisfied by tetris.py.What do you think about this?