Exemple #1
0
        /// <summary>
        /// Loads preview images by provided file paths
        /// </summary>
        /// <param name="files">File paths</param>
        private void LoadPreviewImages(string[] files)
        {
            if (files.Length == 0)
            {
                return;
            }

            foreach (string file in files)
            {
                FileInfo fileInfo = new FileInfo(file);

                if (!ResolutionUtility.CheckImageSize(fileInfo))
                {
                    continue;
                }

                // load image metadata to check width and height
                var bitmapFrame = BitmapFrame.Create(new Uri(file), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);
                if (bitmapFrame.PixelWidth < 1200 || bitmapFrame.PixelHeight < 1700)
                {
                    DialogManager.ShowImageSizeWarning();
                }

                var newItem = new ImagePreviewViewModel(file, Path.GetFileName(file), fileInfo.Length);
                newItem.ImageFileFormat = fileInfo.Extension;
                this.PreviewImages.Add(newItem);
            }

            this.InitialPreviewPanelVisibility = Visibility.Collapsed;
            this.SelectedPreviewImage          = this.PreviewImages.First();
        }
Exemple #2
0
    private void Refresh()
    {
        if (_rt == null)
        {
            return;
        }

        if (!IsResizeSourceChanged() && !_rrChanged)
        {
            return;
        }

        _lastRS = _rs;

        if (_rs == ResizeSource.ScreenSize)
        {
            _rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, Screen.safeArea.x, Screen.safeArea.width);
            _rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, Screen.safeArea.y, Screen.safeArea.height);
        }
        else if (_rs == ResizeSource.Customize)
        {
            Rect scaledSafeArea = ResolutionUtility.GetScaledSafeArea();
            _rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, scaledSafeArea.x, scaledSafeArea.width);
            _rt.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Bottom, scaledSafeArea.y, scaledSafeArea.height);
        }
    }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // Get the BitmapImage if possible
            var image = value as BitmapImage;

            if (image == null)
            {
                return(value);
            }

            // Get the image's source URI if possible
            Uri uri = image.UriSource;

            if (uri == null)
            {
                return(value);
            }

            uri = ResolutionUtility.GetUriWithResolutionSuffix(uri);

            if (targetType == typeof(ImageSource))
            {
                return(new BitmapImage(uri));
            }

            return(uri);
        }
Exemple #4
0
        /// <summary>
        /// Loads single preview image from specified path
        /// </summary>
        /// <param name="pathToImage"></param>
        private void LoadPreviewImage(string pathToImage)
        {
            FileInfo fileInfo = new FileInfo(pathToImage);

            if (!ResolutionUtility.CheckImageSize(fileInfo))
            {
                return;
            }

            // load image metadata to check width and height
            BitmapFrame bitmapFrame = BitmapFrame.Create(new Uri(pathToImage), BitmapCreateOptions.DelayCreation, BitmapCacheOption.None);

            if (bitmapFrame.PixelWidth < 1200 || bitmapFrame.PixelHeight < 1700)
            {
                DialogManager.ShowImageSizeWarning(fileInfo.Name);
            }

            var newItem = new ImagePreviewViewModel(pathToImage, Path.GetFileName(pathToImage), fileInfo.Length);

            newItem.ImageFileFormat = fileInfo.Extension;
            this.PreviewImages.Add(newItem);

            this.InitialPreviewPanelVisibility = Visibility.Collapsed;
            this.CurrentStage = ResultProcessingStages.GotImagesToRecognize;
        }
        /// <summary>
        /// Loads template image located by specified path
        /// </summary>
        /// <param name="path">Path to image</param>
        private void LoadTemplateImageFromFile(string path)
        {
            double monitorWidth, monitorHeight;

            ResolutionUtility.GetMonitorResolution(out monitorWidth, out monitorHeight);

            FileInfo fileInfo = new FileInfo(path);

            this.ImageSizeInBytes  = fileInfo.Length;
            this.TemplateImageName = fileInfo.Name;
            this.ImageFileFormat   = fileInfo.Extension;

            if (!ResolutionUtility.CheckImageSize(fileInfo))
            {
                return;
            }

            this.TemplateImage = new BitmapImage(new Uri("file://" + path));

            if (this.TemplateImage.PixelWidth < 1200 || this.TemplateImage.PixelHeight < 1700)
            {
                DialogManager.ShowImageSizeWarning();
            }

            ZoomKoefficient = monitorWidth / this.TemplateImage.PixelWidth < 1
                ? monitorWidth / this.TemplateImage.PixelWidth
                : 1;

            this.OnPropertyChanged(nameof(this.PageScale));
        }
 public virtual void Update()
 {
     try
     {
         ResolutionUtility.Update();
         RealTime.Update();
         LongEventHandler.LongEventsUpdate(out var sceneChanged);
         if (sceneChanged)
         {
             destroyed = true;
         }
         else if (!LongEventHandler.ShouldWaitForEvent)
         {
             Rand.EnsureStateStackEmpty();
             Widgets.EnsureMousePositionStackEmpty();
             SteamManager.Update();
             PortraitsCache.PortraitsCacheUpdate();
             AttackTargetsCache.AttackTargetsCacheStaticUpdate();
             Pawn_MeleeVerbs.PawnMeleeVerbsStaticUpdate();
             Storyteller.StorytellerStaticUpdate();
             CaravanInventoryUtility.CaravanInventoryUtilityStaticUpdate();
             uiRoot.UIRootUpdate();
             if (Time.frameCount > 3 && !prefsApplied)
             {
                 prefsApplied = true;
                 Prefs.Apply();
             }
             soundRoot.Update();
         }
     }
     catch (Exception arg)
     {
         Log.Error("Root level exception in Update(): " + arg);
     }
 }
