1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2025-06-13 13:04:03 +00:00

Minor puzzle improvements

This commit is contained in:
tobspr 2021-05-03 23:23:41 +02:00
parent 4f846edb9b
commit 05418c2163
4 changed files with 53 additions and 31 deletions

View File

@ -62,9 +62,9 @@
> .puzzles { > .puzzles {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(D(130px), 1fr)); grid-template-columns: repeat(auto-fit, minmax(D(180px), 1fr));
@include S(grid-auto-rows, 90px); @include S(grid-auto-rows, 65px);
@include S(grid-gap, 3px); @include S(grid-gap, 7px);
@include S(margin-top, 10px); @include S(margin-top, 10px);
@include S(padding-right, 4px); @include S(padding-right, 4px);
@include S(height, 360px); @include S(height, 360px);
@ -74,19 +74,20 @@
> .puzzle { > .puzzle {
width: 100%; width: 100%;
@include S(height, 90px); @include S(height, 65px);
background: #f3f3f8; background: #f3f3f8;
@include S(border-radius, $globalBorderRadius); @include S(border-radius, $globalBorderRadius);
display: grid; display: grid;
grid-template-columns: 1fr auto; grid-template-columns: auto 1fr;
grid-template-rows: D(15px) 1fr auto; grid-template-rows: D(15px) D(15px) 1fr;
@include S(padding, 5px); @include S(padding, 5px);
@include S(grid-column-gap, 5px); @include S(grid-column-gap, 5px);
box-sizing: border-box; box-sizing: border-box;
pointer-events: all; pointer-events: all;
cursor: pointer; cursor: pointer;
position: relative; position: relative;
@include S(padding-left, 10px);
@include DarkThemeOverride { @include DarkThemeOverride {
background: rgba(0, 0, 10, 0.2); background: rgba(0, 0, 10, 0.2);
@ -106,23 +107,35 @@
} }
> .title { > .title {
grid-column: 1 / 3; grid-column: 2 / 3;
grid-row: 1 / 2; grid-row: 1 / 2;
@include PlainText; @include PlainText;
white-space: nowrap; white-space: nowrap;
text-overflow: ellipsis; text-overflow: ellipsis;
overflow: hidden; overflow: hidden;
align-self: center; align-self: center;
justify-self: center; justify-self: start;
width: 100%; width: 100%;
box-sizing: border-box; box-sizing: border-box;
@include S(padding, 2px, 5px); @include S(padding, 2px, 5px);
@include S(height, 17px); @include S(height, 17px);
} }
> .icon { > .author {
grid-column: 1 / 3; grid-column: 2 / 2;
grid-row: 2 / 3; grid-row: 2 / 3;
@include SuperSmallText;
color: $accentColorDark;
align-self: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@include S(padding, 2px, 5px);
}
> .icon {
grid-column: 1 / 2;
grid-row: 1 / 4;
align-self: center; align-self: center;
justify-self: center; justify-self: center;
@include S(width, 45px); @include S(width, 45px);
@ -134,17 +147,6 @@
} }
} }
> .author {
grid-column: 1 / 2;
grid-row: 3 / 4;
@include SuperSmallText;
color: $accentColorDark;
align-self: center;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
> .stats { > .stats {
grid-column: 2 / 3; grid-column: 2 / 3;
grid-row: 3 / 4; grid-row: 3 / 4;
@ -200,14 +202,20 @@
color: #000; color: #000;
font-weight: bold; font-weight: bold;
@include S(margin-right, 3px); @include S(margin-right, 3px);
@include S(padding-left, 14px);
opacity: 0.7; opacity: 0.7;
@include DarkThemeInvert;
& { &.stage--easy {
/* @load-async */ color: $colorGreenBright;
background: uiResource("icons/puzzle_completion_rate.png") #{D(1px)} #{D(2px)} / }
#{D(10px)} #{D(10px)} no-repeat; &.stage--normal {
color: #000;
@include DarkThemeInvert;
}
&.stage--medium {
color: $colorOrangeBright;
}
&.stage--hard {
color: $colorRedBright;
} }
} }
} }

View File

@ -35,6 +35,7 @@ $accentColorDark: #7d808a;
$colorGreenBright: #66bb6a; $colorGreenBright: #66bb6a;
$colorBlueBright: rgb(74, 151, 223); $colorBlueBright: rgb(74, 151, 223);
$colorRedBright: #ef5072; $colorRedBright: #ef5072;
$colorOrangeBright: #ef9d50;
$themeColor: #393747; $themeColor: #393747;
$ingameHudBg: rgba(#333438, 0.9); $ingameHudBg: rgba(#333438, 0.9);

View File

@ -3,14 +3,13 @@ import { createLogger } from "../core/logging";
import { DialogWithForm } from "../core/modal_dialog_elements"; import { DialogWithForm } from "../core/modal_dialog_elements";
import { FormElementInput } from "../core/modal_dialog_forms"; import { FormElementInput } from "../core/modal_dialog_forms";
import { TextualGameState } from "../core/textual_game_state"; import { TextualGameState } from "../core/textual_game_state";
import { clamp, formatBigNumberFull } from "../core/utils"; import { formatBigNumberFull } from "../core/utils";
import { enumGameModeIds } from "../game/game_mode"; import { enumGameModeIds } from "../game/game_mode";
import { PUZZLE_RATINGS } from "../game/hud/parts/puzzle_complete_notification";
import { ShapeDefinition } from "../game/shape_definition"; import { ShapeDefinition } from "../game/shape_definition";
import { Savegame } from "../savegame/savegame"; import { Savegame } from "../savegame/savegame";
import { T } from "../translations"; import { T } from "../translations";
const categories = ["top-rated", "short", "hard", "new", "mine"]; const categories = ["top-rated", "new", "easy", "short", "hard", "completed", "mine"];
/** /**
* @type {import("../savegame/savegame_typedefs").PuzzleMetadata} * @type {import("../savegame/savegame_typedefs").PuzzleMetadata}
@ -186,8 +185,20 @@ export class PuzzleMenuState extends TextualGameState {
if (puzzle.downloads > 0) { if (puzzle.downloads > 0) {
const difficulty = document.createElement("div"); const difficulty = document.createElement("div");
difficulty.classList.add("difficulty"); difficulty.classList.add("difficulty");
difficulty.innerText = Math.round((puzzle.completions / puzzle.downloads) * 100.0) + "%";
const completionPercentage = Math.round((puzzle.completions / puzzle.downloads) * 100.0);
difficulty.innerText = completionPercentage + "%";
stats.appendChild(difficulty); stats.appendChild(difficulty);
if (completionPercentage < 10) {
difficulty.classList.add("stage--hard");
} else if (completionPercentage < 30) {
difficulty.classList.add("stage--medium");
} else if (completionPercentage < 60) {
difficulty.classList.add("stage--normal");
} else {
difficulty.classList.add("stage--easy");
}
} }
const downloads = document.createElement("div"); const downloads = document.createElement("div");

View File

@ -137,7 +137,9 @@ puzzleMenu:
top-rated: Top Rated top-rated: Top Rated
mine: My Puzzles mine: My Puzzles
short: Short short: Short
easy: Easy
hard: Hard hard: Hard
completed: Completed
validation: validation:
title: Invalid Puzzle title: Invalid Puzzle