Skip to content

Commit

Permalink
feat(map): add border gap setting
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed May 31, 2024
1 parent e14e240 commit cd0798a
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/renderer/src/intl/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ export default {
<li>When enabled, the overall border of the galaxy will be circular in shape, and there will be no "holes" between systems.</li>
<li>If the galaxy is a "Starburst", a special spiral shape will be used instead of a circle.</li>
</ul>`,
borderGap: 'Border Gap',
borderGap_tooltip: 'Adds blank space between country borders',
hyperlaneSensitiveBorders: 'Hyperlane Sensitive Borders',
hyperlaneSensitiveBorders_tooltip: `<ul>
<li>When enabled, borders will follow hyperlanes.</li>
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/src/lib/map/data/processBorders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const processBordersDeps = [
'sectorBorderStroke',
'mapMode',
'mapModePointOfView',
'borderGap',
] satisfies (keyof MapSettings)[];

export default function processBorders(
Expand Down Expand Up @@ -345,11 +346,19 @@ export default function processBorders(
if (settings.borderStroke.smoothing && boundedOuterBorderGeoJSON != null) {
smoothedOuterBorderGeoJSON = smoothGeojson(boundedOuterBorderGeoJSON, 2);
}
smoothedOuterBorderGeoJSON =
smoothedOuterBorderGeoJSON == null
? null
: (turf.buffer(smoothedOuterBorderGeoJSON, -(settings.borderGap ?? 0) / 2 / SCALE, {
units: 'degrees',
steps: settings.borderStroke.smoothing ? 8 : 1,
}) as ReturnType<typeof turf.buffer> | null);
const smoothedInnerBorderGeoJSON =
smoothedOuterBorderGeoJSON == null
? null
: (turf.buffer(smoothedOuterBorderGeoJSON, -settings.borderStroke.width / SCALE, {
units: 'degrees',
steps: settings.borderStroke.smoothing ? 8 : 1,
}) as ReturnType<typeof turf.buffer> | null);
border.outerPath =
smoothedOuterBorderGeoJSON == null
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/src/lib/settings/mapSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type NumberMapSettings =
| 'systemNamesFontSize';

export type NumberOptionalMapSettings =
| 'borderGap'
| 'countryEmblemsMaxSize'
| 'countryEmblemsMinSize'
| 'countryNamesMaxSize'
Expand Down Expand Up @@ -313,6 +314,7 @@ export const defaultMapSettings: MapSettings = {
colorAdjustments: [],
},
voronoiGridSize: 30,
borderGap: null,
hyperlaneSensitiveBorders: true,
claimVoidBorderThreshold: 0.6,
claimVoidMaxSize: 1000,
Expand Down
9 changes: 9 additions & 0 deletions src/renderer/src/lib/settings/mapSettingsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,15 @@ export const mapSettingsConfig: MapSettingConfigGroup[] = [
type: 'toggle',
tooltip: 'setting.circularGalaxyBorders_tooltip',
},
{
id: 'borderGap',
requiresReprocessing: true,
type: 'number',
step: 0.5,
min: 0,
optional: true,
tooltip: 'setting.borderGap_tooltip',
},
{
id: 'hyperlaneSensitiveBorders',
requiresReprocessing: true,
Expand Down

0 comments on commit cd0798a

Please sign in to comment.