예제 #1
0
        private static void InitializeResources()
        {
            var textureComplete = 0.0;
            var soundComplete   = 0.0;

            EventHandler <LoadProgressUpdatedEventArgs> progressTextureUpdateAction = (sender, args) =>
            {
                var updateLabel = args != null ? args.UpdateLabel : "Load Complete";
                textureComplete = args?.UpdateProgress / 2 ?? 0.5;
                Constants.ConstantsLoadProgressEventUpdated?.Invoke(null, new ConstantsLoadProgressEventUpdatedEventArgs("Resources: Textures: " + updateLabel, soundComplete + textureComplete));
            };

            Constants.ReloadTextures(progressTextureUpdateAction);
            Constants.TextMeasurer = new TextMeasurer();

            SpriteRendererPanel.ReloadTextures();

            EventHandler <LoadProgressUpdatedEventArgs> progressSoundUpdateAction = (sender, args) =>
            {
                var updateLabel = args != null ? args.UpdateLabel : "Load Complete";
                soundComplete = args?.UpdateProgress / 2 ?? 0.5;
                Constants.ConstantsLoadProgressEventUpdated?.Invoke(null, new ConstantsLoadProgressEventUpdatedEventArgs("Resources: Sounds: " + updateLabel, soundComplete + textureComplete));
            };

            Constants.SoundEffects = new ObservableCollection <string>();
            Constants.ReloadSound(progressSoundUpdateAction);
        }
예제 #2
0
        static MapRenderer()
        {
            var spriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            MapRenderer.LevelRenderer     = spriteRendererPanel;
            MapRenderer.LevelControl      = spriteRendererPanel;
            MapRenderer.DisplayOptions    = new ObservableCollection <Tuple <int, LevelDisplayOptions> >();
            MapRenderer.MapDisplayOptions = new MapDisplayOptions();
            MapRenderer.Frame             = 0;
            MapRenderer.WalkablePreview   = new Dictionary <Tuple <int, int, int>, int>();
            MapRenderer.CurrentLevel      = 0;

            MapRenderer.IsDrawing = false;

            SpriteRendererPanel.TextureLoad += () => MapRenderer.IsDrawing = true;

            MapRenderer.LevelControl.ScaledMouseDown  += MapRenderer.LevelControlMouseDown;
            MapRenderer.LevelControl.ScaledMouseMove  += MapRenderer.LevelControlMouseMove;
            MapRenderer.LevelControl.ScaledMouseUp    += MapRenderer.LevelControlMouseUp;
            MapRenderer.LevelControl.ScaledMouseLeave += MapRenderer.LevelControlMouseLeave;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                spriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
            };
        }
예제 #3
0
        private void ReloadGraphics()
        {
            try
            {
                Application.Current?.Dispatcher?.BeginInvoke((Action)(() => LoadProgressWindow.ShowWindow()));

                EventHandler <LoadProgressUpdatedEventArgs> progressUpdateAction = (sender, args) =>
                {
                    Application.Current?.Dispatcher?.BeginInvoke((Action)(() =>
                    {
                        if (args != null)
                        {
                            LoadProgressWindow.SetProgress(args.UpdateProgress, args.UpdateLabel);
                        }
                        else
                        {
                            LoadProgressWindow.HideWindow();
                        }
                    }));
                };

                Constants.ReloadTextures(progressUpdateAction);

                SpriteRendererPanel.ReloadTextures();
            }
            catch (Exception e)
            {
                Application.Current?.Dispatcher?.BeginInvoke((Action)(() => LoadProgressWindow.HideWindow()));
                MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
예제 #4
0
        static CharacterInfoRenderer()
        {
            CharacterInfoRenderer.ViewModel = new CharacterInfoDataViewModel();

            var spriteSheetSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            CharacterInfoRenderer.SpriteSheetRenderer = spriteSheetSpriteRendererPanel;
            CharacterInfoRenderer.SpriteSheetControl  = spriteSheetSpriteRendererPanel;

            var previewRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            CharacterInfoRenderer.PreviewRenderer = previewRendererPanel;
            CharacterInfoRenderer.PreviewControl  = previewRendererPanel;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                spriteSheetSpriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
                previewRendererPanel.TextureLoadStrategy           = Constants.TextureLoadStrategy;
            };

            PreviewTimer = new Timer
            {
                Interval  = 1000 / 60,
                AutoReset = true,
                Enabled   = true
            };

            PreviewTimer.Elapsed += (sender, args) => { CharacterInfoRenderer.Frame++; };

            CharacterInfoRenderer.ViewModel.CurrentSheetIndex = 2;
            CharacterInfoRenderer.ViewModel.Angle             = 1;
        }
예제 #5
0
        static AddEditTranslationRenderer()
        {
            var dialogueRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy, 2);

            AddEditTranslationRenderer.DialogueRenderer = dialogueRendererPanel;
            AddEditTranslationRenderer.DialogueControl  = dialogueRendererPanel;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                dialogueRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
            };
        }
