public RejoinScreenController(AutoController scene) { this.scene = scene; ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages); messageText = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.RejoinText, messageText); Message backButtonPressed = new Message(); guiComps.Register((int)GUICompKeys.RejoinCancelButton, backButtonPressed); backButtonPressed.Subscribe(new SimpleListener(OnBackButtonPressed)); choices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen); screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnScreenEnter())); state = new StateMachine(0); state.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => RefreshText())); connHelper = scene.Game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper); scene.ActivatableList.Add(new ListenerJanitor <IListener <int> >( connHelper.Connection.EnterStateMessenger, new SimpleListener <int>((s) => OnConnectionChange()))); }
private void OnServerConnectionChange(int state) { if (state == (int)ServerConnectionState.None) { LobbyChoices choices = Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); choices.ModFolder = null; choices.OrderChoice = LobbyTurnOrderChoice.None; } }
private void CreateGame() { game = new ModdableChessGame(); game.LoadFirstScene(); this.gameObject.AddComponent <Mods.TOCLoader>(); db = game.Components.Get <GameDatabase>((int)ComponentKeys.GameDatabase); server = game.Components.Get <ServerInformation>((int)ComponentKeys.ServerInformation); local = game.Components.Get <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation); lobby = game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); }
public LobbyExitController(AutoController scene) { game = (ModdableChessGame)scene.Game; choices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); state = new StateMachine(0); state.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnStateChange())); readyStatus = scene.Components.GetOrRegister((int)ComponentKeys.LobbyReadyStatus, SubscribableBool.Create); readyStatus.Subscribe(new SimpleListener <bool>((v) => OnReadyStatusChange())); readyStatus.Value = false; notifyServerReady = scene.Game.Components.Get <Command <bool> >((int)ComponentKeys.LobbyReadyNoticeSendRequest); scene.ActivatableList.Add(new ListenerJanitor <IListener <LobbyExitState> >( scene.Game.Components.Get <IMessage <LobbyExitState> >((int)ComponentKeys.LobbyExitMessageReceived), new SimpleListener <LobbyExitState>(OnAllReadyReceived))); scene.Components.GetOrRegister <SubscribableObject <string> >((int)ComponentKeys.LobbyModSelected, SubscribableObject <string> .Create) .Subscribe(new SimpleListener <string>(OnModChange)); initStatus = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.LobbyInitStatus, StateMachine.Create); initStatus.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => OnInitStatusChange())); getModFolder = scene.Components.GetOrRegister <Query <string, string> >((int)ComponentKeys.GetCachedModFolder, Query <string, string> .Create); screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen); screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => { state.State = 0; readyStatus.Value = false; if (s == (int)LobbyScreen.HostGamePrefs || s == (int)LobbyScreen.ClientGamePrefs) { SendReadyStatus(); } })); }
public ModListController(AutoController scene) { statusSortOrder = new Dictionary <int, int>(); statusSortOrder[(int)ModNetworkStatus.Playable] = 0; statusSortOrder[(int)ModNetworkStatus.HostOutOfDate] = 1; statusSortOrder[(int)ModNetworkStatus.ClientOutOfDate] = 1; statusSortOrder[(int)ModNetworkStatus.OnlyHost] = 2; statusSortOrder[(int)ModNetworkStatus.OnlyClient] = 3; statusSortOrder[(int)ModNetworkStatus.Unknown] = 4; localMods = new List <LocalModInfo>(); networkMods = new List <NetworkModInfo>(); allMods = new List <ComboModInfo>(); showNotLocalMods = true; prevChoices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages); modButtons = new ModList(); guiComps.Register((int)GUICompKeys.ModList, modButtons); modButtons.OnButtonClick.Subscribe(new SimpleListener <int>(OnModButtonClick)); pickedLabelTop = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.ModListLabelTop, pickedLabelTop); pickedLabelBottom = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.ModListLabelBottom, pickedLabelBottom); pickedModTop = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.ModListPickedTop, pickedModTop); pickedModBottom = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.ModListPickedBottom, pickedModBottom); Message reloadBtnPressed = new Message(); guiComps.Register((int)GUICompKeys.ModListReloadBtnPress, reloadBtnPressed); reloadBtnPressed.Subscribe(new SimpleListener(OnReloadButton)); Message hideBtnPressed = new Message(); guiComps.Register((int)GUICompKeys.ModListHideBtnPress, hideBtnPressed); hideBtnPressed.Subscribe(new SimpleListener(OnHideButton)); reqSendNetworkModList = scene.Game.Components.Get <Command <List <LocalModInfo> > >((int)ComponentKeys.NetworkModListSendRequest); scene.ActivatableList.Add(new ListenerJanitor <IListener <List <NetworkModInfo> > >( scene.Game.Components.Get <Message <List <NetworkModInfo> > >((int)ComponentKeys.NetworkModListReceived), new SimpleListener <List <NetworkModInfo> >(OnNetworkModListReceived))); reqSendPickedMod = scene.Game.Components.Get <Command <bool, string> >((int)ComponentKeys.NetworkPickedModSendRequest); scene.ActivatableList.Add(new ListenerJanitor <IListener <bool, string> > ( scene.Game.Components.Get <Message <bool, string> >((int)ComponentKeys.NetworkPickedModReceived), new SimpleListener <bool, string>(OnNetworkPickedModReceived))); selectedModName = scene.Components.GetOrRegister((int)ComponentKeys.LobbyModSelected, SubscribableObject <string> .Create); modSearcher = scene.Components.GetOrRegister <Query <List <LocalModInfo>, string> > ((int)ComponentKeys.SearchModFolderRequest, Query <List <LocalModInfo>, string> .Create); localInfo = scene.Game.Components.Get <LocalPlayerInformation>((int)ComponentKeys.LocalPlayerInformation); initState = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.LobbyInitStatus, StateMachine.Create); initState.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => InitStatusChange())); scene.Components.GetOrRegister <Query <string, string> >((int)ComponentKeys.GetCachedModFolder, Query <string, string> .Create) .Handler = GetCachedModFolder; readyStatus = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.LobbyReadyStatus, SubscribableBool.Create); readyStatus.Subscribe(new SimpleListener <bool>((v) => OnReadyStatusChange())); screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen); screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => { switch ((LobbyScreen)s) { case LobbyScreen.ClientGamePrefs: case LobbyScreen.HostGamePrefs: OnEnterScreen(); break; } })); }
public TurnOrderSelectionController(AutoController scene) { tickHelper = new TickingJanitor(scene.Game, this); tickHelper.Active = false; ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages); btnsInteractable = guiComps.GetOrRegister <SubscribableBool>((int)GUICompKeys.TOSInteractable, SubscribableBool.Create); btnsInteractable.Value = true; toggleValues = new SubscribableBool[3]; toggleValues[0] = new SubscribableBool(false); guiComps.Register((int)GUICompKeys.TOSOpt1Set, toggleValues[0]); toggleValues[1] = new SubscribableBool(false); guiComps.Register((int)GUICompKeys.TOSOpt2Set, toggleValues[1]); toggleValues[2] = new SubscribableBool(false); guiComps.Register((int)GUICompKeys.TOSOpt3Set, toggleValues[2]); Message <bool>[] toggleChanges = new Message <bool> [3]; toggleChanges[0] = new Message <bool>(); guiComps.Register((int)GUICompKeys.TOSOpt1Change, toggleChanges[0]); toggleChanges[1] = new Message <bool>(); guiComps.Register((int)GUICompKeys.TOSOpt2Change, toggleChanges[1]); toggleChanges[2] = new Message <bool>(); guiComps.Register((int)GUICompKeys.TOSOpt3Change, toggleChanges[2]); for (int i = 0; i < toggleChanges.Length; i++) { int index = i; toggleChanges[i].Subscribe(new SimpleListener <bool>((v) => OnToggleChange(index, v))); } choiceBtnIndex = new Dictionary <LobbyTurnOrderChoice, int>(); choiceBtnIndex[LobbyTurnOrderChoice.HostIsFirst] = 0; choiceBtnIndex[LobbyTurnOrderChoice.ClientIsFirst] = 1; choiceBtnIndex[LobbyTurnOrderChoice.Random] = 2; choiceBtnIndex[LobbyTurnOrderChoice.None] = -1; otherSelLabel = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.TOSOtherSelectionLabel, otherSelLabel); otherSelValue = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.TOSOtherSelectionValue, otherSelValue); allowTogglesOff = new SubscribableBool(false); guiComps.Register((int)GUICompKeys.TOSAllowAllTogglesOff, allowTogglesOff); prevChoices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); selected = new SubscribableInt(0); //scene.SceneComponents.Register((int)ComponentKeys.LobbyTurnOrderSelected, selected); initStatus = scene.Components.GetOrRegister <StateMachine>((int)ComponentKeys.LobbyInitStatus, StateMachine.Create); initStatus.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => InitStatusChange())); reqSendPick = scene.Game.Components.Get <Command <LobbyTurnOrderChoice> >((int)ComponentKeys.LobbyTurnOrderChoiceNotify); scene.ActivatableList.Add(new ListenerJanitor <IListener <LobbyTurnOrderChoice> >( scene.Game.Components.Get <IMessage <LobbyTurnOrderChoice> >((int)ComponentKeys.LobbyTurnOrderChoiceReceived), new SimpleListener <LobbyTurnOrderChoice>(OnNetworkPickReceived))); readyStatus = scene.Components.GetOrRegister <SubscribableBool>((int)ComponentKeys.LobbyReadyStatus, SubscribableBool.Create); readyStatus.Subscribe(new SimpleListener <bool>((v) => OnReadyStatusChange())); screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen); screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => { isHost = s == (int)LobbyScreen.HostGamePrefs; if (s == (int)LobbyScreen.HostGamePrefs || s == (int)LobbyScreen.ClientGamePrefs) { ScreenEnter(); } })); }
//private int frame; public SetupHostScreenManager(AutoController scene) { state = State.Hidden; ComponentRegistry guiComps = scene.Components.Get <ComponentRegistry>((int)ComponentKeys.LobbyGUIMessages); guiComps.Register((int)GUICompKeys.BtnHostCancelPress, new Message()); guiComps.Register((int)GUICompKeys.BtnStartHostPress, new Message()); guiComps.Register((int)GUICompKeys.HostPortChange, new Message <string>()); guiComps.Register((int)GUICompKeys.ClientAddressChange, new Message <string>()); startBtnEnabled = new SubscribableBool(hasPort); guiComps.Register((int)GUICompKeys.BtnHostStartEnabledCommand, startBtnEnabled); setInputInteractable = new SubscribableBool(state != State.Connecting); guiComps.Register((int)GUICompKeys.HostStartInputInteractable, setInputInteractable); setPortField = new SubscribableObject <string>(port.ToString()); guiComps.Register((int)GUICompKeys.HostPortSetCommand, setPortField); setAddressField = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.ClientAddressTextField, setAddressField); setAddressInteractable = new SubscribableBool(false); guiComps.Register((int)GUICompKeys.HostAddressInteractable, setAddressInteractable); statusText = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.HostConnectionStatusLabel, statusText); titleText = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.StartGameTitleText, titleText); startButtonText = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.StartGameStartButtonText, startButtonText); guiComps.Get <Message <string> >((int)GUICompKeys.HostPortChange).Subscribe(new SimpleListener <string>(OnPortChange)); guiComps.Get <Message <string> >((int)GUICompKeys.ClientAddressChange).Subscribe(new SimpleListener <string>(OnAddressChange)); guiComps.Get <Message>((int)GUICompKeys.BtnHostCancelPress).Subscribe(new SimpleListener(OnCancelPress)); guiComps.Get <Message>((int)GUICompKeys.BtnStartHostPress).Subscribe(new SimpleListener(OnStartPress)); setPasswordField = new SubscribableObject <string>(""); guiComps.Register((int)GUICompKeys.PasswordTextSet, setPasswordField); Message <string> passwordChange = new Message <string>(); guiComps.Register((int)GUICompKeys.PasswordChange, passwordChange); passwordChange.Subscribe(new SimpleListener <string>(OnPasswordChange)); choices = scene.Game.Components.Get <LobbyChoices>((int)ComponentKeys.LobbyChoices); screen = scene.Components.Get <StateMachine>((int)ComponentKeys.LobbyScreen); netHelper = scene.Game.Components.Get <ConnectionHelper>((int)ComponentKeys.ConnectionHelper); scene.ActivatableList.Add(new ListenerJanitor <IListener <int> >( netHelper.Connection.EnterStateMessenger, new SimpleListener <int>(OnConnectionChange))); screen.EnterStateMessenger.Subscribe(new SimpleListener <int>((s) => { //BalugaDebug.Log("Entering screen " + (LobbyScreen)s); if (s == (int)LobbyScreen.SetupHost || s == (int)LobbyScreen.SetupClient) { state = State.Choosing; EnterScreen(); } else { state = State.Hidden; } })); }