summaryrefslogtreecommitdiff
path: root/noncore/games/kbill/UI.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/kbill/UI.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/kbill/UI.cpp31
1 files changed, 15 insertions, 16 deletions
diff --git a/noncore/games/kbill/UI.cpp b/noncore/games/kbill/UI.cpp
index 611cebf..a49c3c1 100644
--- a/noncore/games/kbill/UI.cpp
+++ b/noncore/games/kbill/UI.cpp
@@ -23,118 +23,117 @@
#include "inputbox.h"
/**************************/
/* Timer control routines */
/**************************/
UI::~UI() {
paint.end();
delete pix;
}
void UI::restart_timer() {
field->startTimer();
}
void UI::kill_timer() {
field->stopTimer();
}
/*******************/
/* Window routines */
/*******************/
void UI::initialize(int *argc, char **argv) {
#ifdef KDEVER
app = new KApplication(*argc, argv, "kbill");
#endif
app = new QPEApplication(*argc, argv);
}
void UI::graph_init() {
pix = new QPixmap(Game::scrwidth, Game::scrheight);
paint.begin(pix, field);
paint.setPen(QPen(Qt::black, 3));
}
void UI::make_mainwin() {
main = new KBill();
app->showMainWidget(main,true);
main->showMaximized();
field = main->getField();
}
void UI::popup_dialog (int dialog) {
kill_timer();
switch (dialog) {
case Game::ENDGAME:
- QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
- break;
+ QMessageBox::message(("Endgame"), QT_TR_NOOP(endgamestr));
+ break;
case Game::HIGHSCORE:
- // QMessageBox::message(("HighScore"), highscorestr);
- break;
- case Game::ENTERNAME: {
+ break;
+ case Game::ENTERNAME:
+ {
InputBox b(main, 0, ("Enter Name"), QT_TR_NOOP(enternamestr));
bool state = b.exec() == 2;
- char str[20], *nl;
- strcpy(str, b.getText());
- if (!str[0] || state)
+ char str[20], *nl;
+ strncpy(str, b.getText(), 19);
+ if (!str[0] || state)
strcpy(str, "Anonymous");
- else if ((nl = strchr(str, '\n')))
+ else if ((nl = strchr(str, '\n')))
*nl = '\0';
- if (strlen(str) > 20)
- str[20] = 0; /* truncate string if too long */
-// scores.recalc(str);
- }
- break;
+ if (strlen(str) > 19)
+ str[19] = '\0'; /* truncate/terminate the string if it is too long */
+ }
+ break;
case Game::SCORE:
- QMessageBox::message(("Score"), scorestr);
- break;
+ QMessageBox::message(("Score"), scorestr);
+ break;
}
restart_timer();
}
/*********************/
/* Graphics routines */
/*********************/
void UI::set_cursor(int cursor) {
QCursor *cur;
switch (cursor) {
case Game::BUCKETC:
cur = bucket.cursor.cursor;
break;
case Game::DOWNC:
cur = downcursor.cursor;
break;
case Game::DEFAULTC:
cur = defaultcursor.cursor;
break;
default:
cur = OS.cursor[cursor].cursor;
}
field->setCursor(*cur);
}
void UI::load_cursors() {
defaultcursor.load("hand_up", MCursor::SEP_MASK);
field->setCursor(*defaultcursor.cursor);
downcursor.load("hand_down", MCursor::SEP_MASK);
}
void UI::clear() {
paint.eraseRect(0, 0, field->width(), field->height());
}
void UI::refresh() {
paint.flush();
field->setPixmap(pix);
field->repaint(FALSE);
}
void UI::draw (Picture pict, int x, int y) {
paint.drawPixmap(x, y, *pict.pix);
}
void UI::draw_centered (Picture pict) {
draw(pict, (field->width() - pict.width) / 2, (field->height() - pict.height) / 2);