@wayward/types 2.12.1-beta.dev.20221017.1 → 2.12.1-beta.dev.20221019.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -104,7 +104,7 @@ export default class Component<E extends HTMLElement = HTMLElement> extends Even
104
104
  /**
105
105
  * Forcibly regenerates the cached result of {@link Component.getBox} for this component and all descendants.
106
106
  */
107
- regenerateBoxes(): void;
107
+ regenerateBoxes(descendants?: boolean): void;
108
108
  /**
109
109
  * Returns an object containing {@link HTMLElement.offsetTop} and {@link HTMLElement.offsetLeft}
110
110
  */
@@ -9,12 +9,14 @@
9
9
  * https://github.com/WaywardGame/types/wiki
10
10
  */
11
11
  import type Dictionary from "language/Dictionary";
12
- import Component from "ui/component/Component";
12
+ import type Component from "ui/component/Component";
13
13
  import type { IDropdownOption } from "ui/component/Dropdown";
14
14
  import EnumDropdown from "ui/component/dropdown/EnumDropdown";
15
- import Tooltip from "ui/tooltip/Tooltip";
15
+ import type Tooltip from "ui/tooltip/Tooltip";
16
+ import type TooltipLocationHandler from "ui/tooltip/TooltipLocationHandler";
16
17
  export default abstract class GroupDropdown<ENUM_OBJECT, OTHER_OPTIONS extends string, GROUP extends number, VALUES = ENUM_OBJECT[keyof ENUM_OBJECT]> extends EnumDropdown<ENUM_OBJECT, OTHER_OPTIONS, VALUES> {
17
18
  private groups;
19
+ private tooltipSurface?;
18
20
  private tooltip?;
19
21
  private lastGroupText?;
20
22
  private readonly wordToGroups;
@@ -35,15 +37,10 @@ export default abstract class GroupDropdown<ENUM_OBJECT, OTHER_OPTIONS extends s
35
37
  protected onClose(): void;
36
38
  protected onRemove(): void;
37
39
  protected onFilterChange(): void;
38
- protected updateTooltip(): GroupDropdownTooltip;
40
+ protected updateTooltip(): Tooltip | undefined;
39
41
  protected onRegenerateBox(): void;
40
42
  private getTooltip;
43
+ protected getTooltipLocation(handler: TooltipLocationHandler): void;
41
44
  private getGroupMap;
42
45
  private addGroup;
43
46
  }
44
- declare class GroupDropdownTooltip extends Tooltip {
45
- constructor(source: Component | HTMLElement);
46
- updatePosition(force?: boolean): this;
47
- protected onShow(): void;
48
- }
49
- export {};
@@ -86,6 +86,9 @@ export declare type TranslationData = IBaseTranslationData | (Partial<IBaseTrans
86
86
  entry: UiTranslation;
87
87
  });
88
88
  export declare type TextOrTranslationData = string | UiTranslation | TranslationData;
89
+ /**
90
+ * @deprecated
91
+ */
89
92
  export declare enum TooltipLocation {
90
93
  AboveLeft = 0,
91
94
  AboveMiddle = 1,
@@ -87,5 +87,6 @@ export declare class BasicText extends Component {
87
87
  protected inputModifier?: Modifier;
88
88
  constructor(elementType?: string);
89
89
  setText(text: IStringSection & Partial<IColorSection> & Partial<ILinkSection> & Partial<IHeadingSection> & Partial<ITooltipSection> & Partial<IReferenceSection> & Partial<IListItemSection> & Partial<IBindingsSection>): this;
90
+ private setTooltipLocation;
90
91
  private onClick;
91
92
  }
@@ -14,6 +14,7 @@ import type Button from "ui/component/Button";
14
14
  import type { IDropdownOption } from "ui/component/Dropdown";
15
15
  import Dropdown from "ui/component/Dropdown";
16
16
  import type Tooltip from "ui/tooltip/Tooltip";
17
+ import type TooltipLocationHandler from "ui/tooltip/TooltipLocationHandler";
17
18
  export default class EnumDropdown<ENUM_OBJECT, OTHER_OPTIONS extends string | never = never, VALUES = ENUM_OBJECT[keyof ENUM_OBJECT]> extends Dropdown<VALUES | OTHER_OPTIONS> {
18
19
  protected readonly enumObject: ENUM_OBJECT;
19
20
  private readonly dictionary;
@@ -27,6 +28,6 @@ export default class EnumDropdown<ENUM_OBJECT, OTHER_OPTIONS extends string | ne
27
28
  protected getTranslation(id: VALUES): import("../../../language/impl/TranslationImpl").default;
28
29
  protected filterEnum?(id: VALUES): boolean;
29
30
  protected getOptions(enumObject: any): [VALUES, (option: Button) => Button][];
30
- private getTooltipLocation;
31
+ protected getOptionTooltipLocation(handler: TooltipLocationHandler): void;
31
32
  protected optionTooltipInitializer?(tooltip: Tooltip, type: VALUES, translation: Translation): any;
32
33
  }
@@ -35,7 +35,7 @@ export default abstract class InspectionsTooltipHandler<INSPECTIONS_LIST extends
35
35
  protected onUpdateTooltipPosition(position: Vector2): void;
36
36
  protected getTooltipClass(): string[];
37
37
  protected initializeHints(hints: InspectionTooltipHints, ...args: TOOLTIP_ARGS): void;
38
- protected updateTooltipPosition(position?: Vector2): void;
38
+ protected updateTooltipPosition(): void;
39
39
  private refreshTooltipExtraInfoAndPosition;
40
40
  protected onMoveToIsland(): void;
41
41
  }
