diff --git a/CHANGELOG.de.md b/CHANGELOG.de.md index a6d11e4e..d6762c3e 100644 --- a/CHANGELOG.de.md +++ b/CHANGELOG.de.md @@ -4,6 +4,16 @@ Alle Versionen von U-Jagd, die neueste zuerst. Die [README](README.de.md) zeigt nur die neueste. +## 1.3.288 + +Version 1.3.288 beendet das Blinken des Bildes hinter einem offenen Menü in +der Mac-App. Unter macOS übernahm die Zeichenfläche des Spiels den +Alphakanal des Fensters, sodass die Schleier und Tafeln von Optionen, Hilfe, +Speichern und den anderen Menüs das Bild teilweise durchsichtig machten und +das Fenster dahinter flackerte. Die Zeichenfläche ist jetzt immer deckend; +auf dem uConsole, unter Windows und im Spiel ändert sich nichts. Spielstände +sind v53; v38 bis v52 laden weiterhin. + ## 1.3.287 Version 1.3.287 ändert nichts am Spiel; sie enthält 1.3.286 und die diff --git a/CHANGELOG.md b/CHANGELOG.md index 68e4ffcc..eb2017d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,15 @@ Every U-Jagd release, newest first. The [README](README.md) shows only the latest one. +## 1.3.288 + +Release 1.3.288 stops the Mac app's picture from blinking behind an open +menu. On macOS the game's drawing canvas inherited the window's alpha +channel, so the veils and panels of the options, help, save and other menus +left the picture partly transparent and the window flickered behind them. The +canvas is now always opaque; nothing changes on the uConsole, Windows or in +play. Saves are v53; v38 to v52 saves still load. + ## 1.3.287 Release 1.3.287 changes nothing in play; it carries 1.3.286 and the browser diff --git a/README.de.md b/README.de.md index f338ffcd..b999af97 100644 --- a/README.de.md +++ b/README.de.md @@ -10,13 +10,14 @@ die Fregatte F-217 mit neun Stationen oder ein U-Boot mit sieben und jagen die andere Seite oder entkommen ihr. Freunde können Stationen im Browser im selben Netz besetzen. -Aktuelle Version: **1.3.287** +Aktuelle Version: **1.3.288** -Version 1.3.287 ändert nichts am Spiel; sie enthält 1.3.286 und die -Maussteuerung des Browsers aus 1.3.285 unverändert. Der Audio-Dauertest zählt -Aussetzer des Mischers erst zwei Sekunden nach einem Kaltstart, damit ein -langsames erstes Bild auf einer ausgelasteten Testmaschine keine Version mehr -aufhält; ein Hänger später im Lauf lässt ihn weiterhin scheitern. Spielstände +Version 1.3.288 beendet das Blinken des Bildes hinter einem offenen Menü in +der Mac-App. Unter macOS übernahm die Zeichenfläche des Spiels den +Alphakanal des Fensters, sodass die Schleier und Tafeln von Optionen, Hilfe, +Speichern und den anderen Menüs das Bild teilweise durchsichtig machten und +das Fenster dahinter flackerte. Die Zeichenfläche ist jetzt immer deckend; +auf dem uConsole, unter Windows und im Spiel ändert sich nichts. Spielstände sind v53; v38 bis v52 laden weiterhin. Frühere Versionen: [CHANGELOG.de.md](CHANGELOG.de.md). diff --git a/README.md b/README.md index 76daf860..d7ce0d46 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ the frigate F-217 with nine stations, or a submarine with seven, and hunt or evade the other side. Friends can crew stations from a browser on the same network. -Current release: **1.3.287** +Current release: **1.3.288** -Release 1.3.287 changes nothing in play; it carries 1.3.286 and the browser -mouse control of 1.3.285 unchanged. The audio soak test now leaves the first -two seconds after a cold start out of its mixer starvation count, so a slow -first frame on a busy test machine no longer stops a release; a stall later in -the run still fails it. Saves are v53; v38 to v52 saves still load. +Release 1.3.288 stops the Mac app's picture from blinking behind an open +menu. On macOS the game's drawing canvas inherited the window's alpha +channel, so the veils and panels of the options, help, save and other menus +left the picture partly transparent and the window flickered behind them. The +canvas is now always opaque; nothing changes on the uConsole, Windows or in +play. Saves are v53; v38 to v52 saves still load. Earlier releases: [CHANGELOG.md](CHANGELOG.md). diff --git a/docs/station-shortcuts.de.md b/docs/station-shortcuts.de.md index 01b7ceda..89a853d3 100644 --- a/docs/station-shortcuts.de.md +++ b/docs/station-shortcuts.de.md @@ -1,4 +1,4 @@ -# U-Jagd 1.3.287 - Stations- und Tastenkürzel +# U-Jagd 1.3.288 - Stations- und Tastenkürzel Druckfassung: [`station-shortcuts.de.pdf`](station-shortcuts.de.pdf). Maßgeblich ist die implementierte lokale Bedienung. Stationsnummern und diff --git a/docs/station-shortcuts.de.pdf b/docs/station-shortcuts.de.pdf index cb84a42d..6380958d 100644 Binary files a/docs/station-shortcuts.de.pdf and b/docs/station-shortcuts.de.pdf differ diff --git a/src/core/game.py b/src/core/game.py index bd4e4c6a..f8715c32 100644 --- a/src/core/game.py +++ b/src/core/game.py @@ -34,7 +34,7 @@ from src.ui import simlog_map # Shared display/help constants and helpers (re-exported for tests/tools). from src.core.game_shared import ( # noqa: F401 HELP_MANUAL_PAGE, HELP_PAGE_COUNT, SONAR_BAND_PRESETS, TMA_ACCEPT_MIN_FIT, - letterbox_layout, make_scanlines) + letterbox_layout, make_canvas, make_scanlines) # Entity classes tests import from ``src.core.game`` (kept as re-exports). from src.enemies.decoy import Decoy # noqa: F401 from src.weapons.torpedo import EnemyTorpedo # noqa: F401 @@ -157,7 +157,7 @@ class Game(PicturesMixin, OperatorMixin, DrawMixin, MissionBridgeMixin, EventMix config.SCREEN_W, config.SCREEN_H) self.display = pygame.display.set_mode(size, pygame.RESIZABLE) self.fullscreen = False - self.screen = pygame.Surface((config.SCREEN_W, config.SCREEN_H)) + self.screen = make_canvas(config.SCREEN_W, config.SCREEN_H) self._scanlines = make_scanlines(config.SCREEN_W, config.SCREEN_H) \ if config.CRT_SCANLINES else None self.clock = pygame.time.Clock() diff --git a/src/core/game_shared.py b/src/core/game_shared.py index 90d8ba8e..04c99498 100644 --- a/src/core/game_shared.py +++ b/src/core/game_shared.py @@ -40,6 +40,18 @@ def letterbox_layout(win_w: int, win_h: int, return scale, (win_w - sw) // 2, (win_h - sh) // 2, sw, sh +def make_canvas(w: int, h: int) -> pygame.Surface: + """The opaque 1280x720 canvas every frame is drawn on. + + Explicit 32-bit RGB without an alpha channel: a plain + ``pygame.Surface`` takes the window's format, and on macOS that format + carries alpha. Translucent layers (menu veils, panels) then left the + canvas pixels partly transparent, and the Mac window blinked behind + every open menu. Without an alpha channel the frame stays opaque on + every system.""" + return pygame.Surface((w, h), 0, 32, (0xFF0000, 0xFF00, 0xFF, 0)) + + def make_scanlines(w: int, h: int, alpha: int = config.SCANLINE_ALPHA): """Vorberechnetes CRT-Scanline-Overlay (einmalig, SRCALPHA).""" s = pygame.Surface((w, h), pygame.SRCALPHA) diff --git a/src/core/version.py b/src/core/version.py index b912d4df..94b61692 100644 --- a/src/core/version.py +++ b/src/core/version.py @@ -4,7 +4,7 @@ This module is deliberately dependency-free because setuptools imports the version while building the project. """ -APP_VERSION = "1.3.287" +APP_VERSION = "1.3.288" SAVE_VERSION = 53 SAVE_SCHEMA = "u-jagd-save-v53" SPLASH_TEXT = ( diff --git a/tests/test_mac_canvas.py b/tests/test_mac_canvas.py new file mode 100644 index 00000000..e80a775b --- /dev/null +++ b/tests/test_mac_canvas.py @@ -0,0 +1,70 @@ +"""The frame canvas stays opaque on every system (Mac menu blinking). + +On macOS the window's pixel format carries an alpha channel and a plain +``pygame.Surface`` copies it. The translucent veils and panels of every +menu then left most canvas pixels partly transparent, and the Mac window +blinked behind an open menu. The canvas is created without alpha. +""" + +import pygame + +from src.core.game import Game, make_canvas +from src.ui import quality + +ARGB = (0xFF0000, 0xFF00, 0xFF, 0xFF000000) + + +def _mac_window(size): + """A window surface in the macOS format (32 bit with alpha).""" + window = pygame.Surface(size, 0, 32, ARGB) + window.set_alpha(None) + window.fill((0, 0, 0, 255)) + return window + + +def _min_alpha(surface) -> int: + alpha = pygame.surfarray.pixels_alpha(surface) + try: + return int(alpha.min()) + finally: + del alpha + + +def test_canvas_has_no_alpha_channel(): + canvas = make_canvas(1280, 720) + assert canvas.get_bitsize() == 32 + assert canvas.get_masks()[3] == 0 + + +def test_game_draws_on_an_opaque_canvas(): + game = Game(seed=3, start_menu=False, show_splash=False, audio_enabled=False) + assert game.screen.get_masks()[3] == 0 + + +def test_a_mac_like_canvas_turns_translucent_behind_a_veil(): + # The cause: a translucent veil blitted onto a canvas that has alpha. + canvas = _mac_window((64, 64)) + veil = pygame.Surface((64, 64), pygame.SRCALPHA) + veil.fill((0, 0, 0, 110)) + canvas.blit(veil, (0, 0)) + assert _min_alpha(canvas) < 255 + # The fix: the opaque canvas blitted onto the same window stays opaque. + opaque = make_canvas(64, 64) + opaque.fill((40, 40, 40)) + opaque.blit(veil, (0, 0)) + window = _mac_window((64, 64)) + window.blit(opaque, (0, 0)) + assert _min_alpha(window) == 255 + + +def test_open_menu_frame_reaches_a_mac_window_opaque(): + game = Game(seed=3, start_menu=False, show_splash=False, audio_enabled=False) + game.options_open = True + for _ in range(3): + game._t += 1 / 30 + game.draw() + for level in ("normal", "low"): + for size in ((1280, 720), (1512, 850), (2560, 1440)): + window = _mac_window(size) + window.blit(quality.scale_canvas(game.screen, size, level), (0, 0)) + assert _min_alpha(window) == 255, (level, size) diff --git a/tests/test_packaging.py b/tests/test_packaging.py index 059b5335..092390ae 100644 --- a/tests/test_packaging.py +++ b/tests/test_packaging.py @@ -86,7 +86,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path): (ROOT / "data/contact_analysis" / name).read_bytes() assert any(name.endswith(".dist-info/licenses/THIRD_PARTY_NOTICES.md") for name in wheel_names) - assert any(name.endswith("-1.3.287.dist-info/METADATA") for name in wheel_names) + assert any(name.endswith("-1.3.288.dist-info/METADATA") for name in wheel_names) source = next(tmp_path.glob("u_jagd-*.tar.gz")) with tarfile.open(source) as archive: @@ -139,7 +139,7 @@ def test_source_and_wheel_contain_editor_templates(tmp_path): [sys.executable, "-c", "from importlib import resources; " "assert resources.files('data.editor_templates').joinpath('mission.json').is_file(); " - "from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.287'; " + "from src.core.version import APP_VERSION; assert APP_VERSION == '1.3.288'; " "from src.commander.server import CommanderServer; " "server=CommanderServer(); server.start('127.0.0.1',0); server.stop(); " "from src.core import manual; page=manual.html_page('de'); assert 'station-sonar' in page; " diff --git a/tests/test_startup.py b/tests/test_startup.py index 1a502c1a..babcf378 100644 --- a/tests/test_startup.py +++ b/tests/test_startup.py @@ -14,9 +14,9 @@ from src.world.real_coast import sector_for_seed def test_release_version_and_exact_splash_text(): - assert APP_VERSION == "1.3.287" + assert APP_VERSION == "1.3.288" assert SPLASH_TEXT == ( - "Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.287" + "Anti Sub Marine Warfare on uConsole by Dominik Bornhäußer Version 1.3.288" )