Esempio n. 1
0
        public QuestionUI(ShuffUIManager shuffUIManager, PageHandler pageHandler)
        {
            PageHandler = pageHandler;
            UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() {
                                                                             Title = "Question",
                                                                             X = 600,
                                                                             Y = 100,
                                                                             Width = 300,
                                                                             Height = 275,
                                                                             AllowClose = true,
                                                                             AllowMinimize = true,
                                                                             Visible = true
                                                                     });
            UIWindow.SwingAway(SwingDirection.TopLeft,true);

            Question = UIWindow.AddElement(new ShuffLabel(20, 40, ""));

            Load = (question) => {
                UIWindow.SwingBack();

                       Question.Text = ( question.Question );
                       AnswerBox.ClearItems();

                       for (var i = 0; i < question.Answers.Length; i++) {
                           AnswerBox.AddItem(new ShuffListItem(question.Answers[i], i));
                       }

                   };
            ExtensionMethods.debugger();

            AnswerBox = UIWindow.AddElement(new ShuffListBox(30, 65, 215, 25 * 5) {
                                                                                          OnClick = e => selectAnswer( e)
                                                                                  });
        }
Esempio n. 2
0
        public PageHandler(string gatewayServerAddress)
        {
            shuffUIManager = new ShuffUIManager();

            gameDrawer = new GameDrawer();
            TimeTracker = new TimeTracker();

            var gateway = new Gateway(gatewayServerAddress,false);
            ClientGameManager = new ClientGameManager(gateway);
            ClientSiteManager = new ClientSiteManager(gateway);
            ClientDebugManager = new ClientDebugManager(gateway);
            ClientChatManager = new ClientChatManager(gateway);

            ClientInfo = new ClientInformation();
            this.GameManager = new GameManager(this);

            LoginUI = new LoginUI(shuffUIManager, this);
            HomeUI = new HomeUI(shuffUIManager, this);
            QuestionUI = new QuestionUI(shuffUIManager, this);

            /*gateway.On("Area.Lobby.ListCardGames.Response", (data) => { });
            gateway.On("Area.Lobby.ListRooms.Response", (data) => { Logger.Log });*/

            //ie8
            /*   {
                   dynamic d2 = (Action<string, ElementEventHandler>)Document.Body.AttachEvent;

                   var m = (Action<string, ElementEventHandler>)d2;
                   m("contextmenu", () =>
                       {

                       });
               }*/
        }
Esempio n. 3
0
        public LoginUI(ShuffUIManager shuffUIManager, PageHandler pageHandler)
        {
            UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() {
                                                                             Title = "Login",
                                                                             X = jQuery.Select("body").GetInnerWidth() - 500,
                                                                             Y = 100,
                                                                             Width = 280,
                                                                             Height = 165,
                                                                             AllowClose = true,
                                                                             AllowMinimize = true,
                                                                             Visible = true
                                                                     });

            ShuffTextbox loginName;
            ShuffTextbox password;
            UIWindow.AddElement(loginName = new ShuffTextbox(115, 40, 150, 30, "", "Username"));
            UIWindow.AddElement(password = new ShuffTextbox(115, 75, 150, 30, "", "Password"));

            UIWindow.AddElement(new ShuffButton(55, 150, 90, 30, "Create", (e) => { pageHandler.ClientSiteManager.Login(loginName.Text, password.Text); }));
            UIWindow.AddElement(new ShuffButton(155, 150, 90, 30, "Login", (e) => { pageHandler.ClientSiteManager.Login(loginName.Text, password.Text); }));

            pageHandler.ClientSiteManager.OnLogin += (user, data) => {
                                                         pageHandler.ClientInfo.LoggedInUser = user;
                                                         pageHandler.HomeUI.UserLoggedIn();
                                                         UIWindow.SwingAway(SwingDirection.Left);
                                                     };
        }
