Frontend:
authorsmxx
Fri, 04 Jun 2010 20:50:24 +0000
changeset 3494 208c5671b202
parent 3493 2adbae321127
child 3495 a6b4f351d400
Frontend: * Avoid overwriting/replacing premade game/weapon schemes
QTfrontend/achievements.cpp
QTfrontend/achievements.h
QTfrontend/ammoSchemeModel.cpp
QTfrontend/selectWeapon.cpp
--- a/QTfrontend/achievements.cpp	Thu Jun 03 23:02:35 2010 +0000
+++ b/QTfrontend/achievements.cpp	Fri Jun 04 20:50:24 2010 +0000
@@ -20,11 +20,18 @@
 
 #include "achievements.h"
 
-const char achievements[][5][256] = {
-    // 5 array members each: id, caption, description, image, required number
-    //{"rounds1", QT_TRANSLATE_NOOP("achievements", "No complete Newbie!"),  QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "nonewb",     1},
-    //{"rounds2", QT_TRANSLATE_NOOP("achievements", "Getting used to it!"),  QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "getused",   25},
-    //{"rounds3", QT_TRANSLATE_NOOP("achievements", "Backyard Veteran"),     QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "veteran",  100},
-    //{"rounds4", QT_TRANSLATE_NOOP("achievements", "1001 Stories to tell"), QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "stories", 1001},
-    {0, 0, 0, 0, 0} // "terminator" line
+// TODO: use some structs instead?
+const char achievements[][6][256] = {
+    // 6 array members each: id, caption, description, image, required number, attributes
+    /*
+    {"rounds1",  QT_TRANSLATE_NOOP("achievements", "No complete Newbie!"),  QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "nonewb",     "1", ""},
+    {"rounds2",  QT_TRANSLATE_NOOP("achievements", "Getting used to it!"),  QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "getused",   "25", ""},
+    {"rounds3",  QT_TRANSLATE_NOOP("achievements", "Backyard Veteran"),     QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "veteran",  "100", ""},
+    {"rounds4",  QT_TRANSLATE_NOOP("achievements", "1001 Stories to tell"), QT_TRANSLATE_NOOP("achievements", "Manage to survive %1 games playing on the official server, no matter if it's a draw or win."), "stories", "1001", ""},
+    {"rope1",    QT_TRANSLATE_NOOP("achievements", "Big Swing"),            QT_TRANSLATE_NOOP("achievements", "Bridge 1000 pixels while using one rope."),                                                    "bgswing",    "1", ""},
+    {"rope2",    QT_TRANSLATE_NOOP("achievements", "Spider Hog"),           QT_TRANSLATE_NOOP("achievements", "Bridge 3000 pixels while using one rope."),                                                    "spider",     "1", "hidden"},
+    {"skipping", QT_TRANSLATE_NOOP("achievements", "Skipped"),              QT_TRANSLATE_NOOP("achievements", "Let a single hog skip over the surface of the water for at least 5 times."),                   "skipped",    "1", "hidden"},
+    {"cgunman",  QT_TRANSLATE_NOOP("achievements", "Crazy Gunman"),         QT_TRANSLATE_NOOP("achievements", "Eliminate 3 hogs with a single shot of the sniper rifle."),                                    "cgunman",    "1", ""},
+    */
+    {0, 0, 0, 0, 0, 0} // "terminator" line
 };
--- a/QTfrontend/achievements.h	Thu Jun 03 23:02:35 2010 +0000
+++ b/QTfrontend/achievements.h	Fri Jun 04 20:50:24 2010 +0000
@@ -20,6 +20,32 @@
 #define ACHIEVEMENTS_H
 
 #define MAX_ACHIEVEMENTS 128
-extern const char achievements[][5][256];
+
+// This is just for testing and far from being complete - everything might change so don't use it anywhere!
+
+enum achflags
+{
+    ACH_FLAGS_NONE      = 0x00,
+    ACH_FLAGS_HIDDEN    = 0x01,
+    ACH_FLAGS_INACTIVE  = 0x02,
+    // UNKNOWN          = 0x04,
+    // UNKNOWN          = 0x08,
+    // UNKNOWN          = 0x10,
+    // UNKNOWN          = 0x20,
+    // UNKNOWN          = 0x40,
+    // UNKNOWN          = 0x80,
+};
+
+struct achievement
+{
+    const char *id;
+    const char *caption;
+    const char *description;
+    const char *image;
+    const int   goal;
+    const int   flags;
+};
+
+extern const char achievements[][6][256];
 
 #endif // ACHIEVEMENTS_H
--- a/QTfrontend/ammoSchemeModel.cpp	Thu Jun 03 23:02:35 2010 +0000
+++ b/QTfrontend/ammoSchemeModel.cpp	Fri Jun 04 20:50:24 2010 +0000
@@ -397,12 +397,12 @@
 
 void AmmoSchemeModel::Save()
 {
-    fileConfig.beginWriteArray("schemes", schemes.size());
+    fileConfig.beginWriteArray("schemes", schemes.size() - numberOfDefaultSchemes);
 
-    for (int i = 0; i < schemes.size(); ++i) {
+    for (int i = 0; i < schemes.size() - numberOfDefaultSchemes; ++i) {
         fileConfig.setArrayIndex(i);
 
-        QList<QVariant> scheme = schemes[i];
+        QList<QVariant> scheme = schemes[i + numberOfDefaultSchemes];
 
         for (int k = 0; k < scheme.size(); ++k)
             fileConfig.setValue(spNames[k], scheme[k]);
--- a/QTfrontend/selectWeapon.cpp	Thu Jun 03 23:02:35 2010 +0000
+++ b/QTfrontend/selectWeapon.cpp	Fri Jun 04 20:50:24 2010 +0000
@@ -168,11 +168,11 @@
 
 void SelWeaponWidget::save()
 {
-    if (m_name->text() == "Default") {
-        QMessageBox impossible(QMessageBox::Warning, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not edit default weapon set"));
-        impossible.exec();
-        return;
-    }
+    for(int i = 0; i < cDefaultAmmos.size(); i++)
+        if (!cDefaultAmmos[i].first.compare(m_name->text())) {
+            QMessageBox::warning(0, QMessageBox::tr("Weapons"), QMessageBox::tr("Can not overwrite default weapon set '%1'!").arg(cDefaultAmmos[i].first));
+            return;
+        }
 
     if (m_name->text() == "") return;