Support for 2 tile sizes ("zooming"). Still needs rc file support.
Make non-rest-on-space space and Enter do the sam as clicking on current location. On handhelds, this is the button on thumbpad.
This commit is contained in:
@@ -27,6 +27,7 @@
|
|||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#endif
|
#endif
|
||||||
#include <qspinbox.h>
|
#include <qspinbox.h>
|
||||||
|
#include <qcheckbox.h>
|
||||||
#include <qfile.h>
|
#include <qfile.h>
|
||||||
#include <qlistbox.h>
|
#include <qlistbox.h>
|
||||||
#include <qlistview.h>
|
#include <qlistview.h>
|
||||||
@@ -91,11 +92,17 @@ signals:
|
|||||||
void fontChanged();
|
void fontChanged();
|
||||||
void tilesChanged();
|
void tilesChanged();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void toggleGlyphSize();
|
||||||
|
void setGlyphSize(bool);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSpinBox tilewidth;
|
QSpinBox tilewidth;
|
||||||
QSpinBox tileheight;
|
QSpinBox tileheight;
|
||||||
QLabel widthlbl;
|
QLabel widthlbl;
|
||||||
QLabel heightlbl;
|
QLabel heightlbl;
|
||||||
|
QCheckBox whichsize;
|
||||||
|
QSize othersize;
|
||||||
|
|
||||||
QComboBox fontsize;
|
QComboBox fontsize;
|
||||||
|
|
||||||
@@ -259,14 +266,15 @@ public:
|
|||||||
|
|
||||||
int width() const { return size.width(); }
|
int width() const { return size.width(); }
|
||||||
int height() const { return size.height(); }
|
int height() const { return size.height(); }
|
||||||
void resize(int w, int h);
|
void toggleSize();
|
||||||
|
void setSize(int w, int h);
|
||||||
|
|
||||||
void drawGlyph(QPainter&, int glyph, int pixelx, int pixely);
|
void drawGlyph(QPainter&, int glyph, int pixelx, int pixely);
|
||||||
void drawCell(QPainter&, int glyph, int cellx, int celly);
|
void drawCell(QPainter&, int glyph, int cellx, int celly);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QImage img;
|
QImage img;
|
||||||
QPixmap pm;
|
QPixmap pm,pm1, pm2;
|
||||||
QSize size;
|
QSize size;
|
||||||
int tiles_per_row;
|
int tiles_per_row;
|
||||||
};
|
};
|
||||||
@@ -326,6 +334,8 @@ public:
|
|||||||
void displayMessages(bool block);
|
void displayMessages(bool block);
|
||||||
void putMessage(int attr, const char* text);
|
void putMessage(int attr, const char* text);
|
||||||
void clearMessages();
|
void clearMessages();
|
||||||
|
|
||||||
|
void clickCursor();
|
||||||
};
|
};
|
||||||
|
|
||||||
class NetHackQtScrollText;
|
class NetHackQtScrollText;
|
||||||
@@ -717,6 +727,7 @@ protected:
|
|||||||
private slots:
|
private slots:
|
||||||
void layout();
|
void layout();
|
||||||
void raiseMap();
|
void raiseMap();
|
||||||
|
void zoomMap();
|
||||||
void raiseMessages();
|
void raiseMessages();
|
||||||
void raiseStatus();
|
void raiseStatus();
|
||||||
|
|
||||||
|
|||||||
@@ -594,6 +594,7 @@ NetHackQtSettings::NetHackQtSettings(int w, int h) :
|
|||||||
tileheight(TILEHMIN,64,1,this),
|
tileheight(TILEHMIN,64,1,this),
|
||||||
widthlbl(&tilewidth,"&Width:",this),
|
widthlbl(&tilewidth,"&Width:",this),
|
||||||
heightlbl(&tileheight,"&Height:",this),
|
heightlbl(&tileheight,"&Height:",this),
|
||||||
|
whichsize("&Zoomed",this),
|
||||||
fontsize(this),
|
fontsize(this),
|
||||||
normal("times"),
|
normal("times"),
|
||||||
#ifdef WS_WIN
|
#ifdef WS_WIN
|
||||||
@@ -664,6 +665,7 @@ NetHackQtSettings::NetHackQtSettings(int w, int h) :
|
|||||||
|
|
||||||
connect(&tilewidth,SIGNAL(valueChanged(int)),this,SLOT(resizeTiles()));
|
connect(&tilewidth,SIGNAL(valueChanged(int)),this,SLOT(resizeTiles()));
|
||||||
connect(&tileheight,SIGNAL(valueChanged(int)),this,SLOT(resizeTiles()));
|
connect(&tileheight,SIGNAL(valueChanged(int)),this,SLOT(resizeTiles()));
|
||||||
|
connect(&whichsize,SIGNAL(toggled(bool)),this,SLOT(setGlyphSize(bool)));
|
||||||
|
|
||||||
fontsize.insertItem("Huge");
|
fontsize.insertItem("Huge");
|
||||||
fontsize.insertItem("Large");
|
fontsize.insertItem("Large");
|
||||||
@@ -673,17 +675,18 @@ NetHackQtSettings::NetHackQtSettings(int w, int h) :
|
|||||||
fontsize.setCurrentItem(default_fontsize);
|
fontsize.setCurrentItem(default_fontsize);
|
||||||
connect(&fontsize,SIGNAL(activated(int)),this,SIGNAL(fontChanged()));
|
connect(&fontsize,SIGNAL(activated(int)),this,SIGNAL(fontChanged()));
|
||||||
|
|
||||||
QGridLayout* grid = new QGridLayout(this, 4, 2, 8);
|
QGridLayout* grid = new QGridLayout(this, 5, 2, 8);
|
||||||
grid->addWidget(&tilewidth, 0, 1); grid->addWidget(&widthlbl, 0, 0);
|
grid->addMultiCellWidget(&whichsize, 0, 0, 0, 1);
|
||||||
grid->addWidget(&tileheight, 1, 1); grid->addWidget(&heightlbl, 1, 0);
|
grid->addWidget(&tilewidth, 1, 1); grid->addWidget(&widthlbl, 1, 0);
|
||||||
|
grid->addWidget(&tileheight, 2, 1); grid->addWidget(&heightlbl, 2, 0);
|
||||||
QLabel* flabel=new QLabel(&fontsize, "&Font:",this);
|
QLabel* flabel=new QLabel(&fontsize, "&Font:",this);
|
||||||
grid->addWidget(flabel, 2, 0); grid->addWidget(&fontsize, 2, 1);
|
grid->addWidget(flabel, 3, 0); grid->addWidget(&fontsize, 3, 1);
|
||||||
QPushButton* dismiss=new QPushButton("Dismiss",this);
|
QPushButton* dismiss=new QPushButton("Dismiss",this);
|
||||||
dismiss->setDefault(TRUE);
|
dismiss->setDefault(TRUE);
|
||||||
grid->addMultiCellWidget(dismiss, 3, 3, 0, 1);
|
grid->addMultiCellWidget(dismiss, 4, 4, 0, 1);
|
||||||
grid->setRowStretch(3,0);
|
grid->setRowStretch(4,0);
|
||||||
grid->setColStretch(0,1);
|
grid->setColStretch(1,1);
|
||||||
grid->setColStretch(1,2);
|
grid->setColStretch(2,2);
|
||||||
grid->activate();
|
grid->activate();
|
||||||
|
|
||||||
connect(dismiss,SIGNAL(clicked()),this,SLOT(accept()));
|
connect(dismiss,SIGNAL(clicked()),this,SLOT(accept()));
|
||||||
@@ -700,10 +703,30 @@ void NetHackQtSettings::resizeTiles()
|
|||||||
int w = tilewidth.value();
|
int w = tilewidth.value();
|
||||||
int h = tileheight.value();
|
int h = tileheight.value();
|
||||||
|
|
||||||
theglyphs->resize(w,h);
|
theglyphs->setSize(w,h);
|
||||||
emit tilesChanged();
|
emit tilesChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetHackQtSettings::toggleGlyphSize()
|
||||||
|
{
|
||||||
|
whichsize.toggle();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetHackQtSettings::setGlyphSize(bool which)
|
||||||
|
{
|
||||||
|
QSize n = QSize(tilewidth.value(),tileheight.value());
|
||||||
|
if ( othersize.isValid() ) {
|
||||||
|
tilewidth.blockSignals(TRUE);
|
||||||
|
tileheight.blockSignals(TRUE);
|
||||||
|
tilewidth.setValue(othersize.width());
|
||||||
|
tileheight.setValue(othersize.height());
|
||||||
|
tileheight.blockSignals(FALSE);
|
||||||
|
tilewidth.blockSignals(FALSE);
|
||||||
|
resizeTiles();
|
||||||
|
}
|
||||||
|
othersize = n;
|
||||||
|
}
|
||||||
|
|
||||||
const QFont& NetHackQtSettings::normalFont()
|
const QFont& NetHackQtSettings::normalFont()
|
||||||
{
|
{
|
||||||
static int size[]={ 18, 14, 12, 10, 8 };
|
static int size[]={ 18, 14, 12, 10, 8 };
|
||||||
@@ -1528,6 +1551,12 @@ void NetHackQtMapWindow::Clear()
|
|||||||
change.add(0,0,COLNO,ROWNO);
|
change.add(0,0,COLNO,ROWNO);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetHackQtMapWindow::clickCursor()
|
||||||
|
{
|
||||||
|
clicksink.Put(cursor.x(),cursor.y(),CLICK_1);
|
||||||
|
qApp->exit_loop();
|
||||||
|
}
|
||||||
|
|
||||||
void NetHackQtMapWindow::mousePressEvent(QMouseEvent* event)
|
void NetHackQtMapWindow::mousePressEvent(QMouseEvent* event)
|
||||||
{
|
{
|
||||||
clicksink.Put(
|
clicksink.Put(
|
||||||
@@ -3735,9 +3764,18 @@ NetHackQtMainWindow::NetHackQtMainWindow(NetHackQtKeyBuffer& ks) :
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NetHackQtMainWindow::zoomMap()
|
||||||
|
{
|
||||||
|
qt_settings->toggleGlyphSize();
|
||||||
|
}
|
||||||
|
|
||||||
void NetHackQtMainWindow::raiseMap()
|
void NetHackQtMainWindow::raiseMap()
|
||||||
{
|
{
|
||||||
stack->raiseWidget(0);
|
if ( stack->id(stack->visibleWidget()) == 0 ) {
|
||||||
|
zoomMap();
|
||||||
|
} else {
|
||||||
|
stack->raiseWidget(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtMainWindow::raiseMessages()
|
void NetHackQtMainWindow::raiseMessages()
|
||||||
@@ -3950,6 +3988,14 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
|
|||||||
break; case Key_Next:
|
break; case Key_Next:
|
||||||
dirkey = 0;
|
dirkey = 0;
|
||||||
if (message) message->Scroll(0,+1);
|
if (message) message->Scroll(0,+1);
|
||||||
|
break; case Key_Space:
|
||||||
|
if ( flags.rest_on_space ) {
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
case Key_Enter:
|
||||||
|
if ( map )
|
||||||
|
map->clickCursor();
|
||||||
break; default:
|
break; default:
|
||||||
dirkey = 0;
|
dirkey = 0;
|
||||||
event->ignore();
|
event->ignore();
|
||||||
@@ -4237,7 +4283,7 @@ NetHackQtGlyphs::NetHackQtGlyphs()
|
|||||||
else
|
else
|
||||||
tilefile_tile_H = tilefile_tile_W;
|
tilefile_tile_H = tilefile_tile_W;
|
||||||
|
|
||||||
resize(tilefile_tile_W, tilefile_tile_H);
|
setSize(tilefile_tile_W, tilefile_tile_H);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
|
void NetHackQtGlyphs::drawGlyph(QPainter& painter, int glyph, int x, int y)
|
||||||
@@ -4258,12 +4304,25 @@ void NetHackQtGlyphs::drawCell(QPainter& painter, int glyph, int cellx, int cell
|
|||||||
{
|
{
|
||||||
drawGlyph(painter,glyph,cellx*width(),celly*height());
|
drawGlyph(painter,glyph,cellx*width(),celly*height());
|
||||||
}
|
}
|
||||||
void NetHackQtGlyphs::resize(int w, int h)
|
void NetHackQtGlyphs::setSize(int w, int h)
|
||||||
{
|
{
|
||||||
|
if ( size == QSize(w,h) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
bool was1 = size == pm1.size();
|
||||||
size = QSize(w,h);
|
size = QSize(w,h);
|
||||||
if (!w || !h)
|
if (!w || !h)
|
||||||
return; // Still not decided
|
return; // Still not decided
|
||||||
|
|
||||||
|
if ( size == pm1.size() ) {
|
||||||
|
pm = pm1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ( size == pm2.size() ) {
|
||||||
|
pm = pm2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (w==tilefile_tile_W && h==tilefile_tile_H) {
|
if (w==tilefile_tile_W && h==tilefile_tile_H) {
|
||||||
pm.convertFromImage(img);
|
pm.convertFromImage(img);
|
||||||
} else {
|
} else {
|
||||||
@@ -4275,6 +4334,7 @@ void NetHackQtGlyphs::resize(int w, int h)
|
|||||||
pm.convertFromImage(scaled,Qt::ThresholdDither|Qt::PreferDither);
|
pm.convertFromImage(scaled,Qt::ThresholdDither|Qt::PreferDither);
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
(was1 ? pm2 : pm1) = pm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user