Launcher: a blocky, Minecraft-like look in dark and light
Blocks palettes (dark default, light, or the system's, chosen in Settings), Pixelify Sans for headings and controls, Pixelarticons icons, square panels with an outline, a bevel and a lip, inventory tabs, and pixel art drawn in code: a stone texture behind the pages and a landscape behind Home. A top bar with the pages and the account chip, and a sidebar with the instances (Horizon shows the grass block the mod browser draws from the player's prepared textures), the hosted servers, and the launcher's version and channel. The mod browser's pages (kinds as tabs, project icons in slots, verdicts as badges, the project page) are restyled, not rebuilt. The benchmark also measures scrolling the Versions list. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@@ -36,3 +36,15 @@ SOFTWARE.
|
||||
developers, with one upstream fix applied
|
||||
([gfx-rs/wgpu#10124](https://github.com/gfx-rs/wgpu/pull/10124)). It is licensed under MIT or
|
||||
Apache-2.0; both licenses are in that folder (`LICENSE.MIT`, `LICENSE.APACHE`).
|
||||
|
||||
## Pixelify Sans
|
||||
|
||||
`crates/horizon-theme/fonts/PixelifySans-*.ttf` is [Pixelify Sans](https://github.com/eifetx/Pixelify-Sans)
|
||||
by The Pixelify Sans Project Authors, licensed under the SIL Open Font License 1.1
|
||||
(`crates/horizon-theme/fonts/OFL-PixelifySans.txt`).
|
||||
|
||||
## Pixelarticons
|
||||
|
||||
`crates/horizon-theme/icons/pixel/*.svg` are icons from
|
||||
[Pixelarticons](https://github.com/halfmage/pixelarticons) by Gerrit Halfmann, under the MIT
|
||||
license (`crates/horizon-theme/icons/pixel/LICENSE-pixelarticons.txt`).
|
||||
|
||||
@@ -3,6 +3,6 @@ name = "horizon-theme"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
license = "MIT"
|
||||
description = "Horizon's design tokens and fonts, shared by the launcher and the game's menus"
|
||||
description = "Horizon's design tokens, fonts and icons, shared by the launcher, the website and the game's menus"
|
||||
|
||||
[dependencies]
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
Copyright 2021 The Pixelify Sans Project Authors (https://github.com/eifetx/Pixelify-Sans)
|
||||
|
||||
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||
This license is copied below, and is also available with a FAQ at:
|
||||
https://scripts.sil.org/OFL
|
||||
|
||||
|
||||
-----------------------------------------------------------
|
||||
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||
-----------------------------------------------------------
|
||||
|
||||
PREAMBLE
|
||||
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||
development of collaborative font projects, to support the font creation
|
||||
efforts of academic and linguistic communities, and to provide a free and
|
||||
open framework in which fonts may be shared and improved in partnership
|
||||
with others.
|
||||
|
||||
The OFL allows the licensed fonts to be used, studied, modified and
|
||||
redistributed freely as long as they are not sold by themselves. The
|
||||
fonts, including any derivative works, can be bundled, embedded,
|
||||
redistributed and/or sold with any software provided that any reserved
|
||||
names are not used by derivative works. The fonts and derivatives,
|
||||
however, cannot be released under any other type of license. The
|
||||
requirement for fonts to remain under this license does not apply
|
||||
to any document created using the fonts or their derivatives.
|
||||
|
||||
DEFINITIONS
|
||||
"Font Software" refers to the set of files released by the Copyright
|
||||
Holder(s) under this license and clearly marked as such. This may
|
||||
include source files, build scripts and documentation.
|
||||
|
||||
"Reserved Font Name" refers to any names specified as such after the
|
||||
copyright statement(s).
|
||||
|
||||
"Original Version" refers to the collection of Font Software components as
|
||||
distributed by the Copyright Holder(s).
|
||||
|
||||
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||
or substituting -- in part or in whole -- any of the components of the
|
||||
Original Version, by changing formats or by porting the Font Software to a
|
||||
new environment.
|
||||
|
||||
"Author" refers to any designer, engineer, programmer, technical
|
||||
writer or other person who contributed to the Font Software.
|
||||
|
||||
PERMISSION & CONDITIONS
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||
redistribute, and sell modified and unmodified copies of the Font
|
||||
Software, subject to the following conditions:
|
||||
|
||||
1) Neither the Font Software nor any of its individual components,
|
||||
in Original or Modified Versions, may be sold by itself.
|
||||
|
||||
2) Original or Modified Versions of the Font Software may be bundled,
|
||||
redistributed and/or sold with any software, provided that each copy
|
||||
contains the above copyright notice and this license. These can be
|
||||
included either as stand-alone text files, human-readable headers or
|
||||
in the appropriate machine-readable metadata fields within text or
|
||||
binary files as long as those fields can be easily viewed by the user.
|
||||
|
||||
3) No Modified Version of the Font Software may use the Reserved Font
|
||||
Name(s) unless explicit written permission is granted by the corresponding
|
||||
Copyright Holder. This restriction only applies to the primary font name as
|
||||
presented to the users.
|
||||
|
||||
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||
Software shall not be used to promote, endorse or advertise any
|
||||
Modified Version, except to acknowledge the contribution(s) of the
|
||||
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||
permission.
|
||||
|
||||
5) The Font Software, modified or unmodified, in part or in whole,
|
||||
must be distributed entirely under this license, and must not be
|
||||
distributed under any other license. The requirement for fonts to
|
||||
remain under this license does not apply to any document created
|
||||
using the Font Software.
|
||||
|
||||
TERMINATION
|
||||
This license becomes null and void if any of the above conditions are
|
||||
not met.
|
||||
|
||||
DISCLAIMER
|
||||
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Gerrit Halfmann
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M3 2h18v2H3zm0 5h18v2H3zM1 4h2v3H1zm20 0h2v3h-2zm-2 5h2v11h-2zM3 9h2v11H3zm2 11h14v2H5zm4-9h6v2H9z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 224 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M20 11v2H4v-2zM8 13v2H6v-2zm2 2v2H8v-2zm2 2v2h-2v-2zm-4-6V9H6v2z"/>
|
||||
<path d="M10 15V7H8v8zm2 2V5h-2v12z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 231 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M2 3h9v2H2zM0 19h11v2H0zM13 3h9v2h-9zm0 16h11v2H13zM11 5h2v18h-2zM0 5h2v14H0zm22 0h2v14h-2zm-7 2h5v2h-5zm0 4h5v2h-5zm0 4h2v2h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 254 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M14 4h4v2h-4zm-4-2h4v2h-4zM6 8h4v2H6zm0 10h4v2H6zm4-8h4v2h-4zm0 10h4v2h-4zm4-12h4v2h-4zm0 10h4v2h-4zM6 4h4v2H6zM2 6h4v2H2zm0 10h4v2H2zM18 6h4v2h-4zm0 10h4v2h-4z"/>
|
||||
<path d="M2 6h2v12H2zm18 0h2v12h-2zm-8 6h2v8h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 340 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M2 5h2v4H2zm20 0h-2v4h2zM4 9h2v2H4zm16 0h-2v2h2zM2 13h4v2H2zm20 0h-4v2h4zM4 17h2v2H4zm16 0h-2v2h2zM2 19h2v2H2zm20 0h-2v2h2zM6 11h12v2H6z"/>
|
||||
<path d="M6 7h2v12H6zm10 0h2v12h-2zM8 19h8v2H8zM8 5h8v2H8z"/>
|
||||
<path d="M11 15h2v6h-2zM8 1h2v6H8zm6 0h2v6h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 378 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M10 18H8v-2h2v2Zm-2-2H6v-2h2v2Zm4-2v2h-2v-2h2Zm-6 0H4v-2h2v2Zm8 0h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2V8h2v2Zm2-2h-2V6h2v2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 245 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M13 16h-2v-2h2v2Zm-2-2H9v-2h2v2Zm4 0h-2v-2h2v2Zm-6-2H7v-2h2v2Zm8 0h-2v-2h2v2ZM7 10H5V8h2v2Zm12 0h-2V8h2v2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 232 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M16 13v-2h-2v2h2Zm-2-2V9h-2v2h2Zm0 4v-2h-2v2h2Zm-2-6V7h-2v2h2Zm0 8v-2h-2v2h2ZM10 7V5H8v2h2Zm0 12v-2H8v2h2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 232 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M6 2h12v2H6zM2 6h2v12H2zm18 0h2v12h-2zm-2-2h2v2h-2zM4 4h2v2H4zm2 18h12v-2H6zm12-2h2v-2h-2zM4 20h2v-2H4zm7-14h2v7h-2zm2 7h2v2h-2zm2 2h2v2h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 266 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M7 19H5V17H7V19ZM19 19H17V17H19V19ZM9 15V17H7V15H9ZM17 17H15V15H17V17ZM11 15H9V13H11V15ZM15 15H13V13H15V15ZM13 13H11V11H13V13ZM11 11H9V9H11V11ZM15 11H13V9H15V11ZM9 9H7V7H9V9ZM17 9H15V7H17V9ZM7 7H5V5H7V7ZM19 7H17V5H19V7Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 343 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M21 15v4h-2v-4zm-2 4v2H5v-2zM5 15v4H3v-4zm8-12v14h-2V3z"/>
|
||||
<path d="M7 11v2h10v-2zm2 2v2h2v-2zm4 0v2h2v-2z"/>
|
||||
<path d="M15 11v2h2v-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 263 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M11 5H5v2h6V5ZM5 7H3v12h2V7Zm12 12H5v2h12v-2Zm2-6h-2v6h2v-6Zm-8 0H9v2h2v-2Zm2-2h-2v2h2v-2Zm2-2h-2v2h2V9Zm2-2h-2v2h2V7Zm2-2h-2v2h2V5Zm2-2h-2v8h2V3Z"/>
|
||||
<path d="M21 3h-8v2h8V3Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 302 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 4h6v2H4zm0 14h16v2H4zM20 8h2v10h-2zM2 6h2v12H2zm8 0h10v2H10z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 189 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 4h16v2H4zm0 14h16v2H4zM2 6h2v12H2zm18 0h2v12h-2zM8 9h2v6H8z"/>
|
||||
<path d="M6 11h6v2H6zm8-2h2v2h-2zm2 4h2v2h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 239 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M6 2h12v2H6zm0 18h12v2H6zM4 4h2v2H4zm5 0h2v2H9zm0 14h2v2H9zm4 0h2v2h-2zM7 6h2v12H7zm8 0h2v12h-2zm-2-2h2v2h-2zm7 0h-2v2h2zM2 6h2v12H2zm20 0h-2v12h2zM4 18h2v2H4zm16 0h-2v2h2z"/>
|
||||
<path d="M3 11h18v2H3z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 326 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M13 22h-2v-2h2v2Zm-2-2H9v-2h2v2Zm4 0h-2v-2h2v2Zm-6-2H7v-2h2v2Zm8 0h-2v-2h2v2ZM7 16H5v-2h2v2Zm12 0h-2v-2h2v2ZM5 14H3v-2h2v2Zm16 0h-2v-2h2v2ZM3 12H1V6h2v6Zm20 0h-2V6h2v6ZM13 8h-2V6h2v2ZM5 6H3V4h2v2Zm6 0H9V4h2v2Zm4 0h-2V4h2v2Zm6 0h-2V4h2v2ZM9 4H5V2h4v2Zm10 0h-4V2h4v2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 391 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 20h16v2H4zm16-10h2v10h-2zM2 10h2v10H2zm2-2h2v2H4zm2-2h2v2H6zm2-2h2v2H8zm2-2h4v2h-4zm4 2h2v2h-2zm2 2h2v2h-2zm2 2h2v2h-2zM8 14h2v6H8zm2-2h4v2h-4zm4 2h2v6h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 284 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 2h16v2H4zm0 18h16v2H4zM2 4h2v16H2zm18 0h2v16h-2zm-4 8h2v2h-2zm-2 2h2v2h-2zm4 0h2v2h-2zm-8 0h2v2h-2zm2 2h2v2h-2zm2 2h2v2h-2z"/>
|
||||
<path d="M20 16h2v2h-2zM8 16h2v2H8zm-2 2h2v2H6zM8 6h2v2H8zM6 8h2v2H6zm2 2h2v2H8zm2-2h2v2h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 350 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 2h16v2H4zm0 18h16v2H4zM2 4h2v16H2zm18 0h2v16h-2zm-9 5h2V7h-2zm0 8h2v-6h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 203 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M20 2H4v2h16zm0 14H6v2h14zm2-12h-2v12h2zM4 4H2v18h2zm2 14H4v2h2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 190 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 2h16v2H4zm0 14h16v2H4zM2 4h2v12H2zm18 0h2v12h-2zm-9 14h2v2h-2zm-3 2h8v2H8z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 203 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M6 8h2v12H6zM2 4h2v12H2zm18 4h2v8h-2zM8 6h12v2H8zM4 2h12v2H4zm14 14h2v2h-2zm-2 2h2v2h-2zm-8 2h8v2H8zm6-6h6v2h-6z"/>
|
||||
<path d="M14 14h2v6h-2zm2-10h2v2h-2zM4 16h2v2H4z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 292 B |
@@ -0,0 +1,4 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M10 20h4v2h-4zm0-16h4V2h-4zm0 6h4v2h-4zm4 8h4v2h-4zm0-12h4V4h-4zm0 2h4v2h-4zm4 8h4v2h-4zm0-8h4V6h-4zM6 18h4v2H6zM6 6h4V4H6zm0 2h4v2H6zm-4 8h4v2H2zm0-8h4V6H2z"/>
|
||||
<path d="M2 6h2v12H2zm18 0h2v12h-2zm-8 6h2v8h-2zm-2-6h4v2h-4z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 350 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M15 11h-2V9h2zm0 4h-2v-2h2zm-2 2h-2v-2h2zm0-8h-2V7h2zm-2-2H9V5h2zM9 21H7V3h2zm6-8h2v-2h-2zm-6 4h2v2H9z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 228 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M13 11h7v2h-7v7h-2v-7H4v-2h7V4h2v7Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 161 B |
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M16 4h2v6h-2zm-2-2h2v2h-2zm0 2h2v8h-2zM4 8H2v5h2z"/>
|
||||
<path d="M4 6h16v2H4zm4 14H6v-6h2zm2 2H8v-2h2zm0-2H8v-8h2zm10-4h2v-5h-2z"/>
|
||||
<path d="M20 18H4v-2h16z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 283 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M22 22h-2v-2h2v2Zm-2-2h-2v-2h2v2Zm-6-2H6v-2h8v2Zm4 0h-2v-2h2v2ZM6 16H4v-2h2v2Zm10 0h-2v-2h2v2ZM4 14H2V6h2v8Zm14 0h-2V6h2v8ZM6 6H4V4h2v2Zm10 0h-2V4h2v2Zm-2-2H6V2h8v2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 291 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M6 7h4v2H6zm0 8h4v2H6zM2 5h2v14H2zm18 0h2v14h-2zM4 19h16v2H4zM4 3h16v2H4zm0 8h16v2H4z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 211 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24"><path d="M8 14H7v6H5v-6H2v-2h6v2Zm5 6h-2V10h2v10Zm9-2h-3v2h-2v-2h-1v-2h6v2Zm-3-4h-2V4h2v10ZM7 10H5V4h2v6Zm6-4h2v2H9V6h2V4h2v2Z"/></svg>
|
||||
|
After Width: | Height: | Size: 215 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 2h16v2H4zm0 18h16v2H4zM2 4h2v16H2zm18 0h2v16h-2zM6 16h2v2H6zm2-2h2v2H8zm-2-2h2v2H6z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 212 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M18 22H6V20H18V22ZM9 6H15V4H17V6H22V8H20V20H18V8H6V20H4V8H2V6H7V4H9V6ZM15 4H9V2H15V4Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 209 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M9 2h6v2H9zm0 8h6v2H9zm6-6h2v6h-2zM7 4h2v6H7zM4 18h2v4H4zm14 0h2v4h-2zM8 14h8v2H8zm-2 2h2v2H6zm10 0h2v2h-2z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 233 B |
@@ -0,0 +1,3 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
|
||||
<path d="M4 13h8v6h2v2h-2v2h-2v-8H2v-4h2v2Zm12 6h-2v-2h2v2Zm2-2h-2v-2h2v2Zm2-2h-2v-2h2v2Zm-6-6h8v4h-2v-2h-8V5h-2V3h2V1h2v8Zm-8 2H4V9h2v2Zm2-2H6V7h2v2Zm2-2H8V5h2v2Z"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 280 B |
@@ -11,6 +11,9 @@ use std::time::Duration;
|
||||
|
||||
pub const FONT: &str = "Geist";
|
||||
pub const MONO: &str = "Geist Mono";
|
||||
/// The launcher's and the website's display face (headings, navigation, buttons, badges only):
|
||||
/// Pixelify Sans, bundled under the SIL Open Font License (`fonts/OFL-PixelifySans.txt`).
|
||||
pub const PIXEL: &str = "Pixelify Sans";
|
||||
|
||||
/// The bundled font files.
|
||||
pub mod fonts {
|
||||
@@ -18,6 +21,62 @@ pub mod fonts {
|
||||
pub const GEIST_MEDIUM: &[u8] = include_bytes!("../fonts/Geist-Medium.ttf");
|
||||
pub const GEIST_SEMIBOLD: &[u8] = include_bytes!("../fonts/Geist-SemiBold.ttf");
|
||||
pub const GEIST_MONO: &[u8] = include_bytes!("../fonts/GeistMono-Regular.ttf");
|
||||
pub const PIXEL_MEDIUM: &[u8] = include_bytes!("../fonts/PixelifySans-Medium.ttf");
|
||||
pub const PIXEL_SEMIBOLD: &[u8] = include_bytes!("../fonts/PixelifySans-SemiBold.ttf");
|
||||
pub const PIXEL_BOLD: &[u8] = include_bytes!("../fonts/PixelifySans-Bold.ttf");
|
||||
}
|
||||
|
||||
/// The launcher's pixel icons: Pixelarticons (MIT, `icons/pixel/LICENSE-pixelarticons.txt`), 24
|
||||
/// unit SVGs filled with `currentColor`, by name (`"home"`, `"play"`…).
|
||||
pub mod icons {
|
||||
macro_rules! icons {
|
||||
($($name:literal),* $(,)?) => {
|
||||
/// Every icon, `(name, svg)`.
|
||||
pub const ALL: &[(&str, &[u8])] = &[
|
||||
$(($name, include_bytes!(concat!("../icons/pixel/", $name, ".svg")))),*
|
||||
];
|
||||
};
|
||||
}
|
||||
icons!(
|
||||
"archive",
|
||||
"arrow-left",
|
||||
"book-open",
|
||||
"box",
|
||||
"bug",
|
||||
"check",
|
||||
"chevron-down",
|
||||
"chevron-right",
|
||||
"clock",
|
||||
"close",
|
||||
"download",
|
||||
"external-link",
|
||||
"folder",
|
||||
"gamepad",
|
||||
"globe",
|
||||
"heart",
|
||||
"home",
|
||||
"image",
|
||||
"info-box",
|
||||
"message",
|
||||
"monitor",
|
||||
"notes",
|
||||
"package",
|
||||
"play",
|
||||
"plus",
|
||||
"reload",
|
||||
"search",
|
||||
"server",
|
||||
"sliders",
|
||||
"terminal",
|
||||
"trash",
|
||||
"user",
|
||||
"zap",
|
||||
);
|
||||
|
||||
/// An icon's SVG by name.
|
||||
pub fn get(name: &str) -> Option<&'static [u8]> {
|
||||
ALL.iter().find(|(n, _)| *n == name).map(|(_, svg)| *svg)
|
||||
}
|
||||
}
|
||||
|
||||
/// Horizon's icon at 64 px (PNG), for window title bars and task bars at run time. Rendered from
|
||||
@@ -275,6 +334,113 @@ pub const DARK: Palette = Palette {
|
||||
dark: true,
|
||||
};
|
||||
|
||||
/// The launcher's and the website's blocky look ("Blocks" in `docs/design-system.md`): stone-dark
|
||||
/// (or lavender-light) neutrals with a violet cast, panels with a dark outline, a light bevel on top
|
||||
/// and a darker lip below, and the violet `face` of the one big action. The game's menus keep
|
||||
/// [`LIGHT`] and [`DARK`].
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct Blocks {
|
||||
/// The window behind everything, tiled with a faint stone texture.
|
||||
pub page: u32,
|
||||
/// The top bar and the sidebar.
|
||||
pub side: u32,
|
||||
/// Panels: rows, cards, dialogs.
|
||||
pub panel: u32,
|
||||
/// A selected or hovered panel or row, the open tab.
|
||||
pub raised: u32,
|
||||
/// Buttons and the chosen segment.
|
||||
pub button: u32,
|
||||
/// A button's top bevel.
|
||||
pub button_bevel: u32,
|
||||
/// Sunk wells: fields, tracks, switch and checkbox boxes, segmented tracks.
|
||||
pub well: u32,
|
||||
/// The light top (and left) edge of a panel.
|
||||
pub bevel: u32,
|
||||
/// The darker bottom edge of a panel or button.
|
||||
pub lip: u32,
|
||||
/// The 2 px outline around panels, buttons and wells.
|
||||
pub outline: u32,
|
||||
/// Rules between rows inside a panel.
|
||||
pub rule: u32,
|
||||
pub ink: u32,
|
||||
pub ink_soft: u32,
|
||||
pub muted: u32,
|
||||
/// Links, focus, progress, the selection marker; text-safe on every background.
|
||||
pub accent: u32,
|
||||
/// The main action's face (Play, Install, Download), its top bevel and bottom lip.
|
||||
pub face: u32,
|
||||
pub face_bevel: u32,
|
||||
pub face_lip: u32,
|
||||
pub on_face: u32,
|
||||
pub danger: u32,
|
||||
pub success: u32,
|
||||
/// "Partly": a mod or pack that runs in part.
|
||||
pub warn: u32,
|
||||
pub dark: bool,
|
||||
}
|
||||
|
||||
pub const BLOCKS_DARK: Blocks = Blocks {
|
||||
page: 0x0f0d17,
|
||||
side: 0x0b0a11,
|
||||
panel: 0x1a1727,
|
||||
raised: 0x221e34,
|
||||
button: 0x2b2641,
|
||||
button_bevel: 0x3d3560,
|
||||
well: 0x0c0b12,
|
||||
bevel: 0x342d52,
|
||||
lip: 0x07060b,
|
||||
outline: 0x05040a,
|
||||
rule: 0x120f1c,
|
||||
ink: 0xecedf3,
|
||||
ink_soft: 0xc5c7d1,
|
||||
muted: 0xa29cb8,
|
||||
accent: 0x9a86ff,
|
||||
face: 0x5b3fd6,
|
||||
face_bevel: 0x8a74ff,
|
||||
face_lip: 0x3a2694,
|
||||
on_face: 0xffffff,
|
||||
danger: 0xf07a68,
|
||||
success: 0x45c27a,
|
||||
warn: 0xf0b84f,
|
||||
dark: true,
|
||||
};
|
||||
|
||||
pub const BLOCKS_LIGHT: Blocks = Blocks {
|
||||
page: 0xece7f7,
|
||||
side: 0xe2dbf2,
|
||||
panel: 0xf8f6fd,
|
||||
raised: 0xe9e3f8,
|
||||
button: 0xddd4f3,
|
||||
button_bevel: 0xf4f0fe,
|
||||
well: 0xf3f0fb,
|
||||
bevel: 0xffffff,
|
||||
lip: 0xc3b8e2,
|
||||
outline: 0x2b2244,
|
||||
rule: 0xe4ddf4,
|
||||
ink: 0x1b1530,
|
||||
ink_soft: 0x3b3354,
|
||||
muted: 0x585071,
|
||||
accent: 0x5333c9,
|
||||
face: 0x5b3fd6,
|
||||
face_bevel: 0x8069ef,
|
||||
face_lip: 0x3a2694,
|
||||
on_face: 0xffffff,
|
||||
danger: 0xa3301d,
|
||||
success: 0x136336,
|
||||
warn: 0x7a4f00,
|
||||
dark: false,
|
||||
};
|
||||
|
||||
/// Pixel sizes of the blocky look: outlines, bevels and lips, the cut corner, and the stone tile.
|
||||
pub const BLOCK_OUTLINE: f32 = 2.;
|
||||
pub const BLOCK_BEVEL: f32 = 2.;
|
||||
pub const BLOCK_LIP: f32 = 4.;
|
||||
/// The stone texture: a 16 by 16 tile, each texel this many logical pixels.
|
||||
pub const TILE_TEXELS: usize = 16;
|
||||
pub const TILE_TEXEL: f32 = 4.;
|
||||
/// The texture's shades: the page colour moved this many levels (of 255) lighter or darker.
|
||||
pub const TILE_SHADES: [i16; 5] = [0, 2, -2, 5, -4];
|
||||
|
||||
/// How strongly the game's menus veil the live backdrop (the title panorama, or the world behind
|
||||
/// the pause and options screens) with the page colour. Every text colour the menus use keeps
|
||||
/// WCAG AA over it, even on a selected row's plate, with a backdrop as bright as
|
||||
@@ -458,6 +624,63 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// The blocky look: every text colour on every background it is drawn on reaches AA, the
|
||||
/// main action's label too, and the focus ring (the accent) reaches 3:1 (WCAG 1.4.11).
|
||||
#[test]
|
||||
fn blocks_text_meets_wcag_aa_in_both_appearances() {
|
||||
for p in [BLOCKS_DARK, BLOCKS_LIGHT] {
|
||||
let theme = if p.dark { "dark" } else { "light" };
|
||||
let backgrounds = [
|
||||
("page", p.page),
|
||||
("side", p.side),
|
||||
("panel", p.panel),
|
||||
("raised", p.raised),
|
||||
("button", p.button),
|
||||
("well", p.well),
|
||||
];
|
||||
let texts = [
|
||||
("ink", p.ink),
|
||||
("ink_soft", p.ink_soft),
|
||||
("muted", p.muted),
|
||||
("accent", p.accent),
|
||||
("danger", p.danger),
|
||||
("success", p.success),
|
||||
("warn", p.warn),
|
||||
];
|
||||
for (bn, bg) in backgrounds {
|
||||
for (tn, fg) in texts {
|
||||
let ratio = contrast(fg, bg);
|
||||
assert!(ratio >= 4.5, "{theme} {tn} on {bn}: {ratio:.2}");
|
||||
}
|
||||
// The texture's lightest shade under the page's text.
|
||||
let lifted = TILE_SHADES.iter().max().copied().unwrap_or(0) as i32;
|
||||
let shade = [16, 8, 0].iter().fold(0, |out, s| {
|
||||
let c = (((p.page >> s) & 255) as i32 + lifted).clamp(0, 255) as u32;
|
||||
out | c << s
|
||||
});
|
||||
for (tn, fg) in texts {
|
||||
let ratio = contrast(fg, shade);
|
||||
assert!(
|
||||
ratio >= 4.5,
|
||||
"{theme} {tn} on the stone texture: {ratio:.2}"
|
||||
);
|
||||
}
|
||||
}
|
||||
let label = contrast(p.on_face, p.face);
|
||||
assert!(label >= 4.5, "{theme} the main action's label: {label:.2}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn every_icon_is_a_pixel_svg() {
|
||||
for (name, svg) in icons::ALL {
|
||||
let svg = std::str::from_utf8(svg).unwrap();
|
||||
assert!(svg.contains("viewBox=\"0 0 24 24\""), "{name}");
|
||||
assert!(svg.contains("currentColor"), "{name}");
|
||||
}
|
||||
assert!(icons::get("play").is_some());
|
||||
}
|
||||
|
||||
/// The game's menus over the brightest backdrop: the page colour veiled over it, and a
|
||||
/// selected row's plate (ink at 8 %) on top.
|
||||
#[test]
|
||||
|
||||
@@ -133,12 +133,12 @@ Geist (400, 500, 600) and Geist Mono (400), bundled under the SIL Open Font Lice
|
||||
|
||||
## Surfaces
|
||||
|
||||
- **Launcher** (`launcher/`): top bar; Play is a page header (version as the title, its notes'
|
||||
first line under it), the client/server segmented control, the version picker and Play, then
|
||||
an index list of Resources, Minecraft folder (and the server rows). Versions and Patch notes
|
||||
are index lists with the release name as the title; Settings is an index list of switches and
|
||||
values. The opening is the faint wordmark drawn letter by letter, then the interface arrives.
|
||||
The sunset photograph is gone: the window is the page colour, light or dark with the system.
|
||||
- **Launcher** (`launcher/`): drawn in the Blocks look below. A top bar (wordmark, the pages as
|
||||
tabs, the account chip, Settings), a sidebar (the instances, the hosted servers, the launcher's
|
||||
own version and channel at its foot), and the page over a stone texture. Home opens on a pixel
|
||||
landscape banner with the hero, the version picker and Play; Mods holds the resource pack,
|
||||
shader pack and modpack tabs; Versions and Patch notes are lists of panels; Settings is
|
||||
grouped panels of rows. Dark by default, Light or System in Settings (Appearance).
|
||||
- **Website** (`website/`): the same page structure as before (what it is, screenshots,
|
||||
parity, launcher, patch notes, community), each section a `micro` mono label, a `display`
|
||||
heading and a short paragraph, its content an index list. Screenshots stay as images (radius
|
||||
@@ -150,6 +150,33 @@ Geist (400, 500, 600) and Geist Mono (400), bundled under the SIL Open Font Lice
|
||||
in mono, the control right). The pause menu is a centred column of plain rows over a darker
|
||||
veil.
|
||||
|
||||
## Blocks (the launcher)
|
||||
|
||||
The launcher's look since the gaming redesign: Minecraft's inventory rather than a document.
|
||||
Its tokens are `horizon_theme::Blocks` (`BLOCKS_DARK`, `BLOCKS_LIGHT`); the palettes above stay
|
||||
what the game's menus read.
|
||||
|
||||
- **Pixel type for what you act on.** Headings, tabs, buttons, badges and the wordmark use Pixelify
|
||||
Sans (Medium, SemiBold, Bold); paragraphs, details and numbers stay in Geist and Geist Mono so long
|
||||
text reads easily.
|
||||
- **Blocks, not rounded cards.** Every surface is a square panel: a 2 px dark outline, a 2 px light
|
||||
bevel along the top and a darker lip along the bottom. The main action (Play, Install) is the
|
||||
violet `face` with its own bevel and a 4 px lip; secondary buttons are raised `button` blocks;
|
||||
fields and tracks are sunk `well`s.
|
||||
- **Inventory tabs** switch the kinds in Mods: the open tab joins the panel under it.
|
||||
- **Slots** hold pictures: a mod's or pack's own icon and gallery images from its source,
|
||||
downloaded when first shown and kept on disk (`launcher/src/browser/images.rs`); the launcher
|
||||
ships no third-party pictures. The Horizon instance shows a grass block drawn from the player's
|
||||
own prepared Minecraft textures. Sources are named in text ("from Modrinth"): Modrinth's logo is
|
||||
all rights reserved, so it is not shown.
|
||||
- **Pixel art made in code** (`launcher/src/art.rs`): the stone behind the pages (16 texel tiles in
|
||||
five shades of the page colour) and the landscape behind Home (a sunset in dark, a dawn in light),
|
||||
baked at the window's scale so each texel covers whole device pixels.
|
||||
- **Icons**: Pixelarticons (MIT), 24 unit pixel SVGs in `crates/horizon-theme/icons/pixel/`, tinted
|
||||
with the text colour.
|
||||
- **Contrast**: every text colour meets WCAG AA (4.5:1) on the panels, the page and the lightest
|
||||
stone shade in both palettes (`blocks_text_meets_wcag_aa_in_both_appearances`).
|
||||
|
||||
## The mark
|
||||
|
||||
**Horizon line.** A sun half set below a horizon, drawn as three horizontal bars of 4, 8 and
|
||||
|
||||
@@ -0,0 +1,323 @@
|
||||
//! The launcher's pixel art, drawn here rather than shipped: the stone texture behind the pages
|
||||
//! and the landscape behind Home (the vanilla grass block is `browser::images::grass_block`).
|
||||
//! GPUI samples images smoothly, so every image is baked at the window's scale with each texel a
|
||||
//! whole block of device pixels, and drawn at exactly its size: the edges stay sharp. Each image
|
||||
//! is made once per appearance and scale, then reused.
|
||||
use gpui::RenderImage;
|
||||
use horizon_theme as tokens;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// What an image is, to find it again.
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
enum Key {
|
||||
Stone { dark: bool, scale: u32 },
|
||||
Scene { dark: bool, scale: u32 },
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Art {
|
||||
made: HashMap<Key, Arc<RenderImage>>,
|
||||
}
|
||||
|
||||
/// The stone texture comes in squares of this many logical pixels (4 by 4 tiles).
|
||||
pub const STONE: f32 = tokens::TILE_TEXEL * (tokens::TILE_TEXELS * 4) as f32;
|
||||
/// Home's landscape: texels of this many logical pixels, and its size in texels.
|
||||
pub const SCENE_TEXEL: f32 = 6.;
|
||||
pub const SCENE_SIZE: (usize, usize) = (220, 56);
|
||||
|
||||
impl Art {
|
||||
/// The page's stone texture, for a window at `scale`.
|
||||
pub fn stone(&mut self, page: u32, dark: bool, scale: f32) -> Arc<RenderImage> {
|
||||
let key = Key::Stone {
|
||||
dark,
|
||||
scale: scale_key(scale),
|
||||
};
|
||||
self.made
|
||||
.entry(key)
|
||||
.or_insert_with(|| {
|
||||
let n = tokens::TILE_TEXELS * 4;
|
||||
bake(&opaque(&stone(page, n)), n, n, tokens::TILE_TEXEL, scale)
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
|
||||
/// Home's landscape: a sunset in the dark appearance, a dawn in the light one.
|
||||
pub fn scene(&mut self, dark: bool, scale: f32) -> Arc<RenderImage> {
|
||||
let key = Key::Scene {
|
||||
dark,
|
||||
scale: scale_key(scale),
|
||||
};
|
||||
self.made
|
||||
.entry(key)
|
||||
.or_insert_with(|| {
|
||||
let (w, h) = SCENE_SIZE;
|
||||
let palette = if dark { &SUNSET } else { &DAWN };
|
||||
bake(&opaque(&scene(palette, 3, w, h)), w, h, SCENE_TEXEL, scale)
|
||||
})
|
||||
.clone()
|
||||
}
|
||||
}
|
||||
|
||||
/// `0xRRGGBB` texels, opaque.
|
||||
fn opaque(texels: &[u32]) -> Vec<[u8; 4]> {
|
||||
texels
|
||||
.iter()
|
||||
.map(|c| [(c >> 16) as u8, (c >> 8) as u8, *c as u8, 255])
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The colour at the top of Home's sky, for the banner above the landscape when it is taller.
|
||||
pub fn sky_top(dark: bool) -> u32 {
|
||||
if dark {
|
||||
SUNSET.sky[0]
|
||||
} else {
|
||||
DAWN.sky[0]
|
||||
}
|
||||
}
|
||||
|
||||
fn scale_key(scale: f32) -> u32 {
|
||||
(scale * 100.).round() as u32
|
||||
}
|
||||
|
||||
/// `texels` (RGBA, row by row) as an image whose texels are `texel` logical pixels square at
|
||||
/// `scale`. Texel edges fall on whole device pixels where the scale allows (1×, 2×, 3×).
|
||||
pub fn bake(texels: &[[u8; 4]], w: usize, h: usize, texel: f32, scale: f32) -> Arc<RenderImage> {
|
||||
let size = |n: usize| ((n as f32 * texel * scale).round() as u32).max(1);
|
||||
let (dw, dh) = (size(w), size(h));
|
||||
let mut buf = image::RgbaImage::new(dw, dh);
|
||||
for (y, row) in buf.rows_mut().enumerate() {
|
||||
let ty = (y * h / dh as usize).min(h - 1);
|
||||
for (x, px) in row.enumerate() {
|
||||
let tx = (x * w / dw as usize).min(w - 1);
|
||||
let [r, g, b, a] = texels[ty * w + tx];
|
||||
// GPUI wants BGRA, its alpha premultiplied.
|
||||
let pre = |c: u8| (c as u32 * a as u32 / 255) as u8;
|
||||
*px = image::Rgba([pre(b), pre(g), pre(r), a]);
|
||||
}
|
||||
}
|
||||
Arc::new(RenderImage::new([image::Frame::new(buf)]))
|
||||
}
|
||||
|
||||
/// A small, fixed random sequence (xorshift), so the art is the same on every start.
|
||||
struct Rng(u32);
|
||||
|
||||
impl Rng {
|
||||
fn next(&mut self) -> f32 {
|
||||
let mut x = self.0;
|
||||
x ^= x << 13;
|
||||
x ^= x >> 17;
|
||||
x ^= x << 5;
|
||||
self.0 = x;
|
||||
(x >> 8) as f32 / (1 << 24) as f32
|
||||
}
|
||||
}
|
||||
|
||||
fn shade(c: u32, by: i16) -> u32 {
|
||||
[16, 8, 0].iter().fold(0, |out, s| {
|
||||
let v = (((c >> s) & 255) as i16 + by).clamp(0, 255) as u32;
|
||||
out | v << s
|
||||
})
|
||||
}
|
||||
|
||||
fn mix(a: u32, b: u32, t: f32) -> u32 {
|
||||
[16, 8, 0].iter().fold(0, |out, s| {
|
||||
let (x, y) = (((a >> s) & 255) as f32, ((b >> s) & 255) as f32);
|
||||
out | ((x + (y - x) * t).round() as u32) << s
|
||||
})
|
||||
}
|
||||
|
||||
/// `n` by `n` texels of stone: the page colour in a few close shades, with darker flecks.
|
||||
fn stone(page: u32, n: usize) -> Vec<u32> {
|
||||
let shades = tokens::TILE_SHADES.map(|by| shade(page, by));
|
||||
let mut rng = Rng(0x9e37_79b9);
|
||||
let mut out: Vec<u32> = (0..n * n)
|
||||
.map(|_| {
|
||||
let v = rng.next();
|
||||
shades[if v < 0.5 {
|
||||
0
|
||||
} else if v < 0.78 {
|
||||
1
|
||||
} else if v < 0.93 {
|
||||
2
|
||||
} else {
|
||||
3
|
||||
}]
|
||||
})
|
||||
.collect();
|
||||
for _ in 0..n * n / 50 {
|
||||
let (x, y) = (
|
||||
(rng.next() * n as f32) as usize,
|
||||
(rng.next() * n as f32) as usize,
|
||||
);
|
||||
let len = 1 + (rng.next() * 3.) as usize;
|
||||
for i in 0..len {
|
||||
out[y * n + (x + i) % n] = shades[4];
|
||||
out[((y + 1) % n) * n + (x + i + 1) % n] = shades[4];
|
||||
}
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
/// A landscape's colours: the sky from the top down, the sun's bands, then the hills from far
|
||||
/// to near, the near hill's top edge, and the trees.
|
||||
pub struct Palette {
|
||||
sky: &'static [u32],
|
||||
sun: [u32; 3],
|
||||
far: u32,
|
||||
mid: u32,
|
||||
near: u32,
|
||||
top: u32,
|
||||
trees: u32,
|
||||
}
|
||||
|
||||
/// The sunset of Horizon's first icon: night blue to violet to coral, and a sun in three bands.
|
||||
pub const SUNSET: Palette = Palette {
|
||||
sky: &[
|
||||
0x0a0f2c, 0x26206a, 0x4b2a7e, 0x7c3a88, 0xc4527a, 0xee6e5a, 0xffb25e,
|
||||
],
|
||||
sun: [0xfff6cf, 0xffd272, 0xff9a44],
|
||||
far: 0x4a2f7e,
|
||||
mid: 0x2b1f5e,
|
||||
near: 0x151a45,
|
||||
top: 0x3d2f80,
|
||||
trees: 0x0e1236,
|
||||
};
|
||||
|
||||
/// The light appearance's morning: lavender to peach, soft violet hills.
|
||||
pub const DAWN: Palette = Palette {
|
||||
sky: &[
|
||||
0x8d7fd8, 0xa596e2, 0xbcaeea, 0xd2c4f0, 0xe7d2ee, 0xf6dce4, 0xffe6d6,
|
||||
],
|
||||
sun: [0xffffff, 0xfff1d0, 0xffd9a8],
|
||||
far: 0xa898dc,
|
||||
mid: 0x8676c8,
|
||||
near: 0x6a5ab4,
|
||||
top: 0x9a8ae0,
|
||||
trees: 0x4c3e94,
|
||||
};
|
||||
|
||||
/// A blocky landscape, `w` by `h` texels: banded sky, a sun half set behind the far hills and cut
|
||||
/// into slices like Horizon's mark, flat clouds, three ridges of hills and a few square trees.
|
||||
pub fn scene(p: &Palette, seed: u32, w: usize, h: usize) -> Vec<u32> {
|
||||
let mut rng = Rng(seed.wrapping_mul(0x2545_f491) | 1);
|
||||
let mut out = vec![0; w * h];
|
||||
let horizon = h * 62 / 100;
|
||||
let band = horizon as f32 / p.sky.len() as f32;
|
||||
for y in 0..h {
|
||||
let f = y as f32 / band;
|
||||
let i = (f as usize).min(p.sky.len() - 1);
|
||||
let dither = f - i as f32 > 0.88 && i + 1 < p.sky.len();
|
||||
for x in 0..w {
|
||||
out[y * w + x] = if dither && (x + y) % 2 == 1 {
|
||||
p.sky[i + 1]
|
||||
} else {
|
||||
p.sky[i]
|
||||
};
|
||||
}
|
||||
}
|
||||
let rect = |out: &mut Vec<u32>, x: isize, y: isize, rw: usize, rh: usize, c: u32| {
|
||||
for yy in y.max(0) as usize..((y + rh as isize).max(0) as usize).min(h) {
|
||||
for xx in x.max(0) as usize..((x + rw as isize).max(0) as usize).min(w) {
|
||||
out[yy * w + xx] = c;
|
||||
}
|
||||
}
|
||||
};
|
||||
for _ in 0..4 {
|
||||
let cx = (rng.next() * w as f32) as isize;
|
||||
let cy = (horizon as f32 * (0.12 + rng.next() * 0.4)) as isize;
|
||||
let cw = 10 + (rng.next() * 14.) as usize;
|
||||
let under = p.sky[((cy as f32 / band) as usize + 1).min(p.sky.len() - 1)];
|
||||
let c = mix(under, 0xffffff, 0.12);
|
||||
rect(&mut out, cx, cy, cw, 2, c);
|
||||
rect(&mut out, cx + 3, cy - 2, cw.saturating_sub(6), 2, c);
|
||||
}
|
||||
let r = (h as f32 * 0.2) as isize;
|
||||
let (cx, cy) = (
|
||||
(w as f32 * 0.68) as isize,
|
||||
horizon as isize - (h as f32 * 0.11) as isize,
|
||||
);
|
||||
for dy in -r..=0 {
|
||||
let half = ((r * r - dy * dy) as f32).sqrt().round() as isize;
|
||||
let t = (dy + r) as f32 / r as f32;
|
||||
let c = p.sun[if t < 0.4 {
|
||||
0
|
||||
} else if t < 0.75 {
|
||||
1
|
||||
} else {
|
||||
2
|
||||
}];
|
||||
if (cy + dy) % 5 != 0 || (dy as f32) < -r as f32 * 0.6 {
|
||||
rect(&mut out, cx - half, cy + dy, (half * 2) as usize, 1, c);
|
||||
}
|
||||
}
|
||||
let ridge = |rng: &mut Rng, base: f32, amp: f32, rough: f32| -> Vec<usize> {
|
||||
let (mut y, mut v) = (base, 0.);
|
||||
(0..w)
|
||||
.map(|x| {
|
||||
if x % 2 == 0 {
|
||||
v = (v + (rng.next() - 0.5) * rough) * 0.86;
|
||||
y += v + (base - y) * 0.06;
|
||||
}
|
||||
y.clamp(base - amp, base + amp).round().max(0.) as usize
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
let hf = h as f32;
|
||||
let layers = [
|
||||
(p.far, horizon as f32 - hf * 0.1, hf * 0.12, 3.2, None),
|
||||
(p.mid, horizon as f32 + hf * 0.02, hf * 0.09, 2.6, None),
|
||||
(
|
||||
p.near,
|
||||
horizon as f32 + hf * 0.18,
|
||||
hf * 0.07,
|
||||
2.2,
|
||||
Some(p.top),
|
||||
),
|
||||
];
|
||||
let mut near = Vec::new();
|
||||
for (c, base, amp, rough, top) in layers {
|
||||
let hs = ridge(&mut rng, base, amp, rough);
|
||||
for (x, &y) in hs.iter().enumerate() {
|
||||
for yy in y.min(h)..h {
|
||||
out[yy * w + x] = c;
|
||||
}
|
||||
if let (Some(top), true) = (top, y < h) {
|
||||
out[y * w + x] = top;
|
||||
}
|
||||
}
|
||||
near = hs;
|
||||
}
|
||||
for _ in 0..w / 26 {
|
||||
let tx = 4 + (rng.next() * (w - 10) as f32) as isize;
|
||||
let ty = near[tx as usize] as isize;
|
||||
rect(&mut out, tx - 2, ty - 8, 5, 5, p.trees);
|
||||
rect(&mut out, tx - 1, ty - 10, 3, 2, p.trees);
|
||||
rect(&mut out, tx, ty - 3, 1, 3, p.trees);
|
||||
}
|
||||
out
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn art_is_the_same_on_every_start() {
|
||||
assert_eq!(scene(&SUNSET, 3, 40, 20), scene(&SUNSET, 3, 40, 20));
|
||||
assert_eq!(stone(0x0f0d17, 16), stone(0x0f0d17, 16));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_stone_stays_within_its_shades() {
|
||||
let shades = tokens::TILE_SHADES.map(|by| shade(0x0f0d17, by));
|
||||
assert!(stone(0x0f0d17, 64).iter().all(|c| shades.contains(c)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn texels_cover_whole_device_pixels() {
|
||||
let image = bake(&opaque(&[0x112233; 4]), 2, 2, 4., 2.);
|
||||
let size = image.size(0);
|
||||
assert_eq!((size.width.0, size.height.0), (16, 16));
|
||||
}
|
||||
}
|
||||
@@ -2195,6 +2195,17 @@ pub fn spawn(job: Job, mut cmd: Command, tx: Sender<Msg>) -> Result<Running, Str
|
||||
Ok(Running { child, stdin })
|
||||
}
|
||||
|
||||
/// The launcher's appearance, as the player picks it in Settings.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum Appearance {
|
||||
#[default]
|
||||
Dark,
|
||||
Light,
|
||||
/// Follow the system's light or dark.
|
||||
System,
|
||||
}
|
||||
|
||||
#[derive(Default, serde::Serialize, serde::Deserialize)]
|
||||
pub struct Settings {
|
||||
pub selected: Option<String>,
|
||||
@@ -2219,6 +2230,9 @@ pub struct Settings {
|
||||
/// builds" switch instead; [`Settings::parse`] reads its `beta_builds: true` as Alpha.
|
||||
#[serde(default)]
|
||||
pub update_channel: UpdateChannel,
|
||||
/// Dark, Light, or the system's: the launcher's look. Dark by default.
|
||||
#[serde(default)]
|
||||
pub appearance: Appearance,
|
||||
/// The player has read what the "I'm playing" ping holds (`telemetry::PING`): on the
|
||||
/// first-run question, or on the Play page once if they answered that before it existed.
|
||||
#[serde(default)]
|
||||
@@ -2247,6 +2261,13 @@ impl Settings {
|
||||
{
|
||||
fields.remove("update_channel");
|
||||
}
|
||||
// The same for an appearance from a newer launcher.
|
||||
if fields
|
||||
.get("appearance")
|
||||
.is_some_and(|a| serde_json::from_value::<Appearance>(a.clone()).is_err())
|
||||
{
|
||||
fields.remove("appearance");
|
||||
}
|
||||
}
|
||||
serde_json::from_value(value).unwrap_or_default()
|
||||
}
|
||||
@@ -2497,6 +2518,24 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_appearance_is_dark_unless_picked_and_an_unknown_one_keeps_the_rest() {
|
||||
assert_eq!(Settings::parse("{}").appearance, Appearance::Dark);
|
||||
let light = Settings::parse(r#"{"appearance": "light", "game_args": "--x"}"#);
|
||||
assert_eq!(light.appearance, Appearance::Light);
|
||||
let future = Settings::parse(r#"{"appearance": "sepia", "game_args": "--x"}"#);
|
||||
assert_eq!(
|
||||
(future.appearance, future.game_args.as_str()),
|
||||
(Appearance::Dark, "--x")
|
||||
);
|
||||
let settings = Settings {
|
||||
appearance: Appearance::System,
|
||||
..Settings::default()
|
||||
};
|
||||
let text = serde_json::to_string(&settings).unwrap();
|
||||
assert!(text.contains(r#""appearance":"system""#), "{text}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_update_channel_is_stored_by_name_and_the_old_beta_switch_reads_as_alpha() {
|
||||
let read = |text: &str| Settings::parse(text).update_channel;
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
//! The blocky look's parts (`docs/design-system.md`, "Blocks"): pixel type, pixel icons, panels
|
||||
//! with a dark outline, a light bevel on top and a darker lip below, sunk wells, badges, the
|
||||
//! inventory tabs, and the slots that hold icons downloaded at run time.
|
||||
use crate::theme::{self, Theme};
|
||||
use gpui::{
|
||||
div, img, prelude::*, px, svg, AnyElement, App, ClickEvent, Div, FontWeight, Hsla, ImageSource,
|
||||
ObjectFit, SharedString, Stateful, Svg, Window,
|
||||
};
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// The icons, served to `svg()` as `icons/<name>.svg`.
|
||||
pub struct Assets;
|
||||
|
||||
impl gpui::AssetSource for Assets {
|
||||
fn load(&self, path: &str) -> gpui::Result<Option<Cow<'static, [u8]>>> {
|
||||
let name = path
|
||||
.strip_prefix("icons/")
|
||||
.and_then(|p| p.strip_suffix(".svg"));
|
||||
Ok(name.and_then(horizon_theme::icons::get).map(Cow::Borrowed))
|
||||
}
|
||||
|
||||
fn list(&self, _path: &str) -> gpui::Result<Vec<SharedString>> {
|
||||
Ok(horizon_theme::icons::ALL
|
||||
.iter()
|
||||
.map(|(name, _)| format!("icons/{name}.svg").into())
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
|
||||
/// A pixel icon (`horizon_theme::icons`) in `color`.
|
||||
pub fn icon(name: &'static str, size: f32, color: Hsla) -> Svg {
|
||||
svg()
|
||||
.path(format!("icons/{name}.svg"))
|
||||
.flex_none()
|
||||
.size(px(size))
|
||||
.text_color(color)
|
||||
}
|
||||
|
||||
/// Text in the pixel face: headings, navigation, buttons, badges.
|
||||
pub fn pixel(size: f32, weight: FontWeight) -> Div {
|
||||
div()
|
||||
.font_family(theme::PIXEL)
|
||||
.font_weight(weight)
|
||||
.text_size(px(size))
|
||||
.line_height(px((size * 1.2).round()))
|
||||
}
|
||||
|
||||
/// The light edge along the top of a raised block and the darker lip along its bottom; the
|
||||
/// block must be `relative`.
|
||||
pub fn edges(top: Hsla, bottom: Hsla, lip: f32) -> [AnyElement; 2] {
|
||||
[
|
||||
div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right_0()
|
||||
.h(px(theme::BEVEL))
|
||||
.bg(top)
|
||||
.into_any_element(),
|
||||
div()
|
||||
.absolute()
|
||||
.bottom_0()
|
||||
.left_0()
|
||||
.right_0()
|
||||
.h(px(lip))
|
||||
.bg(bottom)
|
||||
.into_any_element(),
|
||||
]
|
||||
}
|
||||
|
||||
/// A panel: rows, cards, notices, dialogs.
|
||||
pub fn panel(t: &Theme) -> Div {
|
||||
div()
|
||||
.relative()
|
||||
.bg(t.panel)
|
||||
.border_2()
|
||||
.border_color(t.outline)
|
||||
.children(edges(t.bevel, t.lip, theme::BEVEL))
|
||||
}
|
||||
|
||||
/// A small label in a block of its colour: "Runs", "Partly", a version.
|
||||
pub fn badge(label: impl Into<SharedString>, color: Hsla, t: &Theme) -> Div {
|
||||
let tint = if t.dark { 0.14 } else { 0.12 };
|
||||
div()
|
||||
.flex()
|
||||
.flex_none()
|
||||
.items_center()
|
||||
.gap(px(6.))
|
||||
.h(px(22.))
|
||||
.px(px(8.))
|
||||
.bg(color.opacity(tint))
|
||||
.border_2()
|
||||
.border_color(t.outline)
|
||||
.child(div().size(px(6.)).bg(color))
|
||||
.child(
|
||||
pixel(12., FontWeight::MEDIUM)
|
||||
.text_color(color)
|
||||
.child(label.into()),
|
||||
)
|
||||
}
|
||||
|
||||
/// Inventory tabs: a row of tabs on top of a panel, the open one joined to it.
|
||||
pub fn tabs<T: Copy + PartialEq + 'static>(
|
||||
id: &'static str,
|
||||
options: &[(T, &'static str, &'static str)],
|
||||
current: T,
|
||||
t: &Theme,
|
||||
on_pick: impl Fn(T, &mut Window, &mut App) + Clone + 'static,
|
||||
) -> Div {
|
||||
let t = *t;
|
||||
div()
|
||||
.flex()
|
||||
.items_end()
|
||||
.gap(px(4.))
|
||||
.children(options.iter().map(|&(value, label, icon_name)| {
|
||||
let open = current == value;
|
||||
let pick = on_pick.clone();
|
||||
let tab = div()
|
||||
.id(SharedString::from(format!("{id}-{label}")))
|
||||
.relative()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap(px(8.))
|
||||
.h(px(if open { 42. } else { 38. }))
|
||||
.px(px(14.))
|
||||
.border_2()
|
||||
.border_b_0()
|
||||
.border_color(t.outline)
|
||||
.cursor_pointer()
|
||||
.bg(if open { t.panel } else { t.side })
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.right_0()
|
||||
.h(px(theme::BEVEL))
|
||||
.bg(if open { t.bevel } else { t.raised }),
|
||||
)
|
||||
.child(icon(icon_name, 18., if open { t.accent } else { t.muted }))
|
||||
.child(
|
||||
pixel(15., FontWeight::MEDIUM)
|
||||
.text_color(if open { t.ink } else { t.muted })
|
||||
.child(label),
|
||||
)
|
||||
.when(!open, |d| d.hover(move |s| s.bg(t.raised)))
|
||||
// The open tab covers the panel's outline under it.
|
||||
.when(open, |d| d.mb(px(-2.)))
|
||||
.on_click(move |_: &ClickEvent, window, cx| pick(value, window, cx));
|
||||
crate::keyboard(tab, &t)
|
||||
}))
|
||||
}
|
||||
|
||||
/// A square slot for an icon: the picture at `source` when there is one, else the first letter of
|
||||
/// `name` on a raised block.
|
||||
pub fn slot(source: Option<ImageSource>, name: &str, size: f32, t: &Theme) -> Div {
|
||||
let frame = div()
|
||||
.flex()
|
||||
.flex_none()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.size(px(size))
|
||||
.overflow_hidden()
|
||||
.border_2()
|
||||
.border_color(t.outline)
|
||||
.bg(t.well);
|
||||
match source {
|
||||
Some(source) => frame.child(img(source).size(px(size - 4.)).object_fit(ObjectFit::Cover)),
|
||||
None => frame.bg(t.raised).child(
|
||||
pixel((size * 0.42).round(), FontWeight::BOLD)
|
||||
.text_color(t.muted)
|
||||
.child(
|
||||
name.chars()
|
||||
.find(|c| c.is_alphanumeric())
|
||||
.unwrap_or('?')
|
||||
.to_uppercase()
|
||||
.to_string(),
|
||||
),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Lays the stone texture over an area of `w` by `h` logical pixels.
|
||||
pub fn stone(image: std::sync::Arc<gpui::RenderImage>, w: f32, h: f32) -> Div {
|
||||
let step = crate::art::STONE;
|
||||
let (cols, rows) = ((w / step).ceil() as usize, (h / step).ceil() as usize);
|
||||
let mut layer = div()
|
||||
.absolute()
|
||||
.top_0()
|
||||
.left_0()
|
||||
.size_full()
|
||||
.overflow_hidden();
|
||||
for y in 0..rows {
|
||||
for x in 0..cols {
|
||||
layer = layer.child(
|
||||
img(image.clone())
|
||||
.absolute()
|
||||
.left(px(x as f32 * step))
|
||||
.top(px(y as f32 * step))
|
||||
.size(px(step)),
|
||||
);
|
||||
}
|
||||
}
|
||||
layer
|
||||
}
|
||||
|
||||
/// A clickable block in the sidebar: an instance or a server.
|
||||
pub fn side_item(id: SharedString, selected: bool, t: &Theme) -> Stateful<Div> {
|
||||
let t = *t;
|
||||
div()
|
||||
.id(id)
|
||||
.relative()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap(px(10.))
|
||||
.p(px(6.))
|
||||
.cursor_pointer()
|
||||
.when(selected, |d| {
|
||||
d.bg(t.raised)
|
||||
.children(edges(t.bevel, t.lip, theme::BEVEL))
|
||||
.child(
|
||||
div()
|
||||
.absolute()
|
||||
.left(px(-10.))
|
||||
.top(px(8.))
|
||||
.bottom(px(8.))
|
||||
.w(px(4.))
|
||||
.bg(t.accent),
|
||||
)
|
||||
})
|
||||
.when(!selected, |d| d.hover(move |s| s.bg(t.raised.opacity(0.6))))
|
||||
}
|
||||
@@ -124,9 +124,8 @@ impl Launcher {
|
||||
self.start_client(tag);
|
||||
}
|
||||
|
||||
/// The imported packs, above the Modpacks tab's search.
|
||||
pub(super) fn imported_packs(&mut self, cx: &mut Context<Self>) -> Div {
|
||||
let t = self.theme;
|
||||
/// Reads the imported packs, once (the sidebar and the Modpacks tab both show them).
|
||||
pub(super) fn load_packs(&mut self) {
|
||||
if self.packs_loaded.is_none() {
|
||||
self.packs = modpacks::list();
|
||||
if self.pack_open.is_none() {
|
||||
@@ -134,6 +133,12 @@ impl Launcher {
|
||||
}
|
||||
self.packs_loaded = Some(Instant::now());
|
||||
}
|
||||
}
|
||||
|
||||
/// The imported packs, above the Modpacks tab's search.
|
||||
pub(super) fn imported_packs(&mut self, cx: &mut Context<Self>) -> Div {
|
||||
let t = self.theme;
|
||||
self.load_packs();
|
||||
let busy = self.pack_busy;
|
||||
let pick = |id: &'static str, label: &'static str, folder: bool| {
|
||||
let b = button(id, label, Kind::Secondary, &t);
|
||||
@@ -153,12 +158,17 @@ impl Launcher {
|
||||
.gap(px(8.))
|
||||
.child(pick("import-file", "Import a pack file…", false))
|
||||
.child(pick("import-folder", "Import an instance folder…", true))
|
||||
.child(text(theme::CAPTION).text_color(t.muted).child(
|
||||
.child(text(theme::CAPTION).w_full().text_color(t.muted).child(
|
||||
".mrpack (Modrinth), .zip (CurseForge), or a Prism, MultiMC or CurseForge instance. \
|
||||
Horizon ports what it can on this computer, from your own downloads, and plays \
|
||||
the pack as its own profile. Nothing is uploaded or shared.",
|
||||
));
|
||||
let mut page = div().flex().flex_col().gap(px(32.)).child(actions);
|
||||
let mut page = div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(16.))
|
||||
.child(section_title("Your modpacks", "archive", &t))
|
||||
.child(actions);
|
||||
if busy || !self.pack_log.is_empty() {
|
||||
page = page.child(self.pack_log_plate(&t));
|
||||
}
|
||||
@@ -173,7 +183,7 @@ impl Launcher {
|
||||
);
|
||||
}
|
||||
if self.packs.len() > 1 {
|
||||
let mut list = div().flex().flex_col().border_t_1().border_color(t.rule);
|
||||
let mut list = div().flex().flex_col();
|
||||
for (i, p) in self.packs.iter().enumerate() {
|
||||
let open = self.pack_open.as_ref() == Some(&p.slug);
|
||||
let slug = p.slug.clone();
|
||||
@@ -348,7 +358,7 @@ impl Launcher {
|
||||
});
|
||||
}
|
||||
});
|
||||
let mut list = div().flex().flex_col().border_t_1().border_color(t.rule);
|
||||
let mut list = div().flex().flex_col();
|
||||
for (i, r) in rows.iter().enumerate() {
|
||||
let color = match r.status {
|
||||
Status::Ported => t.success,
|
||||
|
||||
@@ -11,11 +11,12 @@ use horizon_launcher::modpacks;
|
||||
use horizon_port_pack::check::Check;
|
||||
use std::collections::HashMap;
|
||||
|
||||
const KINDS: [(PackKind, &str); 4] = [
|
||||
(PackKind::Mod, "Mods"),
|
||||
(PackKind::Modpack, "Modpacks"),
|
||||
(PackKind::ResourcePack, "Resource packs"),
|
||||
(PackKind::ShaderPack, "Shader packs"),
|
||||
/// The kinds, as the Mods page's tabs: name and icon.
|
||||
const KINDS: [(PackKind, &str, &str); 4] = [
|
||||
(PackKind::Mod, "Mods", "box"),
|
||||
(PackKind::Modpack, "Modpacks", "archive"),
|
||||
(PackKind::ResourcePack, "Resource packs", "image"),
|
||||
(PackKind::ShaderPack, "Shader packs", "zap"),
|
||||
];
|
||||
/// Java mods checked at once.
|
||||
const CHECKING: usize = 2;
|
||||
@@ -72,10 +73,19 @@ pub(super) struct Mods {
|
||||
}
|
||||
|
||||
impl Mods {
|
||||
/// Whether the Modpacks tab is open (the sidebar marks the pack shown there).
|
||||
pub(super) fn on_modpacks(&self) -> bool {
|
||||
self.kind == PackKind::Modpack
|
||||
}
|
||||
|
||||
pub(super) fn new(cx: &mut App) -> Self {
|
||||
let (tx, rx) = channel();
|
||||
Self {
|
||||
kind: PackKind::Mod,
|
||||
kind: if std::env::var("HORIZON_LAUNCHER_PAGE").as_deref() == Ok("modpacks") {
|
||||
PackKind::Modpack
|
||||
} else {
|
||||
PackKind::Mod
|
||||
},
|
||||
source: SourceId::Modrinth,
|
||||
text: String::new(),
|
||||
focus: cx.focus_handle().tab_index(0).tab_stop(true),
|
||||
@@ -143,6 +153,23 @@ fn short_sum(checksum: &str) -> String {
|
||||
}
|
||||
|
||||
impl Launcher {
|
||||
/// Opens the Mods page on its Modpacks tab, with the pack `slug` open when given (the
|
||||
/// sidebar's packs and its + button).
|
||||
pub(super) fn show_modpack(&mut self, slug: Option<String>) {
|
||||
self.go(Page::Mods);
|
||||
if slug.is_some() {
|
||||
self.pack_open = slug;
|
||||
}
|
||||
if self.mods.kind != PackKind::Modpack {
|
||||
self.mods.kind = PackKind::Modpack;
|
||||
self.mods.browse.filters = Default::default();
|
||||
self.mods.browse.open = None;
|
||||
if self.mods.loaded {
|
||||
self.mods_search(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Called with the launcher's other work: what the background sent.
|
||||
pub(super) fn mods_tick(&mut self) -> bool {
|
||||
let mut changed = false;
|
||||
@@ -374,16 +401,17 @@ impl Launcher {
|
||||
.track_focus(&m.focus)
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap(px(10.))
|
||||
.w(px(320.))
|
||||
.h(px(theme::FIELD))
|
||||
.h(px(theme::FIELD + 4.))
|
||||
.px(px(12.))
|
||||
.overflow_hidden()
|
||||
.rounded(px(theme::RADIUS))
|
||||
.border_1()
|
||||
.border_color(if focused { t.accent } else { t.rule })
|
||||
.bg(t.surface)
|
||||
.border_2()
|
||||
.border_color(if focused { t.accent } else { t.outline })
|
||||
.bg(t.well)
|
||||
.text_size(px(theme::UI.px))
|
||||
.cursor_text()
|
||||
.child(blocks::icon("search", 18., t.muted))
|
||||
.child(if m.text.is_empty() && !focused {
|
||||
div().text_color(t.muted).child("Search, then Enter")
|
||||
} else {
|
||||
@@ -442,7 +470,7 @@ impl Launcher {
|
||||
&t,
|
||||
);
|
||||
let this = cx.entity().downgrade();
|
||||
let kinds = segments("mods-kind", &KINDS, self.mods.kind, &t, {
|
||||
let kinds = blocks::tabs("mods-kind", &KINDS, self.mods.kind, &t, {
|
||||
let this = this.clone();
|
||||
move |kind, _, cx| {
|
||||
let _ = this.update(cx, |this, cx| {
|
||||
@@ -477,29 +505,7 @@ impl Launcher {
|
||||
}));
|
||||
// CurseForge support is coming soon: shown, inert, never searched (like the Microsoft
|
||||
// account's "Coming soon").
|
||||
let source_note = div()
|
||||
.flex()
|
||||
.flex_wrap()
|
||||
.items_center()
|
||||
.gap(px(8.))
|
||||
.child(segments("mods-source", &SOURCES, self.mods.source, &t, {
|
||||
let this = this.clone();
|
||||
move |source, _, cx| {
|
||||
let _ = this.update(cx, |this, cx| {
|
||||
if this.mods.source != source {
|
||||
this.mods.source = source;
|
||||
this.mods_search(0);
|
||||
}
|
||||
cx.notify();
|
||||
});
|
||||
}
|
||||
}))
|
||||
.child(disabled(button(
|
||||
"mods-source-curseforge",
|
||||
"CurseForge (coming soon)",
|
||||
Kind::Ghost,
|
||||
&t,
|
||||
)));
|
||||
let source_note = div().flex().child(source_switch(&t));
|
||||
let controls = div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
@@ -510,35 +516,36 @@ impl Launcher {
|
||||
.flex_wrap()
|
||||
.items_center()
|
||||
.gap(px(12.))
|
||||
.child(kinds)
|
||||
.child(self.mods_field(cx))
|
||||
.child(toggle),
|
||||
)
|
||||
.child(source_note)
|
||||
.child(self.mods_filters(cx));
|
||||
if let Some(project) = self.mods_project_page(cx) {
|
||||
return div()
|
||||
// The kinds are inventory tabs on the panel that holds the open one.
|
||||
let body = blocks::panel(&t).flex().flex_col().gap(px(24.)).p(px(20.));
|
||||
let page = |body: Div| {
|
||||
div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(32.))
|
||||
.child(header)
|
||||
.children(self.mods_busy_plate())
|
||||
.child(project);
|
||||
.child(div().flex().flex_col().child(kinds).child(body))
|
||||
};
|
||||
if let Some(project) = self.mods_project_page(cx) {
|
||||
return page(body.children(self.mods_busy_plate()).child(project));
|
||||
}
|
||||
let mut page = div()
|
||||
.flex()
|
||||
.flex_col()
|
||||
.gap(px(32.))
|
||||
.child(header)
|
||||
.child(controls);
|
||||
page = page.children(self.mods_busy_plate());
|
||||
let mut body = body.children(self.mods_busy_plate());
|
||||
if self.mods.kind == PackKind::Modpack {
|
||||
page = page.child(self.imported_packs(cx));
|
||||
body = body
|
||||
.child(self.imported_packs(cx))
|
||||
.child(div().h(px(2.)).bg(t.rule))
|
||||
.child(section_title("Browse modpacks", "search", &t));
|
||||
}
|
||||
body = body.child(controls);
|
||||
if let Some(list) = self.mods_installed_list(cx) {
|
||||
page = page.child(list);
|
||||
body = body.child(list);
|
||||
}
|
||||
page.child(self.mods_results(cx))
|
||||
page(body.child(self.mods_results(cx)))
|
||||
}
|
||||
|
||||
/// The install under way and the last install's answer.
|
||||
@@ -589,7 +596,7 @@ impl Launcher {
|
||||
return None;
|
||||
}
|
||||
let busy = self.mods.busy.is_some();
|
||||
let mut list = div().flex().flex_col().border_t_1().border_color(t.rule);
|
||||
let mut list = div().flex().flex_col();
|
||||
for (i, e) in entries.into_iter().enumerate() {
|
||||
let key = (e.source, e.project.clone());
|
||||
let mut right = div().flex().items_center().gap(px(8.));
|
||||
@@ -691,7 +698,7 @@ impl Launcher {
|
||||
fn mods_results(&mut self, cx: &mut Context<Self>) -> Div {
|
||||
let t = self.theme;
|
||||
let found = self.mods.results.clone();
|
||||
let icons: Vec<AnyElement> = found.iter().map(|p| self.mods_icon(p, 40.)).collect();
|
||||
let icons: Vec<AnyElement> = found.iter().map(|p| self.mods_icon(p, 56.)).collect();
|
||||
let m = &self.mods;
|
||||
if let Some(e) = &m.error {
|
||||
return div().child(notice(e.clone(), &t));
|
||||
@@ -708,7 +715,7 @@ impl Launcher {
|
||||
}
|
||||
let busy = m.busy.as_ref().map(|b| b.0.as_str());
|
||||
let mut icons = icons.into_iter();
|
||||
let mut list = div().flex().flex_col().border_t_1().border_color(t.rule);
|
||||
let mut list = div().flex().flex_col();
|
||||
for (i, p) in m.results.iter().enumerate() {
|
||||
let support = m.support(p);
|
||||
let checking = p.kind == PackKind::Mod
|
||||
@@ -719,14 +726,14 @@ impl Launcher {
|
||||
&& p.support().installable();
|
||||
let color = match support {
|
||||
Support::Works => t.success,
|
||||
Support::Partial(_) => t.accent,
|
||||
Support::Partial(_) => t.warn,
|
||||
Support::No(_) => t.muted,
|
||||
};
|
||||
let mut right = div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.gap(px(8.))
|
||||
.child(caps(support.label()).flex_none().text_color(color));
|
||||
let mut right = div().flex().items_center().gap(px(8.)).child(blocks::badge(
|
||||
support.label(),
|
||||
color,
|
||||
&t,
|
||||
));
|
||||
let page_url = p.page.clone();
|
||||
if !page_url.is_empty() {
|
||||
right = right.child(
|
||||
@@ -826,6 +833,31 @@ impl Launcher {
|
||||
}
|
||||
}
|
||||
|
||||
/// The source switch while Modrinth is the only source: Modrinth chosen, CurseForge shown as
|
||||
/// coming soon and not clickable, like the Microsoft account's "Coming soon".
|
||||
fn source_switch(t: &Theme) -> Stateful<Div> {
|
||||
let soon = div()
|
||||
.flex()
|
||||
.items_center()
|
||||
.h(px(theme::SEGMENT))
|
||||
.px(px(14.))
|
||||
.pb(px(2.))
|
||||
.opacity(theme::DISABLED)
|
||||
.child(
|
||||
blocks::pixel(14., FontWeight::MEDIUM)
|
||||
.text_color(t.muted)
|
||||
.child("CurseForge (coming soon)"),
|
||||
);
|
||||
segments(
|
||||
"mods-source",
|
||||
&SOURCES,
|
||||
SourceId::Modrinth,
|
||||
t,
|
||||
|_, _, _| {},
|
||||
)
|
||||
.child(soon)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
@@ -167,28 +167,7 @@ impl Launcher {
|
||||
.icon
|
||||
.clone()
|
||||
.and_then(|url| self.mods_image(&url, images::ICON));
|
||||
let frame = plate(&t)
|
||||
.flex()
|
||||
.flex_none()
|
||||
.items_center()
|
||||
.justify_center()
|
||||
.size(px(side))
|
||||
.overflow_hidden();
|
||||
match path {
|
||||
Some(path) => frame.child(img(path).size(px(side))).into_any_element(),
|
||||
None => frame
|
||||
.text_color(t.muted)
|
||||
.child(
|
||||
text(theme::UI).child(
|
||||
p.title
|
||||
.chars()
|
||||
.next()
|
||||
.map(|c| c.to_uppercase().to_string())
|
||||
.unwrap_or_default(),
|
||||
),
|
||||
)
|
||||
.into_any_element(),
|
||||
}
|
||||
blocks::slot(path.map(gpui::ImageSource::from), &p.title, side, &t).into_any_element()
|
||||
}
|
||||
|
||||
/// The values the filters can take for the current kind and source, asked for once.
|
||||
@@ -357,7 +336,7 @@ impl Launcher {
|
||||
}
|
||||
|
||||
/// Vanilla's mark, drawn from the player's prepared game files when there are some.
|
||||
fn vanilla_icon(&self) -> Option<PathBuf> {
|
||||
pub(super) fn vanilla_icon(&self) -> Option<PathBuf> {
|
||||
let tag = self.selected().filter(|tag| backend::is_prepared(tag))?;
|
||||
images::grass_block(&backend::game_home(), &backend::resources(tag))
|
||||
}
|
||||
@@ -371,7 +350,7 @@ impl Launcher {
|
||||
let support = self.mods.support(&p);
|
||||
let color = match support {
|
||||
Support::Works => t.success,
|
||||
Support::Partial(_) => t.accent,
|
||||
Support::Partial(_) => t.warn,
|
||||
Support::No(_) => t.muted,
|
||||
};
|
||||
let back = button("mods-back", "Back to results", Kind::Ghost, &t).on_click(cx.listener(
|
||||
@@ -573,7 +552,7 @@ impl Launcher {
|
||||
None => centered("Loading…", &t),
|
||||
Some(Err(e)) => notice(e.clone(), &t),
|
||||
Some(Ok(list)) => {
|
||||
let mut rows = div().flex().flex_col().border_t_1().border_color(t.rule);
|
||||
let mut rows = div().flex().flex_col();
|
||||
for (i, v) in list.iter().take(50).enumerate() {
|
||||
let file = v.file();
|
||||
let mut detail = vec![
|
||||
|
||||
@@ -154,21 +154,27 @@ pub enum Step {
|
||||
Wait,
|
||||
/// Show this page (an index into `Page::ALL`, wrapping).
|
||||
Go(usize),
|
||||
/// Show the longest list (Versions) and scroll it on every frame while [`Bench::scrolling`].
|
||||
Scroll,
|
||||
Quit,
|
||||
}
|
||||
|
||||
const SWITCHING: Duration = Duration::from_secs(4);
|
||||
const SCROLLING: Duration = Duration::from_secs(3);
|
||||
const IDLE: Duration = Duration::from_secs(3);
|
||||
/// The environment variable that makes a launcher window measure itself into the file it names.
|
||||
const BENCH_ENV: &str = "HORIZON_LAUNCHER_BENCH";
|
||||
|
||||
/// A launcher window measuring itself: after its first frame it switches pages every tick for
|
||||
/// a few seconds (each switch animates, so the UI draws continuously), then rests, then writes
|
||||
/// what it measured for `benchmark` and quits.
|
||||
/// a few seconds (each switch animates, so the UI draws continuously), scrolls the longest list
|
||||
/// on every frame for a few more, then rests, then writes what it measured for `benchmark` and
|
||||
/// quits.
|
||||
pub struct Bench {
|
||||
out: PathBuf,
|
||||
began: Option<Instant>,
|
||||
page: usize,
|
||||
/// When scrolling began, and the UI frames drawn by then and by its end.
|
||||
scroll: Option<(Instant, usize, Option<usize>)>,
|
||||
idle_cpu: Option<(Instant, f64)>,
|
||||
}
|
||||
|
||||
@@ -179,10 +185,16 @@ impl Bench {
|
||||
out: out.into(),
|
||||
began: None,
|
||||
page: 0,
|
||||
scroll: None,
|
||||
idle_cpu: None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The window scrolls its content on every frame now.
|
||||
pub fn scrolling(&self) -> bool {
|
||||
matches!(self.scroll, Some((_, _, None)))
|
||||
}
|
||||
|
||||
pub fn tick(&mut self, perf: &Perf) -> Step {
|
||||
let Some(first) = perf.first_frame else {
|
||||
return Step::Wait;
|
||||
@@ -192,6 +204,20 @@ impl Bench {
|
||||
self.page += 1;
|
||||
return Step::Go(self.page);
|
||||
}
|
||||
let frames = perf.ui_frame_times().len();
|
||||
match &mut self.scroll {
|
||||
None => {
|
||||
self.scroll = Some((Instant::now(), frames, None));
|
||||
return Step::Scroll;
|
||||
}
|
||||
Some((at, _, end @ None)) => {
|
||||
if at.elapsed() < SCROLLING {
|
||||
return Step::Wait;
|
||||
}
|
||||
*end = Some(frames);
|
||||
}
|
||||
Some(_) => {}
|
||||
}
|
||||
let pid = std::process::id();
|
||||
let Some((rested, cpu)) = self.idle_cpu else {
|
||||
self.idle_cpu = Some((
|
||||
@@ -212,9 +238,15 @@ impl Bench {
|
||||
.unwrap_or_default();
|
||||
(now.saturating_sub(ago)).as_secs_f64() * 1000.0
|
||||
};
|
||||
let ui = perf.ui_frame_times();
|
||||
let scroll = match self.scroll {
|
||||
Some((_, from, Some(to))) => &ui[from.min(to)..to.min(ui.len())],
|
||||
_ => &[],
|
||||
};
|
||||
let result = serde_json::json!({
|
||||
"first_frame_epoch_ms": epoch_ms(first),
|
||||
"ui_ms": perf.ui_frame_times(),
|
||||
"ui_ms": ui,
|
||||
"scroll_ms": scroll,
|
||||
"rss_mb": horizon_bench::rss_bytes(pid).map(|b| b as f64 / f64::from(1 << 20)),
|
||||
"cpu_idle_pct": cpu_idle_pct,
|
||||
});
|
||||
@@ -270,20 +302,36 @@ pub fn benchmark(repeats: usize) -> Result<PathBuf, String> {
|
||||
}
|
||||
rss.extend(result["rss_mb"].as_f64());
|
||||
cpu.extend(result["cpu_idle_pct"].as_f64());
|
||||
let ui: Vec<f32> = result["ui_ms"]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|v| v.as_f64())
|
||||
.map(|v| v as f32)
|
||||
.collect();
|
||||
let times = |key: &str| -> Vec<f32> {
|
||||
result[key]
|
||||
.as_array()
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.filter_map(|v| v.as_f64())
|
||||
.map(|v| v as f32)
|
||||
.collect()
|
||||
};
|
||||
let (ui, scroll) = (times("ui_ms"), times("scroll_ms"));
|
||||
report
|
||||
.frames
|
||||
.extend(Frames::of("pages", repeat as u32, &ui, &[], &[]));
|
||||
report
|
||||
.frames
|
||||
.extend(Frames::of("scroll", repeat as u32, &scroll, &[], &[]));
|
||||
let mut sorted = scroll.clone();
|
||||
sorted.sort_by(f32::total_cmp);
|
||||
let at = |q: f32| {
|
||||
sorted
|
||||
.get(((sorted.len() as f32 - 1.) * q) as usize)
|
||||
.copied()
|
||||
};
|
||||
eprintln!(
|
||||
"start {}: {:.0} ms to the first frame",
|
||||
"start {}: {:.0} ms to the first frame; scrolling {} frames, median {:.1} ms, p95 {:.1} ms",
|
||||
repeat + 1,
|
||||
starts.last().unwrap_or(&0.0)
|
||||
starts.last().unwrap_or(&0.0),
|
||||
sorted.len(),
|
||||
at(0.5).unwrap_or(0.),
|
||||
at(0.95).unwrap_or(0.)
|
||||
);
|
||||
}
|
||||
report.metric("launcher.cold_start_ms", &starts[..starts.len().min(1)]);
|
||||
@@ -364,6 +412,7 @@ mod tests {
|
||||
began: None,
|
||||
page: 0,
|
||||
idle_cpu: None,
|
||||
scroll: None,
|
||||
};
|
||||
assert!(matches!(bench.tick(&perf), Step::Wait));
|
||||
perf.frame();
|
||||
|
||||
@@ -49,7 +49,7 @@ impl Scrollbar {
|
||||
/// Wrap the scroll container, reserving a narrow gutter so the bar never covers controls.
|
||||
pub fn wrap(&self, content: Stateful<Div>, theme: &Theme) -> Div {
|
||||
let state = self.clone();
|
||||
let track_color = theme.rule;
|
||||
let track_color = theme.well;
|
||||
let thumb_color = theme.muted;
|
||||
div()
|
||||
.relative()
|
||||
@@ -83,17 +83,14 @@ impl Scrollbar {
|
||||
return;
|
||||
};
|
||||
let hitbox = hitbox.unwrap();
|
||||
window.paint_quad(fill(bounds, track_color).corner_radii(px(3.)));
|
||||
window.paint_quad(
|
||||
fill(
|
||||
Bounds::new(
|
||||
point(bounds.left() + px(3.), bounds.top() + px(g.top)),
|
||||
size(bounds.size.width - px(6.), px(g.thumb)),
|
||||
),
|
||||
thumb_color,
|
||||
)
|
||||
.corner_radii(px(3.)),
|
||||
);
|
||||
window.paint_quad(fill(bounds, track_color));
|
||||
window.paint_quad(fill(
|
||||
Bounds::new(
|
||||
point(bounds.left() + px(3.), bounds.top() + px(g.top)),
|
||||
size(bounds.size.width - px(6.), px(g.thumb)),
|
||||
),
|
||||
thumb_color,
|
||||
));
|
||||
window.on_mouse_event({
|
||||
let state = state.clone();
|
||||
move |ev: &MouseDownEvent, phase, window, cx| {
|
||||
|
||||
@@ -114,6 +114,18 @@ pub(super) struct Create {
|
||||
eula_missing: bool,
|
||||
}
|
||||
|
||||
/// What the sidebar shows of the Servers page: its list once the page has read it, and whether
|
||||
/// a server answers.
|
||||
impl Servers {
|
||||
pub(super) fn sidebar_list(&self) -> Option<&[Entry]> {
|
||||
self.loaded.then_some(&self.list[..])
|
||||
}
|
||||
|
||||
pub(super) fn is_up(&self, dir: &std::path::Path) -> bool {
|
||||
self.statuses.get(dir).is_some_and(|s| s.phase == "running")
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) struct Servers {
|
||||
list: Vec<Entry>,
|
||||
loaded: bool,
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
//! The launcher's view of Horizon's design tokens (`crates/horizon-theme`, described in
|
||||
//! `docs/design-system.md`), which the game's menus and the website share: cool neutrals in two
|
||||
//! appearances and one violet accent, Geist and Geist Mono (bundled, SIL Open Font License).
|
||||
//! `docs/design-system.md`): the blocky look it shares with the website ("Blocks"), stone-dark or
|
||||
//! lavender-light with Horizon's violet, Pixelify Sans for headings and controls, Geist and Geist
|
||||
//! Mono for text (all bundled, SIL Open Font License).
|
||||
use gpui::{rgb, Hsla, WindowAppearance};
|
||||
use horizon_launcher::backend::Appearance;
|
||||
use horizon_theme as tokens;
|
||||
use std::time::Duration;
|
||||
|
||||
pub use tokens::{Step, BODY, CAPTION, DISPLAY, HEADING, LABEL, MICRO, TITLE, UI, WORDMARK};
|
||||
pub const FONT: &str = tokens::FONT;
|
||||
pub const MONO: &str = tokens::MONO;
|
||||
pub const PIXEL: &str = tokens::PIXEL;
|
||||
|
||||
pub use tokens::{BLOCK_BEVEL as BEVEL, BLOCK_LIP as LIP};
|
||||
/// Shapes and controls, shared with the game's menus and the website.
|
||||
pub use tokens::{
|
||||
CONTROL, CONTROL_LARGE, DISABLED, FIELD, GUTTER, INDEX, PLATE_BLEED, PRESSED, RADIUS,
|
||||
RADIUS_PILL, RADIUS_PLATE, RISE, ROW, SEGMENT,
|
||||
};
|
||||
pub use tokens::{CONTROL_LARGE, DISABLED, FIELD, PRESSED, RISE, ROW, SEGMENT};
|
||||
|
||||
/// Blocks have square corners: these stay for the places that ask for a radius.
|
||||
pub const RADIUS: f32 = 0.;
|
||||
pub const RADIUS_PLATE: f32 = 0.;
|
||||
/// Buttons are a little taller than the quiet look's, for their lip.
|
||||
pub const CONTROL: f32 = 34.;
|
||||
/// The top bar, and the sidebar of instances and servers.
|
||||
pub const TOPBAR: f32 = 56.;
|
||||
pub const SIDEBAR: f32 = 248.;
|
||||
|
||||
/// Motion: short and eased out, never bouncy.
|
||||
pub const QUICK: Duration = tokens::QUICK.duration();
|
||||
@@ -23,9 +33,15 @@ pub const STAGGER: Duration = tokens::STAGGER;
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct Theme {
|
||||
/// The page behind everything (under its stone texture), and its colour as `0xRRGGBB` for
|
||||
/// the texture.
|
||||
pub page: Hsla,
|
||||
pub page_rgb: u32,
|
||||
/// Hover plates, fields and the console: the raised panel colour.
|
||||
pub plate_soft: Hsla,
|
||||
/// Pressed plates, a switch that is off: the button colour.
|
||||
pub plate: Hsla,
|
||||
/// Dialogs and menus above the page: the panel colour.
|
||||
pub surface: Hsla,
|
||||
pub rule: Hsla,
|
||||
pub ink: Hsla,
|
||||
@@ -35,6 +51,21 @@ pub struct Theme {
|
||||
pub on_accent: Hsla,
|
||||
pub danger: Hsla,
|
||||
pub success: Hsla,
|
||||
pub warn: Hsla,
|
||||
/// The blocky parts (`horizon_theme::Blocks`).
|
||||
pub side: Hsla,
|
||||
pub panel: Hsla,
|
||||
pub raised: Hsla,
|
||||
pub button: Hsla,
|
||||
pub button_bevel: Hsla,
|
||||
pub well: Hsla,
|
||||
pub bevel: Hsla,
|
||||
pub lip: Hsla,
|
||||
pub outline: Hsla,
|
||||
pub face: Hsla,
|
||||
pub face_bevel: Hsla,
|
||||
pub face_lip: Hsla,
|
||||
pub on_face: Hsla,
|
||||
pub dark: bool,
|
||||
}
|
||||
|
||||
@@ -43,42 +74,61 @@ fn c(hex: u32) -> Hsla {
|
||||
}
|
||||
|
||||
impl Theme {
|
||||
/// The system's appearance; `HORIZON_LAUNCHER_APPEARANCE=light` or `dark` overrides it (for
|
||||
/// The player's choice in Settings (dark unless they picked another), the system's when they
|
||||
/// asked to follow it. `HORIZON_LAUNCHER_APPEARANCE=light` or `dark` overrides both (for
|
||||
/// screenshots and tests).
|
||||
pub fn for_appearance(appearance: WindowAppearance) -> Self {
|
||||
pub fn for_appearance(choice: Appearance, system: WindowAppearance) -> Self {
|
||||
match std::env::var("HORIZON_LAUNCHER_APPEARANCE").as_deref() {
|
||||
Ok("light") => return Self::light(),
|
||||
Ok("dark") => return Self::dark(),
|
||||
_ => {}
|
||||
}
|
||||
match appearance {
|
||||
WindowAppearance::Light | WindowAppearance::VibrantLight => Self::light(),
|
||||
match (choice, system) {
|
||||
(Appearance::Light, _) => Self::light(),
|
||||
(Appearance::System, WindowAppearance::Light | WindowAppearance::VibrantLight) => {
|
||||
Self::light()
|
||||
}
|
||||
_ => Self::dark(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dark() -> Self {
|
||||
Self::from(tokens::DARK)
|
||||
Self::from(tokens::BLOCKS_DARK)
|
||||
}
|
||||
|
||||
pub fn light() -> Self {
|
||||
Self::from(tokens::LIGHT)
|
||||
Self::from(tokens::BLOCKS_LIGHT)
|
||||
}
|
||||
|
||||
fn from(p: tokens::Palette) -> Self {
|
||||
fn from(p: tokens::Blocks) -> Self {
|
||||
Self {
|
||||
page: c(p.page),
|
||||
plate_soft: c(p.plate_soft),
|
||||
plate: c(p.plate),
|
||||
surface: c(p.surface),
|
||||
page_rgb: p.page,
|
||||
plate_soft: c(p.raised),
|
||||
plate: c(p.button),
|
||||
surface: c(p.panel),
|
||||
rule: c(p.rule),
|
||||
ink: c(p.ink),
|
||||
ink_soft: c(p.ink_soft),
|
||||
muted: c(p.muted),
|
||||
accent: c(p.accent),
|
||||
on_accent: c(p.on_accent),
|
||||
on_accent: c(p.on_face),
|
||||
danger: c(p.danger),
|
||||
success: c(p.success),
|
||||
warn: c(p.warn),
|
||||
side: c(p.side),
|
||||
panel: c(p.panel),
|
||||
raised: c(p.raised),
|
||||
button: c(p.button),
|
||||
button_bevel: c(p.button_bevel),
|
||||
well: c(p.well),
|
||||
bevel: c(p.bevel),
|
||||
lip: c(p.lip),
|
||||
outline: c(p.outline),
|
||||
face: c(p.face),
|
||||
face_bevel: c(p.face_bevel),
|
||||
face_lip: c(p.face_lip),
|
||||
on_face: c(p.on_face),
|
||||
dark: p.dark,
|
||||
}
|
||||
}
|
||||
@@ -105,13 +155,14 @@ mod tests {
|
||||
/// field (WCAG 1.4.11 asks 3:1 for those), and text over a selected suggestion.
|
||||
#[test]
|
||||
fn marks_and_selections_read_clearly() {
|
||||
for p in [tokens::LIGHT, tokens::DARK] {
|
||||
for p in [tokens::BLOCKS_LIGHT, tokens::BLOCKS_DARK] {
|
||||
let theme = if p.dark { "dark" } else { "light" };
|
||||
for (name, bg) in [
|
||||
("page", p.page),
|
||||
("plate_soft", p.plate_soft),
|
||||
("plate", p.plate),
|
||||
("surface", p.surface),
|
||||
("raised", p.raised),
|
||||
("button", p.button),
|
||||
("panel", p.panel),
|
||||
("well", p.well),
|
||||
] {
|
||||
let ring = tokens::contrast(p.accent, bg);
|
||||
assert!(ring >= 3.0, "{theme} focus ring on {name}: {ring:.2}");
|
||||
@@ -121,7 +172,7 @@ mod tests {
|
||||
"{theme} refused field on {name}: {refused:.2}"
|
||||
);
|
||||
}
|
||||
let selection = blend(p.accent, p.surface, SELECTION);
|
||||
let selection = blend(p.accent, p.panel, SELECTION);
|
||||
let ratio = tokens::contrast(p.ink, selection);
|
||||
assert!(ratio >= 4.5, "{theme} text on a selection: {ratio:.2}");
|
||||
}
|
||||
|
||||