1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2026-03-02 03:39:21 +00:00

Properly implement sound and music volumes, debounce writes

This commit is contained in:
tobspr
2020-09-13 08:40:56 +02:00
parent 50e40888fd
commit 6042fcba62
13 changed files with 9695 additions and 9712 deletions

View File

@@ -351,12 +351,12 @@ canvas {
box-sizing: border-box;
}
.pressed {
.pressed:not(.noPressEffect) {
transform: scale(0.98) !important;
animation: none !important;
}
.pressedSmallElement {
.pressedSmallElement:not(.noPressEffect) {
transform: scale(0.88) !important;
animation: none !important;
}
@@ -570,36 +570,46 @@ canvas {
}
}
.range {
.rangeInputContainer {
display: flex;
align-items: center;
justify-content: center;
label {
@include S(margin-right, 5px);
&,
& * {
@include PlainText;
}
}
}
.range-input {
input.rangeInput {
cursor: pointer;
background-color: transparent;
width: 100px;
height: 10px;
transform: translate(7px, 2px);
@include S(width, 100px);
@include S(height, 16px);
&::-webkit-slider-runnable-track {
background-color: darken($mainBgColor, 3);
color: darken($mainBgColor, 3);
height: 16px;
border-radius: 8px;
// @include S(height, 16px);
@include S(border-radius, 8px);
}
&::-webkit-slider-thumb {
appearance: none;
-webkit-appearance: none;
box-shadow: inset 0 0 0 10px $themeColor;
background-color: transparent;
width: 20px;
height: 20px;
box-shadow: inset 0 0 0 D(10px) $themeColor;
border-radius: 50%;
transition: 0.3s;
transition: box-shadow 0.3s;
}
&:hover::-webkit-slider-thumb {
box-shadow: inset 0 0 0 10px lighten($themeColor, 15);
&:hover {
&::-webkit-slider-thumb {
box-shadow: inset 0 0 0 D(10px) lighten($themeColor, 15);
}
}
}

View File

@@ -1,160 +1,147 @@
#ingame_HUD_GameMenu {
position: absolute;
top: 0;
right: 0;
display: flex;
grid-auto-flow: column;
> .menuButtons {
position: relative;
display: flex;
flex-grow: 1;
@include S(padding, 5px, 4px);
justify-content: flex-end;
@include S(margin-left, 20px);
> .button {
@include S(width, 30px);
@include S(height, 30px);
display: inline-block;
background: center center / 60% no-repeat;
pointer-events: all;
cursor: pointer;
transition: all 0.12s ease-in-out;
transition-property: opacity, transform;
will-change: opacity;
opacity: 0.9;
@include S(margin-left, 5px);
position: relative;
@include IncreasedClickArea(0px);
@include DarkThemeInvert;
&:hover {
opacity: 0.8;
}
&.music {
background-image: uiResource("icons/music_on.png");
&.muted {
background-image: uiResource("icons/music_off.png");
}
}
&.sfx {
background-image: uiResource("icons/sound_on.png");
&.muted {
background-image: uiResource("icons/sound_off.png");
}
}
&.save {
background-image: uiResource("icons/save.png");
@include MakeAnimationWrappedEvenOdd(0.5s ease-in-out) {
0% {
transform: scale(1, 1);
}
70% {
transform: scale(1.5, 1.5) rotate(20deg);
opacity: 0.2;
}
85% {
transform: scale(0.9, 0.9);
opacity: 1;
}
90% {
transform: scale(1.1, 1.1);
}
}
}
&.settings {
background-image: uiResource("icons/settings.png");
}
}
}
.buttonContainer button {
@include PlainText;
color: #fff;
border-color: rgba(0, 0, 0, 0.1);
@include S(padding, 5px, 5px, 5px);
@include S(padding-left, 30px);
@include S(margin-right, 3px);
@include IncreasedClickArea(0px);
@include ButtonText;
@include S(min-height, 40px);
transition: all 0.12s ease-in-out;
transition-property: opacity, transform;
display: inline-flex;
background: center #{D(13px)} / #{D(20px)} no-repeat;
background-color: $colorGreenBright;
&[data-button-id="shop"] {
background-color: rgb(93, 103, 250);
background-image: uiResource("icons/shop.png");
background-size: #{D(18px)};
}
&[data-button-id="stats"] {
background-color: rgb(85, 199, 138);
background-image: uiResource("icons/statistics.png");
}
&:hover {
opacity: 0.9;
}
.keybinding {
border: 0;
color: #fff;
border-top-left-radius: 0;
border-top-right-radius: 0;
bottom: unset;
background: transparent;
@include S(top, 0px);
right: unset;
left: 50%;
transform: translateX(-50%);
}
&:not(.hasBadge) .badge {
display: none;
}
&.hasBadge {
transform-origin: 50% 0%;
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: scale(1.02);
}
}
.badge {
position: absolute;
@include S(bottom, -8px);
left: 50%;
transform: translateX(-50%);
background: #333;
@include PlainText;
display: flex;
justify-content: center;
align-items: center;
@include S(min-width, 5px);
@include S(height, 10px);
@include S(padding, 1px, 3px, 2px);
@include S(border-radius, $globalBorderRadius);
border: #{D(1px)} solid #fff;
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: translateX(-50%) scale(1.05);
}
}
}
}
}
}
#ingame_HUD_GameMenu {
position: absolute;
top: 0;
right: 0;
display: flex;
grid-auto-flow: column;
> .menuButtons {
position: relative;
display: flex;
flex-grow: 1;
@include S(padding, 5px, 4px);
justify-content: flex-end;
@include S(margin-left, 20px);
> .button {
@include S(width, 30px);
@include S(height, 30px);
display: inline-block;
background: center center / 60% no-repeat;
pointer-events: all;
cursor: pointer;
transition: all 0.12s ease-in-out;
transition-property: opacity, transform;
will-change: opacity;
opacity: 0.9;
@include S(margin-left, 5px);
position: relative;
@include IncreasedClickArea(0px);
@include DarkThemeInvert;
&:hover {
opacity: 0.8;
}
&.save {
background-image: uiResource("icons/save.png");
@include MakeAnimationWrappedEvenOdd(0.5s ease-in-out) {
0% {
transform: scale(1, 1);
}
70% {
transform: scale(1.5, 1.5) rotate(20deg);
opacity: 0.2;
}
85% {
transform: scale(0.9, 0.9);
opacity: 1;
}
90% {
transform: scale(1.1, 1.1);
}
}
}
&.settings {
background-image: uiResource("icons/settings.png");
}
}
}
.buttonContainer button {
@include PlainText;
color: #fff;
border-color: rgba(0, 0, 0, 0.1);
@include S(padding, 5px, 5px, 5px);
@include S(padding-left, 30px);
@include S(margin-right, 3px);
@include IncreasedClickArea(0px);
@include ButtonText;
@include S(min-height, 40px);
transition: all 0.12s ease-in-out;
transition-property: opacity, transform;
display: inline-flex;
background: center #{D(13px)} / #{D(20px)} no-repeat;
background-color: $colorGreenBright;
&[data-button-id="shop"] {
background-color: rgb(93, 103, 250);
background-image: uiResource("icons/shop.png");
background-size: #{D(18px)};
}
&[data-button-id="stats"] {
background-color: rgb(85, 199, 138);
background-image: uiResource("icons/statistics.png");
}
&:hover {
opacity: 0.9;
}
.keybinding {
border: 0;
color: #fff;
border-top-left-radius: 0;
border-top-right-radius: 0;
bottom: unset;
background: transparent;
@include S(top, 0px);
right: unset;
left: 50%;
transform: translateX(-50%);
}
&:not(.hasBadge) .badge {
display: none;
}
&.hasBadge {
transform-origin: 50% 0%;
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: scale(1.02);
}
}
.badge {
position: absolute;
@include S(bottom, -8px);
left: 50%;
transform: translateX(-50%);
background: #333;
@include PlainText;
display: flex;
justify-content: center;
align-items: center;
@include S(min-width, 5px);
@include S(height, 10px);
@include S(padding, 1px, 3px, 2px);
@include S(border-radius, $globalBorderRadius);
border: #{D(1px)} solid #fff;
@include InlineAnimation(1s ease-in-out infinite) {
50% {
transform: translateX(-50%) scale(1.05);
}
}
}
}
}
}