예제 #6
0
        static MapSelectionRenderer()
        {
            var mapRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            MapSelectionRenderer.MapRenderer = mapRendererPanel;
            MapSelectionRenderer.MapControl  = mapRendererPanel;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                mapRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
            };
        }
예제 #7
0
        static SpriteSelectionRenderer()
        {
            var spriteSheetSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            SpriteSelectionRenderer.SpriteSheetRenderer = spriteSheetSpriteRendererPanel;
            SpriteSelectionRenderer.SpriteSheetControl  = spriteSheetSpriteRendererPanel;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                spriteSheetSpriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
            };
        }
예제 #8
0
        public OpenGLRenderer(string tcdFile, string password, string graphicsFormat, double initialScaleX, double initialScaleY)
        {
            var loadStrategy = new TCDLoadStrategy(tcdFile, password, graphicsFormat);

            //var loadStrategy = new FolderTextureLoadStrategy("Graphics/{0}.png");
            loadStrategy.ProgressUpdated += this.Load_ProgressUpdate;
            loadStrategy.Load();
            this.renderer    = new SpriteRendererPanel(loadStrategy, initialScaleX, initialScaleY);
            this.lastWasText = false;

            var usedFont      = default(Font);
            var usedMiniFont  = default(Font);
            var usedMicroFont = default(Font);

            if ((new InstalledFontCollection().Families).Any(f => f.Name == "Microsoft Sans Serif"))
            {
                usedFont      = new Font("Microsoft Sans Serif", 15f, FontStyle.Regular);
                usedMiniFont  = new Font("Microsoft Sans Serif", 12f, FontStyle.Regular);
                usedMicroFont = new Font("Microsoft Sans Serif", 11f, FontStyle.Regular);
            }
            else
            {
                this.customFontInstance = new PrivateFontCollection();
                var    assembly     = Assembly.GetExecutingAssembly();
                string resourceName = assembly.GetManifestResourceNames().Single(str => str.EndsWith(OpenGLRenderer.FallbackFont, StringComparison.InvariantCultureIgnoreCase));
                byte[] fontBytes;
                using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                {
                    fontBytes = new byte[stream.Length];
                    stream.Read(fontBytes, 0, fontBytes.Length);
                    stream.Close();
                }
                IntPtr handle = Marshal.AllocCoTaskMem(fontBytes.Length);
                Marshal.Copy(fontBytes, 0, handle, fontBytes.Length);
                this.customFontInstance.AddMemoryFont(handle, fontBytes.Length);
                Marshal.FreeCoTaskMem(handle);
                usedFont      = new Font(this.customFontInstance.Families[0], 15, FontStyle.Regular);
                usedMiniFont  = new Font(this.customFontInstance.Families[0], 12, FontStyle.Regular);
                usedMicroFont = new Font(this.customFontInstance.Families[0], 11, FontStyle.Regular);
            }

            this.regularFont = usedFont;
            this.miniFont    = usedMiniFont;
            this.microFont   = usedMicroFont;

            this.measurer = new GLTextMeasurer(usedFont, usedMiniFont, usedMicroFont);
        }
