diff --git a/README.md b/README.md index 5c1dc0c..5878573 100644 --- a/README.md +++ b/README.md @@ -15,13 +15,14 @@ Le serveur n'a pas besoin du mod (`displayTest="IGNORE_ALL_VERSION"`), et un jou Les captures sont dans `livrable/captures/`. -## Charte +## Charte (proposition A « sobre », branche `design/propositions`) -- Fond papier `#F2F0E6`, encre `#2D2A26`, filets `#DAD5C8`. -- Police Inter (TTF fournie dans le mod, licence OFL : `LICENCE-INTER-OFL.txt`). Le grand titre utilise Inter SemiBold suréchantillonnée, agrandie ×3. -- Aucun arrondi, aucune texture vanilla. Les boutons sont des lignes de liste séparées par des filets fins. -- Accents francs, utilisés avec retenue : orange `#E8590C` (serveur, surtitres), vert `#2B8A3E` (en ligne), rouge `#C92A2A` (hors ligne, quitter). -- Arrière-plan maison : `outils/fond.py` génère `textures/gui/fond.png` (courbes de niveau d'un relief imaginaire, une ligne de crête et un repère orange). La moitié gauche reste vide pour le menu. +- Fond blanc `#FFFFFF` (alterné `#F4F4F4`), encre `#111111`, gris `#6B6B6B`, filets `#D9D9D9` (fort : 2 px d'encre au-dessus des listes). Valeurs de la charte relevée (Mind, météo, Hub). +- Police Inter (TTF fournie dans le mod, licence OFL : `LICENCE-INTER-OFL.txt`). Grands titres en Inter SemiBold suréchantillonnée ; étiquettes en capitales espacées. +- Aucun arrondi, aucune texture vanilla, plus d'image de fond. Les menus sont des listes numérotées séparées par des filets ; l'action principale est une ligne pleine à l'encre. +- La couleur ne sert que de signal, toujours avec un texte : succès `#1A5C2A` sur `#F0F7F0`, alerte `#8A1C1C` sur `#FDF2F2`. +- Accueil : à droite, l'état du serveur en grands chiffres (joueurs, latence, version, adresse), masqué si l'écran est étroit. +- Les deux autres propositions (B, C) et les maquettes sont dans `propositions/`. ## Configuration diff --git a/gradle.properties b/gradle.properties index 0760467..da0522a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xmx2G org.gradle.parallel=true -mod_version=0.1.0 +mod_version=0.2.0 mod_group_id=com.gastinelclient mod_id=gastinelclient diff --git a/outils/fond.py b/outils/fond.py deleted file mode 100644 index f45dc1c..0000000 --- a/outils/fond.py +++ /dev/null @@ -1,61 +0,0 @@ -"""Génère l'arrière-plan de l'accueil GastinelClient (1920x1080, PNG). - -Papier réchauffé, courbes de niveau fines (relief imaginaire façon Vercors), une ligne de crête -à l'encre et un repère orange. La moitié gauche reste presque vide pour le menu. -Usage : python outils/fond.py (écrit src/main/resources/assets/gastinelclient/textures/gui/fond.png) -""" -import os -import numpy as np -from PIL import Image, ImageDraw - -W, H, SS = 1920, 1080, 2 # sur-échantillonnage x2 pour adoucir les traits -PAPIER = np.array([242, 240, 230], float) -FILET = np.array([218, 213, 200], float) -FILET_FORT = np.array([196, 188, 170], float) - -ys, xs = np.mgrid[0:H * SS, 0:W * SS].astype(float) / SS -u, v = xs / W, ys / H - -# Relief : un plateau (falaises) à droite + ondulations douces -relief = ( - 1.6 * np.exp(-((u - 0.78) ** 2 / 0.05 + (v - 0.62) ** 2 / 0.09)) - + 0.9 * np.exp(-((u - 0.98) ** 2 / 0.02 + (v - 0.25) ** 2 / 0.05)) - + 0.25 * np.sin(5.1 * u + 2.3 * v) * np.cos(3.7 * v - 1.2 * u) - + 0.12 * np.sin(13 * u + 7 * v + 1.0) -) -k = 18.0 -f = relief * k -d = np.abs(f - np.round(f)) # distance à la courbe la plus proche -grad = np.hypot(*np.gradient(f, 1.0 / SS)) + 1e-6 -dist_px = d / grad -ligne = np.clip(1.2 - dist_px * 1.4, 0, 1) -maitresse = (np.round(f).astype(int) % 5 == 0) - -# Masque : rien sous le menu à gauche, apparition progressive vers la droite -masque = np.clip((u - 0.34) / 0.22, 0, 1) ** 1.5 - -img = np.ones((H * SS, W * SS, 3)) * PAPIER -coul = np.where(maitresse[..., None], FILET_FORT, FILET) -a = (ligne * masque)[..., None] -img = img * (1 - a) + coul * a - -pil = Image.fromarray(img.astype(np.uint8)).resize((W, H), Image.LANCZOS) -dr = ImageDraw.Draw(pil) - -# Ligne de crête (encre), polyline anguleuse : pas d'arrondi -crete = [(1010, 820), (1120, 760), (1185, 772), (1260, 690), (1330, 668), (1372, 600), - (1460, 596), (1520, 640), (1600, 560), (1700, 548), (1770, 610), (1920, 590)] -dr.line(crete, fill=(45, 42, 38), width=2) -# Repère du spawn : carré orange franc + filet vertical -sx, sy = 1460, 596 -dr.line([(sx, sy - 120), (sx, sy - 8)], fill=(45, 42, 38), width=1) -dr.rectangle([sx - 6, sy - 6 - 120, sx + 6, sy + 6 - 120], fill=(232, 89, 12)) -# Croix de repérage dans les coins (filets fins) -for cx, cy in [(1840, 80), (1840, 1000), (760, 80), (760, 1000)]: - dr.line([(cx - 10, cy), (cx + 10, cy)], fill=(160, 152, 136), width=1) - dr.line([(cx, cy - 10), (cx, cy + 10)], fill=(160, 152, 136), width=1) - -out = os.path.join(os.path.dirname(__file__), "..", "src", "main", "resources", "assets", - "gastinelclient", "textures", "gui", "fond.png") -pil.save(out, optimize=True) -print("écrit", os.path.normpath(out), pil.size) diff --git a/propositions/A/NOTE.md b/propositions/A/NOTE.md new file mode 100644 index 0000000..22af6e3 --- /dev/null +++ b/propositions/A/NOTE.md @@ -0,0 +1,20 @@ +# Proposition A · Sobre, fidèle à la charte (implémentée sur cette branche) + +**Idée** : la charte relevée telle quelle (Mind, météo, Hub) : fond blanc, encre `#111`, gris `#6b6b6b`, filets `#d9d9d9`, Inter, aucun arrondi. Les menus sont des listes numérotées (01, 02…) entre filets, l'action principale est une ligne pleine à l'encre. La couleur ne sert que de signal, toujours avec un texte (vert « En ligne », rouge sombre « Sauvegarder et quitter »). L'accueil gagne un panneau « État du serveur » en grands chiffres, façon météo. + +**Différences avec la 0.1.0** : plus de papier beige ni de fond « courbes de niveau » ni d'orange ; barre du haut « GASTINEL / Rubrique » ; titres plus grands ; étiquettes en capitales espacées ; jauges fines dans les options. + +## Ce qui a changé dans le code (commit de cette proposition) +- `ui/Charte` : nouvelles couleurs, fond blanc uni, `etiquette()` (capitales espacées), `carre()`, `jauge()`. +- `ui/Bouton` : rendu MENU / PRIMAIRE revu (numéro, pastille d'état), nouveau genre `ALERTE`, CADRE blanc à filet d'encre. +- `ecrans/EcranGastinel` : barre du haut, en-tête et pied de page. +- `ecrans/AccueilScreen` : panneau d'état à droite (masqué si l'écran est étroit). +- `ecrans/PauseGastinel`, `OptionsSimplesScreen`, `ServeursScreen` : restyle (jauges, trait de saisie, filets forts). +- `core/Libelles.fraction()` + test JUnit. +- Supprimés : `textures/gui/fond.png`, `outils/fond.py`. Version passée à 0.2.0 dans `gradle.properties`. + +**Pas fait** (vu dans les maquettes, mais plus long) : l'écran Solo reste celui de Minecraft (la maquette montre un tableau maison, ~½ jour) ; le texte « Jouer sur le serveur Gastinel » reste le nom configuré. + +## Effort +Fait en une session (environ ½ jour). Build Gradle vert, tests JUnit verts ; captures en jeu (client de test sans compte, Xvfb) dans `en-jeu/`. Le jar de test `gastinelclient-neoforge-1.21.1-0.2.0.jar` est posé ici (non versionné). +En dev, le pied de page affiche « GastinelClient 0.1.0 » : c'est la version lue par le client de développement, le jar construit porte bien 0.2.0. diff --git a/propositions/A/en-jeu/a-01-accueil.png b/propositions/A/en-jeu/a-01-accueil.png new file mode 100644 index 0000000..f719715 Binary files /dev/null and b/propositions/A/en-jeu/a-01-accueil.png differ diff --git a/propositions/A/en-jeu/a-02-accueil-survol.png b/propositions/A/en-jeu/a-02-accueil-survol.png new file mode 100644 index 0000000..368eab1 Binary files /dev/null and b/propositions/A/en-jeu/a-02-accueil-survol.png differ diff --git a/propositions/A/en-jeu/a-03-options.png b/propositions/A/en-jeu/a-03-options.png new file mode 100644 index 0000000..43d785c Binary files /dev/null and b/propositions/A/en-jeu/a-03-options.png differ diff --git a/propositions/A/en-jeu/a-04-serveurs.png b/propositions/A/en-jeu/a-04-serveurs.png new file mode 100644 index 0000000..086e882 Binary files /dev/null and b/propositions/A/en-jeu/a-04-serveurs.png differ diff --git a/propositions/A/en-jeu/a-06-pause.png b/propositions/A/en-jeu/a-06-pause.png new file mode 100644 index 0000000..2666bde Binary files /dev/null and b/propositions/A/en-jeu/a-06-pause.png differ diff --git a/propositions/A/en-jeu/a-07-pause-survol.png b/propositions/A/en-jeu/a-07-pause-survol.png new file mode 100644 index 0000000..1cdac60 Binary files /dev/null and b/propositions/A/en-jeu/a-07-pause-survol.png differ diff --git a/propositions/A/maquette.html b/propositions/A/maquette.html new file mode 100644 index 0000000..6d05800 --- /dev/null +++ b/propositions/A/maquette.html @@ -0,0 +1,168 @@ + +Proposition A · Sobre + + + + +

A · Écran titre

+
+
GastinelMinecraft 1.21.1 · NeoForge
+
+

Serveur Minecraft

+

Gastinel

+

Le serveur des amis, dans le Vercors.

+
+
01
Jouer sur le serveur GastinelEn ligne · 3 joueurs sur 20 · 15 ms
→
+
02Solo→
+
03Autres serveurs
+
04Options
+
05Quitter
+
+
+
+
+

État du serveur · en direct

+
3/ 20 joueurs
+

En ligne

+
+
Latence15 ms
+
Version1.21.1
+
Adressegastinel.me
+
+
+
GastinelClient 0.2.0Mods
+
+ + +

A · Solo (choix du monde)

+
+
Gastinel / Solo← Retour
+
+

Mondes

+ Créer un monde
+ + + + + + +
NomModeDernière partieVersion
New WorldSurvieAujourd'hui, 14 h 021.21.1
Test redstoneCréatif12 octobre1.21.1
Vercors 1:1Créatif3 octobre1.21.1
Ancien mondeSurvie28 juin1.20.4
+
+
Jouer « New World »ModifierRecréerSupprimer
+
4 mondesEntrée : jouer · Suppr : supprimer
+
+ + +

A · Autres serveurs (multijoueur)

+
+
Gastinel / Autres serveurs← Retour
+
+

Autres serveurs

+

Adresse

+
+
play.exemple.fr
+ RejoindreEnregistrer +
+ + + + + +
Serveur enregistréAdresseÉtatJoueurs
Serveur de Léoleo.ddns.netEn ligne · 42 ms2 / 10
Hypixelmc.hypixel.netEn ligne · 96 ms31 204
Ancien serveur192.168.1.20Hors ligne—
+
+
Le serveur Gastinel est sur l'accueil.Liste complète de Minecraft
+
+ + +

A · Options

+
+
Gastinel / Options← Retour
+
+

Options

+
+

Image

+
Distance d'affichage12 tronçons−+
+
Champ de vision80°−+
+
Luminosité50 %−+
+
Taille de l'interfaceAuto−+
+
Plein écranNonOui
+
Synchro verticaleNonOui
+
+

Son et souris

+
Volume général80 %−+
+
Musique35 %−+
+
Blocs et ambiance100 %−+
+
Sensibilité de la souris50 %−+
+
+
+
+
Enregistré automatiquementToutes les options de Minecraft →
+
+ + +

A · Pause

+
+
+
+
GastinelÉchap : reprendre
+
+

Pause

+
+
01
ReprendreMonde : New World
→
+
02Options
+
03Progrès→
+
04Statistiques
+
05Ouvrir en réseau local
+
06Mods
+
+
Sauvegarder et quitter
+
+
+
+ + + diff --git a/propositions/A/multi.png b/propositions/A/multi.png new file mode 100644 index 0000000..4e2aa99 Binary files /dev/null and b/propositions/A/multi.png differ diff --git a/propositions/A/options.png b/propositions/A/options.png new file mode 100644 index 0000000..8b9ea25 Binary files /dev/null and b/propositions/A/options.png differ diff --git a/propositions/A/pause.png b/propositions/A/pause.png new file mode 100644 index 0000000..c42c940 Binary files /dev/null and b/propositions/A/pause.png differ diff --git a/propositions/A/solo.png b/propositions/A/solo.png new file mode 100644 index 0000000..e907035 Binary files /dev/null and b/propositions/A/solo.png differ diff --git a/propositions/A/titre.png b/propositions/A/titre.png new file mode 100644 index 0000000..35af59f Binary files /dev/null and b/propositions/A/titre.png differ diff --git a/src/main/java/com/gastinelclient/core/Libelles.java b/src/main/java/com/gastinelclient/core/Libelles.java index 094a645..6fa4947 100644 --- a/src/main/java/com/gastinelclient/core/Libelles.java +++ b/src/main/java/com/gastinelclient/core/Libelles.java @@ -45,4 +45,10 @@ public final class Libelles { public static int borne(int v, int min, int max) { return Math.max(min, Math.min(max, v)); } + + /** Position de v entre min et max, ramenée dans [0, 1] (pour une jauge). */ + public static double fraction(int v, int min, int max) { + if (max <= min) return 0; + return Math.max(0, Math.min(1, (v - min) / (double) (max - min))); + } } diff --git a/src/main/java/com/gastinelclient/ecrans/AccueilScreen.java b/src/main/java/com/gastinelclient/ecrans/AccueilScreen.java index 37a3e99..3882e4e 100644 --- a/src/main/java/com/gastinelclient/ecrans/AccueilScreen.java +++ b/src/main/java/com/gastinelclient/ecrans/AccueilScreen.java @@ -18,7 +18,8 @@ import java.net.UnknownHostException; /** * Écran d'accueil Gastinel : Solo, Serveur Gastinel (un clic), Autres serveurs, Options, Quitter. - * Le bouton du serveur affiche son état en direct (ping comme la liste multijoueur vanilla). + * Le bouton du serveur affiche son état en direct (ping comme la liste multijoueur vanilla) ; + * sur un écran assez large, un panneau à droite le détaille en grands chiffres (proposition A). */ public class AccueilScreen extends EcranGastinel { private final ServerStatusPinger pinger = new ServerStatusPinger(); @@ -30,29 +31,32 @@ public class AccueilScreen extends EcranGastinel { super("Accueil", null); } + private int hautBloc() { + return Math.max(34, (this.height - 24 - 168) / 2 + 12); + } + @Override protected void init() { this.gastinel = serveurGastinel(); int m = marge(), l = colonne(); - int bloc = 46 + 32 + 4 * 21; - int y = Math.max(14, (this.height - 24 - bloc) / 2) + 46; + int y = hautBloc() + 58; - addRenderableWidget(new Bouton(m, y, l, 21, "Solo", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new SelectWorldScreen(this)))); - y += 21; - addRenderableWidget(new Bouton(m, y, l, 32, Config.nom(), Bouton.Genre.PRIMAIRE, this::rejoindreGastinel) - .sousTitre(this::sousTitreServeur, () -> couleurEtat)); - y += 32; - addRenderableWidget(new Bouton(m, y, l, 21, "Autres serveurs", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new ServeursScreen(this)))); - y += 21; - addRenderableWidget(new Bouton(m, y, l, 21, "Options", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new OptionsSimplesScreen(this)))); - y += 21; - addRenderableWidget(new Bouton(m, y, l, 21, "Quitter", Bouton.Genre.MENU, () -> this.minecraft.stop())); + addRenderableWidget(new Bouton(m, y, l, 30, Config.nom(), Bouton.Genre.PRIMAIRE, this::rejoindreGastinel) + .numero(1).sousTitre(this::sousTitreServeur, () -> Charte.CLAIR).pastille(() -> enLigne() ? Charte.PASTILLE : null)); + y += 30; + addRenderableWidget(new Bouton(m, y, l, 20, "Solo", Bouton.Genre.MENU, + () -> this.minecraft.setScreen(new SelectWorldScreen(this))).numero(2)); + y += 20; + addRenderableWidget(new Bouton(m, y, l, 20, "Autres serveurs", Bouton.Genre.MENU, + () -> this.minecraft.setScreen(new ServeursScreen(this))).numero(3)); + y += 20; + addRenderableWidget(new Bouton(m, y, l, 20, "Options", Bouton.Genre.MENU, + () -> this.minecraft.setScreen(new OptionsSimplesScreen(this))).numero(4)); + y += 20; + addRenderableWidget(new Bouton(m, y, l, 20, "Quitter", Bouton.Genre.MENU, () -> this.minecraft.stop()).numero(5)); String mods = "Mods"; - lien(this.width - m - this.font.width(Charte.txt(mods)), this.height - 20, mods, + lien(this.width - m - this.font.width(Charte.txt(mods)), this.height - 16, mods, () -> this.minecraft.setScreen(new ModListScreen(this))); // Relancé à chaque retour sur l'accueil : l'état affiché reste frais. @@ -61,6 +65,11 @@ public class AccueilScreen extends EcranGastinel { lancerPing(); } + private boolean enLigne() { + ServerData d = this.gastinel; + return d != null && d.players != null; + } + /** Reprend l'entrée de la liste multijoueur si elle existe (garde le choix du pack de ressources). */ private ServerData serveurGastinel() { String adr = Libelles.nettoyerAdresse(Config.adresse()); @@ -80,13 +89,13 @@ public class AccueilScreen extends EcranGastinel { ServerData d = this.gastinel; Thread t = new Thread(() -> { try { - pinger.pingServer(d, () -> {}, () -> { etat = "Hors ligne pour le moment"; couleurEtat = Charte.ROUGE; }); + pinger.pingServer(d, () -> {}, () -> { etat = "Hors ligne pour le moment"; couleurEtat = Charte.ALERTE; }); } catch (UnknownHostException e) { etat = "Adresse introuvable"; - couleurEtat = Charte.ROUGE; + couleurEtat = Charte.ALERTE; } catch (Exception e) { etat = "Hors ligne pour le moment"; - couleurEtat = Charte.ROUGE; + couleurEtat = Charte.ALERTE; } }, "GastinelClient ping"); t.setDaemon(true); @@ -96,7 +105,7 @@ public class AccueilScreen extends EcranGastinel { private String sousTitreServeur() { ServerData d = this.gastinel; if (d != null && d.players != null) { - couleurEtat = Charte.VERT; + couleurEtat = Charte.SUCCES; return Libelles.enLigne(d.players.online(), d.players.max(), d.ping); } return etat; @@ -126,11 +135,52 @@ public class AccueilScreen extends EcranGastinel { public void render(GuiGraphics g, int mx, int my, float pt) { super.render(g, mx, my, pt); int m = marge(), l = colonne(); - int bloc = 46 + 32 + 4 * 21; - int y = Math.max(14, (this.height - 24 - bloc) / 2); - Charte.texte(g, this.font, Charte.gras("SERVEUR MINECRAFT"), m, y, Charte.ORANGE); - Charte.grandTitre(g, this.font, "Gastinel", m - 1, y + 12, 3f, Charte.ENCRE); - Charte.filet(g, m, m + l, y + 45, Charte.ENCRE); + int y = hautBloc(); + barre(g, m, this.width, null); + Charte.etiquette(g, this.font, "Serveur Minecraft", m, y, Charte.DOUX); + Charte.grandTitre(g, this.font, "Gastinel", m - 2, y + 12, 4f, Charte.ENCRE); + Charte.filet(g, m, m + l, y + 57, Charte.ENCRE); + Charte.filet(g, m, m + l, y + 56, Charte.ENCRE); // filet fort de 2 px au-dessus de la liste + panneauEtat(g, m, l, y); piedDePage(g); } + + /** Panneau de droite : état du serveur en grands chiffres. Masqué si l'écran est trop étroit. */ + private void panneauEtat(GuiGraphics g, int m, int l, int y) { + int xs = m + l + m; + int x = xs + m, larg = this.width - m - x; + if (larg < 150) return; + g.fill(xs, 25, xs + 1, this.height - 22, Charte.FILET); + Charte.etiquette(g, this.font, "État du serveur · en direct", x, y, Charte.DOUX); + ServerData d = this.gastinel; + boolean ok = enLigne(); + String grand = ok ? String.valueOf(d.players.online()) : "—"; + Charte.grandTitre(g, this.font, grand, x - 2, y + 16, 6f, Charte.ENCRE); + int lg = (int) (this.font.width(Charte.titre(grand)) * 6f); + if (ok) { + Charte.texte(g, this.font, Charte.gras("/ " + d.players.max() + (d.players.max() > 1 ? " joueurs" : " joueur")), + x + lg + 6, y + 56, Charte.ENCRE); + } + // Signal : texte coloré sur fond pâle, jamais la couleur seule. + String sig = ok ? "En ligne" : etat; + int ls = this.font.width(Charte.gras(sig)) + 10, sy = y + 76; + g.fill(x, sy, x + ls, sy + 14, ok ? Charte.SUCCES_FOND : (couleurEtat == Charte.ALERTE ? Charte.ALERTE_FOND : Charte.ALTERNE)); + Charte.texte(g, this.font, Charte.gras(sig), x + 5, sy + 3, ok ? Charte.SUCCES : couleurEtat); + // Trois cases séparées par des filets + int cy = sy + 30, lc = Math.min(90, larg * 2 / 7); // la 3e case (adresse) prend le reste + Charte.filet(g, x, x + larg, cy, Charte.FILET); + String[][] cases = { + {"Latence", ok && d.ping >= 0 ? d.ping + " ms" : "—"}, + {"Version", d != null && d.version != null && ok ? d.version.getString() : "1.21.1"}, + {"Adresse", Libelles.adresseCourte(d != null ? d.ip : Config.adresse())}}; + for (int i = 0; i < 3; i++) { + int cx = x + i * lc; + if (i > 0) g.fill(cx - 8, cy, cx - 7, cy + 40, Charte.FILET); + Charte.etiquette(g, this.font, cases[i][0], cx, cy + 10, Charte.DOUX); + String v = cases[i][1]; + int lv = i < 2 ? lc - 12 : larg - 2 * lc; + while (v.length() > 1 && this.font.width(Charte.titre(v)) * 1.5f > lv) v = v.substring(0, v.length() - 1); + Charte.grandTitre(g, this.font, v, cx, cy + 24, 1.5f, Charte.ENCRE); + } + } } diff --git a/src/main/java/com/gastinelclient/ecrans/EcranGastinel.java b/src/main/java/com/gastinelclient/ecrans/EcranGastinel.java index 27019ce..8f77aab 100644 --- a/src/main/java/com/gastinelclient/ecrans/EcranGastinel.java +++ b/src/main/java/com/gastinelclient/ecrans/EcranGastinel.java @@ -9,7 +9,7 @@ import net.minecraft.network.chat.Component; import net.neoforged.fml.ModList; import org.jetbrains.annotations.Nullable; -/** Base des écrans Gastinel hors partie : fond maison, marges, pied de page. */ +/** Base des écrans Gastinel : fond blanc, barre du haut, en-tête, pied de page. */ public abstract class EcranGastinel extends Screen { @Nullable protected final Screen parent; @@ -30,24 +30,32 @@ public abstract class EcranGastinel extends Screen { @Override public void renderBackground(GuiGraphics g, int mx, int my, float pt) { if (this.minecraft != null && this.minecraft.level != null) { - // En partie : voile de papier (pas de flou), le monde reste deviné derrière. - g.fill(0, 0, this.width, this.height, 0xF0F2F0E6); + // En partie : voile blanc presque opaque (pas de flou), le monde reste deviné derrière. + g.fill(0, 0, this.width, this.height, 0xF5FFFFFF); } else { Charte.fond(g, this.width, this.height); } } - /** En-tête : petit libellé orange + titre. Renvoie le y sous l'en-tête. */ - protected int entete(GuiGraphics g, int x, int y, String surtitre, String titre) { - Charte.texte(g, this.font, Charte.gras(surtitre.toUpperCase()), x, y, Charte.ORANGE); - Charte.grandTitre(g, this.font, titre, x, y + 14, 2f, Charte.ENCRE); - Charte.filet(g, x, x + colonne(), y + 38, Charte.ENCRE); + /** Barre du haut : « GASTINEL / Rubrique » à gauche, filet sur toute la largeur. */ + protected void barre(GuiGraphics g, int x, int largeur, String rubrique) { + int l = Charte.etiquette(g, this.font, "Gastinel", x, 9, Charte.ENCRE); + if (rubrique != null && !rubrique.isEmpty()) { + Charte.etiquette(g, this.font, "/ " + rubrique, x + l + 4, 9, Charte.DOUX); + } + Charte.filet(g, 0, largeur, 24, Charte.FILET); + } + + /** En-tête : barre du haut + grand titre. Renvoie le y sous l'en-tête (y + 46, comme avant). */ + protected int entete(GuiGraphics g, int x, int y, String rubrique, String titre) { + barre(g, x, this.width, rubrique); + Charte.grandTitre(g, this.font, titre, x - 1, y + 18, 2f, Charte.ENCRE); return y + 46; } protected void piedDePage(GuiGraphics g) { - int m = marge(), y = this.height - 18; - Charte.filet(g, m, this.width - m, y - 5, Charte.FILET); + int m = marge(), y = this.height - 14; + Charte.filet(g, m, this.width - m, y - 8, Charte.FILET); String v = ModList.get().getModContainerById("gastinelclient") .map(c -> c.getModInfo().getVersion().toString()).orElse("?"); Charte.texte(g, this.font, Charte.txt("Minecraft " + SharedConstants.getCurrentVersion().getName() diff --git a/src/main/java/com/gastinelclient/ecrans/OptionsSimplesScreen.java b/src/main/java/com/gastinelclient/ecrans/OptionsSimplesScreen.java index e44525d..9ae2c19 100644 --- a/src/main/java/com/gastinelclient/ecrans/OptionsSimplesScreen.java +++ b/src/main/java/com/gastinelclient/ecrans/OptionsSimplesScreen.java @@ -13,6 +13,7 @@ import net.minecraft.sounds.SoundSource; import java.util.ArrayList; import java.util.List; +import java.util.function.DoubleSupplier; import java.util.function.IntFunction; import java.util.function.Supplier; @@ -21,7 +22,7 @@ import java.util.function.Supplier; * des curseurs vanilla. « Toutes les options » ouvre l'écran complet de Minecraft. */ public class OptionsSimplesScreen extends EcranGastinel { - private record Ligne(String nom, Supplier valeur, int x, int y, int l) {} + private record Ligne(String nom, Supplier valeur, int x, int y, int l, DoubleSupplier part) {} private record Rubrique(String nom, int x, int y) {} private final List lignes = new ArrayList<>(); @@ -56,9 +57,9 @@ public class OptionsSimplesScreen extends EcranGastinel { y = pasDouble(x2, y, l, "Blocs et ambiance", o().getSoundSourceOptionInstance(SoundSource.BLOCKS), 0.05); pasDouble(x2, y, l, "Sensibilité de la souris", o().sensitivity(), 0.05); - lien(m, this.height - 20, "← Retour", this::onClose); + lien(m, this.height - 16, "← Retour", this::onClose); String tout = "Toutes les options de Minecraft"; - lien(this.width - m - this.font.width(Charte.txt(tout)), this.height - 20, tout, + lien(this.width - m - this.font.width(Charte.txt(tout)), this.height - 16, tout, () -> this.minecraft.setScreen(new OptionsScreen(this, o()))); } @@ -70,12 +71,22 @@ public class OptionsSimplesScreen extends EcranGastinel { /** Pas entier, borné sur les limites de l'option (une valeur hors bornes serait remise par défaut). */ private int pas(int x, int y, int l, String nom, OptionInstance opt, int pas, IntFunction format) { Runnable apres = opt == o().guiScale() ? () -> this.minecraft.resizeDisplay() : () -> {}; - ajouterPas(x, y, l, nom, () -> format.apply(opt.get()), + ajouterPas(x, y, l, nom, () -> format.apply(opt.get()), fraction(opt), () -> { opt.set(borner(opt, opt.get() - pas)); apres.run(); }, () -> { opt.set(borner(opt, opt.get() + pas)); apres.run(); }); return y + 20; } + /** Position dans les bornes de l'option, pour la jauge ; null si les bornes sont inconnues (ex. taille de l'interface). */ + private DoubleSupplier fraction(OptionInstance opt) { + if (opt == o().guiScale()) return null; + int min, max; + if (opt.values() instanceof OptionInstance.IntRange r) { min = r.minInclusive(); max = r.maxInclusive(); } + else if (opt.values() instanceof OptionInstance.ClampingLazyMaxIntRange r) { min = r.minInclusive(); max = r.maxInclusive(); } + else return null; + return () -> Libelles.fraction(opt.get(), min, max); + } + private static int borner(OptionInstance opt, int v) { if (opt.values() instanceof OptionInstance.IntRange r) return Libelles.borne(v, r.minInclusive(), r.maxInclusive()); if (opt.values() instanceof OptionInstance.ClampingLazyMaxIntRange r) return Libelles.borne(v, r.minInclusive(), r.maxInclusive()); @@ -83,20 +94,20 @@ public class OptionsSimplesScreen extends EcranGastinel { } private int pasDouble(int x, int y, int l, String nom, OptionInstance opt, double pas) { - ajouterPas(x, y, l, nom, () -> Libelles.pourcent(opt.get()), + ajouterPas(x, y, l, nom, () -> Libelles.pourcent(opt.get()), opt::get, () -> opt.set(Libelles.pas01(opt.get(), -pas)), () -> opt.set(Libelles.pas01(opt.get(), pas))); return y + 20; } - private void ajouterPas(int x, int y, int l, String nom, Supplier valeur, Runnable moins, Runnable plus) { - lignes.add(new Ligne(nom, valeur, x, y, l - 42)); + private void ajouterPas(int x, int y, int l, String nom, Supplier valeur, DoubleSupplier part, Runnable moins, Runnable plus) { + lignes.add(new Ligne(nom, valeur, x, y, l - 42, part)); addRenderableWidget(new Bouton(x + l - 38, y + 2, 17, 15, "−", Bouton.Genre.CADRE, moins)); addRenderableWidget(new Bouton(x + l - 17, y + 2, 17, 15, "+", Bouton.Genre.CADRE, plus)); } private int bascule(int x, int y, int l, String nom, OptionInstance opt) { - lignes.add(new Ligne(nom, () -> "", x, y, l - 42)); + lignes.add(new Ligne(nom, () -> "", x, y, l - 42, null)); Bouton[] b = new Bouton[1]; b[0] = addRenderableWidget(new Bouton(x + l - 38, y + 2, 38, 15, opt.get() ? "Oui" : "Non", Bouton.Genre.CADRE, () -> { opt.set(!opt.get()); @@ -108,26 +119,31 @@ public class OptionsSimplesScreen extends EcranGastinel { @Override public void render(GuiGraphics g, int mx, int my, float pt) { super.render(g, mx, my, pt); - entete(g, marge(), 16, "Réglages", "Options"); + entete(g, marge(), 16, "Options", "Options"); + int m = marge(); + int l = Math.min(colonne(), (this.width - 2 * m - 24) / 2); for (Rubrique r : rubriques) { - Charte.texte(g, this.font, Charte.gras(r.nom().toUpperCase()), r.x(), r.y(), Charte.DOUX); + Charte.etiquette(g, this.font, r.nom(), r.x(), r.y(), Charte.DOUX); + Charte.filet(g, r.x(), r.x() + l, r.y() + 11, Charte.ENCRE); + Charte.filet(g, r.x(), r.x() + l, r.y() + 12, Charte.ENCRE); } for (Ligne li : lignes) { Charte.texte(g, this.font, Charte.txt(li.nom()), li.x(), li.y() + 6, Charte.ENCRE); String v = li.valeur().get(); + int vx = li.x() + li.l(); if (!v.isEmpty()) { - int w = this.font.width(Charte.gras(v)); - Charte.texte(g, this.font, Charte.gras(v), li.x() + li.l() - w, li.y() + 6, Charte.ENCRE); + vx -= this.font.width(Charte.gras(v)); + Charte.texte(g, this.font, Charte.gras(v), vx, li.y() + 6, Charte.ENCRE); + } + if (li.part() != null) { + // Jauge entre le nom et la valeur, seulement s'il y a la place. + int debut = li.x() + this.font.width(Charte.txt(li.nom())) + 8, fin = vx - 8; + int lj = Math.min(60, fin - debut); + if (lj >= 20) Charte.jauge(g, fin - lj, li.y() + 9, lj, li.part().getAsDouble()); } Charte.filet(g, li.x(), li.x() + li.l() + 42, li.y() + 19, Charte.FILET); } - } - - @Override - public void renderBackground(GuiGraphics g, int mx, int my, float pt) { - super.renderBackground(g, mx, my, pt); - // Deux colonnes : on estompe les courbes de niveau pour que les réglages restent lisibles. - if (this.minecraft.level == null) g.fill(0, 0, this.width, this.height, 0xC8F2F0E6); + Charte.filet(g, m, this.width - m, this.height - 22, Charte.FILET); } @Override diff --git a/src/main/java/com/gastinelclient/ecrans/PauseGastinel.java b/src/main/java/com/gastinelclient/ecrans/PauseGastinel.java index 5f9c597..6e22b0b 100644 --- a/src/main/java/com/gastinelclient/ecrans/PauseGastinel.java +++ b/src/main/java/com/gastinelclient/ecrans/PauseGastinel.java @@ -12,7 +12,7 @@ import net.minecraft.network.chat.Component; import net.neoforged.neoforge.client.gui.ModListScreen; /** - * Menu pause simplifié : un panneau de papier à gauche, le monde visible à droite (sans flou). + * Menu pause simplifié : un panneau blanc à gauche, le monde visible à droite (sans flou). * Reprendre, Options, Progrès, Statistiques, (Ouvrir en réseau local), Mods, Quitter. */ public class PauseGastinel extends EcranGastinel { @@ -26,37 +26,38 @@ public class PauseGastinel extends EcranGastinel { private int haut() { int n = 5 + (lanPossible() ? 1 : 0); - return Math.max(14, (this.height - (46 + 30 + n * 20 + 12 + 20)) / 2); + return Math.max(14, (this.height - (58 + 30 + n * 20 + 14 + 20)) / 2 + 8); } @Override protected void init() { int m = marge(), l = colonne(); boolean solo = this.minecraft.isLocalServer(); - int y = haut() + 46; + int y = haut() + 58; + int n = 1; addRenderableWidget(new Bouton(m, y, l, 30, "Reprendre", Bouton.Genre.PRIMAIRE, this::reprendre) - .sousTitre(this::lieu, () -> Charte.DOUX)); + .numero(n++).sousTitre(this::lieu, () -> Charte.CLAIR)); y += 30; addRenderableWidget(new Bouton(m, y, l, 20, "Options", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new OptionsSimplesScreen(this)))); + () -> this.minecraft.setScreen(new OptionsSimplesScreen(this))).numero(n++)); y += 20; addRenderableWidget(new Bouton(m, y, l, 20, "Progrès", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new AdvancementsScreen(this.minecraft.player.connection.getAdvancements(), this)))); + () -> this.minecraft.setScreen(new AdvancementsScreen(this.minecraft.player.connection.getAdvancements(), this))).numero(n++)); y += 20; addRenderableWidget(new Bouton(m, y, l, 20, "Statistiques", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new StatsScreen(this, this.minecraft.player.getStats())))); + () -> this.minecraft.setScreen(new StatsScreen(this, this.minecraft.player.getStats()))).numero(n++)); y += 20; if (lanPossible()) { addRenderableWidget(new Bouton(m, y, l, 20, "Ouvrir en réseau local", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new ShareToLanScreen(this)))); + () -> this.minecraft.setScreen(new ShareToLanScreen(this))).numero(n++)); y += 20; } addRenderableWidget(new Bouton(m, y, l, 20, "Mods", Bouton.Genre.MENU, - () -> this.minecraft.setScreen(new ModListScreen(this)))); - y += 20 + 12; + () -> this.minecraft.setScreen(new ModListScreen(this))).numero(n++)); + y += 20 + 14; addRenderableWidget(new Bouton(m, y, l, 20, solo ? "Sauvegarder et quitter" : "Se déconnecter", - Bouton.Genre.PRIMAIRE, this::quitter).accent(Charte.ROUGE)); + Bouton.Genre.ALERTE, this::quitter)); } private boolean lanPossible() { @@ -96,8 +97,8 @@ public class PauseGastinel extends EcranGastinel { @Override public void renderBackground(GuiGraphics g, int mx, int my, float pt) { int p = panneau(); - g.fill(0, 0, this.width, this.height, 0x33000000); // monde légèrement assombri, sans flou - g.fill(0, 0, p, this.height, 0xF2F2F0E6); + g.fill(0, 0, this.width, this.height, 0x2E000000); // monde légèrement assombri, sans flou + g.fill(0, 0, p, this.height, Charte.FOND); g.fill(p, 0, p + 1, this.height, Charte.ENCRE); } @@ -105,8 +106,12 @@ public class PauseGastinel extends EcranGastinel { public void render(GuiGraphics g, int mx, int my, float pt) { super.render(g, mx, my, pt); int m = marge(), l = colonne(), y = haut(); - Charte.texte(g, this.font, Charte.gras("GASTINEL"), m, y, Charte.ORANGE); - Charte.grandTitre(g, this.font, "Pause", m - 1, y + 12, 3f, Charte.ENCRE); - Charte.filet(g, m, m + l, y + 45, Charte.ENCRE); + Charte.etiquette(g, this.font, "Gastinel", m, 9, Charte.ENCRE); + String echap = "Échap : reprendre"; + Charte.etiquette(g, this.font, echap, m + l - Charte.largeurEtiquette(this.font, echap), 9, Charte.DOUX); + Charte.filet(g, 0, panneau(), 24, Charte.FILET); + Charte.grandTitre(g, this.font, "Pause", m - 2, y, 4f, Charte.ENCRE); + Charte.filet(g, m, m + l, y + 56, Charte.ENCRE); + Charte.filet(g, m, m + l, y + 57, Charte.ENCRE); } } diff --git a/src/main/java/com/gastinelclient/ecrans/ServeursScreen.java b/src/main/java/com/gastinelclient/ecrans/ServeursScreen.java index 859d288..04d1dcf 100644 --- a/src/main/java/com/gastinelclient/ecrans/ServeursScreen.java +++ b/src/main/java/com/gastinelclient/ecrans/ServeursScreen.java @@ -86,9 +86,9 @@ public class ServeursScreen extends EcranGastinel { } } - lien(m, this.height - 20, "← Retour", this::onClose); + lien(m, this.height - 16, "← Retour", this::onClose); String complet = "Liste complète de Minecraft (modifier, supprimer)"; - lien(this.width - m - this.font.width(Charte.txt(complet)), this.height - 20, complet, + lien(this.width - m - this.font.width(Charte.txt(complet)), this.height - 16, complet, () -> this.minecraft.setScreen(new JoinMultiplayerScreen(this))); } @@ -139,18 +139,24 @@ public class ServeursScreen extends EcranGastinel { int m = marge(), l = colonne(); int y = entete(g, m, 16, "Multijoueur", "Autres serveurs"); // Case d'adresse : cadre fin dessiné par nous (pas de bordure vanilla) - g.renderOutline(m, y, l, 22, adresse != null && adresse.isFocused() ? Charte.ENCRE : Charte.FILET_FORT); + // Case d'adresse : simple trait de 2 px dessous (à l'encre quand elle a le focus). + int c = adresse != null && adresse.isFocused() ? Charte.ENCRE : Charte.FILET_FORT; + g.fill(m, y + 20, m + l, y + 22, c); int ly = y + 26 + 30; - Charte.texte(g, this.font, Charte.gras("ENREGISTRÉS"), m, ly, Charte.DOUX); + int le = Charte.etiquette(g, this.font, "Enregistrés", m, ly, Charte.DOUX), fin = m + l; if (!message.isEmpty()) { - Charte.texte(g, this.font, Charte.txt(message), m + this.font.width(Charte.gras("ENREGISTRÉS")) + 10, ly, Charte.DOUX); + Charte.texte(g, this.font, Charte.txt(message), m + le + 10, ly, Charte.DOUX); + fin = Math.max(fin, m + le + 10 + this.font.width(Charte.txt(message))); } + Charte.filet(g, m, fin, ly + 11, Charte.ENCRE); + Charte.filet(g, m, fin, ly + 12, Charte.ENCRE); + Charte.filet(g, m, this.width - m, this.height - 22, Charte.FILET); } @Override public void renderBackground(GuiGraphics g, int mx, int my, float pt) { super.renderBackground(g, mx, my, pt); int m = marge(), l = colonne(); - g.fill(m, 16 + 46, m + l, 16 + 46 + 22, Charte.CARTE); + g.fill(m, 16 + 46, m + l, 16 + 46 + 20, Charte.ALTERNE); } } diff --git a/src/main/java/com/gastinelclient/ui/Bouton.java b/src/main/java/com/gastinelclient/ui/Bouton.java index 9f65ed8..85a4ac5 100644 --- a/src/main/java/com/gastinelclient/ui/Bouton.java +++ b/src/main/java/com/gastinelclient/ui/Bouton.java @@ -10,19 +10,22 @@ import net.minecraft.network.chat.Component; import java.util.function.Supplier; /** - * Bouton plat de la charte : angles droits, filets fins, pas de texture. - * MENU : ligne de liste alignée à gauche ; PRIMAIRE : comme MENU avec barre d'accent et sous-titre ; - * CADRE : petit bouton encadré centré ; LIEN : texte seul souligné au survol. + * Bouton plat de la charte : angles droits, filets de 1 px, pas de texture. + * MENU : ligne de liste (numéro gris, texte, filet dessous ; survol = fond alterné + barre d'encre + flèche). + * PRIMAIRE : ligne pleine à l'encre, texte blanc, sous-titre gris clair. + * ALERTE : ligne au texte rouge sombre entre deux filets rouges (quitter). + * CADRE : bouton encadré 1 px, plein à l'encre au survol. LIEN : texte seul souligné au survol. */ public class Bouton extends AbstractButton { - public enum Genre { MENU, PRIMAIRE, CADRE, LIEN } + public enum Genre { MENU, PRIMAIRE, ALERTE, CADRE, LIEN } private final Genre genre; private final Runnable action; private Supplier sousTitre = null; private Supplier couleurSousTitre = () -> Charte.DOUX; - private int accent = Charte.ORANGE; + private Supplier pastille = null; private String droite = null; + private int numero = 0; public Bouton(int x, int y, int l, int h, String texte, Genre genre, Runnable action) { super(x, y, l, h, Component.literal(texte)); @@ -36,7 +39,11 @@ public class Bouton extends AbstractButton { return this; } - public Bouton accent(int c) { this.accent = c; return this; } + /** Petit carré de couleur devant le sous-titre (état du serveur) ; null = pas de carré. */ + public Bouton pastille(Supplier c) { this.pastille = c; return this; } + + /** Numéro gris « 01 » en tête de ligne (0 = aucun). */ + public Bouton numero(int n) { this.numero = n; return this; } /** Petit texte gris aligné à droite (ex. adresse d'un serveur). */ public Bouton droite(String s) { this.droite = s; return this; } @@ -49,38 +56,58 @@ public class Bouton extends AbstractButton { Font f = Minecraft.getInstance().font; boolean s = this.active && this.isHoveredOrFocused(); int x = getX(), y = getY(), l = getWidth(), h = getHeight(); - int encre = this.active ? Charte.ENCRE : Charte.FILET_FORT; String t = getMessage().getString(); + int ty = y + (h - 8) / 2; switch (genre) { case MENU, PRIMAIRE -> { - if (s) g.fill(x, y, x + l, y + h, Charte.SURVOL); boolean prim = genre == Genre.PRIMAIRE; - if (prim || s) g.fill(x, y, x + (prim ? 3 : 2), y + h, prim ? accent : Charte.ENCRE); - int tx = x + 12; + int encre = prim ? Charte.FOND : (this.active ? Charte.ENCRE : Charte.FILET_FORT); + if (prim) g.fill(x, y, x + l, y + h, Charte.ENCRE); + else if (s) { + g.fill(x, y, x + l, y + h, Charte.ALTERNE); + g.fill(x, y, x + 1, y + h, Charte.ENCRE); + } + int tx = x + 8; + if (numero > 0) { + Charte.texte(g, f, Charte.gras(String.format("%02d", numero)), tx, ty, prim ? Charte.FILET_FORT : Charte.DOUX); + tx += 22; + } if (sousTitre != null) { - Charte.texte(g, f, Charte.gras(t), tx, y + h / 2 - 10, encre); - Charte.texte(g, f, Charte.txt(sousTitre.get()), tx, y + h / 2 + 2, couleurSousTitre.get()); + Charte.texte(g, f, Charte.txt(t), tx, y + h / 2 - 10, encre); + int sx = tx; + if (pastille != null && pastille.get() != null) { + Charte.carre(g, sx, y + h / 2 + 4, 5, pastille.get()); + sx += 9; + } + Charte.texte(g, f, Charte.txt(sousTitre.get()), sx, y + h / 2 + 2, couleurSousTitre.get()); } else { - Charte.texte(g, f, prim ? Charte.gras(t) : Charte.txt(t), tx, y + (h - 8) / 2, encre); + Charte.texte(g, f, Charte.txt(t), tx, ty, encre); } if (droite != null) { Component d = Charte.txt(droite); - Charte.texte(g, f, d, x + l - 22 - f.width(d), y + (h - 8) / 2, Charte.DOUX); + Charte.texte(g, f, d, x + l - 22 - f.width(d), ty, Charte.DOUX); } - if (s) Charte.texte(g, f, Charte.txt("→"), x + l - 14, y + (h - 8) / 2, Charte.ENCRE); - Charte.filet(g, x, x + l, y + h - 1, Charte.FILET); + if (s || prim) Charte.texte(g, f, Charte.txt("→"), x + l - 14, ty, encre); + if (!prim) Charte.filet(g, x, x + l, y + h - 1, Charte.FILET); + } + case ALERTE -> { + if (s) g.fill(x, y, x + l, y + h, Charte.ALERTE_FOND); + Charte.filet(g, x, x + l, y, Charte.ALERTE); + Charte.filet(g, x, x + l, y + h - 1, Charte.ALERTE); + Charte.texte(g, f, Charte.gras(t), x + 8, ty, Charte.ALERTE); + if (s) Charte.texte(g, f, Charte.txt("→"), x + l - 14, ty, Charte.ALERTE); } case CADRE -> { - if (s) g.fill(x, y, x + l, y + h, Charte.ENCRE); - else g.fill(x, y, x + l, y + h, Charte.CARTE); - g.renderOutline(x, y, l, h, s ? Charte.ENCRE : Charte.FILET_FORT); + int encre = this.active ? Charte.ENCRE : Charte.FILET_FORT; + g.fill(x, y, x + l, y + h, s ? Charte.ENCRE : Charte.FOND); + g.renderOutline(x, y, l, h, this.active ? Charte.ENCRE : Charte.FILET); Component c = Charte.txt(t); - Charte.texte(g, f, c, x + (l - f.width(c)) / 2, y + (h - 8) / 2, s ? Charte.PAPIER : encre); + Charte.texte(g, f, c, x + (l - f.width(c)) / 2, ty, s ? Charte.FOND : encre); } case LIEN -> { Component c = Charte.txt(t); - Charte.texte(g, f, c, x, y + (h - 8) / 2, s ? Charte.ENCRE : Charte.DOUX); - if (s) Charte.filet(g, x, x + f.width(c), y + (h - 8) / 2 + 9, Charte.ENCRE); + Charte.texte(g, f, c, x, ty, s ? Charte.ENCRE : Charte.DOUX); + if (s) Charte.filet(g, x, x + f.width(c), ty + 9, Charte.ENCRE); } } } diff --git a/src/main/java/com/gastinelclient/ui/Charte.java b/src/main/java/com/gastinelclient/ui/Charte.java index 982e82a..729ecd9 100644 --- a/src/main/java/com/gastinelclient/ui/Charte.java +++ b/src/main/java/com/gastinelclient/ui/Charte.java @@ -8,30 +8,31 @@ import net.minecraft.network.chat.MutableComponent; import net.minecraft.resources.ResourceLocation; /** - * Charte Gastinel : papier réchauffé, encre presque noire, filets fins, aucun arrondi, - * police Inter, et quelques couleurs franches réservées aux éléments clés. + * Charte Gastinel (proposition A, « sobre ») : fond blanc, encre #111, gris #6b6b6b, filets #d9d9d9, + * police Inter, aucun arrondi, filets de 1 px. La couleur ne sert que de signal (en ligne, hors ligne). + * Valeurs reprises de la charte relevée (Mind, météo, Hub). */ public final class Charte { private Charte() {} // Couleurs (ARGB) - public static final int PAPIER = 0xFFF2F0E6; - public static final int CARTE = 0xFFF8F7F1; - public static final int SURVOL = 0xFFE9E5D9; - public static final int ENCRE = 0xFF2D2A26; - public static final int DOUX = 0xFF6F6A61; - public static final int FILET = 0xFFDAD5C8; - public static final int FILET_FORT = 0xFFB9B1A0; - // Accents francs (avec retenue) - public static final int ORANGE = 0xFFE8590C; - public static final int VERT = 0xFF2B8A3E; - public static final int ROUGE = 0xFFC92A2A; + public static final int FOND = 0xFFFFFFFF; + public static final int ALTERNE = 0xFFF4F4F4; + public static final int ENCRE = 0xFF111111; + public static final int DOUX = 0xFF6B6B6B; + public static final int CLAIR = 0xFFBDBDBD; // texte secondaire sur fond encre + public static final int FILET = 0xFFD9D9D9; + public static final int FILET_FORT = 0xFF8C8C8C; + // Signaux (jamais seuls : toujours avec un texte) + public static final int SUCCES = 0xFF1A5C2A; + public static final int SUCCES_FOND = 0xFFF0F7F0; + public static final int ALERTE = 0xFF8A1C1C; + public static final int ALERTE_FOND = 0xFFFDF2F2; + public static final int PASTILLE = 0xFF3FBF5F; // carré « en ligne » sur fond encre public static final ResourceLocation INTER = rl("inter"); public static final ResourceLocation INTER_GRAS = rl("inter_gras"); public static final ResourceLocation INTER_TITRE = rl("inter_titre"); - public static final ResourceLocation FOND = rl("textures/gui/fond.png"); - private static final int FOND_L = 1920, FOND_H = 1080; private static ResourceLocation rl(String p) { return ResourceLocation.fromNamespaceAndPath(GastinelClient.MODID, p); @@ -63,12 +64,37 @@ public final class Charte { g.pose().popPose(); } - /** Arrière-plan « à lui » : papier + courbes de niveau, calé à droite, recouvrant tout l'écran. */ + /** Arrière-plan : blanc uni. */ public static void fond(GuiGraphics g, int w, int h) { - g.fill(0, 0, w, h, PAPIER); - float k = Math.max(w / (float) FOND_L, h / (float) FOND_H); - int dw = Math.round(FOND_L * k), dh = Math.round(FOND_H * k); - g.blit(FOND, w - dw, (h - dh) / 2, dw, dh, 0f, 0f, FOND_L, FOND_H, FOND_L, FOND_H); + g.fill(0, 0, w, h, FOND); + } + + /** Étiquette en capitales, lettrage espacé (« GASTINEL », « ÉTAT DU SERVEUR »). Renvoie la largeur. */ + public static int etiquette(GuiGraphics g, Font f, String s, int x, int y, int couleur) { + int cx = x; + for (char ch : s.toUpperCase().toCharArray()) { + Component c = gras(String.valueOf(ch)); + g.drawString(f, c, cx, y, couleur, false); + cx += f.width(c) + 1; + } + return cx - x; + } + + public static int largeurEtiquette(Font f, String s) { + int l = 0; + for (char ch : s.toUpperCase().toCharArray()) l += f.width(gras(String.valueOf(ch))) + 1; + return l; + } + + /** Pastille carrée (aucun arrondi). */ + public static void carre(GuiGraphics g, int x, int y, int c, int couleur) { + g.fill(x, y, x + c, y + c, couleur); + } + + /** Jauge fine : piste grise, partie remplie à l'encre. */ + public static void jauge(GuiGraphics g, int x, int y, int l, double part) { + g.fill(x, y, x + l, y + 2, FILET); + g.fill(x, y, x + (int) Math.round(l * Math.max(0, Math.min(1, part))), y + 2, ENCRE); } /** Filet horizontal fin. */ diff --git a/src/main/resources/assets/gastinelclient/textures/gui/fond.png b/src/main/resources/assets/gastinelclient/textures/gui/fond.png deleted file mode 100644 index 1a297fe..0000000 Binary files a/src/main/resources/assets/gastinelclient/textures/gui/fond.png and /dev/null differ diff --git a/src/test/java/com/gastinelclient/core/LibellesTest.java b/src/test/java/com/gastinelclient/core/LibellesTest.java index e0df990..1790ad1 100644 --- a/src/test/java/com/gastinelclient/core/LibellesTest.java +++ b/src/test/java/com/gastinelclient/core/LibellesTest.java @@ -26,5 +26,8 @@ class LibellesTest { assertEquals(1.0, Libelles.pas01(0.98, 0.05)); assertEquals(0.0, Libelles.pas01(0.02, -0.05)); assertEquals(32, Libelles.borne(40, 2, 32)); + assertEquals(0.5, Libelles.fraction(17, 2, 32)); + assertEquals(1.0, Libelles.fraction(40, 2, 32)); + assertEquals(0.0, Libelles.fraction(5, 5, 5)); } }