Added grid lines to the PPU pattern table viewer for the Qt GUI.
This commit is contained in:
parent
7ce62ebee3
commit
909e3c0c20
|
@ -272,8 +272,8 @@ ppuPatternView_t::ppuPatternView_t( int patternIndexID, QWidget *parent)
|
||||||
viewWidth = 256;
|
viewWidth = 256;
|
||||||
viewHeight = 256;
|
viewHeight = 256;
|
||||||
tileLabel = NULL;
|
tileLabel = NULL;
|
||||||
mode = 0;
|
mode = 0;
|
||||||
drawTileGrid = true;
|
drawTileGrid = true;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuPatternView_t::setPattern( ppuPatternTable_t *p )
|
void ppuPatternView_t::setPattern( ppuPatternTable_t *p )
|
||||||
|
@ -347,29 +347,26 @@ void ppuPatternView_t::keyPressEvent(QKeyEvent *event)
|
||||||
{
|
{
|
||||||
//printf("Pattern View Key Press: 0x%x \n", event->key() );
|
//printf("Pattern View Key Press: 0x%x \n", event->key() );
|
||||||
|
|
||||||
if ( event->key() == Qt::Key_Z )
|
if ( event->key() == Qt::Key_Z )
|
||||||
{
|
{
|
||||||
mode = !mode;
|
mode = !mode;
|
||||||
}
|
}
|
||||||
else if ( event->key() == Qt::Key_G )
|
else if ( event->key() == Qt::Key_G )
|
||||||
{
|
{
|
||||||
if ( mode )
|
drawTileGrid = !drawTileGrid;
|
||||||
{
|
}
|
||||||
drawTileGrid = !drawTileGrid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( event->key() == Qt::Key_E )
|
else if ( event->key() == Qt::Key_E )
|
||||||
{
|
{
|
||||||
openTileEditor();
|
openTileEditor();
|
||||||
}
|
}
|
||||||
else if ( event->key() == Qt::Key_P )
|
else if ( event->key() == Qt::Key_P )
|
||||||
{
|
{
|
||||||
pindex[ patternIndex ] = (pindex[ patternIndex ] + 1) % 9;
|
pindex[ patternIndex ] = (pindex[ patternIndex ] + 1) % 9;
|
||||||
|
|
||||||
PPUViewSkip = 100;
|
PPUViewSkip = 100;
|
||||||
|
|
||||||
FCEUD_UpdatePPUView( -1, 0 );
|
FCEUD_UpdatePPUView( -1, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
@ -407,46 +404,46 @@ void ppuPatternView_t::contextMenuEvent(QContextMenuEvent *event)
|
||||||
{
|
{
|
||||||
QAction *act;
|
QAction *act;
|
||||||
QMenu menu(this);
|
QMenu menu(this);
|
||||||
QMenu *subMenu;
|
QMenu *subMenu;
|
||||||
QActionGroup *group;
|
QActionGroup *group;
|
||||||
QAction *paletteAct[9];
|
QAction *paletteAct[9];
|
||||||
char stmp[64];
|
char stmp[64];
|
||||||
|
|
||||||
act = new QAction(tr("Open Tile Editor"), &menu);
|
act = new QAction(tr("Open Tile Editor"), &menu);
|
||||||
act->setShortcut( QKeySequence(tr("E")));
|
act->setShortcut( QKeySequence(tr("E")));
|
||||||
connect( act, SIGNAL(triggered(void)), this, SLOT(openTileEditor(void)) );
|
connect( act, SIGNAL(triggered(void)), this, SLOT(openTileEditor(void)) );
|
||||||
menu.addAction( act );
|
menu.addAction( act );
|
||||||
|
|
||||||
if ( mode )
|
if ( mode )
|
||||||
{
|
{
|
||||||
sprintf( stmp, "Exit Tile View: %X%X", selTile.y(), selTile.x() );
|
sprintf( stmp, "Exit Tile View: %X%X", selTile.y(), selTile.x() );
|
||||||
|
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
act->setShortcut( QKeySequence(tr("Z")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(exitTileMode(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf( stmp, "View Tile: %X%X", selTile.y(), selTile.x() );
|
||||||
|
|
||||||
|
act = new QAction(tr(stmp), &menu);
|
||||||
|
act->setShortcut( QKeySequence(tr("Z")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(showTileMode(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
}
|
||||||
|
|
||||||
act = new QAction(tr(stmp), &menu);
|
act = new QAction(tr("Draw Tile Grid Lines"), &menu);
|
||||||
act->setShortcut( QKeySequence(tr("Z")));
|
act->setCheckable(true);
|
||||||
connect( act, SIGNAL(triggered(void)), this, SLOT(exitTileMode(void)) );
|
act->setChecked(drawTileGrid);
|
||||||
menu.addAction( act );
|
act->setShortcut( QKeySequence(tr("G")));
|
||||||
|
connect( act, SIGNAL(triggered(void)), this, SLOT(toggleTileGridLines(void)) );
|
||||||
|
menu.addAction( act );
|
||||||
|
|
||||||
act = new QAction(tr("Draw Tile Grid Lines"), &menu);
|
act = new QAction(tr("Next Palette"), &menu);
|
||||||
act->setCheckable(true);
|
act->setShortcut( QKeySequence(tr("P")));
|
||||||
act->setChecked(drawTileGrid);
|
|
||||||
act->setShortcut( QKeySequence(tr("G")));
|
|
||||||
connect( act, SIGNAL(triggered(void)), this, SLOT(toggleTileGridLines(void)) );
|
|
||||||
menu.addAction( act );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf( stmp, "View Tile: %X%X", selTile.y(), selTile.x() );
|
|
||||||
|
|
||||||
act = new QAction(tr(stmp), &menu);
|
|
||||||
act->setShortcut( QKeySequence(tr("Z")));
|
|
||||||
connect( act, SIGNAL(triggered(void)), this, SLOT(showTileMode(void)) );
|
|
||||||
menu.addAction( act );
|
|
||||||
}
|
|
||||||
|
|
||||||
act = new QAction(tr("Next Palette"), &menu);
|
|
||||||
act->setShortcut( QKeySequence(tr("P")));
|
|
||||||
connect( act, SIGNAL(triggered(void)), this, SLOT(cycleNextPalette(void)) );
|
connect( act, SIGNAL(triggered(void)), this, SLOT(cycleNextPalette(void)) );
|
||||||
menu.addAction( act );
|
menu.addAction( act );
|
||||||
|
|
||||||
subMenu = menu.addMenu(tr("Palette Select"));
|
subMenu = menu.addMenu(tr("Palette Select"));
|
||||||
group = new QActionGroup(&menu);
|
group = new QActionGroup(&menu);
|
||||||
|
@ -468,17 +465,17 @@ void ppuPatternView_t::contextMenuEvent(QContextMenuEvent *event)
|
||||||
paletteAct[i]->setChecked( pindex[ patternIndex ] == i );
|
paletteAct[i]->setChecked( pindex[ patternIndex ] == i );
|
||||||
}
|
}
|
||||||
|
|
||||||
connect( paletteAct[0], SIGNAL(triggered(void)), this, SLOT(selPalette0(void)) );
|
connect( paletteAct[0], SIGNAL(triggered(void)), this, SLOT(selPalette0(void)) );
|
||||||
connect( paletteAct[1], SIGNAL(triggered(void)), this, SLOT(selPalette1(void)) );
|
connect( paletteAct[1], SIGNAL(triggered(void)), this, SLOT(selPalette1(void)) );
|
||||||
connect( paletteAct[2], SIGNAL(triggered(void)), this, SLOT(selPalette2(void)) );
|
connect( paletteAct[2], SIGNAL(triggered(void)), this, SLOT(selPalette2(void)) );
|
||||||
connect( paletteAct[3], SIGNAL(triggered(void)), this, SLOT(selPalette3(void)) );
|
connect( paletteAct[3], SIGNAL(triggered(void)), this, SLOT(selPalette3(void)) );
|
||||||
connect( paletteAct[4], SIGNAL(triggered(void)), this, SLOT(selPalette4(void)) );
|
connect( paletteAct[4], SIGNAL(triggered(void)), this, SLOT(selPalette4(void)) );
|
||||||
connect( paletteAct[5], SIGNAL(triggered(void)), this, SLOT(selPalette5(void)) );
|
connect( paletteAct[5], SIGNAL(triggered(void)), this, SLOT(selPalette5(void)) );
|
||||||
connect( paletteAct[6], SIGNAL(triggered(void)), this, SLOT(selPalette6(void)) );
|
connect( paletteAct[6], SIGNAL(triggered(void)), this, SLOT(selPalette6(void)) );
|
||||||
connect( paletteAct[7], SIGNAL(triggered(void)), this, SLOT(selPalette7(void)) );
|
connect( paletteAct[7], SIGNAL(triggered(void)), this, SLOT(selPalette7(void)) );
|
||||||
connect( paletteAct[8], SIGNAL(triggered(void)), this, SLOT(selPalette8(void)) );
|
connect( paletteAct[8], SIGNAL(triggered(void)), this, SLOT(selPalette8(void)) );
|
||||||
|
|
||||||
menu.exec(event->globalPos());
|
menu.exec(event->globalPos());
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void ppuPatternView_t::toggleTileGridLines(void)
|
void ppuPatternView_t::toggleTileGridLines(void)
|
||||||
|
@ -567,9 +564,16 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
viewWidth = event->rect().width();
|
viewWidth = event->rect().width();
|
||||||
viewHeight = event->rect().height();
|
viewHeight = event->rect().height();
|
||||||
|
QPen pen;
|
||||||
|
|
||||||
|
pen = painter.pen();
|
||||||
|
|
||||||
//printf("PPU PatternView %ix%i \n", viewWidth, viewHeight );
|
//printf("PPU PatternView %ix%i \n", viewWidth, viewHeight );
|
||||||
|
|
||||||
|
pen.setWidth( 1 );
|
||||||
|
pen.setColor( QColor( 128, 128, 128) );
|
||||||
|
painter.setPen( pen );
|
||||||
|
|
||||||
w = viewWidth / 128;
|
w = viewWidth / 128;
|
||||||
h = viewHeight / 128;
|
h = viewHeight / 128;
|
||||||
|
|
||||||
|
@ -578,25 +582,25 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
xx = 0; yy = 0;
|
xx = 0; yy = 0;
|
||||||
|
|
||||||
if ( mode == 1 )
|
if ( mode == 1 )
|
||||||
{
|
{
|
||||||
w = viewWidth / 8;
|
w = viewWidth / 8;
|
||||||
h = viewHeight / 8;
|
h = viewHeight / 8;
|
||||||
|
|
||||||
if ( w < h )
|
if ( w < h )
|
||||||
{
|
{
|
||||||
h = w;
|
h = w;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
w = h;
|
w = h;
|
||||||
}
|
}
|
||||||
|
|
||||||
ii = selTile.x();
|
ii = selTile.x();
|
||||||
jj = selTile.y();
|
jj = selTile.y();
|
||||||
|
|
||||||
// Draw Tile Pixels as rectangles
|
// Draw Tile Pixels as rectangles
|
||||||
for (x=0; x < 8; x++)
|
for (x=0; x < 8; x++)
|
||||||
{
|
{
|
||||||
yy = 0;
|
yy = 0;
|
||||||
|
|
||||||
|
@ -608,24 +612,24 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
xx += w;
|
xx += w;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( drawTileGrid )
|
if ( drawTileGrid )
|
||||||
{
|
{
|
||||||
// Draw Tile Pixel grid lines
|
// Draw Tile Pixel grid lines
|
||||||
xx = 0; y = 8*h;
|
xx = 0; y = 8*h;
|
||||||
|
|
||||||
for (x=0; x<9; x++)
|
for (x=0; x<9; x++)
|
||||||
{
|
{
|
||||||
painter.drawLine( xx, 0 , xx, y ); xx += w;
|
painter.drawLine( xx, 0 , xx, y ); xx += w;
|
||||||
}
|
}
|
||||||
yy = 0; x = 8*w;
|
yy = 0; x = 8*w;
|
||||||
|
|
||||||
for (y=0; y<9; y++)
|
for (y=0; y<9; y++)
|
||||||
{
|
{
|
||||||
painter.drawLine( 0, yy , x, yy ); yy += h;
|
painter.drawLine( 0, yy , x, yy ); yy += h;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( PPUView_sprite16Mode[ patternIndex ] )
|
else if ( PPUView_sprite16Mode[ patternIndex ] )
|
||||||
{
|
{
|
||||||
for (i=0; i<16; i++) //Columns
|
for (i=0; i<16; i++) //Columns
|
||||||
{
|
{
|
||||||
|
@ -664,6 +668,23 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( drawTileGrid )
|
||||||
|
{
|
||||||
|
xx = 0; y = 128*h;
|
||||||
|
|
||||||
|
for (i=0; i<16; i++) //Columns
|
||||||
|
{
|
||||||
|
painter.drawLine( xx, 0 , xx, y ); xx += (8*w);
|
||||||
|
}
|
||||||
|
|
||||||
|
yy = 0; x = 128*w;
|
||||||
|
|
||||||
|
for (j=0; j<16; j++) //Rows
|
||||||
|
{
|
||||||
|
painter.drawLine( 0, yy , x, yy ); yy += (8*h);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -688,6 +709,23 @@ void ppuPatternView_t::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( drawTileGrid )
|
||||||
|
{
|
||||||
|
xx = 0; y = 128*h;
|
||||||
|
|
||||||
|
for (i=0; i<16; i++) //Columns
|
||||||
|
{
|
||||||
|
painter.drawLine( xx, 0 , xx, y ); xx += (8*w);
|
||||||
|
}
|
||||||
|
|
||||||
|
yy = 0; x = 128*w;
|
||||||
|
|
||||||
|
for (j=0; j<16; j++) //Rows
|
||||||
|
{
|
||||||
|
painter.drawLine( 0, yy , x, yy ); yy += (8*h);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
|
@ -1622,19 +1660,23 @@ void ppuTileView_t::paintEvent(QPaintEvent *event)
|
||||||
|
|
||||||
if ( drawTileGrid )
|
if ( drawTileGrid )
|
||||||
{
|
{
|
||||||
// Draw Tile Pixel grid lines
|
pen.setWidth( 1 );
|
||||||
xx = 0; y = 8*h;
|
pen.setColor( QColor(128,128,128) );
|
||||||
|
painter.setPen( pen );
|
||||||
for (x=0; x<9; x++)
|
|
||||||
{
|
// Draw Tile Pixel grid lines
|
||||||
painter.drawLine( xx, 0 , xx, y ); xx += w;
|
xx = 0; y = 8*h;
|
||||||
}
|
|
||||||
yy = 0; x = 8*w;
|
for (x=0; x<9; x++)
|
||||||
|
{
|
||||||
for (y=0; y<9; y++)
|
painter.drawLine( xx, 0 , xx, y ); xx += w;
|
||||||
{
|
}
|
||||||
painter.drawLine( 0, yy , x, yy ); yy += h;
|
yy = 0; x = 8*w;
|
||||||
}
|
|
||||||
|
for (y=0; y<9; y++)
|
||||||
|
{
|
||||||
|
painter.drawLine( 0, yy , x, yy ); yy += h;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x = selPix.x() * w;
|
x = selPix.x() * w;
|
||||||
|
|
Loading…
Reference in New Issue