Skip to content

Commit

Permalink
tweak the zoom stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyGalbreath committed Apr 2, 2024
1 parent fb4bad4 commit f4b59c8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 66 deletions.
58 changes: 18 additions & 40 deletions src/Server/Configuration/Config.cs
Expand Up @@ -61,28 +61,6 @@ public sealed class Config {
}
}

[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Global")]
public class LoggerConfig {
[YamlMember(Order = 0, Description = """
Prints pretty colors to the console instead of just normal boring text.
Disable this if your console/terminal does not support colors.
""")]
public bool ColorConsole = true;

[YamlMember(Order = 1, Description = """
Prints debug messages to the console.
It will still write to the log file(s) regardless.
""")]
public bool DebugToConsole = false;

[YamlMember(Order = 2, Description = """
Prints debug messages to the event log file.
It will still write to the debug log file regardless.
""")]
public bool DebugToEventFile = false;
}

[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Global")]
public class WebServerConfig {
Expand Down Expand Up @@ -115,34 +93,34 @@ public class ZoomConfig {
Each additional level requires a new set of tiles
to be rendered, so don't go too wild here.
""")]
public int MaxOut = 3;
public int MaxOut = 8;

[YamlMember(Order = 2, Description = """
Extra zoom in layers will stretch the original
tile images so you can zoom in further without
the extra cost of rendering more tiles.
""")]
public int MaxIn = 2;
public int MaxIn = 3;
}

[YamlMember(Order = 3, Description = """
Forces the map's zoom level to always be a multiple of this.
By default, the zoom level snaps to the nearest integer; lower
values (e.g. 0.5 or 0.1) allow for greater granularity. A
value of 0 means the zoom level will not be snapped.
[SuppressMessage("ReSharper", "ConvertToConstant.Global")]
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Global")]
public class LoggerConfig {
[YamlMember(Order = 0, Description = """
Prints pretty colors to the console instead of just normal boring text.
Disable this if your console/terminal does not support colors.
""")]
public double Snap = 0.25D;
public bool ColorConsole = true;

[YamlMember(Order = 4, Description = """
Controls how much the map's zoom level will change after a zoom in,
zoom out, pressing + or - on the keyboard, or using the zoom controls.
Values smaller than 1 (e.g. 0.5) allow for greater granularity.
[YamlMember(Order = 1, Description = """
Prints debug messages to the console.
It will still write to the log file(s) regardless.
""")]
public double Delta = 0.25D;
public bool DebugToConsole = false;

[YamlMember(Order = 5, Description = """
How many scroll pixels (as reported by L.DomEvent.getWheelDelta) mean
a change of one full zoom level. Smaller values will make wheel-zooming
faster (and vice versa).
[YamlMember(Order = 2, Description = """
Prints debug messages to the event log file.
It will still write to the debug log file regardless.
""")]
public int Wheel = 240;
public bool DebugToEventFile = false;
}
4 changes: 2 additions & 2 deletions web/public/tiles/settings.json
Expand Up @@ -10,8 +10,8 @@
},
"zoom": {
"def": 0,
"maxin": 2,
"maxout": 3
"maxin": 3,
"maxout": 8
},
"interval": {
"tiles": 30,
Expand Down
9 changes: 4 additions & 5 deletions web/src/LiveMap.ts
Expand Up @@ -40,9 +40,9 @@ export class LiveMap extends L.Map {
attributionControl: LiveMap.isstr(settings.attribution),
// canvas is more efficient than svg
preferCanvas: true,
zoomSnap: 1 / 4,
zoomDelta: 1 / 4,
wheelPxPerZoomLevel: 60 * 4
zoomSnap: 1,
zoomDelta: 1,
wheelPxPerZoomLevel: 60
});

this._settings = settings;
Expand Down Expand Up @@ -90,9 +90,8 @@ export class LiveMap extends L.Map {
}

private tick(count: number): void {
// todo - tick tiles
// tick tiles
if (count % this.settings.interval.tiles == 0) {
console.log('update tiles');
this._layerControl.updateTileLayer();
}

Expand Down
20 changes: 1 addition & 19 deletions web/src/settings/Zoom.ts
Expand Up @@ -2,17 +2,11 @@ export class Zoom {
private readonly _def: number;
private readonly _maxin: number;
private readonly _maxout: number;
private readonly _snap: number;
private readonly _delta: number;
private readonly _wheel: number;

constructor(def?: number, min?: number, max?: number, snap?: number, delta?: number, wheel?: number) {
constructor(def?: number, min?: number, max?: number) {
this._def = def ?? 0;
this._maxin = min ?? 2;
this._maxout = max ?? 3;
this._snap = snap ?? 1 / 4;
this._delta = delta ?? 1 / 4;
this._wheel = wheel ?? 60 * 4;
}

get def(): number {
Expand All @@ -26,16 +20,4 @@ export class Zoom {
get maxout(): number {
return this._maxout;
}

get snap(): number {
return this._snap;
}

get delta(): number {
return this._delta;
}

get wheel(): number {
return this._wheel;
}
}

0 comments on commit f4b59c8

Please sign in to comment.