linsyking/messenger-core/20.0.0

Renamed to elm-messenger/messenger-core. That is where the repository lives now. It has not been published as a package under the new name.

Versions published as linsyking/messenger-core still install under that name. 34 versions of 52 come from the new location (see their notes). 7 versions could not be recovered and cannot be installed.

Messenger.Scene.Scene

Scene Base

Core scene types and message types.

Most projects use the type aliases from Messenger.Scene.RawScene or Messenger.Scene.LayeredScene. This module is the lower-level foundation they build on.

type AbstractScene envro env event ren scenemsg userdata
= Roll
(UnrolledAbstractScene envro env event ren scenemsg userdata)

Rolled abstract scene model.

This hides the concrete scene data type so scenes with different data can be stored in the same scene map.

type alias MConcreteScene data userdata scenemsg =
ConcreteScene
data
Runtime
(Env () userdata)
Renderable
scenemsg
userdata

Specialized concrete scene for Messenger.

type alias MAbstractScene userdata scenemsg =
Runtime
(Env () userdata)
Renderable
scenemsg
userdata

Specialized abstract scene for Messenger.

AbstractScene envro env event ren scenemsg userdata
-> UnrolledAbstractScene envro env event ren scenemsg userdata

Unroll an abstract scene.

This is useful when advanced code needs to manually update or view an abstract scene, for example in Messenger.Scene.VSR.

ConcreteScene data envro env event ren scenemsg userdata
-> Maybe scenemsg
-> envro
-> env
-> AbstractScene envro env event ren scenemsg userdata

Abstract a concrete scene.

The concrete scene is initialized immediately with the given message and environment. The resulting AbstractScene stores its data privately.

type SceneOutputMsg scenemsg userdata
= SOMChangeScene (Maybe scenemsg) String
| SOMAlert String
| SOMPrompt String String
| SOMPlayAudio Int String AudioOption
| SOMStopAudio AudioTarget
| SOMTransformAudio AudioTarget (Audio -> Audio)
| SOMSetVolume Float
| SOMSaveGlobalData
| SOMLoadGC (GlobalComponentStorage userdata scenemsg)
| SOMUnloadGC GCTarget
| SOMCallGC ( GCTarget, GCMsg )
| SOMChangeFPS TimeInterval
| SOMLoadResource String ResourceDef

Scene output messages handled by Messenger core.

Scenes, layers, components, and global components emit these messages when they need top-level effects such as changing scenes, playing audio, loading resources, saving global data, or managing global components.

  • SOMChangeScene initMsg name changes to a scene by name.
  • SOMAlert text sends an alert command through user ports.
  • SOMPrompt name title sends a prompt command. The result comes back as a Prompt name result user event.
  • SOMPlayAudio channel name option plays a loaded audio resource.
  • SOMStopAudio target stops matching playing audio.
  • SOMTransformAudio target transform applies an elm-audio transform.
  • SOMSetVolume volume changes the global volume.
  • SOMSaveGlobalData calls globalDataCodec.encode.
  • SOMLoadGC gc loads a global component.
  • SOMUnloadGC target unloads matching global components.
  • SOMCallGC ( target, msg ) sends a message to a global component.
  • SOMChangeFPS interval changes the REGL update interval.
  • SOMLoadResource key resource loads a resource at runtime. Loaded data is stored in opaque runtime data and can be read through Messenger.Base getters.
type alias SceneStorage userdata scenemsg =
Maybe scenemsg
-> Runtime
-> Env () userdata
-> MAbstractScene userdata scenemsg

Scene storage.

A SceneStorage is what goes into the AllScenes dictionary. It receives an optional scene message and the current environment, then returns an initialized abstract scene.

type alias AllScenes userdata scenemsg =
Dict String (SceneStorage userdata scenemsg)

A dictionary of scene names to scene storage.

type alias MMsg othertar msg scenemsg userdata =
Msg othertar msg (SceneOutputMsg scenemsg userdata)

Messenger message.

This specializes Messenger.GeneralModel.Msg with SceneOutputMsg as the parent/system message type.