Exemple #7
0
        protected internal virtual string GetAlbumArtURI(int width, int height)
        {
            width  = ResolutionUtility.GetScaledPixels(width);
            height = ResolutionUtility.GetScaledPixels(height);
            string uri = "{0}/databases/{1}/containers/{2}/extra_data/artwork?mw={3}&mh={4}&session-id={5}";

            return(string.Format(uri, Server.HTTPPrefix, Database.ID, ID, width, height, Server.SessionID));
        }
Exemple #8
0
        /// <summary>
        /// Converts template data model to template view model
        /// </summary>
        /// <param name="template">OmrTemplate to convert</param>
        /// <returns>Resulting TemplateViewModel</returns>
        public static TemplateViewModel ConvertModelToViewModel(OmrTemplate template)
        {
            TemplateViewModel templateViewModel = new TemplateViewModel("Loaded template");

            templateViewModel.TemplateId           = template.TemplateId;
            templateViewModel.FinalizationComplete = template.FinalizationComplete;

            OmrPage page = template.Pages[0];

            templateViewModel.TemplateImageName = page.ImageName;
            templateViewModel.ImageFileFormat   = page.ImageFormat;

            List <BaseQuestionViewModel> elements = new List <BaseQuestionViewModel>();

            foreach (OmrElement modelElement in page.Elements)
            {
                if (modelElement is ChoiceBoxElement)
                {
                    var choiceBoxViewModel = CreateChoiceBoxViewModel((ChoiceBoxElement)modelElement);
                    elements.Add(choiceBoxViewModel);
                }
                else if (modelElement is GridElement)
                {
                    var gridViewModel = CreateGridViewModel((GridElement)modelElement);
                    elements.Add(gridViewModel);
                }
            }

            templateViewModel.AddQuestions(elements);

            if (page.ImageData != null)
            {
                // loading from file
                double monitorWidth, monitorHeight;
                ResolutionUtility.GetMonitorResolution(out monitorWidth, out monitorHeight);

                var image = TemplateSerializer.DecompressImage(page.ImageData);

                templateViewModel.TemplateImage = image;
                templateViewModel.PageWidth     = page.Width;
                templateViewModel.PageHeight    = page.Height;

                TemplateViewModel.ZoomKoefficient = image.PixelWidth / page.Width < 1
                    ? image.PixelWidth / page.Width
                    : 1;
            }
            else
            {
                // processing server response
                templateViewModel.PageWidth  = page.Width;
                templateViewModel.PageHeight = page.Height;
            }

            return(templateViewModel);
        }
