shrub/pkg/arvo/app/launch.hoon

189 lines
4.6 KiB
Plaintext
Raw Normal View History

:: launch [landscape]:
::
:: registers Landscape (and third party) applications, tiles
::
2020-05-20 22:12:53 +03:00
/+ store=launch-store, default-agent, dbug
2019-11-21 02:39:46 +03:00
|%
+$ card card:agent:gall
2019-11-21 02:39:46 +03:00
+$ versioned-state
2020-05-05 20:10:58 +03:00
$% [%0 *]
[%1 *]
[%2 *]
[%3 *]
[%4 state-zero]
2020-09-25 03:44:24 +03:00
[%5 state-zero]
2019-11-21 02:39:46 +03:00
==
::
2019-11-21 02:39:46 +03:00
+$ state-zero
2020-05-20 22:12:53 +03:00
$: =tiles:store
=tile-ordering:store
first-time=?
2020-03-20 22:06:10 +03:00
==
2019-11-21 02:39:46 +03:00
--
::
2020-09-25 03:44:24 +03:00
=| [%5 state-zero]
2019-11-21 02:39:46 +03:00
=* state -
2020-03-12 03:33:48 +03:00
%- agent:dbug
2019-11-21 02:39:46 +03:00
^- agent:gall
|_ =bowl:gall
2019-11-21 02:39:46 +03:00
+* this .
def ~(. (default-agent this %|) bowl)
2020-05-05 20:10:58 +03:00
::
2019-11-21 02:39:46 +03:00
++ on-init
^- (quip card _this)
=/ new-state *state-zero
=. new-state
%_ new-state
tiles
2020-05-20 22:12:53 +03:00
%- ~(gas by *tiles:store)
2020-09-25 03:44:24 +03:00
%+ turn `(list term)`[%weather %clock %dojo ~]
|= =term
:- term
2020-05-20 22:12:53 +03:00
^- tile:store
?+ term [[%custom ~] %.y]
%dojo [[%basic 'Dojo' '/~landscape/img/Dojo.png' '/~dojo'] %.y]
==
2020-09-25 03:44:24 +03:00
tile-ordering [%weather %clock %dojo ~]
==
2020-09-25 03:44:24 +03:00
[~ this(state [%5 new-state])]
2019-11-21 02:39:46 +03:00
::
++ on-save !>(state)
++ on-load
|= old=vase
2020-03-20 22:06:10 +03:00
^- (quip card _this)
=/ old-state !<(versioned-state old)
2020-09-25 03:44:24 +03:00
|-
2020-09-30 16:48:33 +03:00
?: ?=(%5 -.old-state)
`this(state old-state)
?: ?=(%4 -.old-state)
:- [%pass / %arvo %e %disconnect [~ /]]~
2020-09-25 03:44:24 +03:00
=. tiles.old-state
(~(del by tiles.old-state) %chat)
=. tiles.old-state
(~(del by tiles.old-state) %publish)
=. tiles.old-state
(~(del by tiles.old-state) %links)
=. tile-ordering.old-state
(skip tile-ordering.old-state |=(=term ?=(?(%links %chat %publish) term)))
this(state [%5 +.old-state])
=/ new-state *state-zero
=. new-state
%_ new-state
tiles
2020-05-20 22:12:53 +03:00
%- ~(gas by *tiles:store)
2020-09-25 03:44:24 +03:00
%+ turn `(list term)`[%weather %clock %dojo ~]
|= =term
:- term
2020-05-20 22:12:53 +03:00
^- tile:store
?+ term [[%custom ~] %.y]
%dojo [[%basic 'Dojo' '/~landscape/img/Dojo.png' '/~dojo'] %.y]
==
2020-09-25 03:44:24 +03:00
tile-ordering [%weather %clock %dojo ~]
==
2020-09-25 03:44:24 +03:00
:_ this(state [%5 new-state])
%+ welp
:~ [%pass / %arvo %e %disconnect [~ /]]
:* %pass /srv %agent [our.bowl %file-server]
%poke %file-server-action
!>([%serve-dir / /app/landscape %.n %.y])
==
==
%+ turn ~(tap by wex.bowl)
|= [[=wire =ship =term] *]
^- card
[%pass wire %agent [ship term] %leave ~]
2019-11-21 02:39:46 +03:00
::
++ on-poke
|= [=mark =vase]
2019-11-21 02:39:46 +03:00
^- (quip card _this)
|^
?> (team:title our.bowl src.bowl)
=^ cards state
?+ mark (on-poke:def mark vase)
2020-05-20 22:12:53 +03:00
%launch-action (poke-action !<(action:store vase))
==
[cards this]
::
++ poke-action
2020-05-20 22:12:53 +03:00
|= =action:store
^- (quip card _state)
?- -.action
%add
?< (~(has by tiles) name.action)
:- (give [/all /keys ~] action)
%_ state
tiles (~(put by tiles) name.action tile.action)
tile-ordering (snoc tile-ordering name.action)
==
::
%remove
:- (give [/all /keys ~] action)
%_ state
tiles (~(del by tiles) name.action)
tile-ordering
%+ skip tile-ordering
|=(=term =(term name.action))
==
::
%change-order
?> =(~(key by tiles) (silt tile-ordering.action))
:- (give [/all]~ action)
state(tile-ordering tile-ordering.action)
::
%change-is-shown
2020-05-20 22:12:53 +03:00
=/ =tile:store (~(got by tiles) name.action)
?. =(is-shown.tile is-shown.action) [~ state]
=. is-shown.tile is-shown.action
:- (give [/all]~ action)
state(tiles (~(put by tiles) name.action tile))
2020-05-20 22:12:53 +03:00
::
%change-first-time
:- (give [/all]~ action)
state(first-time first-time.action)
==
::
++ give
2020-05-20 22:12:53 +03:00
|= [paths=(list path) =update:store]
^- (list card)
[%give %fact paths [%launch-update !>(update)]]~
--
2019-11-21 02:39:46 +03:00
::
++ on-watch
2020-05-05 20:10:58 +03:00
|= =path
2019-11-21 02:39:46 +03:00
^- (quip card _this)
|^
?> (team:title our.bowl src.bowl)
=/ cards=(list card)
2020-05-20 22:12:53 +03:00
?+ path (on-watch:def path)
[%all ~] (give [%initial tiles tile-ordering first-time])
[%keys ~] (give [%keys ~(key by tiles)])
==
[cards this]
::
++ give
2020-05-20 22:12:53 +03:00
|= =update:store
^- (list card)
[%give %fact ~ [%launch-update !>(update)]]~
--
::
2020-05-20 22:12:53 +03:00
++ on-peek
|= =path
^- (unit (unit cage))
2020-08-19 21:46:52 +03:00
?. (team:title our.bowl src.bowl) ~
?+ path [~ ~]
[%x %tiles ~] ``noun+!>([tiles tile-ordering])
[%x %first-time ~] ``noun+!>(first-time)
2020-08-19 21:46:52 +03:00
[%x %keys ~] ``noun+!>(~(key by tiles))
2020-05-20 22:12:53 +03:00
==
2019-11-21 02:39:46 +03:00
::
++ on-arvo
|= [wir=wire sin=sign-arvo]
^- (quip card:agent:gall _this)
2020-05-05 20:10:58 +03:00
?: ?=(%bound +<.sin) [~ this]
(on-arvo:def wir sin)
::
2020-05-05 20:10:58 +03:00
++ on-agent on-agent:def
++ on-leave on-leave:def
++ on-fail on-fail:def
2019-11-21 02:39:46 +03:00
--