コード例 #1
0
 public void OnUserInput(GamesPanel.UserInput inp)
 {
     if (inp == GamesPanel.UserInput.START_EXIT)
     {
         isExiting    = true;
         timeExiting  = 0f;
         willExitSoon = false;
     }
     if (inp == GamesPanel.UserInput.STOP_EXIT)
     {
         isExiting   = false;
         timeExiting = 0f;
     }
 }
コード例 #2
0
        public override void OnUserInput(GamesPanel.UserInput inp, Vector2 pointerPos)
        {
            //((mousepos / screenheight - screen.center) / motionparent.zoom ) + MotionParent.zoomcenter
            Vector2 panelPos = (((pointerPos / Screen.HeightPixels) - Screen.Center) / Motion.Zoom) + Motion.ZoomCenter;

            Vector2 gridPos = new Vector2(panelPos.X / PANEL_DELTA_GRID_X, panelPos.Y / PANEL_DELTA_GRID_Y) + PanelShiftPos;

            TTutil.Round(ref gridPos);
            //cursor.Motion.TargetPos = (cursor.GridPosition - PanelShiftPos) * new Vector2(PANEL_DELTA_GRID_X, PANEL_DELTA_GRID_Y);
            //cursor.Motion.TargetPos = panelPos;

            if (gridPos.Equals(cursor.GridPosition))
            {
                OnUserInput(GamesPanel.UserInput.START_SELECT);
            }

            cursor.GridPosition = gridPos;

            SelectGameBelowCursor();
        }
コード例 #3
0
        public override void OnUserInput(GamesPanel.UserInput inp)
        {
            // HACK: for web games launch, make sure that music is turned back on upon next user input after play
            if (!isGameLaunchOngoing &&
                !GardenGame.Instance.music.IsFadedIn &&
                GardenGame.Instance.music.UserWantsMusic)
            {
                GardenGame.Instance.music.FadeIn();
            }

            switch (inp)
            {
            case UserInput.DOWN:
                if (cursor.GridPosition.Y < GridMaxY - 1)
                {
                    cursor.GridPosition.Y += 1f;
                    SelectGameBelowCursor();
                }
                break;

            case UserInput.UP:
                if (cursor.GridPosition.Y > 0)
                {
                    cursor.GridPosition.Y -= 1f;
                    SelectGameBelowCursor();
                }
                break;

            case UserInput.LEFT:
                if (cursor.GridPosition.X > 0)
                {
                    cursor.GridPosition.X -= 1f;
                    SelectGameBelowCursor();
                }
                break;

            case UserInput.RIGHT:
                if (cursor.GridPosition.X < GridMaxX - 1)
                {
                    cursor.GridPosition.X += 1f;
                    SelectGameBelowCursor();
                }
                break;

            case UserInput.START_EXIT:
                isExiting = true;
                //selectionLevel = 0;
                Motion.ZoomTarget               = PANEL_ZOOM_TARGET_QUITTING;
                Motion.ZoomSpeed                = PANEL_ZOOM_SPEED_REGULAR;
                infoBox.Motion.TargetPos        = INFOBOX_ALL_HIDDEN_POSITION;
                creditsBitmap.Motion.TargetPos  = CREDITS_HIDDEN_POSITION;
                helpTextBitmap.Motion.TargetPos = HELPTEXT_HIDDEN_POSITION;
                //Motion.ZoomCenter = cursor.Motion.PositionAbs;
                //Motion.ZoomCenterTarget = cursor.Motion;
                break;

            case UserInput.STOP_EXIT:
                if (timeExiting < TIME_BEFORE_EXIT_CONTINUES)
                {
                    isExiting         = false;
                    selectionLevel    = 0;
                    Motion.ZoomTarget = PANEL_ZOOM_REGULAR;
                    Motion.ZoomSpeed  = PANEL_ZOOM_SPEED_ABORTQUITTING;
                    //Motion.ZoomCenter = cursor.Motion.PositionAbs;
                    //Motion.ZoomCenterTarget = cursor.Motion;
                }
                break;

            case UserInput.START_SELECT:
                if (SelectedGame != null)
                {
                    GameThumbnail th = null;
                    try
                    {
                        th = thumbnailsCache[SelectedGame.GameID];
                    }
                    catch (Exception) {; }
                    if (th != null)
                    {
                        switch (selectionLevel)
                        {
                        case 0:
                            // select once - zoom in on selected game
                            Motion.ZoomTarget       = PANEL_ZOOM_DETAILED_VIEW;
                            Motion.ZoomSpeed        = PANEL_ZOOM_SPEED_REGULAR;  // 0.01f;
                            Motion.ZoomCenterTarget = cursor.Motion;
                            SelectedGame.Refresh();
                            selectionLevel++;
                            break;

                        case 1:
                            // select again - install or launch game if selection key pressed long enough.
                            isGameLaunchOngoing = true;
                            break;
                        }
                    }
                }
                break;

            case UserInput.STOP_SELECT:
                // if not launched long enough, reset - no action
                if (timeLaunching < TIME_BEFORE_GAME_LAUNCH)
                {
                    isGameLaunchConfirmed = false;
                }
                else
                {
                    isGameLaunchConfirmed = true;
                }
                isGameLaunchOngoing = false;
                timeLaunching       = 0f;
                break;

            case UserInput.LAUNCH_WEBSITE:
                isLaunchWebsite = true;
                break;

            case UserInput.TOGGLE_MUSIC:
                GardenGame.Instance.music.ToggleMusic();
                break;
            } // switch(inp)

            if (!isExiting)
            {
                if (selectionLevel == 0)
                {
                    infoBox.Motion.TargetPos = INFOBOX_DESCRIPTION_HIDDEN_POSITION;
                }

                if (selectionLevel == 1 && SelectedGame != null)
                {
                    int lnCount = SelectedGame.DescriptionLineCount;
                    infoBox.Motion.TargetPos = INFOBOX_SHOWN_POSITION - new Vector2(0f, 0.015f + 0.029f * (lnCount - 1));
                }

                if (SelectedGame == null || SelectedGame.Name.Length == 0)
                {
                    infoBox.Motion.TargetPos = INFOBOX_ALL_HIDDEN_POSITION;
                }
            }
        }
コード例 #4
0
 /// <summary>
 /// user input in selecting items on screen is directed to this method
 /// </summary>
 /// <param name="inp">category of user input from the enum</param>
 /// <param name="pointerPos">pointer position input by user</param>
 public abstract void OnUserInput(GamesPanel.UserInput inp, Vector2 pointerPos);