Exemple #1
0
        protected override void OnFormClosed(FormClosedEventArgs e)
        {
            _refreshManager?.Dispose();

            TileViewerConfig config = ConfigManager.Config.Debug.TileViewer;

            config.WindowSize       = this.WindowState != FormWindowState.Normal ? this.RestoreBounds.Size : this.Size;
            config.WindowLocation   = this.WindowState != FormWindowState.Normal ? this.RestoreBounds.Location : this.Location;
            config.AutoRefresh      = mnuAutoRefresh.Checked;
            config.AutoRefreshSpeed = _refreshManager.AutoRefreshSpeed;
            config.ShowTileGrid     = chkShowTileGrid.Checked;
            config.RefreshScanline  = ctrlScanlineCycleSelect.Scanline;
            config.RefreshCycle     = ctrlScanlineCycleSelect.Cycle;
            config.ImageScale       = ctrlImagePanel.ImageScale;

            config.Source          = cboMemoryType.GetEnumValue <SnesMemoryType>();
            config.Format          = cboFormat.GetEnumValue <TileFormat>();
            config.Layout          = cboLayout.GetEnumValue <TileLayout>();
            config.ColumnCount     = (int)nudColumns.Value;
            config.Address         = (int)nudAddress.Value;
            config.PageSize        = (int)nudSize.Value;
            config.SelectedPalette = ctrlPaletteViewer.SelectedPalette;

            ConfigManager.ApplyChanges();
            base.OnFormClosed(e);
        }
Exemple #2
0
        protected override void OnLoad(EventArgs evt)
        {
            base.OnLoad(evt);
            if (DesignMode)
            {
                return;
            }

            _tileData            = new byte[0x400000];
            _tileImage           = new Bitmap(512, 512, PixelFormat.Format32bppPArgb);
            ctrlImagePanel.Image = _tileImage;

            BaseConfigForm.InitializeComboBox(cboFormat, typeof(TileFormat));
            BaseConfigForm.InitializeComboBox(cboLayout, typeof(TileLayout));
            InitMemoryTypeDropdown();

            InitShortcuts();

            TileViewerConfig config = ConfigManager.Config.Debug.TileViewer;

            RestoreLocation(config.WindowLocation, config.WindowSize);

            cboMemoryType.SetEnumValue(config.Source);
            cboFormat.SetEnumValue(config.Format);
            cboLayout.SetEnumValue(config.Layout);
            nudColumns.Value = config.ColumnCount;

            int memSize = DebugApi.GetMemorySize(_memoryType);

            config.Address = Math.Min(memSize - config.PageSize, config.Address);

            UpdateMemoryType(config.Source);
            nudAddress.Value          = config.Address;
            nudSize.Value             = config.PageSize;
            mnuAutoRefresh.Checked    = config.AutoRefresh;
            chkShowTileGrid.Checked   = config.ShowTileGrid;
            ctrlImagePanel.ImageScale = config.ImageScale;
            ctrlScanlineCycleSelect.Initialize(config.RefreshScanline, config.RefreshCycle);
            ctrlPaletteViewer.SelectedPalette = config.SelectedPalette;

            nudSize.Increment    = 0x1000;
            nudSize.Minimum      = 0x1000;
            nudSize.Maximum      = Math.Min(memSize, 0x40000);
            nudAddress.Increment = nudSize.Value;
            nudAddress.Maximum   = memSize - nudSize.Value;

            _address                 = config.Address;
            _options.Format          = config.Format;
            _options.Layout          = config.Layout;
            _options.Palette         = config.SelectedPalette;
            _options.Width           = config.ColumnCount;
            _options.PageSize        = config.PageSize;
            ctrlImagePanel.GridSizeX = config.ShowTileGrid ? 8 : 0;
            ctrlImagePanel.GridSizeY = config.ShowTileGrid ? 8 : 0;

            _refreshManager                      = new WindowRefreshManager(this);
            _refreshManager.AutoRefresh          = config.AutoRefresh;
            _refreshManager.AutoRefreshSpeed     = config.AutoRefreshSpeed;
            mnuAutoRefreshLow.Click             += (s, e) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.Low;
            mnuAutoRefreshNormal.Click          += (s, e) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.Normal;
            mnuAutoRefreshHigh.Click            += (s, e) => _refreshManager.AutoRefreshSpeed = RefreshSpeed.High;
            mnuAutoRefreshSpeed.DropDownOpening += (s, e) => UpdateRefreshSpeedMenu();

            RefreshData();
            RefreshViewer();

            cboMemoryType.SelectedIndexChanged += cboMemoryType_SelectedIndexChanged;
            nudAddress.ValueChanged            += nudAddress_ValueChanged;
            chkShowTileGrid.Click              += chkShowTileGrid_Click;
            cboFormat.SelectedIndexChanged     += cboFormat_SelectedIndexChanged;
            cboLayout.SelectedIndexChanged     += cboLayout_SelectedIndexChanged;
            nudColumns.ValueChanged            += nudColumns_ValueChanged;
            nudSize.ValueChanged               += nudSize_ValueChanged;
            ctrlPaletteViewer.SelectionChanged += ctrlPaletteViewer_SelectionChanged;
            mnuAutoRefresh.CheckedChanged      += mnuAutoRefresh_CheckedChanged;

            UpdatePaletteControl();

            btnPresetBg1.Click  += (s, e) => GoToBgLayer(0);
            btnPresetBg2.Click  += (s, e) => GoToBgLayer(1);
            btnPresetBg3.Click  += (s, e) => GoToBgLayer(2);
            btnPresetBg4.Click  += (s, e) => GoToBgLayer(3);
            btnPresetOam1.Click += (s, e) => GoToOamPreset(0);
            btnPresetOam2.Click += (s, e) => GoToOamPreset(1);
        }
