summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/zkbnames.cpp26
-rw-r--r--noncore/games/qasteroids/view.cpp7
-rw-r--r--noncore/games/solitaire/cardpile.h2
3 files changed, 22 insertions, 13 deletions
diff --git a/noncore/applets/zkbapplet/keyzcfg/zkbnames.cpp b/noncore/applets/zkbapplet/keyzcfg/zkbnames.cpp
index b2180ba..a47bf6c 100644
--- a/noncore/applets/zkbapplet/keyzcfg/zkbnames.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/zkbnames.cpp
@@ -1,282 +1,288 @@
#include <qmap.h>
#include "zkbnames.h"
QString Null_String((const char*) 0);
// Implementation of KeyNames
-static struct {
+struct Key_Names_t {
int key;
char *name;
-} Key_Names[] = {
+};
+
+static const Key_Names_t Key_Names[] = {
{ 32, "Space" },
{ 39, "Apostrophe" },
{ 44, "Comma" },
{ 46, "Period" },
{ 47, "Slash" },
{ 65, "A" },
{ 66, "B" },
{ 67, "C" },
{ 68, "D" },
{ 69, "E" },
{ 70, "F" },
{ 71, "G" },
{ 72, "H" },
{ 73, "I" },
{ 74, "J" },
{ 75, "K" },
{ 76, "L" },
{ 77, "M" },
{ 78, "N" },
{ 79, "O" },
{ 80, "P" },
{ 81, "Q" },
{ 82, "R" },
{ 83, "S" },
{ 84, "T" },
{ 85, "U" },
{ 86, "V" },
{ 87, "W" },
{ 88, "X" },
{ 89, "Y" },
{ 90, "Z" },
{ 4096, "Cancel" },
{ 4097, "Tab" },
{ 4099, "Backspace" },
{ 4100, "Enter" },
{ 4114, "Left" },
{ 4115, "Up" },
{ 4116, "Right" },
{ 4117, "Down" },
{ 4128, "Left Shift" },
{ 4130, "Right Shift" },
{ 4152, "Calendar" },
{ 4153, "Addressbook" },
{ 4154, "Menu" },
{ 4155, "Home" },
{ 4156, "Mail" },
{ 4165, "Fn" },
{ 4173, "Middle" },
{ 4176, "OK" },
{ 4177, "Off" },
{ 4178, "Light" },
{ 0, 0 }
};
static QMap<QString, int> kn_map;
static QMap<int, QString> kn_rmap;
void init_kn_maps() {
int i = 0;
while (Key_Names[i].name != 0) {
int key = Key_Names[i].key;
QString name(Key_Names[i].name);
kn_map.insert(name, key);
kn_rmap.insert(key, name);
i++;
}
}
int KeyNames::find(const QString& key) {
if (kn_map.isEmpty()) {
init_kn_maps();
}
QMap<QString, int>::Iterator it = kn_map.find(key);
if (it == kn_map.end()) {
return -1;
} else {
return it.data();
}
}
const QString& KeyNames::find(int k) {
if (kn_map.isEmpty()) {
init_kn_maps();
}
QMap<int, QString>::Iterator it = kn_rmap.find(k);
if (it == kn_rmap.end()) {
return Null_String;
} else {
return it.data();
}
}
// Implementation of ModifierNames
-struct {
+struct Modifier_Names_t {
int value;
char* name;
-} Modifier_Names[] = {
+};
+
+static const Modifier_Names_t Modifier_Names[] = {
{ 8, "Shift" },
{ 16, "Control" },
{ 32, "Alt" },
{ 0x4000, "Keypad" },
{ 0, 0 }
};
static QMap<QString, int> mn_map;
static QMap<int, QString> mn_rmap;
void init_mn_maps() {
int i = 0;
while (Modifier_Names[i].name != 0) {
int value = Modifier_Names[i].value;
QString name(Modifier_Names[i].name);
mn_map.insert(name, value);
mn_rmap.insert(value, name);
i++;
}
}
int ModifierNames::find(const QString& key) {
if (mn_map.isEmpty()) {
init_mn_maps();
}
QMap<QString, int>::Iterator it = mn_map.find(key);
if (it == mn_map.end()) {
return -1;
} else {
return it.data();
}
}
const QString& ModifierNames::find(int k) {
if (mn_map.isEmpty()) {
init_mn_maps();
}
QMap<int, QString>::Iterator it = mn_rmap.find(k);
if (it == mn_rmap.end()) {
return Null_String;
} else {
return it.data();
}
}
// Implementation of KeycodeNames
-struct {
+struct Keycode_Names_t {
char* name;
int keycode;
-} Keycode_Names[] = {
+};
+
+static const Keycode_Names_t Keycode_Names[] = {
{ "Escape", 0x1000 },
{ "Tab", 0x1001 },
{ "Backtab", 0x1002 },
- { "Backspace", 0x1003 },
+ { "Backspace", 0x1003 },
{ "BackSpace", 0x1003 },
{ "Return", 0x1004 },
{ "Enter", 0x1005 },
{ "Insert", 0x1006 },
{ "Delete", 0x1007 },
{ "Pause", 0x1008 },
{ "Print", 0x1009 },
{ "SysReq", 0x100a },
{ "Home", 0x1010 },
{ "End", 0x1011 },
{ "Left", 0x1012 },
{ "Up", 0x1013 },
{ "Right", 0x1014 },
{ "Down", 0x1015 },
- { "Prior", 0x1016 },
- { "PageUp", 0x1016 },
- { "Next", 0x1017 },
+ { "Prior", 0x1016 },
+ { "PageUp", 0x1016 },
+ { "Next", 0x1017 },
{ "PageDown", 0x1017 },
{ "Shift", 0x1020 },
{ "Control", 0x1021 },
{ "Meta", 0x1022 },
{ "Alt", 0x1023 },
{ "CapsLock", 0x1024 },
{ "NumLock", 0x1025 },
{ "ScrollLock", 0x1026 },
{ "F1", 0x1030 },
{ "F2", 0x1031 },
{ "F3", 0x1032 },
{ "F4", 0x1033 },
{ "F5", 0x1034 },
{ "F6", 0x1035 },
{ "F7", 0x1036 },
{ "F8", 0x1037 },
{ "F9", 0x1038 },
{ "F10", 0x1039 },
{ "F11", 0x103a },
{ "F12", 0x103b },
{ "F13", 0x103c },
{ "F14", 0x103d },
{ "F15", 0x103e },
{ "F16", 0x103f },
{ "F17", 0x1040 },
{ "F18", 0x1041 },
{ "F19", 0x1042 },
{ "F20", 0x1043 },
{ "F21", 0x1044 },
{ "F22", 0x1045 },
{ "F23", 0x1046 },
{ "F24", 0x1047 },
{ "F25", 0x1048 },
{ "F26", 0x1049 },
{ "F27", 0x104a },
{ "F28", 0x104b },
{ "F29", 0x104c },
{ "F30", 0x104d },
{ "F31", 0x104e },
{ "F32", 0x104f },
{ "F33", 0x1050 },
{ "F34", 0x1051 },
{ "F35", 0x1052 },
{ "Super_L", 0x1053 },
{ "Super_R", 0x1054 },
{ "Menu", 0x1055 },
{ "Hyper_L", 0x1056 },
{ "Hyper_R", 0x1057 },
{ "Help", 0x1058 },
{ "Space", 0x20 },
{ "Any", 0x20 },
{ "Exclam", 0x21 },
{ "QuoteDbl", 0x22 },
{ "NumberSign", 0x23 },
{ "Dollar", 0x24 },
{ "Percent", 0x25 },
{ "Ampersand", 0x26 },
{ "Apostrophe", 0x27 },
{ "ParenLeft", 0x28 },
{ "ParenRight", 0x29 },
{ "Asterisk", 0x2a },
{ "Plus", 0x2b },
{ "Comma", 0x2c },
{ "Minus", 0x2d },
{ "Period", 0x2e },
{ "Slash", 0x2f },
{ "0", 0x30 },
{ "1", 0x31 },
{ "2", 0x32 },
{ "3", 0x33 },
{ "4", 0x34 },
{ "5", 0x35 },
{ "6", 0x36 },
{ "7", 0x37 },
{ "8", 0x38 },
{ "9", 0x39 },
{ "Colon", 0x3a },
{ "Semicolon", 0x3b },
{ "Less", 0x3c },
{ "Equal", 0x3d },
{ "Greater", 0x3e },
{ "Question", 0x3f },
{ "At", 0x40 },
{ "A", 0x41 },
{ "B", 0x42 },
{ "C", 0x43 },
{ "D", 0x44 },
{ "E", 0x45 },
{ "F", 0x46 },
{ "G", 0x47 },
{ "H", 0x48 },
{ "I", 0x49 },
{ "J", 0x4a },
{ "K", 0x4b },
{ "L", 0x4c },
{ "M", 0x4d },
diff --git a/noncore/games/qasteroids/view.cpp b/noncore/games/qasteroids/view.cpp
index 352c63b..3a4d410 100644
--- a/noncore/games/qasteroids/view.cpp
+++ b/noncore/games/qasteroids/view.cpp
@@ -1,160 +1,161 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************//*
* KAsteroids - Copyright (c) Martin R. Jones 1997
*
* Part of the KDE project
*/
#include "view.h"
#include <qpe/resource.h>
#include <stdlib.h>
#include <math.h>
#define IMG_BACKGROUND "qasteroids/bg.png"
#define REFRESH_DELAY 33
#define SHIP_SPEED 0.3
#define MISSILE_SPEED 10.0
#define SHIP_STEPS 64
#define ROTATE_RATE 2
#define SHIELD_ON_COST 1
#define SHIELD_HIT_COST 30
#define BRAKE_ON_COST 4
#define MAX_ROCK_SPEED 2.5
#define MAX_POWERUP_SPEED 1.5
#define MAX_SHIP_SPEED 8
#define MAX_BRAKES 5
#define MAX_SHIELDS 5
#define MAX_FIREPOWER 5
#define TEXT_SPEED 4
#define PI_X_2 6.283185307
#ifndef M_PI
#define M_PI 3.141592654
#endif
-struct
+struct kas_animations_t
{
int id;
const char *path;
int frames;
-}
-kas_animations [] =
+};
+
+static const kas_animations_t kas_animations [] =
{
// { ID_ROCK_LARGE, "rock1/rock1\%1.png", 32 },
{ ID_ROCK_MEDIUM, "rock2/rock2\%1.png", 32 },
{ ID_ROCK_SMALL, "rock3/rock3\%1.png", 32 },
{ ID_SHIP, "ship/ship\%1.png", 32 },
{ ID_MISSILE, "missile/missile.png", 0 },
{ ID_BIT, "bits/bits\%1.png", 16 },
{ ID_EXHAUST, "exhaust/exhaust.png", 0 },
{ ID_ENERGY_POWERUP, "powerups/energy.png", 0 },
// { ID_TELEPORT_POWERUP, "powerups/teleport%1.png", 12 },
{ ID_BRAKE_POWERUP, "powerups/brake.png", 0 },
{ ID_SHIELD_POWERUP, "powerups/shield.png", 0 },
{ ID_SHOOT_POWERUP, "powerups/shoot.png", 0 },
{ ID_SHIELD, "shield/shield\%1.png", 6 },
{ 0, 0, 0 }
};
KAsteroidsView::KAsteroidsView( QWidget *parent, const char *name )
: QWidget( parent, name ),
field(200, 200),
view(&field,this)
{
view.setVScrollBarMode( QScrollView::AlwaysOff );
view.setHScrollBarMode( QScrollView::AlwaysOff );
rocks.setAutoDelete( TRUE );
missiles.setAutoDelete( TRUE );
bits.setAutoDelete( TRUE );
powerups.setAutoDelete( TRUE );
exhaust.setAutoDelete( TRUE );
QPixmap pm( Resource::loadPixmap(IMG_BACKGROUND) );
field.setBackgroundPixmap( pm );
textSprite = new QCanvasText( &field );
QFont font( "helvetica", 14 );
textSprite->setFont( font );
shield = 0;
shieldOn = FALSE;
refreshRate = REFRESH_DELAY;
readSprites();
shieldTimer = new QTimer( this );
connect( shieldTimer, SIGNAL(timeout()), this, SLOT(hideShield()) );
mTimerId = -1;
shipPower = MAX_POWER_LEVEL;
vitalsChanged = TRUE;
can_destroy_powerups = FALSE;
mPaused = TRUE;
}
// - - -
KAsteroidsView::~KAsteroidsView()
{
}
// - - -
void KAsteroidsView::reset()
{
rocks.clear();
missiles.clear();
bits.clear();
powerups.clear();
exhaust.clear();
shotsFired = 0;
shotsHit = 0;
rockSpeed = 1.0;
powerupSpeed = 1.0;
mFrameNum = 0;
mPaused = FALSE;
ship->hide();
shield->hide();
/*
if ( mTimerId >= 0 ) {
killTimer( mTimerId );
mTimerId = -1;
}
*/
}
// - --
void KAsteroidsView::newGame()
{
if ( shieldOn )
{
diff --git a/noncore/games/solitaire/cardpile.h b/noncore/games/solitaire/cardpile.h
index 1eb2499..757e6b3 100644
--- a/noncore/games/solitaire/cardpile.h
+++ b/noncore/games/solitaire/cardpile.h
@@ -1,115 +1,117 @@
/**********************************************************************
** Copyright (C) 2000 Trolltech AS. All rights reserved.
**
** This file is part of Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#ifndef CARD_PILE_H
#define CARD_PILE_H
+#include "card.h"
+
#include <qpoint.h>
#include <qlist.h>
enum ePileStackingType {
pileCascades = 0, pileStacks, pileCascadesOrStacks
};
enum ePileFaceingType {
pileFaceUp = 0, pileFaceDown, pileFaceUpOrDown
};
class Card;
class Config;
class CardPile : public QList<Card>
{
public:
CardPile(int x, int y);
virtual ~CardPile() { }
int getX() { return pileX; }
int getY() { return pileY; }
int getNextX() { return pileNextX; }
int getNextY() { return pileNextY; }
int getWidth() { return pileWidth; }
int getHeight() { return pileHeight; }
int getOffsetDown() { return pileOffsetDown; }
int getAnzCardsInPile() {
int anz=0;
Card *card = cardOnBottom();
while (card != NULL) { anz++; card = cardInfront(card); }
return anz;
}
void setX(int x) { pileX = x; }
void setY(int y) { pileY = y; }
void setNextX(int x) { pileNextX = x; }
void setNextY(int y) { pileNextY = y; }
void setWidth(int width) { pileWidth = width; }
void setHeight(int height) { pileHeight = height; }
void setOffsetDown(int down) { pileOffsetDown = down; }
void beginDealing() { dealing = TRUE; }
void endDealing() { dealing = FALSE; }
bool isDealing() { return dealing; }
void beginPileResize() { PileResize = TRUE; }
void endPileResize() { PileResize = FALSE; }
bool isPileResize() { return PileResize; }
int distanceFromPile(int x, int y);
int distanceFromNextPos(int x, int y);
Card *cardOnTop() { return getLast(); }
Card *cardOnBottom() { return getFirst(); }
Card *cardInfront(Card *c);
bool kingOnTop();
bool addCardToTop(Card *c);
bool addCardToBottom(Card *c);
bool removeCard(Card *c);
virtual void cardAddedToTop(Card *) { }
virtual void cardAddedToBottom(Card *) { }
virtual void cardRemoved(Card *) { }
virtual bool isAllowedOnTop(Card *) { return FALSE; }
virtual bool isAllowedOnBottom(Card *) { return FALSE; }
virtual bool isAllowedToBeMoved(Card *) { return FALSE; }
virtual QPoint getCardPos(Card *) { return QPoint(pileX, pileY); }
virtual QPoint getHypertheticalNextCardPos() { return QPoint(pileX, pileY); }
void writeConfig( Config& cfg, QString name );
protected:
int pileX, pileY;
int pileNextX, pileNextY;
int pileWidth, pileHeight;
int pileCenterX, pileCenterY;
int pileRadius;
int pileOffsetDown;
private:
bool dealing;
bool PileResize;
};
#endif