Exemple #9
0
        protected override void InitializeApplicationBar()
        {
            // Application Bar Icons
            AddAppBarNowPlayingButton();
            AddApplicationBarIconButton(LocalizedStrings.SearchAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Search.png"), () => NavigationManager.OpenSearchPage(CurrentDatabase));
            AddApplicationBarIconButton(LocalizedStrings.MoreAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Ellipsis.png"), AppBarMoreButton_Click);
#if WP8
            // Disabled for now
            //EnableAppleTVControlButton();
#endif
        }
Exemple #10
0
        protected void EnableAppleTVControlButton()
        {
            var button = new ApplicationBarIconButton();

            button.Text    = "Apple TV";
            button.IconUri = ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/AppleTVControl.png");
            button.Click  += (sender, e) => OpenAppleTVControlDialog();

            _appleTVControlButton = button;
            UpdateAppleTVControlButton();
        }
Exemple #11
0
 private void Revert()
 {
     if (Prefs.LogVerbose)
     {
         Log.Message("Reverting screen settings to " + oldRes.x + "x" + oldRes.z + ", fs=" + oldFullscreen);
     }
     ResolutionUtility.SetResolutionRaw(oldRes.x, oldRes.z, oldFullscreen);
     Prefs.FullScreen   = oldFullscreen;
     Prefs.ScreenWidth  = oldRes.x;
     Prefs.ScreenHeight = oldRes.z;
     Prefs.UIScale      = oldUIScale;
 }
Exemple #12
0
 public virtual void Update()
 {
     try
     {
         ResolutionUtility.Update();
         RealTime.Update();
         bool flag;
         LongEventHandler.LongEventsUpdate(out flag);
         if (flag)
         {
             this.destroyed = true;
         }
         else if (!LongEventHandler.ShouldWaitForEvent)
         {
             Rand.EnsureStateStackEmpty();
             Widgets.EnsureMousePositionStackEmpty();
             SteamManager.Update();
             PortraitsCache.PortraitsCacheUpdate();
             AttackTargetsCache.AttackTargetsCacheStaticUpdate();
             Pawn_MeleeVerbs.PawnMeleeVerbsStaticUpdate();
             Storyteller.StorytellerStaticUpdate();
             CaravanInventoryUtility.CaravanInventoryUtilityStaticUpdate();
             this.uiRoot.UIRootUpdate();
             if (Time.frameCount > 3 && !Root.prefsApplied)
             {
                 Root.prefsApplied = true;
                 Prefs.Apply();
             }
             this.soundRoot.Update();
             try
             {
                 MemoryTracker.Update();
             }
             catch (Exception arg)
             {
                 Log.Error("Error in MemoryTracker: " + arg, false);
             }
             try
             {
                 MapLeakTracker.Update();
             }
             catch (Exception arg2)
             {
                 Log.Error("Error in MapLeakTracker: " + arg2, false);
             }
         }
     }
     catch (Exception arg3)
     {
         Log.Error("Root level exception in Update(): " + arg3, false);
     }
 }
        public ChooseLibraryPage()
        {
            InitializeComponent();

            DisableConnectionStatusPopup = true;

            LayoutRoot.DataContext = ServerManager.PairedServers;

            ApplicationBar = new ApplicationBar();

            AddApplicationBarIconButton(LocalizedStrings.AddAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Add.png"), ShowPairingDialog);
            AddApplicationBarMenuItem(LocalizedStrings.ManualPairingMenuItem, ShowManualPairingDialog);
            AddApplicationBarMenuItem(LocalizedStrings.AboutMenuItem, NavigationManager.OpenAboutPage);
        }
        protected override void InitializeApplicationBar()
        {
            base.InitializeApplicationBar();

            ApplicationBar.Mode = ApplicationBarMode.Minimized;

            // Icon Buttons
            AddAppBarNowPlayingButton();
            AddApplicationBarIconButton(LocalizedStrings.BrowseLibraryAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Browse.png"), () => NavigationManager.OpenLibraryPage(CurrentServer.MainDatabase));
            AddApplicationBarIconButton(LocalizedStrings.SearchAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Search.png"), SearchAppBarButton_Click);
#if WP8
            // Disabled for now
            //EnableAppleTVControlButton();
#endif
        }
        private static void ReturnToEditorAction()
        {
            System.Windows.Forms.DialogResult dialogResult = System.Windows.Forms.MessageBox.Show("Reload map to state before playtesting?", "Reload map?", System.Windows.Forms.MessageBoxButtons.YesNo);
            if (dialogResult == System.Windows.Forms.DialogResult.Yes)
            {
                MapBuilder.ReloadMap();
            }
            else if (dialogResult == System.Windows.Forms.DialogResult.No)
            {
            }

            MapBuilder.bPlayTest = false;
            ResolutionUtility.AdjustResolution(Form1.editorRes.X, Form1.editorRes.Y, Game1.graphics);
            GameProcessor.bIsInGame = false;
        }
Exemple #16
0
        /// <summary>
        /// Updates images at main area according to selected preview image
        /// </summary>
        private void UpdateMainImage()
        {
            string path = this.SelectedPreviewImage.PathToImage;

            this.MainImage = new BitmapImage(new Uri("file://" + path));

            double monitorWidth, monitorHeight;

            ResolutionUtility.GetMonitorResolution(out monitorWidth, out monitorHeight);

            ZoomKoefficient = monitorWidth / this.MainImage.PixelWidth < 1
                ? monitorWidth / this.MainImage.PixelWidth
                : 1;

            this.OnPropertyChanged(nameof(this.PageScale));
        }
        static public void update(GameTime gameTime)
        {
            //     GUICursorPos = ResolutionUtility.mousePos / 1 - (new Vector2(0, 32)) * 1;
            //     cursorPos = ResolutionUtility.mousePos/1 -(new Vector2(0,32)+new Vector2(SceneUtility.xAxis,SceneUtility.yAxis))*1;

            trueCursorPos = new Vector2(CursorUtility.cursorShape.shapeHitBox[0].Location.X, CursorUtility.cursorShape.shapeHitBox[0].Location.Y + CursorUtility.cursorShape.shapeHitBox[0].Height);
            GUICursorPos  = ResolutionUtility.AdjustMousePosition(Game1.graphics, Mouse.GetState().Position.ToVector2());
            cursorPos     = ResolutionUtility.AdjustMousePosition(Game1.graphics, Mouse.GetState().Position.ToVector2()) - (new Vector2(0, 32) + new Vector2(SceneUtility.xAxis, SceneUtility.yAxis)) * 1;

            //This is for Editor ViewPort stuff
            trueCursorPos -= SceneUtility.EditorTransformTranslation;
            trueCursorPos /= SceneUtility.EditorTransformScale;

            cursorShape.position = ResolutionUtility.AdjustMousePosition(Game1.graphics, Mouse.GetState().Position.ToVector2()) - (new Vector2(0, 64)) - new Vector2(SceneUtility.xAxis, SceneUtility.yAxis);

            cursorShape.Update(gameTime);
        }
        public NowPlayingPage()
        {
            InitializeComponent();

            // Set up Application Bar
            InitializeApplicationBar();
            ApplicationBar.Mode = ApplicationBarMode.Minimized;
            //ApplicationBarMenuClosedOpacity = 0;
            ApplicationBar.BackgroundColor = (Color)Application.Current.Resources["PhoneBackgroundColor"];

            // Icon Buttons
            AddApplicationBarIconButton(LocalizedStrings.BrowseLibraryAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Browse.png"), () => NavigationManager.OpenLibraryPage(CurrentServer.MainDatabase));
            AddApplicationBarIconButton(LocalizedStrings.SearchAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/Search.png"), () => NavigationManager.OpenSearchPage(CurrentServer.MainDatabase));

            RebuildApplicationBarMenuItems();

            ManipulationStarted += Page_ManipulationStarted;
        }
        public static void Init()
        {
            bool num = !new FileInfo(GenFilePaths.PrefsFilePath).Exists;

            data = new PrefsData();
            data = DirectXmlLoader.ItemFromXmlFile <PrefsData>(GenFilePaths.PrefsFilePath);
            BackCompatibility.PrefsDataPostLoad(data);
            if (num)
            {
                data.langFolderName = LanguageDatabase.SystemLanguageFolderName();
                data.uiScale        = ResolutionUtility.GetRecommendedUIScale(data.screenWidth, data.screenHeight);
            }
            if (DevModePermanentlyDisabledUtility.Disabled)
            {
                DevMode = false;
            }
            Apply();
        }
Exemple #20
0
        protected internal virtual string GetAlbumArtURI(int width, int height)
        {
            width  = ResolutionUtility.GetScaledPixels(width);
            height = ResolutionUtility.GetScaledPixels(height);
            string uri = "{0}/databases/{1}/groups/{2}/extra_data/artwork?mw={3}&mh={4}&group-type={5}&session-id={6}";

            object groupID;

            if (Server.IsAppleTV)
            {
                groupID = PersistentID;
            }
            else
            {
                groupID = ID;
            }

            return(string.Format(uri, Server.HTTPPrefix, Database.ID, groupID, width, height, GroupType, Server.SessionID));
        }
Exemple #21
0
 private void Revert()
 {
     if (Prefs.LogVerbose)
     {
         Log.Message(string.Concat(new object[]
         {
             "Reverting screen settings to ",
             this.oldRes.x,
             "x",
             this.oldRes.z,
             ", fs=",
             this.oldFullscreen
         }), false);
     }
     ResolutionUtility.SetResolutionRaw(this.oldRes.x, this.oldRes.z, this.oldFullscreen);
     Prefs.FullScreen   = this.oldFullscreen;
     Prefs.ScreenWidth  = this.oldRes.x;
     Prefs.ScreenHeight = this.oldRes.z;
     Prefs.UIScale      = this.oldUIScale;
 }
Exemple #22
0
 public void Apply()
 {
     if (this.customCursorEnabled)
     {
         CustomCursor.Activate();
     }
     else
     {
         CustomCursor.Deactivate();
     }
     AudioListener.volume        = this.volumeGame;
     Application.runInBackground = this.runInBackground;
     if (this.screenWidth == 0 || this.screenHeight == 0)
     {
         ResolutionUtility.SetNativeResolutionRaw();
     }
     else
     {
         ResolutionUtility.SetResolutionRaw(this.screenWidth, this.screenHeight, this.fullscreen);
     }
 }
Exemple #23
0
    private void Refresh()
    {
        if (_cs == null)
        {
            return;
        }

        if (!IsResizeSourceChanged() && !IsScreenOrientationChanged() && !IsResolutionChanged())
        {
            return;
        }

        _lastRS         = _rs;
        _lastScreenOri  = Screen.orientation;
        _lastResolution = new Vector2(Screen.width, Screen.height);

        if (_rs == ResizeSource.ScreenSize)
        {
            _cs.referenceResolution = new Vector2(Screen.width, Screen.height);
            _cs.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            _cs.matchWidthOrHeight  = Screen.width > Screen.height ? 0 : 1;
        }
        else if (_rs == ResizeSource.Customize)
        {
            Vector2 resolution = ResolutionUtility.GetCustomizedReferenceResolution();
            float   match      = ResolutionUtility.GetMatchWidthOrHeight();

            _cs.referenceResolution = new Vector2(resolution.x, resolution.y);
            _cs.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            _cs.matchWidthOrHeight  = match;
        }

        if (onChanged != null)
        {
            onChanged();
        }
    }
Exemple #24
0
 public void Apply()
 {
     if (UnityData.IsInMainThread)
     {
         if (customCursorEnabled)
         {
             CustomCursor.Activate();
         }
         else
         {
             CustomCursor.Deactivate();
         }
         AudioListener.volume        = volumeGame;
         Application.runInBackground = runInBackground;
         if (screenWidth == 0 || screenHeight == 0)
         {
             ResolutionUtility.SetNativeResolutionRaw();
         }
         else
         {
             ResolutionUtility.SetResolutionRaw(screenWidth, screenHeight, fullscreen);
         }
     }
 }
Exemple #25
0
 protected void AddAppBarNowPlayingButton()
 {
     _nowPlayingButton = AddApplicationBarIconButton(LocalizedStrings.NowPlayingAppBarButton, ResolutionUtility.GetUriWithResolutionSuffix("/Assets/Icons/App.iTunes.png"), NavigationManager.OpenNowPlayingPage);
 }
        private void videoOptionHandle()
        {
            bDrawOptionsScreen = true;
            if ((buttonPressUtility.isPressed(Game1.confirmString) || (Game1.bIsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.bMousePressed && Game1.graphics.GraphicsDevice.Viewport.Bounds.Contains(CursorUtility.trueCursorPos))))
            {
                switch ((int)cursorPosition.X)
                {
                case 8:
                    ResolutionUtility.toggleFullscreen();
                    bSubMenu         = false;
                    cursorPosition.X = 0;
                    cursorPosition.Y = 0;
                    break;
                }
            }
            if (SceneUtility.prevScene != 5)
            {
                bDrawOptionsScreen = true;
                if ((buttonPressUtility.isPressed(Game1.confirmString) || (Game1.bIsActive && Mouse.GetState().LeftButton == ButtonState.Pressed && !KeyboardMouseUtility.bMousePressed)))
                {
                    switch ((int)cursorPosition.X)
                    {
                    case 1:
                        ResolutionUtility.AdjustResolution(1024, 768, Game1.graphics);
                        break;

                    case 2:
                        ResolutionUtility.AdjustResolution(1280, 800, Game1.graphics);
                        break;

                    case 3:
                        ResolutionUtility.AdjustResolution(1280, 1024, Game1.graphics);
                        break;

                    case 4:
                        ResolutionUtility.AdjustResolution(1366, 768, Game1.graphics);
                        break;

                    case 5:
                        ResolutionUtility.AdjustResolution(1440, 900, Game1.graphics);
                        break;

                    case 6:
                        ResolutionUtility.AdjustResolution(1600, 900, Game1.graphics);
                        break;

                    case 7:
                        ResolutionUtility.AdjustResolution(1920, 1080, Game1.graphics);
                        break;

                    case 8:
                        ResolutionUtility.toggleFullscreen();
                        bSubMenu         = false;
                        cursorPosition.X = 0;
                        cursorPosition.Y = 0;
                        break;
                    }
                }
                if (buttonPressUtility.isPressed(Game1.moveLeftString))
                {
                    bEditingSubMenu = false;
                }
            }
        }
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            gameRef = this;
            if (bExited)
            {
                Exit();
            }

            if (bIsDebug && TestEnvironment.bDoTest && false)
            {
                TestEnvironment.Test();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.M) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                ToggleMouse();
            }

            //Console.WriteLine("Hello from Update");

            if (Keyboard.GetState().IsKeyDown(Keys.End) && !KeyboardMouseUtility.AnyButtonsPressed())
            {
                Console.WriteLine(Steamworks.SteamAPI.InitSafe());
            }

            SceneUtility.UpdateTransform();
            SceneUtility.Update(gameTime);
            SceneUtility.scenes = scenes;

            ResolutionUtility.bMouseIsVisible = this.IsMouseVisible;
            ResolutionUtility.mousePos.X      = Mouse.GetState().X;
            ResolutionUtility.mousePos.Y      = Mouse.GetState().Y;
            ResolutionUtility.KeyHandler(graphics, gameTime);
            //MouseMustStayWithinGame();
            buttonPressUtility.Update(gameTime);

            if (ResolutionUtility.stdScale != new Vector2(1))
            {
                this.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            }

            bIsActive = this.IsActive;
            //if (!bRunEditMode)
            //{
            //    MusicBGPlayer.Update(gameTime);
            //}

            //CursorUtility.update(gameTime);


            if (!bRunEditMode && !StartScreen.bIsRunning)
            {
                scenes[SceneUtility.currentScene].Update(gameTime, this);
            }
            else if (StartScreen.bIsRunning)
            {
                startScreen.Update(gameTime);
            }
            //else
            //{
            //    ScripTestingScene.Update(gameTime, this);
            //}

            if (SceneUtility.currentScene != (int)Screens.Editor)
            {
                buttonPressUtility.bPressed = true;
                Console.Out.WriteLine("You called the editor!");
                (scenes[(int)Screens.Editor] as Editor).preScreen = SceneUtility.prevScene;
                SceneUtility.ChangeScene((int)Screens.Editor);
                // SceneUtility.prevScene = SceneUtility.currentScene;
                //  SceneUtility.currentScene = (int)Screens.Editor;
                (scenes[(int)Screens.Editor] as Editor).scenes = scenes;
                (scenes[(int)Screens.Editor] as Editor).Start(this);
            }

            KeyboardMouseUtility.Update(this);

            //if (!bRunEditMode)
            //{

            //    if (SceneUtility.prevScene != SceneUtility.currentScene)
            //    {
            //        if (!scenes[SceneUtility.currentScene].bIsInitialized)
            //        {
            //            Console.Out.WriteLine("Called for: " + scenes[SceneUtility.currentScene]);
            //            scenes[SceneUtility.currentScene].Initialize(this);
            //        }
            //        else
            //        {
            //            scenes[SceneUtility.currentScene].Reload();
            //        }

            //    }

            //    if (SceneUtility.currentScene == (int)(Game1.Screens.ExitGame))
            //    {

            //        foreach (Scene scene in scenes)
            //        {
            //            scene.UnloadContent(this);
            //        }

            //        Exit();
            //    }

            //    if (buttonPressUtility.isPressedSub(EditorString) && !buttonPressUtility.bPressed && SceneUtility.currentScene != (int)Screens.Editor)
            //    {
            //        buttonPressUtility.bPressed = true;
            //        Console.Out.WriteLine("You called the editor!");
            //        (scenes[(int)Screens.Editor] as Editor).preScreen = SceneUtility.prevScene;
            //        SceneUtility.ChangeScene((int)Screens.Editor);
            //        // SceneUtility.prevScene = SceneUtility.currentScene;
            //        //  SceneUtility.currentScene = (int)Screens.Editor;
            //        (scenes[(int)Screens.Editor] as Editor).scenes = scenes;
            //        (scenes[(int)Screens.Editor] as Editor).Start(this);
            //    }
            //    else if (buttonPressUtility.isPressedSub(EditorString) && !buttonPressUtility.bPressed && SceneUtility.currentScene == (int)Screens.Editor)
            //    {
            //        buttonPressUtility.bPressed = true;
            //        Console.Out.WriteLine("You left the editor!");
            //        //TODO set the actual prevscreen before entering the editor
            //        SceneUtility.currentScene = SceneUtility.prevScene;
            //        SceneUtility.prevScene = (scenes[(int)Screens.Editor] as Editor).preScreen;
            //        (scenes[(int)Screens.Editor] as Editor).ResetBackToGame(this);
            //    }
            //}



            base.Update(gameTime);
        }
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            //  Console.WriteLine(SteamFriends.GetPersonaName());


            base.Initialize();
            initiateActions();

            ResolutionUtility.bMouseIsVisible = this.IsMouseVisible;
            hitboxHelp       = Content.Load <Texture2D>(@"Graphics\HitBoxHelp");
            selectionTexture = Content.Load <Texture2D>(@"Graphics\MainMenu\TestRectangle");
            mapBorderHelp    = Content.Load <Texture2D>(@"Graphics\Tiles\Basic\BorderTest");
            WhiteTex         = Content.Load <Texture2D>(@"White");
            scenes.Insert((int)(Screens.MainMenu), new MainMenu());
            scenes.Insert((int)(Screens.MainGameStart), new NewGameScene());
            scenes.Insert((int)(Screens.MainGameContinue), new ContinueGameScene());
            scenes.Insert((int)(Screens.OWGame), new OWGame());
            scenes.Insert((int)(Screens.BGame), new MainGame());
            scenes.Insert((int)(Screens.Options), new Options());
            scenes.Insert((int)(Screens.ExitGame), new Scene());
            scenes.Insert((int)(Screens.Editor), new Editor());


            CursorUtility.Initialize(this);
            MainGUI.Initialize(this);


            if (!bRunEditMode)
            {
                scenes[SceneUtility.currentScene].Initialize(this);
            }



            graphics.PreferMultiSampling       = true;
            graphics.PreferredBackBufferWidth  = this.GraphicsDevice.DisplayMode.Width;
            graphics.PreferredBackBufferHeight = this.GraphicsDevice.DisplayMode.Height;
            //   this.Window.Position = new Point(100, 100);
            //graphics.IsFullScreen = true;
            this.IsMouseVisible = false;
            graphics.ApplyChanges();
            LoadAssets();
            this.Window.AllowUserResizing = false;
            //Window.IsBorderless = true;
            Window.AllowAltF4 = true;
            //Window.Location = Point.Zero;
            //900,506
            ResolutionUtility.WindowSizeBeforeFullScreen = new Vector2(1366, 768);
            ResolutionUtility.AdjustResolution(1366, 768, graphics);
            gameRender  = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            gameRender  = new RenderTarget2D(GraphicsDevice, 1366, 768);
            UIRender    = new RenderTarget2D(GraphicsDevice, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            monitorSize = new Vector2(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
            Console.WriteLine("Primary Monitor Size: " + monitorSize);

            EditorFileWriter.LoadSaveSettings();
            startScreen = new StartScreen();
#if !DEBUG
            // GameProcessor.Launch();
#endif
            // GameProcessor.Launch();
        }
        internal void Load()
        {
            GameProcessor.bShadowsEnabled         = bShadowGeneration;
            GameProcessor.bWaterReflectionEnabled = bReflectionGeneration;
            GameProcessor.shadowQualityPercentage = (float)((float)shadowPercentage / 100f);

            if (resolution.X < 100 && resolution.Y < 100)
            {
                resolution = new Vector2(1366, 768);
            }
            ResolutionUtility.AdjustResolution(resolution.X, resolution.Y, Game1.graphics);
            if (bFullScreen)
            {
                ResolutionUtility.toggleFullscreen();
            }

            speedMod       = battleSpeed;
            speedModCamera = battleCameraSpeed;

            if (Math.Abs(MasterVolume) > 100)
            {
                MasterVolume = Math.Abs(MasterVolume) % 100;
            }
            SceneUtility.masterVolume = MasterVolume;

            if (Math.Abs(SoundEffectVolume) > 100)
            {
                SoundEffectVolume = Math.Abs(SoundEffectVolume) % 100;
            }
            SceneUtility.soundEffectsVolume = SoundEffectVolume;

            if (Math.Abs(MusicVolume) > 100)
            {
                MusicVolume = Math.Abs(MusicVolume) % 100;
            }
            SceneUtility.musicVolume = MusicVolume;

            List <ActionKey> lak = new List <ActionKey>();

            if (controls.Count != 0)
            {
                foreach (var item in Game1.actionKeyList)
                {
                    if (controls.Find(ak => ak.actionIndentifierString.Equals(item.actionIndentifierString) && ak.column == item.column) != null)
                    {
                        lak.Add(controls.Find(ak => ak.actionIndentifierString.Equals(item.actionIndentifierString) && ak.column == item.column));
                    }
                    else
                    {
                        lak.Add(item);
                    }
                }
                Game1.actionKeyList = lak;
            }
            else
            {
                controls = Game1.actionKeyList;
            }

            foreach (var act in Game1.actionList)
            {
                for (int i = 0; i < act.whatKeysIsActionAssignedTo.Length; i++)
                {
                    var k = Game1.actionKeyList.Find(ak => ak.actionIndentifierString.Equals(act.actionIndentifierString) && ak.column == i);
                    act.whatKeysIsActionAssignedTo[i] = k;
                }
            }
        }
        static public void Update(GameTime gt)
        {
            CheckMouse();
            // selectedSprite.position = new Vector2(400,300);
            anyButtonsPressed = false;
            mouseState        = Mouse.GetState();
            keyboardState     = Keyboard.GetState();
            //var wot = keyboardState.GetPressedKeys();
            //String test = "";
            //foreach (var item in wot)
            //{
            //    test += item;
            //    test += " + ";
            //}
            //Console.WriteLine(test);

            if (!KeyboardMouseUtility.AnyButtonsPressed() && Keyboard.GetState().IsKeyDown(Keys.LeftAlt) && Keyboard.GetState().IsKeyDown(Keys.Enter))
            {
                // ResolutionUtility.AdjustResolution(Game1.monitorSize.X, Game1.monitorSize.Y, Game1.graphics);
                ResolutionUtility.toggleFullscreen();
                KeyboardMouseUtility.bPressed = true;
            }



            if (keyboardState.GetPressedKeys().Length > 1)
            {
                foreach (var key in Game1.actionKeyList)
                {
                    if (keyboardState.GetPressedKeys()[keyboardState.GetPressedKeys().Length - 1] == (key.assignedActionKey))
                    {
                        lastPressedKey = key;
                    }
                }
            }
            else
            {
                foreach (var key in Game1.actionKeyList)
                {
                    if (keyboardState.IsKeyDown(key.assignedActionKey))
                    {
                        lastPressedKey = key;
                        //selectedSprite.MoverMustUpdateHitboxes = true;
                    }
                }
            }

            if (Keyboard.GetState().IsKeyDown(Keys.NumPad8))
            {
            }

            //if (keyboardState.GetPressedKeys().Length >= 1)
            //{
            //    foreach (var key in Game1.actionKeyList)
            //    {
            //        if (keyboardState.IsKeyDown(key.assignedActionKey))
            //        {
            //            lastPressedKey = key;
            //            break;
            //        }

            //    }
            //}



            List <Actions.ActionKey> pressedKeys = new List <Actions.ActionKey>();

            foreach (var key in Game1.actionKeyList)
            {
                if (keyboardState.IsKeyDown(key.assignedActionKey))
                {
                    #region EDITOR PLAYTEST FUNCTION
                    if (MapBuilder.bPlayTest && Game1.bIsDebug)
                    {
                        if (key.actionIndentifierString.Equals(Game1.cancelString) && Keyboard.GetState().IsKeyDown(Keys.LeftShift) && MapBuilder.bPlayTest)
                        {
                            ReturnToEditorAction();
                            break;
                        }
                    }
                    #endregion

                    pressedKeys.Add(key);
                }
            }


            if (Mouse.GetState().LeftButton == ButtonState.Pressed)
            {
                // KeyboardMouseUtility.bPressed = true;
                pressedKeys.Add(Game1.actionKeyList.Find(key => key.actionIndentifierString.Equals(Game1.confirmString, StringComparison.OrdinalIgnoreCase)));
                KeyboardMouseUtility.bMouseButtonPressed = true;
            }


            if (Mouse.GetState().RightButton == ButtonState.Pressed)
            {
                // KeyboardMouseUtility.bPressed = true;
                pressedKeys.Add(Game1.actionKeyList.Find(key => key.actionIndentifierString.Equals(Game1.cancelString, StringComparison.OrdinalIgnoreCase)));
                KeyboardMouseUtility.bMouseButtonPressed = true;
            }

            if (Mouse.GetState().RightButton != ButtonState.Pressed && Mouse.GetState().LeftButton != ButtonState.Pressed)
            {
                KeyboardMouseUtility.bMouseButtonPressed = false;
            }

            if (KeyboardMouseUtility.ScrollingDown() || KeyboardMouseUtility.ScrollingUp())
            {
                pressedKeys.Add(new Actions.ActionKey());
                pressedKeys.Last().actionIndentifierString = "Scroll";
            }

            #region NON EDITOR PLAYER CONTROLS
            if (pressedKeys.Count != 0)
            {
                // GameProcessor.bUpdateShadows = true;
                GameProcessor.bUpdateOnceMore = true;
                anyButtonsPressed             = true;
                //  GameProcessor.GenerateCamera(GameProcessor.cameraFollowTarget, .06f, GameProcessor.zoom);
                if (LUA.LuaExecutionList.DemandOverride())
                {
                    LUA.LuaExecutionList.ControlOverride(pressedKeys);
                }

                switch (currentController)
                {
                case Controllers.NonCombat:
                    NonCombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.Combat:
                    CombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.Menu:
                    MenuCtrl.Update(pressedKeys);
                    break;

                case Controllers.Dialogue:
                    DialogueCtrl.Update(pressedKeys);
                    break;

                case Controllers.SoloCombat:
                    SoloCombatCtrl.Update(pressedKeys);
                    break;

                case Controllers.EXPGainScreen:
                    ExpGainCtrl.Update(pressedKeys);
                    break;

                case Controllers.StartScreen:
                    ContextControllers.StartScreenCtrl.Update(pressedKeys);
                    break;

                case Controllers.ScriptProcessor:
                    ScriptProcessorCtrl.Update(pressedKeys);
                    break;

                case Controllers.GameSettingsMenu:
                    if (!SettingsMenu.bIsRunning)
                    {
                        currentController = Controllers.NonCombat;
                    }
                    GameSettingsMenuCtrl.Update(pressedKeys);
                    break;

                case Controllers.GameOptions:
                    if (!OptionsMenu.bIsRunning)
                    {
                        currentController = Controllers.NonCombat;
                    }
                    GameOptionsMenuCtrl.Update(pressedKeys);
                    break;

                default:
                    break;
                }
            }
            else if (KeyboardMouseUtility.bMouseMoved)
            {
                switch (currentController)
                {
                case Controllers.NonCombat:
                    break;

                case Controllers.Combat:
                    break;

                case Controllers.Menu:
                    MenuCtrl.MouseMove();
                    break;

                case Controllers.Dialogue:
                    break;

                case Controllers.SoloCombat:
                    break;

                case Controllers.EXPGainScreen:
                    break;

                case Controllers.StartScreen:
                    ContextControllers.StartScreenCtrl.MouseMove();
                    break;

                case Controllers.ScriptProcessor:
                    ScriptProcessorCtrl.HandleMouseMove();
                    break;

                case Controllers.GameSettingsMenu:
                    GameSettingsMenuCtrl.HandleMouseMove();
                    break;

                case Controllers.GameOptions:
                    GameOptionsMenuCtrl.HandleMouseMove();
                    break;

                default:
                    break;
                }
            }
            else if (selectedSprite != null && !CombatProcessor.bIsRunning)
            {
                selectedSprite.animationIndex = (int)BaseCharacter.CharacterAnimations.Idle;
            }

            #endregion
            if (selectedSprite != null && (!CombatProcessor.bStartPhase1 && !CombatProcessor.bMainCombat && !CombatProcessor.bIsRunning) && !ScriptProcessor.bIsRunning)
            {
                selectedSprite.Update(gt);
            }

            stop : { }
        }