asciiquarium: Convert to tqt3 library.

Signed-off-by: gregory guy <gregory-tde@laposte.net>
pull/16/head
gregory guy 3 years ago
parent 212bd4dc33
commit 1837fdeebf
No known key found for this signature in database
GPG Key ID: 2CC84A1CC6823AF8

@ -39,9 +39,9 @@
#include <klocale.h> #include <klocale.h>
#include <kconfigdialog.h> #include <kconfigdialog.h>
#include <qdesktopwidget.h> #include <ntqdesktopwidget.h>
#include <qpainter.h> #include <ntqpainter.h>
#include <qbrush.h> #include <ntqbrush.h>
#include "screen.h" #include "screen.h"
#include "frame.h" #include "frame.h"
@ -68,7 +68,7 @@ AASaver::AASaver( WId id ): KScreenSaver(id)
} }
QString AASaver::randColor(QString color_mask) TQString AASaver::randColor(TQString color_mask)
{ {
char colors[] = {'c','C','r','R','y','Y','b','B','g','G','m','M'}; char colors[] = {'c','C','r','R','y','Y','b','B','g','G','m','M'};
for (int i = 1; i <= 9; ++i) for (int i = 1; i <= 9; ++i)
@ -81,7 +81,7 @@ QString AASaver::randColor(QString color_mask)
void AASaver::addCastle() void AASaver::addCastle()
{ {
QString castle_image = TQString castle_image =
" T~~\n" " T~~\n"
" |\n" " |\n"
" /^\\\n" " /^\\\n"
@ -97,7 +97,7 @@ void AASaver::addCastle()
" |_______|__|_|_|_|__|_______|\n"; " |_______|__|_|_|_|__|_______|\n";
QString castle_mask = TQString castle_mask =
" RR\n" " RR\n"
"\n" "\n"
" yyy\n" " yyy\n"
@ -122,7 +122,7 @@ void AASaver::addCastle()
void AASaver::addEnvironment() void AASaver::addEnvironment()
{ {
QString water_line_segment[] = { TQString water_line_segment[] = {
"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~",
"^^^^ ^^^ ^^^ ^^^ ^^^^ ", "^^^^ ^^^ ^^^ ^^^ ^^^^ ",
"^^^^ ^^^^ ^^^ ^^ ", "^^^^ ^^^^ ^^^ ^^ ",
@ -135,13 +135,13 @@ void AASaver::addEnvironment()
for (unsigned i = 0; i < ARRAY_SIZE(water_line_segment); ++i) { for (unsigned i = 0; i < ARRAY_SIZE(water_line_segment); ++i) {
//do the tiling //do the tiling
QString out; TQString out;
for (int r = 0; r < segment_repeat; ++r) for (int r = 0; r < segment_repeat; ++r)
out += water_line_segment[i]; out += water_line_segment[i];
//create a sprite. //create a sprite.
Sprite* s = new Sprite(screen, 0, i + 5, 22); Sprite* s = new Sprite(screen, 0, i + 5, 22);
s->addFrame(Frame(out, QString::null, 0x149494)); s->addFrame(Frame(out, TQString::null, 0x149494));
screen->addSprite(s); screen->addSprite(s);
} }
} }
@ -197,7 +197,7 @@ public:
void AASaver::addSeaweed(Screen* screen) void AASaver::addSeaweed(Screen* screen)
{ {
QString seaweed_image[] = {"", ""}; TQString seaweed_image[] = {"", ""};
int height = intRand(5) + 3; int height = intRand(5) + 3;
for (int i = 1; i <= height; ++i) for (int i = 1; i <= height; ++i)
{ {
@ -212,8 +212,8 @@ void AASaver::addSeaweed(Screen* screen)
Seaweed* s = new Seaweed(screen, x, y, Seaweed* s = new Seaweed(screen, x, y,
intRand(4*60000) + (8*60000)); // seaweed lives for 8 to 12 minutes intRand(4*60000) + (8*60000)); // seaweed lives for 8 to 12 minutes
s->addFrame(Frame(seaweed_image[0], QString::null, 0x18AF18)); s->addFrame(Frame(seaweed_image[0], TQString::null, 0x18AF18));
s->addFrame(Frame(seaweed_image[1], QString::null, 0x18AF18)); s->addFrame(Frame(seaweed_image[1], TQString::null, 0x18AF18));
s->setFrameDelay(intRand(50) + 250); s->setFrameDelay(intRand(50) + 250);
screen->addSprite(s); screen->addSprite(s);
} }
@ -239,9 +239,9 @@ public:
AirBubble(Screen *screen, int x, int y, int z) : AirBubble(Screen *screen, int x, int y, int z) :
Sprite(screen, x, y, z), m_startY(y) Sprite(screen, x, y, z), m_startY(y)
{ {
addFrame(Frame(".", QString(), 0x18B2B2)); addFrame(Frame(".", TQString(), 0x18B2B2));
addFrame(Frame("o", QString(), 0x18B2B2)); addFrame(Frame("o", TQString(), 0x18B2B2));
addFrame(Frame("O", QString(), 0x18B2B2)); addFrame(Frame("O", TQString(), 0x18B2B2));
setFrameDelay(100); setFrameDelay(100);
} }
@ -423,12 +423,12 @@ public:
if(isKilled()) if(isKilled())
return true; return true;
if(QABS(realX() - m_lastBubbleRelease) >= m_spacesPerBubble) if(TQABS(realX() - m_lastBubbleRelease) >= m_spacesPerBubble)
{ {
m_lastBubbleRelease = realX(); m_lastBubbleRelease = realX();
int bubbleX = m_x; int bubbleX = m_x;
QRect geometry = geom(); TQRect geometry = geom();
if(m_direct > 0) // Moving right if(m_direct > 0) // Moving right
bubbleX += geometry.width(); bubbleX += geometry.width();
@ -446,7 +446,7 @@ void AASaver::addAllFish()
// many we'd be dealing with in full screen, and then scale the user's // many we'd be dealing with in full screen, and then scale the user's
// number down to adjust so that we look about the same in a window as we // number down to adjust so that we look about the same in a window as we
// do fullscreen. TODO: Xinerama issues? // do fullscreen. TODO: Xinerama issues?
QRect fullScreenGeometry = kapp->desktop()->screenGeometry(); TQRect fullScreenGeometry = kapp->desktop()->screenGeometry();
int full_width = fullScreenGeometry.width() / screen->cellWidth(); int full_width = fullScreenGeometry.width() / screen->cellWidth();
int full_height = fullScreenGeometry.height() / screen->cellHeight() - 9; int full_height = fullScreenGeometry.height() / screen->cellHeight() - 9;
@ -463,7 +463,7 @@ void AASaver::addAllFish()
Sprite *AASaver::newFish(Screen *screen) Sprite *AASaver::newFish(Screen *screen)
{ {
QString fish_image[] = { TQString fish_image[] = {
" \\\n" " \\\n"
" ...\\..,\n" " ...\\..,\n"
"\\" "??" "/' \\\n" // trigraphs suck "\\" "??" "/' \\\n" // trigraphs suck
@ -656,7 +656,7 @@ Sprite *AASaver::newFish(Screen *screen)
double speed = doubleRand(2) + 0.25; double speed = doubleRand(2) + 0.25;
int depth = 3 + intRand(18); int depth = 3 + intRand(18);
QString color_mask = fish_image[fish_index+1]; TQString color_mask = fish_image[fish_index+1];
color_mask.replace('4', 'W'); color_mask.replace('4', 'W');
color_mask = randColor(color_mask); color_mask = randColor(color_mask);
@ -702,10 +702,10 @@ public:
* @param center The point to center the splat around. * @param center The point to center the splat around.
* @param depth The depth to create the splat at. * @param depth The depth to create the splat at.
*/ */
Splat(Screen *screen, QPoint center, int depth) : Splat(Screen *screen, TQPoint center, int depth) :
Sprite(screen, 0, 0, depth, 450 /* frame Delay */) Sprite(screen, 0, 0, depth, 450 /* frame Delay */)
{ {
QString splats[] = { TQString splats[] = {
"\n" "\n"
" .\n" " .\n"
" ***\n" " ***\n"
@ -733,9 +733,9 @@ public:
}; };
for(unsigned i = 0; i < ARRAY_SIZE(splats); ++i) for(unsigned i = 0; i < ARRAY_SIZE(splats); ++i)
addFrame(Frame(splats[i], QString(), 0xB21818, ' ')); addFrame(Frame(splats[i], TQString(), 0xB21818, ' '));
QRect r(center, QSize(9, 5)); TQRect r(center, TQSize(9, 5));
r.moveCenter(center); r.moveCenter(center);
m_x = r.x(); m_x = r.x();
m_y = r.y(); m_y = r.y();
@ -766,7 +766,7 @@ public:
if(m_direct > 0) // Moving to right. if(m_direct > 0) // Moving to right.
m_realX = -10; m_realX = -10;
addFrame(Frame("????????", QString(), 0)); addFrame(Frame("????????", TQString(), 0));
} }
/// Returns true since we can collide. /// Returns true since we can collide.
@ -794,7 +794,7 @@ public:
void AASaver::addShark(Screen* screen) void AASaver::addShark(Screen* screen)
{ {
QString shark_image[] = { TQString shark_image[] = {
" __\n" " __\n"
" ( `\\\n" " ( `\\\n"
" ,??????????????????????????" ") `\\\n" // trigraphs suck " ,??????????????????????????" ") `\\\n" // trigraphs suck
@ -842,7 +842,7 @@ void AASaver::addShark(Screen* screen)
int shark_num = intRand(ARRAY_SIZE(shark_image)/2); int shark_num = intRand(ARRAY_SIZE(shark_image)/2);
int shark_index = shark_num * 2; int shark_index = shark_num * 2;
QString color_mask = randColor(shark_image[shark_index+1]); TQString color_mask = randColor(shark_image[shark_index+1]);
Frame sharkFrame(shark_image[shark_index], color_mask, 0x18B2B2); Frame sharkFrame(shark_image[shark_index], color_mask, 0x18B2B2);
int x = -53; int x = -53;
@ -867,7 +867,7 @@ void AASaver::addBubble(Screen *screen, int x, int y, int z)
void AASaver::addShip(Screen* screen) void AASaver::addShip(Screen* screen)
{ {
QString ship_image[] = { TQString ship_image[] = {
" | | |\n" " | | |\n"
" )_) )_) )_)\n" " )_) )_) )_)\n"
" )___))___))___)\\\n" " )___))___))___)\\\n"
@ -912,7 +912,7 @@ void AASaver::addShip(Screen* screen)
void AASaver::addWhale(Screen* screen) void AASaver::addWhale(Screen* screen)
{ {
QString whale_image[] = { TQString whale_image[] = {
" .-----:\n" " .-----:\n"
" .' `.\n" " .' `.\n"
",????/ (o) \\\n" ",????/ (o) \\\n"
@ -940,7 +940,7 @@ void AASaver::addWhale(Screen* screen)
"BBBB BBBBB" "BBBB BBBBB"
}; };
QString spouty[] = { TQString spouty[] = {
"\n" "\n"
"\n" "\n"
" :", " :",
@ -980,30 +980,30 @@ void AASaver::addWhale(Screen* screen)
dir = -1; dir = -1;
} }
QString mask = whale_image[2 * whale_num + 1]; TQString mask = whale_image[2 * whale_num + 1];
RandomMovingSprite *whale = new RandomMovingSprite(screen, dir, 1.0, x, 0, 2); RandomMovingSprite *whale = new RandomMovingSprite(screen, dir, 1.0, x, 0, 2);
whale->setFrameDelay(80); whale->setFrameDelay(80);
whale->setFrameTime(40); whale->setFrameTime(40);
// We have to add some frames now. The first five will have no water spout. // We have to add some frames now. The first five will have no water spout.
QString blankWhaleFrame = QString("\n\n\n") + whale_image[2 * whale_num]; TQString blankWhaleFrame = TQString("\n\n\n") + whale_image[2 * whale_num];
for(unsigned i = 0; i < 5; ++i) for(unsigned i = 0; i < 5; ++i)
whale->addFrame(Frame(blankWhaleFrame, mask, 0xFFFFFF)); whale->addFrame(Frame(blankWhaleFrame, mask, 0xFFFFFF));
// Now add frames for the animated water spout. // Now add frames for the animated water spout.
QString whaleFrame = whale_image[2 * whale_num]; TQString whaleFrame = whale_image[2 * whale_num];
for (unsigned i = 0; i < ARRAY_SIZE(spouty); ++i) for (unsigned i = 0; i < ARRAY_SIZE(spouty); ++i)
{ {
QStringList spoutLines = QStringList::split("\n", spouty[i], true); TQStringList spoutLines = TQStringList::split("\n", spouty[i], true);
QString spout; TQString spout;
QString padding; TQString padding;
padding.fill(' ', spout_align); padding.fill(' ', spout_align);
// Move spout over an appropriate distance to line up right. // Move spout over an appropriate distance to line up right.
for(QStringList::ConstIterator it = spoutLines.begin(); it != spoutLines.end(); ++it) for(TQStringList::ConstIterator it = spoutLines.begin(); it != spoutLines.end(); ++it)
{ {
spout += padding; spout += padding;
spout += *it; spout += *it;
@ -1019,7 +1019,7 @@ void AASaver::addWhale(Screen* screen)
void AASaver::addBigFish(Screen* screen) void AASaver::addBigFish(Screen* screen)
{ {
QString big_fish_image[] = { TQString big_fish_image[] = {
" ______\n" " ______\n"
"`\"\"-. `````-----.....__\n" "`\"\"-. `````-----.....__\n"
" `. . . `-.\n" " `. . . `-.\n"
@ -1093,7 +1093,7 @@ void AASaver::addBigFish(Screen* screen)
dir = -1; dir = -1;
} }
QString colors = randColor(big_fish_image[2 * big_fish_num + 1]); TQString colors = randColor(big_fish_image[2 * big_fish_num + 1]);
RandomMovingSprite *bigFish = new RandomMovingSprite(screen, dir, 3.0, x, y, 2); RandomMovingSprite *bigFish = new RandomMovingSprite(screen, dir, 3.0, x, y, 2);
bigFish->addFrame(Frame(big_fish_image[2 * big_fish_num], colors, 0xFFFF54)); bigFish->addFrame(Frame(big_fish_image[2 * big_fish_num], colors, 0xFFFF54));
@ -1102,7 +1102,7 @@ void AASaver::addBigFish(Screen* screen)
void AASaver::addNessie(Screen* screen) void AASaver::addNessie(Screen* screen)
{ {
QString nessie_image[] = { TQString nessie_image[] = {
" ____\n" " ____\n"
" __??????????????????????????????????????????/ o \\\n" " __??????????????????????????????????????????/ o \\\n"
" / \\????????_?????????????????????_???????/ ____ >\n" " / \\????????_?????????????????????_???????/ ____ >\n"
@ -1152,7 +1152,7 @@ void AASaver::addNessie(Screen* screen)
" | |????/ \\?????| |????| || |???| |?????/ /" " | |????/ \\?????| |????| || |???| |?????/ /"
}; };
QString nessie_mask[] = { TQString nessie_mask[] = {
"\n" "\n"
" W\n" " W\n"
"\n" "\n"
@ -1220,7 +1220,7 @@ void AASaver::addRandom(Screen* screen)
} }
} }
void AASaver::paintEvent(QPaintEvent* pe) void AASaver::paintEvent(TQPaintEvent* pe)
{ {
screen->paint(pe->region()); screen->paint(pe->region());
} }
@ -1237,7 +1237,7 @@ extern "C"
return new AASaver( id ); return new AASaver( id );
} }
KDE_EXPORT QDialog *kss_setup() KDE_EXPORT TQDialog *kss_setup()
{ {
KConfigDialog *dialog = KConfigDialog::exists("settings"); KConfigDialog *dialog = KConfigDialog::exists("settings");
if(dialog) if(dialog)

@ -58,7 +58,7 @@ class Sprite;
* examples for creating a Frame. * examples for creating a Frame.
* *
* The Frame supports transparency and colors, and will convert the textual data * The Frame supports transparency and colors, and will convert the textual data
* into a QPixmap representation on demand in order to reduce CPU load (at the * into a TQPixmap representation on demand in order to reduce CPU load (at the
* expense of a slight memory usage increase for each sprite). * expense of a slight memory usage increase for each sprite).
* *
* Screen handles the timing for the project, and at each timeout will call * Screen handles the timing for the project, and at each timeout will call
@ -93,10 +93,10 @@ public:
} }
/** /**
* Returns a QString holding a color mask, created by choosing random colors * Returns a TQString holding a color mask, created by choosing random colors
* to replace numbers in \p color_mask. * to replace numbers in \p color_mask.
*/ */
static QString randColor(QString color_mask); static TQString randColor(TQString color_mask);
/// Adds the castle sprite to the screen. /// Adds the castle sprite to the screen.
void addCastle(); void addCastle();
@ -191,7 +191,7 @@ public:
/** /**
* Reimplemented to update the widget when it gets dirty. * Reimplemented to update the widget when it gets dirty.
*/ */
virtual void paintEvent(QPaintEvent* pe); virtual void paintEvent(TQPaintEvent* pe);
}; };
#endif /* AA_AASAVER_H */ #endif /* AA_AASAVER_H */

@ -28,12 +28,12 @@
#include <kglobalsettings.h> #include <kglobalsettings.h>
#include <kdebug.h> #include <kdebug.h>
#include <qvaluevector.h> #include <ntqvaluevector.h>
#include <qstringlist.h> #include <ntqstringlist.h>
#include <qimage.h> #include <ntqimage.h>
#include <qfontmetrics.h> #include <ntqfontmetrics.h>
#include <qpainter.h> #include <ntqpainter.h>
#include <qbitmap.h> #include <ntqbitmap.h>
#include "frame.h" #include "frame.h"
@ -45,22 +45,22 @@ void Frame::convertDataToPixmap(const Screen *screen)
} }
int w = screen->cellWidth(), h = screen->cellHeight(); int w = screen->cellWidth(), h = screen->cellHeight();
QPixmap pix(width() * w, height() * h); TQPixmap pix(width() * w, height() * h);
pix.fill(); pix.fill();
QBitmap mask(pix.size(), true); TQBitmap mask(pix.size(), true);
QPainter p, p2; TQPainter p, p2;
p.begin(&pix, true); p.begin(&pix, true);
p2.begin(&mask, true); p2.begin(&mask, true);
p.setFont(KGlobalSettings::fixedFont()); p.setFont(KGlobalSettings::fixedFont());
QFontMetrics fm(p.font()); TQFontMetrics fm(p.font());
int leadHeight = fm.leading() + fm.descent(); int leadHeight = fm.leading() + fm.descent();
for(unsigned j = 0; j < m_data.count(); ++j) { for(unsigned j = 0; j < m_data.count(); ++j) {
QValueVector<Screen::Pixel> row = m_data[j]; TQValueVector<Screen::Pixel> row = m_data[j];
if(row.isEmpty()) if(row.isEmpty())
continue; continue;
@ -74,18 +74,18 @@ void Frame::convertDataToPixmap(const Screen *screen)
if(row[i].letter == m_transparentChar) if(row[i].letter == m_transparentChar)
continue; continue;
p2.fillRect(i * w, j * h, w, h, Qt::color1); p2.fillRect(i * w, j * h, w, h, TQt::color1);
p.setPen(row[i].color); p.setPen(row[i].color);
p.fillRect(i * w, j * h, w, h, Qt::black); p.fillRect(i * w, j * h, w, h, TQt::black);
p.drawText(i * w, j * h + (h - 1 - leadHeight), QChar(row[i].letter)); p.drawText(i * w, j * h + (h - 1 - leadHeight), TQChar(row[i].letter));
} }
} }
pix.setMask(mask); pix.setMask(mask);
QPixmap erase(pix); TQPixmap erase(pix);
erase.fill(Qt::black); erase.fill(TQt::black);
erase.setMask(mask); erase.setMask(mask);
m_pixmap = pix; m_pixmap = pix;
@ -95,18 +95,18 @@ void Frame::convertDataToPixmap(const Screen *screen)
m_data.clear(); m_data.clear();
} }
Frame::Frame (QString text, QString mask, QRgb defaultColor, QChar transparent) Frame::Frame (TQString text, TQString mask, TQRgb defaultColor, TQChar transparent)
{ {
//First, process the pixels. //First, process the pixels.
QStringList rows = QStringList::split('\n', text, true); TQStringList rows = TQStringList::split('\n', text, true);
m_height = rows.size(); m_height = rows.size();
m_width = 0; m_width = 0;
m_transparentChar = transparent; m_transparentChar = transparent;
for (QStringList::iterator i = rows.begin(); i != rows.end(); ++i) for (TQStringList::iterator i = rows.begin(); i != rows.end(); ++i)
{ {
QValueVector<Screen::Pixel> row; TQValueVector<Screen::Pixel> row;
for (int pos = 0; pos < (*i).length(); ++pos) for (int pos = 0; pos < (*i).length(); ++pos)
{ {
Screen::Pixel p; Screen::Pixel p;
@ -115,14 +115,14 @@ Frame::Frame (QString text, QString mask, QRgb defaultColor, QChar transparent)
row.append(p); row.append(p);
} }
m_width = QMAX(m_width, row.size()); m_width = TQMAX(m_width, row.size());
m_data.append(row); m_data.append(row);
} }
//Now, the colors. //Now, the colors.
QStringList cols = QStringList::split('\n', mask, true); TQStringList cols = TQStringList::split('\n', mask, true);
int y = 0; int y = 0;
for (QStringList::iterator i = cols.begin(); i != cols.end(); ++i) for (TQStringList::iterator i = cols.begin(); i != cols.end(); ++i)
{ {
if (y >= m_data.size()) if (y >= m_data.size())
break; break;
@ -177,7 +177,7 @@ Frame::Frame (QString text, QString mask, QRgb defaultColor, QChar transparent)
case ' ': case ' ':
break; break;
default: default:
qDebug("dunno about color code:'%c'", (*i).at(pos).unicode()); tqDebug("dunno about color code:'%c'", (*i).at(pos).unicode());
m_data[y][pos].color = 0xFFFFFF; m_data[y][pos].color = 0xFFFFFF;
} }
} }

@ -28,9 +28,9 @@
#ifndef AA_FRAME_H #ifndef AA_FRAME_H
#define AA_FRAME_H #define AA_FRAME_H
#include <qstring.h> #include <ntqstring.h>
#include <qvaluevector.h> #include <ntqvaluevector.h>
#include <qpixmap.h> #include <ntqpixmap.h>
#include "screen.h" #include "screen.h"
/** /**
@ -47,13 +47,13 @@ class Frame
* *
* @see Pixel * @see Pixel
*/ */
QValueVector<QValueVector<Screen::Pixel> > m_data; TQValueVector<TQValueVector<Screen::Pixel> > m_data;
/// Masked pixmap of the animation frame. Created by convertDataToPixmap(). /// Masked pixmap of the animation frame. Created by convertDataToPixmap().
QPixmap m_pixmap; TQPixmap m_pixmap;
/// Masked pixmap used to clear frame. Created by convertDataToPixmap(). /// Masked pixmap used to clear frame. Created by convertDataToPixmap().
QPixmap m_erasePixmap; TQPixmap m_erasePixmap;
/// Height of this frame of animation in logical coordinates. /// Height of this frame of animation in logical coordinates.
int m_height; int m_height;
@ -63,7 +63,7 @@ class Frame
/// Character to be used as a special 'transparent' character. Normally is /// Character to be used as a special 'transparent' character. Normally is
/// the '?' character. /// the '?' character.
QChar m_transparentChar; TQChar m_transparentChar;
public: public:
@ -100,7 +100,7 @@ public:
* auto-transparency feature can't detect transparent * auto-transparency feature can't detect transparent
* areas. * areas.
*/ */
Frame(QString text, QString mask, QRgb defaultColor, QChar transparent = '?'); Frame(TQString text, TQString mask, TQRgb defaultColor, TQChar transparent = '?');
/** /**
* Paints this Frame into the given screen. * Paints this Frame into the given screen.

@ -25,12 +25,12 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
#include <qcolor.h> #include <ntqcolor.h>
#include <qfontmetrics.h> #include <ntqfontmetrics.h>
#include <qpainter.h> #include <ntqpainter.h>
#include <qpixmap.h> #include <ntqpixmap.h>
#include <qtimer.h> #include <ntqtimer.h>
#include <qwidget.h> #include <ntqwidget.h>
#include <kglobalsettings.h> #include <kglobalsettings.h>
@ -40,7 +40,7 @@
Screen::Screen(AASaver* widget): m_widget(widget) Screen::Screen(AASaver* widget): m_widget(widget)
{ {
QFontMetrics fm(KGlobalSettings::fixedFont()); TQFontMetrics fm(KGlobalSettings::fixedFont());
// Compute cell geometries. // Compute cell geometries.
m_cellW = fm.maxWidth(); m_cellW = fm.maxWidth();
@ -55,13 +55,13 @@ Screen::Screen(AASaver* widget): m_widget(widget)
m_offY = (widget->height() - m_height * m_cellH) / 2; m_offY = (widget->height() - m_height * m_cellH) / 2;
// Create double buffer. // Create double buffer.
m_backBuffer = QPixmap(m_widget->size()); m_backBuffer = TQPixmap(m_widget->size());
m_backBuffer.fill(black); m_backBuffer.fill(black);
// FIXME: handle resizing! // FIXME: handle resizing!
// Setup animation timer. // Setup animation timer.
QTimer* timer = new QTimer(this); TQTimer* timer = new TQTimer(this);
connect(timer, SIGNAL(timeout()), SLOT(doAnimate())); connect(timer, SIGNAL(timeout()), SLOT(doAnimate()));
timer->start(msPerTick()); timer->start(msPerTick());
@ -76,36 +76,36 @@ Screen::~Screen()
{ {
} }
void Screen::updateSpan(int x, int y, const QPixmap &updatePixmap) void Screen::updateSpan(int x, int y, const TQPixmap &updatePixmap)
{ {
if (y < 0 || y >= m_height) return; if (y < 0 || y >= m_height) return;
QPoint upperLeft(m_offX + x * m_cellW, m_offY + y * m_cellH); TQPoint upperLeft(m_offX + x * m_cellW, m_offY + y * m_cellH);
bitBlt(&m_backBuffer, upperLeft, &updatePixmap, updatePixmap.rect(), Qt::CopyROP); bitBlt(&m_backBuffer, upperLeft, &updatePixmap, updatePixmap.rect(), TQt::CopyROP);
m_widget->update(QRect(upperLeft, updatePixmap.size())); m_widget->update(TQRect(upperLeft, updatePixmap.size()));
} }
void Screen::clearSpan(int x, int y, const QPixmap &clearPixmap) void Screen::clearSpan(int x, int y, const TQPixmap &clearPixmap)
{ {
if (y < 0 || y >= m_height) return; if (y < 0 || y >= m_height) return;
QPoint upperLeft(m_offX + x * m_cellW, m_offY + y * m_cellH); TQPoint upperLeft(m_offX + x * m_cellW, m_offY + y * m_cellH);
bitBlt(&m_backBuffer, upperLeft, &clearPixmap, clearPixmap.rect(), Qt::CopyROP); bitBlt(&m_backBuffer, upperLeft, &clearPixmap, clearPixmap.rect(), TQt::CopyROP);
m_widget->update(QRect(upperLeft, clearPixmap.size())); m_widget->update(TQRect(upperLeft, clearPixmap.size()));
} }
//Actually paints the region on the widget. //Actually paints the region on the widget.
void Screen::paint(QRegion r) void Screen::paint(TQRegion r)
{ {
QPainter p(m_widget); TQPainter p(m_widget);
QMemArray<QRect> rects = r.rects(); TQMemArray<TQRect> rects = r.rects();
for (int r = 0; r < rects.size(); ++r) for (int r = 0; r < rects.size(); ++r)
{ {
//Determine the grid locations described by the rect //Determine the grid locations described by the rect
QRect bound = rects[r]; TQRect bound = rects[r];
bitBlt(m_widget, bound.topLeft(), &m_backBuffer, bound, Qt::CopyROP); bitBlt(m_widget, bound.topLeft(), &m_backBuffer, bound, TQt::CopyROP);
} //for rect in region } //for rect in region
}; };
@ -141,10 +141,10 @@ struct ZKey
void Screen::doAnimate() void Screen::doAnimate()
{ {
//First, rebuild a new list of sprites, and build a dirty region //First, rebuild a new list of sprites, and build a dirty region
QRegion dirtyRegion; TQRegion dirtyRegion;
QValueVector<Sprite*> sprites; TQValueVector<Sprite*> sprites;
QValueVector<Sprite*> colliders; TQValueVector<Sprite*> colliders;
// Look for sprites that can suffer a collision. // Look for sprites that can suffer a collision.
for (unsigned pos = 0; pos < m_sprites.size(); ++pos) for (unsigned pos = 0; pos < m_sprites.size(); ++pos)
@ -169,7 +169,7 @@ void Screen::doAnimate()
for (int pos = 0; pos < m_sprites.size(); ++pos) for (int pos = 0; pos < m_sprites.size(); ++pos)
{ {
Sprite* sprite = m_sprites[pos]; Sprite* sprite = m_sprites[pos];
QRect oldRect = sprite->geom(); TQRect oldRect = sprite->geom();
if (!sprite->isKilled()) { if (!sprite->isKilled()) {
bool dirty = sprite->tickUpdate(); bool dirty = sprite->tickUpdate();
@ -199,8 +199,8 @@ void Screen::doAnimate()
//Compute the list of sprites affected. Note that this is //Compute the list of sprites affected. Note that this is
//done iteratively until fixed point. //done iteratively until fixed point.
QValueVector<Sprite*> paintSprites; TQValueVector<Sprite*> paintSprites;
QValueVector<Sprite*> remSprites; TQValueVector<Sprite*> remSprites;
bool changed; bool changed;
do do
@ -229,20 +229,20 @@ void Screen::doAnimate()
while (changed); while (changed);
//Z-sort the items. //Z-sort the items.
QMap<ZKey, Sprite* > sorted; TQMap<ZKey, Sprite* > sorted;
for (int pos = 0; pos < paintSprites.size(); ++pos) for (int pos = 0; pos < paintSprites.size(); ++pos)
sorted[ZKey(paintSprites[pos])] = paintSprites[pos]; sorted[ZKey(paintSprites[pos])] = paintSprites[pos];
//Paint, in Z-order //Paint, in Z-order
for (QMapIterator<ZKey, Sprite*> i = sorted.begin(); for (TQMapIterator<ZKey, Sprite*> i = sorted.begin();
i != sorted.end(); ++i) i != sorted.end(); ++i)
i.data()->paint(); i.data()->paint();
// Make sure black strip at edge is still present. // Make sure black strip at edge is still present.
if(!paintSprites.isEmpty()) if(!paintSprites.isEmpty())
{ {
QPainter p(&m_backBuffer); TQPainter p(&m_backBuffer);
p.fillRect(m_backBuffer.width() - m_offX, 0, m_offX, m_backBuffer.height(), Qt::black); p.fillRect(m_backBuffer.width() - m_offX, 0, m_offX, m_backBuffer.height(), TQt::black);
} }
} }

@ -28,11 +28,11 @@
#ifndef AA_SCREEN_H #ifndef AA_SCREEN_H
#define AA_SCREEN_H #define AA_SCREEN_H
#include <qcolor.h> #include <ntqcolor.h>
#include <qfont.h> #include <ntqfont.h>
#include <qobject.h> #include <ntqobject.h>
#include <qvaluevector.h> #include <ntqvaluevector.h>
#include <qpixmap.h> #include <ntqpixmap.h>
class Sprite; class Sprite;
class AASaver; class AASaver;
@ -47,7 +47,7 @@ class AASaver;
* Use addSprite() to add new Sprites to the Screen after you have created them * Use addSprite() to add new Sprites to the Screen after you have created them
* and added their Frames. * and added their Frames.
*/ */
class Screen: public QObject class Screen: public TQObject
{ {
Q_OBJECT Q_OBJECT
@ -57,7 +57,7 @@ public:
*/ */
struct Pixel { struct Pixel {
char letter; ///< Character to display in the cell. char letter; ///< Character to display in the cell.
QRgb color; ///< Color to use for the cell. TQRgb color; ///< Color to use for the cell.
/// Default constructor. /// Default constructor.
Pixel(): letter(' '), color(0) Pixel(): letter(' '), color(0)
@ -76,13 +76,13 @@ private:
* to the pixmap, which is then bitBlt()'ed to m_widget when the time comes * to the pixmap, which is then bitBlt()'ed to m_widget when the time comes
* to paint. * to paint.
*/ */
QPixmap m_backBuffer; TQPixmap m_backBuffer;
int m_cellW; ///< The GUI width of a character cell. int m_cellW; ///< The GUI width of a character cell.
int m_cellH; ///< The GUI height of a character cell. int m_cellH; ///< The GUI height of a character cell.
QValueVector<Sprite*> m_sprites; ///< List of Sprites on screen. TQValueVector<Sprite*> m_sprites; ///< List of Sprites on screen.
QValueVector<Sprite*> m_addedSprites; ///< List of Sprites to be added next frame. TQValueVector<Sprite*> m_addedSprites; ///< List of Sprites to be added next frame.
private slots: private slots:
/** /**
@ -145,7 +145,7 @@ public:
* @param updatePixmap The pixmap to draw into the buffer, which should be * @param updatePixmap The pixmap to draw into the buffer, which should be
* masked to only draw non-transparent regions. * masked to only draw non-transparent regions.
*/ */
void updateSpan(int x, int y, const QPixmap &updatePixmap); void updateSpan(int x, int y, const TQPixmap &updatePixmap);
/** /**
* Clear the given portion of the backbuffer, asks for a repaint. * Clear the given portion of the backbuffer, asks for a repaint.
@ -156,14 +156,14 @@ public:
* the background color of the Screen, and masked to * the background color of the Screen, and masked to
* only draw the area that needs cleared. * only draw the area that needs cleared.
*/ */
void clearSpan(int x, int y, const QPixmap &clearPixmap); void clearSpan(int x, int y, const TQPixmap &clearPixmap);
/** /**
* Actually paints the region on the widget. * Actually paints the region on the widget.
* *
* @param r The region of the widget to update. * @param r The region of the widget to update.
*/ */
void paint(QRegion r); void paint(TQRegion r);
}; };
#endif #endif

@ -1,6 +1,6 @@
<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> <!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>SettingsWidget</class> <class>SettingsWidget</class>
<widget class="QWidget"> <widget class="TQWidget">
<property name="name"> <property name="name">
<cstring>SettingsWidget</cstring> <cstring>SettingsWidget</cstring>
</property> </property>
@ -19,7 +19,7 @@
<property name="name"> <property name="name">
<cstring>unnamed</cstring> <cstring>unnamed</cstring>
</property> </property>
<widget class="QLabel"> <widget class="TQLabel">
<property name="name"> <property name="name">
<cstring>textLabel1</cstring> <cstring>textLabel1</cstring>
</property> </property>
@ -27,7 +27,7 @@
<string>Number of Fish:</string> <string>Number of Fish:</string>
</property> </property>
</widget> </widget>
<widget class="QSpinBox"> <widget class="TQSpinBox">
<property name="name"> <property name="name">
<cstring>kcfg_fishCount</cstring> <cstring>kcfg_fishCount</cstring>
</property> </property>

@ -85,9 +85,9 @@ bool Sprite::tickUpdate()
return true; return true;
} }
QRect Sprite::geom() const TQRect Sprite::geom() const
{ {
return QRect(m_x, m_y, m_frames[0].width(), m_frames[0].height()); return TQRect(m_x, m_y, m_frames[0].width(), m_frames[0].height());
} }

@ -28,7 +28,7 @@
#ifndef AA_SPRITE_H #ifndef AA_SPRITE_H
#define AA_SPRITE_H #define AA_SPRITE_H
#include <qvaluevector.h> #include <ntqvaluevector.h>
#include "frame.h" #include "frame.h"
/** /**
@ -53,7 +53,7 @@ protected:
int m_y; ///< Our current logical y position. int m_y; ///< Our current logical y position.
int m_z; ///< Our current depth. int m_z; ///< Our current depth.
QValueVector<Frame> m_frames; ///< Array of animation frames. TQValueVector<Frame> m_frames; ///< Array of animation frames.
bool m_isKilled; ///< True if we've been killed. bool m_isKilled; ///< True if we've been killed.
bool m_killAfterLastFrame; ///< True if we should auto-kill after the last frame. bool m_killAfterLastFrame; ///< True if we should auto-kill after the last frame.
int m_ticksSinceFrameChange; ///< Number of timer ticks since we last changed frame. int m_ticksSinceFrameChange; ///< Number of timer ticks since we last changed frame.
@ -165,7 +165,7 @@ public:
* @return The rectangular geometry of this object in the Pixel coordinate * @return The rectangular geometry of this object in the Pixel coordinate
* system. * system.
*/ */
QRect geom() const; TQRect geom() const;
/** /**
* Erases this Sprite from its Screen, using the current animation frame to * Erases this Sprite from its Screen, using the current animation frame to

Loading…
Cancel
Save