Exemple #3
0
        protected override void OnLoad(EventArgs evt)
        {
            base.OnLoad(evt);
            if (DesignMode)
            {
                return;
            }

            _notifListener = new NotificationListener();
            _notifListener.OnNotification += OnNotificationReceived;

            _tileData            = new byte[512 * 512 * 4];
            _tileImage           = new Bitmap(512, 512, PixelFormat.Format32bppPArgb);
            ctrlImagePanel.Image = _tileImage;

            BaseConfigForm.InitializeComboBox(cboFormat, typeof(TileFormat));
            BaseConfigForm.InitializeComboBox(cboLayout, typeof(TileLayout));
            InitMemoryTypeDropdown();

            InitShortcuts();

            TileViewerConfig config = ConfigManager.Config.Debug.TileViewer;

            if (!config.WindowSize.IsEmpty)
            {
                this.StartPosition = FormStartPosition.Manual;
                this.Size          = config.WindowSize;
                this.Location      = config.WindowLocation;
            }

            cboMemoryType.SetEnumValue(config.Source);
            cboFormat.SetEnumValue(config.Format);
            cboLayout.SetEnumValue(config.Layout);
            nudColumns.Value          = config.ColumnCount;
            nudBank.Value             = config.Bank;
            nudOffset.Value           = config.Offset;
            mnuAutoRefresh.Checked    = config.AutoRefresh;
            chkShowTileGrid.Checked   = config.ShowTileGrid;
            ctrlImagePanel.ImageScale = config.ImageScale;
            ctrlScanlineCycleSelect.Initialize(config.RefreshScanline, config.RefreshCycle);
            ctrlPaletteViewer.SelectedPalette = config.SelectedPalette;

            UpdateMemoryType(config.Source);
            _addressOffset           = config.Bank * 0x10000 + config.Offset;
            _options.Format          = config.Format;
            _options.Layout          = config.Layout;
            _options.Palette         = config.SelectedPalette;
            _options.Width           = config.ColumnCount;
            ctrlImagePanel.GridSizeX = config.ShowTileGrid ? 8 : 0;
            ctrlImagePanel.GridSizeY = config.ShowTileGrid ? 8 : 0;
            _autoRefresh             = config.AutoRefresh;

            RefreshData();
            RefreshViewer();

            cboMemoryType.SelectedIndexChanged += cboMemoryType_SelectedIndexChanged;
            nudBank.ValueChanged               += nudBank_ValueChanged;
            chkShowTileGrid.Click              += chkShowTileGrid_Click;
            cboFormat.SelectedIndexChanged     += cboFormat_SelectedIndexChanged;
            cboLayout.SelectedIndexChanged     += cboLayout_SelectedIndexChanged;
            nudColumns.ValueChanged            += nudColumns_ValueChanged;
            nudOffset.ValueChanged             += nudOffset_ValueChanged;
            ctrlPaletteViewer.SelectionChanged += ctrlPaletteViewer_SelectionChanged;
            mnuAutoRefresh.CheckedChanged      += mnuAutoRefresh_CheckedChanged;

            UpdatePaletteControl();

            btnPresetBg1.Click  += (s, e) => GoToBgLayer(0);
            btnPresetBg2.Click  += (s, e) => GoToBgLayer(1);
            btnPresetBg3.Click  += (s, e) => GoToBgLayer(2);
            btnPresetBg4.Click  += (s, e) => GoToBgLayer(3);
            btnPresetOam1.Click += (s, e) => GoToOamPreset(0);
            btnPresetOam2.Click += (s, e) => GoToOamPreset(1);
        }