Esempio n. 4
0
        public CreateRoomUI(ShuffUIManager shuffUIManager, PageHandler pageHandler, string gameType)
        {
            UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() {
                                                                             Title = "Create Room",
                                                                             X = jQuery.Select("body").GetInnerWidth() / 2 - 280 / 2,
                                                                             Y = jQuery.Select("body").GetInnerHeight() / 2 - 125 / 2,
                                                                             Width = 280,
                                                                             Height = 125,
                                                                             AllowClose = true,
                                                                             AllowMinimize = true,
                                                                             Visible = true
                                                                     });
            UIWindow.SwingAway(SwingDirection.BottomLeft, true);
            UIWindow.SwingBack();

            ShuffTextbox roomName = null;
            UIWindow.AddElement(roomName = new ShuffTextbox(115, 40, 150, 30, "", "Room Name") {OnEnter = () => { createRoom(pageHandler, gameType, roomName); }});

            UIWindow.AddElement(new ShuffButton(55,
                                                100,
                                                90,
                                                30,
                                                "Create",
                                                (e) => { createRoom(pageHandler, gameType, roomName); }));
            roomName.Focus();
        }
Esempio n. 5
0
        public CodeEditorUI(ShuffUIManager shuffUIManager, PageHandler pageHandler)
        {
            ShuffUIManager = shuffUIManager;
            breakPoints = new List<int>();

            codeEditor = UIWindow.AddElement(new ShuffCodeEditor(0, 0, "100%", "80%", "") {Dock = DockStyle.FillWidth});

            console = UIWindow.AddElement(new ShuffCodeEditor(0, 0, "100%", "20%", "") {LineNumbers = false, Dock = DockStyle.FillWidth});

            pageHandler.ClientDebugManager.OnGetGameSource += populateGameSource;
            pageHandler.ClientDebugManager.RequestGameSource(new GameSourceRequestModel("Sevens"));
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        public DebugUI(ShuffUIManager shuffUIManager, PageHandler pageHandler)
        {
            UIWindow = shuffUIManager.CreateWindow(new ShuffWindow() {
                                                                             Title = "Developer",
                                                                             X = 500, //jQuery.Select("body").GetInnerWidth() -
                                                                             Y = 100,
                                                                             Width = 420,
                                                                             Height = 450,
                                                                             AllowClose = true,
                                                                             AllowMinimize = true,
                                                                             Visible = false
                                                                     });

            ShuffButton but = null;
            UIWindow.AddElement(but = new ShuffButton(280,
                                                      84,
                                                      150,
                                                      25,
                                                      new Func<string>(() => "Game: " + selectedGame),
                                                      (e) => {
                                                          if (selectedGame == "Sevens") selectedGame = "BlackJack";
                                                          else selectedGame = "Sevens";

                                                          pageHandler.ClientDebugManager.RequestGameSource(new GameSourceRequestModel(selectedGame));

                                                          string m = but.Text;
                                                      }
                                              ));

            lblHowFast = UIWindow.AddElement(new ShuffLabel(280 - 200, 80, "Time Taken:"));
            lblAnother = UIWindow.AddElement(new ShuffLabel(280 - 200, 100, "Another: "));

            /* devArea.AddButton(new ShuffButton()
             {
                 X = 280,
                 Y = 94,
                 Width = "150",
                 Height = "25",
                 Text = "Continue",
                 Click = (evt) =>
                 {
                     pageHandler.gateway.Emit("Area.Debug.Continue", new { }, devArea.Data.gameServer); //NO EMIT"ING OUTSIDE OF PageHandler
                 }
             });*/

            varText = UIWindow.AddElement(new ShuffTextbox(150, 134, 100, 25, "Var Lookup"));
            /*  devArea.AddButton(new ShuffButton()
              {
                  X = 280,
                  Y = 134,
                  Width = "150",
                  Height = "25",
                  Text = "Lookup",
                  Click = (evt) =>
                  {
                      pageHandler.gateway.Emit("Area.Debug.VariableLookup.Request", new { variableName = devArea.Data.varText.GetValue() }, devArea.Data.gameServer); //NO EMIT"ING OUTSIDE OF PageHandler
                  }
              });*/

            /*   devArea.AddButton(new ShuffButton()
               {
                   X = 280,
                   Y = 164,
                   Width = "150",
                   Height = "25",
                   Text = "Push New Source",
                   Click = (evt) =>
                   {
                       pageHandler.gateway.Emit("Area.Debug.PushNewSource", new { source = codeArea.Data.codeEditor.editor.GetValue(), breakPoints = codeArea.Data.breakPoints },
                           devArea.Data.gameServer); //NO EMIT"ING OUTSIDE OF PageHandler
                   }
               });*/

            txtNumOfPlayers = UIWindow.AddElement(new ShuffTextbox(130, 43, 130, 20, "6", "Number of players=", "font-size:13px"));
        }
Esempio n. 8
0
        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(); }));
        }