add tsl::ordered_map for json objects,

update project code to save json files with new ordered object
This commit is contained in:
garakmon
2020-03-05 22:46:25 -05:00
committed by huderlem
parent 12614a174a
commit 799e5537f9
9 changed files with 2535 additions and 133 deletions

View File

@@ -4,7 +4,10 @@
#include <QString>
#include <QPixmap>
#include <QMap>
#include <QJsonObject>
#include "orderedjson.h"
using OrderedJson = poryjson::Json;
class EventType
{
@@ -67,19 +70,19 @@ public:
static Event* createNewHiddenItemEvent(Project*);
static Event* createNewSecretBaseEvent(Project*);
QJsonObject buildObjectEventJSON();
QJsonObject buildWarpEventJSON(QMap<QString, QString>*);
QJsonObject buildTriggerEventJSON();
QJsonObject buildWeatherTriggerEventJSON();
QJsonObject buildSignEventJSON();
QJsonObject buildHiddenItemEventJSON();
QJsonObject buildSecretBaseEventJSON();
OrderedJson::object buildObjectEventJSON();
OrderedJson::object buildWarpEventJSON(QMap<QString, QString>*);
OrderedJson::object buildTriggerEventJSON();
OrderedJson::object buildWeatherTriggerEventJSON();
OrderedJson::object buildSignEventJSON();
OrderedJson::object buildHiddenItemEventJSON();
OrderedJson::object buildSecretBaseEventJSON();
void setPixmapFromSpritesheet(QImage, int, int, int, bool);
int getPixelX();
int getPixelY();
QMap<QString, bool> getExpectedFields();
void readCustomValues(QJsonObject values);
void addCustomValuesTo(QJsonObject *obj);
void addCustomValuesTo(OrderedJson::object *obj);
void setFrameFromMovement(QString);
QMap<QString, QString> values;

View File

@@ -1,4 +1,3 @@
/// Wrappings around QJsonObjects that preserves order
/* poryjson
*
* poryjson is a modified version of json11, which adds support to preserve the key order
@@ -56,15 +55,14 @@
#include <QString>
#include <QVector>
#include <QPair>
#include <QFile>
#include <QTextStream>
#include <map>
#include <memory>
#include <initializer_list>
// temp
#include <iostream>
#include "orderedmap.h"
#ifdef _MSC_VER
#if _MSC_VER <= 1800 // VS 2013
@@ -95,7 +93,7 @@ public:
// Array and object typedefs
typedef QVector<Json> array;
typedef std::map<QString, Json> object;
typedef tsl::ordered_map<QString, Json> object;
// Constructors for the various types of JSON value.
Json() noexcept; // NUL
@@ -196,14 +194,6 @@ public:
bool operator> (const Json &rhs) const { return (rhs < *this); }
bool operator>= (const Json &rhs) const { return !(*this < rhs); }
/* has_shape(types, err)
*
* Return true if this is a JSON object and, for each item in types, has a field of
* the given type. If not, return false and set err to a descriptive message.
*/
typedef std::initializer_list<std::pair<QString, Type>> shape;
bool has_shape(const shape & types, QString & err) const;
private:
std::shared_ptr<JsonValue> m_ptr;
};

2406
include/lib/orderedmap.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -7,6 +7,7 @@
#include "event.h"
#include "wildmoninfo.h"
#include "parseutil.h"
#include "orderedjson.h"
#include <QStringList>
#include <QList>
@@ -93,7 +94,7 @@ public:
QMap<QString, QMap<QString, WildPokemonHeader>> wildMonData;
QVector<EncounterField> wildMonFields;
QVector<QString> encounterGroupLabels;
QMap<QString, QJsonObject> extraEncounterGroups;
QVector<poryjson::Json::object> extraEncounterGroups;
bool readSpeciesIconPaths();
QMap<QString, QString> speciesToIconPath;