Allow configuring map resources scale

This commit is contained in:
tobspr 2020-10-08 09:13:53 +02:00
parent 21c9c3cee6
commit 5a96e76151
7 changed files with 51 additions and 3 deletions

View File

@ -13,6 +13,17 @@ import { getStringForKeyCode } from "../game/key_action_mapper";
import { createLogger } from "./logging";
import { T } from "../translations";
/*
* ***************************************************
*
* LEGACY CODE WARNING
*
* This is old code from yorg3.io and needs to be refactored
* @TODO
*
* ***************************************************
*/
const kbEnter = 13;
const kbCancel = 27;

View File

@ -2,6 +2,17 @@ import { BaseItem } from "../game/base_item";
import { ClickDetector } from "./click_detector";
import { Signal } from "./signal";
/*
* ***************************************************
*
* LEGACY CODE WARNING
*
* This is old code from yorg3.io and needs to be refactored
* @TODO
*
* ***************************************************
*/
export class FormElement {
constructor(id, label) {
this.id = id;

View File

@ -122,6 +122,7 @@ export const KEYCODE_RMB = 3;
* @returns {string}
*/
export function getStringForKeyCode(code) {
// @todo: Refactor into dictionary
switch (code) {
case KEYCODE_LMB:
return "LMB";

View File

@ -104,15 +104,17 @@ export class MapChunkView extends MapChunk {
});
parameters.context.imageSmoothingEnabled = true;
const resourcesScale = this.root.app.settings.getAllSettings().mapResourcesScale;
// Draw patch items
if (this.root.currentLayer === "regular") {
if (this.root.currentLayer === "regular" && resourcesScale > 0.05) {
const diameter = (70 / Math.pow(parameters.zoomLevel, 0.35)) * (0.2 + 2 * resourcesScale);
for (let i = 0; i < this.patches.length; ++i) {
const patch = this.patches[i];
if (patch.item.getItemType() === "shape") {
const destX = this.x * dims + patch.pos.x * globalConfig.tileSize;
const destY = this.y * dims + patch.pos.y * globalConfig.tileSize;
const diameter = 80 / Math.pow(parameters.zoomLevel, 0.35);
patch.item.drawItemCenteredClipped(destX, destY, parameters, diameter);
}
}

View File

@ -267,6 +267,7 @@ export const allApplicationSettings = [
new BoolSetting("rotationByBuilding", enumCategories.advanced, (app, value) => {}),
new BoolSetting("displayChunkBorders", enumCategories.advanced, (app, value) => {}),
new BoolSetting("pickMinerOnPatch", enumCategories.advanced, (app, value) => {}),
new RangeSetting("mapResourcesScale", enumCategories.advanced, () => null),
new EnumSetting("refreshRate", {
options: refreshRateOptions,
@ -324,6 +325,7 @@ class SettingsStorage {
this.lowQualityTextures = false;
this.simplifiedBelts = false;
this.zoomToCursor = true;
this.mapResourcesScale = 0.5;
/**
* @type {Object.<string, number>}
@ -534,7 +536,7 @@ export class ApplicationSettings extends ReadWriteProxy {
}
getCurrentVersion() {
return 29;
return 30;
}
/** @param {{settings: SettingsStorage, version: number}} data */
@ -672,6 +674,11 @@ export class ApplicationSettings extends ReadWriteProxy {
data.version = 29;
}
if (data.version < 30) {
data.settings.mapResourcesScale = 0.5;
data.version = 30;
}
return ExplainedResult.good();
}
}

View File

@ -7,6 +7,17 @@ import { T } from "../translations";
const logger = createLogger("setting_types");
/*
* ***************************************************
*
* LEGACY CODE WARNING
*
* This is old code from yorg3.io and needs to be refactored
* @TODO
*
* ***************************************************
*/
export class BaseSetting {
/**
*

View File

@ -1030,6 +1030,11 @@ settings:
description: >-
If activated the zoom will happen in the direction of your mouse position, otherwise in the middle of the screen.
mapResourcesScale:
title: Map Resources Size
description: >-
Controls the size of the shapes on the map overview (when zooming out).
keybindings:
title: Keybindings
hint: >-