Example #1
0
            public override void Update()
            {
                shared.timer.Update();

                // Keep Kodu animating even if a dialog is active.
                shared.boku.UpdateFace();
                shared.boku.UpdateAnimations();

                if (AuthUI.IsModalActive)
                {
                    return;
                }

                if (parent.newWorldDialog.Active)
                {
                    parent.newWorldDialog.Update();
                    return;
                }

                // If not modal, always show status.
                AuthUI.ShowStatusDialog();

                // Update the dialogs.
                parent.prevSessionCrashedMessage.Update();
                parent.noCommunityMessage.Update();
                parent.noSharingMessage.Update();

                // Don't do anything else until the user reads and dismisses the dialogs.
                if (parent.prevSessionCrashedMessage.Active ||
                    parent.exitingKodu)
                {
                    return;
                }

                // Update the options menu.  Do this first so that if it is active it can steal input.
                shared.optionsMenu.Update();

                // Main menu should always be active.
                shared.menu.Active = true;

                // If OptionsMenu is active, don't look at input.  This is a problem for touch input
                // which doesn't support any kind of "ClearAllWasPressedState" functionality.
                if (!shared.optionsMenu.Active)
                {
                    // Check for click on signOut tile or url.
                    if (MouseInput.Left.WasPressed || Actions.Select.WasPressed || TouchInput.WasTouched)
                    {
                        TouchContact touch = TouchInput.GetOldestTouch();
                        if (touch != null)
                        {
                            touch.position = ScreenWarp.ScreenToRT(touch.position);
                        }
                        Vector2 mouseHit = MouseInput.GetMouseInRtCoords();

                        // url is in rt coords.
                        if (shared.urlBox.Contains(mouseHit) ||
                            (null != touch && shared.urlBox.Contains(touch.position)))
                        {
#if NETFX_CORE
                            Launcher.LaunchUriAsync(new Uri(KoduGameLabUrl));
#else
                            Process.Start(KoduGameLabUrl);
#endif
                            MouseInput.Left.ClearAllWasPressedState();
                        }
                    }

                    // Enable resume option if we have something to resume to.
                    if (InGame.UnDoStack.HaveResume() && (shared.menu.Item(0) != Strings.Localize("mainMenu.resume")))
                    {
                        shared.menu.InsertText(Strings.Localize("mainMenu.resume"), 0);
                    }

                    shared.liveFeed.UpdateFeed();
                    shared.liveFeed.Update(shared.camera);

                    if (!UpdateNonMenuItems())
                    {
                        // JW - Only update the menu and process input if the interactive non-menu
                        // items didn't already handle the input.
                        int curIndex = shared.menu.CurIndex;
                        shared.menu.Update(shared.camera, ref shared.worldMatrix);
                        int newIndex = shared.menu.CurIndex;

                        // If the user made a menu change, have boku glance over.
                        if (curIndex != newIndex)
                        {
                            shared.boku.DirectGaze(new Vector3(0.2f, -0.4f, 0.08f - 0.05f * newIndex), 0.5f);
                        }
                    }
                }

                if (Actions.MiniHub.WasPressed && InGame.XmlWorldData != null)
                {
                    parent.Deactivate();
                    InGame.inGame.SwitchToMiniHub();
                    return;
                }

#if IMPORT_DEBUG
                if (!string.IsNullOrEmpty(StartupWorldFilename))
                {
                    LevelPackage.DebugPrint("MainMenu");
                    LevelPackage.DebugPrint("    StartupWorldFilename : " + StartupWorldFilename);
                }
#endif
                // Jump into the startup world, if it was specified.
                if (!String.IsNullOrEmpty(StartupWorldFilename))
                {
                    if (Storage4.FileExists(StartupWorldFilename, StorageSource.All))
                    {
#if IMPORT_DEBUG
                        LevelPackage.DebugPrint("    level exists, trying to load and run");
#endif
                        if (BokuGame.bokuGame.inGame.LoadLevelAndRun(StartupWorldFilename, keepPersistentScores: false, newWorld: false, andRun: true))
                        {
#if IMPORT_DEBUG
                            LevelPackage.DebugPrint("    success on load and run");
#endif
                            parent.Deactivate();
                        }
#if IMPORT_DEBUG
                        else
                        {
                            LevelPackage.DebugPrint("    fail to load and run");
                        }
#endif
                        shared.waitingForStorage = false;
                    }
#if IMPORT_DEBUG
                    else
                    {
                        LevelPackage.DebugPrint("    level not found");
                    }
#endif

                    StartupWorldFilename = null;
                }

                // Set news feed state to opposite of options menu.  This allows the
                // News Feed to "hide" when the Options Menu is active.
                if (shared.optionsMenu.Active)
                {
                    shared.liveFeed.Deactivate();
                }
                else
                {
                    shared.liveFeed.Activate();
                    shared.liveFeed.UpdateFeed();
                }
            }   // end of Update()
Example #2
0
        /// <summary>
        /// Return whether a file exists in either title or user space.
        /// Looks in user space first.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static bool FileExists(string filePath, StorageSource sources)
        {
            bool result = false;

            try
            {
                if (!string.IsNullOrEmpty(filePath))
                {
                    // Test user space first.
                    if ((sources & StorageSource.UserSpace) != 0)
                    {
                        string fullPath = Path.Combine(UserLocation, filePath);
                        result = File.Exists(fullPath);
                    }

                    // If not found, try title space.
                    if (result == false && (sources & StorageSource.TitleSpace) != 0)
                    {
                        string fullPath = Path.Combine(TitleLocation, filePath);
                        result = File.Exists(fullPath);
                    }
                }
            }
            catch (Exception e)
            {
                string str = e.Message;
                if (e.InnerException != null)
                {
                    str += e.InnerException.Message;
                }
                Debug.Assert(false, str);

#if IMPORT_DEBUG
                LevelPackage.DebugPrint("FileExists threw an error");
                LevelPackage.DebugPrint(e.ToString());
#endif
            }

#if IMPORT_DEBUG
            if (result == false)
            {
                LevelPackage.DebugPrint("FileExists cant't find : " + filePath);
                LevelPackage.DebugPrint("    UserLocation : " + UserLocation);
                LevelPackage.DebugPrint("    TitleLocation : " + TitleLocation);

                string   dirPath = Path.GetDirectoryName(filePath);
                string[] files   = GetFiles(dirPath, sources);
                LevelPackage.DebugPrint("==Files in : " + dirPath);
                if (files == null || files.Length == 0)
                {
                    LevelPackage.DebugPrint("    none");
                }
                else
                {
                    foreach (string file in files)
                    {
                        LevelPackage.DebugPrint("    " + file);
                    }
                }
            }
#endif

            return(result);
        }   // end of FileExists()