Skip to content

Commit caa38af

Browse files
committed
Autogenerate ./types
1 parent 4a5ca2e commit caa38af

File tree

7 files changed

+91
-18
lines changed

7 files changed

+91
-18
lines changed

types/gui/list.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { ModEntry } from '../types';
22
import { Fliters } from '../filters';
33
import './list-entry';
4-
import './repo-add';
54
declare global {
65
namespace modmanager.gui {
76
interface MenuList extends sc.ListTabbedPane, sc.Model.Observer {

types/gui/menu.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ declare global {
3131
checkUpdatesButton: sc.ButtonGui;
3232
filtersButton: sc.ButtonGui;
3333
filtersPopup: modmanager.gui.FiltersPopup;
34-
reposPopup: modmanager.gui.RepoAddPopup;
3534
changelogButton: sc.ButtonGui;
3635
changelogPopup?: modmanager.gui.Changelog;
3736
initInputField(this: this): void;

types/gui/options/option-elements-inject.d.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,16 @@ declare global {
3535
var OptionsOptionButton: OptionsOptionButtonConstructor;
3636
}
3737
}
38+
declare global {
39+
namespace modmanager.gui {
40+
interface OptionsOptionInputField extends ig.GuiElementBase {
41+
option: GuiOption;
42+
inputField: nax.ccuilib.InputField;
43+
isValidText?: sc.TextGui;
44+
}
45+
interface OptionsOptionInputFieldValidationConstructor extends ImpactClass<OptionsOptionInputField> {
46+
new (option: GuiOption, y: number, rowGroup: sc.RowButtonGroup, width: number): OptionsOptionInputField;
47+
}
48+
var OptionsOptionInputField: OptionsOptionInputFieldValidationConstructor;
49+
}
50+
}

types/gui/options/tabbox.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export {};
44
declare global {
55
namespace modmanager.gui {
66
namespace OptionsTabBox {
7-
type GuiOption = sc.OptionInfoBox | modmanager.gui.OptionsOptionRow | modmanager.gui.OptionsOptionButton;
7+
type GuiOption = sc.OptionInfoBox | modmanager.gui.OptionsOptionRow | modmanager.gui.OptionsOptionButton | modmanager.gui.OptionsOptionInputField;
88
}
99
interface OptionsTabBox extends ig.GuiElementBase, sc.Model.Observer {
1010
gfx: ig.Image;

types/mod-options.d.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export type Option = {
1818
description?: ig.LangLabel.Data;
1919
/** Is the option hidden from the menu */
2020
hidden?: boolean | (() => boolean);
21-
} & (BUTTON_GROUP | ARRAY_SLIDER | OBJECT_SILDER | CHECKBOX | CONTROLS | INFO | BUTTON | JSON_DATA);
21+
} & (BUTTON_GROUP | ARRAY_SLIDER | OBJECT_SILDER | CHECKBOX | CONTROLS | INFO | BUTTON | JSON_DATA | INPUT_FIELD);
2222
type BUTTON_GROUP = OptionChangeable & {
2323
type: 'BUTTON_GROUP';
2424
/** Initial option value */
@@ -33,6 +33,15 @@ type BUTTON_GROUP = OptionChangeable & {
3333
group: string[];
3434
data: Record<string, number>;
3535
});
36+
interface INPUT_FIELD extends OptionChangeable {
37+
type: 'INPUT_FIELD';
38+
/** Initial option value */
39+
init: string;
40+
/** Input field height */
41+
height?: number;
42+
/** Validation function */
43+
isValid?: (text: string) => boolean | Promise<boolean>;
44+
}
3645
interface ARRAY_SLIDER extends OptionChangeable {
3746
type: 'ARRAY_SLIDER';
3847
data: number[];
@@ -127,7 +136,7 @@ O extends keyof F = OmitNonChangeableToUnion<E>['key']> = {
127136
[K in O]: F[K];
128137
};
129138
export type OptsType<E extends Options, O extends Record<string, any> = OmitNonChangeable<E>> = {
130-
[T in keyof O]: O[T]['type'] extends 'CHECKBOX' ? boolean : O[T]['type'] extends 'BUTTON_GROUP' ? O[T]['enum'][keyof O[T]['enum']] : O[T]['type'] extends 'JSON_DATA' ? Readonly<O[T]['init']> : number;
139+
[T in keyof O]: O[T]['type'] extends 'CHECKBOX' ? boolean : O[T]['type'] extends 'BUTTON_GROUP' ? O[T]['enum'][keyof O[T]['enum']] : O[T]['type'] extends 'JSON_DATA' ? Readonly<O[T]['init']> : O[T]['type'] extends 'INPUT_FIELD' ? string : number;
131140
} & {
132141
flatOpts: FlatOpts<E>;
133142
};

types/options.d.ts

Lines changed: 62 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { repoChangeEvent, repoIsValid } from './repo-add';
12
export declare let Opts: ReturnType<typeof modmanager.registerAndGetModOptions<ReturnType<typeof registerOpts>>>;
23
export declare function registerOpts(): {
34
readonly general: {
@@ -11,19 +12,6 @@ export declare function registerOpts(): {
1112
readonly type: "CHECKBOX";
1213
readonly init: true;
1314
};
14-
readonly repositoriesButton: {
15-
readonly type: "BUTTON";
16-
readonly onPress: (this: import("./mod-options").GuiOption) => void;
17-
};
18-
readonly resetRepositoriesButton: {
19-
readonly type: "BUTTON";
20-
readonly onPress: (this: import("./mod-options").GuiOption) => void;
21-
};
22-
readonly repositories: {
23-
readonly type: "JSON_DATA";
24-
readonly init: string[];
25-
readonly changeEvent: (this: import("./mod-options").GuiOption) => void;
26-
};
2715
readonly testingOptInMods: {
2816
readonly type: "JSON_DATA";
2917
readonly init: string[];
@@ -76,4 +64,65 @@ export declare function registerOpts(): {
7664
};
7765
};
7866
};
67+
readonly repositories: {
68+
readonly settings: {
69+
readonly tabIcon: "interface";
70+
readonly title: "Repositories";
71+
};
72+
readonly headers: {
73+
readonly repositories: {
74+
readonly inputFieldRepo0: {
75+
type: "INPUT_FIELD";
76+
init: string;
77+
changeEvent: typeof repoChangeEvent;
78+
isValid: typeof repoIsValid;
79+
};
80+
readonly inputFieldRepo1: {
81+
type: "INPUT_FIELD";
82+
init: string;
83+
changeEvent: typeof repoChangeEvent;
84+
isValid: typeof repoIsValid;
85+
};
86+
readonly inputFieldRepo2: {
87+
type: "INPUT_FIELD";
88+
init: string;
89+
changeEvent: typeof repoChangeEvent;
90+
isValid: typeof repoIsValid;
91+
};
92+
readonly inputFieldRepo3: {
93+
type: "INPUT_FIELD";
94+
init: string;
95+
changeEvent: typeof repoChangeEvent;
96+
isValid: typeof repoIsValid;
97+
};
98+
readonly inputFieldRepo4: {
99+
type: "INPUT_FIELD";
100+
init: string;
101+
changeEvent: typeof repoChangeEvent;
102+
isValid: typeof repoIsValid;
103+
};
104+
readonly inputFieldRepo5: {
105+
type: "INPUT_FIELD";
106+
init: string;
107+
changeEvent: typeof repoChangeEvent;
108+
isValid: typeof repoIsValid;
109+
};
110+
readonly inputFieldRepo6: {
111+
type: "INPUT_FIELD";
112+
init: string;
113+
changeEvent: typeof repoChangeEvent;
114+
isValid: typeof repoIsValid;
115+
};
116+
readonly resetRepositoriesButton: {
117+
readonly type: "BUTTON";
118+
readonly onPress: (this: import("./mod-options").GuiOption) => void;
119+
};
120+
readonly repositories: {
121+
readonly type: "JSON_DATA";
122+
readonly init: string[];
123+
readonly changeEvent: (this: import("./mod-options").GuiOption) => void;
124+
};
125+
};
126+
};
127+
};
79128
};

types/repo-add.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import { Option } from './mod-options';
2+
export declare function repoChangeEvent(this: Option): void;
3+
export declare function modDatabasesToInputFields(): void;
4+
export declare function repoIsValid(this: Option, value: string): Promise<boolean>;

0 commit comments

Comments
 (0)