From c90c389a8a8d9d8661e9772ec4144c5cf2039f23 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegames@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- klickety/CHANGELOG | 22 ++++ klickety/LICENSE | 18 +++ klickety/Makefile.am | 70 ++++++++++ klickety/README | 12 ++ klickety/board.cpp | 163 +++++++++++++++++++++++ klickety/board.h | 38 ++++++ klickety/eventsrc | 249 +++++++++++++++++++++++++++++++++++ klickety/field.cpp | 80 +++++++++++ klickety/field.h | 33 +++++ klickety/highscores.cpp | 27 ++++ klickety/highscores.h | 18 +++ klickety/klickety.desktop | 84 ++++++++++++ klickety/klicketyui.rc | 17 +++ klickety/main.cpp | 73 ++++++++++ klickety/main.h | 29 ++++ klickety/pics/Makefile.am | 3 + klickety/pics/hi128-app-klickety.png | Bin 0 -> 9711 bytes klickety/pics/hi16-app-klickety.png | Bin 0 -> 684 bytes klickety/pics/hi22-app-klickety.png | Bin 0 -> 1089 bytes klickety/pics/hi32-app-klickety.png | Bin 0 -> 1716 bytes klickety/pics/hi48-app-klickety.png | Bin 0 -> 3000 bytes klickety/pics/hi64-app-klickety.png | Bin 0 -> 3950 bytes klickety/piece.cpp | 52 ++++++++ klickety/piece.h | 42 ++++++ 24 files changed, 1030 insertions(+) create mode 100644 klickety/CHANGELOG create mode 100644 klickety/LICENSE create mode 100644 klickety/Makefile.am create mode 100644 klickety/README create mode 100644 klickety/board.cpp create mode 100644 klickety/board.h create mode 100644 klickety/eventsrc create mode 100644 klickety/field.cpp create mode 100644 klickety/field.h create mode 100644 klickety/highscores.cpp create mode 100644 klickety/highscores.h create mode 100644 klickety/klickety.desktop create mode 100644 klickety/klicketyui.rc create mode 100644 klickety/main.cpp create mode 100644 klickety/main.h create mode 100644 klickety/pics/Makefile.am create mode 100644 klickety/pics/hi128-app-klickety.png create mode 100644 klickety/pics/hi16-app-klickety.png create mode 100644 klickety/pics/hi22-app-klickety.png create mode 100644 klickety/pics/hi32-app-klickety.png create mode 100644 klickety/pics/hi48-app-klickety.png create mode 100644 klickety/pics/hi64-app-klickety.png create mode 100644 klickety/piece.cpp create mode 100644 klickety/piece.h (limited to 'klickety') diff --git a/klickety/CHANGELOG b/klickety/CHANGELOG new file mode 100644 index 00000000..2ecde970 --- /dev/null +++ b/klickety/CHANGELOG @@ -0,0 +1,22 @@ +1.0.3 (4 July 2004) [KDE 3.3 stable] + * use zoom in/out actions (bug #65456) + +1.0.2 (10 March 2004) [KDE 3.2.2 stable] + * fix bug #65490 (default with simpler removed display) + * fix bug #77170 (crash at startup) + +1.0.1 (18 December 2002) [KDE 3.2 stable] + * notifications + +1.0.0b (18 December 2002) [KDE 3.1 stable] + * fix uninitialized variable + +1.0.0 (16 June 2002) + * adapt to library changes + * world-wide highscores + +0.0.1 (23 May 2002) + * initial version in CVS + +----------------- +see also the CHANGELOG for ksirtet diff --git a/klickety/LICENSE b/klickety/LICENSE new file mode 100644 index 00000000..250ac00d --- /dev/null +++ b/klickety/LICENSE @@ -0,0 +1,18 @@ +KLICKETY +-------- +Copyright (c) 2001-2004 Nicolas HADACEK (hadacek@kde.org) + + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/klickety/Makefile.am b/klickety/Makefile.am new file mode 100644 index 00000000..5d9e6336 --- /dev/null +++ b/klickety/Makefile.am @@ -0,0 +1,70 @@ +SUBDIRS = pics + +INCLUDES = -I$(top_builddir)/libksirtet -I$(top_srcdir)/libksirtet -I$(top_srcdir)/libkdegames/highscore -I$(top_srcdir)/libkdegames $(all_includes) + +KDE_CXXFLAGS = $(KDE_USE_FPIE) + +bin_PROGRAMS = klickety +klickety_LDADD = $(top_builddir)/libksirtet/base/libksirtetbase.la +klickety_DEPENDENCIES = $(LIB_KDEGAMES_DEP) +klickety_LDFLAGS = $(KDE_USE_PIE) $(LIB_KDEGAMES) $(all_libraries) $(KDE_RPATH) +klickety_SOURCES = piece.cpp board.cpp field.cpp highscores.cpp main.cpp +METASOURCES = board.moc field.moc main.moc + +rcdir = $(kde_datadir)/klickety +rc_DATA = klicketyui.rc + +xdg_apps_DATA = klickety.desktop + +appdatadir = $(kde_datadir)/klickety +appdata_DATA = eventsrc + +messages: rc.cpp + $(XGETTEXT) rc.cpp $(klickety_SOURCES) -o $(podir)/klickety.pot + +# for system-wide highscore file +DESTBIN = $(DESTDIR)$(bindir)/$(bin_PROGRAMS) +DESTHIGHSCORES = $(DESTDIR)$(HIGHSCORE_DIRECTORY) +DESTSCORES = $(DESTDIR)$(HIGHSCORE_DIRECTORY)/$(bin_PROGRAMS).scores + +install-data-local: + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && echo "********************************************************" \ + && echo "" \ + && echo "This game is installed sgid \"games\" to use the" \ + && echo "system-wide highscore file (in "$(HIGHSCORE_DIRECTORY)")." \ + && echo "" \ + && echo "If the system-wide highscore file does not exist, it is" \ + && echo "created with the correct ownership and permissions. See the" \ + && echo "INSTALL file in \"kdegames/libkdegames/highscore\" for details." \ + && echo "" \ + && echo "********************************************************" \ + ) || true + +install-exec-hook: + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((chown $(highscore_user):$(highscore_group) $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((mkdir -p $(DESTHIGHSCORES) && chown $(highscore_user):$(highscore_group) $(DESTHIGHSCORES) \ + && chmod 750 $(DESTHIGHSCORES)) \ + || echo "Error: Could not create the highscore directory with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((chown $(highscore_user):$(highscore_group) $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test ${setgid} = true \ + && ((chmod 2755 $(DESTBIN)) \ + || echo "Error: Could not install the game with correct permissions !!" \ + )) || true + + @(test x$(HIGHSCORE_DIRECTORY) != x \ + && ((touch $(DESTSCORES) && chown $(highscore_user):$(highscore_group) $(DESTSCORES) \ + && chmod 0660 $(DESTSCORES)) \ + || echo "Error: Could not create system-wide highscore file with correct permissions !!" \ + )) || true diff --git a/klickety/README b/klickety/README new file mode 100644 index 00000000..2a548cf6 --- /dev/null +++ b/klickety/README @@ -0,0 +1,12 @@ +KLICKETY : a clickomania-alike game +------------------------------------- +Copyright (c) 2001-2004 Nicolas HADACEK (hadacek@kde.org) +Distributed under the GNU General Public License + +Klickety is an adaptation of the (perharps) well-known Clickomania game ; it +is very similar to the "same" game. + +The code links to the ksirtet libraries. + + +Enjoy ! diff --git a/klickety/board.cpp b/klickety/board.cpp new file mode 100644 index 00000000..92969d6e --- /dev/null +++ b/klickety/board.cpp @@ -0,0 +1,163 @@ +#include "board.h" +#include "board.moc" + +#include "base/factory.h" + + +using namespace KGrid2D; + +void KLBoard::contentsMouseReleaseEvent(QMouseEvent *e) +{ + if ( e->button()!=LeftButton || blocked ) return; + QCanvasItemList list = canvas()->collisions(e->pos()); + if ( list.count()==0 ) return; + + QCanvasSprite *spr = static_cast(list.first()); + Coord c = findSprite(spr); + field.fill(0); + addRemoved = findGroup(field, c); + if ( addRemoved>=2 ) { + if ( state!=Normal ) { + state = Normal; + emit firstBlockClicked(); + } + blocked = true; + _beforeRemove(true); + } +} + +KLBoard::KLBoard(QWidget *parent) + : BaseBoard(true, parent), + field(matrix().width(), matrix().height()), + empty(matrix().width()), + blocked(false) +{} + +void KLBoard::start(const GTInitData &data) +{ + BaseBoard::start(data); + + updateScore(matrix().width() * matrix().height()); + state = GameOver; + sliding = false; + blocked = false; + for (uint i=0; isetValue(Piece::info().generateType(&randomSequence()), main); + Coord c(i, j); + setBlock(c, block); + } + computeInfos(); + showBoard(true); +} + +Coord KLBoard::findSprite(QCanvasSprite *spr) const +{ + for (uint i=0; isprite()==spr ) return c; + } + Q_ASSERT(false); + return Coord(); +} + +bool KLBoard::toBeRemoved(const Coord &c) const +{ + return ( field[c]==-1 ); +} + +void KLBoard::remove() +{ + BaseBoard::remove(); + updateRemoved(nbRemoved() + addRemoved); + updateScore(score() - addRemoved); +} + +bool KLBoard::toFall(const Coord &c) const +{ + Coord under(c.first, c.second-1); + return ( matrix()[under]==0 ); +} + +void KLBoard::computeInfos() +{ + BaseBoard::computeInfos(); + if ( graphic() ) computeNeighbours(); + empty.fill(true); + for (uint i=0; ibbi.nbFallStages); + + for (uint j=0; j heights(matrix().width()); + for (uint i=1; iupdate(); + if (final) computeInfos(); + return final; +} + +BaseBoard::AfterRemoveResult KLBoard::afterRemove(bool doAll, bool first) +{ + AfterRemoveResult res = Done; // dummy default + if (sliding) { + res = (doSlide(doAll, loop==bfactory->bbi.nbFallStages+1, false) ? Done + : NeedAfterRemove); + if ( res==Done ) sliding = false; + } else { + res = BaseBoard::afterRemove(doAll, first); + if ( res==Done ) { + res = NeedAfterRemove; + sliding = true; + loop++; + } + } + return res; +} + +bool KLBoard::afterAfterRemove() +{ + // check if there are remaining groups + field.fill(0); + QMemArray groups = findGroups(field, 2, true); + blocked = false; + return groups.size()!=0; +} diff --git a/klickety/board.h b/klickety/board.h new file mode 100644 index 00000000..d239f83d --- /dev/null +++ b/klickety/board.h @@ -0,0 +1,38 @@ +#ifndef KL_BOARD_H +#define KL_BOARD_H + +#include "base/board.h" +#include "base/piece.h" + +class KLBoard : public BaseBoard +{ + Q_OBJECT + public: + KLBoard(QWidget *parent); + + void start(const GTInitData &data); + + signals: + void firstBlockClicked(); + + private: + KGrid2D::Square field; + bool sliding; + QMemArray empty; + uint addRemoved; + bool blocked; + + KGrid2D::Coord findSprite(QCanvasSprite *) const; + AfterRemoveResult afterRemove(bool doAll, bool first); + bool afterAfterRemove(); + bool toBeRemoved(const KGrid2D::Coord &) const; + void remove(); + bool toFall(const KGrid2D::Coord &) const; + bool toSlide(const KGrid2D::Coord &) const; + bool doSlide(bool doAll, bool first, bool lineByLine); + void computeInfos(); + + void contentsMouseReleaseEvent(QMouseEvent *); +}; + +#endif diff --git a/klickety/eventsrc b/klickety/eventsrc new file mode 100644 index 00000000..912a83e6 --- /dev/null +++ b/klickety/eventsrc @@ -0,0 +1,249 @@ +[!Global!] +IconName=klickety +Comment=Klickety +Comment[ar]=لعبة Klickety +Comment[be]=Адбітак +Comment[bn]=ক্লিকেটি +Comment[hi]=के-लिकेटी +Comment[ne]=केलिकेटी +Comment[ta]=கேலிங்கட்டி + +[removed] +Name=Line removed +Name[ar]=لقد أزيل الخط +Name[be]=Лінія выдаленая +Name[bg]=Премахната е линия +Name[bn]=লাইন সরিয়ে ফেলা হয়েছে +Name[br]=Linenn lemet +Name[bs]=Uklonjena linija +Name[ca]=Línia eliminada +Name[cs]=Odstraněn řádek +Name[cy]=Gwaredwyd llinell +Name[da]=Linje fjernet +Name[de]=Zeile entfernt +Name[el]=Γραμμή αφαιρέθηκε +Name[eo]=Linio forigita +Name[es]=Línea eliminada +Name[et]=Eemaldatud rida +Name[eu]=Lerroa kendu da +Name[fa]=خط حذف شد +Name[fi]=Rivi poistettu +Name[fr]=Ligne supprimée +Name[ga]=Líne bainte +Name[gl]=Liña eliminada +Name[he]=שורה הוסרה +Name[hi]=पंक्ति हटाए +Name[hr]=Uklonjena linija +Name[hu]=Sor eltávolítva +Name[is]=Lína fjarlægð +Name[it]=Riga rimossa +Name[ja]=線を消しました +Name[km]=បន្ទាត់​ដែល​បាន​យក​ចេញ +Name[lt]=Linija panaikinta +Name[lv]=Rinda noņemta +Name[mk]=Отстранета е линија +Name[nb]=Linje fjernet +Name[nds]=Reeg wegdaan +Name[ne]=रेखा हटाइयो +Name[nl]=Regel verwijderd +Name[nn]=Linje fjerna +Name[pa]=ਸਤਰ ਹਟਾਈ +Name[pl]=Linia usunięta +Name[pt]=Linha removida +Name[pt_BR]=Linha removida +Name[ro]=Linie eliminată +Name[ru]=Линия удалена +Name[se]=Linnjá lea eretváldon +Name[sk]=Čiara odstránená +Name[sl]=Vrstica odstranjena +Name[sr]=Уклоњена линија +Name[sr@Latn]=Uklonjena linija +Name[sv]=Rad borttagen +Name[ta]=கோடு நீக்கப்பட்டது +Name[tg]=Сатр хориҷ карда шуд +Name[tr]=Silinen Çizgiler +Name[uk]=Лінія видалена +Name[zh_CN]=消去的行数 +Name[zh_TW]=消去的行 +Comment=Line removed +Comment[ar]=لقد أزيل الخط +Comment[be]=Лінія выдаленая +Comment[bg]=Премахната е линия +Comment[bn]=লাইন সরিয়ে ফেলা হয়েছে +Comment[br]=Linenn lemet +Comment[bs]=Uklonjena linija +Comment[ca]=Línia eliminada +Comment[cs]=Odstraněn řádek +Comment[cy]=Gwaredwyd llinell +Comment[da]=Linje fjernet +Comment[de]=Zeile entfernt +Comment[el]=Γραμμή αφαιρέθηκε +Comment[eo]=Linio forigita +Comment[es]=Línea eliminada +Comment[et]=Eemaldatud rida +Comment[eu]=Lerroa kendu da +Comment[fa]=خط حذف شد +Comment[fi]=Rivi poistettu +Comment[fr]=Ligne supprimée +Comment[ga]=Líne bainte +Comment[gl]=Liña eliminada +Comment[he]=שורה הוסרה +Comment[hi]=पंक्ति हटाए +Comment[hr]=Uklonjena linija +Comment[hu]=Sor eltávolítva +Comment[is]=Lína fjarlægð +Comment[it]=Linea rimossa +Comment[ja]=線を消しました +Comment[km]=បន្ទាត់​ដែល​បាន​យក​ចេញ +Comment[lt]=Linija panaikinta +Comment[lv]=Rinda ir noņemta +Comment[mk]=Отстранета е линија +Comment[nb]=Linje fjernet +Comment[nds]=Reeg wegdaan +Comment[ne]=रेखा हटाइयो +Comment[nl]=Regel verwijderd +Comment[nn]=Linje fjerna +Comment[pa]=ਸਤਰ ਹਟਾਈ +Comment[pl]=Linia usunięta +Comment[pt]=Linha removida +Comment[pt_BR]=Linha removida +Comment[ro]=Linie eliminată +Comment[ru]=Линия удалена +Comment[se]=Linnjá lea eretváldon +Comment[sk]=Čiara odstránená +Comment[sl]=Odstranjena vrstica +Comment[sr]=Уклоњена линија +Comment[sr@Latn]=Uklonjena linija +Comment[sv]=Rad borttagen +Comment[ta]=கோடு நீக்கப்பட்டது +Comment[tg]=Сатр хориҷ карда шуд +Comment[tr]=Silinen çizgiler +Comment[uk]=Лінія видалена +Comment[zh_CN]=消去的行数 +Comment[zh_TW]=消去的行 +default_presentation=0 + +[game over] +Name=Game Over +Name[af]=Speletjie Bo +Name[ar]=اللعبة انتهت +Name[az]=Oyun Qurtardı +Name[be]=Канец гульні +Name[bg]=Край на играта +Name[bn]=খেল খতম +Name[br]=Echu an abadenn +Name[bs]=Igra završena +Name[ca]=Fi de la partida +Name[cs]=Konec hry +Name[cy]=Gêm Drosodd +Name[da]=Spillet forbi +Name[de]=Spiel beendet +Name[el]=Τέλος παιχνιδιού +Name[eo]=Ludo finita +Name[es]=Fin de la partida +Name[et]=Mäng läbi +Name[eu]=Jokoa amaitu da +Name[fa]=بازی تمام شد +Name[fi]=Peli loppu +Name[fr]=Fin de la partie +Name[ga]=Cluiche Thart +Name[gl]=Fin do Xogo +Name[he]=סיום משחק +Name[hi]=खेल ख़त्म +Name[hr]=Igra je završena +Name[hu]=Vége a játéknak +Name[id]=permainan berakhir +Name[is]=Leik lokið +Name[it]=Gioco terminato +Name[ja]=ゲームオーバー +Name[km]=ល្បែង​ចប់ +Name[ko]=SameGame +Name[lt]=Žaidimas baigtas +Name[lv]=Spēles beigas +Name[mk]=Играта заврши +Name[mt]=Il-Logħba Spiċċat +Name[nb]=Spillet er slutt +Name[nds]=Speel vörbi +Name[ne]=खेल समाप्त +Name[nl]=Spel is afgelopen +Name[nn]=Spelet er slutt +Name[nso]=Papadi e Fedile +Name[pa]=ਖੇਡ ਖਤਮ +Name[pl]=Koniec gry +Name[pt]=Fim do jogo +Name[pt_BR]=Fim do jogo +Name[ro]=Joc terminat +Name[ru]=Конец игры +Name[se]=Speallu nogai +Name[sk]=Koniec hry +Name[sl]=Konec igre +Name[sr]=Крај игре +Name[sr@Latn]=Kraj igre +Name[sv]=Spelet är slut +Name[ta]=ஆட்டம் முடிந்தது +Name[tg]=Бозӣ ба итмом расид +Name[th]=จบเกม +Name[tr]=Oyun Bitti +Name[uk]=Гру завершено +Name[uz]=Oʻyin tugadi +Name[uz@cyrillic]=Ўйин тугади +Name[ven]=Muthambo wo Fhela +Name[vi]=Game kết thúc +Name[wa]=Li djeu est houte +Name[xh]=Uphelile Umdlalo +Name[zh_CN]=游戏结束 +Name[zh_TW]=遊戲結束 +Name[zu]=Umdlalo uphelile +Comment=Game over +Comment[be]=Канец гульні +Comment[bg]=Край на играта +Comment[bn]=খেল খতম +Comment[br]=Echu an abadenn +Comment[bs]=Kraj igre +Comment[ca]=Fi de la partida +Comment[cs]=Hra skončena +Comment[cy]=Gêm drosodd +Comment[da]=Spil forbi +Comment[de]=Das Spiel ist vorbei +Comment[el]=Τέλος παιχνιδιού +Comment[eo]=Ludo finita +Comment[es]=Fin de la partida +Comment[et]=Mäng läbi +Comment[eu]=Jokoa amaitu da +Comment[fa]=بازی تمام شد +Comment[fi]=Peli loppui +Comment[fr]=Fin de la partie +Comment[ga]=Cluiche thart +Comment[he]=סיום משחק +Comment[hr]=Kraj igre +Comment[hu]=Vége a játéknak +Comment[is]=Leik lokið +Comment[it]=Gioco terminato +Comment[ja]=ゲームオーバー +Comment[km]=ល្បែង​ចប់ +Comment[lt]=Žaidimas baigtas +Comment[lv]=Spēle beigusies +Comment[mk]=Играта заврши +Comment[nb]=Spillet er slutt +Comment[nds]=Speel vörbi +Comment[ne]=खेल समाप्त +Comment[nl]=Het spel is afgelopen +Comment[nn]=Spelet er slutt +Comment[pa]=ਖੇਡ ਖਤਮ +Comment[pl]=Koniec gry +Comment[pt]=Fim do jogo +Comment[pt_BR]=Fim do Jogo +Comment[ru]=Конец игры +Comment[se]=Speallu nogai +Comment[sk]=Koniec hry +Comment[sl]=Konec igre +Comment[sr]=Крај игре +Comment[sr@Latn]=Kraj igre +Comment[sv]=Spelet slut +Comment[ta]=ஆட்டம் முடிந்தது +Comment[tr]=Oyun bitti +Comment[uk]=Кінець гри +Comment[wa]=Li djeu est houte +Comment[zh_CN]=游戏结束 +Comment[zh_TW]=遊戲結束 +default_presentation=0 diff --git a/klickety/field.cpp b/klickety/field.cpp new file mode 100644 index 00000000..4b85a3fe --- /dev/null +++ b/klickety/field.cpp @@ -0,0 +1,80 @@ +#include "field.h" +#include "field.moc" + +#include +#include + +#include +#include +#include + +#include "base/board.h" + + +Field::Field(QWidget *parent) + : QWidget(parent, "field"), BaseField(this) +{ + KGameLCDList *sc = new KGameLCDList(i18n("Remaining blocks"), this); + showScore = new KGameLCD(3, sc); + sc->append(showScore); + QWhatsThis::add(sc, i18n("Display the number of remaining " + "blocks.
" + "It turns blue" + " if it is a highscore " + "and red " + "if it is the best local score.
")); + lcds->addWidget(sc, 1, 0); + lcds->setRowStretch(2, 1); + + KGameLCDList *et = new KGameLCDList(i18n("Elapsed time"), this); + elapsedTime = new KGameLCDClock(et); + connect(board, SIGNAL(firstBlockClicked()), elapsedTime, SLOT(start())); + et->append(elapsedTime); + lcds->addWidget(et, 5, 0); + lcds->setRowStretch(6, 1); + + connect(board, SIGNAL(scoreUpdated()), SLOT(scoreUpdatedSlot())); + connect(board, SIGNAL(gameOverSignal()), SLOT(gameOver())); + + settingsChanged(); + connect(parent, SIGNAL(settingsChanged()), SLOT(settingsChanged())); + QTimer::singleShot(0, this, SLOT(start())); +} + +void Field::pause() +{ + if ( board->isGameOver() ) return; + bool paused = board->isPaused(); + if (paused) elapsedTime->start(); + else elapsedTime->stop(); + BaseField::pause(!paused); +} + +void Field::start() +{ + init(false, false, true, true, QString::null); + GTInitData data; + data.seed = kapp->random(); + BaseField::start(data); + elapsedTime->reset(); +} + +void Field::gameOver() +{ + elapsedTime->stop(); + stop(true); + BaseField::gameOver(currentScore(), this); +} + +KExtHighscore::Score Field::currentScore() const +{ + KExtHighscore::Score score(KExtHighscore::Won); + score.setScore(board->score()); + score.setData("time", 3600 - elapsedTime->seconds()); + return score; +} + +bool Field::_isPaused() const +{ + return board->isPaused(); +} diff --git a/klickety/field.h b/klickety/field.h new file mode 100644 index 00000000..67e6529b --- /dev/null +++ b/klickety/field.h @@ -0,0 +1,33 @@ +#ifndef KL_FIELD_H +#define KL_FIELD_H + +#include + +#include "base/field.h" +#include "base/inter.h" + +class KGameLCDClock; + +class Field : public QWidget, public BaseField, public BaseInterface +{ + Q_OBJECT + public: + Field(QWidget *parent); + + private slots: + void scoreUpdatedSlot() { scoreUpdated(); } + void start(); + void gameOver(); + void settingsChanged() { BaseField::settingsChanged(); } + + private: + KGameLCDClock *elapsedTime; + + void pause(); + KExtHighscore::Score currentScore() const; + void _start() { start(); } + void _pause() { pause(); } + bool _isPaused() const; +}; + +#endif diff --git a/klickety/highscores.cpp b/klickety/highscores.cpp new file mode 100644 index 00000000..6c49952e --- /dev/null +++ b/klickety/highscores.cpp @@ -0,0 +1,27 @@ +#include "highscores.h" + +#include "base/factory.h" +#include "base/board.h" + + +using namespace KExtHighscore; + +KLHighscores::KLHighscores() +{ + Item *item = createItem(ScoreDefault); + setScoreItem(bfactory->bbi.width * bfactory->bbi.height + 1, item); + addScoreItem("time", createItem(ElapsedTime)); +} + +bool KLHighscores::isStrictlyLess(const Score &s1, const Score &s2) const +{ + if ( s1.score()==s2.score() ) + return s1.data("time").toUInt()s2.score(); +} + +void KLHighscores::additionalQueryItems(KURL &url, const Score &s) const +{ + uint time = s.data("time").toUInt(); + addToQueryURL(url, "scoreTime", QString::number(time)); +} diff --git a/klickety/highscores.h b/klickety/highscores.h new file mode 100644 index 00000000..27548e69 --- /dev/null +++ b/klickety/highscores.h @@ -0,0 +1,18 @@ +#ifndef KL_HIGHSCORES_H +#define KL_HIGHSCORES_H + +#include "base/highscores.h" + + +class KLHighscores : public BaseHighscores +{ + public: + KLHighscores(); + + private: + bool isStrictlyLess(const KExtHighscore::Score &, + const KExtHighscore::Score &) const; + void additionalQueryItems(KURL &url, const KExtHighscore::Score &) const; +}; + +#endif diff --git a/klickety/klickety.desktop b/klickety/klickety.desktop new file mode 100644 index 00000000..dd93b3b2 --- /dev/null +++ b/klickety/klickety.desktop @@ -0,0 +1,84 @@ +[Desktop Entry] +Name=Klickety +Name[ar]=لعبة استراتيجية (Klickety) +Name[be]=Адбітак +Name[bn]=ক্লিকেটি +Name[hi]=के-लिकेटी +Name[ne]=केलिकेटि +Name[ta]=கேலிங்கட்டி +Name[zu]=I-Klickety +GenericName=Board Game +GenericName[af]=Bord Speletjie +GenericName[ar]=لعبة لوح +GenericName[be]=Настольная гульня +GenericName[bg]=Табла +GenericName[bn]=ছককেন্দ্রিক খেলা +GenericName[br]=Ur c'hoari taolenn +GenericName[bs]=Igra s pločom +GenericName[ca]=Joc de taula +GenericName[cs]=Desková Same +GenericName[cy]=Gêm Fwrdd +GenericName[da]=Brætspil +GenericName[de]=Brettspiel +GenericName[el]=Επιτραπέζιο παιχνίδι +GenericName[eo]=Tabuloludo +GenericName[es]=Juego de tablero +GenericName[et]=Lauamäng +GenericName[eu]=Mahai-jokoa +GenericName[fa]=بازی تخته +GenericName[fi]=Lautapeli +GenericName[fo]=Borðspæl +GenericName[fr]=Jeu de plateau +GenericName[ga]=Cluiche Chláir +GenericName[gl]=Xogo de Taboleiro +GenericName[he]=משחק לוח +GenericName[hi]=बिसात का खेल +GenericName[hr]=Igra na ploči +GenericName[hu]=Táblajáték +GenericName[is]=Borðleikur +GenericName[it]=Gioco da tavolo +GenericName[ja]=ボードゲーム +GenericName[km]=ល្បែង​ក្ដារ +GenericName[ko]=리버시 보드 게임 +GenericName[lt]=Stalo žaidimas +GenericName[lv]=Galda spēle +GenericName[mk]=Игра на табла +GenericName[mt]=Logħba tal-bord +GenericName[nb]=Brettspill +GenericName[nds]=Brettspeel +GenericName[ne]=बोर्ड खेल +GenericName[nl]=Bordspel +GenericName[nn]=Brettspel +GenericName[pa]=ਬੋਰਡ ਖੇਡ +GenericName[pl]=Gra planszowa +GenericName[pt]=Jogo de Tabuleiro +GenericName[pt_BR]=Jogo de Tabuleiro +GenericName[ro]=Un joc de table +GenericName[ru]=Настольная игра +GenericName[rw]=Umukino w'Ikibaho +GenericName[se]=Duolbbášspeallu +GenericName[sk]=Stolová hra +GenericName[sl]=Namizna igra +GenericName[sr]=Игра на табли +GenericName[sr@Latn]=Igra na tabli +GenericName[sv]=Brädspel +GenericName[ta]=பலகை விளையாட்டு +GenericName[tg]=Бозии Рӯи Мизӣ +GenericName[th]=เกมกระดาน +GenericName[tr]=Tahta Oyunu +GenericName[uk]=Гра на дошці +GenericName[uz]=Stol oʻyini +GenericName[uz@cyrillic]=Стол ўйини +GenericName[ven]=Mutambo wa Bodo +GenericName[vi]=Game bàn +GenericName[wa]=Djeu d' platea +GenericName[xh]=Umdlalo Webhodi +GenericName[zh_CN]=棋类游戏 +GenericName[zh_TW]=棋盤遊戲 +GenericName[zu]=Umdlalo webhodi +Icon=klickety +Exec=klickety -caption "%c" %i %m +Type=Application +DocPath=klickety/index.html +Comment= +Categories=Qt;KDE;Game;StrategyGame; diff --git a/klickety/klicketyui.rc b/klickety/klicketyui.rc new file mode 100644 index 00000000..2571e1ef --- /dev/null +++ b/klickety/klicketyui.rc @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/klickety/main.cpp b/klickety/main.cpp new file mode 100644 index 00000000..da6b0afe --- /dev/null +++ b/klickety/main.cpp @@ -0,0 +1,73 @@ +#include "main.h" +#include "main.moc" + +#include +#include +#include +#include + +#include "base/settings.h" +#include "piece.h" +#include "highscores.h" + +//----------------------------------------------------------------------------- +const MainData MAIN_DATA = { + "klickety", + I18N_NOOP("Klickety"), + I18N_NOOP("Klickety is an adaptation of the \"clickomania\" game"), + "http://klickety.sourceforge.net/", + I18N_NOOP("Removed blocks"), + "1.0.3", + "1.0.3 (5 August 2004)" +}; + +const uint HISTOGRAM_SIZE = 16; +const uint HISTOGRAM[HISTOGRAM_SIZE] = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 20, 160 +}; + +const BaseBoardInfo BASE_BOARD_INFO = { + 10, 16, false, // width, height, with pieces + + 50, // before remove time + 10, // after removed time + 3, // nb toggles + 7, // nb partial fall stages + + 0, // nb arcade stages + + HISTOGRAM, HISTOGRAM_SIZE, true, // score is bound +}; + +KLFactory::KLFactory() + : BaseFactory(MAIN_DATA, BASE_BOARD_INFO) +{ + _aboutData->addCredit("Dan Hill", I18N_NOOP("Icons")); +} + + +//----------------------------------------------------------------------------- +KLMainWindow::KLMainWindow() +{ + Field *field = static_cast(_inter); + buildGUI(field); +} + +//----------------------------------------------------------------------------- +int main(int argc, char **argv) +{ + KHighscore::init(MAIN_DATA.appName); + KLFactory flf; + flf.init(argc, argv); + + KLPieceInfo pieceInfo; + KLHighscores highscores; + + if ( kapp->isRestored() ) RESTORE(KLMainWindow) + else { + KLMainWindow *mw = new KLMainWindow; + kapp->setMainWidget(mw); + mw->show(); + } + return kapp->exec(); +} diff --git a/klickety/main.h b/klickety/main.h new file mode 100644 index 00000000..e5b335f8 --- /dev/null +++ b/klickety/main.h @@ -0,0 +1,29 @@ +#ifndef KL_MAIN_H +#define KL_MAIN_H + +#include "base/main.h" +#include "base/factory.h" +#include "board.h" +#include "field.h" + + +class KLFactory : public BaseFactory +{ + public: + KLFactory(); + + protected: + virtual BaseBoard *createBoard(bool, QWidget *parent) + { return new KLBoard(parent); } + virtual BaseInterface *createInterface(QWidget *parent) + { return new Field(parent); } +}; + +class KLMainWindow : public BaseMainWindow +{ + Q_OBJECT + public: + KLMainWindow(); +}; + +#endif diff --git a/klickety/pics/Makefile.am b/klickety/pics/Makefile.am new file mode 100644 index 00000000..c471f62b --- /dev/null +++ b/klickety/pics/Makefile.am @@ -0,0 +1,3 @@ + +KDE_ICON= AUTO + diff --git a/klickety/pics/hi128-app-klickety.png b/klickety/pics/hi128-app-klickety.png new file mode 100644 index 00000000..7e9ee5a5 Binary files /dev/null and b/klickety/pics/hi128-app-klickety.png differ diff --git a/klickety/pics/hi16-app-klickety.png b/klickety/pics/hi16-app-klickety.png new file mode 100644 index 00000000..5f34ab07 Binary files /dev/null and b/klickety/pics/hi16-app-klickety.png differ diff --git a/klickety/pics/hi22-app-klickety.png b/klickety/pics/hi22-app-klickety.png new file mode 100644 index 00000000..f1c969a1 Binary files /dev/null and b/klickety/pics/hi22-app-klickety.png differ diff --git a/klickety/pics/hi32-app-klickety.png b/klickety/pics/hi32-app-klickety.png new file mode 100644 index 00000000..d2bec938 Binary files /dev/null and b/klickety/pics/hi32-app-klickety.png differ diff --git a/klickety/pics/hi48-app-klickety.png b/klickety/pics/hi48-app-klickety.png new file mode 100644 index 00000000..d4d61bac Binary files /dev/null and b/klickety/pics/hi48-app-klickety.png differ diff --git a/klickety/pics/hi64-app-klickety.png b/klickety/pics/hi64-app-klickety.png new file mode 100644 index 00000000..46e67906 Binary files /dev/null and b/klickety/pics/hi64-app-klickety.png differ diff --git a/klickety/piece.cpp b/klickety/piece.cpp new file mode 100644 index 00000000..4a33910b --- /dev/null +++ b/klickety/piece.cpp @@ -0,0 +1,52 @@ +#include "piece.h" + +#include +#include +#include "base/board.h" + + +const char *KLPieceInfo::DEFAULT_COLORS[NB_BLOCK_TYPES] = { + "#C86464", "#64C864", "#6464C8", "#C8C864", "#C864C8" +}; + +QColor KLPieceInfo::defaultColor(uint i) const +{ + if ( i>=nbColors() ) return QColor(); + return QColor(DEFAULT_COLORS[i]); +} + +QString KLPieceInfo::colorLabel(uint i) const +{ + return i18n("Color #%1:").arg(i+1); +} + +void KLPieceInfo::draw(QPixmap *pixmap, uint blockType, uint bMode, + bool lighted) const +{ + QColor col = color(blockType); + if (lighted) col = col.light(); + pixmap->fill(col); + + QPainter p(pixmap); + QRect r = pixmap->rect(); + + p.setPen(col.dark()); + if ( !(bMode & BaseBoard::Up) ) + p.drawLine(r.topLeft(), r.topRight()); + if ( !(bMode & BaseBoard::Down) ) + p.drawLine(r.bottomLeft(), r.bottomRight()); + if ( !(bMode & BaseBoard::Left) ) + p.drawLine(r.topLeft(), r.bottomLeft()); + if ( !(bMode & BaseBoard::Right) ) + p.drawLine(r.topRight(),r.bottomRight()); + + p.setPen(col.dark(110)); + if (bMode & BaseBoard::Up) + p.drawLine(r.topLeft()+QPoint(1,0), r.topRight()+QPoint(-1,0)); + if (bMode & BaseBoard::Down) + p.drawLine(r.bottomLeft()+QPoint(1,0), r.bottomRight()+QPoint(-1,0)); + if (bMode & BaseBoard::Left) + p.drawLine(r.topLeft()+QPoint(0,1), r.bottomLeft()+QPoint(0,-1)); + if (bMode & BaseBoard::Right) + p.drawLine(r.topRight()+QPoint(0,1), r.bottomRight()+QPoint(0,-1)); +} diff --git a/klickety/piece.h b/klickety/piece.h new file mode 100644 index 00000000..b7d192f0 --- /dev/null +++ b/klickety/piece.h @@ -0,0 +1,42 @@ +#ifndef KL_PIECE_H +#define KL_PIECE_H + +#include "base/piece.h" + + +class KLPieceInfo : public GPieceInfo +{ + public: + KLPieceInfo() {} + + virtual uint nbBlocks() const { return 0; } + virtual uint nbTypes() const { return NB_BLOCK_TYPES; } + virtual uint nbForms() const { return 0; } + + virtual const int *i(uint, uint) const { return 0; } + virtual const int *j(uint, uint) const { return 0; } + virtual uint value(uint, uint) const { return 0; } + virtual uint form(uint) const { return 0; } + virtual uint nbConfigurations(uint) const { return 0; } + + virtual uint nbNormalBlockTypes() const { return NB_BLOCK_TYPES; } + virtual uint nbGarbageBlockTypes() const { return 0; } + virtual uint nbBlockModes() const { return 1+4+6+4+1; } + + virtual uint nbColors() const { return NB_BLOCK_TYPES; } + virtual QString colorLabel(uint i) const; + virtual QColor defaultColor(uint i) const; + + protected: + void draw(QPixmap *, uint blockType, uint blockMode, + bool lighted) const; + + private: + static const uint NB_BLOCK_TYPES = 5; + static const char *DEFAULT_COLORS[NB_BLOCK_TYPES]; +}; + +#endif + + + -- cgit v1.2.1