From 66ea2388e9659c777d6b5e5021ebabd344eb123a Mon Sep 17 00:00:00 2001 From: Tobias Berger Date: Mon, 27 Sep 2021 11:12:31 +0200 Subject: [PATCH] Add Log and placeholder for resource table --- src/App.svelte | 2 +- src/components/Header.svelte | 6 +- src/components/Log.svelte | 64 +++++ src/components/ResourceTable.svelte | 8 + src/components/Wrapper.svelte | 21 +- src/shark/Message.ts | 15 ++ src/shark/Settings.ts | 342 +++++++++++++++++++++++++++ src/shark/{index.ts => SharkGame.ts} | 9 + src/styles/global.scss | 2 +- 9 files changed, 463 insertions(+), 6 deletions(-) create mode 100644 src/components/Log.svelte create mode 100644 src/components/ResourceTable.svelte create mode 100644 src/shark/Message.ts create mode 100644 src/shark/Settings.ts rename src/shark/{index.ts => SharkGame.ts} (83%) diff --git a/src/App.svelte b/src/App.svelte index 8486938..9b60685 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -2,7 +2,7 @@ import Footer from "./components/Footer.svelte"; import Header from "./components/Header.svelte"; import Wrapper from "./components/Wrapper.svelte"; - import { SharkGame } from "./shark"; + import { SharkGame } from "./shark/SharkGame"; SharkGame.init(); diff --git a/src/components/Header.svelte b/src/components/Header.svelte index 939236d..8b03fc4 100644 --- a/src/components/Header.svelte +++ b/src/components/Header.svelte @@ -1,5 +1,5 @@ + +
+ + +
    + {#each displaymessages as message, i} + {#if i < logLength} +
  1. {message}
  2. + {/if} + {/each} +
+
+ + diff --git a/src/components/ResourceTable.svelte b/src/components/ResourceTable.svelte new file mode 100644 index 0000000..ea68458 --- /dev/null +++ b/src/components/ResourceTable.svelte @@ -0,0 +1,8 @@ +
Resource Table goes here
+ + diff --git a/src/components/Wrapper.svelte b/src/components/Wrapper.svelte index 0c78c15..d13934c 100644 --- a/src/components/Wrapper.svelte +++ b/src/components/Wrapper.svelte @@ -1,7 +1,20 @@ -
Wrapper
+ + +
+
+ + +
+
diff --git a/src/shark/Message.ts b/src/shark/Message.ts new file mode 100644 index 0000000..12d2241 --- /dev/null +++ b/src/shark/Message.ts @@ -0,0 +1,15 @@ +export class Message { + static even = true; + isEven: boolean; + message: string; + + constructor(message: string) { + this.message = message; + this.isEven = Message.even; + Message.even = !Message.even; + } + + toString(): string { + return this.message; + } +} diff --git a/src/shark/Settings.ts b/src/shark/Settings.ts new file mode 100644 index 0000000..6826d74 --- /dev/null +++ b/src/shark/Settings.ts @@ -0,0 +1,342 @@ +// How to make current just be undefined here, but keep the type of defaultValue? + +export const Settings = { + // Internal / No category + buyAmount: { + current: 1, + defaultValue: 1 as const, + options: [1, 10, 100, -3, -2, -1, "custom"] as const, + }, + + grottoMode: { + current: "simple", + defaultValue: "simple" as const, + options: ["simple", "advanced"] as const, + }, + + showPercentages: { + current: "absolute", + defaultValue: "absolute" as const, + options: ["absolute", "percentage"] as const, + }, + + // PERFORMANCE + + framerate: { + current: 20, + defaultValue: 20 as const, + name: "Framerate/TPS" as const, + desc: "How fast to update the game." as const, + category: "PERFORMANCE" as const, + options: [1, 2, 5, 10, 20, 30] as const, + onChange(): void { + // main.applyFramerate(); + console.warn("TODO"); + }, + }, + + showAnimations: { + current: true, + defaultValue: true as const, + name: "Show Animations" as const, + desc: "Whether to show animated transitions." as const, + category: "PERFORMANCE" as const, + options: [true, false] as const, // might remove this option? could be a pain to continue supporting it + }, + + // LAYOUT + + minimizedTopbar: { + current: true, + defaultValue: true as const, + name: "Minimized Title Bar" as const, + desc: "Whether to minimize the title bar at the top." as const, + category: "LAYOUT" as const, + options: [true, false] as const, + onChange(): void { + // if (SharkGame.Settings.current["minimizedTopbar"]) { + // document.querySelector("body").classList.add("top-bar"); + // $("#wrapper").removeClass("notMinimized"); + // } else { + // document.querySelector("body").classList.remove("top-bar"); + // $("#wrapper").addClass("notMinimized"); + // } + console.warn("TODO"); + }, + }, + + groupResources: { + current: true, + defaultValue: true as const, + name: "Group Resources" as const, + desc: "Whether to categorize resources in the table." as const, + category: "LAYOUT" as const, + options: [true, false] as const, + onChange(): void { + // res.rebuildTable = true; + console.warn("TODO"); + }, + }, + + smallTable: { + current: false, + defaultValue: false as const, + name: "Smaller Table" as const, + desc: "Whether to make the stuff table smaller." as const, + category: "LAYOUT" as const, + options: [true, false] as const, + onChange(): void { + // res.rebuildTable = true; + console.warn("TODO"); + }, + }, + + buttonDisplayType: { + current: "pile", + defaultValue: "pile" as const, + name: "Home Sea Button Display" as const, + desc: "How to arrange buttons." as const, + category: "LAYOUT" as const, + options: ["list", "pile"] as const, + onChange(): void { + // SharkGame.TabHandler.changeTab(SharkGame.Tabs.current); + console.warn("TODO"); + }, + }, + + logLength: { + current: 30, + defaultValue: 30 as const, + name: "Max Log Messages" as const, + desc: "Max number of messages kept in the log." as const, + category: "LAYOUT" as const, + options: [5, 10, 15, 20, 30, 60] as const, + onChange(): void { + // log.correctLogLength(); + }, + }, + + sidebarWidth: { + current: "30%", + defaultValue: "30%" as const, + name: "Sidebar Width" as const, + desc: "How much screen space the sidebar should take." as const, + category: "LAYOUT" as const, + options: ["25%", "30%", "35%"] as const, + onChange(): void { + // const sidebar = $("#sidebar"); + // if (SharkGame.Settings.current.showAnimations) { + // sidebar.animate( + // { width: SharkGame.Settings.current.sidebarWidth }, + // 100 + // ); + // } else { + // sidebar.width(SharkGame.Settings.current.sidebarWidth); + // } + console.warn("TODO"); + }, + }, + + // APPEARANCE + + colorCosts: { + current: "color", + defaultValue: "color" as const, + name: "Color Resource Names" as const, + desc: "How to color names of resources." as const, + category: "APPEARANCE" as const, + options: ["color", "bright", "none"] as const, + onChange(): void { + // res.rebuildTable = true; + // stats.recreateIncomeTable = true; + console.warn("TODO"); + }, + }, + + boldCosts: { + current: true, + defaultValue: true as const, + name: "Bold Resource Names" as const, + desc: "Should resource names be bolded?" as const, + options: [true, false] as const, + category: "APPEARANCE" as const, + onChange(): void { + // res.rebuildTable = true; + // stats.recreateIncomeTable = true; + console.warn("TODO"); + }, + }, + + alwaysSingularTooltip: { + current: false, + defaultValue: false as const, + name: "Tooltip Always Singular" as const, + desc: "Should the tooltip only show what one of each thing produces?" as const, + category: "APPEARANCE" as const, + options: [true, false] as const, + }, + + tooltipQuantityReminders: { + current: true, + defaultValue: true as const, + name: "Tooltip Amount Reminder" as const, + desc: "Should tooltips tell you much you own of stuff?" as const, + category: "APPEARANCE" as const, + options: [true, false] as const, + }, + + enableThemes: { + current: true, + defaultValue: true as const, + name: "Enable Planet-dependent Styles" as const, + desc: "Should page colors change for different planets?" as const, + options: [true, false] as const, + category: "APPEARANCE" as const, + onChange(): void { + // if (SharkGame.Settings.enableThemes.current) { + // document.querySelector("body").classList.remove("no-theme"); + // } else { + // document.querySelector("body").classList.add("no-theme"); + // } + console.warn("TODO"); + }, + }, + + showIcons: { + current: true, + defaultValue: true as const, + name: "Show Action Button icons" as const, + desc: "Show button icons?" as const, + category: "APPEARANCE" as const, + options: [true, false] as const, + }, + + showTabImages: { + current: true, + defaultValue: true as const, + name: "Show Tab Header Images" as const, + desc: "Show art?" as const, + category: "APPEARANCE" as const, + options: [true, false] as const, + onChange(): void { + // SharkGame.TabHandler.changeTab(SharkGame.Tabs.current); + console.warn("TODO"); + }, + }, + + // ACCESSIBILITY + + doAspectTable: { + current: "tree", + defaultValue: "tree" as const, + name: "Aspect Table or Tree" as const, + desc: "Draw a visual aspect tree or a more accessible aspect table?" as const, + category: "ACCESSIBILITY" as const, + options: ["tree", "table"] as const, + }, + + verboseTokenDescriptions: { + current: false, + defaultValue: false as const, + name: "Verbose Token" as const, + desc: "Should tokens display text saying where they are?" as const, + category: "ACCESSIBILITY" as const, + options: [true, false] as const, + onChange(): void { + // res.tokens.updateTokenDescriptions(); + console.warn("TODO"); + }, + }, + + minuteHandEffects: { + current: true, + defaultValue: true as const, + name: "Minute Hand Special Effects" as const, + desc: "Should the minute hand glow a ton?" as const, + category: "ACCESSIBILITY" as const, + options: [true, false] as const, + onChange(): void { + // res.minuteHand.updatePowers(); + console.warn("TODO"); + }, + }, + + // OTHER + + idleEnabled: { + current: true, + defaultValue: true as const, + name: "Stored Offline Progress" as const, + desc: "Should the game store idle progress for later use? (otherwise, it will not go idle and will have real offline progress)" as const, + category: "OTHER" as const, + options: [true, false] as const, + onChange(): void { + // res.minuteHand.init(); + console.warn("TODO"); + }, + }, + + showTooltips: { + current: true, + defaultValue: true as const, + name: "Tooltips" as const, + desc: "Whether to show informational tooltips when hovering over certain stuff." as const, + category: "OTHER" as const, + options: [true, false] as const, + }, + + updateCheck: { + current: true, + defaultValue: true as const, + name: "Check for updates" as const, + desc: "Whether to notify you of new updates." as const, + category: "OTHER" as const, + options: [true, false] as const, + onChange(): void { + // clearInterval(SharkGame.Main.checkForUpdateHandler); + // if (SharkGame.Settings.current.updateCheck) { + // SharkGame.Main.checkForUpdateHandler = setInterval( + // main.checkForUpdates, + // 300000 + // ); + // } + console.warn("TODO"); + }, + }, + + offlineModeActive: { + current: true, + defaultValue: true as const, + name: "Offline Progress" as const, + desc: "Should there be ANY offline progress?" as const, + category: "OTHER" as const, + options: [true, false] as const, + }, + + // SAVES (Needs to come last due to hard-coded import/export/wipe buttons at the bottom) + + autosaveFrequency: { + // times given in minutes + current: 5, + defaultValue: 5 as const, + name: "Autosave Frequency" as const, + desc: "Number of minutes between autosaves." as const, + category: "SAVES" as const, + options: [1, 2, 5, 10, 30] as const, + onChange(): void { + // clearInterval(main.autosaveHandler); + // main.autosaveHandler = setInterval( + // main.autosave, + // SharkGame.Settings.current.autosaveFrequency * 60000 + // ); + // log.addMessage( + // "Now autosaving every " + + // SharkGame.Settings.current.autosaveFrequency + + // " minute" + + // sharktext.plural(SharkGame.Settings.current.autosaveFrequency) + + // "." + // ); + console.warn("TODO"); + }, + }, +}; diff --git a/src/shark/index.ts b/src/shark/SharkGame.ts similarity index 83% rename from src/shark/index.ts rename to src/shark/SharkGame.ts index 9e9699d..a9de521 100644 --- a/src/shark/index.ts +++ b/src/shark/SharkGame.ts @@ -1,3 +1,5 @@ +import { Message } from "./Message"; +import { Settings } from "./Settings"; import { StaticClass } from "./StaticClass"; export class SharkGame extends StaticClass { @@ -51,7 +53,14 @@ export class SharkGame extends StaticClass { ] as const; static title: string; + static readonly Settings = Settings; + static messages: Message[] = [new Message("Welcome to Sharg!")]; + static init(): void { + for (const setting of Object.values(Settings)) { + setting.current = setting.defaultValue; + } + SharkGame.title = SharkGame.#GAME_NAMES[ Math.floor(Math.random() * SharkGame.#GAME_NAMES.length) diff --git a/src/styles/global.scss b/src/styles/global.scss index c868bd7..e0d027c 100644 --- a/src/styles/global.scss +++ b/src/styles/global.scss @@ -2,7 +2,7 @@ html { height: calc(100vh - 2em - 3em); } body { - min-height: 100%; + height: 100%; margin: 0; font-family: Verdana, Geneva, sans-serif; text-align: center;