Closed CosmoMyzrailGorynych closed 2 years ago
Hey there 👋 I marked this issue as stale as it hadn't brought much attention for quite a while. I do understand that stale issues are still issues, yet here stale issues receive the least attention from maintainers so they can focus on more relevant tasks. You can help with this issue by checking whether it affects latest versions of ct.js and writing about it if it does, providing an example project and steps to reproduce. Or maybe you can close it with a PR! Note that some platform-dependent issues can't be resolved by developers due to the absense of such devices :c We will need help from you for such tasks. If this issue won't get attention in three months, it will be closed.
This issue is now closed! Please create a new one with a proper template if this issue still affects ct.js.
Tidy up the mess with global event listeners, aka
window.signals
. There should be a logical and obvious naming system, an accessible list of names of existing events, and triggers set up on generic asset changes and UI events.window.signals
(WIP)Intention of
window.signals
window.signals
must only be used to update views of directly edited entities and those entities that use others as is. For example,node_requires/resources/textures
is made to update texture asset in FS (file system);textureUpdated
is fired with the new texture's JSON object, as well asassetUpdated
;textureUpdated
and filtering the results.But also consider this:
node_requires/resources/textures
is made to delete the texture from the FS;assetUpdated
, as well as{x}Updated
relevant to their asset type;{x}Updated
events (say a type has lost its texture and its thumbnail needs to be refreshed).{x}Updated
events;textureDeleted
andassetDeleted
are triggered.assetDeleted
event.Asset viewers must not patch their assets by themselves due to changes in dependencies.
Handling changes coming both from a user and dependency hooks
Users may be editing an asset that gets patched by a hook that resolves missing asset dependencies. Before making patches,
window.orders.trigger('saveAsset')
is called to forcefully save an asset if it is opened in an asset viewer.Operations upon assets
These events must be triggered only from the
node_requires/resources
directory. All the CRUD logic also lies here.For each asset type, these events must be generated (using
texture
as an example here):textureCreated
textureUpdated
textureDeleted
textureMoved
These events are for updates between different entities. Any asset type also emits these events:
assetCreated
assetUpdated
assetDeleted
assetMoved
These events are mainly for the asset viewer. All the events pass two arguments: the changed js object and a path to an asset file.
assetRenamed
also passes the old path as its third argument.Move operations are counted as
assetRenamed
.UI events
assetOpened
— when a user opened an asset or switches a tab to it. Passes the type of the asset and full path to it as its arguments.ideFocused
ideBlurred
debuggerStarted
debuggerStopped
projectLoaded
— is it even a UI event? Anyways, it is needed.window.orders
(WIP)While
window.signals
is used for read-only operations in UI,window.orders
may be used to forcefully trigger some events in asset editors.saveAllAssets
saveAsset
— has a path to the asset as its only argument. Orders to save a currently edited asset, if it is opened.openAsset
— has a path to the asset as its only argument. Creates a new tab or focuses on the existing one. This may be called from asset editors to quickly jump between dependent entities.