commit c1eaa5695b4cc0d3c6efa64eee111cb563a49cdd Author: Михаил Капелько Date: Fri Jul 12 22:38:19 2024 +0300 d diff --git a/main.py b/main.py new file mode 100644 index 0000000..3f6831a --- /dev/null +++ b/main.py @@ -0,0 +1,47 @@ +import os +import sys + +SCRIPT_DIR = os.path.dirname(os.path.realpath(sys.argv[0])) + +sys.path.append(f"{SCRIPT_DIR}/../cross-language-dialect/ctx") +sys.path.append(f"{SCRIPT_DIR}/../cross-language-dialect/lib") +sys.path.append(f"{SCRIPT_DIR}/py") + +import arcade +from cld import * +from ctx import * +from desktop_Platform import * +from desktop_Window import * +from ht_Context import * + +ctrl = ctx_Controller(ht_createContext()) +ctrl.registerFunctions([ +]) + +def printDbg(c): + print(f"Dbg key/value: '{c.recentField}'/'{c.field(c.recentField)}'") +ctrl.registerCallback(printDbg) + +p = desktop_Platform() +p.ctrl = ctrl + +# Bind platform to context changes. +def process(c): + # Copy context to platform. + p.c = c + # Perform context dependent calls of desktop functions. + # Similar to context functions, but no platform is returned. + ### desktop_deselectMismatchedTiles(p) +ctrl.registerCallback(process) + +ctrl.set("windowWidth", 900) +ctrl.set("windowHeight", 600) +ctrl.set("windowAntialiasing", False) +ctrl.set("windowBackgroundColor", "#ffffff") +ctrl.set("windowTitle", "Прототип: Отель") + +#desktop_loadTextures(p) + +wnd = desktop_Window(p) +ctrl.set("didLaunch", True) +arcade.run() diff --git a/py/__pycache__/desktop_Platform.cpython-312.pyc b/py/__pycache__/desktop_Platform.cpython-312.pyc new file mode 100644 index 0000000..c01b20f Binary files /dev/null and b/py/__pycache__/desktop_Platform.cpython-312.pyc differ diff --git a/py/__pycache__/desktop_Window.cpython-312.pyc b/py/__pycache__/desktop_Window.cpython-312.pyc new file mode 100644 index 0000000..ce34ac7 Binary files /dev/null and b/py/__pycache__/desktop_Window.cpython-312.pyc differ diff --git a/py/__pycache__/ht_Context.cpython-312.pyc b/py/__pycache__/ht_Context.cpython-312.pyc new file mode 100644 index 0000000..8c98232 Binary files /dev/null and b/py/__pycache__/ht_Context.cpython-312.pyc differ diff --git a/py/desktop_Platform.py b/py/desktop_Platform.py new file mode 100644 index 0000000..5631822 --- /dev/null +++ b/py/desktop_Platform.py @@ -0,0 +1,9 @@ +import arcade + +class desktop_Platform: + def __init__(self): + self.c = None + self.ctrl = None + self.mousePosition = [] + self.dbgSprites = arcade.SpriteList() + self.dbgTextures = [] diff --git a/py/desktop_Window.py b/py/desktop_Window.py new file mode 100644 index 0000000..264a0ab --- /dev/null +++ b/py/desktop_Window.py @@ -0,0 +1,23 @@ +import arcade + +class desktop_Window(arcade.Window): + def __init__(self, p): + super().__init__( + p.c.windowWidth, + p.c.windowHeight, + p.c.windowTitle, + ) + self.antialiasing = p.c.windowAntialiasing + self.background_color = arcade.color_from_hex_string(p.c.windowBackgroundColor) + self.p = p + + def on_draw(self): + arcade.start_render() + self.p.dbgSprites.draw() + + def on_mouse_press(self, x, y, button, key_modifiers): + print("mouse press:", x, y) + pass + + def on_update(self, delta): + pass diff --git a/py/ht_Context.py b/py/ht_Context.py new file mode 100644 index 0000000..f523e41 --- /dev/null +++ b/py/ht_Context.py @@ -0,0 +1,17 @@ +class ht_Context: + def __init__(self): + self.didLaunch = False + self.recentField = "none" + self.windowBackgroundColor = "#000000" + self.windowHeight = 0 + self.windowTitle = "" + self.windowWidth = 0 + + def field(self, fieldName): + return getattr(self, fieldName) + + def setField(self, fieldName, value): + setattr(self, fieldName, value) + +def ht_createContext(): + return ht_Context() diff --git a/run b/run new file mode 100755 index 0000000..e697db6 --- /dev/null +++ b/run @@ -0,0 +1,2 @@ +#!/bin/bash +/Users/mk/py3.12venv/bin/python3.12 main.py