Skip to content
This repository has been archived by the owner on Oct 25, 2022. It is now read-only.

Commit

Permalink
feat(ui): Remove deprecated CSS manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
oliversalzburg committed May 30, 2022
1 parent d873aff commit 235c020
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 80 deletions.
1 change: 0 additions & 1 deletion packages/userscript/source/fixtures/localstorage.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
"toggle-praiseFilter": true,
"toggle-festivalFilter": true,
"toggle-tradeFilter": true,
"toggle-style": true,
"set-steamworks-max": 100,
"set-magneto-max": 100,
"set-quarry-max": 100,
Expand Down
2 changes: 0 additions & 2 deletions packages/userscript/source/i18n/i18nData.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"option.hunt": "Hunt",
"option.crypto": "Trade Blackcoin",
"option.embassies": "Build Embassies (Beta)",
"option.style": "View Full Width",
"option.steamworks": "Turn on Steamworks",
"filter.build": "Building",
"filter.craft": "Crafting",
Expand Down Expand Up @@ -197,7 +196,6 @@
"option.hunt": "狩猎",
"option.crypto": "黑币交易",
"option.embassies": "建造大使馆 (Beta)",
"option.style": "占满屏幕",
"option.steamworks": "启动蒸汽工房",
"filter.build": "建筑",
"filter.craft": "工艺",
Expand Down
3 changes: 3 additions & 0 deletions packages/userscript/source/options/BonfireSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export type BonfireSettingsItem = {
*/
name?: Building;

/**
* A resource that you must have unlocked to build this.
*/
require: Requirement;

/**
Expand Down
4 changes: 1 addition & 3 deletions packages/userscript/source/options/OptionsSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ export type OptionsItem =
| "hunt"
| "observe"
| "promote"
| "shipOverride"
| "style";
| "shipOverride";

export type OptionsSettingsItem = {
enabled: boolean;
Expand All @@ -33,7 +32,6 @@ export class OptionsSettings extends SettingsSection {
crypto: { enabled: true, subTrigger: 10000 },
fixCry: { enabled: false },
buildEmbassies: { enabled: true, subTrigger: 0.9 },
style: { enabled: true },
_steamworks: { enabled: false },
};
}
16 changes: 0 additions & 16 deletions packages/userscript/source/ui/OptionsSettingsUi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export class OptionsSettingsUi extends SettingsSectionUi<OptionsSettings> {
this._options.items.buildEmbassies,
this._host.i18n("option.embassies")
),
this._getOptionsOption("style", this._options.items.style, this._host.i18n("option.style")),
this._getOptionsOption(
"_steamworks",
this._options.items._steamworks,
Expand All @@ -116,21 +115,6 @@ export class OptionsSettingsUi extends SettingsSectionUi<OptionsSettings> {
): JQuery<HTMLElement> {
const element = this._getOption(name, option, iname);

// hack for style.
// If there are more UI options, split it to "getUIOption"
if (name === "style") {
const input = element.children("input");
input.unbind("change");
input.on("change", () => {
this._host.updateOptions(() => (option.enabled = input.prop("checked") as boolean));
if (option.enabled) {
document.body.setAttribute("data-ks-style", "");
} else {
document.body.removeAttribute("data-ks-style");
}
});
}

if (option.subTrigger !== undefined) {
const triggerButton = $("<div/>", {
id: `set-${name}-subTrigger`,
Expand Down
58 changes: 0 additions & 58 deletions packages/userscript/source/ui/UserInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,64 +161,6 @@ export class UserInterface {

// Ensure the right column gets a scrollbar, when our content extends it too far down.
this._addRule("body #gamePageContainer #game #rightColumn { overflow-y: auto }");

// Set the entire UI to a monospace font.
//this._addRule(
// "body {" + // low priority. make sure it can be covered by the theme
// "font-family: monospace;" +
// "font-size: 12px;" +
// "}"
//);

// Ignore remaining rules for now, until their use becomes clear.
return;

const defaultSelector = "body[data-ks-style]:not(.scheme_sleek)";

this._addRule(`${defaultSelector} #game { min-width: 1300px; top: 32px; }`);

this._addRule(
`${defaultSelector} .column {
min-height: inherit;
max-width: inherit !important;
padding: 1%;
margin: 0;
overflow-y: auto; }`
);

this._addRule(`${defaultSelector} #leftColumn { height: 92%; width: 26%; }`);

this._addRule(
`${defaultSelector} #midColumn { margin-top: 1% !important; height: 90%; width: 48%; }`
);

this._addRule(`${defaultSelector} #rightColumn { overflow-y: auto; height: 92%; width: 19%; }`);

this._addRule(
`${defaultSelector} #gameLog { overflow-y: hidden !important; width: 100% !important; padding-top: 5px !important; }`
);

this._addRule(`${defaultSelector} #resContainer .maxRes { color: #676766; }`);

this._addRule(
`${defaultSelector} #game .btn {
border-radius: 0px;
font-family: monospace;
font-size: 12px !important;
margin: 0 5px 7px 0;
width: 290px; }`
);

// TODO: Sound related to exploration. Should likely be removed.
this._addRule(
`${defaultSelector} #game .map-viewport {
height: 340px;
max-width: 500px;
overflow: visible; }`
);
this._addRule("#game .map-dashboard { height: 120px; width: 292px; }");

this._addRule(".right-tab { height: unset !important; }");
}

private _addRule(rule: string) {
Expand Down

0 comments on commit 235c020

Please sign in to comment.