PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.0
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.0
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
desktop-mode / includes / games / inkfall.php

inkfall.php in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 1.1.0, at includes/games/inkfall.php

107 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * OpenStation — Inkfall registration.
4 *
5 * Inkfall is the built-in typing game: words fall like ink down a
6 * notebook page; typing a word launches a musical note that tears
7 * the word apart into scattering letters. The game code lives in
8 * its own lazily-loaded bundle (`assets/js/game-inkfall[.min].js`,
9 * source `src/games/inkfall/`); this file only declares the
10 * discovery metadata + score columns. The shared dictionary asset
11 * arrives via the framework-injected `wordsUrl` config key.
12 *
13 * @package OpenStation
14 */
15
16 defined( 'ABSPATH' ) || exit;
17
18 /**
19 * The Inkfall icon: a musical note falling onto a notebook page.
20 *
21 * @return string Raw `<svg>` markup.
22 */
23 function openstation_inkfall_icon_svg() {
24 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">'
25 . '<rect x="8" y="6" width="48" height="52" rx="6" fill="#f7f3e8"/>'
26 . '<line x1="8" y1="20" x2="56" y2="20" stroke="#bcd4e6" stroke-width="2"/>'
27 . '<line x1="8" y1="32" x2="56" y2="32" stroke="#bcd4e6" stroke-width="2"/>'
28 . '<line x1="8" y1="44" x2="56" y2="44" stroke="#bcd4e6" stroke-width="2"/>'
29 . '<line x1="18" y1="6" x2="18" y2="58" stroke="#e8a1a1" stroke-width="2"/>'
30 . '<path fill="#2b3a55" d="M40 14v18.6a7 7 0 1 0 3 5.7V22l8 2v-6l-11-4z"/>'
31 . '</svg>';
32 }
33
34 /**
35 * Register Inkfall with the games registry on `init`.
36 *
37 * Priority 20 — alongside the Games window registration.
38 */
39 function openstation_inkfall_register() {
40 if ( ! function_exists( 'openstation_games_user_can_use' ) || ! openstation_games_user_can_use() ) {
41 return;
42 }
43
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 'score_columns' => array(
52 array(
53 'key' => 'score',
54 'label' => __( 'Score', 'desktop-mode' ),
55 'type' => 'number',
56 ),
57 array(
58 'key' => 'mode',
59 'label' => __( 'Difficulty', 'desktop-mode' ),
60 'type' => 'text',
61 ),
62 array(
63 'key' => 'words',
64 'label' => __( 'Words', 'desktop-mode' ),
65 'type' => 'number',
66 ),
67 array(
68 'key' => 'wpm',
69 'label' => __( 'WPM', 'desktop-mode' ),
70 'type' => 'number',
71 ),
72 array(
73 'key' => 'accuracy',
74 'label' => __( 'Accuracy', 'desktop-mode' ),
75 'type' => 'number',
76 ),
77 array(
78 'key' => 'time',
79 'label' => __( 'Time', 'desktop-mode' ),
80 'type' => 'time',
81 ),
82 array(
83 'key' => 'level',
84 'label' => __( 'Level', 'desktop-mode' ),
85 'type' => 'number',
86 ),
87 ),
88 // The dictionary URL arrives via the framework-injected
89 // `wordsUrl` config key (see includes/games/config.php).
90 )
91 );
92 }
93 add_action( 'init', 'openstation_inkfall_register', 20 );
94
95 /**
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.
99 */
100 function openstation_inkfall_enqueue_styles() {
101 if ( ! function_exists( 'openstation_games_user_can_use' ) || ! openstation_games_user_can_use() ) {
102 return;
103 }
104 wp_enqueue_style( 'os-game-inkfall' );
105 }
106 add_action( 'admin_enqueue_scripts', 'openstation_inkfall_enqueue_styles', 30 );
107