urbit/pkg/arvo/app/launch.hoon

171 lines
4.4 KiB
Plaintext
Raw Normal View History

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]
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-05-05 20:10:58 +03:00
=| [%4 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)
%+ turn `(list term)`[%chat %publish %links %weather %clock %dojo ~]
|= =term
:- term
2020-05-20 22:12:53 +03:00
^- tile:store
?+ term [[%custom ~] %.y]
%chat [[%basic 'Chat' '/~landscape/img/Chat.png' '/~chat'] %.y]
2020-05-26 23:43:27 +03:00
%links [[%basic 'Links' '/~landscape/img/Links.png' '/~link'] %.y]
%dojo [[%basic 'Dojo' '/~landscape/img/Dojo.png' '/~dojo'] %.y]
%publish
[[%basic 'Publish' '/~landscape/img/Publish.png' '/~publish'] %.y]
==
tile-ordering [%chat %publish %links %weather %clock %dojo ~]
==
[~ this(state [%4 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-05-05 20:10:58 +03:00
?: ?=(%4 -.old-state)
[~ this(state old-state)]
=/ new-state *state-zero
=. new-state
%_ new-state
tiles
2020-05-20 22:12:53 +03:00
%- ~(gas by *tiles:store)
%+ turn `(list term)`[%chat %publish %links %weather %clock %dojo ~]
|= =term
:- term
2020-05-20 22:12:53 +03:00
^- tile:store
?+ term [[%custom ~] %.y]
%chat [[%basic 'Chat' '/~landscape/img/Chat.png' '/~chat'] %.y]
2020-05-26 23:43:27 +03:00
%links [[%basic 'Links' '/~landscape/img/Links.png' '/~link'] %.y]
%dojo [[%basic 'Dojo' '/~landscape/img/Dojo.png' '/~dojo'] %.y]
%publish
[[%basic 'Publish' '/~landscape/img/Publish.png' '/~publish'] %.y]
==
tile-ordering [%chat %publish %links %weather %clock %dojo ~]
==
:_ this(state [%4 new-state])
:- [%pass / %arvo %e %disconnect [~ /]]
%+ 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))
?+ path (on-peek:def path)
[%x %keys ~] ``noun+!>(~(key by tiles))
==
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
--