From 7ee2612c17a90a80e5a0a7793a4c81465e212c0c Mon Sep 17 00:00:00 2001 From: Martin Fournier Date: Sun, 9 Jan 2022 11:15:09 -0500 Subject: [PATCH] Allow drag on character overview Makes the character overview (and tutorial) draggable, persisting the {x, y, opened} in the user's settings. - Remove margin & padding from html, body and ensure main content is full height - Add setting to disable progress bars - Refactor options to use new OptionSwitch - Add exclusions to prettierignore - Specify line ending in prettier & gitattributes --- .gitattributes | 2 +- .prettierignore | 11 + .prettierrc | 1 + src/Settings/Settings.ts | 21 +- src/Terminal/commands/connect.ts | 2 - src/index.html | 5 + src/ui/GameRoot.tsx | 149 +++---- .../InteractiveTutorialRoot.tsx | 3 +- src/ui/React/CharacterOverview.tsx | 24 +- src/ui/React/GameOptionsRoot.tsx | 363 +++++------------- src/ui/React/OptionSwitch.tsx | 30 ++ src/ui/React/Overview.tsx | 135 +++++-- 12 files changed, 375 insertions(+), 371 deletions(-) create mode 100644 src/ui/React/OptionSwitch.tsx diff --git a/.gitattributes b/.gitattributes index 176a458f9..6313b56c5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto +* text=auto eol=lf diff --git a/.prettierignore b/.prettierignore index 0a8c737e6..3f7bbbd2b 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,3 +2,14 @@ node_modules package.json dist doc/build/ +doc/source +.build +.package + +editor.main.js +main.bundle.js +index.html +markdown + +package.json +package.lock.json diff --git a/.prettierrc b/.prettierrc index 907d4d108..89810948d 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,5 +1,6 @@ { "trailingComma": "all", + "endOfLine": "lf", "tabWidth": 2, "printWidth": 120 } diff --git a/src/Settings/Settings.ts b/src/Settings/Settings.ts index 5872b5c68..153ab43e5 100644 --- a/src/Settings/Settings.ts +++ b/src/Settings/Settings.ts @@ -2,7 +2,8 @@ import { ISelfInitializer, ISelfLoading } from "../types"; import { OwnedAugmentationsOrderSetting, PurchaseAugmentationsOrderSetting } from "./SettingEnums"; import { defaultTheme, ITheme } from "./Themes"; import { defaultStyles, IStyleSettings } from "./Styles"; -import { WordWrapOptions } from '../ScriptEditor/ui/Options'; +import { WordWrapOptions } from "../ScriptEditor/ui/Options"; +import { OverviewSettings } from "../ui/React/Overview"; /** * Represents the default settings the player could customize. @@ -41,6 +42,11 @@ interface IDefaultSettings { */ DisableTextEffects: boolean; + /** + * Whether overview progress bars should be visible. + */ + DisableOverviewProgressBars: boolean; + /** * Enable bash hotkeys */ @@ -125,6 +131,11 @@ interface IDefaultSettings { * Use GiB instead of GB */ UseIEC60027_2: boolean; + + /* + * Character overview settings + */ + overview: OverviewSettings; } /** @@ -160,6 +171,7 @@ export const defaultSettings: IDefaultSettings = { DisableASCIIArt: false, DisableHotkeys: false, DisableTextEffects: false, + DisableOverviewProgressBars: false, EnableBashHotkeys: false, TimestampsFormat: "", Locale: "en", @@ -178,6 +190,7 @@ export const defaultSettings: IDefaultSettings = { theme: defaultTheme, styles: defaultStyles, + overview: { x: 0, y: 0, opened: true }, }; /** @@ -192,6 +205,7 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { DisableASCIIArt: defaultSettings.DisableASCIIArt, DisableHotkeys: defaultSettings.DisableHotkeys, DisableTextEffects: defaultSettings.DisableTextEffects, + DisableOverviewProgressBars: defaultSettings.DisableOverviewProgressBars, EnableBashHotkeys: defaultSettings.EnableBashHotkeys, TimestampsFormat: defaultSettings.TimestampsFormat, Locale: "en", @@ -213,10 +227,11 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { MonacoInsertSpaces: false, MonacoFontSize: 20, MonacoVim: false, - MonacoWordWrap: 'off', + MonacoWordWrap: "off", theme: { ...defaultTheme }, styles: { ...defaultStyles }, + overview: defaultSettings.overview, init() { Object.assign(Settings, defaultSettings); }, @@ -226,6 +241,8 @@ export const Settings: ISettings & ISelfInitializer & ISelfLoading = { delete save.theme; Object.assign(Settings.styles, save.styles); delete save.styles; + Object.assign(Settings.overview, save.overview); + delete save.overview; Object.assign(Settings, save); }, }; diff --git a/src/Terminal/commands/connect.ts b/src/Terminal/commands/connect.ts index 23d02e2b1..a419def70 100644 --- a/src/Terminal/commands/connect.ts +++ b/src/Terminal/commands/connect.ts @@ -5,8 +5,6 @@ import { BaseServer } from "../../Server/BaseServer"; import { getServerOnNetwork } from "../../Server/ServerHelpers"; import { GetServer } from "../../Server/AllServers"; import { Server } from "../../Server/Server"; -import { Programs } from "src/Programs/Programs"; -import { programsMetadata } from "src/Programs/data/ProgramsMetadata"; export function connect( terminal: ITerminal, diff --git a/src/index.html b/src/index.html index 474104ec9..fb801e99b 100644 --- a/src/index.html +++ b/src/index.html @@ -52,6 +52,11 @@ <% } %>