mirror of
https://github.com/wanderer-industries/wanderer
synced 2026-08-24 23:06:42 +00:00
Introduces automatic tagging and labeling for destination systems upon wormhole jumps. Users can now configure the format for these tags and labels in the map settings.
- feat(mapper): Implement auto-tagging and auto-labeling logic for destination systems - feat(settings): Add UI options to configure system auto-tag and auto-label formats - feat(backend): Add new system auto-tag and auto-label settings to user preferences - refactor(settings): Extract shared auto-format options into a constant
This commit is contained in:
+73
-1
@@ -11,8 +11,9 @@ import { SystemSignaturesContent } from '@/hooks/Mapper/components/mapInterface/
|
||||
import { MULTI_DEST_WHS, ALL_DEST_TYPES_MAP, DEST_TYPES_MAP_MAP } from '@/hooks/Mapper/constants.ts';
|
||||
import { SETTINGS_KEYS, SignatureSettingsType } from '@/hooks/Mapper/constants/signatures';
|
||||
import { getSystemClassGroup } from '@/hooks/Mapper/components/map/helpers/getSystemClassGroup.ts';
|
||||
import { handleAutoBookmark } from '@/hooks/Mapper/helpers/bookmarkFormatHelper.ts';
|
||||
import { handleAutoBookmark, numberToLetters } from '@/hooks/Mapper/helpers/bookmarkFormatHelper.ts';
|
||||
import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo';
|
||||
import { LabelsManager } from '@/hooks/Mapper/utils/labelsManager.ts';
|
||||
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
||||
import { CommandLinkSignatureToSystem, SignatureGroup, SystemSignature } from '@/hooks/Mapper/types';
|
||||
import { OutCommand } from '@/hooks/Mapper/types/mapHandlers.ts';
|
||||
@@ -161,6 +162,77 @@ export const SystemLinkSignatureDialog = ({ data, setVisible }: SystemLinkSignat
|
||||
},
|
||||
});
|
||||
|
||||
const systemAutoTag = userSettings?.system_auto_tag;
|
||||
const systemCustomLabelName = userSettings?.system_custom_label_name;
|
||||
|
||||
if (systemAutoTag || systemCustomLabelName) {
|
||||
const info = parseSignatureCustomInfo(updatedSignature.custom_info);
|
||||
const bIndex = info.bookmark_index ?? 0;
|
||||
const startAtZero = userSettings?.bookmark_wormholes_start_at_zero;
|
||||
const letter = numberToLetters(bIndex, startAtZero);
|
||||
|
||||
const targetSystem = systems.find((s: any) => s.system_static_info?.solar_system_id === data.solar_system_target);
|
||||
|
||||
if (targetSystem) {
|
||||
if (systemAutoTag) {
|
||||
let tagValue = '';
|
||||
switch (systemAutoTag) {
|
||||
case 'index':
|
||||
case 'chain_index':
|
||||
tagValue = bIndex.toString();
|
||||
break;
|
||||
case 'index_letter':
|
||||
tagValue = letter;
|
||||
break;
|
||||
case 'chain_index_letters':
|
||||
tagValue = info.bookmark_index_chained_letters === letter ? letter : bIndex.toString();
|
||||
break;
|
||||
}
|
||||
|
||||
if (tagValue) {
|
||||
await outCommand({
|
||||
type: OutCommand.updateSystemTag,
|
||||
data: {
|
||||
system_id: targetSystem.id,
|
||||
value: tagValue,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (systemCustomLabelName) {
|
||||
let labelValue = '';
|
||||
switch (systemCustomLabelName) {
|
||||
case 'index':
|
||||
labelValue = bIndex.toString();
|
||||
break;
|
||||
case 'index_letter':
|
||||
labelValue = letter;
|
||||
break;
|
||||
case 'chain_index':
|
||||
labelValue = info.bookmark_index_chained as string || bIndex.toString();
|
||||
break;
|
||||
case 'chain_index_letters':
|
||||
labelValue = info.bookmark_index_chained_letters as string || letter;
|
||||
break;
|
||||
}
|
||||
|
||||
if (labelValue) {
|
||||
const outLabel = new LabelsManager(targetSystem.labels ?? '');
|
||||
outLabel.updateCustomLabel(labelValue);
|
||||
|
||||
await outCommand({
|
||||
type: OutCommand.updateSystemLabels,
|
||||
data: {
|
||||
system_id: targetSystem.id,
|
||||
value: outLabel.toString(),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setVisible(false);
|
||||
},
|
||||
[data, setVisible, userSettings, targetSystemClassGroup, systemSignatures, systems, wormholesData],
|
||||
|
||||
+25
-7
@@ -10,8 +10,18 @@ export const DEFAULT_REMOTE_SETTINGS = {
|
||||
[UserSettingsRemoteProps.bookmark_wormholes_start_at_zero]: false,
|
||||
[UserSettingsRemoteProps.bookmark_auto_copy]: true,
|
||||
[UserSettingsRemoteProps.bookmark_auto_temp_name]: '',
|
||||
[UserSettingsRemoteProps.system_auto_tag]: '',
|
||||
[UserSettingsRemoteProps.system_custom_label_name]: '',
|
||||
};
|
||||
|
||||
export const AUTO_FORMAT_OPTIONS = [
|
||||
{ label: 'Disabled', value: '' },
|
||||
{ label: 'Numeric index (1, 2, 3)', value: 'index' },
|
||||
{ label: 'Letter index (A, B, C)', value: 'index_letter' },
|
||||
{ label: 'Numeric chain (11, 12, 121)', value: 'chain_index' },
|
||||
{ label: 'Letter chain (A, A1, A21)', value: 'chain_index_letters' },
|
||||
];
|
||||
|
||||
export const UserSettingsRemoteList = [
|
||||
UserSettingsRemoteProps.link_signature_on_splash,
|
||||
UserSettingsRemoteProps.select_on_spash,
|
||||
@@ -20,6 +30,8 @@ export const UserSettingsRemoteList = [
|
||||
UserSettingsRemoteProps.bookmark_wormholes_start_at_zero,
|
||||
UserSettingsRemoteProps.bookmark_auto_copy,
|
||||
UserSettingsRemoteProps.bookmark_auto_temp_name,
|
||||
UserSettingsRemoteProps.system_auto_tag,
|
||||
UserSettingsRemoteProps.system_custom_label_name,
|
||||
];
|
||||
|
||||
// export const COMMON_CHECKBOXES_PROPS: SettingsListItem[] = [
|
||||
@@ -71,13 +83,19 @@ export const BOOKMARKS_SETTINGS_PROPS: SettingsListItem[] = [
|
||||
prop: UserSettingsRemoteProps.bookmark_auto_temp_name,
|
||||
label: 'Auto-fill wormhole temporary name',
|
||||
type: 'dropdown',
|
||||
options: [
|
||||
{ label: 'Disabled', value: '' },
|
||||
{ label: 'Numeric index (1, 2, 3)', value: 'index' },
|
||||
{ label: 'Letter index (A, B, C)', value: 'index_letter' },
|
||||
{ label: 'Numeric chain (11, 12, 121)', value: 'chain_index' },
|
||||
{ label: 'Letter chain (A, A1, A21)', value: 'chain_index_letters' },
|
||||
],
|
||||
options: AUTO_FORMAT_OPTIONS,
|
||||
},
|
||||
{
|
||||
prop: UserSettingsRemoteProps.system_auto_tag,
|
||||
label: 'Auto-tag jumped system',
|
||||
type: 'dropdown',
|
||||
options: AUTO_FORMAT_OPTIONS,
|
||||
},
|
||||
{
|
||||
prop: UserSettingsRemoteProps.system_custom_label_name,
|
||||
label: 'Auto-label jumped system',
|
||||
type: 'dropdown',
|
||||
options: AUTO_FORMAT_OPTIONS,
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ export enum UserSettingsRemoteProps {
|
||||
bookmark_wormholes_start_at_zero = 'bookmark_wormholes_start_at_zero',
|
||||
bookmark_auto_copy = 'bookmark_auto_copy',
|
||||
bookmark_auto_temp_name = 'bookmark_auto_temp_name',
|
||||
system_auto_tag = 'system_auto_tag',
|
||||
system_custom_label_name = 'system_custom_label_name',
|
||||
}
|
||||
|
||||
export type UserSettingsRemote = {
|
||||
@@ -18,6 +20,8 @@ export type UserSettingsRemote = {
|
||||
bookmark_wormholes_start_at_zero: boolean;
|
||||
bookmark_auto_copy: boolean;
|
||||
bookmark_auto_temp_name: string;
|
||||
system_auto_tag: string;
|
||||
system_custom_label_name: string;
|
||||
};
|
||||
|
||||
export type UserSettings = UserSettingsRemote & InterfaceStoredSettings;
|
||||
|
||||
@@ -6,7 +6,9 @@ defmodule WandererApp.MapUserSettingsRepo do
|
||||
"link_signature_on_splash" => false,
|
||||
"delete_connection_with_sigs" => false,
|
||||
"primary_character_id" => nil,
|
||||
"bookmark_name_format" => ""
|
||||
"bookmark_name_format" => "",
|
||||
"system_auto_tag" => "",
|
||||
"system_custom_label_name" => ""
|
||||
}
|
||||
|
||||
def get(map_id, user_id) do
|
||||
|
||||
@@ -239,7 +239,9 @@ defmodule WandererAppWeb.MapCoreEventHandler do
|
||||
"bookmark_name_format",
|
||||
"bookmark_wormholes_start_at_zero",
|
||||
"bookmark_auto_copy",
|
||||
"bookmark_auto_temp_name"
|
||||
"bookmark_auto_temp_name",
|
||||
"system_auto_tag",
|
||||
"system_custom_label_name"
|
||||
])
|
||||
|> Jason.encode!()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user