Skip to content

Commit

Permalink
feat(client-electron): add ability to emit sequences immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
marcincichocki committed Oct 15, 2022
1 parent 721bf12 commit 41f5db6
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/core/solver/breach-protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Daemon } from './daemon';
import { HierarchyProvider } from './hierarchy/hierarchy-provider';
import { memoizedFindOverlap } from './overlap';
import { Sequence, SequenceJSON } from './sequence';
import { SequenceFactory } from './sequence-factory';
import { SequenceFactory, SequenceFactoryOptions } from './sequence-factory';

export type BreachProtocolResultJSON = {
path: string[];
Expand Down Expand Up @@ -120,7 +120,8 @@ export class BreachProtocolResult implements Serializable {
}
}

export interface BreachProtocolOptions {
export interface BreachProtocolOptions
extends Pick<SequenceFactoryOptions, 'immediate'> {
strategy: BreachProtocolStrategy;
hierarchyProvider: HierarchyProvider<BreachProtocolRawData>;
}
Expand Down Expand Up @@ -156,6 +157,7 @@ export class BreachProtocol {

private readonly factory = new SequenceFactory(this.rawData, {
hierarchy: this.options.hierarchyProvider.provide(this.rawData),
immediate: this.options.immediate,
});

constructor(
Expand Down
2 changes: 1 addition & 1 deletion src/core/solver/sequence-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Daemon } from './daemon';
import { memoizedFindOverlap } from './overlap';
import { Sequence } from './sequence';

interface SequenceFactoryOptions {
export interface SequenceFactoryOptions {
/** Hierarchy of daemons that will be used to sort sequences. */
hierarchy: number[];

Expand Down
2 changes: 1 addition & 1 deletion src/electron/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export interface AppSettings
KeyBindsConfig,
ResolverSettings,
Required<BreachProtocolOCROptions>,
Pick<BreachProtocolOptions, 'strategy'> {
Exclude<BreachProtocolOptions, 'hierarchyProvider'> {
historySize: number;
preserveSourceOnSuccess: boolean;
checkForUpdates: boolean;
Expand Down
6 changes: 6 additions & 0 deletions src/electron/common/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,12 @@ export const options: BreachProtocolOption[] = [
DAEMON_DATAMINE_V1,
],
},
{
id: 'immediate',
description:
'Determines if sequences should be emitted immediately, or should they be grouped by permutation of daemons. Grouped sequences are sorted by raw path length.',
defaultValue: false,
},
];

function optionsToObject<T>(cb: (option: BreachProtocolOption) => T) {
Expand Down
22 changes: 22 additions & 0 deletions src/electron/renderer/components/PerformanceSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export const PerformanceSettings = () => {
next();
}

async function notifyAboutExtendedDaemonsAndTypesRecognitionRange(
value: boolean,
next: () => void
) {
if (value && !values.extendedDaemonsAndTypesRecognitionRange) {
await nativeDialog.alert({
message:
'This option might have little to no impact when extended daemons and types recognition range is not enabled.',
});
}

next();
}

return (
<Section title="Performance">
<Field name="format">
Expand Down Expand Up @@ -108,6 +122,14 @@ export const PerformanceSettings = () => {
onBeforeValueChange={notifyAboutDfs}
></Select>
</Field>
<Field name="immediate">
<Label>Immediate sequences</Label>
<Switch
onBeforeValueChange={
notifyAboutExtendedDaemonsAndTypesRecognitionRange
}
/>
</Field>
</Section>
);
};

0 comments on commit 41f5db6

Please sign in to comment.