2022-06-27 00:17:22 +00:00
|
|
|
import type { Settings } from "game/settings";
|
2022-01-14 04:25:47 +00:00
|
|
|
import { createNanoEvents } from "nanoevents";
|
2022-12-06 04:53:46 +00:00
|
|
|
import type { App } from "vue";
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
import type { Layer } from "./layers";
|
2024-03-17 05:50:22 +00:00
|
|
|
import state from "./state";
|
2022-01-14 04:25:47 +00:00
|
|
|
|
2022-07-15 05:55:36 +00:00
|
|
|
/** All types of events able to be sent or emitted from the global event bus. */
|
2022-01-14 04:25:47 +00:00
|
|
|
export interface GlobalEvents {
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent whenever a layer is added.
|
|
|
|
* @param layer The layer being added.
|
|
|
|
* @param saveData The layer's save data object within player.
|
|
|
|
*/
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
addLayer: (layer: Layer, saveData: Record<string, unknown>) => void;
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent whenever a layer is removed.
|
|
|
|
* @param layer The layer being removed.
|
|
|
|
*/
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
removeLayer: (layer: Layer) => void;
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent every game tick. Runs the life cycle of the project.
|
|
|
|
* @param diff The delta time since last tick, in ms.
|
|
|
|
* @param trueDiff The delta time since last tick, in ms. Unaffected by time modifiers like {@link game/player.Player.devSpeed} or {@link game/player.Player.offlineTime}. Intended for things like updating animations.
|
|
|
|
*/
|
2022-03-11 20:02:41 +00:00
|
|
|
update: (diff: number, trueDiff: number) => void;
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent when constructing the {@link Settings} object.
|
|
|
|
* Use it to add default values for custom properties to the object.
|
|
|
|
* @param settings The settings object being constructed.
|
|
|
|
* @see {@link features/features.setDefault} for setting default values.
|
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
loadSettings: (settings: Partial<Settings>) => void;
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent when the game has ended.
|
|
|
|
*/
|
2022-03-11 23:26:39 +00:00
|
|
|
gameWon: VoidFunction;
|
2022-07-15 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Sent when setting up the Vue Application instance.
|
|
|
|
* Use it to register global components or otherwise set up things that should affect Vue globally.
|
|
|
|
* @param vue The Vue App being constructed.
|
|
|
|
*/
|
2022-01-14 04:25:47 +00:00
|
|
|
setupVue: (vue: App) => void;
|
2022-07-22 00:23:33 +00:00
|
|
|
/**
|
|
|
|
* Sent whenever a save has finished loading.
|
|
|
|
* Happens when the page is opened and upon switching saves in the saves manager.
|
|
|
|
*/
|
|
|
|
onLoad: VoidFunction;
|
2022-08-22 05:39:59 +00:00
|
|
|
/**
|
|
|
|
* Using document.fonts.ready returns too early on firefox, so we use document.fonts.onloadingdone instead, which doesn't accept multiple listeners.
|
|
|
|
* This event fires when that callback is called.
|
|
|
|
*/
|
|
|
|
fontsLoaded: VoidFunction;
|
2022-01-14 04:25:47 +00:00
|
|
|
}
|
|
|
|
|
2022-07-15 05:55:36 +00:00
|
|
|
/** A global event bus for hooking into {@link GlobalEvents}. */
|
2022-01-14 04:25:47 +00:00
|
|
|
export const globalBus = createNanoEvents<GlobalEvents>();
|
|
|
|
|
2023-02-16 05:15:55 +00:00
|
|
|
if ("fonts" in document) {
|
|
|
|
// This line breaks tests
|
|
|
|
// JSDom doesn't add document.fonts, and Object.defineProperty doesn't seem to work on document
|
|
|
|
document.fonts.onloadingdone = () => globalBus.emit("fontsLoaded");
|
|
|
|
}
|
2024-03-17 05:50:22 +00:00
|
|
|
|
|
|
|
document.onmousemove = function () {
|
|
|
|
state.mouseActivity[state.mouseActivity.length - 1] = true;
|
|
|
|
};
|