summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Changelog8
-rw-r--r--Doxyfile2
-rw-r--r--sigbattle/ActionQueue.h24
-rw-r--r--sigmod/Badge.h58
-rw-r--r--sigmod/Fraction.cpp4
-rw-r--r--sigmod/Fraction.h58
-rw-r--r--sigmod/Global.h33
-rw-r--r--sigmod/Hat.h70
-rw-r--r--sigmod/Macros.h7
-rw-r--r--sigmod/Map.cpp9
-rw-r--r--sigmod/Map.h1
-rw-r--r--sigmod/Matrix.h153
-rw-r--r--sigmod/Object.cpp29
-rw-r--r--sigmod/Object.h100
-rw-r--r--sigmod/Script.h53
-rw-r--r--sigmod/Sigmod.h46
-rw-r--r--sigmodr/MapEffectUI.cpp3
-rw-r--r--sigmodr/MapTrainerUI.cpp3
-rw-r--r--sigmodr/MapWarpUI.cpp3
-rw-r--r--sigmodr/ScriptWidget.cpp22
-rw-r--r--sigmodr/TilemapModel.h2
-rw-r--r--sigmodr/TypechartModel.h6
-rw-r--r--sigscript/Config.h4
-rw-r--r--sigscript/MapWrapper.cpp5
-rw-r--r--sigscript/MapWrapper.h1
25 files changed, 563 insertions, 141 deletions
diff --git a/Changelog b/Changelog
index b6f42ce2..151689d1 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,12 @@
-----------------
+Rev: 272
+Date: 6 October 2008
+User: MathStuf
+-----------------
+[FIX] Started documenting Sigmod
+[FIX] A few minor bugs
+
+-----------------
Rev: 271
Date: 5 October 2008
User: MathStuf
diff --git a/Doxyfile b/Doxyfile
index fa022b80..2a410d18 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -83,7 +83,7 @@ FILE_VERSION_FILTER =
#---------------------------------------------------------------------------
# configuration options related to warning and progress messages
#---------------------------------------------------------------------------
-QUIET = NO
+QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
diff --git a/sigbattle/ActionQueue.h b/sigbattle/ActionQueue.h
index 91797932..9c456c84 100644
--- a/sigbattle/ActionQueue.h
+++ b/sigbattle/ActionQueue.h
@@ -29,43 +29,45 @@
namespace Sigbattle
{
-class SIGBATTLE_EXPORT ActionQueue : public QQueue<TeamMember::RequestedAction>
+class SIGBATTLE_EXPORT ActionQueue
{
public:
- ActionQueue();
-
TeamMember::RequestedAction dequeue();
void enqueue(const TeamMember::RequestedAction& action);
+ bool isEmpty();
+
TeamMember::RequestedAction& head();
void lock();
void unlock();
private:
+ QQueue<TeamMember::RequestedAction> m_queue;
QMutex m_mutex;
};
-inline ActionQueue::ActionQueue() :
- QQueue<TeamMember::RequestedAction>()
-{
-}
-
inline TeamMember::RequestedAction ActionQueue::dequeue()
{
QMutexLocker locker(&m_mutex);
- return QQueue<TeamMember::RequestedAction>::dequeue();
+ return m_queue.dequeue();
}
inline void ActionQueue::enqueue(const TeamMember::RequestedAction& action)
{
QMutexLocker locker(&m_mutex);
- QQueue<TeamMember::RequestedAction>::enqueue(action);
+ m_queue.enqueue(action);
}
inline TeamMember::RequestedAction& ActionQueue::head()
{
QMutexLocker locker(&m_mutex);
- return QQueue<TeamMember::RequestedAction>::head();
+ return m_queue.head();
+}
+
+inline bool ActionQueue::isEmpty()
+{
+ QMutexLocker locker(&m_mutex);
+ return m_queue.isEmpty();
}
inline void ActionQueue::lock()
diff --git a/sigmod/Badge.h b/sigmod/Badge.h
index debe7abe..e6a54ff0 100644
--- a/sigmod/Badge.h
+++ b/sigmod/Badge.h
@@ -36,7 +36,7 @@ class Sigmod;
* \brief Class describing a badge.
*
* Badges are used to show a trainer's worthiness. Without them, team members that are too high leveled may not
- * listen to its trainer. Some badges also boost stats (only with in-game battles).
+ * listen to its trainer. Badges may also boost stats.
*/
class SIGMOD_EXPORT Badge : public Object
{
@@ -59,7 +59,7 @@ class SIGMOD_EXPORT Badge : public Object
/**
* Data copy constructor. Copies the data from \p badge and parents the new badge with \p parent and id \p id.
*
- * \param ability The badge to copy the data from.
+ * \param badge The badge to copy the data from.
* \param parent The parent of the badge.
* \param id The id number for the badge.
*/
@@ -91,16 +91,70 @@ class SIGMOD_EXPORT Badge : public Object
*/
QDomElement save() const;
+ /**
+ * Sets the name of the badge to be used in the game.
+ *
+ * \param name The name of the badge.
+ */
void setName(const QString& name);
+ /**
+ * Set the \p id of the sprite that is to be used for the badge before it is obtained.
+ *
+ * \param face The \p id of the sprite to be used before the badge is obtained.
+ */
void setFace(const int face);
+ /**
+ * Set the \p id of the sprite that is to be used for the badge once it is obtained.
+ *
+ * \param badge The \p id of the sprite to be used after the badge is obtained.
+ */
void setBadge(const int badge);
+ /**
+ * Set the maximum level at which team members of the player are guaranteed to obey the player.
+ * Above this level, team members may not obey its trainer.
+ *
+ * \param obey The maximum level that is guaranteed to obey the player once the badge is obtained.
+ */
void setObey(const int obey);
+ /**
+ * Set a multiplier for a stat once the badge is obtained.
+ *
+ * \param stat The stat to set the multiplier for.
+ * \param multiplier The multiplier for the stat once the badge is obtained.
+ */
void setStat(const Stat stat, const Fraction& multiplier);
+ /**
+ * \sa setName
+ *
+ * \return The name of the badge.
+ */
QString name() const;
+ /**
+ * \sa setFace
+ *
+ * \return The \p id of the sprite that represents the badge before it is obtained.
+ */
int face() const;
+ /**
+ * \sa setBadge
+ *
+ * \return The \p id of the sprite that represents the badge once it has been obtained.
+ */
int badge() const;
+ /**
+ * \sa setObey
+ *
+ * \return The maximum level that is guaranteed to obey the player once the badge is obtained.
+ */
int obey() const;
+ /**
+ * \sa setStat
+ *
+ * \param stat The stat to get the multiplier for.
+ *
+ * \return The multiplier for the \p stat.
+ */
Fraction stat(const Stat stat) const;
Badge& operator=(const Badge& rhs);
diff --git a/sigmod/Fraction.cpp b/sigmod/Fraction.cpp
index f3f1ecd7..8bafe022 100644
--- a/sigmod/Fraction.cpp
+++ b/sigmod/Fraction.cpp
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Fraction.cpp
+ */
+
// Header include
#include "Fraction.h"
diff --git a/sigmod/Fraction.h b/sigmod/Fraction.h
index b2315fc3..65f59523 100644
--- a/sigmod/Fraction.h
+++ b/sigmod/Fraction.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Fraction.h
+ */
+
#ifndef SIGMOD_FRACTION
#define SIGMOD_FRACTION
@@ -26,21 +30,75 @@
namespace Sigmod
{
+/**
+ * \class Sigmod::Fraction Fraction.h sigmod/Fraction.h
+ * \brief Class that represents a fractional quantity.
+ *
+ * This class should be used in place of \p double because of accuracy.
+ */
class SIGMOD_EXPORT Fraction
{
public:
+ /**
+ * Constructor.
+ *
+ * \param numerator The numerator of the fraction.
+ * \param denominator The denominator of the fraction.
+ */
explicit Fraction(const int numerator = 1, const int denominator = 1);
+ /**
+ * Copy constructor.
+ *
+ * \param fraction The value to copy.
+ */
Fraction(const Fraction& fraction);
+ /**
+ * Set the value of the fraction.
+ *
+ * \param numerator The numerator of the fraction.
+ * \param denominator The denominator of the fraction.
+ */
void set(const int numerator, const int denominator);
+ /**
+ * Sets the numerator of the fraction.
+ *
+ * \param numerator The numerator of the fraction.
+ */
void setNumerator(const int numerator);
+ /**
+ * Set the denominator of the fraciton.
+ *
+ * \param denominator The denominator of the fraction.
+ */
void setDenominator(const int denominator);
+ /**
+ * \return The numerator of the fraction.
+ */
int numerator() const;
+ /**
+ * \return The denominator of the fraction.
+ */
int denominator() const;
+ /**
+ * Reduces the fraction.
+ */
void reduce();
+ /**
+ * Uses the value of the fraction to return a weighted boolean.
+ *
+ * \return \p true with a weight of the fraction, \p false otherwise.
+ */
bool poll() const;
+ /**
+ * Convenience function to get a weighted boolean value.
+ *
+ * \param numerator The numerator of the chance that the function returns \p true.
+ * \param demoninator The denominator of the chance that the function returns \p true.
+ * \return \p true with a weight of the (\p numerator / \p denominator), \p false otherwise.
+ */
static bool poll(const int numerator, const int demoninator);
Fraction& operator=(const Fraction& rhs);
diff --git a/sigmod/Global.h b/sigmod/Global.h
index ea75387a..a7fdd8e1 100644
--- a/sigmod/Global.h
+++ b/sigmod/Global.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Global.h
+ */
+
#ifndef SIGMOD_GLOBAL
#define SIGMOD_GLOBAL
@@ -26,21 +30,23 @@
#include <kdemacros.h>
#ifndef SIGMOD_EXPORT
-# ifdef MAKE_SIGMOD_LIB
- /* We are building this library */
-# define SIGMOD_EXPORT KDE_EXPORT
-# else
- /* We are using this library */
-# define SIGMOD_EXPORT KDE_IMPORT
-# endif
+# ifdef MAKE_SIGMOD_LIB
+# define SIGMOD_EXPORT KDE_EXPORT /// Export the symbol if building the library.
+# else
+# define SIGMOD_EXPORT KDE_IMPORT /// Import the symbol if including the library.
+# endif
#endif
-# ifndef SIGMOD_EXPORT_DEPRECATED
-# define SIGMOD_EXPORT_DEPRECATED KDE_DEPRECATED SIGMOD_EXPORT
-# endif
+#ifndef SIGMOD_EXPORT_DEPRECATED
+# define SIGMOD_EXPORT_DEPRECATED KDE_DEPRECATED SIGMOD_EXPORT /// Mark as deprecated
+#endif
namespace Sigmod
{
+/**
+ * \enum Stat
+ * \brief Enumeration of stats.
+ */
enum Stat
{
ST_HP = 0,
@@ -53,9 +59,15 @@ enum Stat
ST_Accuracy = 6,
ST_Evasion = 7,
};
+/// Strings for the stats for a combined Special stat.
const QStringList StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "" << "Accuracy" << "Evasion";
+/// Strings for the stats when the Special stat is split.
const QStringList StatGSCStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special Attack" << "Special Defense" << "Accuracy" << "Evasion";
+/**
+ * \enum Direction
+ * \brief Enumeration of directions.
+ */
enum Direction
{
D_Up = 0,
@@ -64,6 +76,7 @@ enum Direction
D_Right = 3,
D_None = 4
};
+/// Strings for the directions.
const QStringList DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None";
}
diff --git a/sigmod/Hat.h b/sigmod/Hat.h
index c9ae94f0..20514412 100644
--- a/sigmod/Hat.h
+++ b/sigmod/Hat.h
@@ -15,10 +15,15 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Hat.h
+ */
+
#ifndef SIGMOD_HAT
#define SIGMOD_HAT
// Sigmod includes
+#include "Fraction.h"
#include "Global.h"
// Qt includes
@@ -27,22 +32,72 @@
namespace Sigmod
{
+/**
+ * \class Sigmod::Hat Hat.h sigmod/Hat.h
+ * \brief Class to help choose items from a weighted set of items.
+ *
+ * Given a set of weighted items to choose from, Hat will pick out a random item from the set.
+ */
template<class T> class Hat
{
public:
+ /**
+ * Default constructor.
+ */
Hat();
+ /**
+ * Choose an item from the set without removal.
+ *
+ * \return The item chosen.
+ */
T pick() const;
+ /**
+ * Choose an item from the set with removal.
+ *
+ * \return The item chosen.
+ */
T take();
+ /**
+ * Choose an item from the set as well as all identical items.
+ *
+ * \return The item chosen.
+ */
T takeAndClear();
+ /**
+ * Set the weight of an item in the set.
+ *
+ * \param key The item to set.
+ * \param weight The weight of the item.
+ */
void setCount(const T& key, const int weight);
+ /**
+ * Add a number of items to the set.
+ *
+ * \param key The item to add to the set.
+ * \param weight How many of the item to add.
+ */
void add(const T& key, const int weight);
+ /**
+ * \return The number of distinct items in the set.
+ */
int distinctCount() const;
+ /**
+ * \return The number of total items in the set.
+ */
int count() const;
+ /**
+ * \param key The item to get the count of.
+ *
+ * \return The amount of \p key in the set.
+ */
int count(const T& key) const;
- double chance(const T& key) const;
-
- int operator[](const T& key) const;
+ /**
+ * \param key The item to get the chance of.
+ *
+ * \return The chance of choosing \p key.
+ */
+ Fraction chance(const T& key) const;
private:
QMap<T, int> m_objects;
int m_count;
@@ -119,14 +174,9 @@ template<class T> inline int Hat<T>::count(const T& key) const
return 0;
}
-template<class T> inline double Hat<T>::chance(const T& key) const
-{
- return (double(count(key)) / m_count);
-}
-
-template<class T> inline int Hat<T>::operator[](const T& key) const
+template<class T> inline Fraction Hat<T>::chance(const T& key) const
{
- return count(key);
+ return Fraction(count(key), m_count);
}
}
diff --git a/sigmod/Macros.h b/sigmod/Macros.h
index 6d61526a..dd149746 100644
--- a/sigmod/Macros.h
+++ b/sigmod/Macros.h
@@ -15,13 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Macros.h
+ * \todo Replace macros with protected methods of Object
+ */
+
#ifndef SIGMOD_MACROS
#define SIGMOD_MACROS
#ifdef MAKE_SIGMOD_LIB
-// TODO: The macros should probably be replaced by protected members of Object
-
#define LOAD_ID() \
int newId = id; \
if ((id == -1) && xml.hasAttribute("id")) \
diff --git a/sigmod/Map.cpp b/sigmod/Map.cpp
index fe599cc6..021de6ac 100644
--- a/sigmod/Map.cpp
+++ b/sigmod/Map.cpp
@@ -169,7 +169,7 @@ void Sigmod::Map::setTile(const int row, const int column, const int tile)
if (qobject_cast<const Sigmod*>(sigmod())->tileIndex(tile) == INT_MAX)
emit(error(bounds("tile")));
else
- m_map.set(row, column, tile);
+ m_map(row, column) = tile;
}
void Sigmod::Map::insertColumn(const int column)
@@ -214,7 +214,7 @@ Sigmod::Matrix<int>* Sigmod::Map::map()
int Sigmod::Map::tile(const int row, const int column) const
{
- return m_map.at(row, column);
+ return m_map(row, column);
}
int Sigmod::Map::width() const
@@ -227,11 +227,6 @@ int Sigmod::Map::height() const
return m_map.height();
}
-QPoint Sigmod::Map::size() const
-{
- return m_map.size();
-}
-
const Sigmod::MapEffect* Sigmod::Map::effect(const int index) const
{
Q_ASSERT(index < effectCount());
diff --git a/sigmod/Map.h b/sigmod/Map.h
index 030ce05d..4657e9dc 100644
--- a/sigmod/Map.h
+++ b/sigmod/Map.h
@@ -80,7 +80,6 @@ class SIGMOD_EXPORT Map : public Object
int tile(const int row, const int column) const;
int width() const;
int height() const;
- QPoint size() const;
const MapEffect* effect(const int index) const;
MapEffect* effect(const int index);
diff --git a/sigmod/Matrix.h b/sigmod/Matrix.h
index 37c9b58d..16d3a5d0 100644
--- a/sigmod/Matrix.h
+++ b/sigmod/Matrix.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Matrix.h
+ */
+
#ifndef SIGMOD_MATRIX
#define SIGMOD_MATRIX
@@ -27,34 +31,125 @@
namespace Sigmod
{
+/**
+ * \class Sigmod::Matrix Matrix.h sigmod/Matrix.h
+ * \brief Class for a two dimensional vector.
+ */
template<class T> class SIGMOD_EXPORT Matrix
{
public:
+ /**
+ * Default constructor.
+ */
Matrix();
+ /**
+ * Constructor.
+ *
+ * \param height The height of the matrix.
+ * \param width The width of the matrix.
+ * \param value The value to set all values to.
+ */
Matrix(const int height, const int width, const T& value = T());
+ /**
+ * Copy constructor.
+ *
+ * \param rhs The matrix to copy.
+ */
Matrix(const Matrix<T>& rhs);
+ /**
+ * Add a row to the matrix.
+ *
+ * \param value The value to set the row to.
+ */
void addRow(const T& value = T());
+ /**
+ * Add a column to the matrix.
+ *
+ * \param value The value to set the column to.
+ */
void addColumn(const T& value = T());
+ /**
+ * Inserts a row into the matrix.
+ *
+ * \param row Where the new row will be placed.
+ * \param value The value to set the row to.
+ */
void insertRow(const int row, const T& value = T());
+ /**
+ * Inserts a column into the matrix.
+ *
+ * \param column Where the new column will be placed.
+ * \param value The value to set the column to.
+ */
void insertColumn(const int column, const T& value = T());
+ /**
+ * Removes a row from the matrix.
+ *
+ * \param row The row to remove from the matrix.
+ */
void deleteRow(const int row);
+ /**
+ * Removes a column from the matrix.
+ *
+ * \param column The column to remove from the matrix.
+ */
void deleteColumn(const int column);
+ /**
+ * Clears the matrix.
+ */
void clear();
- void set(const int row, const int column, const T& value);
+ /**
+ * Resizes the matrix to a new size. Rows and columns are removed from the end to shrink and added to the
+ * end to grow.
+ *
+ * \param newHeight The target height.
+ * \param newWidth The target width.
+ * \param value Value to set any additional rows and columns to.
+ */
void resize(const int newHeight, const int newWidth, const T& value = T());
- T at(const int row, const int column) const;
+ /**
+ * Get a row from the matrix.
+ *
+ * \param row The row to retrieve.
+ * \return A row of the matrix.
+ */
QVector<T> row(const int row) const;
+ /**
+ * Get a column from the matrix.
+ *
+ * \param column The column to retrieve.
+ * \return A column of the matrix.
+ */
QVector<T> column(const int column) const;
+ /**
+ * \return The height of the matrix.
+ */
int height() const;
+ /**
+ * \return The width of the matrix.
+ */
int width() const;
- QPoint size() const;
+ /**
+ * Method for accessing values in the matrix.
+ *
+ * \param row The row of the cell.
+ * \param column The column of te cell.
+ * \return The value of the cell in the matrix.
+ */
T& operator()(const int row, const int column);
+ /**
+ * Convenience method.
+ *
+ * \param row The row of the cell.
+ * \param column The column of te cell.
+ * \return The value of the cell in the matrix.
+ */
T operator()(const int row, const int column) const;
Matrix<T>& operator=(const Matrix<T>& rhs);
bool operator==(const Matrix<T>& rhs) const;
@@ -79,41 +174,30 @@ template<class T> Matrix<T>::Matrix(const Matrix<T>& rhs)
template<class T> void Matrix<T>::addRow(const T& value)
{
- if (size() == QPoint(0, 0))
- m_matrix.append(QVector<T>(1, value));
- else
- m_matrix.append(QVector<T>(width(), value));
+ insertRow(height(), value);
}
template<class T> void Matrix<T>::addColumn(const T& value)
{
- if (size() == QPoint(0, 0))
- m_matrix.append(QVector<T>(1, value));
- else
- {
- for (int i = 0; i < height(); ++i)
- m_matrix[i].append(value);
- }
+ insertColumn(width(), value);
}
template<class T> void Matrix<T>::insertRow(const int row, const T& value)
{
- if (size() == QPoint(0, 0))
+ Q_ASSERT(row <= height());
+ if (!height() || !width())
m_matrix.append(QVector<T>(1, value));
else
- {
- Q_ASSERT(row <= height());
m_matrix.insert(row, QVector<T>(width(), value));
- }
}
template<class T> void Matrix<T>::insertColumn(const int column, const T& value)
{
- if (size() == QPoint(0, 0))
+ Q_ASSERT(column <= width());
+ if (!height() || !width())
m_matrix.append(QVector<T>(1, value));
else
{
- Q_ASSERT(column <= width());
for (int i = 0; i < height(); ++i)
m_matrix[i].insert(column, value);
}
@@ -121,22 +205,20 @@ template<class T> void Matrix<T>::insertColumn(const int column, const T& value)
template<class T> void Matrix<T>::deleteRow(const int row)
{
+ Q_ASSERT(row < height());
if (height() == 1)
m_matrix.clear();
else
- {
- Q_ASSERT(row < height());
m_matrix.remove(row);
- }
}
template<class T> void Matrix<T>::deleteColumn(const int column)
{
+ Q_ASSERT(column < width());
if (width() == 1)
m_matrix.clear();
else
{
- Q_ASSERT(column < width());
for (int i = 0; i < height(); ++i)
m_matrix[i].remove(column);
}
@@ -147,13 +229,6 @@ template<class T> void Matrix<T>::clear()
m_matrix.clear();
}
-template<class T> void Matrix<T>::set(const int row, const int column, const T& value)
-{
- Q_ASSERT(row < height());
- Q_ASSERT(column < width());
- (m_matrix[row])[column] = value;
-}
-
template<class T> void Matrix<T>::resize(const int newHeight, const int newWidth, const T& value)
{
while (height() < newHeight)
@@ -166,13 +241,6 @@ template<class T> void Matrix<T>::resize(const int newHeight, const int newWidth
deleteColumn(newWidth);
}
-template<class T> T Matrix<T>::at(const int row, const int column) const
-{
- Q_ASSERT(row < height());
- Q_ASSERT(column < width());
- return m_matrix.at(row).at(column);
-}
-
template<class T> QVector<T> Matrix<T>::row(const int row) const
{
Q_ASSERT(row < height());
@@ -200,11 +268,6 @@ template<class T> int Matrix<T>::width() const
return 0;
}
-template<class T> QPoint Matrix<T>::size() const
-{
- return QPoint(height(), width());
-}
-
template<class T> T& Matrix<T>::operator()(const int row, const int column)
{
Q_ASSERT(row < height());
@@ -214,7 +277,9 @@ template<class T> T& Matrix<T>::operator()(const int row, const int column)
template<class T> T Matrix<T>::operator()(const int row, const int column) const
{
- return at(row, column);
+ Q_ASSERT(row < height());
+ Q_ASSERT(column < width());
+ return m_matrix.at(row).at(column);
}
template<class T> Matrix<T>& Matrix<T>::operator=(const Matrix<T>& rhs)
diff --git a/sigmod/Object.cpp b/sigmod/Object.cpp
index 803dadc5..74065fd7 100644
--- a/sigmod/Object.cpp
+++ b/sigmod/Object.cpp
@@ -15,19 +15,16 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Object.cpp
+ */
+
// Header include
#include "Object.h"
// Sigmod includes
#include "Macros.h"
-Sigmod::Object::Object(const Object& object) :
- QObject(NULL),
- m_id(object.id()),
- m_parent(object.parent())
-{
-}
-
Sigmod::Object::Object(const Object* parent, const int id) :
QObject(NULL),
m_id(id),
@@ -40,11 +37,11 @@ const Sigmod::Object* Sigmod::Object::parent() const
return m_parent;
}
-const Sigmod::Object* Sigmod::Object::sigmod() const
+const Sigmod::Sigmod* Sigmod::Object::sigmod() const
{
if (m_parent)
return m_parent->sigmod();
- return this;
+ return qobject_cast<const Sigmod*>(this);
}
int Sigmod::Object::id() const
@@ -57,11 +54,6 @@ void Sigmod::Object::setId(const int id)
CHECK(id);
}
-QString Sigmod::Object::className() const
-{
- return QString(metaObject()->className()).section(':', -1);
-}
-
QDomDocument Sigmod::Object::xml(const Object* object)
{
QDomDocument xml(object->className());
@@ -69,6 +61,15 @@ QDomDocument Sigmod::Object::xml(const Object* object)
return xml;
}
+void Sigmod::Object::validateScript(const Script& script)
+{
+}
+
+QString Sigmod::Object::className() const
+{
+ return QString(metaObject()->className()).section(':', -1);
+}
+
QString Sigmod::Object::unused(const QString& variable)
{
return QString("Setting unused variable %1").arg(variable);
diff --git a/sigmod/Object.h b/sigmod/Object.h
index 6b4ca974..23fbbd5c 100644
--- a/sigmod/Object.h
+++ b/sigmod/Object.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Object.h
+ */
+
#ifndef SIGMOD_OBJECT
#define SIGMOD_OBJECT
@@ -38,34 +42,121 @@
namespace Sigmod
{
+// Forward decarations
+class Sigmod;
+
+/**
+ * \class Sigmod::Object Object.h sigmod/Object.h
+ * \brief Base class for all data structures in a Sigmod.
+ *
+ * The Object class sets up a parenting structure for all Sigmod classes. It also provides an interface for validation,
+ * saving to XML format, as well as loading from XML.
+ */
class SIGMOD_EXPORT Object : public QObject
{
Q_OBJECT
public:
- Object(const Object& object);
+ /**
+ * Constructor.
+ *
+ * \param parent The parent of the object.
+ * \param id The id of the object.
+ */
Object(const Object* parent, const int id);
+ /**
+ * Destructor.
+ */
virtual ~Object();
+ /**
+ * \return The parent of the object.
+ */
const Object* parent() const;
- const Object* sigmod() const;
+ /**
+ * \return The Sigmod that the object belongs to.
+ */
+ const Sigmod* sigmod() const;
+ /**
+ * \return The id of the object.
+ */
int id() const;
+ /**
+ * \return The name of the class of the object without the namespace.
+ */
QString className() const;
+ /**
+ * Convenience function to create a QDomDocument from the QDomElement that is returned from \link Object::save save \endlink .
+ *
+ * \param object The object to create an XML structure from.
+ * \return The XML representation of \p object.
+ */
static QDomDocument xml(const Object* object);
+ /**
+ * Method for validating the object.
+ */
virtual void validate() = 0;
+ /**
+ * Validates a script. It ensures that system modules are not included so that the scripts cannot do anything beyond
+ * interacting with the .
+ *
+ * \param script The script to validate.
+ *
+ * \todo Validate the script.
+ */
+ void validateScript(const Script& script);
+ /**
+ * Loads data from an XML structure.
+ *
+ * \param xml The XML data structure to load data from.
+ */
virtual void load(const QDomElement& xml) = 0;
+ /**
+ * Saves the data of the object to XML.
+ *
+ * \return An XML representation of the class.
+ */
virtual QDomElement save() const = 0;
signals:
+ /**
+ * Signal for when the object encounters something unexpected, but it does not invalid when validating.
+ *
+ * \param message The message.
+ */
void valMessage(const QString& message) const;
+ /**
+ * Signal for when the object encounters a value that is either confusing or not advised, but does not
+ * render the Sigmod as inconsistent.
+ *
+ * \param message The warning.
+ */
void valWarning(const QString& message) const;
+ /**
+ * Signal for when the object encounters an unexpected value that introduces an inconsistency in the Sigmod.
+ *
+ * \param message The error.
+ */
void valError(const QString& message) const;
+ /**
+ * Signal for when a value was set, but it may not be optimal.
+ *
+ * \param message The warning.
+ */
void warning(const QString& message) const;
+ /**
+ * Signal for when a value assignment was attempted, but the value was invalid.
+ *
+ * \param message The error.
+ */
void error(const QString& message) const;
+ /**
+ * Signal for when the object has changed.
+ */
void changed() const;
protected:
void setId(const int id);
@@ -229,7 +320,7 @@ template<> inline QDomElement Object::saveValue<QImage>(const QString& name, con
QByteArray bytes;
QBuffer* buffer = new QBuffer(&bytes);
buffer->open(QIODevice::WriteOnly);
- value.save(buffer, "PNG");
+ value.save(buffer, "PNG", 0);
element.appendChild(QDomDocument().createTextNode(bytes.toBase64()));
delete buffer;
return element;
@@ -290,4 +381,7 @@ template<typename T> inline QDomElement Object::saveMatrix(const QString& name,
}
+// This makes the moc file happy.
+#include "Sigmod.h"
+
#endif
diff --git a/sigmod/Script.h b/sigmod/Script.h
index 5fe87ad9..c884aaf5 100644
--- a/sigmod/Script.h
+++ b/sigmod/Script.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file sigmod/Script.h
+ */
+
#ifndef SIGMOD_SCRIPT
#define SIGMOD_SCRIPT
@@ -26,16 +30,55 @@
namespace Sigmod
{
+/**
+ * \class Sigmod::Script Script.h sigmod/Script.h
+ * \brief Class that describes a script for the game engine.
+ */
class SIGMOD_EXPORT Script
{
public:
- Script();
- Script(const QString& interpreter, const QString& script);
+ /**
+ * Constructor.
+ *
+ * \param interpreter The language of the script.
+ * \param script The code for the script.
+ */
+ explicit Script(const QString& interpreter = "", const QString& script = "");
+ /**
+ * Set the language of the script. The default game engine uses Kross <http://kross.dipe.org/> to
+ * run the scripts. The following values are valid for Kross:
+ *
+ * - \b mono -- C# <http://www.mono-project.com/Main_Page>
+ * - \b falcon -- Falcon <http://www.falconpl.org/>
+ * - \b java -- Java <http://www.java.com/en/>
+ * - \b lua -- Lua <http://www.lua.org/>
+ * - \b php -- PHP <http://www.php.net/>
+ * - \b python -- Python <http://www.python.org/>
+ * - \b ruby -- Ruby <http://www.ruby-lang.org/en/>
+ *
+ * Other languages may be added in the future.
+ *
+ * \param interpreter The language of the script.
+ */
void setInterpreter(const QString& interpreter);
+ /**
+ *
+ * \param script The code for the script.
+ */
void setScript(const QString& script);
+ /**
+ * \sa setInterpreter
+ *
+ * \return The language of the script.
+ */
QString interpreter() const;
+ /**
+ * \sa setScript
+ *
+ * \return The code for the script.
+ */
QString script() const;
Script& operator=(const Script& rhs);
@@ -46,12 +89,6 @@ class SIGMOD_EXPORT Script
QString m_script;
};
-inline Script::Script() :
- m_interpreter(""),
- m_script("")
-{
-}
-
inline Script::Script(const QString& interpreter, const QString& script) :
m_interpreter(interpreter),
m_script(script)
diff --git a/sigmod/Sigmod.h b/sigmod/Sigmod.h
index e902aaac..544d1957 100644
--- a/sigmod/Sigmod.h
+++ b/sigmod/Sigmod.h
@@ -15,6 +15,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+/**
+ * \file simod/Sigmod.h
+ */
+
#ifndef SIGMOD_SIGMOD
#define SIGMOD_SIGMOD
@@ -53,17 +57,57 @@ class Trainer;
class Type;
class Weather;
+/**
+ * \class Sigmod::Sigmod Sigmod.h sigmod/Sigmod.h
+ * \brief Main class used to create and manage Sigmods.
+ *
+ * The Sigmod class describes an entire set of objects for use with the game engine.
+ * Games will refuse to run if the \link Sigmod::validate validate \endlink returns
+ * any errors. Warnings will not stop the engine from running the Sigmod, but they
+ * should be minimized.
+ */
class SIGMOD_EXPORT Sigmod : public Object
{
Q_OBJECT
public:
+ /**
+ * Default constructor.
+ */
Sigmod();
+ /**
+ * Copy constructor.
+ *
+ * \param sigmod The Sigmod to copy.
+ */
Sigmod(const Sigmod& sigmod);
+ /**
+ * XML data constructor.
+ *
+ * \param xml The XML structure to extract the data from.
+ */
Sigmod(const QDomElement& xml);
+ /**
+ * Destructor.
+ */
~Sigmod();
+ /**
+ * Check to make sure the Sigmod is valid.
+ */
+ void validate();
+
+ /**
+ * Load data from XML.
+ *
+ * \param xml The XML structure to extract data from.
+ */
void load(const QDomElement& xml);
+ /**
+ * Get the data for the badge in XML format.
+ *
+ * \return The XML structure representing the badge.
+ */
QDomElement save() const;
void setTitle(const QString& title);
@@ -354,8 +398,6 @@ class SIGMOD_EXPORT Sigmod : public Object
Sigmod& operator=(const Sigmod& rhs);
private:
- void validate();
-
int newAbilityId() const;
Ability* newAbility(Ability* ability);
diff --git a/sigmodr/MapEffectUI.cpp b/sigmodr/MapEffectUI.cpp
index a2306cd2..4d94c203 100644
--- a/sigmodr/MapEffectUI.cpp
+++ b/sigmodr/MapEffectUI.cpp
@@ -38,7 +38,8 @@ Sigmodr::MapEffectUI::~MapEffectUI()
void Sigmodr::MapEffectUI::refreshGui()
{
- varCoordinate->setMaximum(qobject_cast<const Sigmod::Map*>(original()->parent())->size());
+ const Sigmod::Map* map = qobject_cast<const Sigmod::Map*>(original()->parent());
+ varCoordinate->setMaximum(QPoint(map->width(), map->height()));
for (int i = 0; i < sigmod()->skinCount(); ++i)
{
const Sigmod::Skin* skin = sigmod()->skin(i);
diff --git a/sigmodr/MapTrainerUI.cpp b/sigmodr/MapTrainerUI.cpp
index 61bbfd00..7330a1df 100644
--- a/sigmodr/MapTrainerUI.cpp
+++ b/sigmodr/MapTrainerUI.cpp
@@ -48,7 +48,8 @@ void Sigmodr::MapTrainerUI::refreshGui()
varTrainerClass->addItem(trainer->name(), trainer->id());
}
varTrainerClass->blockSignals(blockedTrainerClass);
- varCoordinate->setMaximum(qobject_cast<const Sigmod::Map*>(original()->parent())->size());
+ const Sigmod::Map* map = qobject_cast<const Sigmod::Map*>(original()->parent());
+ varCoordinate->setMaximum(QPoint(map->width(), map->height()));
varNumberFight->setMaximum(sigmod()->rules()->maxFight());
const bool blockedLeadTeamMember = varLeadTeamMember->blockSignals(true);
varLeadTeamMember->clear();
diff --git a/sigmodr/MapWarpUI.cpp b/sigmodr/MapWarpUI.cpp
index c26d1194..07049479 100644
--- a/sigmodr/MapWarpUI.cpp
+++ b/sigmodr/MapWarpUI.cpp
@@ -45,7 +45,8 @@ void Sigmodr::MapWarpUI::initGui()
void Sigmodr::MapWarpUI::refreshGui()
{
- varCoordinate->setMaximum(qobject_cast<const Sigmod::Map*>(original()->parent())->size());
+ const Sigmod::Map* map = qobject_cast<const Sigmod::Map*>(original()->parent());
+ varCoordinate->setMaximum(QPoint(map->width(), map->height()));
const bool blocked = varToMap->blockSignals(true);
varToMap->clear();
for (int i = 0; i < sigmod()->mapCount(); ++i)
diff --git a/sigmodr/ScriptWidget.cpp b/sigmodr/ScriptWidget.cpp
index d3df997c..75857d98 100644
--- a/sigmodr/ScriptWidget.cpp
+++ b/sigmodr/ScriptWidget.cpp
@@ -47,7 +47,7 @@ Sigmodr::ScriptWidget::ScriptWidget(QWidget* parent, const Sigmod::Script& value
languages["PHP"] = "php";
languages["Python"] = "python";
languages["Ruby"] = "ruby";
- QList<QString> langs = languages.keys();
+ QStringList langs = languages.keys();
foreach (const QString& language, langs)
varInterpreter->addItem(language, languages[language]);
if (!m_editor)
@@ -55,9 +55,9 @@ Sigmodr::ScriptWidget::ScriptWidget(QWidget* parent, const Sigmod::Script& value
KMessageBox::error(this, "A KDE text-editor component could not be found;\nplease check your KDE installation.");
KApplication::kApplication()->exit(1);
}
- m_editor->readConfig(NULL);
- m_document = m_editor->createDocument(NULL);
- m_view = m_document->createView(NULL);
+ m_editor->readConfig();
+ m_document = m_editor->createDocument(this);
+ m_view = m_document->createView(this);
KActionCollection* collection = m_view->actionCollection();
collection->action("file_save")->setVisible(false);
collection->action("file_save")->setEnabled(false);
@@ -75,7 +75,7 @@ Sigmodr::ScriptWidget::ScriptWidget(QWidget* parent, const Sigmod::Script& value
KXmlGuiWindow* topLevel = qobject_cast<KXmlGuiWindow*>(KApplication::kApplication()->activeWindow());
if (topLevel)
{
- QMenu *menu = qobject_cast<KMenu*>(topLevel->factory()->container("ktexteditor_popup", topLevel));
+ KMenu *menu = qobject_cast<KMenu*>(topLevel->factory()->container("ktexteditor_popup", topLevel));
if (menu)
m_view->setContextMenu(menu);
}
@@ -90,7 +90,6 @@ Sigmodr::ScriptWidget::ScriptWidget(QWidget* parent, const Sigmod::Script& value
Sigmodr::ScriptWidget::~ScriptWidget()
{
m_editor->writeConfig(NULL);
-// delete m_document;
}
Sigmod::Script Sigmodr::ScriptWidget::value() const
@@ -109,10 +108,11 @@ void Sigmodr::ScriptWidget::setGui()
void Sigmodr::ScriptWidget::setValue(const Sigmod::Script& value)
{
- if (m_value == value)
- return;
- m_value = value;
- emit(valueChanged(m_value));
+ if (m_value != value)
+ {
+ m_value = value;
+ emit(valueChanged(m_value));
+ }
}
void Sigmodr::ScriptWidget::on_varInterpreter_activated()
@@ -143,6 +143,6 @@ void Sigmodr::ScriptWidget::unfocused(KTextEditor::View* view)
KXmlGuiWindow* topLevel = qobject_cast<KXmlGuiWindow*>(KApplication::kApplication()->activeWindow());
QWidget* focused = KApplication::focusWidget();
// FIXME: Does this fail with non-Kate KTextEditor implementations?
- if (topLevel && focused && ((focused->metaObject()->className() != QString("KateViewInternal")) || ((QString(focused->metaObject()->className()) == view->metaObject()->className()) && (focused != view))))
+ if (topLevel && focused && ((focused->metaObject()->className() != QString("KateViewInternal")) || ((focused != view) && (QString(focused->metaObject()->className()) == view->metaObject()->className()))))
topLevel->guiFactory()->removeClient(view);
}
diff --git a/sigmodr/TilemapModel.h b/sigmodr/TilemapModel.h
index 52f0c407..8ca4d460 100644
--- a/sigmodr/TilemapModel.h
+++ b/sigmodr/TilemapModel.h
@@ -82,7 +82,7 @@ inline QVariant TilemapModel::data(const QModelIndex& index, int role) const
}
}
else if (role == Qt::EditRole)
- return m_tilemap.at(index.row(), index.column());
+ return m_tilemap(index.row(), index.column());
return QVariant();
}
diff --git a/sigmodr/TypechartModel.h b/sigmodr/TypechartModel.h
index 6ccbc4e9..341b7509 100644
--- a/sigmodr/TypechartModel.h
+++ b/sigmodr/TypechartModel.h
@@ -69,12 +69,12 @@ inline QVariant TypechartModel::data(const QModelIndex& index, int role) const
if (!index.isValid())
return QVariant();
if (role == Qt::DisplayRole)
- return QString::number(m_typechart.at(index.row(), index.column()), 'g', 3);
+ return QString::number(m_typechart(index.row(), index.column()), 'g', 3);
else if (role == Qt::EditRole)
- return QVariant::fromValue(m_typechart.at(index.row(), index.column()));
+ return QVariant::fromValue(m_typechart(index.row(), index.column()));
else if (role == Qt::BackgroundRole)
{
- double multiplier = m_typechart.at(index.row(), index.column());
+ double multiplier = m_typechart(index.row(), index.column());
if (multiplier <= .5)
return KStatefulBrush(KColorScheme::View, KColorScheme::NegativeBackground).brush(QPalette::Normal);
else if (multiplier < 2.)
diff --git a/sigscript/Config.h b/sigscript/Config.h
index 064831fe..a38bba4d 100644
--- a/sigscript/Config.h
+++ b/sigscript/Config.h
@@ -22,10 +22,10 @@
#include "Global.h"
// Qt includes
-#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QObject>
#include <QtCore/QString>
+#include <QtCore/QStringList>
#include <QtCore/QVariant>
// Forward declarations
@@ -61,7 +61,7 @@ class SIGSCRIPT_EXPORT Config : public QObject
virtual void writeBack();
private:
QMap<QString, QVariant> m_values;
- QList<QString> m_temporaries;
+ QStringList m_temporaries;
};
template<typename T> T Config::valueOfType(const QString& name, const bool recursive) const
diff --git a/sigscript/MapWrapper.cpp b/sigscript/MapWrapper.cpp
index a035a03b..d3f32823 100644
--- a/sigscript/MapWrapper.cpp
+++ b/sigscript/MapWrapper.cpp
@@ -89,11 +89,6 @@ Sigscript::TileWrapper* Sigscript::MapWrapper::tile(const int row, const int col
return sigmod()->tile(m_map->tile(row, column));
}
-QPoint Sigscript::MapWrapper::mapSize() const
-{
- return m_map->size();
-}
-
Sigscript::MapEffectWrapper* Sigscript::MapWrapper::effect(const QString& name)
{
for (int i = 0; i < m_map->effectCount(); ++i)
diff --git a/sigscript/MapWrapper.h b/sigscript/MapWrapper.h
index 28136f48..029109cc 100644
--- a/sigscript/MapWrapper.h
+++ b/sigscript/MapWrapper.h
@@ -51,7 +51,6 @@ class SIGSCRIPT_EXPORT MapWrapper : public ObjectWrapper
Q_SCRIPTABLE MapWarpWrapper* flyWarp();
Q_SCRIPTABLE Sigmod::Map::Type type() const;
Q_SCRIPTABLE TileWrapper* tile(const int row, const int column);
- Q_SCRIPTABLE QPoint mapSize() const;
Q_SCRIPTABLE MapEffectWrapper* effect(const QString& name);
Q_SCRIPTABLE MapTrainerWrapper* trainer(const QString& name);