| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Desktop Mode — Alphabet Soup registration. | |
| 3 | + * OpenStation — Alphabet Soup registration. | |
| 4 | 4 | * |
| 5 | 5 | * Alphabet Soup is the built-in daily word search: a seeded letter |
| 6 | 6 | * grid with hidden words to drag out of the soup. The seed is the |
| 7 | 7 | * current date (`dd-mm-yyyy`), so every player worldwide gets the |
| @@ -12,10 +12,9 @@ | ||
| 12 | 12 | * `src/games/alphabet-soup/`); this file only declares the |
| 13 | 13 | * discovery metadata + score columns. The shared dictionary asset |
| 14 | 14 | * arrives via the framework-injected `wordsUrl` config key. |
| 15 | 15 | * |
| 16 | - * @package WPDesktopMode | |
| 17 | - * @since 0.9.8 | |
| 16 | + * @package OpenStation | |
| 18 | 17 | */ |
| 19 | 18 | |
| 20 | 19 | defined( 'ABSPATH' ) || exit; |
| 21 | 20 | |
| @@ -21,13 +20,11 @@ | ||
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | 22 | * The Alphabet Soup icon: a steaming bowl with letter tiles afloat. |
| 24 | 23 | * |
| 25 | - * @since 0.9.8 | |
| 26 | - * | |
| 27 | 24 | * @return string Raw `<svg>` markup. |
| 28 | 25 | */ |
| 29 | -function desktop_mode_alphabet_soup_icon_svg() { | |
| 26 | +function openstation_alphabet_soup_icon_svg() { | |
| 30 | 27 | return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">' |
| 31 | 28 | . '<path fill="#2b1d4d" d="M8 30h48a2 2 0 0 1 2 2c0 10-6 18-14 21l-1 3H21l-1-3C12 50 6 42 6 32a2 2 0 0 1 2-2z"/>' |
| 32 | 29 | . '<ellipse cx="32" cy="30" rx="24" ry="5" fill="#4c3585"/>' |
| 33 | 30 | . '<rect x="16" y="22" width="11" height="11" rx="2.5" fill="#ffd166" transform="rotate(-8 21.5 27.5)"/>' |
| @@ -43,48 +40,99 @@ | ||
| 43 | 40 | /** |
| 44 | 41 | * Register Alphabet Soup with the games registry on `init`. |
| 45 | 42 | * |
| 46 | 43 | * Priority 20 — alongside the Games window registration. |
| 47 | - * | |
| 48 | - * @since 0.9.8 | |
| 49 | 44 | */ |
| 50 | -function desktop_mode_alphabet_soup_register() { | |
| 51 | - if ( ! function_exists( 'desktop_mode_games_user_can_use' ) || ! desktop_mode_games_user_can_use() ) { | |
| 45 | +function openstation_alphabet_soup_register() { | |
| 46 | + if ( ! function_exists( 'openstation_games_user_can_use' ) || ! openstation_games_user_can_use() ) { | |
| 52 | 47 | return; |
| 53 | 48 | } |
| 54 | 49 | |
| 55 | - desktop_mode_register_game( 'alphabet-soup', array( | |
| 56 | - 'title' => __( 'Alphabet Soup', 'desktop-mode' ), | |
| 57 | - 'description' => __( 'The daily word search: a seeded letter soup that is the same for every player worldwide — the seed is today’s date. Pick a pot (8×8, 12×12, or 16×16 with more words), drag across the letters to fish them out, chain streaks, and clear waves; Time Attack stirs a different pot against the clock. Your first run of each puzzle earns the shareable score card.', 'desktop-mode' ), | |
| 58 | - 'icon_svg' => desktop_mode_alphabet_soup_icon_svg(), | |
| 59 | - 'script' => 'desktop-mode-game-alphabet-soup', | |
| 60 | - 'score_columns' => array( | |
| 61 | - array( 'key' => 'score', 'label' => __( 'Score', 'desktop-mode' ), 'type' => 'number' ), | |
| 62 | - array( 'key' => 'mode', 'label' => __( 'Mode', 'desktop-mode' ), 'type' => 'text' ), | |
| 63 | - array( 'key' => 'size', 'label' => __( 'Size', 'desktop-mode' ), 'type' => 'text' ), | |
| 64 | - array( 'key' => 'words', 'label' => __( 'Words', 'desktop-mode' ), 'type' => 'number' ), | |
| 65 | - array( 'key' => 'wpm', 'label' => __( 'WPM', 'desktop-mode' ), 'type' => 'number' ), | |
| 66 | - array( 'key' => 'accuracy', 'label' => __( 'Accuracy', 'desktop-mode' ), 'type' => 'number' ), | |
| 67 | - array( 'key' => 'streak', 'label' => __( 'Streak', 'desktop-mode' ), 'type' => 'number' ), | |
| 68 | - array( 'key' => 'wave', 'label' => __( 'Wave', 'desktop-mode' ), 'type' => 'number' ), | |
| 69 | - array( 'key' => 'time', 'label' => __( 'Time', 'desktop-mode' ), 'type' => 'time' ), | |
| 70 | - ), | |
| 50 | + openstation_register_game( | |
| 51 | + 'alphabet-soup', | |
| 52 | + array( | |
| 53 | + 'title' => __( 'Alphabet Soup', 'desktop-mode' ), | |
| 54 | + 'description' => __( 'The daily word search: a seeded letter soup that is the same for every player worldwide — the seed is today’s date. Pick a pot (8×8, 12×12, or 16×16 with more words), drag across the letters to fish them out, chain streaks, and clear waves; Time Attack stirs a different pot against the clock. Your first run of each puzzle earns the shareable score card.', 'desktop-mode' ), | |
| 55 | + 'icon_svg' => openstation_alphabet_soup_icon_svg(), | |
| 56 | + 'script' => 'os-game-alphabet-soup', | |
| 57 | + // Mirrors the `window` block in | |
| 58 | + // `src/games/alphabet-soup/index.ts`. Declared here as well | |
| 59 | + // so the window opens at the right size on the very first | |
| 60 | + // play, before the bundle that carries the def has been | |
| 61 | + // fetched. Keep the two in step. | |
| 62 | + 'window' => array( | |
| 63 | + 'width' => 860, | |
| 64 | + 'height' => 660, | |
| 65 | + 'minWidth' => 600, | |
| 66 | + 'minHeight' => 500, | |
| 67 | + ), | |
| 68 | + 'score_columns' => array( | |
| 69 | + array( | |
| 70 | + 'key' => 'score', | |
| 71 | + 'label' => __( 'Score', 'desktop-mode' ), | |
| 72 | + 'type' => 'number', | |
| 73 | + ), | |
| 74 | + array( | |
| 75 | + 'key' => 'mode', | |
| 76 | + 'label' => __( 'Mode', 'desktop-mode' ), | |
| 77 | + 'type' => 'text', | |
| 78 | + ), | |
| 79 | + array( | |
| 80 | + 'key' => 'size', | |
| 81 | + 'label' => __( 'Size', 'desktop-mode' ), | |
| 82 | + 'type' => 'text', | |
| 83 | + ), | |
| 84 | + array( | |
| 85 | + 'key' => 'words', | |
| 86 | + 'label' => __( 'Words', 'desktop-mode' ), | |
| 87 | + 'type' => 'number', | |
| 88 | + ), | |
| 89 | + array( | |
| 90 | + 'key' => 'wpm', | |
| 91 | + 'label' => __( 'WPM', 'desktop-mode' ), | |
| 92 | + 'type' => 'number', | |
| 93 | + ), | |
| 94 | + array( | |
| 95 | + 'key' => 'accuracy', | |
| 96 | + 'label' => __( 'Accuracy', 'desktop-mode' ), | |
| 97 | + 'type' => 'number', | |
| 98 | + ), | |
| 99 | + array( | |
| 100 | + 'key' => 'streak', | |
| 101 | + 'label' => __( 'Streak', 'desktop-mode' ), | |
| 102 | + 'type' => 'number', | |
| 103 | + ), | |
| 104 | + array( | |
| 105 | + 'key' => 'wave', | |
| 106 | + 'label' => __( 'Wave', 'desktop-mode' ), | |
| 107 | + 'type' => 'number', | |
| 108 | + ), | |
| 109 | + array( | |
| 110 | + 'key' => 'time', | |
| 111 | + 'label' => __( 'Time', 'desktop-mode' ), | |
| 112 | + 'type' => 'time', | |
| 113 | + ), | |
| 114 | + ), | |
| 71 | 115 | // The dictionary URL arrives via the framework-injected |
| 72 | 116 | // `wordsUrl` config key (see includes/games/config.php). |
| 73 | - ) ); | |
| 117 | + ) | |
| 118 | + ); | |
| 74 | 119 | } |
| 75 | -add_action( 'init', 'desktop_mode_alphabet_soup_register', 20 ); | |
| 120 | +add_action( 'init', 'openstation_alphabet_soup_register', 20 ); | |
| 76 | 121 | |
| 77 | 122 | /** |
| 78 | - * Enqueue the Alphabet Soup window styles. The game's script is | |
| 79 | - * lazily loaded by the framework on first launch, but its CSS is | |
| 80 | - * tiny and must already be present when the window opens. | |
| 123 | + * Ride the Alphabet Soup window styles on the Games window as a | |
| 124 | + * companion — same shape as Inkfall; see | |
| 125 | + * `openstation_inkfall_window_styles()` for the reasoning. | |
| 81 | 126 | * |
| 82 | - * @since 0.9.8 | |
| 127 | + * @param array $window_args Args passed to `openstation_register_window()`. | |
| 128 | + * @return array | |
| 83 | 129 | */ |
| 84 | -function desktop_mode_alphabet_soup_enqueue_styles() { | |
| 85 | - if ( ! function_exists( 'desktop_mode_games_user_can_use' ) || ! desktop_mode_games_user_can_use() ) { | |
| 86 | - return; | |
| 130 | +function openstation_alphabet_soup_window_styles( $window_args ) { | |
| 131 | + if ( ! is_array( $window_args ) ) { | |
| 132 | + return $window_args; | |
| 87 | 133 | } |
| 88 | - wp_enqueue_style( 'desktop-mode-game-alphabet-soup' ); | |
| 134 | + $window_args['styles'] = isset( $window_args['styles'] ) ? (array) $window_args['styles'] : array(); | |
| 135 | + $window_args['styles'][] = 'os-game-alphabet-soup'; | |
| 136 | + return $window_args; | |
| 89 | 137 | } |
| 90 | -add_action( 'admin_enqueue_scripts', 'desktop_mode_alphabet_soup_enqueue_styles', 30 ); | |
| 138 | +add_filter( 'openstation_games_window_args', 'openstation_alphabet_soup_window_styles' ); | |