PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/games/inkfall.php +77 -35 0.9.61.1.10 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 - * Desktop Mode — Inkfall registration.
3 + * OpenStation — Inkfall registration.
4 4 *
5 5 * Inkfall is the built-in typing game: words fall like ink down a
6 6 * notebook page; typing a word launches a musical note that tears
7 7 * the word apart into scattering letters. The game code lives in
@@ -9,10 +9,9 @@
9 9 * source `src/games/inkfall/`); this file only declares the
10 10 * discovery metadata + score columns. The shared dictionary asset
11 11 * arrives via the framework-injected `wordsUrl` config key.
12 12 *
13 - * @package WPDesktopMode
14 - * @since 0.9.6
13 + * @package OpenStation
15 14 */
16 15
17 16 defined( 'ABSPATH' ) || exit;
18 17
@@ -18,13 +17,11 @@
18 17
19 18 /**
20 19 * The Inkfall icon: a musical note falling onto a notebook page.
21 20 *
22 - * @since 0.9.6
23 - *
24 21 * @return string Raw `<svg>` markup.
25 22 */
26 -function desktop_mode_inkfall_icon_svg() {
23 +function openstation_inkfall_icon_svg() {
27 24 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">'
28 25 . '<rect x="8" y="6" width="48" height="52" rx="6" fill="#f7f3e8"/>'
29 26 . '<line x1="8" y1="20" x2="56" y2="20" stroke="#bcd4e6" stroke-width="2"/>'
30 27 . '<line x1="8" y1="32" x2="56" y2="32" stroke="#bcd4e6" stroke-width="2"/>'
@@ -37,46 +34,91 @@
37 34 /**
38 35 * Register Inkfall with the games registry on `init`.
39 36 *
40 37 * Priority 20 — alongside the Games window registration.
41 - *
42 - * @since 0.9.6
43 38 */
44 -function desktop_mode_inkfall_register() {
45 - if ( ! function_exists( 'desktop_mode_games_user_can_use' ) || ! desktop_mode_games_user_can_use() ) {
39 +function openstation_inkfall_register() {
40 + if ( ! function_exists( 'openstation_games_user_can_use' ) || ! openstation_games_user_can_use() ) {
46 41 return;
47 42 }
48 43
49 - desktop_mode_register_game( 'inkfall', array(
50 - 'title' => __( 'Inkfall', 'desktop-mode' ),
51 - 'description' => __( 'Words fall down a notebook page — type them before they reach the bottom. Finishing a word sends up a musical note that tears it into scattering letters.', 'desktop-mode' ),
52 - 'icon_svg' => desktop_mode_inkfall_icon_svg(),
53 - 'script' => 'desktop-mode-game-inkfall',
54 - 'score_columns' => array(
55 - array( 'key' => 'score', 'label' => __( 'Score', 'desktop-mode' ), 'type' => 'number' ),
56 - array( 'key' => 'mode', 'label' => __( 'Difficulty', 'desktop-mode' ), 'type' => 'text' ),
57 - array( 'key' => 'words', 'label' => __( 'Words', 'desktop-mode' ), 'type' => 'number' ),
58 - array( 'key' => 'wpm', 'label' => __( 'WPM', 'desktop-mode' ), 'type' => 'number' ),
59 - array( 'key' => 'accuracy', 'label' => __( 'Accuracy', 'desktop-mode' ), 'type' => 'number' ),
60 - array( 'key' => 'time', 'label' => __( 'Time', 'desktop-mode' ), 'type' => 'time' ),
61 - array( 'key' => 'level', 'label' => __( 'Level', 'desktop-mode' ), 'type' => 'number' ),
62 - ),
44 + openstation_register_game(
45 + 'inkfall',
46 + array(
47 + 'title' => __( 'Inkfall', 'desktop-mode' ),
48 + 'description' => __( 'Words fall down a notebook page — type them before they reach the bottom. Finishing a word sends up a musical note that tears it into scattering letters.', 'desktop-mode' ),
49 + 'icon_svg' => openstation_inkfall_icon_svg(),
50 + 'script' => 'os-game-inkfall',
51 + // Mirrors the `window` block in `src/games/inkfall/index.ts`.
52 + // Declared here as well so the window opens at the right
53 + // size on the very first play, before the bundle that
54 + // carries the def has been fetched. Keep the two in step.
55 + 'window' => array(
56 + 'width' => 820,
57 + 'height' => 620,
58 + 'minWidth' => 520,
59 + 'minHeight' => 420,
60 + ),
61 + 'score_columns' => array(
62 + array(
63 + 'key' => 'score',
64 + 'label' => __( 'Score', 'desktop-mode' ),
65 + 'type' => 'number',
66 + ),
67 + array(
68 + 'key' => 'mode',
69 + 'label' => __( 'Difficulty', 'desktop-mode' ),
70 + 'type' => 'text',
71 + ),
72 + array(
73 + 'key' => 'words',
74 + 'label' => __( 'Words', 'desktop-mode' ),
75 + 'type' => 'number',
76 + ),
77 + array(
78 + 'key' => 'wpm',
79 + 'label' => __( 'WPM', 'desktop-mode' ),
80 + 'type' => 'number',
81 + ),
82 + array(
83 + 'key' => 'accuracy',
84 + 'label' => __( 'Accuracy', 'desktop-mode' ),
85 + 'type' => 'number',
86 + ),
87 + array(
88 + 'key' => 'time',
89 + 'label' => __( 'Time', 'desktop-mode' ),
90 + 'type' => 'time',
91 + ),
92 + array(
93 + 'key' => 'level',
94 + 'label' => __( 'Level', 'desktop-mode' ),
95 + 'type' => 'number',
96 + ),
97 + ),
63 98 // The dictionary URL arrives via the framework-injected
64 99 // `wordsUrl` config key (see includes/games/config.php).
65 - ) );
100 + )
101 + );
66 102 }
67 -add_action( 'init', 'desktop_mode_inkfall_register', 20 );
103 +add_action( 'init', 'openstation_inkfall_register', 20 );
68 104
69 105 /**
70 - * Enqueue the Inkfall window styles. The game's script is lazily
71 - * loaded by the framework on first launch, but its CSS is tiny and
72 - * must already be present when the window opens.
106 + * Ride the Inkfall window styles on the Games window as a companion.
73 107 *
74 - * @since 0.9.6
108 + * The game's script is lazily loaded by the framework on first
109 + * launch, and every launch goes through the games bundle — so a
110 + * sheet travelling with that bundle is in the tab before the game
111 + * window paints, without costing every admin page that never plays.
112 + *
113 + * @param array $window_args Args passed to `openstation_register_window()`.
114 + * @return array
75 115 */
76 -function desktop_mode_inkfall_enqueue_styles() {
77 - if ( ! function_exists( 'desktop_mode_games_user_can_use' ) || ! desktop_mode_games_user_can_use() ) {
78 - return;
116 +function openstation_inkfall_window_styles( $window_args ) {
117 + if ( ! is_array( $window_args ) ) {
118 + return $window_args;
79 119 }
80 - wp_enqueue_style( 'desktop-mode-game-inkfall' );
120 + $window_args['styles'] = isset( $window_args['styles'] ) ? (array) $window_args['styles'] : array();
121 + $window_args['styles'][] = 'os-game-inkfall';
122 + return $window_args;
81 123 }
82 -add_action( 'admin_enqueue_scripts', 'desktop_mode_inkfall_enqueue_styles', 30 );
124 +add_filter( 'openstation_games_window_args', 'openstation_inkfall_window_styles' );