예제 #9
0
        static EncounterRenderer()
        {
            var fieldSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.FieldRenderer = fieldSpriteRendererPanel;
            EncounterRenderer.FieldControl  = fieldSpriteRendererPanel;
            EncounterRenderer.FieldControl.ScaledMouseMove += EncounterRenderer.FieldControl_MouseMove;
            EncounterRenderer.FieldControl.ScaledMouseDown += EncounterRenderer.FieldControl_MouseDown;
            EncounterRenderer.FieldControl.ScaledMouseUp   += EncounterRenderer.FieldControl_MouseUp;

            var patternSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.PatternRenderer = patternSpriteRendererPanel;
            EncounterRenderer.PatternControl  = patternSpriteRendererPanel;
            EncounterRenderer.PatternControl.ScaledMouseMove += EncounterRenderer.PatternControl_MouseMove;
            EncounterRenderer.PatternControl.ScaledMouseDown += EncounterRenderer.PatternControl_MouseDown;
            EncounterRenderer.PatternControl.ScaledMouseUp   += EncounterRenderer.PatternControl_MouseUp;

            var enemySpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.EnemyRenderer = enemySpriteRendererPanel;
            EncounterRenderer.EnemyControl  = enemySpriteRendererPanel;
            EncounterRenderer.EnemyControl.ScaledMouseDown += EncounterRenderer.EnemyControl_MouseDown;
            EncounterRenderer.EnemyControl.ScaledMouseUp   += EncounterRenderer.EnemyControl_MouseUp;

            var enemySelectionSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.EnemySelectionRenderer = enemySelectionSpriteRendererPanel;
            EncounterRenderer.EnemySelectionControl  = enemySelectionSpriteRendererPanel;
            EncounterRenderer.EnemySelectionControl.ScaledMouseMove += EncounterRenderer.EnemySelectionControl_MouseMove;
            EncounterRenderer.EnemySelectionControl.ScaledMouseDown += EncounterRenderer.EnemySelectionControl_MouseDown;
            EncounterRenderer.EnemySelectionControl.ScaledMouseUp   += EncounterRenderer.EnemySelectionControl_MouseUp;

            var primaryPanelSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.PrimaryPanelRenderer = primaryPanelSpriteRendererPanel;
            EncounterRenderer.PrimaryPanelControl  = primaryPanelSpriteRendererPanel;
            EncounterRenderer.PrimaryPanelControl.ScaledMouseDown  += EncounterRenderer.PrimaryPanelControl_MouseDown;
            EncounterRenderer.PrimaryPanelControl.ScaledMouseUp    += EncounterRenderer.PrimaryPanelControl_MouseUp;
            EncounterRenderer.PrimaryPanelControl.ScaledMouseEnter += EncounterRenderer.PrimaryPanelControl_MouseEnter;
            EncounterRenderer.PrimaryPanelControl.ScaledMouseLeave += EncounterRenderer.PrimaryPanelControl_MouseLeave;

            var secondaryPanelSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.SecondaryPanelRenderer = secondaryPanelSpriteRendererPanel;
            EncounterRenderer.SecondaryPanelControl  = secondaryPanelSpriteRendererPanel;
            EncounterRenderer.SecondaryPanelControl.ScaledMouseDown  += EncounterRenderer.SecondaryPanelControl_MouseDown;
            EncounterRenderer.SecondaryPanelControl.ScaledMouseUp    += EncounterRenderer.SecondaryPanelControl_MouseUp;
            EncounterRenderer.SecondaryPanelControl.ScaledMouseEnter += EncounterRenderer.SecondaryPanelControl_MouseEnter;
            EncounterRenderer.SecondaryPanelControl.ScaledMouseLeave += EncounterRenderer.SecondaryPanelControl_MouseLeave;

            var panelSelectionSpriteRendererPanel = new SpriteRendererPanel(Constants.TextureLoadStrategy);

            EncounterRenderer.PanelSelectionRenderer = panelSelectionSpriteRendererPanel;
            EncounterRenderer.PanelSelectionControl  = panelSelectionSpriteRendererPanel;
            EncounterRenderer.PanelSelectionControl.ScaledMouseMove += EncounterRenderer.PanelSelectionControl_MouseMove;
            EncounterRenderer.PanelSelectionControl.ScaledMouseDown += EncounterRenderer.PanelSelectionControl_MouseDown;
            EncounterRenderer.PanelSelectionControl.ScaledMouseUp   += EncounterRenderer.PanelSelectionControl_MouseUp;

            SpriteRendererPanel.TexturesReloaded += () =>
            {
                fieldSpriteRendererPanel.TextureLoadStrategy          = Constants.TextureLoadStrategy;
                patternSpriteRendererPanel.TextureLoadStrategy        = Constants.TextureLoadStrategy;
                enemySpriteRendererPanel.TextureLoadStrategy          = Constants.TextureLoadStrategy;
                enemySelectionSpriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
                primaryPanelSpriteRendererPanel.TextureLoadStrategy   = Constants.TextureLoadStrategy;
                secondaryPanelSpriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
                panelSelectionSpriteRendererPanel.TextureLoadStrategy = Constants.TextureLoadStrategy;
            };
        }