type alias MMsgBase othermsg scenemsg userdata =
MsgBase othermsg (SceneOutputMsg scenemsg userdata)

Messenger message base.

This specializes Messenger.GeneralModel.MsgBase with SceneOutputMsg as the parent/system message type.

type alias MConcreteGeneralModel data common userdata tar msg bdata scenemsg =
ConcreteGeneralModel
data
Runtime
(Env common userdata)
tar
msg
Renderable
bdata
(SceneOutputMsg scenemsg userdata)

Specialized concrete general model for Messenger scenes, layers, and components.

type alias MAbstractGeneralModel common userdata tar msg bdata scenemsg =
Runtime
(Env common userdata)
tar
msg
Renderable
bdata
(SceneOutputMsg scenemsg userdata)

Specialized abstract general model for Messenger scenes, layers, and components.

Scene Result Remapper

( ( List (SceneOutputMsg scenemsg userdata), env )
-> ( List (SceneOutputMsg scenemsg userdata), env )
)
-> AbstractScene envro env event ren scenemsg userdata
-> AbstractScene envro env event ren scenemsg userdata

Remap the result of an abstract scene update.

Use this when wrapping a scene and transforming its emitted SceneOutputMsgs or environment.

Global Component

type alias GCCommonData userdata scenemsg =
MAbstractScene userdata scenemsg

Common data passed to global components.

It is the currently running scene, so global components can render or update in relation to the active scene when needed.

type alias GCBaseData =
{ dead : Bool
, postProcessor : Renderable -> Renderable
}

Base data shared by all global components.

dead marks a component for removal. postProcessor transforms the scene renderable after the scene view is produced.

type alias GCMsg =
Value

Global component message type.

JSON values are used so global components can be addressed dynamically.

type alias GCTarget =
String

Global component target type.

type alias AbstractGlobalComponent userdata scenemsg =
MAbstractGeneralModel
(GCCommonData userdata scenemsg)
userdata
GCTarget
GCMsg
GCBaseData
scenemsg

Abstract global component model.

The concrete data type is hidden after initialization.

type alias ConcreteGlobalComponent data userdata scenemsg =
{ init : GlobalComponentInit userdata scenemsg data
, update : GlobalComponentUpdate userdata scenemsg data
, updaterec : GlobalComponentUpdateRec userdata scenemsg data
, view : GlobalComponentView userdata scenemsg data
, id : GCTarget
}

Concrete global component model.

type alias GlobalComponentInit userdata scenemsg data =
Runtime
-> Env (GCCommonData userdata scenemsg) userdata
-> GCMsg
-> ( data, GCBaseData )

Global component init type.

type alias GlobalComponentUpdate userdata scenemsg data =
Runtime
-> Env (GCCommonData userdata scenemsg) userdata
-> data
-> GCBaseData
-> ( ( data, GCBaseData )
, List (MMsg GCTarget GCMsg scenemsg userdata)
, ( Env (GCCommonData userdata scenemsg) userdata, Bool )
)

Global component update type.

The returned boolean is the block flag. If it is True, the current user event will not be passed to later global components or the scene.

type alias GlobalComponentUpdateRec userdata scenemsg data =
Runtime
-> Env (GCCommonData userdata scenemsg) userdata
-> GCMsg
-> data
-> GCBaseData
-> ( ( data, GCBaseData )
, List (MMsg GCTarget GCMsg scenemsg userdata)
, Env (GCCommonData userdata scenemsg) userdata
)

Global component recursive update type.

This handles messages sent to the global component by target.

type alias GlobalComponentView userdata scenemsg data =
Runtime
-> Env (GCCommonData userdata scenemsg) userdata
-> data
-> GCBaseData
-> Renderable

Global component view type.

type alias GlobalComponentStorage userdata scenemsg =
Runtime
-> Env (GCCommonData userdata scenemsg) userdata
-> AbstractGlobalComponent userdata scenemsg

Global component storage.

This is what gets loaded by SOMLoadGC or startup global component lists.