Last active
June 3, 2019 01:29
-
-
Save bryanedds/3481e73bcb257720daf651272edc864b to your computer and use it in GitHub Desktop.
Latest example of WIP Nelmish.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type [<NoComparison>] OmniModel = | |
{ Splash : Screen | |
Title : Screen | |
TitleGui : Layer | |
TitlePlay : Entity | |
TitleCredits : Entity | |
TitleExit : Entity | |
Credits : Screen | |
CreditsGui : Layer | |
CreditsBack : Entity | |
Battle : Screen | |
BattleGui : Layer | |
BattleBack : Entity } | |
type OmniCommand = | |
| PlayTitleSong | |
| PlaySplashSound | |
| FadeSong | |
| ShowTitle | |
| ShowCredits | |
| ShowBattle | |
| ExitGame | |
type Game with | |
member this.GetOmniModel world : OmniModel = this.Get Property? OmniModel world | |
member this.SetOmniModel (value : OmniModel) world = this.Set Property? OmniModel value world | |
member this.OmniModel = PropertyTag.make this Property? OmniModel this.GetOmniModel this.SetOmniModel | |
type OmniDispatcher () = | |
inherit GameDispatcher<OmniModel, unit, OmniCommand> (fun game -> game.OmniModel) | |
static member Properties = | |
[Define? OmniModel | |
{ Splash = Screen "Splash" | |
Title = Screen "Title" | |
TitleGui = Layer "Title/Gui" | |
TitlePlay = Entity "Title/Gui/Play" | |
TitleCredits = Entity "Title/Gui/Credits" | |
TitleExit = Entity "Title/Gui/Exit" | |
Credits = Screen "Credits" | |
CreditsGui = Layer "Credits/Gui" | |
CreditsBack = Entity "Credits/Gui/Back" | |
Battle = Screen "Battle" | |
BattleGui = Layer "Battle/Gui" | |
BattleBack = Entity "Battle/Gui/Back" }] | |
override this.Bindings (model, _, _) = | |
[model.Title.IncomingStartEvent ==>! PlayTitleSong | |
model.Title.OutgoingStartEvent ==>! FadeSong | |
model.TitleCredits.ClickEvent ==>! ShowCredits | |
model.TitlePlay.ClickEvent ==>! ShowBattle | |
model.TitleExit.ClickEvent ==>! ExitGame | |
model.CreditsBack.ClickEvent ==>! ShowTitle | |
model.Battle.OutgoingStartEvent ==>! FadeSong | |
model.BattleBack.ClickEvent ==>! ShowTitle | |
model.Splash.RegisterEvent ==>! PlaySplashSound] | |
override this.Update (_, model, _, _) = | |
just model | |
override this.Command (command, model, _, world) = | |
match command with | |
| PlayTitleSong -> World.playSong 0 (1.0f * Constants.Audio.MasterSongVolume) Assets.TitleSong world | |
| PlaySplashSound -> World.playSound 1.0f Assets.NuSplashSound world | |
| FadeSong -> World.fadeOutSong Constants.Audio.DefaultTimeToFadeOutSongMs world | |
| ShowTitle -> World.transitionScreen model.Title world | |
| ShowCredits -> World.transitionScreen model.Credits world | |
| ShowBattle -> World.transitionScreen model.Battle world | |
| ExitGame -> World.exit world | |
override this.View (model, _, _) = | |
[View.screen [] [] (Splash (Constants.OmniBlade.DissolveData, Constants.OmniBlade.SplashData, model.Title)) model.Splash | |
View.screenFromLayerFile Assets.TitleLayerFilePath (Dissolve Constants.OmniBlade.DissolveData) model.Title | |
View.screenFromLayerFile Assets.CreditsLayerFilePath (Dissolve Constants.OmniBlade.DissolveData) model.Credits | |
View.screenFromLayerFile<BattleDispatcher> Assets.BattleLayerFilePath (Dissolve Constants.OmniBlade.DissolveData) model.Battle] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment