Skip to content

Commit

Permalink
feat(core): add ukrainian game language support
Browse files Browse the repository at this point in the history
  • Loading branch information
marcincichocki committed Oct 2, 2023
1 parent fbaa34b commit bc3c3ac
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
Binary file added resources/tessdata/ukr.traineddata.gz
Binary file not shown.
24 changes: 23 additions & 1 deletion src/core/daemons-i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export type BreachProtocolLanguage =
| 'ara'
| 'chi_tra'
| 'ces'
| 'hun';
| 'hun'
| 'ukr';

type DaemonDict = Record<DaemonId, string>;

Expand Down Expand Up @@ -368,6 +369,26 @@ export const hun: DaemonDict = {
[d.DAEMON_EXPERT_DATAMINE]: 'SZAKÉRTŐ ADATBÁNYÁSZAT',
};

export const ukr: DaemonDict = {
[d.DAEMON_DATAMINE_V1]: '',
[d.DAEMON_DATAMINE_V2]: '',
[d.DAEMON_DATAMINE_V3]: '',
[d.DAEMON_ICEPICK]: '',
[d.DAEMON_MASS_VULNERABILITY]: '',
[d.DAEMON_CAMERA_SHUTDOWN]: '',
[d.DAEMON_FRIENDLY_TURRETS]: '',
[d.DAEMON_TURRET_SHUTDOWN]: '',
[d.DAEMON_OPTICS_JAMMER]: '',
[d.DAEMON_WEAPONS_JAMMER]: '',
[d.DAEMON_DATAMINE_COPY_MALWARE]: 'ПОШУК ДАНИХ: КОПІЮВАННЯ ВІРУСУ',
[d.DAEMON_NEUTRALIZE_MALWARE]: 'ЗНЕШКОДИТИ ВІРУС',
[d.DAEMON_GAIN_ACCESS]: 'ОТРИМАТИ ДОСТУП',
[d.DAEMON_DATAMINE_CRAFTING_SPECS]: 'ПОШУК ДАНИХ: ДОКУМЕНТАЦІЯ',
[d.DAEMON_BASIC_DATAMINE]: 'БАЗОВЕ ДОБУВАННЯ ДАНИХ',
[d.DAEMON_ADVANCED_DATAMINE]: 'ПРОСУНУТЕ ДОБУВАННЯ ДАНИХ',
[d.DAEMON_EXPERT_DATAMINE]: 'ЕКСПЕРТНЕ ДОБУВАННЯ ДАНИХ',
};

export const daemonsI18n: Record<BreachProtocolLanguage, DaemonDict> = {
eng,
pol,
Expand All @@ -386,4 +407,5 @@ export const daemonsI18n: Record<BreachProtocolLanguage, DaemonDict> = {
chi_tra,
ces,
hun,
ukr,
};
28 changes: 25 additions & 3 deletions src/electron/renderer/components/GeneralSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { RemoveLastNHistoryEntriesAction } from '@/electron/common';
import {
AppSettings,
RemoveLastNHistoryEntriesAction,
} from '@/electron/common';
import { getPatchName, nativeDialog } from '../common';
import { Field, Label, OnBeforeValueChange } from './Form';
import { Field, Label, OnBeforeValueChange, useForm } from './Form';
import { RangeSlider } from './RangeSlider';
import { Section } from './Section';
import { Switch } from './Switch';
Expand All @@ -13,6 +16,7 @@ const patchOptions: SelectOption<string>[] = patches.map((value) => ({
}));

export const GeneralSettings = ({ historySize }: { historySize: number }) => {
const { values } = useForm<AppSettings>();
const onBeforeHistorySizeChange: OnBeforeValueChange<number> = async (
value,
next
Expand All @@ -35,11 +39,29 @@ export const GeneralSettings = ({ historySize }: { historySize: number }) => {
next();
};

const ensureValidGameLanguageForPatch: OnBeforeValueChange<
'1.x' | '2.x'
> = async (value, next) => {
if (value === '1.x' && values.gameLang === 'ukr') {
await nativeDialog.alert({
message: 'Ukrainian localization was introduced in patch 2.0',
detail: 'Please change game language option before changing the patch.',
});

return;
}

next();
};

return (
<Section title="General">
<Field name="patch">
<Label>Cyberpunk patch</Label>
<Select options={patchOptions}></Select>
<Select
options={patchOptions}
onBeforeValueChange={ensureValidGameLanguageForPatch}
></Select>
</Field>
<Field name="minimizeToTray">
<Label>Minimize to tray</Label>
Expand Down
15 changes: 13 additions & 2 deletions src/electron/renderer/components/RecognitionSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Section } from './Section';
import { Select, SelectOption } from './Select';
import { Switch } from './Switch';

const gameLanguageOptions: SelectOption<BreachProtocolLanguage>[] = [
const v1GameLanguageOptions: SelectOption<BreachProtocolLanguage>[] = [
{ name: 'polski', value: 'pol' },
{ name: 'English', value: 'eng' },
{ name: 'Español', value: 'spa' },
Expand All @@ -29,6 +29,11 @@ const gameLanguageOptions: SelectOption<BreachProtocolLanguage>[] = [
{ name: 'ไทย', value: 'tha+eng' },
];

const v2GameLanguageOptions: SelectOption<BreachProtocolLanguage>[] = [
...v1GameLanguageOptions,
{ name: 'Українська', value: 'ukr' },
];

interface ThresholdFieldProps {
name: keyof AppSettings;
label: string;
Expand Down Expand Up @@ -109,7 +114,13 @@ export const RecognitionSettings = ({
</Field>
<Field name="gameLang">
<Label>Game language</Label>
<Select options={gameLanguageOptions} />
<Select
options={
values.patch === '1.x'
? v1GameLanguageOptions
: v2GameLanguageOptions
}
/>
</Field>
<Field name="filterRecognizerResults">
<Label>Filter OCR results</Label>
Expand Down

0 comments on commit bc3c3ac

Please sign in to comment.