Commit a7e42b33 authored by Gaël de Chalendar's avatar Gaël de Chalendar

New skin editor for KsirK; just an empty window right now

svn path=/trunk/KDE/kdegames/ksirk/; revision=848523
parent d5990b13
......@@ -5,4 +5,5 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${KDE4_ENABLE_EXCEPTIONS}")
remove_definitions(-DQT_NO_STL)
add_subdirectory(ksirk)
add_subdirectory(ksirkskineditor)
......@@ -1022,7 +1022,7 @@ void GameAutomaton::gameEvent(const ::std::string& event, const QPointF& point)
/** returns the name of the current state */
QString GameAutomaton::stateName() const
{
if ((size_t)(m_state) >= sizeof(GameStateNames))
if (m_state >= sizeof(GameStateNames))
{
::std::ostringstream oss;
oss << "Invalid stored state id: " << m_state;
......
......@@ -248,7 +248,7 @@ central-point=562,212
cannon-point=542,169
cavalry-point=573,183
infantry-point=522,224
neighbours=14,16
neighbours=14,16,18
[Russia]
id=18
......@@ -258,7 +258,7 @@ central-point=733,203
cannon-point=652,207
cavalry-point=774,209
infantry-point=740,156
neighbours=16,22,23,24
neighbours=16,17,22,23,24
[Iran]
id=19
......@@ -268,7 +268,7 @@ central-point=618,341
cannon-point=574,332
cavalry-point=616,353
infantry-point=637,361
neighbours=16,21,33,35
neighbours=16,21,33
# ,34
[China]
......@@ -441,7 +441,7 @@ central-point=719,377
cannon-point=714,362
cavalry-point=695,407
infantry-point=685,387
neighbours=19,20,21,36
neighbours=20,21,36
[Vietnam]
......@@ -556,7 +556,7 @@ continent-countries=12,13,14,15,16,17,22
#4
[Africa]
id=4
bonus=3
bonus=6
continent-countries=26,27,28,29,30,31,32,33
# ,34
......
# add_subdirectory( skins )
include_directories(
${CMAKE_BINARY_DIR}/ksirkskineditor
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
########### next target ###############
set(ksirkskineditor_SRCS
main.cpp
mainwindow.cpp
ksirkSkinEditorConfigDialog.cpp
)
set(ksirkskineditor_UI
# ksirkskineditor.ui
preferences.ui
)
kde4_add_ui_files(ksirkskineditor_SRCS ${ksirkskineditor_UI} )
kde4_add_kcfg_files( ksirkskineditor_SRCS ksirkskineditorsettings.kcfgc )
kde4_add_app_icon(ksirkskineditor_SRCS "hi*-app-ksirkskineditor.png")
kde4_add_executable(ksirkskineditor ${ksirkskineditor_SRCS})
target_link_libraries(ksirkskineditor
${QT_QTXML_LIBRARY}
${QT_QTSVG_LIBRARY}
${KDE4_KIO_LIBS}
${KDE4_PHONON_LIBRARY}
${CRYPT_LIBS}
${KDEGAMES_LIBRARY}
)
install( TARGETS ksirkskineditor ${INSTALL_TARGETS_DEFAULT_ARGS})
########### install files ###############
kde4_install_icons( ${ICON_INSTALL_DIR} )
install( FILES ksirkskineditorsettings.kcfg DESTINATION ${KCFG_INSTALL_DIR} )
install( FILES ksirkskineditor.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} )
install( FILES ksirkskineditorui.rc DESTINATION ${DATA_INSTALL_DIR}/ksirkskineditor )
/* 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 "ksirkSkinEditorConfigDialog.h"
#include "ksirkskineditorsettings.h"
#include "ui_preferences.h"
#include <kfiledialog.h>
#include <kconfig.h>
#include <kurl.h>
#include <ktabwidget.h>
#include <kedittoolbar.h>
#include <kdebug.h>
#include <kstandardaction.h>
#include <klibloader.h>
#include <kmessagebox.h>
#include <kstatusbar.h>
#include <klocale.h>
#include <kconfigdialog.h>
#include <kapplication.h>
#include <qslider.h>
#include <qcheckbox.h>
#include <iostream>
using namespace KsirkSkinEditor;
KsirkSkinEditorConfigurationDialog::KsirkSkinEditorConfigurationDialog (
QWidget *parent, const char *name, KConfigSkeleton *config,
FaceType dialogType, ButtonCodes dialogButtons,
ButtonCode defaultButton, bool modal) :
KConfigDialog (parent, name, config) , m_changed(false),
m_widget(new Ui::KsirkSkinEditorPreferencesWidget())
{
setFaceType(dialogType);
setButtons(dialogButtons);
setDefaultButton(defaultButton);
setModal(modal);
QWidget* w = new QWidget();
m_widget->setupUi(w);
addPage( w, i18n("Preferences"), "games-config-options"/*, i18n("Preferences"), false*/);
// below, connection to activate the apply button
// connect(m_widget->reloadOnChangeMode, SIGNAL(clicked(int)), this, SLOT(settingChanged(int)));
}
KsirkSkinEditorConfigurationDialog::~KsirkSkinEditorConfigurationDialog ()
{
}
void KsirkSkinEditorConfigurationDialog::settingChanged(int)
{
kDebug();
m_changed = true;
//settingsChangedSlot();
//updateButtons ();
}
bool KsirkSkinEditorConfigurationDialog::hasChanged()
{
kDebug();
return m_changed;
}
void KsirkSkinEditorConfigurationDialog::updateSettings()
{
kDebug();
m_changed = false;
KsirkSkinEditorSettings::self()->writeConfig();
}
void KsirkSkinEditorConfigurationDialog::updateWidgets()
{
kDebug();
m_changed = false;
}
#include "ksirkSkinEditorConfigDialog.moc"
/* 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 _KSIRKSKINEDITORCONFIGDIALOG_H_
#define _KSIRKSKINEDITORCONFIGDIALOG_H_
#include <kconfigdialog.h>
namespace Ui
{
class KsirkSkinEditorPreferencesWidget;
}
/**
* This is the KsirK Skin Editor configuration dialog. Based on KConfigDialog.
*
* @short Configuration dialog
* @author Gaël de Chalendar (aka Kleag) <kleag@free.fr>
*/
class KsirkSkinEditorConfigurationDialog : public KConfigDialog
{
Q_OBJECT
public:
/**
* Constructor
*/
KsirkSkinEditorConfigurationDialog (
QWidget *parent, const char *name, KConfigSkeleton *config,
FaceType faceType=List,
ButtonCodes dialogButtons=Default|Ok|Apply|Cancel|Help,
ButtonCode defaultButton=Ok, bool modal=false);
/** Destructor */
virtual ~KsirkSkinEditorConfigurationDialog ();
Q_SIGNALS:
protected Q_SLOTS:
virtual void updateSettings();
virtual void updateWidgets();
void settingChanged(int);
protected:
virtual bool hasChanged();
bool m_changed;
Ui::KsirkSkinEditorPreferencesWidget* m_widget;
};
#endif
# KDE Config File
[Desktop Entry]
Type=Application
Exec=ksirkskineditor -caption "%c" %i
Icon=ksirkskineditor
X-DocPath=ksirkskineditor/index.html
Terminal=false
Name=KsirK Skin Editor
Name[sv]=KsirkSkinEditor
Name[x-test]=xxKsirkSkinEditorxx
GenericName=Skin Editor for the World Domination Strategy Game
GenericName[fr]=Editeur de Thème pour le Jeu de stratégie pour la domination du monde
Categories=Qt;KDE;Game;StrategyGame;
X-KDE-StartupNotify=true
X-DBUS-StartupType=Multi
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE kcfg SYSTEM "http://www.kde.org/standards/kcfg/1.0/kcfg.dtd">
<kcfg>
<kcfgfile name="ksirkskineditorrc"/>
<group name="General">
</group>
</kcfg>
File=ksirkskineditorsettings.kcfg
ClassName=KsirkSkinEditorSettings
Singleton=true
Mutators=true
NameSpace=KsirkSkinEditor
\ No newline at end of file
<!DOCTYPE kpartgui>
<kpartgui name="ksirkskineditor" version="1">
<MenuBar>
<Menu name="game"><text>&amp;Game</text>
<Action name="game_new" append="new_merge" />
<Action name="game_load" append="new_merge" />
<Action name="game_save" append="new_merge" />
<Separator/>
<Action name="game_quit" append="new_merge" />
</Menu>
<Menu name="settings"><text>&amp;Settings</text>
</Menu>
<Menu name="help"><text>&amp;Help</text>
</Menu>
</MenuBar>
<ToolBar name="mainToolBar" noMerge="1"><text>Main Toolbar</text>
<Action name="game_new" />
<Action name="game_load" />
<Action name="game_save" />
<Separator/>
<Action name="view_zoom_in" />
<Action name="view_zoom_out" />
<Separator/>
</ToolBar>
</kpartgui>
/***************************************************************************
main.cpp - description
-------------------
begin : mer jui 11 22:27:28 EDT 2001
copyright : (C) 2001 by Gaël de Chalendar
email : Gael.de.Chalendar@free.fr
This is the standard main function of a KDE application
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 "mainwindow.h"
#include <KCmdLineArgs>
#include <KAboutData>
#include <KLocale>
#include <KDebug>
#include <KApplication>
#include <KToolBar>
static const char *description =
I18N_NOOP("KsirK Skin Editor");
// INSERT A DESCRIPTION FOR YOUR APPLICATION HERE
int main(int argc, char *argv[])
{
kDebug() << "Hello World!";
KAboutData aboutData( "ksirkskineditor", 0, ki18n("KsirK Skin Editor"),
KDE_VERSION_STRING, ki18n(description), KAboutData::License_GPL,
ki18n("(c) 2008, Gaël de Chalendar\n"), ki18n("For help and user manuel, please see\nThe KsirK Web site"), "http://games.kde.org/game.php?game=ksirk", "kleag@free.fr");
aboutData.addAuthor(ki18n("Gael de Chalendar aka Kleag"),KLocalizedString(), "kleag@free.fr");
KCmdLineArgs::init( argc, argv, &aboutData );
KCmdLineOptions options;
options.add("+[File]", ki18n("file to open"));
KCmdLineArgs::addCmdLineOptions( options ); // Add our own options.
KApplication app;
if (app.isSessionRestored())
{
RESTORE(KsirkSkinEditor::MainWindow);
}
else
{
kDebug() << "Creating main window";
KsirkSkinEditor::MainWindow *ksirkskineditor = new KsirkSkinEditor::MainWindow();
ksirkskineditor->show();
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
args->clear();
}
kDebug() << "Executing app";
return app.exec();
}
/* 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
*/
// application specific includes
#include "mainwindow.h"
#include "ksirkSkinEditorConfigDialog.h"
#include "ksirkskineditorsettings.h"
//include files for QT
#include <QDockWidget>
#include <QTreeView>
#include <QPushButton>
#include <QGridLayout>
#include <QString>
#include <QVBoxLayout>
#include <QMovie>
// include files for KDE
#include <kiconloader.h>
#include <kmessagebox.h>
#include <kfiledialog.h>
#include <klocale.h>
#include <kconfig.h>
#include <kstandardgameaction.h>
#include <kstandardaction.h>
#include <kactioncollection.h>
#include <kstandarddirs.h>
#include <kmenubar.h>
#include <kdebug.h>
#include <ktextedit.h>
#include <phonon/mediaobject.h>
#include <KPushButton>
#include <kglobal.h>
#include <KStatusBar>
#include <KToolBar>
#include <KAction>
#include <KSvgRenderer>
#include <KDialog>
#include <KAboutApplicationDialog>
#include <assert.h>
namespace KsirkSkinEditor
{
MainWindow::MainWindow(QWidget* parent) :
KXmlGuiWindow(parent)
{
kDebug() << "MainWindow constructor begin";
m_dirs = KGlobal::dirs();
// m_accels.setEnabled(true);
QString iconFileName = m_dirs-> findResource("appdata", "ksirkskineditor.png");
/* if (iconFileName.isNull())
{
KMessageBox::error(0, i18n("Cannot load icon<br>Program cannot continue"), i18n("Error !"));
exit(2);
}*/
QPixmap icon(iconFileName);
// kDebug() << "Before initActions";
initActions();
kDebug() << "Setting up GUI";
setupGUI();
// kDebug() << "Before initStatusBar";
initStatusBar();
menuBar()-> show();
setMouseTracking(true);
}
MainWindow::~MainWindow()
{
kDebug();
m_dirs = 0;
}
void MainWindow::initActions()
{
QAction *action;
// standard game actions
// action = KStandardGameAction::gameNew(this, SLOT(slotNewGame()), this);
// actionCollection()->addAction(action->objectName(), action);
// action = KStandardGameAction::load(this, SLOT(slotOpenGame()), this);
// actionCollection()->addAction(action->objectName(), action);
// m_saveGameAction = KStandardGameAction::save(this, SLOT(slotSaveGame()), this);
// actionCollection()->addAction(m_saveGameAction->objectName(), m_saveGameAction);
// action = KStandardGameAction::quit(this, SLOT(close()), this);
// actionCollection()->addAction(action->objectName(), action);
action = KStandardAction::zoomIn(this, SLOT(slotZoomIn()), this);
actionCollection()->addAction(action->objectName(), action);
action = KStandardAction::zoomOut(this, SLOT(slotZoomOut()), this);
actionCollection()->addAction(action->objectName(), action);
KStandardAction::preferences( this, SLOT( optionsConfigure() ), actionCollection() );
}
void MainWindow::initStatusBar()
{
statusBar()-> setSizeGripEnabled(true);
}
/**
* Reimplementation of the inherited function called when a window close event arise
*/
bool MainWindow::queryClose()
{
// TODO : Test si jeu en cours
return true;
}
void MainWindow::saveXml(std::ostream& xmlStream)
{
xmlStream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << std::endl;
xmlStream << "<ksirkskin formatVersion=\"2.0\" >" << std::endl;
xmlStream << "</ksirkskin>" << std::endl;
}
void MainWindow::optionsConfigure()
{
//An instance of your dialog could be already created and could be cached,
//in which case you want to display the cached dialog instead of creating
//another one
if ( KsirkSkinEditorConfigurationDialog::showDialog( "settings" ) )
return;
//KConfigDialog didn't find an instance of this dialog, so lets create it :
KsirkSkinEditorConfigurationDialog* dialog = new KsirkSkinEditorConfigurationDialog(
this, "settings",
KsirkSkinEditorSettings::self() );
dialog->show();
}
void MainWindow::slotZoomIn()
{
kDebug();
}
void MainWindow::slotZoomOut()
{
kDebug();
}
void MainWindow::slotShowAboutApplication()
{
KAboutApplicationDialog dialog(KGlobal::mainComponent().aboutData(), this);
dialog.exec();
}
bool MainWindow::queryExit()
{
// kDebug() << "Writing skin m_config: " << m_automaton->skin();
KGlobal::config()->sync();
return true;
}
} // closing namespace
#include "mainwindow.moc"
/* 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 MAINWINDOW_H
#define MAINWINDOW_H
// include files for Qt
#include <QPointF>
#include <QPixmap>
#include <QLabel>
#include <QPushButton>
#include <QStackedWidget>
#include <QGroupBox>
#include <QSplitter>
#include <QSlider>
#include <QHBoxLayout>
#include <QVBoxLayout>
// include files for KDE
#include <ksharedconfig.h>
#include <KXmlGuiWindow>
#include <KStandardDirs>
#include <KShortcut>
// include files for kde games
class QAction;
class KToolBar;
class KDialog;
class QEvent;
class QDockWidget;
class QGraphicsScene;
namespace Phonon
{
class MediaObject;
}
namespace KsirkSkinEditor
{
/**
* This is the main window.
*