mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-06-13 13:04:03 +00:00
Added reset all and fixed double notifications
This commit is contained in:
parent
5f0cd2c675
commit
9ef35a2b1c
BIN
res/ui/achievements/reset.png
Normal file
BIN
res/ui/achievements/reset.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
@ -39,6 +39,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.info {
|
.info {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: center;
|
||||||
grid-column: 2;
|
grid-column: 2;
|
||||||
grid-row: 2 / 3;
|
grid-row: 2 / 3;
|
||||||
.title {
|
.title {
|
||||||
@ -74,6 +77,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.reset {
|
||||||
|
button.reset {
|
||||||
|
background-color: $colorRedBright;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: darken($colorRedBright, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.info {
|
||||||
|
.title {
|
||||||
|
font-weight: bold;
|
||||||
|
color: $colorRedBright;
|
||||||
|
}
|
||||||
|
.description {
|
||||||
|
color: lighten($colorRedBright, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:not(.unlocked) {
|
&:not(.unlocked) {
|
||||||
button.reset {
|
button.reset {
|
||||||
background-color: #aaa;
|
background-color: #aaa;
|
||||||
|
@ -66,7 +66,7 @@ $icons: notification_saved, notification_success, notification_upgrade, notifica
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$achievements: hidden, belt500Tiles, blueprint100k, blueprint1m, completeLvl26, cutShape, darkMode,
|
$achievements: reset, hidden, belt500Tiles, blueprint100k, blueprint1m, completeLvl26, cutShape, darkMode,
|
||||||
destroy1000, irrelevantShape, level100, level50, logoBefore18, mam, mapMarkers15, noBeltUpgradesUntilBp,
|
destroy1000, irrelevantShape, level100, level50, logoBefore18, mam, mapMarkers15, noBeltUpgradesUntilBp,
|
||||||
noInverseRotater, oldLevel17, openWires, paintShape, place5000Wires, placeBlueprint, placeBp1000, play1h,
|
noInverseRotater, oldLevel17, openWires, paintShape, place5000Wires, placeBlueprint, placeBp1000, play1h,
|
||||||
play10h, play20h, produceLogo, produceMsLogo, produceRocket, rotateShape, speedrunBp30, speedrunBp60,
|
play10h, play20h, produceLogo, produceMsLogo, produceRocket, rotateShape, speedrunBp30, speedrunBp60,
|
||||||
|
@ -65,38 +65,95 @@ export class HUDAchievements extends BaseHUDPart {
|
|||||||
this.achievementToElements[achievementKey] = handle;
|
this.achievementToElements[achievementKey] = handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
const handle = {};
|
this.hiddenElement = {};
|
||||||
// Wrapper
|
// Wrapper
|
||||||
handle.hidden = makeDiv(this.contentDiv, null, ["achievement"]);
|
this.hiddenElement.hidden = makeDiv(this.contentDiv, null, ["achievement"]);
|
||||||
|
|
||||||
// Icon
|
// Icon
|
||||||
handle.icon = makeDiv(handle.hidden, null, ["icon"]);
|
this.hiddenElement.icon = makeDiv(this.hiddenElement.hidden, null, ["icon"]);
|
||||||
handle.icon.setAttribute("data-icon", "achievements/hidden.png");
|
this.hiddenElement.icon.setAttribute("data-icon", "achievements/hidden.png");
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
handle.info = makeDiv(handle.hidden, null, ["info"]);
|
this.hiddenElement.info = makeDiv(this.hiddenElement.hidden, null, ["info"]);
|
||||||
|
|
||||||
// Title
|
// Title
|
||||||
handle.title = makeDiv(handle.info, null, ["title"], T.achievements.hidden.title);
|
this.hiddenElement.title = makeDiv(
|
||||||
|
this.hiddenElement.info,
|
||||||
|
null,
|
||||||
|
["title"],
|
||||||
|
T.achievements.hidden.title
|
||||||
|
);
|
||||||
|
|
||||||
// Description
|
// Description
|
||||||
handle.description = makeDiv(
|
this.hiddenElement.description = makeDiv(
|
||||||
handle.info,
|
this.hiddenElement.info,
|
||||||
null,
|
null,
|
||||||
["description"],
|
["description"],
|
||||||
T.achievements.hidden.description.replace("<amountHidden>", HIDDEN_ACHIEVEMENTS.length + "")
|
T.achievements.hidden.description.replace("<amountHidden>", HIDDEN_ACHIEVEMENTS.length + "")
|
||||||
);
|
);
|
||||||
this.hiddenElement = handle;
|
|
||||||
|
this.resetElement = {};
|
||||||
|
|
||||||
|
// Wrapper
|
||||||
|
this.resetElement.elem = makeDiv(this.contentDiv, null, ["achievement", "reset", "unlocked"]);
|
||||||
|
|
||||||
|
// Icon
|
||||||
|
this.resetElement.icon = makeDiv(this.resetElement.elem, null, ["icon"]);
|
||||||
|
this.resetElement.icon.setAttribute("data-icon", "achievements/reset.png");
|
||||||
|
|
||||||
|
// Info
|
||||||
|
this.resetElement.info = makeDiv(this.resetElement.elem, null, ["info"]);
|
||||||
|
|
||||||
|
// Title
|
||||||
|
this.resetElement.title = makeDiv(
|
||||||
|
this.resetElement.info,
|
||||||
|
null,
|
||||||
|
["title"],
|
||||||
|
T.achievements.reset.title
|
||||||
|
);
|
||||||
|
|
||||||
|
// Description
|
||||||
|
this.resetElement.description = makeDiv(
|
||||||
|
this.resetElement.info,
|
||||||
|
null,
|
||||||
|
["description"],
|
||||||
|
T.achievements.reset.description
|
||||||
|
);
|
||||||
|
|
||||||
|
// Reset button
|
||||||
|
this.resetElement.resetButton = document.createElement("button");
|
||||||
|
this.resetElement.resetButton.classList.add("reset", "styledButton");
|
||||||
|
this.resetElement.resetButton.innerText = T.ingame.achievements.buttonReset;
|
||||||
|
this.resetElement.elem.appendChild(this.resetElement.resetButton);
|
||||||
|
this.trackClicks(this.resetElement.resetButton, () => {
|
||||||
|
const signals = this.root.hud.parts.dialogs.showWarning(
|
||||||
|
T.dialogs.resetAchievements.title,
|
||||||
|
T.dialogs.resetAchievements.description,
|
||||||
|
["cancel:bad:escape", "ok:good:enter"]
|
||||||
|
);
|
||||||
|
signals.ok.add(() => {
|
||||||
|
for (const achievementKey in ACHIEVEMENTS) {
|
||||||
|
if (!this.root.achievementProxy.provider.collection.map.has(achievementKey))
|
||||||
|
this.root.achievementProxy.provider.collection.lock(
|
||||||
|
achievementKey,
|
||||||
|
enum_achievement_mappings[ACHIEVEMENTS[achievementKey]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
renderStatus() {
|
renderStatus() {
|
||||||
|
let unlocked = 0;
|
||||||
let hidden = 0;
|
let hidden = 0;
|
||||||
for (const achievementKey in this.achievementToElements) {
|
for (const achievementKey in this.achievementToElements) {
|
||||||
const handle = this.achievementToElements[achievementKey];
|
const handle = this.achievementToElements[achievementKey];
|
||||||
|
|
||||||
|
//Check if user has achievement
|
||||||
if (!this.root.achievementProxy.provider.collection.map.get(ACHIEVEMENTS[achievementKey])) {
|
if (!this.root.achievementProxy.provider.collection.map.get(ACHIEVEMENTS[achievementKey])) {
|
||||||
if (!handle.elem.classList.contains("unlocked")) handle.elem.classList.add("unlocked");
|
if (!handle.elem.classList.contains("unlocked")) handle.elem.classList.add("unlocked");
|
||||||
if (handle.elem.classList.contains("hidden")) handle.elem.classList.remove("hidden");
|
if (handle.elem.classList.contains("hidden")) handle.elem.classList.remove("hidden");
|
||||||
|
unlocked++;
|
||||||
} else {
|
} else {
|
||||||
if (handle.elem.classList.contains("unlocked")) handle.elem.classList.remove("unlocked");
|
if (handle.elem.classList.contains("unlocked")) handle.elem.classList.remove("unlocked");
|
||||||
|
|
||||||
@ -111,6 +168,12 @@ export class HUDAchievements extends BaseHUDPart {
|
|||||||
"<amountHidden>",
|
"<amountHidden>",
|
||||||
hidden + ""
|
hidden + ""
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (unlocked > 0) {
|
||||||
|
if (!this.resetElement.elem.classList.contains("unlocked"))
|
||||||
|
this.resetElement.elem.classList.add("unlocked");
|
||||||
|
} else if (this.resetElement.elem.classList.contains("unlocked"))
|
||||||
|
this.resetElement.elem.classList.remove("unlocked");
|
||||||
}
|
}
|
||||||
|
|
||||||
initialize() {
|
initialize() {
|
||||||
|
@ -472,8 +472,8 @@ export class AchievementCollection {
|
|||||||
achievement
|
achievement
|
||||||
.unlock()
|
.unlock()
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (this.map.has(key)) this.root.signals.achievementCompleted.dispatch(key, data);
|
||||||
this.onActivate(null, key);
|
this.onActivate(null, key);
|
||||||
this.root.signals.achievementCompleted.dispatch(key, data);
|
|
||||||
})
|
})
|
||||||
.catch(err => {
|
.catch(err => {
|
||||||
this.onActivate(err, key);
|
this.onActivate(err, key);
|
||||||
|
@ -253,6 +253,10 @@ dialogs:
|
|||||||
title: Tutorial Available
|
title: Tutorial Available
|
||||||
desc: There is a tutorial video available for this level, but it is only available in English. Would you like to watch it?
|
desc: There is a tutorial video available for this level, but it is only available in English. Would you like to watch it?
|
||||||
|
|
||||||
|
resetAchievements:
|
||||||
|
title: Reset Achievements
|
||||||
|
description: Are you sure you want to reset all your achievements?
|
||||||
|
|
||||||
ingame:
|
ingame:
|
||||||
# This is shown in the top left corner and displays useful keybindings in
|
# This is shown in the top left corner and displays useful keybindings in
|
||||||
# every situation
|
# every situation
|
||||||
@ -499,6 +503,9 @@ shopUpgrades:
|
|||||||
|
|
||||||
# All achievements
|
# All achievements
|
||||||
achievements:
|
achievements:
|
||||||
|
reset:
|
||||||
|
title: Reset achievements
|
||||||
|
description: Resets all your achievements!
|
||||||
hidden:
|
hidden:
|
||||||
title: Hidden achievements
|
title: Hidden achievements
|
||||||
description: You have <amountHidden> hidden achievement(s)
|
description: You have <amountHidden> hidden achievement(s)
|
||||||
|
Loading…
Reference in New Issue
Block a user