Skip to content

Commit

Permalink
feat(ui): convert union mode to map mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelMakesGames committed Sep 9, 2024
1 parent 53aebc0 commit 6ad9fa1
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 38 deletions.
7 changes: 5 additions & 2 deletions src/renderer/src/intl/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,8 @@ export default {
sectorCoreBorderColor: 'Core Sector Border Color',
sectorFrontierBorderStroke: 'Frontier Sector Borders',
sectorFrontierBorderColor: 'Frontier Sector Border Color',
unionBorderStroke: 'Union Borders',
unionBorderColor: 'Union Border Color',
unionBorderStroke: 'Union Joined Borders',
unionBorderColor: 'Union Joined Border Color',
unionMode: 'Union Mode',
unionSubjects: 'Subjects',
unionHegemonies: 'Hegemony Federations',
Expand Down Expand Up @@ -445,6 +445,9 @@ export default {
default: {
name: 'Empires',
},
unions: {
name: 'Unions',
},
wars: {
name: 'Wars',
tooltip_label: 'War Status',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/lib/SettingControl/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
</div>
{/if}
<div class="grow" />
{#if config.type === 'stroke' || config.type === 'icon'}
{#if (config.type === 'stroke' && !config.noDisable) || config.type === 'icon'}
<div class="relative top-1 inline-block">
<SlideToggle
name={config.id}
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/src/lib/map/data/mapModes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export const mapModes: Record<string, MapMode> = {
id: 'default',
name: 'map_mode.default.name',
},
unions: {
id: 'unions',
name: 'map_mode.unions.name',
},
wars: {
id: 'wars',
name: 'map_mode.wars.name',
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/lib/map/data/processMapData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default async function processMapData(
const settings = { ...rawSettings };
if (settings.hyperlaneMetroStyle) settings.alignStarsToGrid = true;
if (settings.alignStarsToGrid) settings.hyperlaneSensitiveBorders = false;
if (settings.mapMode !== 'default') settings.unionMode = false;
settings.unionMode = settings.mapMode === 'unions';

// get these started right away; await just before needed
const emblemsPromise = timeItAsync(
Expand Down
1 change: 1 addition & 0 deletions src/renderer/src/lib/settings/SettingConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface SettingConfigStroke<Settings, ID> extends SettingConfigBase<Set
requiresReprocessing?: boolean | RequiresReprocessingFunc<StrokeSetting>;
noSmoothing?: boolean;
noDashed?: boolean;
noDisable?: boolean;
}

export interface SettingConfigIcon<Settings, ID> extends SettingConfigBase<Settings, ID> {
Expand Down
57 changes: 23 additions & 34 deletions src/renderer/src/lib/settings/mapSettingsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,57 +116,48 @@ export const mapSettingsConfig: MapSettingConfigGroup[] = [
hideIf: (settings) =>
!settings.sectorTypeBorderStyles || !settings.sectorBorderStroke.enabled,
},
{
id: 'unionBorderStroke',
type: 'stroke',
requiresReprocessing: (prev, next) => prev.smoothing !== next.smoothing,
hideIf: (settings) =>
!settings.unionMode ||
![settings.unionFederations, settings.unionHegemonies, settings.unionSubjects].includes(
'joinedBorders',
),
},
{
id: 'unionBorderColor',
type: 'color',
hideIf: (settings) =>
!settings.unionBorderStroke.enabled ||
!settings.unionMode ||
![settings.unionFederations, settings.unionHegemonies, settings.unionSubjects].includes(
'joinedBorders',
),
},
],
},
{
id: 'unions',
name: 'setting.group.unions',
settings: [
{
id: 'unionMode',
type: 'toggle',
requiresReprocessing: true,
},
{
id: 'unionSubjects',
requiresReprocessing: true,
type: 'select',
options: unionOptions,
hideIf: (settings) => !settings.unionMode,
},
{
id: 'unionHegemonies',
requiresReprocessing: true,
type: 'select',
options: unionOptions,
hideIf: (settings) => !settings.unionMode,
},
{
id: 'unionFederations',
requiresReprocessing: true,
type: 'select',
options: unionOptions,
hideIf: (settings) => !settings.unionMode,
},
{
id: 'unionBorderStroke',
type: 'stroke',
requiresReprocessing: (prev, next) => prev.smoothing !== next.smoothing,
hideIf: (settings) =>
![settings.unionFederations, settings.unionHegemonies, settings.unionSubjects].includes(
'joinedBorders',
),
noDisable: true,
},
{
id: 'unionBorderColor',
type: 'color',
hideIf: (settings) =>
!settings.unionBorderStroke.enabled ||
![settings.unionFederations, settings.unionHegemonies, settings.unionSubjects].includes(
'joinedBorders',
),
},
{
id: 'unionFederationsColor',
Expand All @@ -177,28 +168,26 @@ export const mapSettingsConfig: MapSettingConfigGroup[] = [
{ id: 'leader', name: 'option.union_federations_color.leader' },
],
hideIf: (settings) =>
!settings.unionMode ||
(settings.unionFederations === 'off' && settings.unionHegemonies === 'off'),
settings.unionFederations === 'off' && settings.unionHegemonies === 'off',
},
{
id: 'unionLeaderSymbol',
type: 'select',
options: glyphOptions,
hideIf: (settings) => !settings.unionMode || !settings.countryEmblems,
hideIf: (settings) => !settings.countryEmblems,
},
{
id: 'unionLeaderSymbolSize',
type: 'range',
min: 0.05,
max: 1,
step: 0.05,
hideIf: (settings) =>
!settings.unionMode || !settings.countryEmblems || settings.unionLeaderSymbol === 'none',
hideIf: (settings) => !settings.countryEmblems || settings.unionLeaderSymbol === 'none',
},
{
id: 'unionLeaderUnderline',
type: 'toggle',
hideIf: (settings) => !settings.unionMode || !settings.countryNames,
hideIf: (settings) => !settings.countryNames,
},
],
},
Expand Down

0 comments on commit 6ad9fa1

Please sign in to comment.