PyRobbo 1.0.0__tar.gz → 1.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyrobbo-1.0.0/PyRobbo.egg-info → pyrobbo-1.1.0}/PKG-INFO +38 -9
- pyrobbo-1.0.0/PKG-INFO → pyrobbo-1.1.0/README.md +27 -23
- pyrobbo-1.1.0/pyproject.toml +57 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/__init__.py +24 -12
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/editor.py +88 -64
- pyrobbo-1.1.0/robbo/i18n.py +44 -0
- pyrobbo-1.1.0/robbo/levels.py +318 -0
- pyrobbo-1.1.0/robbo/locale/pl/LC_MESSAGES/pyrobbo.mo +0 -0
- pyrobbo-1.1.0/robbo/locale/pl/LC_MESSAGES/pyrobbo.po +539 -0
- pyrobbo-1.1.0/robbo/locale/pyrobbo.pot +540 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/menu.py +24 -13
- pyrobbo-1.0.0/.github/workflows/main.yml +0 -31
- pyrobbo-1.0.0/.gitignore +0 -36
- pyrobbo-1.0.0/.idea/encodings.xml +0 -4
- pyrobbo-1.0.0/.idea/fileColors.xml +0 -7
- pyrobbo-1.0.0/.idea/fileTemplates/internal/Python Script.py +0 -12
- pyrobbo-1.0.0/.idea/inspectionProfiles/Project_Default.xml +0 -16
- pyrobbo-1.0.0/.idea/markdown-exported-files.xml +0 -8
- pyrobbo-1.0.0/.idea/markdown-navigator/profiles_settings.xml +0 -3
- pyrobbo-1.0.0/.idea/markdown-navigator.xml +0 -83
- pyrobbo-1.0.0/.idea/misc.xml +0 -10
- pyrobbo-1.0.0/.idea/modules.xml +0 -8
- pyrobbo-1.0.0/.idea/runConfigurations/pyrobbo.xml +0 -24
- pyrobbo-1.0.0/.idea/scopes/robbo.xml +0 -3
- pyrobbo-1.0.0/.idea/scopes/sprites.xml +0 -3
- pyrobbo-1.0.0/.idea/vcs.xml +0 -6
- pyrobbo-1.0.0/.vscode/launch.json +0 -15
- pyrobbo-1.0.0/.vscode/settings.json +0 -3
- pyrobbo-1.0.0/PyRobbo.egg-info/SOURCES.txt +0 -80
- pyrobbo-1.0.0/PyRobbo.egg-info/dependency_links.txt +0 -1
- pyrobbo-1.0.0/PyRobbo.egg-info/entry_points.txt +0 -2
- pyrobbo-1.0.0/PyRobbo.egg-info/requires.txt +0 -3
- pyrobbo-1.0.0/PyRobbo.egg-info/scm_file_list.json +0 -75
- pyrobbo-1.0.0/PyRobbo.egg-info/scm_version.json +0 -8
- pyrobbo-1.0.0/PyRobbo.egg-info/top_level.txt +0 -1
- pyrobbo-1.0.0/README.md +0 -152
- pyrobbo-1.0.0/docs/images/level-editor.png +0 -0
- pyrobbo-1.0.0/docs/images/original-level-01.png +0 -0
- pyrobbo-1.0.0/pyproject.toml +0 -42
- pyrobbo-1.0.0/pyrobbo.py +0 -17
- pyrobbo-1.0.0/robbo/__version__.py +0 -24
- pyrobbo-1.0.0/robbo/level_document.py +0 -180
- pyrobbo-1.0.0/robbo/levels.py +0 -142
- pyrobbo-1.0.0/robbo.ico +0 -0
- pyrobbo-1.0.0/robbo.svg +0 -144
- pyrobbo-1.0.0/setup.cfg +0 -4
- pyrobbo-1.0.0/tests/test_editor.py +0 -79
- pyrobbo-1.0.0/tests/test_level_document.py +0 -92
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/LICENSE +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/board.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/defs.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/game.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/images.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/levels/ala.dat +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/levels/forever.dat +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/levels/original.dat +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/levels/test.dat +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/default/digits.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/default/icons.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/oily/digits.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/oily/icons.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/tronic/ciphers32.bmp +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/tronic/digits.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/skins/tronic/icons.png +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/blaster.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/bomb.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/bullet.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/die.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/door.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/finish.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/key.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/lastscrew.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/life.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/push.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/screw.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/shoot.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/spawn.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/teleport.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds/wallshoot.wav +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sounds.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/__init__.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/guns.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/items.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/mobs.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/robbo.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/static.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/sprites/teleport.py +0 -0
- {pyrobbo-1.0.0 → pyrobbo-1.1.0}/robbo/status.py +0 -0
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PyRobbo
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.1.0
|
|
4
4
|
Summary: Clone of an old 8-bit Atari game Robbo
|
|
5
|
-
Author-email: Maciej Dems <macdems@gmail.com>
|
|
6
5
|
License: GPL3
|
|
7
|
-
|
|
6
|
+
License-File: LICENSE
|
|
8
7
|
Keywords: game,pygame,robbo,atari,clone
|
|
8
|
+
Author: Maciej Dems
|
|
9
|
+
Author-email: macdems@gmail.com
|
|
10
|
+
Requires-Python: >=3
|
|
9
11
|
Classifier: Development Status :: 4 - Beta
|
|
10
12
|
Classifier: Intended Audience :: End Users/Desktop
|
|
11
13
|
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
14
|
Classifier: Natural Language :: English
|
|
15
|
+
Classifier: Natural Language :: Polish
|
|
13
16
|
Classifier: Operating System :: OS Independent
|
|
14
17
|
Classifier: Topic :: Games/Entertainment :: Arcade
|
|
15
18
|
Classifier: Topic :: Games/Entertainment :: Puzzle Games
|
|
16
|
-
Requires-
|
|
19
|
+
Requires-Dist: PyYAML (>=5.3.1)
|
|
20
|
+
Requires-Dist: appdirs (>=1.4.4)
|
|
21
|
+
Requires-Dist: pygame (>=2.0.0)
|
|
22
|
+
Project-URL: Homepage, http://github.com/macdems/pyrobbo
|
|
17
23
|
Description-Content-Type: text/markdown
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
Requires-Dist: pygame>=2.0.0
|
|
20
|
-
Requires-Dist: PyYAML>=5.3.1
|
|
21
|
-
Requires-Dist: appdirs>=1.4.4
|
|
22
|
-
Dynamic: license-file
|
|
23
24
|
|
|
24
25
|
# PyRobbo
|
|
25
26
|
|
|
@@ -53,6 +54,16 @@ pyrobbo --window
|
|
|
53
54
|
The setuptools pin supplies `pkg_resources`, which the game uses to load its
|
|
54
55
|
assets. For published releases, see [PyRobbo on PyPI][pypi].
|
|
55
56
|
|
|
57
|
+
## Language
|
|
58
|
+
|
|
59
|
+
PyRobbo opens in Polish when it detects a Polish language preference. It
|
|
60
|
+
reads `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, and `LANG` in that order. On
|
|
61
|
+
Windows it uses the user's Windows display language if none of those
|
|
62
|
+
variables are set. English is the fallback.
|
|
63
|
+
|
|
64
|
+
To override detection, run `pyrobbo --lang pl` for Polish or
|
|
65
|
+
`pyrobbo --lang en` for English. These commands also work in PowerShell.
|
|
66
|
+
|
|
56
67
|
## Choose a planet
|
|
57
68
|
|
|
58
69
|
For a first game, select **original**, **level 1**, and press **Enter**. On this
|
|
@@ -158,6 +169,23 @@ installed sets and `~/.config/pyrobbo.yml` for settings. To start with a
|
|
|
158
169
|
particular theme or display mode, use a command such as
|
|
159
170
|
`pyrobbo --fullscreen --skin tronic`. Run `pyrobbo --help` for all options.
|
|
160
171
|
|
|
172
|
+
## Maintain translations
|
|
173
|
+
|
|
174
|
+
The gettext template is `robbo/locale/pyrobbo.pot`. Install Babel in the
|
|
175
|
+
development environment with `python -m pip install Babel`, then run the
|
|
176
|
+
following commands from the repository root.
|
|
177
|
+
|
|
178
|
+
```sh
|
|
179
|
+
pybabel extract -k N_ --project PyRobbo -o robbo/locale/pyrobbo.pot robbo
|
|
180
|
+
pybabel update -D pyrobbo -i robbo/locale/pyrobbo.pot -d robbo/locale
|
|
181
|
+
pybabel compile -D pyrobbo -d robbo/locale --statistics
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Edit the `.po` catalog after updating it and before compiling. To add a
|
|
185
|
+
language, use `pybabel init` with the same paths and `-l` followed by the
|
|
186
|
+
language code. Commit the source and compiled catalogs. Installed copies of
|
|
187
|
+
the game read the bundled `.mo` files through Python's standard library.
|
|
188
|
+
|
|
161
189
|
## Credits and license
|
|
162
190
|
|
|
163
191
|
Janusz Pelc wrote the original *Robbo* for the Atari XE/XL, published by
|
|
@@ -173,3 +201,4 @@ version 3 or later.
|
|
|
173
201
|
[level-files]: robbo/levels/
|
|
174
202
|
[gnu-robbo]: https://sourceforge.net/projects/gnurobbo/
|
|
175
203
|
[license]: LICENSE
|
|
204
|
+
|
|
@@ -1,26 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: PyRobbo
|
|
3
|
-
Version: 1.0.0
|
|
4
|
-
Summary: Clone of an old 8-bit Atari game Robbo
|
|
5
|
-
Author-email: Maciej Dems <macdems@gmail.com>
|
|
6
|
-
License: GPL3
|
|
7
|
-
Project-URL: Homepage, http://github.com/macdems/pyrobbo
|
|
8
|
-
Keywords: game,pygame,robbo,atari,clone
|
|
9
|
-
Classifier: Development Status :: 4 - Beta
|
|
10
|
-
Classifier: Intended Audience :: End Users/Desktop
|
|
11
|
-
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
-
Classifier: Natural Language :: English
|
|
13
|
-
Classifier: Operating System :: OS Independent
|
|
14
|
-
Classifier: Topic :: Games/Entertainment :: Arcade
|
|
15
|
-
Classifier: Topic :: Games/Entertainment :: Puzzle Games
|
|
16
|
-
Requires-Python: >=3
|
|
17
|
-
Description-Content-Type: text/markdown
|
|
18
|
-
License-File: LICENSE
|
|
19
|
-
Requires-Dist: pygame>=2.0.0
|
|
20
|
-
Requires-Dist: PyYAML>=5.3.1
|
|
21
|
-
Requires-Dist: appdirs>=1.4.4
|
|
22
|
-
Dynamic: license-file
|
|
23
|
-
|
|
24
1
|
# PyRobbo
|
|
25
2
|
|
|
26
3
|
PyRobbo is a Pygame remake of *Robbo*, the puzzle game for 8-bit Atari
|
|
@@ -53,6 +30,16 @@ pyrobbo --window
|
|
|
53
30
|
The setuptools pin supplies `pkg_resources`, which the game uses to load its
|
|
54
31
|
assets. For published releases, see [PyRobbo on PyPI][pypi].
|
|
55
32
|
|
|
33
|
+
## Language
|
|
34
|
+
|
|
35
|
+
PyRobbo opens in Polish when it detects a Polish language preference. It
|
|
36
|
+
reads `LANGUAGE`, `LC_ALL`, `LC_MESSAGES`, and `LANG` in that order. On
|
|
37
|
+
Windows it uses the user's Windows display language if none of those
|
|
38
|
+
variables are set. English is the fallback.
|
|
39
|
+
|
|
40
|
+
To override detection, run `pyrobbo --lang pl` for Polish or
|
|
41
|
+
`pyrobbo --lang en` for English. These commands also work in PowerShell.
|
|
42
|
+
|
|
56
43
|
## Choose a planet
|
|
57
44
|
|
|
58
45
|
For a first game, select **original**, **level 1**, and press **Enter**. On this
|
|
@@ -158,6 +145,23 @@ installed sets and `~/.config/pyrobbo.yml` for settings. To start with a
|
|
|
158
145
|
particular theme or display mode, use a command such as
|
|
159
146
|
`pyrobbo --fullscreen --skin tronic`. Run `pyrobbo --help` for all options.
|
|
160
147
|
|
|
148
|
+
## Maintain translations
|
|
149
|
+
|
|
150
|
+
The gettext template is `robbo/locale/pyrobbo.pot`. Install Babel in the
|
|
151
|
+
development environment with `python -m pip install Babel`, then run the
|
|
152
|
+
following commands from the repository root.
|
|
153
|
+
|
|
154
|
+
```sh
|
|
155
|
+
pybabel extract -k N_ --project PyRobbo -o robbo/locale/pyrobbo.pot robbo
|
|
156
|
+
pybabel update -D pyrobbo -i robbo/locale/pyrobbo.pot -d robbo/locale
|
|
157
|
+
pybabel compile -D pyrobbo -d robbo/locale --statistics
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Edit the `.po` catalog after updating it and before compiling. To add a
|
|
161
|
+
language, use `pybabel init` with the same paths and `-l` followed by the
|
|
162
|
+
language code. Commit the source and compiled catalogs. Installed copies of
|
|
163
|
+
the game read the bundled `.mo` files through Python's standard library.
|
|
164
|
+
|
|
161
165
|
## Credits and license
|
|
162
166
|
|
|
163
167
|
Janusz Pelc wrote the original *Robbo* for the Atari XE/XL, published by
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "PyRobbo"
|
|
3
|
+
authors = [{ name = "Maciej Dems", email = "macdems@gmail.com" }]
|
|
4
|
+
description = "Clone of an old 8-bit Atari game Robbo"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3"
|
|
7
|
+
license = { text = "GPL3" }
|
|
8
|
+
keywords = ["game", "pygame", "robbo", "atari", "clone"]
|
|
9
|
+
classifiers = [
|
|
10
|
+
"Development Status :: 4 - Beta",
|
|
11
|
+
"Intended Audience :: End Users/Desktop",
|
|
12
|
+
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
|
13
|
+
"Natural Language :: English",
|
|
14
|
+
"Natural Language :: Polish",
|
|
15
|
+
"Operating System :: OS Independent",
|
|
16
|
+
"Topic :: Games/Entertainment :: Arcade",
|
|
17
|
+
"Topic :: Games/Entertainment :: Puzzle Games",
|
|
18
|
+
]
|
|
19
|
+
dependencies = ["pygame>=2.0.0", "PyYAML>=5.3.1", "appdirs>=1.4.4"]
|
|
20
|
+
dynamic = []
|
|
21
|
+
version = "1.1.0"
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Homepage = "http://github.com/macdems/pyrobbo"
|
|
25
|
+
|
|
26
|
+
[build-system]
|
|
27
|
+
requires = [
|
|
28
|
+
"poetry-core>=2.0.0",
|
|
29
|
+
"poetry-dynamic-versioning>=1.0.0,<2.0.0"
|
|
30
|
+
]
|
|
31
|
+
build-backend = "poetry_dynamic_versioning.backend"
|
|
32
|
+
|
|
33
|
+
[project.gui-scripts]
|
|
34
|
+
pyrobbo = "robbo:main"
|
|
35
|
+
|
|
36
|
+
[tool.poetry]
|
|
37
|
+
packages = [{ include = "robbo" }]
|
|
38
|
+
include = [
|
|
39
|
+
{ path = "robbo/sounds/*.wav", format = ["sdist", "wheel"] },
|
|
40
|
+
{ path = "robbo/levels/*.dat", format = ["sdist", "wheel"] },
|
|
41
|
+
{ path = "robbo/skins/*/*.png", format = ["sdist", "wheel"] },
|
|
42
|
+
{ path = "robbo/locale/*/LC_MESSAGES/pyrobbo.mo", format = ["sdist", "wheel"] },
|
|
43
|
+
{ path = "robbo/locale/*/LC_MESSAGES/pyrobbo.po", format = ["sdist"] },
|
|
44
|
+
{ path = "robbo/locale/pyrobbo.pot", format = ["sdist"] },
|
|
45
|
+
{ path = "robbo/robbo.svg", format = ["sdist", "wheel"] },
|
|
46
|
+
{ path = "robbo/robbo.ico", format = ["sdist", "wheel"] },
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[tool.poetry.requires-plugins]
|
|
50
|
+
poetry-dynamic-versioning = { version = ">=1.0.0,<2.0.0", extras = ["plugin"] }
|
|
51
|
+
|
|
52
|
+
[tool.poetry-dynamic-versioning]
|
|
53
|
+
enable = false
|
|
54
|
+
vcs = "git"
|
|
55
|
+
style = "pep440"
|
|
56
|
+
pattern = "default-unprefixed"
|
|
57
|
+
bump = true
|
|
@@ -17,6 +17,7 @@ import yaml
|
|
|
17
17
|
import pygame
|
|
18
18
|
|
|
19
19
|
from .defs import *
|
|
20
|
+
from .i18n import _, select_language
|
|
20
21
|
from .images import available_skins
|
|
21
22
|
from .levels import load_level_sets
|
|
22
23
|
|
|
@@ -29,14 +30,6 @@ screen = None
|
|
|
29
30
|
screen_rect = None
|
|
30
31
|
skin = 'default'
|
|
31
32
|
|
|
32
|
-
parser = argparse.ArgumentParser()
|
|
33
|
-
parser_screen = parser.add_mutually_exclusive_group()
|
|
34
|
-
parser_screen.add_argument('-f', '--fullscreen', help="start in fullscreen", action='store_true')
|
|
35
|
-
parser_screen.add_argument('-w', '--window', help="start in window", action='store_true')
|
|
36
|
-
parser.add_argument('-s', '--skin', help="selected skin set", type=str)
|
|
37
|
-
parser.add_argument("levelset", help="name of the level set to install", nargs='*')
|
|
38
|
-
|
|
39
|
-
|
|
40
33
|
levelset = 'original'
|
|
41
34
|
|
|
42
35
|
levels = {}
|
|
@@ -63,8 +56,26 @@ def quit():
|
|
|
63
56
|
sys.exit(0)
|
|
64
57
|
|
|
65
58
|
|
|
66
|
-
def
|
|
59
|
+
def command_line():
|
|
60
|
+
language_parser = argparse.ArgumentParser(add_help=False)
|
|
61
|
+
language_parser.add_argument('--lang')
|
|
62
|
+
language_args, _remaining = language_parser.parse_known_args()
|
|
63
|
+
select_language(language_args.lang)
|
|
64
|
+
|
|
65
|
+
parser = argparse.ArgumentParser()
|
|
66
|
+
display = parser.add_mutually_exclusive_group()
|
|
67
|
+
display.add_argument('-f', '--fullscreen', help=_('start in fullscreen'), action='store_true')
|
|
68
|
+
display.add_argument('-w', '--window', help=_('start in a window'), action='store_true')
|
|
69
|
+
parser.add_argument('-s', '--skin', help=_('choose a visual theme'))
|
|
70
|
+
parser.add_argument('--lang', metavar='CODE', help=_('choose the UI language (for example, en or pl)'))
|
|
71
|
+
parser.add_argument('levelset', help=_('path to a level set to install'), nargs='*')
|
|
67
72
|
args = parser.parse_args()
|
|
73
|
+
select_language(args.lang)
|
|
74
|
+
return parser, args
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def main():
|
|
78
|
+
parser, args = command_line()
|
|
68
79
|
|
|
69
80
|
try:
|
|
70
81
|
with open(CONFIG_FILE) as config_file:
|
|
@@ -75,9 +86,10 @@ def main():
|
|
|
75
86
|
global skin, levelset, levels, clock, clock_speed, screen, screen_rect
|
|
76
87
|
skins = available_skins()
|
|
77
88
|
if not skins:
|
|
78
|
-
parser.exit(1,
|
|
89
|
+
parser.exit(1, _('No themes found.') + '\n')
|
|
79
90
|
if args.skin is not None and args.skin not in skins:
|
|
80
|
-
parser.error("
|
|
91
|
+
parser.error(_("Unknown theme '{theme}'. Choose from {choices}.").format(
|
|
92
|
+
theme=args.skin, choices=', '.join(skins)))
|
|
81
93
|
skin = args.skin if args.skin is not None else config.get('skin', 'default')
|
|
82
94
|
if skin not in skins:
|
|
83
95
|
skin = 'default' if 'default' in skins else skins[0]
|
|
@@ -120,7 +132,7 @@ def main():
|
|
|
120
132
|
packs = load_level_sets()
|
|
121
133
|
if not packs:
|
|
122
134
|
pygame.quit()
|
|
123
|
-
parser.exit(1,
|
|
135
|
+
parser.exit(1, _('No playable level sets found.') + '\n')
|
|
124
136
|
levelset = config.get('levelset', levelset)
|
|
125
137
|
if levelset not in packs:
|
|
126
138
|
levelset = 'original' if 'original' in packs else next(iter(packs))
|
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
# coding: utf8
|
|
2
|
+
# Copyright (C) 2026 Maciej Dems <maciej.dems@p.lodz.pl>
|
|
3
|
+
#
|
|
4
|
+
# This program is free software; you can redistribute it and/or modify it
|
|
5
|
+
# under the terms of GNU General Public License as published by the
|
|
6
|
+
# Free Software Foundation; either version 3 of the license, or (at your
|
|
7
|
+
# opinion) any later version.
|
|
8
|
+
#
|
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12
|
+
# GNU General Public License for more details.
|
|
2
13
|
from collections import deque
|
|
3
14
|
from copy import deepcopy
|
|
4
15
|
import re
|
|
@@ -7,30 +18,30 @@ import pygame
|
|
|
7
18
|
|
|
8
19
|
import robbo as main
|
|
9
20
|
from . import images
|
|
10
|
-
from .
|
|
11
|
-
from .levels import read_level_source
|
|
21
|
+
from .i18n import _, N_
|
|
22
|
+
from .levels import Level, LevelSet, check_name, read_level_source
|
|
12
23
|
from .menu import BACKGROUND, EDGE, GOLD, MUTED, PANEL, TEXT, preview_tiles
|
|
13
24
|
|
|
14
25
|
CELL = 24
|
|
15
26
|
CANVAS = pygame.Rect(14, 120, 16 * CELL, 12 * CELL)
|
|
16
27
|
PALETTE = {
|
|
17
|
-
'.': 'Empty', 'O': 'Stone wall', 'Q': 'Brick wall', '-': 'Void', 'H': 'Grass', 'R': 'Robbo',
|
|
18
|
-
'!': 'Capsule', 'T': 'Screw', '%': 'Key', 'D': 'Door', "'": 'Ammunition', '#': 'Box',
|
|
19
|
-
'~': 'Sliding box', 'b': 'Bomb', '?': 'Surprise', '&': 'Teleport', 'M': 'Magnet', '}': 'Gun',
|
|
20
|
-
'@': 'Bear', '*': 'Black bear', '^': 'Bird', 'V': 'Butterfly', '=': 'Force field',
|
|
21
|
-
'L': 'Horizontal blast', 'l': 'Vertical blast',
|
|
28
|
+
'.': N_('Empty'), 'O': N_('Stone wall'), 'Q': N_('Brick wall'), '-': N_('Void'), 'H': N_('Grass'), 'R': 'Robbo',
|
|
29
|
+
'!': N_('Capsule'), 'T': N_('Screw'), '%': N_('Key'), 'D': N_('Door'), "'": N_('Ammunition'), '#': N_('Box'),
|
|
30
|
+
'~': N_('Sliding box'), 'b': N_('Bomb'), '?': N_('Surprise'), '&': N_('Teleport'), 'M': N_('Magnet'), '}': N_('Gun'),
|
|
31
|
+
'@': N_('Bear'), '*': N_('Black bear'), '^': N_('Bird'), 'V': N_('Butterfly'), '=': N_('Force field'),
|
|
32
|
+
'L': N_('Horizontal blast'), 'l': N_('Vertical blast'),
|
|
22
33
|
}
|
|
23
|
-
DIRECTIONS = ('East', 'South', 'West', 'North')
|
|
24
|
-
HORIZONTAL = ('East', 'West')
|
|
25
|
-
VERTICAL = ('South', 'North')
|
|
26
|
-
SWITCH = ('Off', 'On')
|
|
34
|
+
DIRECTIONS = (N_('East'), N_('South'), N_('West'), N_('North'))
|
|
35
|
+
HORIZONTAL = (N_('East'), N_('West'))
|
|
36
|
+
VERTICAL = (N_('South'), N_('North'))
|
|
37
|
+
SWITCH = (N_('Off'), N_('On'))
|
|
27
38
|
OPTIONS = {
|
|
28
|
-
'@': [('Facing', DIRECTIONS)], '*': [('Facing', DIRECTIONS)],
|
|
29
|
-
'^': [('Movement', DIRECTIONS), ('Fire direction', DIRECTIONS), ('Fires', SWITCH)],
|
|
30
|
-
'}': [('Facing', DIRECTIONS), ('Movement', DIRECTIONS), ('Shot', ('Bullet', 'Laser', 'Blaster')),
|
|
31
|
-
('Moves', SWITCH), ('Rotates', SWITCH), ('Random rotation', SWITCH)],
|
|
39
|
+
'@': [(N_('Facing'), DIRECTIONS)], '*': [(N_('Facing'), DIRECTIONS)],
|
|
40
|
+
'^': [(N_('Movement'), DIRECTIONS), (N_('Fire direction'), DIRECTIONS), (N_('Fires'), SWITCH)],
|
|
41
|
+
'}': [(N_('Facing'), DIRECTIONS), (N_('Movement'), DIRECTIONS), (N_('Shot'), (N_('Bullet'), N_('Laser'), N_('Blaster'))),
|
|
42
|
+
(N_('Moves'), SWITCH), (N_('Rotates'), SWITCH), (N_('Random rotation'), SWITCH)],
|
|
32
43
|
'M': [('Facing', HORIZONTAL)], '=': [('Movement', HORIZONTAL)],
|
|
33
|
-
'L': [('Movement', HORIZONTAL)], 'l': [('Movement', VERTICAL)], '&': [('Link group', ())],
|
|
44
|
+
'L': [('Movement', HORIZONTAL)], 'l': [('Movement', VERTICAL)], '&': [(N_('Link group'), ())],
|
|
34
45
|
}
|
|
35
46
|
|
|
36
47
|
|
|
@@ -40,10 +51,11 @@ def field(label, value, choices=()):
|
|
|
40
51
|
|
|
41
52
|
class Dialog:
|
|
42
53
|
"""A small form. Choice fields cycle, text fields accept pygame text input."""
|
|
43
|
-
def __init__(self, title, fields, submit, accept, hint=''):
|
|
54
|
+
def __init__(self, title, fields, submit, accept, hint='', translate_choices=False):
|
|
44
55
|
self.title, self.fields, self.submit, self.accept = title, fields, submit, accept
|
|
45
56
|
self.values = [value for _, value, _ in fields]
|
|
46
57
|
self.hint = hint
|
|
58
|
+
self.translate_choices = translate_choices
|
|
47
59
|
self.focus(0)
|
|
48
60
|
self.error = ''
|
|
49
61
|
height = 138 + 41 * len(fields)
|
|
@@ -64,11 +76,12 @@ class Dialog:
|
|
|
64
76
|
pygame.draw.rect(ui.page, PANEL, self.box)
|
|
65
77
|
pygame.draw.rect(ui.page, EDGE, self.box, 1)
|
|
66
78
|
ui.text(self.title, (self.box.x + 18, self.box.y + 12), font=ui.heading)
|
|
67
|
-
for i, (label,
|
|
79
|
+
for i, (label, _initial, choices) in enumerate(self.fields):
|
|
68
80
|
rect = self.inputs[i]
|
|
69
81
|
ui.text(label, (self.box.x + 18, rect.y + 7), limit=201)
|
|
70
82
|
value = self.values[i]
|
|
71
83
|
if choices:
|
|
84
|
+
value = _(value) if self.translate_choices else value
|
|
72
85
|
ui.button(rect, '< ' + value + ' >', active=i == self.active)
|
|
73
86
|
else:
|
|
74
87
|
pygame.draw.rect(ui.page, BACKGROUND, rect)
|
|
@@ -88,7 +101,7 @@ class Dialog:
|
|
|
88
101
|
ui.text(value, (rect.x + 7, rect.y + 8), limit=rect.w-14)
|
|
89
102
|
ui.text(self.error or self.hint, (self.box.x + 18, self.box.bottom - 69),
|
|
90
103
|
GOLD if self.error else MUTED, limit=self.box.width - 36)
|
|
91
|
-
ui.button(self.cancel, 'Cancel')
|
|
104
|
+
ui.button(self.cancel, _('Cancel'))
|
|
92
105
|
ui.button(self.ok, self.accept, active=True)
|
|
93
106
|
|
|
94
107
|
def cycle(self, step):
|
|
@@ -176,21 +189,21 @@ class LevelEditor:
|
|
|
176
189
|
self.swatches = {s: pygame.Rect(414 + i % 6 * 35, 143 + i // 6 * 32, 32, 30)
|
|
177
190
|
for i, s in enumerate(PALETTE)}
|
|
178
191
|
self.buttons = [
|
|
179
|
-
((
|
|
180
|
-
((
|
|
181
|
-
((
|
|
182
|
-
((530, 12, 96, 32), 'Done', self.done),
|
|
192
|
+
((218, 12, 98, 32), N_('New set'), self.new_set),
|
|
193
|
+
((322, 12, 98, 32), N_('Save as'), self.save_as),
|
|
194
|
+
((426, 12, 98, 32), N_('Save'), self.save),
|
|
195
|
+
((530, 12, 96, 32), N_('Done'), self.done),
|
|
183
196
|
((14, 69, 185, 32), '', self.open_set),
|
|
184
197
|
((215, 69, 32, 32), '<', lambda: self.navigate(-1)),
|
|
185
198
|
((348, 69, 32, 32), '>', lambda: self.navigate(1)),
|
|
186
|
-
((398, 69, 76, 32), '+ Level', lambda: self.add(False)),
|
|
187
|
-
((480, 69, 63, 32), 'Copy', lambda: self.add(True)),
|
|
188
|
-
((549, 69, 77, 32), 'Remove', self.remove),
|
|
189
|
-
((414, 333, 212, 28), 'Tile options', self.tile_options),
|
|
190
|
-
((414, 371, 212, 30), 'Board settings', self.settings),
|
|
191
|
-
((414, 410, 212, 28), 'Undo', self.undo),
|
|
199
|
+
((398, 69, 76, 32), N_('+ Level'), lambda: self.add(False)),
|
|
200
|
+
((480, 69, 63, 32), N_('Copy'), lambda: self.add(True)),
|
|
201
|
+
((549, 69, 77, 32), N_('Remove'), self.remove),
|
|
202
|
+
((414, 333, 212, 28), N_('Tile options'), self.tile_options),
|
|
203
|
+
((414, 371, 212, 30), N_('Board settings'), self.settings),
|
|
204
|
+
((414, 410, 212, 28), N_('Undo'), self.undo),
|
|
192
205
|
]
|
|
193
|
-
for i, (label, delta) in enumerate((('<', (-1, 0)), ('>', (1, 0)), ('Up', (0, -2)), ('Down', (0, 2)))):
|
|
206
|
+
for i, (label, delta) in enumerate((('<', (-1, 0)), ('>', (1, 0)), (N_('Up'), (0, -2)), (N_('Down'), (0, 2)))):
|
|
194
207
|
self.buttons.append(((14 + i * 50, 414, 48, 26), label, lambda d=delta: self.pan(*d)))
|
|
195
208
|
self.load(LevelSet(name, read_level_source(name)), index)
|
|
196
209
|
|
|
@@ -239,18 +252,18 @@ class LevelEditor:
|
|
|
239
252
|
|
|
240
253
|
def draw(self):
|
|
241
254
|
self.page.fill(BACKGROUND)
|
|
242
|
-
self.text('Level editor', (14, 14), font=self.heading)
|
|
243
|
-
self.text('LEVEL SET' + (' * unsaved' if self.dirty else ''), (14, 51), GOLD if self.dirty else MUTED)
|
|
244
|
-
self.text('LEVEL', (255, 51), MUTED)
|
|
255
|
+
self.text(_('Level editor'), (14, 14), font=self.heading, limit=196)
|
|
256
|
+
self.text(_('LEVEL SET') + (' * ' + _('unsaved') if self.dirty else ''), (14, 51), GOLD if self.dirty else MUTED)
|
|
257
|
+
self.text(_('LEVEL'), (255, 51), MUTED)
|
|
245
258
|
number = '{} / {}'.format(self.index + 1, len(self.doc.levels))
|
|
246
259
|
image = self.font.render(number, True, TEXT)
|
|
247
260
|
self.page.blit(image, image.get_rect(center=(297, 85)))
|
|
248
261
|
pygame.draw.line(self.page, EDGE, (14, 110), (626, 110))
|
|
249
|
-
for rect, label,
|
|
262
|
+
for rect, label, _callback in self.buttons:
|
|
250
263
|
enabled = not ((label == 'Tile options' and self.brush not in OPTIONS)
|
|
251
264
|
or (label == 'Undo' and not self.history)
|
|
252
265
|
or (label == 'Remove' and len(self.doc.levels) == 1))
|
|
253
|
-
self.button(rect, label
|
|
266
|
+
self.button(rect, _(label) if label else self.doc.name + ' >', label == 'Save' and self.dirty, enabled)
|
|
254
267
|
board = self.level
|
|
255
268
|
width, height = board.size
|
|
256
269
|
ox, oy = self.offset
|
|
@@ -268,8 +281,9 @@ class LevelEditor:
|
|
|
268
281
|
pygame.draw.rect(self.page, PANEL, rect, 1)
|
|
269
282
|
if self.hover == (x, y):
|
|
270
283
|
pygame.draw.rect(self.page, GOLD, rect, 2)
|
|
271
|
-
self.text('Rows {}–{} of {}'.format(
|
|
272
|
-
|
|
284
|
+
self.text(_('Rows {first}–{last} of {total}').format(
|
|
285
|
+
first=oy + 1, last=min(height, oy + CANVAS.h // CELL), total=height), (220, 420), MUTED)
|
|
286
|
+
self.text(_('TILES'), (414, 119), MUTED)
|
|
273
287
|
for symbol, rect in self.swatches.items():
|
|
274
288
|
pygame.draw.rect(self.page, (53, 63, 74), rect)
|
|
275
289
|
self.icon(symbol, self.args if symbol == self.brush else (), rect)
|
|
@@ -277,9 +291,9 @@ class LevelEditor:
|
|
|
277
291
|
pygame.draw.line(self.page, MUTED, rect.bottomleft + pygame.Vector2(6, -6),
|
|
278
292
|
rect.topright + pygame.Vector2(-6, 6), 1)
|
|
279
293
|
pygame.draw.rect(self.page, GOLD if symbol == self.brush else EDGE, rect, 2 if symbol == self.brush else 1)
|
|
280
|
-
self.text(PALETTE.get(self.brush, self.brush), (414, 309), GOLD)
|
|
294
|
+
self.text(_(PALETTE.get(self.brush, self.brush)), (414, 309), GOLD)
|
|
281
295
|
pygame.draw.line(self.page, EDGE, (14, 449), (626, 449))
|
|
282
|
-
self.text(self.message or 'Left drag to paint Right drag to erase Middle click to pick a tile',
|
|
296
|
+
self.text(self.message or _('Left drag to paint Right drag to erase Middle click to pick a tile'),
|
|
283
297
|
(14, 458), GOLD if self.message else MUTED, limit=612)
|
|
284
298
|
if self.dialog:
|
|
285
299
|
self.dialog.draw(self)
|
|
@@ -287,9 +301,9 @@ class LevelEditor:
|
|
|
287
301
|
self.screen.blit(pygame.transform.scale(self.page, self.viewport.size), self.viewport)
|
|
288
302
|
pygame.display.flip()
|
|
289
303
|
|
|
290
|
-
def form(self, title, fields, submit, accept=
|
|
304
|
+
def form(self, title, fields, submit, accept=None, hint='', *, translate_choices=False):
|
|
291
305
|
self.stroke = None
|
|
292
|
-
self.dialog = Dialog(title, fields, submit, accept, hint)
|
|
306
|
+
self.dialog = Dialog(title, fields, submit, accept or _('Apply'), hint, translate_choices)
|
|
293
307
|
pygame.key.start_text_input()
|
|
294
308
|
|
|
295
309
|
def close_dialog(self):
|
|
@@ -298,7 +312,7 @@ class LevelEditor:
|
|
|
298
312
|
|
|
299
313
|
def guard(self, action):
|
|
300
314
|
if self.dirty:
|
|
301
|
-
self.form('Discard unsaved changes?', [], action, 'Discard', 'Cancel to return to your work.')
|
|
315
|
+
self.form(_('Discard unsaved changes?'), [], action, _('Discard'), _('Cancel to return to your work.'))
|
|
302
316
|
else:
|
|
303
317
|
action()
|
|
304
318
|
|
|
@@ -312,9 +326,9 @@ class LevelEditor:
|
|
|
312
326
|
name = name.strip()
|
|
313
327
|
check_name(name)
|
|
314
328
|
if name in self.packs:
|
|
315
|
-
raise ValueError('A set with that name already exists.')
|
|
329
|
+
raise ValueError(_('A set with that name already exists.'))
|
|
316
330
|
self.load(LevelSet(name), 0)
|
|
317
|
-
self.guard(lambda: self.form('New level set', [field('Set name', '')], create, 'Create'))
|
|
331
|
+
self.guard(lambda: self.form(_('New level set'), [field(_('Set name'), '')], create, _('Create')))
|
|
318
332
|
|
|
319
333
|
def open_set(self):
|
|
320
334
|
names = sorted(self.packs)
|
|
@@ -322,15 +336,15 @@ class LevelEditor:
|
|
|
322
336
|
self.load(LevelSet(name, read_level_source(name)), 0)
|
|
323
337
|
self.last_saved = name, 0
|
|
324
338
|
name = self.doc.name if self.doc.name in names else names[0]
|
|
325
|
-
self.guard(lambda: self.form('Open level set', [field('Set', name, names)], select, 'Open'))
|
|
339
|
+
self.guard(lambda: self.form(_('Open level set'), [field(_('Set'), name, names)], select, _('Open')))
|
|
326
340
|
|
|
327
341
|
def save_as(self):
|
|
328
342
|
def save_new(name):
|
|
329
343
|
name = name.strip()
|
|
330
344
|
if name in self.packs:
|
|
331
|
-
raise ValueError('Choose a new set name.')
|
|
345
|
+
raise ValueError(_('Choose a new set name.'))
|
|
332
346
|
self.save(name)
|
|
333
|
-
self.form('Save set as', [field('New set name', self.doc.name + '-copy')], save_new, 'Save copy')
|
|
347
|
+
self.form(_('Save set as'), [field(_('New set name'), self.doc.name + '-copy')], save_new, _('Save copy'))
|
|
334
348
|
|
|
335
349
|
def save(self, name=None):
|
|
336
350
|
name = self.doc.name if name is None else name
|
|
@@ -338,7 +352,7 @@ class LevelEditor:
|
|
|
338
352
|
self.last_saved = name, self.index
|
|
339
353
|
self.history.clear()
|
|
340
354
|
self.dirty = False
|
|
341
|
-
self.message = 'Saved {}.dat'.format(name)
|
|
355
|
+
self.message = _('Saved {name}.dat').format(name=name)
|
|
342
356
|
|
|
343
357
|
def remember(self):
|
|
344
358
|
self.history.append((self.doc.levels.copy(), self.index, self.dirty))
|
|
@@ -349,7 +363,7 @@ class LevelEditor:
|
|
|
349
363
|
if self.history:
|
|
350
364
|
self.doc.levels, self.index, self.dirty = self.history.pop()
|
|
351
365
|
self.pan(0, 0)
|
|
352
|
-
self.message = 'Undid the last edit.'
|
|
366
|
+
self.message = _('Undid the last edit.')
|
|
353
367
|
|
|
354
368
|
def navigate(self, step):
|
|
355
369
|
self.index = (self.index + step) % len(self.doc.levels)
|
|
@@ -370,24 +384,27 @@ class LevelEditor:
|
|
|
370
384
|
del self.doc.levels[self.index]
|
|
371
385
|
self.index = min(self.index, len(self.doc.levels) - 1)
|
|
372
386
|
self.offset = [0, 0]
|
|
373
|
-
self.form('Remove level {}?'.format(self.index + 1), [], delete, 'Remove', 'Undo restores this board.')
|
|
387
|
+
self.form(_('Remove level {number}?').format(number=self.index + 1), [], delete, _('Remove'), _('Undo restores this board.'))
|
|
374
388
|
|
|
375
389
|
def settings(self):
|
|
376
390
|
board = self.level
|
|
377
391
|
width, height = board.size
|
|
378
392
|
def apply(position, w, h, colour, author, screws):
|
|
379
|
-
|
|
393
|
+
try:
|
|
394
|
+
position, w, h = int(position), int(w), int(h)
|
|
395
|
+
except ValueError as err:
|
|
396
|
+
raise ValueError(_('Position, width and height must be whole numbers.')) from err
|
|
380
397
|
if not 1 <= position <= len(self.doc.levels):
|
|
381
|
-
raise ValueError('Enter a level number within this set.')
|
|
398
|
+
raise ValueError(_('Enter a level number within this set.'))
|
|
382
399
|
if min(w, h) < 1 or w*h > max(65536, width*height):
|
|
383
|
-
raise ValueError('Use positive dimensions up to 65,536 tiles.')
|
|
400
|
+
raise ValueError(_('Use positive dimensions up to 65,536 tiles.'))
|
|
384
401
|
colour = colour.strip().lstrip('#')
|
|
385
402
|
if not re.fullmatch('[a-fA-F0-9]{6}', colour):
|
|
386
|
-
raise ValueError('Enter a six-digit hex colour.')
|
|
403
|
+
raise ValueError(_('Enter a six-digit hex colour.'))
|
|
387
404
|
if screws and not screws.isdecimal():
|
|
388
|
-
raise ValueError('Enter a screw count or leave it blank.')
|
|
405
|
+
raise ValueError(_('Enter a screw count or leave it blank.'))
|
|
389
406
|
if author.startswith(('[', '#')) or '\n' in author or '\r' in author:
|
|
390
|
-
raise ValueError('Use a single line for the author. Avoid initial [ or #.')
|
|
407
|
+
raise ValueError(_('Use a single line for the author. Avoid initial [ or #.'))
|
|
391
408
|
self.remember()
|
|
392
409
|
board = deepcopy(self.level)
|
|
393
410
|
if (w, h) != (width, height):
|
|
@@ -398,9 +415,15 @@ class LevelEditor:
|
|
|
398
415
|
self.index = position - 1
|
|
399
416
|
self.doc.levels.insert(self.index, board)
|
|
400
417
|
self.pan(0, 0)
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
418
|
+
fields = [
|
|
419
|
+
field(_('Position in set'), self.index + 1),
|
|
420
|
+
field(_('Width'), width),
|
|
421
|
+
field(_('Height'), height),
|
|
422
|
+
field(_('Colour (RGB hex)'), board.colour),
|
|
423
|
+
field(_('Author'), board.author),
|
|
424
|
+
field(_('Screws (blank = all)'), board.screws if board.screws is not None else ''),
|
|
425
|
+
]
|
|
426
|
+
self.form(_('Board settings'), fields, apply, hint=_('The game shows up to 16 columns.'))
|
|
404
427
|
|
|
405
428
|
def select_brush(self, symbol, args=None):
|
|
406
429
|
self.brush = symbol
|
|
@@ -423,7 +446,7 @@ class LevelEditor:
|
|
|
423
446
|
value = DIRECTIONS[value]
|
|
424
447
|
elif values:
|
|
425
448
|
value = values[value]
|
|
426
|
-
fields.append(field(label, value, values))
|
|
449
|
+
fields.append(field(_(label), value, values))
|
|
427
450
|
def apply(*values):
|
|
428
451
|
args = []
|
|
429
452
|
for value, (_, options) in zip(values, OPTIONS[self.brush]):
|
|
@@ -434,9 +457,10 @@ class LevelEditor:
|
|
|
434
457
|
elif re.fullmatch(r'[A-Za-z]|[0-9]+', value):
|
|
435
458
|
args.append(int(value) if value.isdecimal() else value)
|
|
436
459
|
else:
|
|
437
|
-
raise ValueError('Use a letter or a number for the link group.')
|
|
460
|
+
raise ValueError(_('Use a letter or a number for the link group.'))
|
|
438
461
|
self.args = tuple(args)
|
|
439
|
-
self.form(PALETTE[self.brush]
|
|
462
|
+
self.form(_('Tile options: {tile}').format(tile=_(PALETTE[self.brush])), fields, apply,
|
|
463
|
+
hint=_('Paint to apply these settings to a tile.'), translate_choices=True)
|
|
440
464
|
|
|
441
465
|
def pan(self, dx, dy):
|
|
442
466
|
for i, (step, size, visible) in enumerate(zip((dx, dy), self.level.size, (CANVAS.w//CELL, CANVAS.h//CELL))):
|
|
@@ -491,7 +515,7 @@ class LevelEditor:
|
|
|
491
515
|
args = self.level.extra.get(symbol, {}).get(point, ())
|
|
492
516
|
self.select_brush(symbol, args[:1] if symbol == '&' else args)
|
|
493
517
|
elif event.button == 1:
|
|
494
|
-
for rect,
|
|
518
|
+
for rect, _label, callback in self.buttons:
|
|
495
519
|
if pygame.Rect(rect).collidepoint(pos):
|
|
496
520
|
callback()
|
|
497
521
|
return
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Load the UI catalog for the requested or detected language."""
|
|
2
|
+
import gettext
|
|
3
|
+
import locale
|
|
4
|
+
import os
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
LOCALE_DIR = Path(__file__).with_name('locale')
|
|
8
|
+
_translation = gettext.NullTranslations()
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def preferred_languages():
|
|
12
|
+
for variable in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
|
|
13
|
+
value = os.environ.get(variable)
|
|
14
|
+
if value:
|
|
15
|
+
return value.split(':')
|
|
16
|
+
if os.name == 'nt':
|
|
17
|
+
import ctypes
|
|
18
|
+
|
|
19
|
+
language_id = ctypes.windll.kernel32.GetUserDefaultUILanguage()
|
|
20
|
+
language = locale.windows_locale.get(language_id)
|
|
21
|
+
if language:
|
|
22
|
+
return [language]
|
|
23
|
+
return ['en']
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def select_language(language=None):
|
|
27
|
+
global _translation
|
|
28
|
+
languages = []
|
|
29
|
+
for code in [language] if language else preferred_languages():
|
|
30
|
+
code = code.replace('-', '_')
|
|
31
|
+
base = code.split('.', 1)[0].split('_', 1)[0].lower()
|
|
32
|
+
if base in ('c', 'posix', 'en'):
|
|
33
|
+
break # English is the source language and needs no catalog.
|
|
34
|
+
languages.append(code)
|
|
35
|
+
_translation = gettext.translation('pyrobbo', LOCALE_DIR, languages, fallback=True)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def _(message):
|
|
39
|
+
return _translation.gettext(message)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def N_(message):
|
|
43
|
+
"""Mark strings for extraction when they are translated at render time."""
|
|
44
|
+
return message
|