mima-engine 0.4.0__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.
Files changed (153) hide show
  1. mima/__init__.py +4 -0
  2. mima/backend/__init__.py +1 -0
  3. mima/backend/pygame_assets.py +401 -0
  4. mima/backend/pygame_audio.py +78 -0
  5. mima/backend/pygame_backend.py +603 -0
  6. mima/backend/pygame_camera.py +63 -0
  7. mima/backend/pygame_events.py +695 -0
  8. mima/backend/touch_control_scheme_a.py +126 -0
  9. mima/backend/touch_control_scheme_b.py +132 -0
  10. mima/core/__init__.py +0 -0
  11. mima/core/collision.py +325 -0
  12. mima/core/database.py +58 -0
  13. mima/core/engine.py +367 -0
  14. mima/core/mode_engine.py +81 -0
  15. mima/core/scene_engine.py +81 -0
  16. mima/integrated/__init__.py +0 -0
  17. mima/integrated/entity.py +183 -0
  18. mima/integrated/layered_map.py +351 -0
  19. mima/integrated/sprite.py +156 -0
  20. mima/layered/__init__.py +0 -0
  21. mima/layered/assets.py +56 -0
  22. mima/layered/scene.py +415 -0
  23. mima/layered/shape.py +99 -0
  24. mima/layered/shaped_sprite.py +78 -0
  25. mima/layered/virtual_input.py +302 -0
  26. mima/maps/__init__.py +0 -0
  27. mima/maps/template.py +71 -0
  28. mima/maps/tile.py +20 -0
  29. mima/maps/tile_animation.py +7 -0
  30. mima/maps/tile_info.py +10 -0
  31. mima/maps/tile_layer.py +52 -0
  32. mima/maps/tiled/__init__.py +0 -0
  33. mima/maps/tiled/tiled_layer.py +48 -0
  34. mima/maps/tiled/tiled_map.py +95 -0
  35. mima/maps/tiled/tiled_object.py +79 -0
  36. mima/maps/tiled/tiled_objectgroup.py +25 -0
  37. mima/maps/tiled/tiled_template.py +49 -0
  38. mima/maps/tiled/tiled_tile.py +90 -0
  39. mima/maps/tiled/tiled_tileset.py +51 -0
  40. mima/maps/tilemap.py +216 -0
  41. mima/maps/tileset.py +39 -0
  42. mima/maps/tileset_info.py +9 -0
  43. mima/maps/transition_map.py +146 -0
  44. mima/objects/__init__.py +0 -0
  45. mima/objects/animated_sprite.py +217 -0
  46. mima/objects/attribute_effect.py +26 -0
  47. mima/objects/attributes.py +126 -0
  48. mima/objects/creature.py +384 -0
  49. mima/objects/dynamic.py +206 -0
  50. mima/objects/effects/__init__.py +0 -0
  51. mima/objects/effects/colorize_screen.py +60 -0
  52. mima/objects/effects/debug_box.py +133 -0
  53. mima/objects/effects/light.py +103 -0
  54. mima/objects/effects/show_sprite.py +50 -0
  55. mima/objects/effects/walking_on_grass.py +70 -0
  56. mima/objects/effects/walking_on_water.py +57 -0
  57. mima/objects/loader.py +111 -0
  58. mima/objects/projectile.py +111 -0
  59. mima/objects/sprite.py +116 -0
  60. mima/objects/world/__init__.py +0 -0
  61. mima/objects/world/color_gate.py +67 -0
  62. mima/objects/world/color_switch.py +101 -0
  63. mima/objects/world/container.py +175 -0
  64. mima/objects/world/floor_switch.py +109 -0
  65. mima/objects/world/gate.py +178 -0
  66. mima/objects/world/light_source.py +121 -0
  67. mima/objects/world/logic_gate.py +157 -0
  68. mima/objects/world/movable.py +399 -0
  69. mima/objects/world/oneway.py +195 -0
  70. mima/objects/world/pickup.py +157 -0
  71. mima/objects/world/switch.py +179 -0
  72. mima/objects/world/teleport.py +308 -0
  73. mima/py.typed +0 -0
  74. mima/scripts/__init__.py +2 -0
  75. mima/scripts/command.py +38 -0
  76. mima/scripts/commands/__init__.py +0 -0
  77. mima/scripts/commands/add_quest.py +19 -0
  78. mima/scripts/commands/change_map.py +34 -0
  79. mima/scripts/commands/close_dialog.py +9 -0
  80. mima/scripts/commands/equip_weapon.py +23 -0
  81. mima/scripts/commands/give_item.py +26 -0
  82. mima/scripts/commands/give_resource.py +51 -0
  83. mima/scripts/commands/move_map.py +152 -0
  84. mima/scripts/commands/move_to.py +49 -0
  85. mima/scripts/commands/oneway_move.py +58 -0
  86. mima/scripts/commands/parallel.py +66 -0
  87. mima/scripts/commands/play_sound.py +13 -0
  88. mima/scripts/commands/present_item.py +53 -0
  89. mima/scripts/commands/progress_quest.py +12 -0
  90. mima/scripts/commands/quit_game.py +8 -0
  91. mima/scripts/commands/save_game.py +14 -0
  92. mima/scripts/commands/screen_fade.py +83 -0
  93. mima/scripts/commands/serial.py +69 -0
  94. mima/scripts/commands/set_facing_direction.py +21 -0
  95. mima/scripts/commands/set_spawn_map.py +17 -0
  96. mima/scripts/commands/show_choices.py +52 -0
  97. mima/scripts/commands/show_dialog.py +118 -0
  98. mima/scripts/commands/take_coins.py +23 -0
  99. mima/scripts/script_processor.py +61 -0
  100. mima/standalone/__init__.py +0 -0
  101. mima/standalone/camera.py +153 -0
  102. mima/standalone/geometry.py +1318 -0
  103. mima/standalone/multicolumn_list.py +54 -0
  104. mima/standalone/pixel_font.py +84 -0
  105. mima/standalone/scripting.py +145 -0
  106. mima/standalone/spatial.py +186 -0
  107. mima/standalone/sprite.py +158 -0
  108. mima/standalone/tiled_map.py +1247 -0
  109. mima/standalone/transformed_view.py +433 -0
  110. mima/standalone/user_input.py +563 -0
  111. mima/states/__init__.py +0 -0
  112. mima/states/game_state.py +189 -0
  113. mima/states/memory.py +28 -0
  114. mima/states/quest.py +71 -0
  115. mima/types/__init__.py +0 -0
  116. mima/types/alignment.py +7 -0
  117. mima/types/blend.py +8 -0
  118. mima/types/damage.py +42 -0
  119. mima/types/direction.py +44 -0
  120. mima/types/gate_color.py +7 -0
  121. mima/types/graphic_state.py +23 -0
  122. mima/types/keys.py +64 -0
  123. mima/types/mode.py +9 -0
  124. mima/types/nature.py +12 -0
  125. mima/types/object.py +22 -0
  126. mima/types/player.py +9 -0
  127. mima/types/position.py +13 -0
  128. mima/types/start.py +7 -0
  129. mima/types/terrain.py +9 -0
  130. mima/types/tile_collision.py +11 -0
  131. mima/types/weapon_slot.py +6 -0
  132. mima/types/window.py +44 -0
  133. mima/usables/__init__.py +0 -0
  134. mima/usables/item.py +51 -0
  135. mima/usables/weapon.py +68 -0
  136. mima/util/__init__.py +1 -0
  137. mima/util/colors.py +50 -0
  138. mima/util/constants.py +55 -0
  139. mima/util/functions.py +38 -0
  140. mima/util/input_defaults.py +170 -0
  141. mima/util/logging.py +51 -0
  142. mima/util/property.py +8 -0
  143. mima/util/runtime_config.py +327 -0
  144. mima/util/trading_item.py +23 -0
  145. mima/view/__init__.py +0 -0
  146. mima/view/camera.py +192 -0
  147. mima/view/mima_mode.py +618 -0
  148. mima/view/mima_scene.py +231 -0
  149. mima/view/mima_view.py +12 -0
  150. mima/view/mima_window.py +244 -0
  151. mima_engine-0.4.0.dist-info/METADATA +47 -0
  152. mima_engine-0.4.0.dist-info/RECORD +153 -0
  153. mima_engine-0.4.0.dist-info/WHEEL +4 -0
