| @@ -47,8 +47,18 @@ | ||
| 47 | 47 | 'title' => __( 'Inkfall', 'desktop-mode' ), |
| 48 | 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 | 49 | 'icon_svg' => openstation_inkfall_icon_svg(), |
| 50 | 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 | + ), | |
| 51 | 61 | 'score_columns' => array( |
| 52 | 62 | array( |
| 53 | 63 | 'key' => 'score', |
| 54 | 64 | 'label' => __( 'Score', 'desktop-mode' ), |
| @@ -92,15 +102,23 @@ | ||
| 92 | 102 | } |
| 93 | 103 | add_action( 'init', 'openstation_inkfall_register', 20 ); |
| 94 | 104 | |
| 95 | 105 | /** |
| 96 | - * Enqueue the Inkfall window styles. The game's script is lazily | |
| 97 | - * loaded by the framework on first launch, but its CSS is tiny and | |
| 98 | - * must already be present when the window opens. | |
| 106 | + * Ride the Inkfall window styles on the Games window as a companion. | |
| 107 | + * | |
| 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 | |
| 99 | 115 | */ |
| 100 | -function openstation_inkfall_enqueue_styles() { | |
| 101 | - if ( ! function_exists( 'openstation_games_user_can_use' ) || ! openstation_games_user_can_use() ) { | |
| 102 | - return; | |
| 116 | +function openstation_inkfall_window_styles( $window_args ) { | |
| 117 | + if ( ! is_array( $window_args ) ) { | |
| 118 | + return $window_args; | |
| 103 | 119 | } |
| 104 | - wp_enqueue_style( 'os-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; | |
| 105 | 123 | } |
| 106 | -add_action( 'admin_enqueue_scripts', 'openstation_inkfall_enqueue_styles', 30 ); | |
| 124 | +add_filter( 'openstation_games_window_args', 'openstation_inkfall_window_styles' ); | |