Commit 82be4dac authored by Gaël de Chalendar's avatar Gaël de Chalendar
Browse files

Ported the main menu to use an ui generated with designer instead of a hardcoded one;

Start of a better integration of Jabber playing

svn path=/branches/work/ksirk.jabber/; revision=863349
parent f21e9b44
......@@ -66,6 +66,7 @@ set(ksirk_SRCS
Dialogs/restartOrExitDialogImpl.cpp
Dialogs/joingame.cpp
Dialogs/jabberconnect.cpp
Dialogs/jabbergameui.cpp
main.cpp
decoratedgameframe.cpp
gestionSprites.cpp
......@@ -93,8 +94,10 @@ set(ksirk_UI
Dialogs/restartOrExitDialog.ui
Dialogs/jabberconnect.ui
Dialogs/joingame.ui
Dialogs/jabbergameui.ui
preferences.ui
)
mainMenu.ui
)
kde4_add_ui_files(ksirk_SRCS ${ksirk_UI} )
......
/* This file is part of KsirK.
Copyright (C) 2008 Gael de Chalendar <kleag@free.fr>
KsirK 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, version 2.
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
*/
#include "jabbergameui.h"
#include "ksirksettings.h"
#include <KDebug>
KsirkJabberGameWidget::KsirkJabberGameWidget(QWidget* parent) : QWidget(parent)
{
kDebug();
setupUi(this);
jabberid->setText(Ksirk::KsirkSettings::jabberId());
password->setText(Ksirk::KsirkSettings::jabberPassword());
roomjid->setText(Ksirk::KsirkSettings::roomJid());
roompassword->setText(Ksirk::KsirkSettings::roomPassword());
nickname->setText(Ksirk::KsirkSettings::nickname());
}
#include "jabbergameui.moc"
\ No newline at end of file
/* This file is part of KsirK.
Copyright (C) 2008 Gael de Chalendar <kleag@free.fr>
KsirK 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, version 2.
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
*/
#ifndef JABBERGAMEWIDGET_H
#define JABBERGAMEWIDGET_H
#include "ui_jabbergameui.h"
#include <QWidget>
class KsirkJabberGameWidget : public QWidget, public Ui::KsirkJabberGameWidget
{
Q_OBJECT
public:
KsirkJabberGameWidget(QWidget* parent);
};
#endif
<ui version="4.0" >
<class>KsirkJabberGameWidget</class>
<widget class="QWidget" name="KsirkJabberGameWidget" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>395</height>
</rect>
</property>
<property name="windowTitle" >
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_3" >
<item row="0" column="0" >
<widget class="QStackedWidget" name="stackedWidget" >
<property name="currentIndex" >
<number>0</number>
</property>
<widget class="QWidget" name="jabberconnectpage" >
<layout class="QVBoxLayout" name="verticalLayout_4" >
<item>
<widget class="QLabel" name="label_7" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Connection to the Jabber Network</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_4" >
<item row="0" column="0" >
<widget class="QLabel" name="label" >
<property name="text" >
<string>Jabber ID:</string>
</property>
</widget>
</item>
<item rowspan="2" row="0" column="2" >
<widget class="KLineEdit" name="jabberid" >
<property name="text" >
<string>kleag@kdetalk.net</string>
</property>
</widget>
</item>
<item rowspan="2" row="1" column="2" >
<widget class="KLineEdit" name="password" >
<property name="text" >
<string>12345678</string>
</property>
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_2" >
<property name="text" >
<string>Password:</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4" >
<item>
<widget class="KPushButton" name="connectbutton" >
<property name="text" >
<string>Connect</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_8" >
<property name="text" >
<string>State :</string>
</property>
</widget>
</item>
<item>
<widget class="KLed" name="jabberstateled" >
<property name="layoutDirection" >
<enum>Qt::LeftToRight</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_4" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>143</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="chatroomconnectpage" >
<layout class="QVBoxLayout" name="verticalLayout_2" >
<item>
<widget class="QLabel" name="label_9" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Joining a KsirK Jabber Chatroom</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_2" >
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Room JID:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="KLineEdit" name="roomjid" />
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Nickname:</string>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="KLineEdit" name="nickname" />
</item>
<item row="2" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Room Password:</string>
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="KLineEdit" name="roompassword" >
<property name="echoMode" >
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3" >
<item>
<widget class="KPushButton" name="joinroombutton" >
<property name="text" >
<string>Join Room</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="label_10" >
<property name="text" >
<string>State:</string>
</property>
</widget>
</item>
<item>
<widget class="KLed" name="chatroomstateled" />
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer_2" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>97</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>joinroombutton</zorder>
<zorder>roompassword</zorder>
<zorder>nickname</zorder>
<zorder>label_5</zorder>
<zorder>label_4</zorder>
<zorder>roomjid</zorder>
<zorder>label_3</zorder>
<zorder>label_9</zorder>
<zorder>verticalSpacer_2</zorder>
<zorder></zorder>
<zorder>verticalSpacer_2</zorder>
<zorder>layoutWidget</zorder>
</widget>
<widget class="QWidget" name="roomgamespage" >
<layout class="QGridLayout" name="gridLayout" >
<item row="0" column="0" >
<widget class="QLabel" name="label_6" >
<property name="font" >
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text" >
<string>Games in the room</string>
</property>
</widget>
</item>
<item row="1" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QTableWidget" name="tableWidget" />
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout" >
<item>
<widget class="KPushButton" name="startnewgamebutton" >
<property name="text" >
<string>Start a New Game</string>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="joingamebutton" >
<property name="text" >
<string>Join Selected Game</string>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="loadsavedgamebutton" >
<property name="text" >
<string>Load a Saved Game</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</widget>
</item>
<item row="1" column="0" >
<spacer name="verticalSpacer_3" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>59</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0" >
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<spacer name="horizontalSpacer" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="KPushButton" name="previousbutton" >
<property name="text" >
<string>&lt; Previous</string>
</property>
</widget>
</item>
<item>
<widget class="KPushButton" name="nextbutton" >
<property name="text" >
<string>Next ></string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>KLed</class>
<extends>QWidget</extends>
<header>kled.h</header>
</customwidget>
<customwidget>
<class>KLineEdit</class>
<extends>QLineEdit</extends>
<header>klineedit.h</header>
</customwidget>
<customwidget>
<class>KPushButton</class>
<extends>QPushButton</extends>
<header>kpushbutton.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
......@@ -66,10 +66,10 @@ namespace Ksirk
hostEdit->setFocus();
QStringList headers;
headers.push_back("Nickname");
headers.push_back("Host");
headers.push_back("Port");
headers.push_back("Skin");
headers.push_back(i18n("Nickname"));
headers.push_back(i18n("Host"));
headers.push_back(i18n("Port"));
headers.push_back(i18n("Skin"));
jabberTable->setHorizontalHeaderLabels(headers);
}
......
......@@ -8,7 +8,7 @@
<x>0</x>
<y>0</y>
<width>526</width>
<height>424</height>
<height>403</height>
</rect>
</property>
<property name="windowTitle" >
......@@ -28,7 +28,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="3" >
<item row="1" column="0" colspan="4" >
<widget class="QSpinBox" name="playersNumberEntry" >
<property name="toolTip" >
<string>Spin this to choose the number of players.</string>
......@@ -38,19 +38,6 @@
</property>
</widget>
</item>
<item row="1" column="3" >
<widget class="QCheckBox" name="networkGameCheckBox" >
<property name="toolTip" >
<string>Check this to create a network game</string>
</property>
<property name="whatsThis" >
<string>A network game will be created if checked</string>
</property>
<property name="text" >
<string>Ne&amp;twork game</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="4" >
<widget class="Line" name="line1" >
<property name="frameShape" >
......@@ -204,7 +191,6 @@
<tabstop>playersNumberEntry</tabstop>
<tabstop>radioWorld</tabstop>
<tabstop>radioGoal</tabstop>
<tabstop>networkGameCheckBox</tabstop>
</tabstops>
<resources/>
<connections/>
......
......@@ -82,7 +82,7 @@ void NewGameDialogImpl::slotOK()
m_nbPlayers = playersNumberEntry->value();
m_skin = m_worlds[skinCombo->currentText()]->skin();
kDebug() << " m_skin is " << m_skin;
m_networkGame = networkGameCheckBox->isChecked();
// m_networkGame = networkGameCheckBox->isChecked();
m_useGoals = (radioGoal->isChecked());
emit newGameOK(m_nbPlayers, m_skin, m_networkGame, m_useGoals);
// accept();
......
......@@ -289,7 +289,7 @@ GameAutomaton::GameState GameAutomaton::run()
if (event == "actionNewGame")
{
if (m_game->actionNewGame())
if (m_game->actionNewGame(false))
{
state(INIT);
QTimer::singleShot(200, this, SLOT(run()));
......@@ -1222,7 +1222,7 @@ QDataStream& operator>>(QDataStream& s, GameAutomaton::GameState& state)
}
bool GameAutomaton::setupPlayersNumberAndSkin()
bool GameAutomaton::setupPlayersNumberAndSkin(bool socket)
{
kDebug() << endl;
QMap< QString, QString > nations = m_game->nationsList();
......@@ -1233,7 +1233,7 @@ bool GameAutomaton::setupPlayersNumberAndSkin()
KMessageBox::error(m_game, mes, i18n("Fatal Error!"));
exit(1);
}
m_socketkGame = socket;
m_game->newGameDialog(nations.size(), m_skin.value());
return false;
......@@ -1255,7 +1255,7 @@ bool GameAutomaton::finishSetupPlayersNumberAndSkin(const QString& skin, bool ne
m_skin = skin;
// }
if (networkGame)
if (m_socketkGame)
{
// porting
KDialog* dialog = new KDialog( m_game );
......@@ -1801,7 +1801,7 @@ void GameAutomaton::slotConnectionToServerBroken()
KGuiItem(i18n("Do nothing")))
== KMessageBox::Yes)
{
if (!m_game->actionNewGame())
if (!m_game->actionNewGame(false))
exit(0);
}
else
......@@ -1832,7 +1832,7 @@ void GameAutomaton::slotConnectionToClientBroken(KMessageIO *)
case KMessageBox::No :;
default: ;
}
if (!m_game->actionNewGame())
if (!m_game->actionNewGame(false))
exit(1);
}
// else
......
......@@ -312,7 +312,7 @@ public:
* will contain the port on which we will wait for connections.
* @param newPlayersNumber Will contain the number players of the new game.
*/
bool setupPlayersNumberAndSkin();
bool setupPlayersNumberAndSkin(bool socket);
/**
* Create an IO device like Mouse or Keyboard for the given player
......@@ -551,7 +551,8 @@ private:
KPixmapCache m_pixmapCache;
QMap<QString, QSvgRenderer*> m_renderers;
QMap<QString, KGameSvgDocument> m_svgDoms;
bool m_socketkGame;
};
QDataStream& operator>>(QDataStream& s, GameAutomaton::GameState& state);
......
......@@ -286,6 +286,13 @@ void DecoratedGameFrame::slotMouseInput(KGameIO *input,QDataStream &stream,QMous
kDebug() << e;
QGraphicsItem* item = itemAt(mapFromScene(((QGraphicsSceneMouseEvent*)e)->scenePos()));
if (item == 0)
{
*eatevent=false;
e->setAccepted(false);
return;
}
while (item->parentItem()!=0 && dynamic_cast<KGamePopupItem*>(item)==0)
{
item = item->parentItem();
......
......@@ -19,7 +19,8 @@
/* begin : mer jui 11 22:27:28 EDT 2001 */
// application specific includes
#include "kgamewin.h"
#include "kgamewin.h"
#include "mainMenu.h"
#include "ksirkConfigDialog.h"
#include "ksirksettings.h"
#include "MessageBubble.h"
......@@ -43,6 +44,7 @@
#include "Dialogs/kwaitedplayersetupdialog.h"
#include "Dialogs/restartOrExitDialogImpl.h"
#include "Dialogs/newGameDialogImpl.h"
#include "Dialogs/jabbergameui.h"
#include "im.h"
#include "xmpp_tasks.h"
......@@ -574,7 +576,7 @@ void KGameWindow::newSkin(const QString& onuFileName)
bool firstCall = false;
if (m_mainMenu == 0)