mima/usables/item.py ADDED
@@ -0,0 +1,51 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, Dict
4
+
5
+ from ..util.constants import DEFAULT_SPRITE_HEIGHT, DEFAULT_SPRITE_WIDTH
6
+
7
+ if TYPE_CHECKING:
8
+ from ..engine import MimaEngine
9
+ from ..objects.creature import Creature
10
+ from ..objects.dynamic import Dynamic
11
+
12
+
13
+ class Item:
14
+ engine: MimaEngine
15
+
16
+ def __init__(self):
17
+ self.name: str = ""
18
+ self.description: str = ""
19
+ self.sprite_name: str = ""
20
+ # self.sprite_ox: int = 0
21
+ # self.sprite_oy: int = 0
22
+ # self.sprite_width: int = DEFAULT_SPRITE_WIDTH
23
+ # self.sprite_height: int = DEFAULT_SPRITE_HEIGHT
24
+ self.key_item: bool = False
25
+ self.equipable: bool = False
26
+ self.price: int = 0
27
+ self.stackable: bool = False
28
+ self.stackable_by_merchant: bool = False
29
+
30
+ def init(self, data: Dict[str, Any]):
31
+
32
+ for key, val in data.items():
33
+ setattr(self, key, val)
34
+ # self.usable_id = data["usable_id"]
35
+ # self.name = data["name"]
36
+ # self.description = data["description"]
37
+ # self.price = data.get("attr_price", 0)
38
+ # self.sprite_name = data.get("sprite_name")
39
+
40
+ def on_interaction(self, obj: Dynamic):
41
+ return False
42
+
43
+ def on_use(self, obj: Creature):
44
+ return False
45
+
46
+ def __str__(self):
47
+ txt = f"{type(self).__name__}({self.name})"
48
+ return txt
49
+
50
+ def __repr__(self):
51
+ return str(self)
mima/usables/weapon.py ADDED
@@ -0,0 +1,68 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, Any, Dict, Tuple
4
+
5
+ from ..types.damage import Damage
6
+ from ..types.direction import Direction
7
+ from .item import Item
8
+
9
+ if TYPE_CHECKING:
10
+ from ..objects.creature import Creature
11
+
12
+
13
+ class Weapon(Item):
14
+ def __init__(self):
15
+ super().__init__()
16
+
17
+ self.equipable = True
18
+
19
+ self.damage: int = 0
20
+ self.dtype: Damage = Damage.BODY
21
+ self.health_cost: float = 0.0
22
+ self.magic_cost: float = 0.0
23
+ self.stamina_cost: float = 0.0
24
+ self.arrow_cost: int = 0
25
+ self.bomb_cost: int = 0
26
+ self.swing_timer: float = 0.2
27
+
28
+ def init(self, data: Dict[str, Any]):
29
+ for key, val in data.items():
30
+ setattr(self, key, val)
31
+ # self.usable_id = data["usable_id"]
32
+ # self.name = data["display_name"]
33
+ # self.description = data["description"]
34
+ # self.sprite_name = data["sprite_name"]
35
+ # self.price = data["attr_price"]
36
+ # self.swing_timer = data["attr_swing_timer"]
37
+ # self.damage = data["attr_damage"]
38
+ # self.dtype = data["attr_dtype"]
39
+ # self.health_cost = data["attr_health_cost"]
40
+ # self.magic_cost = data["attr_magic_cost"]
41
+ # self.stamina_cost = data["attr_stamina_cost"]
42
+ # self.bomb_cost = data["attr_bomb_cost"]
43
+ # self.arrow_cost = data["attr_arrow_cost"]
44
+ # print()
45
+
46
+ def _determine_attack_origin(self, obj: Creature) -> Tuple[float, float]:
47
+ vx = 0.0
48
+ vy = 0.0
49
+
50
+ if obj.facing_direction == Direction.SOUTH:
51
+ vy = 1.0
52
+ if obj.facing_direction == Direction.WEST:
53
+ vx = -1.0
54
+ if obj.facing_direction == Direction.NORTH:
55
+ vy = -1.0
56
+ if obj.facing_direction == Direction.EAST:
57
+ vx = 1.0
58
+
59
+ return vx, vy
60
+
61
+ def on_equip(self, obj: Creature):
62
+ pass
63
+
64
+ def on_unequip(self, obj: Creature):
65
+ pass
66
+
67
+ def on_interaction(self, target: Creature):
68
+ return True # Add to inventory
mima/util/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .runtime_config import RuntimeConfig
mima/util/colors.py ADDED
@@ -0,0 +1,50 @@
1
+ from typing import Tuple
2
+
3
+
4
+ class Color:
5
+ def __init__(self, red: int, green: int, blue: int, alpha: int = 255):
6
+ self.red = red
7
+ self.green = green
8
+ self.blue = blue
9
+ self.alpha = alpha
10
+
11
+ def getRGBA(self) -> Tuple[int, int, int, int]:
12
+ return (self.red, self.green, self.blue, self.alpha)
13
+
14
+ def getRGB(self) -> Tuple[int, int, int]:
15
+ return (self.red, self.green, self.blue)
16
+
17
+ def __repr__(self):
18
+ return (
19
+ f"Color(red={self.red}, green={self.green}, "
20
+ f"blue={self.blue}, alpha={self.alpha})"
21
+ )
22
+
23
+ def short_name(self):
24
+ return f"{self.red}-{self.green}-{self.blue}-{self.alpha}"
25
+
26
+
27
+ BLACK = Color(0, 0, 0)
28
+ WHITE = Color(255, 255, 255)
29
+ ALPHA = Color(254, 253, 254)
30
+ LIGHTGREY = Color(100, 100, 100)
31
+ DARK_GREY = Color(64, 64, 64, 160)
32
+ VERY_LIGHT_GREY = Color(195, 195, 195)
33
+ RED = Color(255, 0, 0)
34
+ GREEN = Color(0, 255, 0)
35
+ BLUE = Color(0, 0, 255)
36
+ YELLOW = Color(255, 255, 0)
37
+ CYAN = Color(0, 255, 255)
38
+ PURPLE = Color(128, 0, 128)
39
+ DARK_RED = Color(64, 0, 0, 160)
40
+ DARK_GREEN = Color(0, 64, 0, 160)
41
+ DARK_BLUE = Color(0, 0, 64, 160)
42
+ DARK_YELLOW = Color(64, 64, 0, 160)
43
+ DARK_CYAN = Color(0, 64, 64, 160)
44
+ DARK_PURPLE = Color(64, 0, 64, 160)
45
+ TRANS_CYAN = Color(0, 64, 64, 128)
46
+ TRANS_LIGHT_RED = Color(255, 0, 0, 128)
47
+ TRANS_LIGHT_YELLOW = Color(255, 255, 0, 128)
48
+ TRANS_LIGHT_CYAN = Color(0, 255, 255, 128)
49
+ TRANS_LIGHT_PURPLE = Color(255, 0, 255, 128)
50
+ TRANS_LIGHT_GREEN = Color(0, 255, 0, 128)
mima/util/constants.py ADDED
@@ -0,0 +1,55 @@
1
+ # Tile dimensions
2
+ WIDTH: int = int(256 * 1) # TODO: remove
3
+ HEIGHT: int = int(144 * 1) # TODO: remove
4
+ TILE_WIDTH: int = 16
5
+ TILE_HEIGHT: int = TILE_WIDTH
6
+ DEFAULT_SPRITE_WIDTH: int = TILE_WIDTH
7
+ DEFAULT_SPRITE_HEIGHT: int = TILE_HEIGHT
8
+ UI_HIGHT: int = 1 # TODO: remove
9
+
10
+ # Map transition
11
+ MOVE_MAP_DURATION: float = 1.0
12
+ MAP_TRANSITION_DURATION_FACTOR: float = 0.75
13
+ ONEWAY_ACTIVATION_DELAY: float = 0.075
14
+ ONEWAY_SPEED_BOOST: float = 2.5
15
+
16
+ # Gamepad
17
+ AXIS_DEADZONE: float = 0.25
18
+ AXIS_ACTIVATION: float = 0.5
19
+
20
+ # Touchscreen
21
+ TOUCH_ACTIVATION: float = 0.001
22
+ SINGLE_TAP_MIN: float = 0.2
23
+ SINGLE_TAP_MAX: float = 1.0
24
+ DOUBLE_TAP_SPEED: float = 0.2
25
+
26
+ # Font
27
+ BIG_FONT_NAME: str = "pixel-font"
28
+ BIG_FONT_WIDTH: int = 6
29
+ BIG_FONT_HEIGHT: int = 8
30
+ SMALL_FONT_NAME: str = "pixel-font-small"
31
+ SMALL_FONT_WIDTH: int = 4
32
+ SMALL_FONT_HEIGHT: int = 5
33
+
34
+ # Dynamics
35
+ DEFAULT_GRAPHIC_TIMER_STANDING: float = 0.5
36
+ DEFAULT_GRAPHIC_TIMER_WALKING: float = 0.15
37
+ DEFAULT_GRAPHIC_TIMER_DAMAGED: float = 0.075
38
+ DEFAULT_GRAPHIC_TIMER_DEAD: float = 0.25
39
+ DEFAULT_GRAPHIC_TIMER: float = 0.5
40
+ ATTRIBUTE_TIMER: float = 0.25
41
+ DEFAULT_KNOCK_SPEED: float = 6.0
42
+
43
+ # Gameplay
44
+ ABYSS_DAMAGE: int = 1
45
+ PLAYER_BASE_HEALTH: int = 30
46
+ PLAYER_BASE_SPEED: float = 4.5
47
+ PLAYER_BASE_RUN_SPEED: float = 6.0
48
+
49
+ # Dialog
50
+ DIALOG_WIDTH: float = 14.0
51
+ DIALOG_HEIGHT: float = 3.0
52
+ DIALOG_CHARS_PER_LINE: int = 36
53
+ DIALOG_N_LINES: int = 4
54
+
55
+ SAVE_FILE_NAME = "savegame"
mima/util/functions.py ADDED
@@ -0,0 +1,38 @@
1
+ from .constants import BIG_FONT_WIDTH
2
+
3
+
4
+ def strtobool(val: str) -> bool:
5
+ """Convert a string representation of truth to true (1) or false (0).
6
+ True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
7
+ are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
8
+ 'val' is anything else.
9
+ """
10
+ val = val.lower()
11
+ if val in ("y", "yes", "t", "true", "on", "1"):
12
+ return True
13
+ elif val in ("n", "no", "f", "false", "off", "0", ""):
14
+ return False
15
+ else:
16
+ raise ValueError("invalid truth value %r" % (val,))
17
+
18
+
19
+ def wrap_text(text: str, n_chars: int = 0) -> list[str]:
20
+ if n_chars == 0:
21
+ return [text]
22
+
23
+ words = text.split(" ")
24
+ lines: list[str] = []
25
+ new_text = ""
26
+ for idx, word in enumerate(words):
27
+ if len(new_text + word) > n_chars:
28
+ lines.append(new_text)
29
+ new_text = ""
30
+
31
+ new_text += f"{word.strip()} "
32
+ # new_text.strip()
33
+ lines.append(new_text.strip())
34
+ return lines
35
+
36
+
37
+ def text_to_center(text: str, ppx: int, pwidth: int, font_width=BIG_FONT_WIDTH):
38
+ return int(ppx + pwidth / 2 - (len(text) / 2 * BIG_FONT_WIDTH))
@@ -0,0 +1,170 @@
1
+ from ..types.keys import Key as K
2
+
3
+ BUTTONS = [
4
+ K.UP,
5
+ K.DOWN,
6
+ K.LEFT,
7
+ K.RIGHT,
8
+ K.START,
9
+ K.SELECT,
10
+ K.A,
11
+ K.B,
12
+ K.X,
13
+ K.Y,
14
+ K.L,
15
+ K.R,
16
+ K.P1_UP,
17
+ K.P1_DOWN,
18
+ K.P1_LEFT,
19
+ K.P1_RIGHT,
20
+ K.P1_START,
21
+ K.P1_SELECT,
22
+ K.P1_A,
23
+ K.P1_B,
24
+ K.P1_X,
25
+ K.P1_Y,
26
+ K.P1_L,
27
+ K.P1_R,
28
+ K.P2_UP,
29
+ K.P2_DOWN,
30
+ K.P2_LEFT,
31
+ K.P2_RIGHT,
32
+ K.P2_START,
33
+ K.P2_SELECT,
34
+ K.P2_A,
35
+ K.P2_B,
36
+ K.P2_X,
37
+ K.P2_Y,
38
+ K.P2_L,
39
+ K.P2_R,
40
+ K.P3_UP,
41
+ K.P3_DOWN,
42
+ K.P3_LEFT,
43
+ K.P3_RIGHT,
44
+ K.P3_START,
45
+ K.P3_SELECT,
46
+ K.P3_A,
47
+ K.P3_B,
48
+ K.P3_X,
49
+ K.P3_Y,
50
+ K.P3_L,
51
+ K.P3_R,
52
+ K.P4_UP,
53
+ K.P4_DOWN,
54
+ K.P4_LEFT,
55
+ K.P4_RIGHT,
56
+ K.P4_START,
57
+ K.P4_SELECT,
58
+ K.P4_A,
59
+ K.P4_B,
60
+ K.P4_X,
61
+ K.P4_Y,
62
+ K.P4_L,
63
+ K.P4_R,
64
+ ]
65
+
66
+
67
+ # Keyboard
68
+ # The arrow keys need to be uppercase, other keys are lowercase
69
+ DEFAULT_KEYBOARD_MAP = {
70
+ K.UP: ["w", "UP"],
71
+ K.DOWN: ["s", "DOWN"],
72
+ K.LEFT: ["a", "LEFT"],
73
+ K.RIGHT: ["d", "RIGHT"],
74
+ K.START: ["i"],
75
+ K.SELECT: ["t"],
76
+ K.A: ["k"],
77
+ K.B: ["h"],
78
+ K.X: ["l"],
79
+ K.Y: ["j"],
80
+ K.L: ["o"],
81
+ K.R: ["c"],
82
+ K.P1_UP: [],
83
+ K.P1_DOWN: [],
84
+ K.P1_LEFT: [],
85
+ K.P1_RIGHT: [],
86
+ K.P1_START: [],
87
+ K.P1_SELECT: [],
88
+ K.P1_A: [],
89
+ K.P1_B: [],
90
+ K.P1_X: [],
91
+ K.P1_Y: [],
92
+ K.P1_L: [],
93
+ K.P1_R: [],
94
+ K.P1_UP: [],
95
+ K.P1_UP: [],
96
+ K.P2_DOWN: [],
97
+ K.P2_LEFT: [],
98
+ K.P2_RIGHT: [],
99
+ K.P2_START: [],
100
+ K.P2_SELECT: [],
101
+ K.P2_A: [],
102
+ K.P2_B: [],
103
+ K.P2_X: [],
104
+ K.P2_Y: [],
105
+ K.P2_L: [],
106
+ K.P2_R: [],
107
+ K.P2_UP: [],
108
+ K.P3_UP: [],
109
+ K.P3_DOWN: [],
110
+ K.P3_LEFT: [],
111
+ K.P3_RIGHT: [],
112
+ K.P3_START: [],
113
+ K.P3_SELECT: [],
114
+ K.P3_A: [],
115
+ K.P3_B: [],
116
+ K.P3_X: [],
117
+ K.P3_Y: [],
118
+ K.P3_L: [],
119
+ K.P3_R: [],
120
+ K.P4_UP: [],
121
+ K.P4_DOWN: [],
122
+ K.P4_LEFT: [],
123
+ K.P4_RIGHT: [],
124
+ K.P4_START: [],
125
+ K.P4_SELECT: [],
126
+ K.P4_A: [],
127
+ K.P4_B: [],
128
+ K.P4_X: [],
129
+ K.P4_Y: [],
130
+ K.P4_L: [],
131
+ K.P4_R: [],
132
+ }
133
+
134
+ DEFAULT_JOYSTICK_MAP = {
135
+ K.UP: ["up"],
136
+ K.DOWN: ["down"],
137
+ K.LEFT: ["left"],
138
+ K.RIGHT: ["right"],
139
+ K.START: [7],
140
+ K.SELECT: [6],
141
+ K.A: [0],
142
+ K.B: [1],
143
+ K.X: [3],
144
+ K.Y: [2],
145
+ K.L: [4],
146
+ K.R: [5],
147
+ }
148
+
149
+ DEFAULT_TOUCHSCREEN_MAP = {
150
+ K.P1_UP: [[0, 0], [0.5, 1.0]],
151
+ K.P1_L: [[0, 0], [0.0625, 0.1111]],
152
+ K.P1_R: [[0.9375, 0], [1.0, 0.1111]],
153
+ K.P1_START: [[0.5, 0], [1.0, 0.3]],
154
+ K.P1_Y: [[0.5, 0.3], [0.75, 0.5]],
155
+ K.P1_X: [[0.75, 0.3], [1.0, 0.5]],
156
+ K.P1_B: [[0.5, 0.5], [0.75, 1.0]],
157
+ K.P1_A: [[0.75, 0.5], [1.0, 1.0]],
158
+ }
159
+
160
+ ALT_TOUCHSCREEN_MAP = {
161
+ K.P1_UP: {"pos": [0.1, 0.2], "size": [0.4, 0.7]},
162
+ K.P1_A: {"pos": [0.83, 0.80], "size": [0.15, 0.15]},
163
+ K.P1_B: {"pos": [0.67, 0.80], "size": [0.15, 0.15]},
164
+ K.P1_X: {"pos": [0.83, 0.65], "size": [0.12, 0.12]},
165
+ K.P1_Y: {"pos": [0.70, 0.65], "size": [0.12, 0.12]},
166
+ K.P1_START: {"pos": [0.56, 0.02], "size": [0.1, 0.1]},
167
+ K.P1_SELECT: {"pos": [0.34, 0.02], "size": [0.1, 0.1]},
168
+ K.P1_L: {"pos": [0.01, 0.1], "size": [0.05, 0.4]},
169
+ K.P1_R: {"pos": [0.94, 0.1], "size": [0.05, 0.4]},
170
+ }
mima/util/logging.py ADDED
@@ -0,0 +1,51 @@
1
+ import logging
2
+ import logging.config
3
+
4
+ _TRACE_INSTALLED = False
5
+ _DEFAULT_CONFIG = {
6
+ "version": 1,
7
+ "formatters": {
8
+ "brief": {
9
+ "format": ("%(asctime)s [%(name)s][%(levelname)s] %(message)s")
10
+ },
11
+ },
12
+ "handlers": {
13
+ "console": {
14
+ "class": "logging.StreamHandler",
15
+ "formatter": "brief",
16
+ "level": "INFO",
17
+ "stream": "ext://sys.stdout",
18
+ },
19
+ },
20
+ "root": {
21
+ "level": "ERROR",
22
+ "handlers": ["console"],
23
+ },
24
+ "loggers": {
25
+ "mima": {"level": "TRACE"},
26
+ },
27
+ }
28
+
29
+
30
+ def install_trace_logger():
31
+ global _TRACE_INSTALLED
32
+ if _TRACE_INSTALLED:
33
+ return
34
+ level = logging.TRACE = logging.DEBUG - 5
35
+
36
+ def log_logger(self, message, *args, **kwargs):
37
+ if self.isEnabledFor(level):
38
+ self._log(level, message, args, **kwargs)
39
+
40
+ logging.getLoggerClass().trace = log_logger
41
+
42
+ def log_root(msg, *args, **kwargs):
43
+ logging.log(level, msg, *args, **kwargs)
44
+
45
+ logging.addLevelName(level, "TRACE")
46
+ logging.trace = log_root
47
+ _TRACE_INSTALLED = True
48
+
49
+
50
+ def configure_logging(config=_DEFAULT_CONFIG):
51
+ logging.config.dictConfig(config)
mima/util/property.py ADDED
@@ -0,0 +1,8 @@
1
+ from dataclasses import dataclass
2
+
3
+
4
+ @dataclass
5
+ class Property:
6
+ name: str
7
+ dtype: str
8
+ value: str