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 --- libksirtet/common/inter.cpp | 150 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 libksirtet/common/inter.cpp (limited to 'libksirtet/common/inter.cpp') diff --git a/libksirtet/common/inter.cpp b/libksirtet/common/inter.cpp new file mode 100644 index 00000000..e9f1688b --- /dev/null +++ b/libksirtet/common/inter.cpp @@ -0,0 +1,150 @@ +#include "inter.h" +#include "inter.moc" + +#include +#include +#include + +#include "factory.h" +#include "field.h" +#include "commonprefs.h" +#include "main.h" + + +const ActionData Interface::ACTION_DATA[Nb_Actions] = { + { I18N_NOOP("Move Left"), "move left", SLOT(moveLeft()), 0 }, + { I18N_NOOP("Move Right"), "move right", SLOT(moveRight()), 0 }, + { I18N_NOOP("Drop Down"), "drop down", SLOT(dropDownStart()), + SLOT(dropDownStop()) }, + { I18N_NOOP("One Line Down"), "one line down", SLOT(oneLineDown()), 0 }, + { I18N_NOOP("Rotate Left"), "rotate left", SLOT(rotateLeft()), 0 }, + { I18N_NOOP("Rotate Right"), "rotate right", SLOT(rotateRight()), 0 }, + { I18N_NOOP("Move to Left Column"), "move left total", + SLOT(moveLeftTotal()), 0 }, + { I18N_NOOP("Move to Right Column"), "move right total", + SLOT(moveRightTotal()), 0 } +}; + +const int Interface::KEYCODE_ONE[Nb_Actions] = { + Key_Left, Key_Right, Key_Down, Key_Shift, Key_Up, Key_Return, + CTRL+Key_Left, CTRL+Key_Right +}; +const int Interface::KEYCODE_TWO[Nb_Actions] = { + Key_F, Key_G, Key_D, Key_Space, Key_E, Key_C, SHIFT+Key_F, SHIFT+Key_G +}; + +Interface::Interface(const MPGameInfo &gi, QWidget *parent) + : MPSimpleInterface(gi, Nb_Actions, ACTION_DATA, parent) +{ + setDefaultKeycodes(1, 0, KEYCODE_ONE); + setDefaultKeycodes(2, 0, KEYCODE_TWO); + setDefaultKeycodes(2, 1, KEYCODE_ONE); +} + +MPBoard *Interface::newBoard(uint i) +{ + Field *f = static_cast(cfactory->createField(this)); + f->settingsChanged(); + connect(this, SIGNAL(settingsChanged()), f, SLOT(settingsChanged())); + if ( i==0 ) _firstField = f; + return f; +} + +void Interface::normalGame() +{ + singleHuman(); +} + +void Interface::arcadeGame() +{ + singleHuman(); + _firstField->setArcade(); +} + +void Interface::_init() +{ + if ( !server() ) return; + _data.resize(nbPlayers()); + _scores.setPlayerCount( nbPlayers() ); + for (uint i=0; i> _data[i]; + if (_data[i].end) end = true; + } + return end; +} + +void Interface::_sendPlayData() +{ + ServerPlayData sd; + for(uint i=0; iisArcade() ) { + _score.setType(KExtHighscore::Won); + BaseField::gameOver(_score, this); + } +} + +uint Interface::prev(uint i) const +{ + if ( i==0 ) return nbPlayers()-1; + else return i-1; +} + +uint Interface::next(uint i) const +{ + if ( i==(nbPlayers()-1) ) return 0; + else return i+1; +} + +// server only +void Interface::_treatInit() +{ + ServerInitData sid; + sid.seed = kapp->random(); + sid.initLevel = CommonPrefs::initialGameLevel(); + for (uint i=0; i1 ); + for (uint i=0; i> _score; + if (multiplayers) _scores.addScore(i, _score); + } + if (multiplayers) s << _scores; + // else no need to send anything +} + +// client only +void Interface::_readGameOverData(QDataStream &s) +{ + s >> _scores; +} -- cgit v1.2.1