From d5de568f9ea6ce8f09f5e6bbd441be0b7479653c Mon Sep 17 00:00:00 2001 From: Edward Badel Date: Sun, 27 Jun 2021 21:43:50 -0400 Subject: [PATCH] Small Improvements --- gulp/contributors.js | 8 +-- src/css/states/credits.scss | 32 +++++------- src/js/states/credits.js | 98 +++++++++++++++++++++---------------- translations/base-en.yaml | 12 +++++ 4 files changed, 81 insertions(+), 69 deletions(-) diff --git a/gulp/contributors.js b/gulp/contributors.js index 396b364c..8bf71c83 100644 --- a/gulp/contributors.js +++ b/gulp/contributors.js @@ -5,7 +5,7 @@ const nodeFetch = require("node-fetch"); const APILink = "https://api.github.com/repos/tobspr/shapez.io"; const numOfReqPerPage = 100; // Max is 100, change to something lower if loads are too long -const personalAccessToken = " tryToUpdateContributors().then(() => cb)); gulp.task("contributors.build.force", cb => updateContributors().then(() => cb)); - - gulp.task("fetch.test", cb => { - fetch(APILink) - .then(res => console.log(res.headers.get("x-ratelimit-remaining"))) - .then(cb); - }); } module.exports = { diff --git a/src/css/states/credits.scss b/src/css/states/credits.scss index 6cf967b8..da619a26 100644 --- a/src/css/states/credits.scss +++ b/src/css/states/credits.scss @@ -2,6 +2,10 @@ .container .content { text-align: center; + .tobspr .title { + @include S(margin-top, 10px); + } + .section { @include S(margin-top, 10px); @include S(padding, 5px); @@ -12,28 +16,18 @@ .title { @include Heading; + @include S(margin-bottom, 8px); + + color: #555; + @include DarkThemeOverride { + color: #eee; + } } .people { - .entry { - } - - .flex-entry { - display: flex; - - .entry { - display: inline-block; - width: min-content; - } - } - } - - .people-flex { - display: flex; - - .entry { - display: flex; - } + max-height: 0; + overflow: hidden; + transition: max-height 0.5s ease-out; } } } diff --git a/src/js/states/credits.js b/src/js/states/credits.js index be577fe1..f302553e 100644 --- a/src/js/states/credits.js +++ b/src/js/states/credits.js @@ -1,76 +1,61 @@ import { TextualGameState } from "../core/textual_game_state"; import { contributors, translators } from "../../../contributors.json"; -const APILink = "https://api.github.com/repos/tobspr/shapez.io"; // Should use THRIDPARY_URLS, but it is really hard to read. -const numOfReqPerPage = 100; // Max is 100, change to something lower if loads are too long +import { T } from "../translations"; export class CreditsState extends TextualGameState { constructor() { super("CreditsState"); - this.state = "Credits"; } getStateHeaderTitle() { - return this.state; + return T.credits.title; } getMainContentHTML() { return ` -
Tobias Springer - Main Programer and Artist
+
${this.linkify( + "https://github.com/tobspr", + "Tobias Springer" + )} - ${T.credits.tobspr}
-
A Special Thanks To:
+
-
Pepsin - Created the soundtrack
-
Sense 101 - Designed the Puzzle DLC's official puzzles
-
SargeanTravis - Created an achievement by whining a lot
-
Bagel03 - Was an absolute CHAD
-
Dengr - Wouldn't tell me what to put here
-
Block of Emerald - Also wouldn't tell me what to put here
+
${this.linkify( + "https://soundcloud.com/pettersumelius", + "Peppsen" + )} - ${T.credits.specialThanks.descriptions.peppsen}
+
Add some other people here (Whoever you think deserves it)
+
-
Translators:
-
- ${this.getTranslatorsHTML()} + +
+ ${this.getGithubHTML(translators)}
-
Contributors:
-
- ${this.getContributorsHTML()} + +
+ ${this.getGithubHTML(contributors)}
`; } - getTranslatorsHTML() { - let html = ""; - for (let i = 0; i < translators.length; i++) { - html += ` -
-
- ${ - translators[i].username - }:
${translators[i].value - .map(pr => { - return `${this.getGoodTitle(pr.title)}, `; - }) - .reduce((p, c) => p + c) - .slice(0, -2)} -
- `; - } - return html; + linkify(href, text) { + return `${text}`; } - getContributorsHTML() { + getGithubHTML(list) { let html = ""; - for (let i = 0; i < contributors.length; i++) { + for (let i = 0; i < list.length; i++) { html += ` -
+ ${i === 0 ? "" : "
"}
- ${ - contributors[i].username - }:
${contributors[i].value + ${this.linkify(`https://github.com/${list[i].username}`, list[i].username)}:
${list[ + i + ].value .map(pr => { return `${this.getGoodTitle(pr.title)}, `; }) @@ -89,6 +74,33 @@ export class CreditsState extends TextualGameState { } onEnter() { - // this.setPRInnerHTML(); + // Allow the user to close any section by clicking on the title + const buttons = this.htmlElement.querySelectorAll("button.title"); + buttons.forEach(button => { + /** @type {HTMLElement} */ + //@ts-ignore + const people = button.nextElementSibling; + + button.addEventListener("click", e => { + if (people.style.maxHeight) { + people.style.maxHeight = null; + } else { + people.style.maxHeight = people.scrollHeight + "px"; + } + }); + + // Set them to open at the start + people.style.maxHeight = people.scrollHeight + "px"; + }); + + // Link stuff + const links = this.htmlElement.querySelectorAll("a[href]"); + links.forEach(link => { + this.trackClicks( + link, + () => this.app.platformWrapper.openExternalLink(link.getAttribute("href")), + { preventClick: true } + ); + }); } } diff --git a/translations/base-en.yaml b/translations/base-en.yaml index 69ad421c..ab621f12 100644 --- a/translations/base-en.yaml +++ b/translations/base-en.yaml @@ -1381,6 +1381,18 @@ about: changelog: title: Changelog +credits: + title: Credits + tobspr: Main Programer and Artist + specialThanks: + title: Special Thanks To + descriptions: + peppsen: Created the awesome soundtrack + translators: + title: Translators + contributors: + title: Contributors + demo: features: restoringGames: Restoring savegames