PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.7
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.7
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 0.9.7, at includes/games/inkfall.php

83 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 * Desktop Mode — 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 WPDesktopMode
14 * @since 0.9.6
15 */
16
17 defined( 'ABSPATH' ) || exit;
18
19 /**
20 * The Inkfall icon: a musical note falling onto a notebook page.
21 *
22 * @since 0.9.6
23 *
24 * @return string Raw `<svg>` markup.
25 */
26 function desktop_mode_inkfall_icon_svg() {
27 return '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">'
28 . '<rect x="8" y="6" width="48" height="52" rx="6" fill="#f7f3e8"/>'
29 . '<line x1="8" y1="20" x2="56" y2="20" stroke="#bcd4e6" stroke-width="2"/>'
30 . '<line x1="8" y1="32" x2="56" y2="32" stroke="#bcd4e6" stroke-width="2"/>'
31 . '<line x1="8" y1="44" x2="56" y2="44" stroke="#bcd4e6" stroke-width="2"/>'
32 . '<line x1="18" y1="6" x2="18" y2="58" stroke="#e8a1a1" stroke-width="2"/>'
33 . '<path fill="#2b3a55" d="M40 14v18.6a7 7 0 1 0 3 5.7V22l8 2v-6l-11-4z"/>'
34 . '</svg>';
35 }
36
37 /**
38 * Register Inkfall with the games registry on `init`.
39 *
40 * Priority 20 — alongside the Games window registration.
41 *
42 * @since 0.9.6
43 */
44 function desktop_mode_inkfall_register() {
45 if ( ! function_exists( 'desktop_mode_games_user_can_use' ) || ! desktop_mode_games_user_can_use() ) {
46 return;
47 }
48
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 ),
63 // The dictionary URL arrives via the framework-injected
64 // `wordsUrl` config key (see includes/games/config.php).
65 ) );
66 }
67 add_action( 'init', 'desktop_mode_inkfall_register', 20 );
68
69 /**
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.
73 *
74 * @since 0.9.6
75 */
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;
79 }
80 wp_enqueue_style( 'desktop-mode-game-inkfall' );
81 }
82 add_action( 'admin_enqueue_scripts', 'desktop_mode_inkfall_enqueue_styles', 30 );
83