mima-engine 0.1.1__py3-none-any.whl → 0.1.3__py3-none-any.whl
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.
Potentially problematic release.
This version of mima-engine might be problematic. Click here for more details.
- mima/__init__.py +1 -1
- mima/backend/pygame_assets.py +15 -22
- mima/engine.py +8 -3
- mima/scene_engine.py +11 -4
- mima/util/runtime_config.py +28 -31
- {mima_engine-0.1.1.dist-info → mima_engine-0.1.3.dist-info}/METADATA +1 -1
- {mima_engine-0.1.1.dist-info → mima_engine-0.1.3.dist-info}/RECORD +9 -9
- {mima_engine-0.1.1.dist-info → mima_engine-0.1.3.dist-info}/WHEEL +0 -0
- {mima_engine-0.1.1.dist-info → mima_engine-0.1.3.dist-info}/top_level.txt +0 -0
mima/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.3"
|
mima/backend/pygame_assets.py
CHANGED
|
@@ -7,15 +7,11 @@ from typing import TYPE_CHECKING, Dict, Optional
|
|
|
7
7
|
|
|
8
8
|
import pygame
|
|
9
9
|
|
|
10
|
-
# from ...maps.object_loader import ObjectLoader
|
|
11
10
|
from ..maps.tiled.tiled_map import TiledMap
|
|
12
11
|
from ..maps.tiled.tiled_template import TiledTemplate
|
|
13
12
|
from ..maps.tiled.tiled_tileset import TiledTileset
|
|
14
|
-
from ..util.colors import
|
|
15
|
-
WHITE,
|
|
16
|
-
) # GB_DARK,; GB_LIGHT,; GB_MEDIUM_DARK,; GB_MEDIUM_LIGHT,; TEXT_COLOR,
|
|
13
|
+
from ..util.colors import WHITE
|
|
17
14
|
|
|
18
|
-
# from .game.tilemap import Tilemap
|
|
19
15
|
if TYPE_CHECKING:
|
|
20
16
|
from ..util import RuntimeConfig
|
|
21
17
|
|
|
@@ -32,7 +28,6 @@ class PygameAssets:
|
|
|
32
28
|
self._music: Dict[str, str] = {}
|
|
33
29
|
self._sound: Dict[str, str] = {}
|
|
34
30
|
self._csvs: Dict[str, str] = {}
|
|
35
|
-
# self._items: Dict[str, Item] = {}
|
|
36
31
|
self._assets_to_load: Dict[str, str] = {}
|
|
37
32
|
self._assets_to_preload: Dict[str, str] = {}
|
|
38
33
|
self._paths: Dict[str, str] = {}
|
|
@@ -326,20 +321,18 @@ class PygameAssets:
|
|
|
326
321
|
return pygame.image.load(filename).convert_alpha()
|
|
327
322
|
else:
|
|
328
323
|
image = pygame.image.load(filename).convert_alpha()
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
# var.replace(GB_LIGHT.getRGBA(), self.rtc.colors["gb_light"].getRGBA())
|
|
344
|
-
# del var
|
|
324
|
+
var = pygame.PixelArray(image)
|
|
325
|
+
|
|
326
|
+
new_colors = {
|
|
327
|
+
name: color
|
|
328
|
+
for name, color in self.rtc.colors.items()
|
|
329
|
+
if f"{name}_default" in self.rtc.colors
|
|
330
|
+
}
|
|
331
|
+
for name, new_color in new_colors.items():
|
|
332
|
+
var.replace(
|
|
333
|
+
self.rtc.colors[f"{name}_default"].getRGBA(),
|
|
334
|
+
new_color.getRGBA(),
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
del var
|
|
345
338
|
return image
|
mima/engine.py
CHANGED
|
@@ -16,8 +16,8 @@ from .objects.dynamic import Dynamic
|
|
|
16
16
|
from .objects.sprite import Sprite
|
|
17
17
|
from .scripts import Command, ScriptProcessor
|
|
18
18
|
from .states.quest import Quest
|
|
19
|
-
from .types.mode import Mode
|
|
20
19
|
from .types.gate_color import GateColor
|
|
20
|
+
from .types.mode import Mode
|
|
21
21
|
from .usables.item import Item
|
|
22
22
|
from .util import RuntimeConfig
|
|
23
23
|
from .util.logging import install_trace_logger
|
|
@@ -29,9 +29,14 @@ LOG = logging.getLogger(__name__)
|
|
|
29
29
|
|
|
30
30
|
class MimaEngine(ABC):
|
|
31
31
|
def __init__(
|
|
32
|
-
self,
|
|
32
|
+
self,
|
|
33
|
+
init_file: str,
|
|
34
|
+
config_path: str,
|
|
35
|
+
default_config: Dict[str, Any],
|
|
36
|
+
platform: str = "PC",
|
|
37
|
+
caption: str = "MimaEngine",
|
|
33
38
|
):
|
|
34
|
-
self.rtc = RuntimeConfig()
|
|
39
|
+
self.rtc = RuntimeConfig(config_path, default_config)
|
|
35
40
|
install_trace_logger()
|
|
36
41
|
|
|
37
42
|
self.backend: PygameBackend = PygameBackend(
|
mima/scene_engine.py
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
from typing import TYPE_CHECKING, Dict, List, Optional, Union
|
|
1
|
+
from typing import TYPE_CHECKING, Dict, List, Optional, Union, Any
|
|
2
2
|
|
|
3
3
|
from .engine import MimaEngine
|
|
4
4
|
from .states.game_state import GameState
|
|
5
5
|
from .types.keys import Key as K
|
|
6
|
+
from .types.mode import Mode
|
|
6
7
|
from .types.nature import Nature
|
|
7
8
|
from .view.scene import Scene
|
|
8
|
-
from .types.mode import Mode
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
class MimaSceneEngine(MimaEngine):
|
|
12
12
|
def __init__(
|
|
13
|
-
self,
|
|
13
|
+
self,
|
|
14
|
+
init_file: str,
|
|
15
|
+
config_path: str,
|
|
16
|
+
default_config: Dict[str, Any],
|
|
17
|
+
platform: str = "PC",
|
|
18
|
+
caption: str = "MimaEngine",
|
|
14
19
|
):
|
|
15
|
-
super().__init__(
|
|
20
|
+
super().__init__(
|
|
21
|
+
init_file, config_path, default_config, platform, caption
|
|
22
|
+
)
|
|
16
23
|
|
|
17
24
|
self.scene_stack: List[str] = []
|
|
18
25
|
self._scenes: Dict[str, Scene] = {}
|
mima/util/runtime_config.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import configparser
|
|
2
2
|
import os
|
|
3
3
|
from copy import deepcopy
|
|
4
|
-
from typing import Any, Dict
|
|
4
|
+
from typing import Any, Dict, Optional
|
|
5
5
|
|
|
6
6
|
from ..types.keys import Key as K
|
|
7
7
|
from .colors import Color
|
|
@@ -22,19 +22,22 @@ DEFAULT_CONFIG = {
|
|
|
22
22
|
"START": "i",
|
|
23
23
|
"SELECT": "t",
|
|
24
24
|
},
|
|
25
|
-
"colors": {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"gb_medium_light": "186,191,181",
|
|
29
|
-
"gb_light": "255,255,241",
|
|
30
|
-
},
|
|
31
|
-
"flags": {"use_color": "false"},
|
|
25
|
+
"colors": {},
|
|
26
|
+
"color_remaps": {},
|
|
27
|
+
"flags": {},
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
|
|
35
31
|
class RuntimeConfig:
|
|
36
|
-
def __init__(
|
|
37
|
-
self
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
config_path: str = "",
|
|
35
|
+
default_config: Optional[Dict[str, Any]] = None,
|
|
36
|
+
):
|
|
37
|
+
if default_config is None:
|
|
38
|
+
default_config = DEFAULT_CONFIG
|
|
39
|
+
|
|
40
|
+
self._loaded: Dict[str, Any] = deepcopy(default_config)
|
|
38
41
|
self._converted: Dict[str, Any] = {}
|
|
39
42
|
|
|
40
43
|
if not config_path:
|
|
@@ -62,16 +65,14 @@ class RuntimeConfig:
|
|
|
62
65
|
vals = mapping.strip().split(",")
|
|
63
66
|
self._loaded["keymap"][key.upper()] = vals
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
self._loaded["colors"]
|
|
67
|
-
"
|
|
68
|
-
|
|
69
|
-
self._loaded["colors"]
|
|
70
|
-
"gb_medium_light"
|
|
71
|
-
]
|
|
72
|
-
self._loaded["colors"]["gb_light"] = config["colors"]["gb_light"]
|
|
68
|
+
default_colors = {}
|
|
69
|
+
for color_name, color in self._loaded["colors"].items():
|
|
70
|
+
default_colors[f"{color_name}_default"] = color
|
|
71
|
+
self._loaded["colors"][color_name] = config["colors"][color_name]
|
|
72
|
+
self._loaded["colors"].update(default_colors)
|
|
73
73
|
|
|
74
|
-
self._loaded["flags"]
|
|
74
|
+
for flag in self._loaded["flags"]:
|
|
75
|
+
self._loaded["flags"][flag] = config["flags"][flag]
|
|
75
76
|
|
|
76
77
|
def _write_config(self, config: configparser.ConfigParser):
|
|
77
78
|
config["keymap"] = {}
|
|
@@ -80,16 +81,13 @@ class RuntimeConfig:
|
|
|
80
81
|
for key, mapping in self._loaded["keymap"].items():
|
|
81
82
|
config["keymap"][key.lower()] = mapping
|
|
82
83
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
config["colors"]["gb_medium_light"] = self._loaded["colors"][
|
|
88
|
-
"gb_medium_light"
|
|
89
|
-
]
|
|
90
|
-
config["colors"]["gb_light"] = self._loaded["colors"]["gb_light"]
|
|
84
|
+
for color_name, color in self._loaded["colors"].items():
|
|
85
|
+
if color_name.endswith("_default"):
|
|
86
|
+
continue
|
|
87
|
+
config["colors"][color_name] = color
|
|
91
88
|
|
|
92
|
-
|
|
89
|
+
for flag_name, flag in self._loaded["flags"].items():
|
|
90
|
+
config["flags"][flag_name] = flag
|
|
93
91
|
|
|
94
92
|
with open(self._config_path, "w") as cfg_file:
|
|
95
93
|
config.write(cfg_file)
|
|
@@ -126,8 +124,7 @@ class RuntimeConfig:
|
|
|
126
124
|
return self._converted["flags"]
|
|
127
125
|
else:
|
|
128
126
|
self._converted["flags"] = {}
|
|
129
|
-
self.
|
|
130
|
-
self.
|
|
131
|
-
)
|
|
127
|
+
for flag, value in self._loaded["flags"].items():
|
|
128
|
+
self._converted["flags"][flag] = strtobool(value)
|
|
132
129
|
|
|
133
130
|
return self._converted["flags"]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
mima/__init__.py,sha256=
|
|
1
|
+
mima/__init__.py,sha256=XEqb2aiIn8fzGE68Mph4ck1FtQqsR_am0wRWvrYPffQ,22
|
|
2
2
|
mima/collision.py,sha256=roHN_U2H5dhhKwvhgBQLArjodhbNlt3fV9KjPs7nGzw,6872
|
|
3
|
-
mima/engine.py,sha256=
|
|
4
|
-
mima/scene_engine.py,sha256=
|
|
3
|
+
mima/engine.py,sha256=t3nbBNfbLeDnIcv7qlKoU0E4zhH58m7YOOfpPtoeUWw,6106
|
|
4
|
+
mima/scene_engine.py,sha256=CZOMetEQH2UlT39siaco8EVtOHEnv1JvMlqXF7FMYjs,2678
|
|
5
5
|
mima/backend/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
6
|
-
mima/backend/pygame_assets.py,sha256=
|
|
6
|
+
mima/backend/pygame_assets.py,sha256=9UMNoZ41C8JuMjyI6TXDZwMH6mYMW0Xij0RdkQzl750,11793
|
|
7
7
|
mima/backend/pygame_audio.py,sha256=HsEF321PecqE6DuFy92HiV5YWsQxAtnid_4Tm-VezGQ,2320
|
|
8
8
|
mima/backend/pygame_backend.py,sha256=vMBVEMCQBkELyxRKzH2OwNxwJUxc3vLhhrQM0zDWo9M,11747
|
|
9
9
|
mima/backend/pygame_events.py,sha256=w4zYiBlcbZsx2lPRz6wZ4mEvjpVlzvDTGWgcpoosYCY,16248
|
|
@@ -104,11 +104,11 @@ mima/util/functions.py,sha256=QCy6Q88qVFUx1nV9DEq4uTruzJzJMee5wsnn7LrwD0g,524
|
|
|
104
104
|
mima/util/input_defaults.py,sha256=0UMEA4ltPCLRo5foOTSRRRMb8YucEJazw2_rqw7d-x0,759
|
|
105
105
|
mima/util/logging.py,sha256=p6-C1ozlCs_sCkmykh_B0NgZtvSkcZXXseE6qA6Zwew,1197
|
|
106
106
|
mima/util/property.py,sha256=o6dEWpIOWxwS_lf6MvYZSjkyI5Amo56P2JIDa7AMaRY,107
|
|
107
|
-
mima/util/runtime_config.py,sha256=
|
|
107
|
+
mima/util/runtime_config.py,sha256=6DUvBCMUVV6XHTM0pp3Ppxz5DCO891j8B7sAl9mclH4,3811
|
|
108
108
|
mima/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
109
109
|
mima/view/camera.py,sha256=cDg6Sp4XjR3uEyk3pZr5O40EXJZuf8FowhBqxeEZba0,1779
|
|
110
110
|
mima/view/scene.py,sha256=rxuiaL-z7K9G9tWnUtkgxCdyxLOPszINTvq2DIFpQlU,12118
|
|
111
|
-
mima_engine-0.1.
|
|
112
|
-
mima_engine-0.1.
|
|
113
|
-
mima_engine-0.1.
|
|
114
|
-
mima_engine-0.1.
|
|
111
|
+
mima_engine-0.1.3.dist-info/METADATA,sha256=vHldABJEwy7oZBe8xZFRutGZuZckyO5qih7jDq0Otmw,432
|
|
112
|
+
mima_engine-0.1.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
113
|
+
mima_engine-0.1.3.dist-info/top_level.txt,sha256=5t1cOdQSaPQ0jWDhKDvDXwpV2XZ_a1GSSFAIvEsG0fQ,5
|
|
114
|
+
mima_engine-0.1.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|