@@ -63,7 +63,7 @@ export declare enum ItemClasses {
63
63
  NearlyDecayed = "item-component-nearly-decayed"
64
64
  }
65
65
  export declare namespace ItemClasses {
66
- const IconLocation: (enumValue: ItemDetailIconLocation) => "item-component-icon-location-topleft" | "item-component-icon-location-bottomright";
66
+ const IconLocation: (enumValue: ItemDetailIconLocation) => "item-component-icon-location-bottomright" | "item-component-icon-location-topleft";
67
67
  }
68
68
  export interface IItemHandler {
69
69
  noDrag?: true;
@@ -50,7 +50,7 @@ export default abstract class QuadrantComponent extends StaticComponent {
50
50
  protected readonly scrollableHandler: void;
51
51
  get preferredQuadrant(): Quadrant;
52
52
  get quadrant(): Quadrant;
53
- get quadrantName(): "TopLeft" | "TopRight" | "BottomLeft" | "BottomRight" | "None" | "Top" | "Bottom" | "Any";
53
+ get quadrantName(): "None" | "Top" | "Bottom" | "TopRight" | "BottomRight" | "BottomLeft" | "TopLeft" | "Any";
54
54
  readonly log: Log;
55
55
  constructor(id: QuadrantComponentId);
56
56
  protected registerDataHost(): void;
@@ -16,7 +16,8 @@ import type { TranslationGenerator } from "ui/component/IComponent";
16
16
  import { TooltipLocation } from "ui/component/IComponent";
17
17
  import Text, { Paragraph } from "ui/component/Text";
18
18
  import type Bindable from "ui/input/Bindable";
19
- import Vector2 from "utilities/math/Vector2";
19
+ import type { TooltipAnchorStringHorizontal, TooltipAnchorStringVertical } from "ui/tooltip/TooltipLocationHandler";
20
+ import TooltipLocationHandler from "ui/tooltip/TooltipLocationHandler";
20
21
  export declare enum TooltipClasses {
21
22
  Main = "tooltip",
22
23
  ForceShown = "tooltip-force-shown",
@@ -28,24 +29,28 @@ export declare enum TooltipClasses {
28
29
  Secondary = "tooltip-colored-secondary"
29
30
  }
30
31
  export interface ITooltipEvents extends Events<Component> {
31
- move(position: Vector2): any;
32
- setLocation(location: TooltipLocation): any;
32
+ setLocation(): any;
33
+ updatePosition(): any;
33
34
  }
34
35
  export default class Tooltip extends Component {
35
36
  event: IEventEmitter<this, ITooltipEvents>;
36
- get location(): TooltipLocation;
37
37
  readonly source: Component;
38
38
  readonly blocks: Component<HTMLElement>;
39
39
  readonly hints: Component<HTMLElement>;
40
+ readonly location: TooltipLocationHandler;
40
41
  private forceShown;
41
42
  private maxWidth;
42
43
  private hasSetPosition;
43
44
  constructor(source: Component | HTMLElement);
44
45
  protected onRemove(): void;
45
- protected onHide(): void;
46
46
  setSecondary(): this;
47
47
  setForceShown(forceShown?: boolean): this;
48
48
  wasForceShown(): boolean;
49
+ setLocation(initializer: (locationHandler: TooltipLocationHandler) => any): this;
50
+ setLocation(xAnchor: TooltipAnchorStringHorizontal, yAnchor: TooltipAnchorStringVertical): this;
51
+ setLocation(xAnchor: TooltipAnchorStringHorizontal, xRefSelector: string, yAnchor: TooltipAnchorStringVertical): this;
52
+ setLocation(xAnchor: TooltipAnchorStringHorizontal, yAnchor: TooltipAnchorStringVertical, yRefSelector: string): this;
53
+ setLocation(xAnchor: TooltipAnchorStringHorizontal, xRefSelector: string, yAnchor: TooltipAnchorStringVertical, yRefSelector: string): this;
49
54
  setLocation(location: TooltipLocation): this;
50
55
  /**
51
56
  * Sets the max width of this tooltip.
@@ -72,9 +77,10 @@ export default class Tooltip extends Component {
72
77
  updatePosition(regenerateBox?: boolean): this;
73
78
  private initialPositionAndShownHandledExternally;
74
79
  setInitialPositionAndShownHandledExternally(): this;
80
+ private dumpOnShow;
81
+ setDumpOnShow(dumpOnShow?: boolean): this;
75
82
  protected onShow(): void;
76
83
  dump(): this;
77
- private onMouseMove;
78
84
  }
79
85
  export declare class TooltipBlock extends Component {
80
86
  constructor();
@@ -0,0 +1,77 @@
1
+ /*!
2
+ * Copyright 2011-2021 Unlok
3
+ * https://www.unlok.ca
4
+ *
5
+ * Credits & Thanks:
6
+ * https://www.unlok.ca/credits-thanks/
7
+ *
8
+ * Wayward is a copyrighted and licensed work. Modification and/or distribution of any source files is prohibited. If you wish to modify the game in any way, please refer to the modding guide:
9
+ * https://github.com/WaywardGame/types/wiki
10
+ */
11
+ import type Tooltip from "ui/tooltip/Tooltip";
12
+ import type { IVector2 } from "utilities/math/IVector";
13
+ export declare enum TooltipAnchorType {
14
+ Off = 0,
15
+ Aligned = 1
16
+ }
17
+ export declare enum TooltipAnchorSideHorizontal {
18
+ Right = 0,
19
+ Left = 1
20
+ }
21
+ export declare enum TooltipAnchorSideVertical {
22
+ Top = 0,
23
+ Bottom = 1
24
+ }
25
+ export declare type TooltipAnchorTypeString = Lowercase<keyof typeof TooltipAnchorType>;
26
+ export declare type TooltipAnchorSideStringHorizontal = Lowercase<keyof typeof TooltipAnchorSideHorizontal>;
27
+ export declare type TooltipAnchorSideStringVertical = Lowercase<keyof typeof TooltipAnchorSideVertical>;
28
+ export declare type TooltipAnchorStringHorizontalSimple = `${TooltipAnchorTypeString} ${TooltipAnchorSideStringHorizontal}` | "center";
29
+ export declare type TooltipAnchorStringHorizontal = `${"sticky " | ""}${TooltipAnchorStringHorizontalSimple}`;
30
+ export declare type TooltipAnchorStringVerticalSimple = `${TooltipAnchorTypeString} ${TooltipAnchorSideStringVertical}` | "center";
31
+ export declare type TooltipAnchorStringVertical = `${"sticky " | ""}${TooltipAnchorStringVerticalSimple}`;
32
+ export declare type TooltipAnchorStringSimple = TooltipAnchorStringHorizontalSimple | TooltipAnchorStringVerticalSimple;
33
+ export declare type TooltipAnchorString = TooltipAnchorStringHorizontal | TooltipAnchorStringVertical;
34
+ export interface ITooltipLocationPreference {
35
+ xAnchor: ITooltipLocationHorizontalAnchor;
36
+ xRefSelector: string;
37
+ yAnchor: ITooltipLocationVerticalAnchor;
38
+ yRefSelector: string;
39
+ }
40
+ export interface ITooltipLocationHorizontalAnchor {
41
+ type: TooltipAnchorTypeString | "center";
42
+ side: TooltipAnchorSideStringHorizontal | "center";
43
+ sticky: boolean;
44
+ }
45
+ export interface ITooltipLocationVerticalAnchor {
46
+ type: TooltipAnchorTypeString | "center";
47
+ side: TooltipAnchorSideStringVertical | "center";
48
+ sticky: boolean;
49
+ }
50
+ export declare enum TooltipLocationAlignment {
51
+ Left = 0,
52
+ Center = 1,
53
+ Right = 2
54
+ }
55
+ export interface ITooltipLocation extends IVector2 {
56
+ mouse: boolean;
57
+ padX: boolean;
58
+ alignment?: Lowercase<keyof typeof TooltipLocationAlignment>;
59
+ }
60
+ export default class TooltipLocationHandler {
61
+ readonly locationPreference: ITooltipLocationPreference[];
62
+ private readonly _tooltip;
63
+ get tooltip(): Tooltip | undefined;
64
+ constructor(tooltip: Tooltip);
65
+ isMouse(): boolean;
66
+ reset(): this;
67
+ add(xAnchor: TooltipAnchorStringHorizontal, yAnchor: TooltipAnchorStringVertical): this;
68
+ add(xAnchor: TooltipAnchorStringHorizontal, xRefSelector: string, yAnchor: TooltipAnchorStringVertical): this;
69
+ add(xAnchor: TooltipAnchorStringHorizontal, yAnchor: TooltipAnchorStringVertical, yRefSelector: string): this;
70
+ add(xAnchor: TooltipAnchorStringHorizontal, xRefSelector: string, yAnchor: TooltipAnchorStringVertical, yRefSelector: string): this;
71
+ private parseAnchor;
72
+ private location;
73
+ get(): ITooltipLocation;
74
+ update(): void;
75
+ private readonly refCache;
76
+ private resolveAnchorRef;
77
+ }
@@ -8,14 +8,13 @@
8
8
  * Wayward is a copyrighted and licensed work. Modification and/or distribution of any source files is prohibited. If you wish to modify the game in any way, please refer to the modding guide:
9
9
  * https://github.com/WaywardGame/types/wiki
10
10
  */
11
+ import EventEmitter from "event/EventEmitter";
11
12
  import Component from "ui/component/Component";
12
13
  import Tooltip from "ui/tooltip/Tooltip";
13
- import type Vector2 from "utilities/math/Vector2";
14
14
  export default class TooltipManager {
15
- readonly tooltipWrapper: Component;
16
- readonly tooltipMainWrapper: Component;
17
- readonly tooltipMouseWrapper: Component;
18
- private current;
15
+ readonly surfaceWrapper: Component<HTMLElement>;
16
+ readonly main: TooltipSurface;
17
+ readonly surfaces: TooltipSurface[];
19
18
  private readonly disablers;
20
19
  constructor();
21
20
  show(host: HTMLElement, initialize?: (tooltip: Tooltip) => any): Tooltip | undefined;
@@ -32,10 +31,27 @@ export default class TooltipManager {
32
31
  * disabler has been removed.
33
32
  */
34
33
  enable(disabler: any): this;
34
+ createSurface(): TooltipSurface;
35
35
  protected onInterrupt(): void;
36
36
  protected onInterruptClose(): void;
37
37
  protected onScreenResize(): void;
38
- protected onMove(_: any, position: Vector2): void;
38
+ protected onMove(): void;
39
39
  private loop;
40
- private remove;
40
+ }
41
+ export interface ITooltipSurfaceEvents {
42
+ remove(): any;
43
+ }
44
+ export declare class TooltipSurface extends EventEmitter.Host<ITooltipSurfaceEvents> {
45
+ private _host?;
46
+ get host(): HTMLElement | undefined;
47
+ tooltip?: Tooltip;
48
+ readonly surface: Component<HTMLElement>;
49
+ setId(id: string): this;
50
+ hasTooltip(): boolean;
51
+ showTooltip(host: HTMLElement, initialize?: (tooltip: Tooltip) => any): Tooltip | undefined;
52
+ hideTooltip(host?: HTMLElement | undefined): boolean;
53
+ removeTooltip(): void;
54
+ remove(): void;
55
+ private currentAlignment;
56
+ updatePosition(): void;
41
57
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wayward/types",
3
3
  "description": "TypeScript declarations for Wayward, used for modding.",
4
- "version": "2.12.1-beta.dev.20221017.1",
4
+ "version": "2.12.1-beta.dev.20221019.1",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",