public ActiveLobbyUI(ShuffUIManager shuffUIManager, PageHandler pageHandler, RoomData room) { pageHandler.ClientSiteManager.OnGetRoomInfoReceived += GetRoomInfo; pageHandler.ClientChatManager.OnGetChatLines += GetChatLines; pageHandler.ClientChatManager.OnGetChatInfo += GetChatInfo; myShuffUIManager = shuffUIManager; myPageHandler = pageHandler; myRoom = room; UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() { Title = string.Format("{0} Lobby", myRoom.RoomName), X = 250, Y = 100, Width = 800, Height = 600, AllowClose = true, AllowMinimize = true, Visible = true }); UIWindow.OnClose += () => { UIWindow.Visible = true; UIWindow.SwingAway(SwingDirection.BottomRight); pageHandler.ClientSiteManager.LeaveRoom(new LeaveRoomRequest(room)); pageHandler.HomeUI.UIWindow.SwingBack(); }; UIWindow.SwingAway(SwingDirection.BottomRight, true); myRoomPlayers = UIWindow.AddElement(new ShuffListBox(600, 200, 175, 300) {Visible = true}); UIWindow.AddElement(new ShuffButton(600, 510, 175, 23, "Start Game!", (a) => { pageHandler.GameManager.StartGame( ); UIWindow.Height = 200; })); myChatBox = UIWindow.AddElement(new ChatBox(50, 50, 550, 500) {Visible = true}); myChatText = UIWindow.AddElement(new ShuffTextbox(50, 560, 500, 30, "", "") { OnEnter = () => { if (myChatText.Text.Trim() == string.Empty) return; pageHandler.ClientChatManager.SendChatMessage(new SendChatMessageModel(myChatText.Text)); myChatText.Text = ""; } }); UIWindow.AddElement(new ShuffButton(560, 560, 50, 30, "Send", (e) => { if (myChatText.Text.Trim() == string.Empty) return; pageHandler.ClientChatManager.SendChatMessage(new SendChatMessageModel(myChatText.Text)); myChatText.Text = ""; })); UIWindow.SwingBack(); PopulateGameRoom(room); }
public HomeUI(ShuffUIManager shuffUIManager, PageHandler pageHandler) { myShuffUIManager = shuffUIManager; myPageHandler = pageHandler; pageHandler.ClientSiteManager.OnGetGameTypesReceived += PopulateGames; pageHandler.ClientSiteManager.OnGetRoomsReceived += PopulateRooms; pageHandler.ClientSiteManager.OnRoomJoined += RoomJoined; pageHandler.ClientSiteManager.OnGetRoomInfoReceived += GetRoomInfo; UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() { Title = "CardGame", X = 400, Y = 100, Width = 600, Height = 450, AllowClose = true, AllowMinimize = true, Visible = false }); lblHeader = UIWindow.AddElement(new ShuffLabel(40, 44, "Please Login!")); UIWindow.AddElement(new ShuffLabel(30, 80, "Game Types")); myGameTypeList = UIWindow.AddElement(new ShuffListBox(25, 100, 150, 300) { OnClick = (item) => { myPageHandler.ClientSiteManager.GetRooms(new GetRoomsRequest((string) item.Value)); } }); myCreateGameType = UIWindow.AddElement(new ShuffButton(45, 410, 100, 40, "Create New Game!", c => { CodeEditorUI ui = new CodeEditorUI(shuffUIManager, pageHandler); })); UIWindow.AddElement(new ShuffLabel(210, 80, "Rooms")); myCreateRoom = UIWindow.AddElement(new ShuffButton(260, 70, 70, 25, "Refresh!", c => { myPageHandler.ClientSiteManager.GetRooms(new GetRoomsRequest((string) myGameTypeList.SelectedItem.Value)); })); myRoomsList = UIWindow.AddElement(new ShuffListBox(200, 100, 175, 300) { OnClick = (item) => { var room = myLoadedRooms.First(a => a.RoomName == (string) item.Value); PopulateRoom(room); } }); myCreateRoom = UIWindow.AddElement(new ShuffButton(225, 410, 100, 40, "Create New Room!", c => { var create = new CreateRoomUI(shuffUIManager, pageHandler, (string) myGameTypeList.SelectedItem.Value); shuffUIManager.Focus(create.UIWindow); })); myRoomPlayers = UIWindow.AddElement(new ShuffListBox(400, 200, 175, 200) {Visible = false}); myRoomGameType = UIWindow.AddElement(new ShuffLabel(400, 100, "") {Visible = false}); myRoomName = UIWindow.AddElement(new ShuffLabel(400, 130, "") {Visible = false}); myJoinRoom = UIWindow.AddElement(new ShuffButton(410, 160, 75, 25, "Join!", c => { pageHandler.ClientSiteManager.JoinRoom(new RoomJoinRequest((string) myGameTypeList.SelectedItem.Value, (string) myRoomsList.SelectedItem.Value)); }) {Visible = false}); mySpectateRoom = UIWindow.AddElement(new ShuffButton(490, 160, 75, 25, "Spectate!", c => { }) {Visible = false}); myRefreshRoom = UIWindow.AddElement(new ShuffButton(420, 410, 150, 25, "Refresh!", c => { pageHandler.ClientSiteManager.GetRoomInfo(new GetRoomInfoRequest((string) myGameTypeList.SelectedItem.Value, (string) myRoomsList.SelectedItem.Value)); }) {Visible = false}); //UIWindow.AddElement(new ShuffButton(280, 54, 150, 25, "Update game list", (e) => { pageHandler.ClientSiteManager.GetGameList(); })); }