View File

@@ -1,188 +1,188 @@
#state_SettingsState {
$colorCategoryButton: #eee;
$colorCategoryButtonSelected: #5f748b;
.container .content {
display: flex;
overflow-y: scroll;
.categoryContainer {
width: 100%;
.category {
display: none;
&.active {
display: block;
}
.setting {
@include S(padding, 10px);
background: #eeeff5;
@include S(border-radius, $globalBorderRadius);
@include S(margin-bottom, 5px);
label {
text-transform: uppercase;
@include Text;
}
.desc {
@include S(margin-top, 5px);
@include SuperSmallText;
color: #aaadb2;
}
> .row {
display: grid;
align-items: center;
grid-template-columns: 1fr auto;
}
&.disabled {
// opacity: 0.3;
pointer-events: none;
* {
pointer-events: none !important;
cursor: default !important;
}
position: relative;
.standaloneOnlyHint {
@include PlainText;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: all;
display: flex;
align-items: center;
justify-content: center;
background: rgba(#fff, 0.5);
text-transform: uppercase;
color: $colorRedBright;
}
}
.value.enum {
background: #fff;
@include PlainText;
display: flex;
align-items: flex-start;
pointer-events: all;
cursor: pointer;
justify-content: center;
@include S(min-width, 100px);
@include S(border-radius, $globalBorderRadius);
@include S(padding, 4px);
@include S(padding-right, 15px);
background: #fff uiResource("icons/enum_selector.png") calc(100% - #{D(5px)})
calc(50% + #{D(1px)}) / #{D(15px)} no-repeat;
transition: background-color 0.12s ease-in-out;
&:hover {
background-color: #fafafa;
}
}
}
}
}
.sidebar {
display: flex;
flex-direction: column;
@include S(min-width, 210px);
@include S(max-width, 320px);
width: 30%;
height: 100%;
position: sticky;
top: 0;
@include S(margin-left, 20px);
@include S(margin-right, 32px);
.other {
margin-top: auto;
}
button {
@include S(margin-top, 4px);
width: calc(100% - #{D(20px)});
text-align: start;
&::after {
content: unset;
}
}
button.categoryButton,
button.about {
background-color: $colorCategoryButton;
color: #777a7f;
&.active {
background-color: $colorCategoryButtonSelected;
color: #fff;
&:hover {
opacity: 1;
}
}
&.pressed {
transform: none !important;
}
}
.versionbar {
@include S(margin-top, 20px);
@include SuperSmallText;
display: grid;
align-items: center;
grid-template-columns: 1fr auto;
.buildVersion {
display: flex;
flex-direction: column;
color: #aaadaf;
}
}
}
}
@include DarkThemeOverride {
.container .content {
.sidebar {
button.categoryButton,
button.about {
background-color: #3f3f47;
&.active {
background-color: $colorBlueBright;
}
}
}
.categoryContainer {
.category {
.setting {
background: darken($darkModeGameBackground, 10);
.value.enum {
// dirty but works
filter: invert(0.78) sepia(40%) hue-rotate(190deg);
color: #222;
}
.value.checkbox {
background-color: #74767b;
&.checked {
background-color: $colorBlueBright;
}
}
}
}
}
}
}
}
#state_SettingsState {
$colorCategoryButton: #eee;
$colorCategoryButtonSelected: #5f748b;
.container .content {
display: flex;
overflow-y: scroll;
.categoryContainer {
width: 100%;
.category {
display: none;
&.active {
display: block;
}
.setting {
@include S(padding, 10px);
background: #eeeff5;
@include S(border-radius, $globalBorderRadius);
@include S(margin-bottom, 5px);
.desc {
@include S(margin-top, 5px);
@include SuperSmallText;
color: #aaadb2;
}
> .row {
display: grid;
align-items: center;
grid-template-columns: 1fr auto;
> label {
text-transform: uppercase;
@include Text;
}
}
&.disabled {
// opacity: 0.3;
pointer-events: none;
* {
pointer-events: none !important;
cursor: default !important;
}
position: relative;
.standaloneOnlyHint {
@include PlainText;
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
pointer-events: all;
display: flex;
align-items: center;
justify-content: center;
background: rgba(#fff, 0.5);
text-transform: uppercase;
color: $colorRedBright;
}
}
.value.enum {
background: #fff;
@include PlainText;
display: flex;
align-items: flex-start;
pointer-events: all;
cursor: pointer;
justify-content: center;
@include S(min-width, 100px);
@include S(border-radius, $globalBorderRadius);
@include S(padding, 4px);
@include S(padding-right, 15px);
background: #fff uiResource("icons/enum_selector.png") calc(100% - #{D(5px)})
calc(50% + #{D(1px)}) / #{D(15px)} no-repeat;
transition: background-color 0.12s ease-in-out;
&:hover {
background-color: #fafafa;
}
}
}
}
}
.sidebar {
display: flex;
flex-direction: column;
@include S(min-width, 210px);
@include S(max-width, 320px);
width: 30%;
height: 100%;
position: sticky;
top: 0;
@include S(margin-left, 20px);
@include S(margin-right, 32px);
.other {
margin-top: auto;
}
button {
@include S(margin-top, 4px);
width: calc(100% - #{D(20px)});
text-align: start;
&::after {
content: unset;
}
}
button.categoryButton,
button.about {
background-color: $colorCategoryButton;
color: #777a7f;
&.active {
background-color: $colorCategoryButtonSelected;
color: #fff;
&:hover {
opacity: 1;
}
}
&.pressed {
transform: none !important;
}
}
.versionbar {
@include S(margin-top, 20px);
@include SuperSmallText;
display: grid;
align-items: center;
grid-template-columns: 1fr auto;
.buildVersion {
display: flex;
flex-direction: column;
color: #aaadaf;
}
}
}
}
@include DarkThemeOverride {
.container .content {
.sidebar {
button.categoryButton,
button.about {
background-color: #3f3f47;
&.active {
background-color: $colorBlueBright;
}
}
}
.categoryContainer {
.category {
.setting {
background: darken($darkModeGameBackground, 10);
.value.enum {
// dirty but works
filter: invert(0.78) sepia(40%) hue-rotate(190deg);
color: #222;
}
.value.checkbox {
background-color: #74767b;
&.checked {
background-color: $colorBlueBright;
}
}
}
}
}
}
}
}