Compare commits

..

No commits in common. "8791eb32ac1fca31f1dbdccdd8fcfc8383959aad" and "f522d20dd40df9db44fc52770cae2ec0a2723ecf" have entirely different histories.

107 changed files with 1293 additions and 1634 deletions

View file

@ -18,57 +18,53 @@
#include <map> #include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum; using namespace Magnum;
static const std::map<Int, Containers::StringView> accessories { static const std::map<Int, const char*> accessories {
// Primitives // Primitives
{1, "Cube (S)"_s}, {1, "Cube (S)"},
{2, "Pentagon (S)"_s}, {2, "Pentagon (S)"},
{3, "Hexagon (S)"_s}, {3, "Hexagon (S)"},
{4, "Cylinder (S)"_s}, {4, "Cylinder (S)"},
{5, "Sphere (S)"_s}, {5, "Sphere (S)"},
{6, "TriPyramid (S)"_s}, {6, "TriPyramid (S)"},
{7, "SquPyramid (S)"_s}, {7, "SquPyramid (S)"},
{8, "PenPyramid (S)"_s}, {8, "PenPyramid (S)"},
{9, "HexPyramid (S)"_s}, {9, "HexPyramid (S)"},
{10, "Cone (S)"_s}, {10, "Cone (S)"},
{11, "SquStick (S)"_s}, {11, "SquStick (S)"},
{12, "PenStick (S)"_s}, {12, "PenStick (S)"},
{13, "HexStick (S)"_s}, {13, "HexStick (S)"},
{14, "CycStick (S)"_s}, {14, "CycStick (S)"},
{15, "Capsule (S)"_s}, {15, "Capsule (S)"},
{16, "Decal Pad 01 (S)"_s}, {16, "Decal Pad 01 (S)"},
{17, "Decal Pad 02 (S)"_s}, {17, "Decal Pad 02 (S)"},
{18, "Decal Pad 03 (S)"_s}, {18, "Decal Pad 03 (S)"},
{19, "Decal Pad 04 (S)"_s}, {19, "Decal Pad 04 (S)"},
{20, "Decal Pad 05 (S)"_s}, {20, "Decal Pad 05 (S)"},
{51, "SquBevel (S)"_s}, {51, "SquBevel (S)"},
{52, "TriBevel (S)"_s}, {52, "TriBevel (S)"},
{53, "PenBevel (S)"_s}, {53, "PenBevel (S)"},
{54, "HexBevel (S)"_s}, {54, "HexBevel (S)"},
{55, "CycBevel (S)"_s}, {55, "CycBevel (S)"},
{56, "RecBevel (S)"_s}, {56, "RecBevel (S)"},
{57, "DaiBevel (S)"_s}, {57, "DaiBevel (S)"},
{58, "MonBevel (S)"_s}, {58, "MonBevel (S)"},
{59, "CofBevel (S)"_s}, {59, "CofBevel (S)"},
{60, "JevBevel (S)"_s}, {60, "JevBevel (S)"},
{61, "SquEmboss (S)"_s}, {61, "SquEmboss (S)"},
{62, "TriEmboss (S)"_s}, {62, "TriEmboss (S)"},
{63, "PenEmboss (S)"_s}, {63, "PenEmboss (S)"},
{64, "HexEmboss (S)"_s}, {64, "HexEmboss (S)"},
{65, "CycEmboss (S)"_s}, {65, "CycEmboss (S)"},
{66, "RecEmboss (S)"_s}, {66, "RecEmboss (S)"},
{67, "DaiEmboss (S)"_s}, {67, "DaiEmboss (S)"},
{68, "MonEmboss (S)"_s}, {68, "MonEmboss (S)"},
{69, "CofEmboss (S)"_s}, {69, "CofEmboss (S)"},
{70, "JevEmboss (S)"_s}, {70, "JevEmboss (S)"},
// Armours // Armours

View file

@ -18,38 +18,34 @@
#include <map> #include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum; using namespace Magnum;
struct ArmourSet { struct ArmourSet {
Containers::StringView name; const char* name;
bool neck_compatible; bool neck_compatible;
}; };
static const std::map<Int, ArmourSet> armour_sets { static const std::map<Int, ArmourSet> armour_sets {
{-1, {"<unequipped>"_s, true}}, {-1, {"<unequipped>", true}},
{0, {"Vanguard"_s, true}}, {0, {"Vanguard", true}},
{1, {"Assault Mk.I"_s, true}}, {1, {"Assault Mk.I", true}},
{2, {"Assault Mk.II"_s, false}}, {2, {"Assault Mk.II", false}},
{3, {"Assault Mk.III"_s, false}}, {3, {"Assault Mk.III", false}},
{7, {"Titan 001"_s, true}}, {7, {"Titan 001", true}},
{8, {"Titan 002"_s, false}}, {8, {"Titan 002", false}},
{9, {"Titan 003"_s, false}}, {9, {"Titan 003", false}},
{13, {"Blitz X"_s, true}}, {13, {"Blitz X", true}},
{14, {"Blitz EX"_s, false}}, {14, {"Blitz EX", false}},
{15, {"Blitz EXS"_s, false}}, {15, {"Blitz EXS", false}},
{16, {"Kaiser S-R0"_s, true}}, {16, {"Kaiser S-R0", true}},
{17, {"Kaiser S-R1"_s, false}}, {17, {"Kaiser S-R1", false}},
{18, {"Kaiser S-R2"_s, false}}, {18, {"Kaiser S-R2", false}},
{19, {"Hammerfall MG-A"_s, true}}, {19, {"Hammerfall MG-A", true}},
{20, {"Hammerfall MG-S"_s, false}}, {20, {"Hammerfall MG-S", false}},
{21, {"Hammerfall MG-X"_s, false}}, {21, {"Hammerfall MG-X", false}},
{22, {"Panzer S-UC"_s, true}}, {22, {"Panzer S-UC", true}},
{23, {"Panzer L-UC"_s, false}}, {23, {"Panzer L-UC", false}},
{24, {"Panzer H-UC"_s, false}}, {24, {"Panzer H-UC", false}},
}; };

View file

@ -15,42 +15,42 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifdef c #ifdef c
c(Face, "enuArmorSlots::NewEnumerator0"_s, "Face"_s) c(Face, "enuArmorSlots::NewEnumerator0", "Face")
c(UpperHead, "enuArmorSlots::NewEnumerator1"_s, "Upper head"_s) c(UpperHead, "enuArmorSlots::NewEnumerator1", "Upper head")
c(LowerHead, "enuArmorSlots::NewEnumerator2"_s, "Lower head"_s) c(LowerHead, "enuArmorSlots::NewEnumerator2", "Lower head")
c(Neck, "enuArmorSlots::NewEnumerator3"_s, "Neck"_s) c(Neck, "enuArmorSlots::NewEnumerator3", "Neck")
c(UpperBody, "enuArmorSlots::NewEnumerator4"_s, "Upper body"_s) c(UpperBody, "enuArmorSlots::NewEnumerator4", "Upper body")
c(MiddleBody, "enuArmorSlots::NewEnumerator5"_s, "Middle body"_s) c(MiddleBody, "enuArmorSlots::NewEnumerator5", "Middle body")
c(LowerBody, "enuArmorSlots::NewEnumerator6"_s, "Lower body"_s) c(LowerBody, "enuArmorSlots::NewEnumerator6", "Lower body")
c(FrontWaist, "enuArmorSlots::NewEnumerator7"_s, "Front waist"_s) c(FrontWaist, "enuArmorSlots::NewEnumerator7", "Front waist")
c(LeftFrontSkirt, "enuArmorSlots::NewEnumerator8"_s, "Left front skirt"_s) c(LeftFrontSkirt, "enuArmorSlots::NewEnumerator8", "Left front skirt")
c(RightFrontSkirt, "enuArmorSlots::NewEnumerator9"_s, "Right front skirt"_s) c(RightFrontSkirt, "enuArmorSlots::NewEnumerator9", "Right front skirt")
c(LeftSideSkirt, "enuArmorSlots::NewEnumerator10"_s, "Left side skirt"_s) c(LeftSideSkirt, "enuArmorSlots::NewEnumerator10", "Left side skirt")
c(RightSideSkirt, "enuArmorSlots::NewEnumerator11"_s, "Right side skirt"_s) c(RightSideSkirt, "enuArmorSlots::NewEnumerator11", "Right side skirt")
c(LeftBackSkirt, "enuArmorSlots::NewEnumerator12"_s, "Left back skirt"_s) c(LeftBackSkirt, "enuArmorSlots::NewEnumerator12", "Left back skirt")
c(RightBackSkirt, "enuArmorSlots::NewEnumerator13"_s, "Right back skirt"_s) c(RightBackSkirt, "enuArmorSlots::NewEnumerator13", "Right back skirt")
c(BackWaist, "enuArmorSlots::NewEnumerator14"_s, "Back waist"_s) c(BackWaist, "enuArmorSlots::NewEnumerator14", "Back waist")
c(LeftShoulder, "enuArmorSlots::NewEnumerator15"_s, "Left shoulder"_s) c(LeftShoulder, "enuArmorSlots::NewEnumerator15", "Left shoulder")
c(RightShoulder, "enuArmorSlots::NewEnumerator16"_s, "Right shoulder"_s) c(RightShoulder, "enuArmorSlots::NewEnumerator16", "Right shoulder")
c(LeftUpperArm, "enuArmorSlots::NewEnumerator17"_s, "Left upper arm"_s) c(LeftUpperArm, "enuArmorSlots::NewEnumerator17", "Left upper arm")
c(RightUpperArm, "enuArmorSlots::NewEnumerator18"_s, "Right upper arm"_s) c(RightUpperArm, "enuArmorSlots::NewEnumerator18", "Right upper arm")
c(LeftElbow, "enuArmorSlots::NewEnumerator19"_s, "Left elbow"_s) c(LeftElbow, "enuArmorSlots::NewEnumerator19", "Left elbow")
c(RightElbow, "enuArmorSlots::NewEnumerator20"_s, "Right elbow"_s) c(RightElbow, "enuArmorSlots::NewEnumerator20", "Right elbow")
c(LeftLowerArm, "enuArmorSlots::NewEnumerator21"_s, "Left lower arm"_s) c(LeftLowerArm, "enuArmorSlots::NewEnumerator21", "Left lower arm")
c(RightLowerArm, "enuArmorSlots::NewEnumerator22"_s, "Right lower arm"_s) c(RightLowerArm, "enuArmorSlots::NewEnumerator22", "Right lower arm")
c(Backpack, "enuArmorSlots::NewEnumerator23"_s, "Backpack"_s) c(Backpack, "enuArmorSlots::NewEnumerator23", "Backpack")
c(LeftHand, "enuArmorSlots::NewEnumerator24"_s, "Left hand"_s) c(LeftHand, "enuArmorSlots::NewEnumerator24", "Left hand")
c(RightHand, "enuArmorSlots::NewEnumerator25"_s, "Right hand"_s) c(RightHand, "enuArmorSlots::NewEnumerator25", "Right hand")
c(LeftUpperLeg, "enuArmorSlots::NewEnumerator26"_s, "Left upper leg"_s) c(LeftUpperLeg, "enuArmorSlots::NewEnumerator26", "Left upper leg")
c(RightUpperLeg, "enuArmorSlots::NewEnumerator27"_s, "Right upper leg"_s) c(RightUpperLeg, "enuArmorSlots::NewEnumerator27", "Right upper leg")
c(LeftKnee, "enuArmorSlots::NewEnumerator28"_s, "Left knee"_s) c(LeftKnee, "enuArmorSlots::NewEnumerator28", "Left knee")
c(RightKnee, "enuArmorSlots::NewEnumerator29"_s, "Right knee"_s) c(RightKnee, "enuArmorSlots::NewEnumerator29", "Right knee")
c(LeftLowerLeg, "enuArmorSlots::NewEnumerator30"_s, "Left lower leg"_s) c(LeftLowerLeg, "enuArmorSlots::NewEnumerator30", "Left lower leg")
c(RightLowerLeg, "enuArmorSlots::NewEnumerator31"_s, "Right lower leg"_s) c(RightLowerLeg, "enuArmorSlots::NewEnumerator31", "Right lower leg")
c(LeftAnkle, "enuArmorSlots::NewEnumerator32"_s, "Left ankle"_s) c(LeftAnkle, "enuArmorSlots::NewEnumerator32", "Left ankle")
c(RightAnkle, "enuArmorSlots::NewEnumerator33"_s, "Right ankle"_s) c(RightAnkle, "enuArmorSlots::NewEnumerator33", "Right ankle")
c(LeftHeel, "enuArmorSlots::NewEnumerator34"_s, "Left heel"_s) c(LeftHeel, "enuArmorSlots::NewEnumerator34", "Left heel")
c(RightHeel, "enuArmorSlots::NewEnumerator35"_s, "Right heel"_s) c(RightHeel, "enuArmorSlots::NewEnumerator35", "Right heel")
c(LeftFoot, "enuArmorSlots::NewEnumerator36"_s, "Left foot"_s) c(LeftFoot, "enuArmorSlots::NewEnumerator36", "Left foot")
c(RightFoot, "enuArmorSlots::NewEnumerator37"_s, "Right foot"_s) c(RightFoot, "enuArmorSlots::NewEnumerator37", "Right foot")
#endif #endif

View file

@ -15,10 +15,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifdef c #ifdef c
c(Physical, "enuDamageProperty::NewEnumerator0"_s) c(Physical, "enuDamageProperty::NewEnumerator0")
c(Piercing, "enuDamageProperty::NewEnumerator1"_s) c(Piercing, "enuDamageProperty::NewEnumerator1")
c(Heat, "enuDamageProperty::NewEnumerator2"_s) c(Heat, "enuDamageProperty::NewEnumerator2")
c(Freeze, "enuDamageProperty::NewEnumerator3"_s) c(Freeze, "enuDamageProperty::NewEnumerator3")
c(Shock, "enuDamageProperty::NewEnumerator4"_s) c(Shock, "enuDamageProperty::NewEnumerator4")
c(Plasma, "enuDamageProperty::NewEnumerator5"_s) c(Plasma, "enuDamageProperty::NewEnumerator5")
#endif #endif

View file

@ -15,6 +15,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifdef c #ifdef c
c(Default, "enuWeaponEffectColorMode::NewEnumerator0"_s) c(Default, "enuWeaponEffectColorMode::NewEnumerator0")
c(Custom, "enuWeaponEffectColorMode::NewEnumerator1"_s) c(Custom, "enuWeaponEffectColorMode::NewEnumerator1")
#endif #endif

View file

@ -18,39 +18,31 @@
#include <map> #include <map>
#include <Corrade/Containers/StringView.h> static const std::map<Int, const char*> mission_id_map {{
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
static const std::map<Int, Containers::StringView> mission_id_map {{
// Story missions // Story missions
{0x0064, "Mission 1 - Training"_s}, {0x0064, "Mission 1 - Training"},
{0x0065, "Mission 2 - Patrol Operation"_s}, {0x0065, "Mission 2 - Patrol Operation"},
{0x0066, "Mission 3 - Fusion Cells in the Snow"_s}, {0x0066, "Mission 3 - Fusion Cells in the Snow"},
{0x0067, "Mission 4 - Earning Changes"_s}, {0x0067, "Mission 4 - Earning Changes"},
{0x0068, "Mission 5 - Unexpected Coordination"_s}, {0x0068, "Mission 5 - Unexpected Coordination"},
{0x0069, "Mission 6 - Empowering Void"_s}, {0x0069, "Mission 6 - Empowering Void"},
{0x006A, "Mission 7 - Logisitics Obstacles"_s}, {0x006A, "Mission 7 - Logisitics Obstacles"},
{0x006B, "Mission 8 - Wrath of the Wastelands"_s}, {0x006B, "Mission 8 - Wrath of the Wastelands"},
{0x006C, "Mission 9 - Suspicious Originator"_s}, {0x006C, "Mission 9 - Suspicious Originator"},
{0x006D, "Mission 10 - Researchers Data Recovery"_s}, {0x006D, "Mission 10 - Researchers Data Recovery"},
{0x006E, "Mission 11 - Tempestuous Sector"_s}, {0x006E, "Mission 11 - Tempestuous Sector"},
{0x006F, "Mission 12 - Clashes of Metal"_s}, {0x006F, "Mission 12 - Clashes of Metal"},
{0x0070, "Mission 13 - The Sandstorm Glutton"_s}, {0x0070, "Mission 13 - The Sandstorm Glutton"},
{0x0071, "Mission 14 - An Icy Investigation"_s}, {0x0071, "Mission 14 - An Icy Investigation"},
// Hunting grounds // Hunting grounds
{0x00C8, "Hunt 1 - Desert Pathway Safety"_s}, {0x00C8, "Hunt 1 - Desert Pathway Safety"},
{0x00C9, "Hunt 2 - Snowfield Custodian"_s}, {0x00C9, "Hunt 2 - Snowfield Custodian"},
{0x00CA, "Hunt 3 - Abandoned Valley Raid"_s}, {0x00CA, "Hunt 3 - Abandoned Valley Raid"},
{0x00CB, "Hunt 4 - Depths of the Machineries"_s}, {0x00CB, "Hunt 4 - Depths of the Machineries"},
// Challenges // Challenges
{0x012C, "Challenge 1 - Redline Battlefront"_s}, {0x012C, "Challenge 1 - Redline Battlefront"},
{0x0140, "Challenge 2 - Void Convergence"_s}, {0x0140, "Challenge 2 - Void Convergence"},
{0x0190, "Challenge 3 - Gates of Ascension"_s} {0x0190, "Challenge 3 - Gates of Ascension"}
}}; }};

View file

@ -17,85 +17,78 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum;
struct StoryProgressPoint { struct StoryProgressPoint {
Int id; Int id;
Containers::StringView chapter; const char* chapter;
Containers::StringView point; const char* point;
Containers::StringView after = nullptr; const char* after = nullptr;
}; };
static const Corrade::Containers::Array<StoryProgressPoint> story_progress static const Corrade::Containers::Array<StoryProgressPoint> story_progress
{ {
InPlaceInit, InPlaceInit,
{ {
{0x0000, "Chapter 1"_s, "Chapter start (company isn't named yet)"_s}, {0x0000, "Chapter 1", "Chapter start (company isn't named yet)"},
{0x0064, "Chapter 1"_s, "First time in the hangar"_s}, {0x0064, "Chapter 1", "First time in the hangar"},
{0x0065, "Chapter 1"_s, "After 1st meeting with Quin in mission section"_s}, {0x0065, "Chapter 1", "After 1st meeting with Quin in mission section"},
{0x0066, "Chapter 1"_s, "Talking with Reina and Quin in hangar"_s, "After training"_s}, {0x0066, "Chapter 1", "Talking with Reina and Quin in hangar", "After training"},
{0x0067, "Chapter 1"_s, "Returned to hangar"_s, "After training"_s}, {0x0067, "Chapter 1", "Returned to hangar", "After training"},
{0x0068, "Chapter 1"_s, "Talked with Quin in development section"_s, "After training"_s}, {0x0068, "Chapter 1", "Talked with Quin in development section", "After training"},
{0x0069, "Chapter 1"_s, "Talked with Waltz in armour section"_s, "After training"_s}, {0x0069, "Chapter 1", "Talked with Waltz in armour section", "After training"},
{0x00C8, "Chapter 1"_s, "Talked with Kael in tuning section"_s, "After training"_s}, {0x00C8, "Chapter 1", "Talked with Kael in tuning section", "After training"},
{0x00C9, "Chapter 1"_s, "Got mission 2 briefing"_s, "After training"_s}, {0x00C9, "Chapter 1", "Got mission 2 briefing", "After training"},
{0x012C, "Chapter 1"_s, "Talking with Reina"_s, "After mission 2"_s}, {0x012C, "Chapter 1", "Talking with Reina", "After mission 2"},
{0x012D, "Chapter 1"_s, "Returned to hangar"_s, "After mission 2"_s}, {0x012D, "Chapter 1", "Returned to hangar", "After mission 2"},
{0x012E, "Chapter 1"_s, "Talked with Kael in tuning section"_s, "After mission 2"_s}, {0x012E, "Chapter 1", "Talked with Kael in tuning section", "After mission 2"},
{0x012F, "Chapter 1"_s, "Talked with Reina in hangar"_s, "After mission 2"_s}, {0x012F, "Chapter 1", "Talked with Reina in hangar", "After mission 2"},
{0x0130, "Chapter 1"_s, "Got mission 3 briefing"_s, "After mission 2"_s}, {0x0130, "Chapter 1", "Got mission 3 briefing", "After mission 2"},
{0x0190, "Chapter 1"_s, "Talking with Reina"_s, "After mission 3"_s}, {0x0190, "Chapter 1", "Talking with Reina", "After mission 3"},
{0x0191, "Chapter 1"_s, "Returned to hangar"_s, "After mission 3"_s}, {0x0191, "Chapter 1", "Returned to hangar", "After mission 3"},
{0x0192, "Chapter 1"_s, "Talked with Waltz in armour section"_s, "After mission 3"_s}, {0x0192, "Chapter 1", "Talked with Waltz in armour section", "After mission 3"},
{0x0193, "Chapter 1"_s, "Got mission 4 briefing"_s, "After mission 3"_s}, {0x0193, "Chapter 1", "Got mission 4 briefing", "After mission 3"},
{0x01F4, "Chapter 1"_s, "Talking with Reina"_s, "After mission 4"_s}, {0x01F4, "Chapter 1", "Talking with Reina", "After mission 4"},
{0x01F5, "Chapter 1"_s, "Returned to hangar"_s, "After mission 4"_s}, {0x01F5, "Chapter 1", "Returned to hangar", "After mission 4"},
{0x01F6, "Chapter 1"_s, "Talked with Waltz in armour section"_s, "After mission 4"_s}, {0x01F6, "Chapter 1", "Talked with Waltz in armour section", "After mission 4"},
{0x01F7, "Chapter 1"_s, "Talked with Reina in hangar"_s, "After mission 4"_s}, {0x01F7, "Chapter 1", "Talked with Reina in hangar", "After mission 4"},
{0x01F8, "Chapter 1"_s, "Got mission 5 and hunt 1 briefing"_s, "After mission 4"_s}, {0x01F8, "Chapter 1", "Got mission 5 and hunt 1 briefing", "After mission 4"},
{0x0258, "Chapter 1"_s, "Meeting Neon and Aine"_s, "After mission 5"_s}, {0x0258, "Chapter 1", "Meeting Neon and Aine", "After mission 5"},
{0x0259, "Chapter 1"_s, "Returned to hangar"_s, "After mission 5"_s}, {0x0259, "Chapter 1", "Returned to hangar", "After mission 5"},
{0x025A, "Chapter 1"_s, "Got mission 6 briefing"_s, "After mission 5"_s}, {0x025A, "Chapter 1", "Got mission 6 briefing", "After mission 5"},
{0x02BC, "Chapter 1"_s, "Talking with Reina"_s, "After mission 6"_s}, {0x02BC, "Chapter 1", "Talking with Reina", "After mission 6"},
{0x02BD, "Chapter 1"_s, "Returned to hangar"_s, "After mission 6"_s}, {0x02BD, "Chapter 1", "Returned to hangar", "After mission 6"},
{0x02BE, "Chapter 1"_s, "Got hunt 2 briefing"_s, "After mission 6"_s}, {0x02BE, "Chapter 1", "Got hunt 2 briefing", "After mission 6"},
{0x02BF, "Chapter 1"_s, "Met Ellenier"_s, "After mission 6"_s}, {0x02BF, "Chapter 1", "Met Ellenier", "After mission 6"},
{0x02C0, "Chapter 1"_s, "Got mission 7 briefing"_s, "After mission 6"_s}, {0x02C0, "Chapter 1", "Got mission 7 briefing", "After mission 6"},
{0x0320, "Chapter 1"_s, "Talking with Nier"_s, "After mission 7"_s}, {0x0320, "Chapter 1", "Talking with Nier", "After mission 7"},
{0x0321, "Chapter 1"_s, "Returned to hangar"_s, "After mission 7"_s}, {0x0321, "Chapter 1", "Returned to hangar", "After mission 7"},
{0x0322, "Chapter 1"_s, "Talked with Quin, Reina, and Nier in development section"_s, "After mission 7"_s}, {0x0322, "Chapter 1", "Talked with Quin, Reina, and Nier in development section", "After mission 7"},
{0x0323, "Chapter 1"_s, "Got mission 8 briefing"_s, "After mission 7"_s}, {0x0323, "Chapter 1", "Got mission 8 briefing", "After mission 7"},
{0x0384, "Chapter 1"_s, "Talking with crew in hangar"_s, "After mission 8"_s}, {0x0384, "Chapter 1", "Talking with crew in hangar", "After mission 8"},
{0x0385, "Chapter 1"_s, "Returned to hangar"_s, "After mission 8"_s}, {0x0385, "Chapter 1", "Returned to hangar", "After mission 8"},
{0x0386, "Chapter 1"_s, "Got hunt 3 briefing"_s, "After mission 8"_s}, {0x0386, "Chapter 1", "Got hunt 3 briefing", "After mission 8"},
{0x0387, "Chapter 1"_s, "Talked with Reina, Nier, and Quin in development section"_s, "After mission 8"_s}, {0x0387, "Chapter 1", "Talked with Reina, Nier, and Quin in development section", "After mission 8"},
{0x0388, "Chapter 2"_s, "Chapter start"_s}, {0x0388, "Chapter 2", "Chapter start"},
{0x0389, "Chapter 2"_s, "Got mission 9 briefing"_s}, {0x0389, "Chapter 2", "Got mission 9 briefing"},
{0x03E8, "Chapter 2"_s, "Talking with Reina in hangar"_s, "After mission 9"_s}, {0x03E8, "Chapter 2", "Talking with Reina in hangar", "After mission 9"},
{0x03E9, "Chapter 2"_s, "Returned to hangar"_s, "After mission 9"_s}, {0x03E9, "Chapter 2", "Returned to hangar", "After mission 9"},
{0x03EA, "Chapter 2"_s, "Talked with crew in armour section"_s, "After mission 9"_s}, {0x03EA, "Chapter 2", "Talked with crew in armour section", "After mission 9"},
{0x03EB, "Chapter 2"_s, "Got mission 10 briefing"_s, "After mission 9"_s}, {0x03EB, "Chapter 2", "Got mission 10 briefing", "After mission 9"},
{0x044C, "Chapter 2"_s, "Talking with Reina in hangar"_s, "After mission 10"_s}, {0x044C, "Chapter 2", "Talking with Reina in hangar", "After mission 10"},
{0x044D, "Chapter 2"_s, "Returned to hangar"_s, "After mission 10"_s}, {0x044D, "Chapter 2", "Returned to hangar", "After mission 10"},
{0x044E, "Chapter 2"_s, "Got mission 11 briefing"_s, "After mission 10"_s}, {0x044E, "Chapter 2", "Got mission 11 briefing", "After mission 10"},
{0x04B0, "Chapter 2"_s, "Talking with Reina and Nier in hangar"_s, "After mission 11"_s}, {0x04B0, "Chapter 2", "Talking with Reina and Nier in hangar", "After mission 11"},
{0x04B1, "Chapter 2"_s, "Returned to hangar"_s, "After mission 11"_s}, {0x04B1, "Chapter 2", "Returned to hangar", "After mission 11"},
{0x04B2, "Chapter 2"_s, "Got mission 12 briefing"_s, "After mission 11"_s}, {0x04B2, "Chapter 2", "Got mission 12 briefing", "After mission 11"},
{0x0514, "Chapter 2"_s, "Talking with Reina and Waltz in hangar"_s, "After mission 12"_s}, {0x0514, "Chapter 2", "Talking with Reina and Waltz in hangar", "After mission 12"},
{0x0515, "Chapter 2"_s, "Returned to hangar"_s, "After mission 12"_s}, {0x0515, "Chapter 2", "Returned to hangar", "After mission 12"},
{0x0516, "Chapter 2"_s, "Got hunt 4 and mission 13 briefing"_s, "After mission 12"_s}, {0x0516, "Chapter 2", "Got hunt 4 and mission 13 briefing", "After mission 12"},
{0x0578, "Chapter 2"_s, "Talking with Reina in hangar"_s, "After mission 13"_s}, {0x0578, "Chapter 2", "Talking with Reina in hangar", "After mission 13"},
{0x0579, "Chapter 2"_s, "Returned to hangar"_s, "After mission 13"_s}, {0x0579, "Chapter 2", "Returned to hangar", "After mission 13"},
{0x057A, "Chapter 2"_s, "Talked with Reina in development section"_s, "After mission 13"_s}, {0x057A, "Chapter 2", "Talked with Reina in development section", "After mission 13"},
{0x057B, "Chapter 2"_s, "Got briefing for challenges 1, 2, and 3"_s, "After mission 13"_s}, {0x057B, "Chapter 2", "Got briefing for challenges 1, 2, and 3", "After mission 13"},
{0x057C, "Chapter 2"_s, "Talked with Reina about device"_s, "After mission 13"_s}, {0x057C, "Chapter 2", "Talked with Reina about device", "After mission 13"},
{0x057D, "Chapter 2"_s, "Got mission 14 briefing"_s, "After mission 13"_s}, {0x057D, "Chapter 2", "Got mission 14 briefing", "After mission 13"},
} }
}; };

View file

@ -18,179 +18,175 @@
#include <map> #include <map>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum; using namespace Magnum;
extern const std::map<Int, Containers::StringView> style_names extern const std::map<Int, const char*> style_names
#ifdef STYLENAMES_DEFINITION #ifdef STYLENAMES_DEFINITION
{ {
{0, "Custom Style 1"_s}, {0, "Custom Style 1"},
{1, "Custom Style 2"_s}, {1, "Custom Style 2"},
{2, "Custom Style 3"_s}, {2, "Custom Style 3"},
{3, "Custom Style 4"_s}, {3, "Custom Style 4"},
{4, "Custom Style 5"_s}, {4, "Custom Style 5"},
{5, "Custom Style 6"_s}, {5, "Custom Style 6"},
{6, "Custom Style 7"_s}, {6, "Custom Style 7"},
{7, "Custom Style 8"_s}, {7, "Custom Style 8"},
{8, "Custom Style 9"_s}, {8, "Custom Style 9"},
{9, "Custom Style 10"_s}, {9, "Custom Style 10"},
{10, "Custom Style 11"_s}, {10, "Custom Style 11"},
{11, "Custom Style 12"_s}, {11, "Custom Style 12"},
{12, "Custom Style 13"_s}, {12, "Custom Style 13"},
{13, "Custom Style 14"_s}, {13, "Custom Style 14"},
{14, "Custom Style 15"_s}, {14, "Custom Style 15"},
{15, "Custom Style 16"_s}, {15, "Custom Style 16"},
{50, "Global Style 1"_s}, {50, "Global Style 1"},
{51, "Global Style 2"_s}, {51, "Global Style 2"},
{52, "Global Style 3"_s}, {52, "Global Style 3"},
{53, "Global Style 4"_s}, {53, "Global Style 4"},
{54, "Global Style 5"_s}, {54, "Global Style 5"},
{55, "Global Style 6"_s}, {55, "Global Style 6"},
{56, "Global Style 7"_s}, {56, "Global Style 7"},
{57, "Global Style 8"_s}, {57, "Global Style 8"},
{58, "Global Style 9"_s}, {58, "Global Style 9"},
{59, "Global Style 10"_s}, {59, "Global Style 10"},
{60, "Global Style 11"_s}, {60, "Global Style 11"},
{61, "Global Style 12"_s}, {61, "Global Style 12"},
{62, "Global Style 13"_s}, {62, "Global Style 13"},
{63, "Global Style 14"_s}, {63, "Global Style 14"},
{64, "Global Style 15"_s}, {64, "Global Style 15"},
{65, "Global Style 16"_s}, {65, "Global Style 16"},
{100, "Iron"_s}, {100, "Iron"},
{101, "Silver"_s}, {101, "Silver"},
{102, "Gold"_s}, {102, "Gold"},
{103, "Bronze"_s}, {103, "Bronze"},
{104, "Copper"_s}, {104, "Copper"},
{105, "Nickel"_s}, {105, "Nickel"},
{106, "Cobalt"_s}, {106, "Cobalt"},
{107, "Aluminium"_s}, {107, "Aluminium"},
{108, "Titanium"_s}, {108, "Titanium"},
{109, "Platinum"_s}, {109, "Platinum"},
{110, "Gun Metal"_s}, {110, "Gun Metal"},
{111, "White"_s}, {111, "White"},
{112, "White Metal"_s}, {112, "White Metal"},
{113, "White Gloss"_s}, {113, "White Gloss"},
{114, "Grey"_s}, {114, "Grey"},
{115, "Grey Metal"_s}, {115, "Grey Metal"},
{116, "Grey Gloss"_s}, {116, "Grey Gloss"},
{117, "Dark Grey"_s}, {117, "Dark Grey"},
{118, "Dark Grey Metal"_s}, {118, "Dark Grey Metal"},
{119, "Dark Grey Gloss"_s}, {119, "Dark Grey Gloss"},
{120, "Black"_s}, {120, "Black"},
{121, "Black Metal"_s}, {121, "Black Metal"},
{122, "Black Gloss"_s}, {122, "Black Gloss"},
{123, "Red"_s}, {123, "Red"},
{124, "Red Metal"_s}, {124, "Red Metal"},
{125, "Red Gloss"_s}, {125, "Red Gloss"},
{126, "Dark Red"_s}, {126, "Dark Red"},
{127, "Dark Red Metal"_s}, {127, "Dark Red Metal"},
{128, "Dark Red Gloss"_s}, {128, "Dark Red Gloss"},
{129, "Orange"_s}, {129, "Orange"},
{130, "Orange Metal"_s}, {130, "Orange Metal"},
{131, "Orange Gloss"_s}, {131, "Orange Gloss"},
{132, "Dark Orange"_s}, {132, "Dark Orange"},
{133, "Dark Orange Metal"_s}, {133, "Dark Orange Metal"},
{134, "Dark Orange Gloss"_s}, {134, "Dark Orange Gloss"},
{135, "Yellow"_s}, {135, "Yellow"},
{136, "Yellow Metal"_s}, {136, "Yellow Metal"},
{137, "Yellow Gloss"_s}, {137, "Yellow Gloss"},
{138, "Brown"_s}, {138, "Brown"},
{139, "Brown Metal"_s}, {139, "Brown Metal"},
{140, "Brown Gloss"_s}, {140, "Brown Gloss"},
{141, "Dark Brown"_s}, {141, "Dark Brown"},
{142, "Dark Brown Metal"_s}, {142, "Dark Brown Metal"},
{143, "Dark Brown Gloss"_s}, {143, "Dark Brown Gloss"},
{144, "Leafgreen"_s}, {144, "Leafgreen"},
{145, "Leafgreen Metal"_s}, {145, "Leafgreen Metal"},
{146, "Leafgreen Gloss"_s}, {146, "Leafgreen Gloss"},
{147, "Military Green"_s}, {147, "Military Green"},
{148, "Military Green Metal"_s}, {148, "Military Green Metal"},
{149, "Military Green Gloss"_s}, {149, "Military Green Gloss"},
{150, "Green"_s}, {150, "Green"},
{151, "Green Metal"_s}, {151, "Green Metal"},
{152, "Green Gloss"_s}, {152, "Green Gloss"},
{153, "Dark Green"_s}, {153, "Dark Green"},
{154, "Dark Green Metal"_s}, {154, "Dark Green Metal"},
{155, "Dark Green Gloss"_s}, {155, "Dark Green Gloss"},
{156, "Teal"_s}, {156, "Teal"},
{157, "Teal Metal"_s}, {157, "Teal Metal"},
{158, "Teal Gloss"_s}, {158, "Teal Gloss"},
{159, "Cyan"_s}, {159, "Cyan"},
{160, "Cyan Metal"_s}, {160, "Cyan Metal"},
{161, "Cyan Gloss"_s}, {161, "Cyan Gloss"},
{162, "Blue"_s}, {162, "Blue"},
{163, "Blue Metal"_s}, {163, "Blue Metal"},
{164, "Blue Gloss"_s}, {164, "Blue Gloss"},
{165, "Blue Sky"_s}, {165, "Blue Sky"},
{166, "Blue Sky Metal"_s}, {166, "Blue Sky Metal"},
{167, "Blue Sky Gloss"_s}, {167, "Blue Sky Gloss"},
{168, "Dark Blue"_s}, {168, "Dark Blue"},
{169, "Dark Blue Metal"_s}, {169, "Dark Blue Metal"},
{170, "Dark Blue Gloss"_s}, {170, "Dark Blue Gloss"},
{171, "Purple"_s}, {171, "Purple"},
{172, "Purple Metal"_s}, {172, "Purple Metal"},
{173, "Purple Gloss"_s}, {173, "Purple Gloss"},
{174, "Dark Purple"_s}, {174, "Dark Purple"},
{175, "Dark Purple Metal"_s}, {175, "Dark Purple Metal"},
{176, "Dark Purple Gloss"_s}, {176, "Dark Purple Gloss"},
{177, "Pink"_s}, {177, "Pink"},
{178, "Pink Metal"_s}, {178, "Pink Metal"},
{179, "Pink Gloss"_s}, {179, "Pink Gloss"},
{180, "Rosy Brown"_s}, {180, "Rosy Brown"},
{181, "Rosy Brown Metal"_s}, {181, "Rosy Brown Metal"},
{182, "Rosy Brown Gloss"_s}, {182, "Rosy Brown Gloss"},
{183, "Ivory"_s}, {183, "Ivory"},
{184, "Ivory Metal"_s}, {184, "Ivory Metal"},
{185, "Ivory Gloss"_s}, {185, "Ivory Gloss"},
{186, "Slate Brown"_s}, {186, "Slate Brown"},
{187, "Slate Brown Metal"_s}, {187, "Slate Brown Metal"},
{188, "Slate Brown Gloss"_s}, {188, "Slate Brown Gloss"},
{189, "Slate Green"_s}, {189, "Slate Green"},
{190, "Slate Green Metal"_s}, {190, "Slate Green Metal"},
{191, "Slate Green Gloss"_s}, {191, "Slate Green Gloss"},
{192, "Slate Blue"_s}, {192, "Slate Blue"},
{193, "Slate Blue Metal"_s}, {193, "Slate Blue Metal"},
{194, "Slate Blue Gloss"_s}, {194, "Slate Blue Gloss"},
{195, "Slate Purple"_s}, {195, "Slate Purple"},
{196, "Slate Purple Metal"_s}, {196, "Slate Purple Metal"},
{197, "Slate Purple Gloss"_s}, {197, "Slate Purple Gloss"},
{198, "White Glow"_s}, {198, "White Glow"},
{199, "White Radiance"_s}, {199, "White Radiance"},
{200, "Red Glow"_s}, {200, "Red Glow"},
{201, "Red Radiance"_s}, {201, "Red Radiance"},
{202, "Orange Glow"_s}, {202, "Orange Glow"},
{203, "Orange Radiance"_s}, {203, "Orange Radiance"},
{204, "Yellow Glow"_s}, {204, "Yellow Glow"},
{205, "Yellow Radiance"_s}, {205, "Yellow Radiance"},
{206, "Leafgreen Glow"_s}, {206, "Leafgreen Glow"},
{207, "Leafgreen Radiance"_s}, {207, "Leafgreen Radiance"},
{208, "Green Glow"_s}, {208, "Green Glow"},
{209, "Green Radiance"_s}, {209, "Green Radiance"},
{210, "Teal Glow"_s}, {210, "Teal Glow"},
{211, "Teal Radiance"_s}, {211, "Teal Radiance"},
{212, "Cyan Glow"_s}, {212, "Cyan Glow"},
{213, "Cyan Radiance"_s}, {213, "Cyan Radiance"},
{214, "Blue Glow"_s}, {214, "Blue Glow"},
{215, "Blue Radiance"_s}, {215, "Blue Radiance"},
{216, "Purple Glow"_s}, {216, "Purple Glow"},
{217, "Purple Radiance"_s}, {217, "Purple Radiance"},
{218, "Pink Glow"_s}, {218, "Pink Glow"},
{219, "Pink Radiance"_s}, {219, "Pink Radiance"},
{220, "Grey Camo"_s}, {220, "Grey Camo"},
{221, "Dark Grey Camo"_s}, {221, "Dark Grey Camo"},
{222, "Green Camo"_s}, {222, "Green Camo"},
{223, "Dark Green Camo"_s}, {223, "Dark Green Camo"},
{224, "Brown Camo"_s}, {224, "Brown Camo"},
{225, "Dark Brown Camo"_s}, {225, "Dark Brown Camo"},
{226, "Blue Camo"_s}, {226, "Blue Camo"},
{227, "Dark Blue Camo"_s}, {227, "Dark Blue Camo"},
} }
#endif #endif
; ;

View file

@ -15,10 +15,10 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifdef c #ifdef c
c(Melee, "enuWeaponTypes::NewEnumerator0"_s, "Melee weapon"_s) c(Melee, "enuWeaponTypes::NewEnumerator0", "Melee weapon")
c(BulletShooter, "enuWeaponTypes::NewEnumerator1"_s, "Bullet shooter"_s) c(BulletShooter, "enuWeaponTypes::NewEnumerator1", "Bullet shooter")
c(EnergyShooter, "enuWeaponTypes::NewEnumerator2"_s, "Energy shooter"_s) c(EnergyShooter, "enuWeaponTypes::NewEnumerator2", "Energy shooter")
c(BulletLauncher, "enuWeaponTypes::NewEnumerator3"_s, "Bullet launcher"_s) c(BulletLauncher, "enuWeaponTypes::NewEnumerator3", "Bullet launcher")
c(EnergyLauncher, "enuWeaponTypes::NewEnumerator4"_s, "Energy launcher"_s) c(EnergyLauncher, "enuWeaponTypes::NewEnumerator4", "Energy launcher")
c(Shield, "enuWeaponTypes::NewEnumerator5"_s, "Shield"_s) c(Shield, "enuWeaponTypes::NewEnumerator5", "Shield")
#endif #endif

View file

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>

View file

@ -16,17 +16,16 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/String.h> #include <string>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h> #include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h> #include <Magnum/Math/Vector2.h>
using namespace Corrade;
using namespace Magnum; using namespace Magnum;
struct CustomStyle { struct CustomStyle {
Containers::String name; std::string name;
Color4 colour{0.0f}; Color4 colour{0.0f};
Float metallic = 0.5f; Float metallic = 0.5f;
Float gloss = 0.5f; Float gloss = 0.5f;

View file

@ -16,6 +16,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h> #include <Magnum/Math/Color.h>
#include <Magnum/Math/Vector2.h> #include <Magnum/Math/Vector2.h>

File diff suppressed because it is too large Load diff

View file

@ -16,11 +16,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h> #include <Magnum/Math/Color.h>
@ -56,16 +56,16 @@ class Mass {
Mass(Mass&&) = default; Mass(Mass&&) = default;
Mass& operator=(Mass&&) = default; Mass& operator=(Mass&&) = default;
auto lastError() -> Containers::StringView; auto lastError() -> std::string const&;
static auto getNameFromFile(Containers::StringView path) -> Containers::Optional<Containers::String>; static auto getNameFromFile(const std::string& path) -> Containers::Optional<std::string>;
void refreshValues(); void refreshValues();
auto filename() -> Containers::StringView; auto filename() -> std::string const&;
auto name() -> Containers::StringView; auto name() -> Containers::Optional<std::string> const&;
auto setName(Containers::StringView new_name) -> bool; auto setName(std::string new_name) -> bool;
auto state() -> State; auto state() -> State;
@ -135,8 +135,8 @@ class Mass {
auto architecture() -> Int&; auto architecture() -> Int&;
auto techs() -> Containers::ArrayView<Int>; auto techs() -> Containers::ArrayView<Int>;
auto account() -> Containers::StringView; auto account() -> std::string const&;
auto updateAccount(Containers::StringView new_account) -> bool; auto updateAccount(const std::string& new_account) -> bool;
private: private:
void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array); void getCustomStyles(Containers::ArrayView<CustomStyle> styles, ArrayProperty* style_array);
@ -148,33 +148,37 @@ class Mass {
void getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array); void getAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accessory_array);
void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array); void writeAccessories(Containers::ArrayView<Accessory> accessories, ArrayProperty* accs_array);
void getWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array); void getWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array);
auto writeWeaponType(Containers::StringView prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool; auto writeWeaponType(const char* prop_name, Containers::ArrayView<Weapon> weapon_array) -> bool;
void getTuningCategory(Containers::StringView big_node_prop_name, Int& big_node_id, void getTuningCategory(const char* big_node_prop_name, Int& big_node_id,
Containers::StringView small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids); const char* small_nodes_prop_name, Containers::ArrayView<Int> small_nodes_ids);
Containers::Optional<UESaveFile> _mass; Containers::Optional<UESaveFile> _mass;
Containers::String _lastError; std::string _lastError;
Containers::String _folder; std::string _folder;
Containers::String _filename; std::string _filename;
State _state = State::Empty; State _state = State::Empty;
bool _dirty = false; bool _dirty = false;
Containers::Optional<Containers::String> _name = Containers::NullOpt; Containers::Optional<std::string> _name = Containers::NullOpt;
struct { struct {
Joints joints{}; Joints joints{};
Containers::StaticArray<4, Int> styles{ValueInit}; Containers::StaticArray<4, Int> styles{ValueInit};
Color4 eyeFlare{0.0f}; Color4 eyeFlare{0.0f};
Containers::StaticArray<16, CustomStyle> customStyles; Containers::StaticArray<16, CustomStyle> customStyles;
} _frame; } _frame;
struct { struct {
Containers::StaticArray<38, ArmourPart> parts; Containers::StaticArray<38, ArmourPart> parts;
Containers::StaticArray<16, CustomStyle> customStyles; Containers::StaticArray<16, CustomStyle> customStyles;
} _armour; } _armour;
@ -200,5 +204,5 @@ class Mass {
Containers::StaticArray<7, Int> techIds; Containers::StaticArray<7, Int> techIds;
} _tuning; } _tuning;
Containers::String _account; std::string _account;
}; };

View file

@ -16,9 +16,10 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Math/Color.h> #include <Magnum/Math/Color.h>
@ -61,7 +62,7 @@ struct Weapon {
Weapon(Weapon&& other) = default; Weapon(Weapon&& other) = default;
Weapon& operator=(Weapon&& other) = default; Weapon& operator=(Weapon&& other) = default;
Containers::String name; std::string name;
WeaponType type = WeaponType::Melee; WeaponType type = WeaponType::Melee;
Containers::Array<WeaponPart> parts; Containers::Array<WeaponPart> parts;
Containers::StaticArray<16, CustomStyle> customStyles{ValueInit}; Containers::StaticArray<16, CustomStyle> customStyles{ValueInit};

View file

@ -19,23 +19,22 @@
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
#include <Corrade/Containers/StringStl.h>
#include "MassManager.h" #include "MassManager.h"
using namespace Containers::Literals; static const std::string empty_string = "";
MassManager::MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir): MassManager::MassManager(const std::string& save_path, const std::string& steam_id, bool demo, const std::string& staging_dir):
_saveDirectory{save_path}, _saveDirectory{save_path},
_account{account}, _steamId{steam_id},
_demo{demo}, _demo{demo},
_stagingAreaDirectory{staging_dir} _stagingAreaDirectory{staging_dir}
{ {
Containers::arrayReserve(_hangars, 32); Containers::arrayReserve(_hangars, 32);
Containers::String mass_filename = ""; std::string mass_filename = "";
for(int i = 0; i < 32; i++) { for(int i = 0; i < 32; i++) {
mass_filename = Utility::Directory::join(_saveDirectory, Utility::formatString("{}Unit{:.2d}{}.sav", demo ? "Demo"_s : ""_s, i, _account)); mass_filename = Utility::Directory::join(_saveDirectory, Utility::formatString("{}Unit{:.2d}{}.sav", demo ? "Demo" : "", i, _steamId));
Containers::arrayAppend(_hangars, Mass{mass_filename}); Containers::arrayAppend(_hangars, Mass{mass_filename});
} }
@ -46,7 +45,7 @@ MassManager::MassManager(Containers::StringView save_path, Containers::StringVie
refreshStagedMasses(); refreshStagedMasses();
} }
auto MassManager::lastError() -> Containers::StringView { auto MassManager::lastError() -> std::string const& {
return _lastError; return _lastError;
} }
@ -59,43 +58,43 @@ void MassManager::refreshHangar(Int hangar) {
return; return;
} }
Containers::String mass_filename = std::string mass_filename =
Utility::Directory::join(_saveDirectory, Utility::formatString("{}Unit{:.2d}{}.sav", _demo ? "Demo" : "", hangar, _account)); Utility::Directory::join(_saveDirectory, Utility::formatString("{}Unit{:.2d}{}.sav", _demo ? "Demo" : "", hangar, _steamId));
_hangars[hangar] = Mass{mass_filename}; _hangars[hangar] = Mass{mass_filename};
} }
auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bool { auto MassManager::importMass(const std::string& staged_fn, Int hangar) -> bool {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar out of range in MassManager::importMass()"_s; _lastError = "Hangar out of range in MassManager::importMass()";
return false; return false;
} }
auto it = _stagedMasses.find(staged_fn); auto it = _stagedMasses.find(staged_fn);
if(it == _stagedMasses.end()) { if(it == _stagedMasses.end()) {
_lastError = "Couldn't find "_s + staged_fn + " in the staged M.A.S.S.es."_s; _lastError = "Couldn't find " + staged_fn + " in the staged M.A.S.S.es.";
return false; return false;
} }
Containers::String source = Utility::Directory::join(_stagingAreaDirectory, staged_fn); std::string source = Utility::Directory::join(_stagingAreaDirectory, staged_fn);
Utility::Directory::copy(source, source + ".tmp"_s); Utility::Directory::copy(source, source + ".tmp");
{ {
Mass mass{source + ".tmp"_s}; Mass mass{source + ".tmp"};
if(!mass.updateAccount(_account)) { if(!mass.updateAccount(_steamId)) {
_lastError = mass.lastError(); _lastError = mass.lastError();
Utility::Directory::rm(source + ".tmp"_s); Utility::Directory::rm(source + ".tmp");
return false; return false;
} }
} }
Containers::String dest = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()); std::string dest = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename());
if(Utility::Directory::exists(dest)) { if(Utility::Directory::exists(dest)) {
Utility::Directory::rm(dest); Utility::Directory::rm(dest);
} }
if(!Utility::Directory::move(source + ".tmp"_s, dest)) { if(!Utility::Directory::move(source + ".tmp", dest)) {
_lastError = Utility::formatString("Couldn't move {} to hangar {:.2d}", staged_fn, hangar + 1); _lastError = Utility::formatString("Couldn't move {} to hangar {:.2d}", staged_fn, hangar + 1);
return false; return false;
} }
@ -105,7 +104,7 @@ auto MassManager::importMass(Containers::StringView staged_fn, Int hangar) -> bo
auto MassManager::exportMass(Int hangar) -> bool { auto MassManager::exportMass(Int hangar) -> bool {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar out of range in MassManager::exportMass()"_s; _lastError = "Hangar out of range in MassManager::exportMass()";
return false; return false;
} }
@ -114,9 +113,9 @@ auto MassManager::exportMass(Int hangar) -> bool {
return false; return false;
} }
Containers::String source = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename()); std::string source = Utility::Directory::join(_saveDirectory, _hangars[hangar].filename());
Containers::String dest = Utility::Directory::join(_stagingAreaDirectory, std::string dest = Utility::Directory::join(_stagingAreaDirectory,
Utility::formatString("{}_{}.sav", _hangars[hangar].name(), _account)); Utility::formatString("{}_{}.sav", *_hangars[hangar].name(), _steamId));
if(!Utility::Directory::copy(source, dest)) { if(!Utility::Directory::copy(source, dest)) {
_lastError = Utility::formatString("Couldn't export data from hangar {:.2d} to {}", hangar, dest); _lastError = Utility::formatString("Couldn't export data from hangar {:.2d} to {}", hangar, dest);
@ -128,17 +127,17 @@ auto MassManager::exportMass(Int hangar) -> bool {
auto MassManager::moveMass(Int source, Int destination) -> bool { auto MassManager::moveMass(Int source, Int destination) -> bool {
if(source < 0 || source >= 32) { if(source < 0 || source >= 32) {
_lastError = "Source hangar out of range."_s; _lastError = "Source hangar out of range.";
return false; return false;
} }
if(destination < 0 || destination >= 32) { if(destination < 0 || destination >= 32) {
_lastError = "Destination hangar out of range."_s; _lastError = "Destination hangar out of range.";
return false; return false;
} }
Containers::String source_file = Utility::Directory::join(_saveDirectory, _hangars[source].filename()); std::string source_file = Utility::Directory::join(_saveDirectory, _hangars[source].filename());
Containers::String dest_file = Utility::Directory::join(_saveDirectory, _hangars[destination].filename()); std::string dest_file = Utility::Directory::join(_saveDirectory, _hangars[destination].filename());
Mass::State dest_state = _hangars[destination].state(); Mass::State dest_state = _hangars[destination].state();
switch(dest_state) { switch(dest_state) {
@ -148,14 +147,14 @@ auto MassManager::moveMass(Int source, Int destination) -> bool {
Utility::Directory::rm(dest_file); Utility::Directory::rm(dest_file);
break; break;
case Mass::State::Valid: case Mass::State::Valid:
Utility::Directory::move(dest_file, dest_file + ".tmp"_s); Utility::Directory::move(dest_file, dest_file + ".tmp");
break; break;
} }
Utility::Directory::move(source_file, dest_file); Utility::Directory::move(source_file, dest_file);
if(dest_state == Mass::State::Valid) { if(dest_state == Mass::State::Valid) {
Utility::Directory::move(dest_file + ".tmp"_s, source_file); Utility::Directory::move(dest_file + ".tmp", source_file);
} }
return true; return true;
@ -163,7 +162,7 @@ auto MassManager::moveMass(Int source, Int destination) -> bool {
auto MassManager::deleteMass(Int hangar) -> bool { auto MassManager::deleteMass(Int hangar) -> bool {
if(hangar < 0 || hangar >= 32) { if(hangar < 0 || hangar >= 32) {
_lastError = "Hangar out of range."_s; _lastError = "Hangar out of range.";
return false; return false;
} }
@ -175,7 +174,7 @@ auto MassManager::deleteMass(Int hangar) -> bool {
return true; return true;
} }
auto MassManager::stagedMasses() -> std::map<Containers::String, Containers::String> const& { auto MassManager::stagedMasses() -> std::map<std::string, std::string> const& {
return _stagedMasses; return _stagedMasses;
} }
@ -183,31 +182,31 @@ void MassManager::refreshStagedMasses() {
_stagedMasses.clear(); _stagedMasses.clear();
using Utility::Directory::Flag; using Utility::Directory::Flag;
auto file_list = Utility::Directory::list(_stagingAreaDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot); std::vector<std::string> file_list = Utility::Directory::list(_stagingAreaDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
auto iter = std::remove_if(file_list.begin(), file_list.end(), [](std::string& file){ auto iter = std::remove_if(file_list.begin(), file_list.end(), [](std::string& file){
return !Utility::String::endsWith(file, ".sav"_s); return !Utility::String::endsWith(file, ".sav");
}); });
file_list.erase(iter, file_list.end()); file_list.erase(iter, file_list.end());
for(auto& file : file_list) { for(const std::string& file : file_list) {
auto name = Mass::getNameFromFile(Utility::Directory::join(_stagingAreaDirectory, file)); std::string name = *Mass::getNameFromFile(Utility::Directory::join(_stagingAreaDirectory, file));
if(name) { if(!name.empty()) {
_stagedMasses[file] = *name; _stagedMasses[file] = name;
} }
} }
} }
auto MassManager::deleteStagedMass(Containers::StringView filename) -> bool { auto MassManager::deleteStagedMass(const std::string& filename) -> bool {
if(_stagedMasses.find(filename) == _stagedMasses.cend()) { if(_stagedMasses.find(filename) == _stagedMasses.cend()) {
_lastError = "The file "_s + filename + " couldn't be found in the list of staged M.A.S.S.es."_s; _lastError = "The file " + filename + " couldn't be found in the list of staged M.A.S.S.es.";
return false; return false;
} }
if(!Utility::Directory::rm(Utility::Directory::join(_stagingAreaDirectory, filename))) { if(!Utility::Directory::rm(Utility::Directory::join(_stagingAreaDirectory, filename))) {
_lastError = filename + " couldn't be deleted: " + std::strerror(errno); _lastError = Utility::formatString("{} couldn't be deleted: {}", filename, std::strerror(errno));
return false; return false;
} }

View file

@ -17,10 +17,9 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <map> #include <map>
#include <string>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "../Mass/Mass.h" #include "../Mass/Mass.h"
@ -28,34 +27,34 @@ using namespace Corrade;
class MassManager { class MassManager {
public: public:
MassManager(Containers::StringView save_path, Containers::StringView account, bool demo, Containers::StringView staging_dir); MassManager(const std::string& save_path, const std::string& steam_id, bool demo, const std::string& staging_dir);
auto lastError() -> Containers::StringView; auto lastError() -> std::string const&;
auto hangar(int hangar) -> Mass&; auto hangar(int hangar) -> Mass&;
void refreshHangar(int hangar); void refreshHangar(int hangar);
auto importMass(Containers::StringView staged_fn, int hangar) -> bool; auto importMass(const std::string& staged_fn, int hangar) -> bool;
auto exportMass(int hangar) -> bool; auto exportMass(int hangar) -> bool;
auto moveMass(int source, int destination) -> bool; auto moveMass(int source, int destination) -> bool;
auto deleteMass(int hangar) -> bool; auto deleteMass(int hangar) -> bool;
auto stagedMasses() -> std::map<Containers::String, Containers::String> const&; auto stagedMasses() -> std::map<std::string, std::string> const&;
void refreshStagedMasses(); void refreshStagedMasses();
auto deleteStagedMass(Containers::StringView filename) -> bool; auto deleteStagedMass(const std::string& filename) -> bool;
private: private:
Containers::StringView _saveDirectory; const std::string& _saveDirectory;
Containers::StringView _account; const std::string& _steamId;
bool _demo; bool _demo;
Containers::String _lastError; std::string _lastError;
Containers::Array<Mass> _hangars; Containers::Array<Mass> _hangars;
Containers::StringView _stagingAreaDirectory; const std::string& _stagingAreaDirectory;
std::map<Containers::String, Containers::String> _stagedMasses; std::map<std::string, std::string> _stagedMasses;
}; };

View file

@ -18,7 +18,6 @@
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
@ -31,14 +30,13 @@
#include "Profile.h" #include "Profile.h"
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals;
Profile::Profile(Containers::StringView path): Profile::Profile(const std::string& path):
_profile(path) _profile(path)
{ {
_filename = Utility::Directory::filename(path); _filename = Utility::Directory::filename(path);
if(Utility::String::beginsWith(_filename, "Demo"_s)) { if(Utility::String::beginsWith(_filename, "Demo")) {
_type = ProfileType::Demo; _type = ProfileType::Demo;
} }
else { else {
@ -47,13 +45,13 @@ Profile::Profile(Containers::StringView path):
auto account_prop = _profile.at<StringProperty>("Account"); auto account_prop = _profile.at<StringProperty>("Account");
if(!account_prop) { if(!account_prop) {
_lastError = "Couldn't find an account ID in "_s + _filename; _lastError = "Couldn't find an account ID in " + _filename;
_valid = false; _valid = false;
return; return;
} }
_account = account_prop->value; _account = account_prop->value;
if(Utility::String::beginsWith(_account, "PMCSlot"_s)) { if(Utility::String::beginsWith(_account, "PMCSlot")) {
_version = ProfileVersion::Normal; _version = ProfileVersion::Normal;
} }
else { else {
@ -67,11 +65,11 @@ auto Profile::valid() const -> bool {
return _valid; return _valid;
} }
auto Profile::lastError() const -> Containers::StringView { auto Profile::lastError() const -> std::string const& {
return _lastError; return _lastError;
} }
auto Profile::filename() const -> Containers::StringView { auto Profile::filename() const -> std::string const& {
return _filename; return _filename;
} }
@ -83,7 +81,7 @@ auto Profile::version() const -> ProfileVersion {
return _version; return _version;
} }
auto Profile::account() const -> Containers::StringView { auto Profile::account() const -> std::string const& {
return _account; return _account;
} }
@ -94,61 +92,61 @@ void Profile::refreshValues() {
return; return;
} }
auto name_prop = _profile.at<StringProperty>("CompanyName"_s); auto name_prop = _profile.at<StringProperty>("CompanyName");
if(!name_prop) { if(!name_prop) {
_lastError = "No company name in "_s + _filename; _lastError = "No company name in " + _filename;
_valid = false; _valid = false;
return; return;
} }
_name = name_prop->value; _name = name_prop->value;
auto prop = _profile.at<IntProperty>("ActiveFrameSlot"_s); auto prop = _profile.at<IntProperty>("ActiveFrameSlot");
_activeFrameSlot = prop ? prop->value : 0; _activeFrameSlot = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("Credit"_s); prop = _profile.at<IntProperty>("Credit");
_credits = prop ? prop->value : 0; _credits = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("StoryProgress"_s); prop = _profile.at<IntProperty>("StoryProgress");
_storyProgress = prop ? prop->value : 0; _storyProgress = prop ? prop->value : 0;
prop = _profile.at<IntProperty>("LastMissionID"_s); prop = _profile.at<IntProperty>("LastMissionID");
_lastMissionId = prop ? prop->value : 0; _lastMissionId = prop ? prop->value : 0;
_verseSteel = getResource("ResourceMaterial"_s, VerseSteel); _verseSteel = getResource("ResourceMaterial", VerseSteel);
_undinium = getResource("ResourceMaterial"_s, Undinium); _undinium = getResource("ResourceMaterial", Undinium);
_necriumAlloy = getResource("ResourceMaterial"_s, NecriumAlloy); _necriumAlloy = getResource("ResourceMaterial", NecriumAlloy);
_lunarite = getResource("ResourceMaterial"_s, Lunarite); _lunarite = getResource("ResourceMaterial", Lunarite);
_asterite = getResource("ResourceMaterial"_s, Asterite); _asterite = getResource("ResourceMaterial", Asterite);
_ednil = getResource("ResourceMaterial"_s, Ednil); _ednil = getResource("ResourceMaterial", Ednil);
_nuflalt = getResource("ResourceMaterial"_s, Nuflalt); _nuflalt = getResource("ResourceMaterial", Nuflalt);
_aurelene = getResource("ResourceMaterial"_s, Aurelene); _aurelene = getResource("ResourceMaterial", Aurelene);
_soldus = getResource("ResourceMaterial"_s, Soldus); _soldus = getResource("ResourceMaterial", Soldus);
_synthesisedN = getResource("ResourceMaterial"_s, SynthesisedN); _synthesisedN = getResource("ResourceMaterial", SynthesisedN);
_alcarbonite = getResource("ResourceMaterial"_s, Alcarbonite); _alcarbonite = getResource("ResourceMaterial", Alcarbonite);
_keriphene = getResource("ResourceMaterial"_s, Keriphene); _keriphene = getResource("ResourceMaterial", Keriphene);
_nitinolCM = getResource("ResourceMaterial"_s, NitinolCM); _nitinolCM = getResource("ResourceMaterial", NitinolCM);
_quarkium = getResource("ResourceMaterial"_s, Quarkium); _quarkium = getResource("ResourceMaterial", Quarkium);
_alterene = getResource("ResourceMaterial"_s, Alterene); _alterene = getResource("ResourceMaterial", Alterene);
_mixedComposition = getResource("ResourceQuarkData"_s, MixedComposition); _mixedComposition = getResource("ResourceQuarkData", MixedComposition);
_voidResidue = getResource("ResourceQuarkData"_s, VoidResidue); _voidResidue = getResource("ResourceQuarkData", VoidResidue);
_muscularConstruction = getResource("ResourceQuarkData"_s, MuscularConstruction); _muscularConstruction = getResource("ResourceQuarkData", MuscularConstruction);
_mineralExoskeletology = getResource("ResourceQuarkData"_s, MineralExoskeletology); _mineralExoskeletology = getResource("ResourceQuarkData", MineralExoskeletology);
_carbonisedSkin = getResource("ResourceQuarkData"_s, CarbonisedSkin); _carbonisedSkin = getResource("ResourceQuarkData", CarbonisedSkin);
_valid = true; _valid = true;
} }
auto Profile::companyName() const -> Containers::StringView { auto Profile::companyName() const -> std::string const& {
return _name; return _name;
} }
auto Profile::renameCompany(Containers::StringView new_name) -> bool { auto Profile::renameCompany(const std::string& new_name) -> bool {
auto name_prop = _profile.at<StringProperty>("CompanyName"_s); auto name_prop = _profile.at<StringProperty>("CompanyName");
if(!name_prop) { if(!name_prop) {
_lastError = "No company name in "_s + _filename; _lastError = "No company name in " + _filename;
_valid = false; _valid = false;
return false; return false;
} }
@ -172,11 +170,11 @@ auto Profile::credits() const -> Int {
} }
auto Profile::setCredits(Int amount) -> bool { auto Profile::setCredits(Int amount) -> bool {
auto credits_prop = _profile.at<IntProperty>("Credit"_s); auto credits_prop = _profile.at<IntProperty>("Credit");
if(!credits_prop) { if(!credits_prop) {
credits_prop = new IntProperty; credits_prop = new IntProperty;
credits_prop->name.emplace("Credit"_s); credits_prop->name.emplace("Credit");
_profile.appendProperty(IntProperty::ptr{credits_prop}); _profile.appendProperty(IntProperty::ptr{credits_prop});
} }
@ -195,11 +193,11 @@ auto Profile::storyProgress() const -> Int {
} }
auto Profile::setStoryProgress(Int progress) -> bool { auto Profile::setStoryProgress(Int progress) -> bool {
auto story_progress_prop = _profile.at<IntProperty>("StoryProgress"_s); auto story_progress_prop = _profile.at<IntProperty>("StoryProgress");
if(!story_progress_prop) { if(!story_progress_prop) {
story_progress_prop = new IntProperty; story_progress_prop = new IntProperty;
story_progress_prop->name.emplace("StoryProgress"_s); story_progress_prop->name.emplace("StoryProgress");
_profile.appendProperty(IntProperty::ptr{story_progress_prop}); _profile.appendProperty(IntProperty::ptr{story_progress_prop});
} }
@ -222,7 +220,7 @@ auto Profile::verseSteel() const -> Int {
} }
auto Profile::setVerseSteel(Int amount) -> bool { auto Profile::setVerseSteel(Int amount) -> bool {
return setResource("ResourceMaterial"_s, VerseSteel, amount); return setResource("ResourceMaterial", VerseSteel, amount);
} }
auto Profile::undinium() const -> Int { auto Profile::undinium() const -> Int {
@ -230,7 +228,7 @@ auto Profile::undinium() const -> Int {
} }
auto Profile::setUndinium(Int amount) -> bool { auto Profile::setUndinium(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Undinium, amount); return setResource("ResourceMaterial", Undinium, amount);
} }
auto Profile::necriumAlloy() const -> Int { auto Profile::necriumAlloy() const -> Int {
@ -238,7 +236,7 @@ auto Profile::necriumAlloy() const -> Int {
} }
auto Profile::setNecriumAlloy(Int amount) -> bool { auto Profile::setNecriumAlloy(Int amount) -> bool {
return setResource("ResourceMaterial"_s, NecriumAlloy, amount); return setResource("ResourceMaterial", NecriumAlloy, amount);
} }
auto Profile::lunarite() const -> Int { auto Profile::lunarite() const -> Int {
@ -246,7 +244,7 @@ auto Profile::lunarite() const -> Int {
} }
auto Profile::setLunarite(Int amount) -> bool { auto Profile::setLunarite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Lunarite, amount); return setResource("ResourceMaterial", Lunarite, amount);
} }
auto Profile::asterite() const -> Int { auto Profile::asterite() const -> Int {
@ -254,7 +252,7 @@ auto Profile::asterite() const -> Int {
} }
auto Profile::setAsterite(Int amount) -> bool { auto Profile::setAsterite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Asterite, amount); return setResource("ResourceMaterial", Asterite, amount);
} }
auto Profile::ednil() const -> Int { auto Profile::ednil() const -> Int {
@ -262,7 +260,7 @@ auto Profile::ednil() const -> Int {
} }
auto Profile::setEdnil(Int amount) -> bool { auto Profile::setEdnil(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Ednil, amount); return setResource("ResourceMaterial", Ednil, amount);
} }
auto Profile::nuflalt() const -> Int { auto Profile::nuflalt() const -> Int {
@ -270,7 +268,7 @@ auto Profile::nuflalt() const -> Int {
} }
auto Profile::setNuflalt(Int amount) -> bool { auto Profile::setNuflalt(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Nuflalt, amount); return setResource("ResourceMaterial", Nuflalt, amount);
} }
auto Profile::aurelene() const -> Int { auto Profile::aurelene() const -> Int {
@ -278,7 +276,7 @@ auto Profile::aurelene() const -> Int {
} }
auto Profile::setAurelene(Int amount) -> bool { auto Profile::setAurelene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Aurelene, amount); return setResource("ResourceMaterial", Aurelene, amount);
} }
auto Profile::soldus() const -> Int { auto Profile::soldus() const -> Int {
@ -286,7 +284,7 @@ auto Profile::soldus() const -> Int {
} }
auto Profile::setSoldus(Int amount) -> bool { auto Profile::setSoldus(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Soldus, amount); return setResource("ResourceMaterial", Soldus, amount);
} }
auto Profile::synthesisedN() const -> Int { auto Profile::synthesisedN() const -> Int {
@ -294,7 +292,7 @@ auto Profile::synthesisedN() const -> Int {
} }
auto Profile::setSynthesisedN(Int amount) -> bool { auto Profile::setSynthesisedN(Int amount) -> bool {
return setResource("ResourceMaterial"_s, SynthesisedN, amount); return setResource("ResourceMaterial", SynthesisedN, amount);
} }
auto Profile::alcarbonite() const -> Int { auto Profile::alcarbonite() const -> Int {
@ -302,7 +300,7 @@ auto Profile::alcarbonite() const -> Int {
} }
auto Profile::setAlcarbonite(Int amount) -> bool { auto Profile::setAlcarbonite(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Alcarbonite, amount); return setResource("ResourceMaterial", Alcarbonite, amount);
} }
auto Profile::keriphene() const -> Int { auto Profile::keriphene() const -> Int {
@ -310,7 +308,7 @@ auto Profile::keriphene() const -> Int {
} }
auto Profile::setKeriphene(Int amount) -> bool { auto Profile::setKeriphene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Keriphene, amount); return setResource("ResourceMaterial", Keriphene, amount);
} }
auto Profile::nitinolCM() const -> Int { auto Profile::nitinolCM() const -> Int {
@ -318,7 +316,7 @@ auto Profile::nitinolCM() const -> Int {
} }
auto Profile::setNitinolCM(Int amount) -> bool { auto Profile::setNitinolCM(Int amount) -> bool {
return setResource("ResourceMaterial"_s, NitinolCM, amount); return setResource("ResourceMaterial", NitinolCM, amount);
} }
auto Profile::quarkium() const -> Int { auto Profile::quarkium() const -> Int {
@ -326,7 +324,7 @@ auto Profile::quarkium() const -> Int {
} }
auto Profile::setQuarkium(Int amount) -> bool { auto Profile::setQuarkium(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Quarkium, amount); return setResource("ResourceMaterial", Quarkium, amount);
} }
auto Profile::alterene() const -> Int { auto Profile::alterene() const -> Int {
@ -334,7 +332,7 @@ auto Profile::alterene() const -> Int {
} }
auto Profile::setAlterene(Int amount) -> bool { auto Profile::setAlterene(Int amount) -> bool {
return setResource("ResourceMaterial"_s, Alterene, amount); return setResource("ResourceMaterial", Alterene, amount);
} }
auto Profile::mixedComposition() const -> Int { auto Profile::mixedComposition() const -> Int {
@ -342,7 +340,7 @@ auto Profile::mixedComposition() const -> Int {
} }
auto Profile::setMixedComposition(Int amount) -> bool { auto Profile::setMixedComposition(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MixedComposition, amount); return setResource("ResourceQuarkData", MixedComposition, amount);
} }
auto Profile::voidResidue() const -> Int { auto Profile::voidResidue() const -> Int {
@ -350,7 +348,7 @@ auto Profile::voidResidue() const -> Int {
} }
auto Profile::setVoidResidue(Int amount) -> bool { auto Profile::setVoidResidue(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, VoidResidue, amount); return setResource("ResourceQuarkData", VoidResidue, amount);
} }
auto Profile::muscularConstruction() const -> Int { auto Profile::muscularConstruction() const -> Int {
@ -358,7 +356,7 @@ auto Profile::muscularConstruction() const -> Int {
} }
auto Profile::setMuscularConstruction(Int amount) -> bool { auto Profile::setMuscularConstruction(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MuscularConstruction, amount); return setResource("ResourceQuarkData", MuscularConstruction, amount);
} }
auto Profile::mineralExoskeletology() const -> Int { auto Profile::mineralExoskeletology() const -> Int {
@ -366,7 +364,7 @@ auto Profile::mineralExoskeletology() const -> Int {
} }
auto Profile::setMineralExoskeletology(Int amount) -> bool { auto Profile::setMineralExoskeletology(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, MineralExoskeletology, amount); return setResource("ResourceQuarkData", MineralExoskeletology, amount);
} }
auto Profile::carbonisedSkin() const -> Int { auto Profile::carbonisedSkin() const -> Int {
@ -374,10 +372,10 @@ auto Profile::carbonisedSkin() const -> Int {
} }
auto Profile::setCarbonisedSkin(Int amount) -> bool { auto Profile::setCarbonisedSkin(Int amount) -> bool {
return setResource("ResourceQuarkData"_s, CarbonisedSkin, amount); return setResource("ResourceQuarkData", CarbonisedSkin, amount);
} }
auto Profile::getResource(Containers::StringView container, MaterialID id) -> Int { auto Profile::getResource(const char* container, MaterialID id) -> Int {
auto mats_prop = _profile.at<ArrayProperty>(container); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { if(!mats_prop) {
@ -393,11 +391,11 @@ auto Profile::getResource(Containers::StringView container, MaterialID id) -> In
return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0; return it != mats_prop->items.end() ? static_cast<ResourceItemValue*>(it->get())->quantity : 0;
} }
auto Profile::setResource(Containers::StringView container, MaterialID id, Int amount) -> bool { auto Profile::setResource(const char* container, MaterialID id, Int amount) -> bool {
auto mats_prop = _profile.at<ArrayProperty>(container); auto mats_prop = _profile.at<ArrayProperty>(container);
if(!mats_prop) { if(!mats_prop) {
_lastError = "Couldn't find "_s + container + " in "_s + _filename; _lastError = "Couldn't find " + std::string{container} + " in " + _filename;
_valid = false; _valid = false;
return false; return false;
} }

View file

@ -16,8 +16,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/String.h> #include <string>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
@ -25,7 +24,6 @@
#include "ResourceIDs.h" #include "ResourceIDs.h"
using namespace Corrade;
using namespace Magnum; using namespace Magnum;
enum class ProfileType : UnsignedByte { enum class ProfileType : UnsignedByte {
@ -40,24 +38,24 @@ enum class ProfileVersion : UnsignedByte {
class Profile { class Profile {
public: public:
explicit Profile(Containers::StringView path); explicit Profile(const std::string& path);
auto valid() const -> bool; auto valid() const -> bool;
auto lastError() const -> Containers::StringView; auto lastError() const -> std::string const&;
auto filename() const -> Containers::StringView; auto filename() const -> std::string const&;
auto type() const -> ProfileType; auto type() const -> ProfileType;
auto version() const -> ProfileVersion; auto version() const -> ProfileVersion;
auto account() const -> Containers::StringView; auto account() const -> std::string const&;
void refreshValues(); void refreshValues();
auto companyName() const -> Containers::StringView; auto companyName() const -> std::string const&;
auto renameCompany(Containers::StringView new_name) -> bool; auto renameCompany(const std::string& new_name) -> bool;
auto activeFrameSlot() const -> Int; auto activeFrameSlot() const -> Int;
@ -130,17 +128,17 @@ class Profile {
auto setCarbonisedSkin(Int amount) -> bool; auto setCarbonisedSkin(Int amount) -> bool;
private: private:
auto getResource(Containers::StringView container, MaterialID id) -> Int; auto getResource(const char* container, MaterialID id) -> Int;
auto setResource(Containers::StringView container, MaterialID id, Int amount) -> bool; auto setResource(const char* container, MaterialID id, Int amount) -> bool;
Containers::String _filename; std::string _filename;
ProfileType _type; ProfileType _type;
ProfileVersion _version; ProfileVersion _version;
UESaveFile _profile; UESaveFile _profile;
Containers::String _name; std::string _name;
Int _activeFrameSlot = 0; Int _activeFrameSlot = 0;
Int _credits = 0; Int _credits = 0;
Int _storyProgress = 0; Int _storyProgress = 0;
@ -170,8 +168,8 @@ class Profile {
Int _mineralExoskeletology = 0; Int _mineralExoskeletology = 0;
Int _carbonisedSkin = 0; Int _carbonisedSkin = 0;
Containers::String _account; std::string _account;
bool _valid = false; bool _valid = false;
Containers::String _lastError; std::string _lastError;
}; };

View file

@ -23,7 +23,6 @@
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
@ -32,9 +31,7 @@
#include "ProfileManager.h" #include "ProfileManager.h"
using namespace Containers::Literals; ProfileManager::ProfileManager(const std::string& save_dir, const std::string& backup_dir):
ProfileManager::ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir):
_saveDirectory{save_dir}, _saveDirectory{save_dir},
_backupsDirectory{backup_dir} _backupsDirectory{backup_dir}
{ {
@ -45,7 +42,7 @@ auto ProfileManager::ready() const -> bool {
return _ready; return _ready;
} }
auto ProfileManager::lastError() -> Containers::StringView { auto ProfileManager::lastError() -> std::string const& {
return _lastError; return _lastError;
} }
@ -57,21 +54,21 @@ auto ProfileManager::refreshProfiles() -> bool {
_profiles = Containers::Array<Profile>{}; _profiles = Containers::Array<Profile>{};
using Utility::Directory::Flag; using Utility::Directory::Flag;
auto files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot); std::vector<std::string> files = Utility::Directory::list(_saveDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
auto predicate = [](Containers::StringView file)->bool{ auto predicate = [](const std::string& file)->bool{
std::regex regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs); std::regex regex("(Demo)?Profile[0-9]{17}\\.sav", std::regex::nosubs);
std::cmatch m; std::cmatch m;
return !std::regex_match(file.data(), m, regex); return !std::regex_match(file.c_str(), m, regex);
}; };
files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end()); files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end());
for(const auto& file : files) { for(const std::string& file : files) {
Profile profile{Utility::Directory::join(_saveDirectory, file)}; Profile profile{Utility::Directory::join(_saveDirectory, file)};
if(!profile.valid()) { if(!profile.valid()) {
Utility::Warning{} << "Profile"_s << file.c_str() << "is invalid:"_s << profile.lastError(); Utility::Warning{} << "Profile" << file.c_str() << "is invalid:" << profile.lastError().c_str();
continue; continue;
} }
@ -79,7 +76,7 @@ auto ProfileManager::refreshProfiles() -> bool {
} }
if(_profiles.empty()) { if(_profiles.empty()) {
_lastError = "No valid profiles were found."_s; _lastError = "No valid profiles were found.";
return false; return false;
} }
@ -92,7 +89,7 @@ auto ProfileManager::getProfile(std::size_t index) -> Profile* {
auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool { auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> bool {
if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles[index].filename()))) { if(!Utility::Directory::rm(Utility::Directory::join(_saveDirectory, _profiles[index].filename()))) {
_lastError = Utility::format("Couldn't delete {} (filename: {}).", _lastError = Utility::formatString("Couldn't delete {} (filename: {}).",
_profiles[index].companyName(), _profiles[index].companyName(),
_profiles[index].filename()); _profiles[index].filename());
refreshProfiles(); refreshProfiles();
@ -101,15 +98,15 @@ auto ProfileManager::deleteProfile(std::size_t index, bool delete_builds) -> boo
if(delete_builds) { if(delete_builds) {
for(UnsignedByte i = 0; i < 32; ++i) { for(UnsignedByte i = 0; i < 32; ++i) {
auto filename = Utility::format("{}Unit{:.2d}{}.sav", std::string filename = Utility::formatString("{}Unit{:.2d}{}.sav",
_profiles[index].type() == ProfileType::Demo ? "Demo": "", _profiles[index].type() == ProfileType::Demo ? "Demo": "",
i, _profiles[index].account()); i, _profiles[index].account());
Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename)); Utility::Directory::rm(Utility::Directory::join(_saveDirectory, filename));
} }
} }
auto file = _profiles[index].filename(); std::string file = _profiles[index].filename();
auto it = std::remove_if(_profiles.begin(), _profiles.end(), [&file](Profile& profile){ return profile.filename() == file; }); auto it = std::remove_if(_profiles.begin(), _profiles.end(), [&file](Profile& profile){return profile.filename() == file;});
if(it != _profiles.end()) { if(it != _profiles.end()) {
arrayRemoveSuffix(_profiles, 1); arrayRemoveSuffix(_profiles, 1);
@ -122,7 +119,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); std::time_t timestamp = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::tm* time = std::localtime(&timestamp); std::tm* time = std::localtime(&timestamp);
auto filename = Utility::format("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup", std::string filename = Utility::formatString("{}_{}{:.2d}{:.2d}_{:.2d}{:.2d}{:.2d}.mbprofbackup",
Utility::String::replaceAll(_profiles[index].companyName(), " ", "_"), Utility::String::replaceAll(_profiles[index].companyName(), " ", "_"),
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec); time->tm_hour, time->tm_min, time->tm_sec);
@ -143,24 +140,25 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
return false; return false;
} }
if(zip_file_add(zip, _profiles[index].filename().data(), profile_source, ZIP_FL_ENC_UTF_8) == -1) { if(zip_file_add(zip, _profiles[index].filename().c_str(), profile_source, ZIP_FL_ENC_UTF_8) == -1) {
_lastError = zip_strerror(zip); _lastError = zip_strerror(zip);
zip_source_free(profile_source); zip_source_free(profile_source);
return false; return false;
} }
auto comment = "|"_s.join({_profiles[index].companyName(), std::string comment = Utility::String::join({_profiles[index].companyName(),
_profiles[index].type() == ProfileType::Demo ? "demo"_s : "full"_s, _profiles[index].type() == ProfileType::Demo ? "demo" : "full",
Utility::format("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}", Utility::formatString("{}-{:.2d}-{:.2d}-{:.2d}-{:.2d}-{:.2d}",
time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, time->tm_year + 1900, time->tm_mon + 1, time->tm_mday,
time->tm_hour, time->tm_min, time->tm_sec)}); time->tm_hour, time->tm_min, time->tm_sec)
zip_set_archive_comment(zip, comment.data(), comment.size()); }, '|');
zip_set_archive_comment(zip, comment.c_str(), comment.length());
if(backup_builds) { if(backup_builds) {
for(UnsignedByte i = 0; i < 32; ++i) { for(UnsignedByte i = 0; i < 32; ++i) {
auto build_filename = Utility::format("{}Unit{:.2d}{}.sav", std::string build_filename = Utility::formatString("{}Unit{:.2d}{}.sav",
_profiles[index].type() == ProfileType::Demo ? "Demo"_s : ""_s, i, _profiles[index].type() == ProfileType::Demo ? "Demo": "",
_profiles[index].account()); i, _profiles[index].account());
if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) { if(!Utility::Directory::exists(Utility::Directory::join(_saveDirectory, build_filename))) {
continue; continue;
@ -172,7 +170,7 @@ auto ProfileManager::backupProfile(std::size_t index, bool backup_builds) -> boo
continue; continue;
} }
if(zip_file_add(zip, build_filename.data(), build_source, ZIP_FL_ENC_UTF_8) == -1) { if(zip_file_add(zip, build_filename.c_str(), build_source, ZIP_FL_ENC_UTF_8) == -1) {
zip_source_free(build_source); zip_source_free(build_source);
continue; continue;
} }
@ -199,8 +197,8 @@ void ProfileManager::refreshBackups() {
using Utility::Directory::Flag; using Utility::Directory::Flag;
std::vector<std::string> files = Utility::Directory::list(_backupsDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot); std::vector<std::string> files = Utility::Directory::list(_backupsDirectory, Flag::SkipSpecial|Flag::SkipDirectories|Flag::SkipDotAndDotDot);
auto predicate = [](Containers::StringView file)->bool{ auto predicate = [](const std::string& file)->bool{
return !file.hasSuffix(".mbprofbackup"_s); return !Utility::String::endsWith(file, ".mbprofbackup");
}; };
files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end()); files.erase(std::remove_if(files.begin(), files.end(), predicate), files.end());
@ -219,40 +217,40 @@ void ProfileManager::refreshBackups() {
Containers::ScopeGuard guard{zip, zip_close}; Containers::ScopeGuard guard{zip, zip_close};
int comment_length; int comment_length;
Containers::StringView comment = zip_get_archive_comment(zip, &comment_length, ZIP_FL_UNCHANGED); const char* comment = zip_get_archive_comment(zip, &comment_length, ZIP_FL_UNCHANGED);
if(comment == nullptr) { if(comment == nullptr) {
continue; continue;
} }
auto info = comment.split('|'); auto info = Utility::String::split(comment, '|');
if(info.size() != 3) { if(info.size() != 3) {
continue; continue;
} }
backup.company = info[0]; backup.company = info.at(0);
if(info[1] == "full") { if(info.at(1) == "full") {
backup.type = ProfileType::FullGame; backup.type = ProfileType::FullGame;
} }
else if(info[1] == "demo") { else if(info.at(1) == "demo") {
backup.type = ProfileType::Demo; backup.type = ProfileType::Demo;
} }
else { else {
continue; continue;
} }
auto ts = info[2].split('-'); auto ts = Utility::String::split(info.at(2), '-');
if(ts.size() != 6) { if(ts.size() != 6) {
continue; continue;
} }
backup.timestamp.year = std::stoi(ts[0]); backup.timestamp.year = std::stoi(ts.at(0));
backup.timestamp.month = std::stoi(ts[1]); backup.timestamp.month = std::stoi(ts.at(1));
backup.timestamp.day = std::stoi(ts[2]); backup.timestamp.day = std::stoi(ts.at(2));
backup.timestamp.hour = std::stoi(ts[3]); backup.timestamp.hour = std::stoi(ts.at(3));
backup.timestamp.minute = std::stoi(ts[4]); backup.timestamp.minute = std::stoi(ts.at(4));
backup.timestamp.second = std::stoi(ts[5]); backup.timestamp.second = std::stoi(ts.at(5));
Long num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED); Long num_entries = zip_get_num_entries(zip, ZIP_FL_UNCHANGED);
@ -276,7 +274,7 @@ auto ProfileManager::deleteBackup(std::size_t index) -> bool {
return false; return false;
} }
auto file = _backups[index].filename; std::string file = _backups[index].filename;
auto it = std::remove_if(_backups.begin(), _backups.end(), [&file](Backup& backup){return backup.filename == file;}); auto it = std::remove_if(_backups.begin(), _backups.end(), [&file](Backup& backup){return backup.filename == file;});
if(it != _backups.end()) { if(it != _backups.end()) {
@ -289,7 +287,7 @@ auto ProfileManager::deleteBackup(std::size_t index) -> bool {
auto ProfileManager::restoreBackup(std::size_t index) -> bool { auto ProfileManager::restoreBackup(std::size_t index) -> bool {
const Backup& backup = _backups[index]; const Backup& backup = _backups[index];
auto error_format = "Extraction of file {} failed: {}"_s; static const char* error_format = "Extraction of file {} failed: {}";
int error_code = 0; int error_code = 0;
zip_t* zip = nullptr; zip_t* zip = nullptr;
@ -304,18 +302,18 @@ auto ProfileManager::restoreBackup(std::size_t index) -> bool {
Containers::ScopeGuard zip_guard{zip, zip_close}; Containers::ScopeGuard zip_guard{zip, zip_close};
for(Containers::StringView file : backup.includedFiles) { for(const std::string& file : backup.includedFiles) {
FILE* out = std::fopen(Utility::Directory::join(_saveDirectory, file).c_str(), "wb"); FILE* out = std::fopen(Utility::Directory::join(_saveDirectory, file).c_str(), "wb");
if(out == nullptr) { if(out == nullptr) {
_lastError = Utility::formatString(error_format.data(), file, std::strerror(errno)); _lastError = Utility::formatString(error_format, file, std::strerror(errno));
return false; return false;
} }
Containers::ScopeGuard out_guard{out, std::fclose}; Containers::ScopeGuard out_guard{out, std::fclose};
zip_file_t* zf = zip_fopen(zip, file.data(), ZIP_FL_ENC_GUESS); zip_file_t* zf = zip_fopen(zip, file.c_str(), ZIP_FL_ENC_GUESS);
if(zf == nullptr) { if(zf == nullptr) {
_lastError = Utility::format(error_format.data(), file, zip_strerror(zip)); _lastError = Utility::formatString(error_format, file, zip_strerror(zip));
return false; return false;
} }
@ -326,13 +324,13 @@ auto ProfileManager::restoreBackup(std::size_t index) -> bool {
Long bytes_read = 0; Long bytes_read = 0;
while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) { while((bytes_read = zip_fread(zf, buf.data(), buf.size())) > 0) {
if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast<std::size_t>(bytes_read)) { if(std::fwrite(buf.data(), sizeof(char), bytes_read, out) < static_cast<std::size_t>(bytes_read)) {
_lastError = Utility::format(error_format.data(), file, "not enough bytes written."); _lastError = Utility::formatString(error_format, file, "not enough bytes written.");
return false; return false;
} }
} }
if(bytes_read == -1) { if(bytes_read == -1) {
_lastError = Utility::format(error_format.data(), file, "couldn't read bytes from archive."); _lastError = Utility::formatString(error_format, file, "couldn't read bytes from archive.");
return false; return false;
} }
} }

View file

@ -19,15 +19,14 @@
#include <string> #include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/String.h>
#include "../Profile/Profile.h" #include "../Profile/Profile.h"
using namespace Corrade; using namespace Corrade;
struct Backup { struct Backup {
Containers::String filename; std::string filename;
Containers::String company; std::string company;
ProfileType type; ProfileType type;
struct { struct {
int year; int year;
@ -37,15 +36,15 @@ struct Backup {
int minute; int minute;
int second; int second;
} timestamp; } timestamp;
Containers::Array<Containers::String> includedFiles; Containers::Array<std::string> includedFiles;
}; };
class ProfileManager { class ProfileManager {
public: public:
explicit ProfileManager(Containers::StringView save_dir, Containers::StringView backup_dir); explicit ProfileManager(const std::string& save_dir, const std::string& backup_dir);
auto ready() const -> bool; auto ready() const -> bool;
auto lastError() -> Containers::StringView; auto lastError() -> std::string const&;
auto profiles() -> Containers::ArrayView<Profile>; auto profiles() -> Containers::ArrayView<Profile>;
auto refreshProfiles() -> bool; auto refreshProfiles() -> bool;
@ -62,10 +61,10 @@ class ProfileManager {
private: private:
bool _ready = false; bool _ready = false;
Containers::String _lastError; std::string _lastError;
Containers::StringView _saveDirectory; const std::string& _saveDirectory;
Containers::StringView _backupsDirectory; const std::string& _backupsDirectory;
Containers::Array<Profile> _profiles; Containers::Array<Profile> _profiles;
Containers::Array<Backup> _backups; Containers::Array<Backup> _backups;

View file

@ -19,7 +19,6 @@
#include <cstring> #include <cstring>
#include <Corrade/Containers/ScopeGuard.h> #include <Corrade/Containers/ScopeGuard.h>
#include <Corrade/Containers/StringStl.h>
#include <Corrade/Utility/Directory.h> #include <Corrade/Utility/Directory.h>
#include <Corrade/Utility/FormatStl.h> #include <Corrade/Utility/FormatStl.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
@ -47,8 +46,6 @@
#include "../FontAwesome/IconsFontAwesome5.h" #include "../FontAwesome/IconsFontAwesome5.h"
#include "../FontAwesome/IconsFontAwesome5Brands.h" #include "../FontAwesome/IconsFontAwesome5Brands.h"
using namespace Containers::Literals;
extern const ImVec2 center_pivot = {0.5f, 0.5f}; extern const ImVec2 center_pivot = {0.5f, 0.5f};
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
@ -61,19 +58,19 @@ SaveTool::SaveTool(const Arguments& arguments):
.setSize({960, 720})} .setSize({960, 720})}
{ {
#ifdef SAVETOOL_DEBUG_BUILD #ifdef SAVETOOL_DEBUG_BUILD
tweak.enable(""_s, "../../"_s); tweak.enable("", "../../");
#endif #endif
if(SDL_VERSION_ATLEAST(2, 0, 5)) { if(SDL_VERSION_ATLEAST(2, 0, 5)) {
if(SDL_SetHintWithPriority(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1", SDL_HINT_OVERRIDE) == SDL_TRUE) { if(SDL_SetHintWithPriority(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1", SDL_HINT_OVERRIDE) == SDL_TRUE) {
Utility::Debug{} << "Clickthrough is available."_s; Utility::Debug{} << "Clickthrough is available.";
} }
else { else {
Utility::Warning{} << "Clickthrough is not available (hint couldn't be set)."_s; Utility::Warning{} << "Clickthrough is not available (hint couldn't be set).";
} }
} }
else { else {
Utility::Warning{} << "Clickthrough is not available (SDL2 is too old)."_s; Utility::Warning{} << "Clickthrough is not available (SDL2 is too old).";
} }
GL::Renderer::enable(GL::Renderer::Feature::Blending); GL::Renderer::enable(GL::Renderer::Feature::Blending);
@ -128,7 +125,7 @@ SaveTool::SaveTool(const Arguments& arguments):
} }
if(!findGameDataDirectory()) { if(!findGameDataDirectory()) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.data(), window()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising the app", _lastError.c_str(), window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
return; return;
} }
@ -148,7 +145,8 @@ SaveTool::SaveTool(const Arguments& arguments):
[](UnsignedInt interval, void* param)->UnsignedInt{ [](UnsignedInt interval, void* param)->UnsignedInt{
static_cast<SaveTool*>(param)->checkGameState(); static_cast<SaveTool*>(param)->checkGameState();
return interval; return interval;
}, this); },
this);
if(_gameCheckTimerId == 0) { if(_gameCheckTimerId == 0) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", SDL_GetError(), window()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error", SDL_GetError(), window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -172,7 +170,7 @@ SaveTool::SaveTool(const Arguments& arguments):
if(_checkUpdatesOnStartup) { if(_checkUpdatesOnStartup) {
_updateThread = std::thread{[this]{ checkForUpdates(); }}; _updateThread = std::thread{[this]{ checkForUpdates(); }};
_queue.addToast(Toast::Type::Default, "Checking for updates..."_s); _queue.addToast(Toast::Type::Default, "Checking for updates...");
} }
if(GL::Context::current().isExtensionSupported<GL::Extensions::KHR::debug>() && if(GL::Context::current().isExtensionSupported<GL::Extensions::KHR::debug>() &&
@ -190,20 +188,20 @@ SaveTool::SaveTool(const Arguments& arguments):
SaveTool::~SaveTool() { SaveTool::~SaveTool() {
SDL_RemoveTimer(_gameCheckTimerId); SDL_RemoveTimer(_gameCheckTimerId);
_conf.setValue("cheat_mode"_s, _cheatMode); _conf.setValue("cheat_mode", _cheatMode);
_conf.setValue("unsafe_mode"_s, _unsafeMode); _conf.setValue("unsafe_mode", _unsafeMode);
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup); _conf.setValue("startup_update_check", _checkUpdatesOnStartup);
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer); _conf.setValue("skip_disclaimer", _skipDisclaimer);
switch(_framelimit) { switch(_framelimit) {
case Framelimit::Vsync: case Framelimit::Vsync:
_conf.setValue("frame_limit"_s, "vsync"_s); _conf.setValue("frame_limit", "vsync");
break; break;
case Framelimit::HalfVsync: case Framelimit::HalfVsync:
_conf.setValue("frame_limit"_s, "half_vsync"_s); _conf.setValue("frame_limit", "half_vsync");
break; break;
case Framelimit::FpsCap: case Framelimit::FpsCap:
_conf.setValue<UnsignedInt>("frame_limit"_s, _fpsCap); _conf.setValue<UnsignedInt>("frame_limit", _fpsCap);
break; break;
} }
@ -368,7 +366,7 @@ void SaveTool::initEvent(SDL_Event& event) {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
break; break;
case ProfileManagerFailure: case ProfileManagerFailure:
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().data(), window()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error initialising ProfileManager", _profileManager->lastError().c_str(), window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
break; break;
default: default:
@ -383,12 +381,12 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
delete static_cast<cpr::Response*>(event.user.data1); delete static_cast<cpr::Response*>(event.user.data1);
if(r.elapsed > 10.0) { if(r.elapsed > 10.0) {
_queue.addToast(Toast::Type::Error, "The request timed out."_s); _queue.addToast(Toast::Type::Error, "The request timed out.");
return; return;
} }
if(r.status_code != 200) { if(r.status_code != 200) {
_queue.addToast(Toast::Type::Error, Utility::format("The request failed with error code {}: {}", r.status_code, r.reason)); _queue.addToast(Toast::Type::Error, Utility::formatString("The request failed with error code {}: {}", r.status_code, r.reason));
return; return;
} }
@ -397,18 +395,18 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
json response = json::parse(r.text); json response = json::parse(r.text);
struct Version { struct Version {
explicit Version(Containers::StringView str) { explicit Version(const std::string& str) {
std::size_t start_point = 0; std::size_t start_point = 0;
if(str[0] == 'v') { if(str[0] == 'v') {
start_point++; start_point++;
} }
auto components = Containers::StringView{str.data() + start_point, strlen(str.data() + start_point)}.split('.'); major = std::atoi(str.c_str() + start_point);
start_point = str.find('.', start_point) + 1;
major = std::strtol(components[0].data(), nullptr, 10); minor = std::atoi(str.c_str() + start_point);
minor = std::strtol(components[1].data(), nullptr, 10); start_point = str.find('.', start_point) + 1;
patch = std::strtol(components[2].data(), nullptr, 10); patch = std::atoi(str.c_str() + start_point);
} }
Int major; Int major;
Int minor; Int minor;
@ -421,8 +419,8 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
return ( major * 10000 + minor * 100 + patch) > return ( major * 10000 + minor * 100 + patch) >
(other.major * 10000 + other.minor * 100 + other.patch); (other.major * 10000 + other.minor * 100 + other.patch);
} }
operator Containers::String() const { operator std::string() const {
return Utility::format("{}.{}.{}", major, minor, patch); return Utility::formatString("{}.{}.{}", major, minor, patch);
} }
}; };
@ -433,21 +431,21 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
continue; continue;
} }
Version latest_ver{to_string(release["tag_name"])}; Version latest_ver{release["tag_name"]};
if(latest_ver > current_ver || (latest_ver == current_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) { if(latest_ver > current_ver || (latest_ver == current_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
_queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information."_s, _queue.addToast(Toast::Type::Warning, "Your version is out of date.\nCheck the settings for more information.",
std::chrono::milliseconds{5000}); std::chrono::milliseconds{5000});
_updateAvailable = true; _updateAvailable = true;
_latestVersion = latest_ver; _latestVersion = latest_ver;
_releaseLink = to_string(release["html_url"]); _releaseLink = release["html_url"];
_downloadLink = to_string(release["assets"][0]["browser_download_url"]); _downloadLink = release["assets"][0]["browser_download_url"];
} }
else if(latest_ver == current_ver || (current_ver > latest_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) { else if(latest_ver == current_ver || (current_ver > latest_ver && Utility::String::endsWith(SAVETOOL_VERSION, "-pre"))) {
_queue.addToast(Toast::Type::Success, "The application is already up to date."_s); _queue.addToast(Toast::Type::Success, "The application is already up to date.");
} }
else if(current_ver > latest_ver) { else if(current_ver > latest_ver) {
_queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???"_s); _queue.addToast(Toast::Type::Warning, "Your version is more recent than the latest one in the repo. How???");
} }
break; break;
@ -455,40 +453,40 @@ void SaveTool::updateCheckEvent(SDL_Event& event) {
} }
void SaveTool::initialiseConfiguration() { void SaveTool::initialiseConfiguration() {
if(_conf.hasValue("cheat_mode"_s)) { if(_conf.hasValue("cheat_mode")) {
_cheatMode = _conf.value<bool>("cheat_mode"_s); _cheatMode = _conf.value<bool>("cheat_mode");
} }
else { else {
_conf.setValue("cheat_mode"_s, _cheatMode); _conf.setValue("cheat_mode", _cheatMode);
} }
if(_conf.hasValue("unsafe_mode"_s)) { if(_conf.hasValue("unsafe_mode")) {
_unsafeMode = _conf.value<bool>("unsafe_mode"_s); _unsafeMode = _conf.value<bool>("unsafe_mode");
} }
else { else {
_conf.setValue("unsafe_mode"_s, _unsafeMode); _conf.setValue("unsafe_mode", _unsafeMode);
} }
if(_conf.hasValue("startup_update_check"_s)) { if(_conf.hasValue("startup_update_check")) {
_checkUpdatesOnStartup = _conf.value<bool>("startup_update_check"_s); _checkUpdatesOnStartup = _conf.value<bool>("startup_update_check");
} }
else { else {
_conf.setValue("startup_update_check"_s, _checkUpdatesOnStartup); _conf.setValue("startup_update_check", _checkUpdatesOnStartup);
} }
if(_conf.hasValue("skip_disclaimer"_s)) { if(_conf.hasValue("skip_disclaimer")) {
_skipDisclaimer = _conf.value<bool>("skip_disclaimer"_s); _skipDisclaimer = _conf.value<bool>("skip_disclaimer");
} }
else { else {
_conf.setValue("skip_disclaimer"_s, _skipDisclaimer); _conf.setValue("skip_disclaimer", _skipDisclaimer);
} }
if(_conf.hasValue("frame_limit"_s)) { if(_conf.hasValue("frame_limit")) {
std::string frame_limit = _conf.value("frame_limit"_s); std::string frame_limit = _conf.value("frame_limit");
if(frame_limit == "vsync"_s) { if(frame_limit == "vsync") {
_framelimit = Framelimit::Vsync; _framelimit = Framelimit::Vsync;
} }
else if(frame_limit == "half_vsync"_s) { else if(frame_limit == "half_vsync") {
_framelimit = Framelimit::HalfVsync; _framelimit = Framelimit::HalfVsync;
} }
else { else {
@ -497,7 +495,7 @@ void SaveTool::initialiseConfiguration() {
} }
} }
else { else {
_conf.setValue("frame_limit"_s, "vsync"_s); _conf.setValue("frame_limit", "vsync");
} }
_conf.save(); _conf.save();
@ -508,7 +506,7 @@ void SaveTool::initialiseGui() {
ImGuiIO& io = ImGui::GetIO(); ImGuiIO& io = ImGui::GetIO();
auto reg_font = _rs.getRaw("SourceSansPro-Regular.ttf"_s); auto reg_font = _rs.getRaw("SourceSansPro-Regular.ttf");
ImFontConfig font_config; ImFontConfig font_config;
font_config.FontDataOwnedByAtlas = false; font_config.FontDataOwnedByAtlas = false;
std::strcpy(font_config.Name, "Source Sans Pro"); std::strcpy(font_config.Name, "Source Sans Pro");
@ -528,7 +526,7 @@ void SaveTool::initialiseGui() {
static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 }; static const ImWchar brand_range[] = { ICON_MIN_FAB, ICON_MAX_FAB, 0 };
io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), brand_font.size(), 16.0f, &icon_config, brand_range); io.Fonts->AddFontFromMemoryTTF(const_cast<char*>(brand_font.data()), brand_font.size(), 16.0f, &icon_config, brand_range);
auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf"_s); auto mono_font = _rs.getRaw("SourceCodePro-Regular.ttf");
ImVector<ImWchar> range; ImVector<ImWchar> range;
ImFontGlyphRangesBuilder builder; ImFontGlyphRangesBuilder builder;
builder.AddRanges(io.Fonts->GetGlyphRangesDefault()); builder.AddRanges(io.Fonts->GetGlyphRangesDefault());
@ -568,14 +566,14 @@ auto SaveTool::findGameDataDirectory() -> bool {
Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree}; Containers::ScopeGuard guard{localappdata_path, CoTaskMemFree};
if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK) if(SHGetKnownFolderPath(FOLDERID_LocalAppData, KF_FLAG_NO_APPCONTAINER_REDIRECTION, nullptr, &localappdata_path) != S_OK)
{ {
_lastError = "SHGetKnownFolderPath() failed in SaveTool::findGameDataDirectory()"_s; _lastError = "SHGetKnownFolderPath() failed in SaveTool::findGameDataDirectory()";
return false; return false;
} }
_gameDataDir = Utility::Directory::join(Utility::Directory::fromNativeSeparators(Utility::Unicode::narrow(localappdata_path)), "MASS_Builder"); _gameDataDir = Utility::Directory::join(Utility::Directory::fromNativeSeparators(Utility::Unicode::narrow(localappdata_path)), "MASS_Builder");
if(!Utility::Directory::exists(_gameDataDir)) { if(!Utility::Directory::exists(_gameDataDir)) {
_lastError = _gameDataDir + " wasn't found. Make sure to play the game at least once."_s; _lastError = _gameDataDir + " wasn't found. Make sure to play the game at least once.";
return false; return false;
} }
@ -750,18 +748,18 @@ void SaveTool::drawGameState() {
} }
} }
void SaveTool::drawHelpMarker(Containers::StringView text, Float wrap_pos) { void SaveTool::drawHelpMarker(const char* text, Float wrap_pos) {
ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE); ImGui::TextUnformatted(ICON_FA_QUESTION_CIRCLE);
drawTooltip(text, wrap_pos); drawTooltip(text, wrap_pos);
} }
void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) { void SaveTool::drawTooltip(const char* text, Float wrap_pos) {
if(ImGui::IsItemHovered()){ if(ImGui::IsItemHovered()){
ImGui::BeginTooltip(); ImGui::BeginTooltip();
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {
ImGui::PushTextWrapPos(wrap_pos); ImGui::PushTextWrapPos(wrap_pos);
} }
ImGui::TextUnformatted(text.data()); ImGui::TextUnformatted(text);
if(wrap_pos > 0.0f) { if(wrap_pos > 0.0f) {
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
} }
@ -769,8 +767,8 @@ void SaveTool::drawTooltip(Containers::StringView text, Float wrap_pos) {
} }
} }
void SaveTool::openUri(Containers::StringView uri) { void SaveTool::openUri(const std::string& uri) {
ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri.data()).c_str(), nullptr, nullptr, SW_SHOWDEFAULT); ShellExecuteW(nullptr, nullptr, Utility::Unicode::widen(uri).c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
} }
void SaveTool::checkGameState() { void SaveTool::checkGameState() {

View file

@ -16,11 +16,9 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <thread> #include <thread>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Utility/Configuration.h> #include <Corrade/Utility/Configuration.h>
#include <Corrade/Utility/Resource.h> #include <Corrade/Utility/Resource.h>
@ -45,7 +43,6 @@
#endif #endif
using namespace Corrade; using namespace Corrade;
using namespace Containers::Literals;
using namespace Magnum; using namespace Magnum;
class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener { class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener {
@ -109,11 +106,11 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawGeneralInfo(); void drawGeneralInfo();
void drawResearchInventory(); void drawResearchInventory();
template<typename Getter, typename Setter> template<typename Getter, typename Setter>
void drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter); void drawMaterialRow(const char* name, Int tier, Getter getter, Setter setter);
void drawUnavailableMaterialRow(Containers::StringView name, Int tier); void drawUnavailableMaterialRow(const char* name, Int tier);
void drawMassManager(); void drawMassManager();
auto drawDeleteMassPopup(int mass_index) -> ImGuiID; auto drawDeleteMassPopup(int mass_index) -> ImGuiID;
auto drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID; auto drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID;
void drawMassViewer(); void drawMassViewer();
void drawFrameInfo(); void drawFrameInfo();
@ -124,14 +121,13 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawArmour(); void drawArmour();
void drawCustomArmourStyles(); void drawCustomArmourStyles();
void drawWeapons(); void drawWeapons();
void drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty, void drawWeaponCategory(const char* name, Containers::ArrayView<Weapon> weapons_view, bool& dirty, const char* payload_type, const char* payload_tooltip);
Containers::StringView payload_type, Containers::StringView payload_tooltip);
void drawWeaponEditor(Weapon& weapon); void drawWeaponEditor(Weapon& weapon);
void drawGlobalStyles(); void drawGlobalStyles();
void drawTuning(); void drawTuning();
void drawDecalEditor(Decal& decal); void drawDecalEditor(Decal& decal);
void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view); void drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<CustomStyle> style_view);
auto getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView; auto getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> const char*;
enum DCSResult { enum DCSResult {
DCS_Fail, DCS_Fail,
@ -144,8 +140,8 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
void drawGameState(); void drawGameState();
// Convenience wrappers over ImGui stuff // Convenience wrappers over ImGui stuff
void drawHelpMarker(Containers::StringView text, Float wrap_pos = 0.0f); void drawHelpMarker(const char* text, Float wrap_pos = 0.0f);
void drawTooltip(Containers::StringView text, Float wrap_pos = 0.0f); void drawTooltip(const char* text, Float wrap_pos = 0.0f);
template<typename Functor, typename... Args> template<typename Functor, typename... Args>
auto drawUnsafeWidget(Functor func, Args... args) -> bool { auto drawUnsafeWidget(Functor func, Args... args) -> bool {
@ -167,7 +163,7 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
// Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc... // Also, func should be a lambda if there are any default arguments, like ImGui::Button(), etc...
template<typename... Args> template<typename... Args>
void drawUnsafeText(Containers::StringView text, Args... args) { // Alternative to the above, for ImGui::Text*() variants. void drawUnsafeText(const char* text, Args... args) { // Alternative to the above, for ImGui::Text*() variants.
if(!_unsafeMode && _gameState != GameState::NotRunning) { if(!_unsafeMode && _gameState != GameState::NotRunning) {
ImGui::TextDisabled(text, std::forward<Args>(args)...); ImGui::TextDisabled(text, std::forward<Args>(args)...);
} }
@ -177,19 +173,19 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
} }
template<typename... Args> template<typename... Args>
void drawAlignedText(Containers::StringView text, Args... args) { void drawAlignedText(const char* text, Args... args) {
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
ImGui::Text(text.data(), std::forward<Args>(args)...); ImGui::Text(text, std::forward<Args>(args)...);
} }
void openUri(Containers::StringView uri); void openUri(const std::string& uri);
void checkGameState(); void checkGameState();
void checkForUpdates(); void checkForUpdates();
Utility::Configuration _conf{"MassBuilderSaveTool.ini"_s}; Utility::Configuration _conf{"MassBuilderSaveTool.ini"};
Utility::Resource _rs{"assets"_s}; Utility::Resource _rs{"assets"};
// GUI-related members // GUI-related members
ImGuiIntegration::Context _imgui{NoCreate}; ImGuiIntegration::Context _imgui{NoCreate};
@ -217,19 +213,19 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
UnsignedInt _initEventId; UnsignedInt _initEventId;
UnsignedInt _updateEventId; UnsignedInt _updateEventId;
Containers::String _lastError; std::string _lastError;
Containers::String _gameDataDir; std::string _gameDataDir;
Containers::String _configDir; std::string _configDir;
Containers::String _saveDir; std::string _saveDir;
Containers::String _screenshotsDir; std::string _screenshotsDir;
Containers::String _backupsDir; std::string _backupsDir;
Containers::String _stagingDir; std::string _stagingDir;
Containers::String _armouryDir; std::string _armouryDir;
Containers::String _armoursDir; std::string _armoursDir;
Containers::String _weaponsDir; std::string _weaponsDir;
Containers::String _stylesDir; std::string _stylesDir;
enum class GameState : UnsignedByte { enum class GameState : UnsignedByte {
Unknown, NotRunning, Running Unknown, NotRunning, Running
@ -264,9 +260,9 @@ class SaveTool: public Platform::Sdl2Application, public efsw::FileWatchListener
bool _unsafeMode{false}; bool _unsafeMode{false};
bool _updateAvailable{false}; bool _updateAvailable{false};
Containers::String _latestVersion; std::string _latestVersion;
Containers::String _releaseLink; std::string _releaseLink;
Containers::String _downloadLink; std::string _downloadLink;
bool _jointsDirty{false}; bool _jointsDirty{false};
bool _stylesDirty{false}; bool _stylesDirty{false};

View file

@ -43,7 +43,7 @@ void SaveTool::drawManager() {
} }
drawAlignedText("Current profile: %s (%s)", drawAlignedText("Current profile: %s (%s)",
_currentProfile->companyName(), _currentProfile->companyName().c_str(),
_currentProfile->type() == ProfileType::Demo ? "demo" : "full game"); _currentProfile->type() == ProfileType::Demo ? "demo" : "full game");
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button(ICON_FA_ARROW_LEFT " Back to profile manager")) { if(ImGui::Button(ICON_FA_ARROW_LEFT " Back to profile manager")) {
@ -220,7 +220,7 @@ void SaveTool::drawGeneralInfo() {
for(auto& c : name_buf) { for(auto& c : name_buf) {
c = '\0'; c = '\0';
} }
std::strncpy(name_buf.data(), _currentProfile->companyName().data(), 32); std::strncpy(name_buf.data(), _currentProfile->companyName().c_str(), 32);
ImGui::OpenPopup("name_edit"); ImGui::OpenPopup("name_edit");
} }
if(drawRenamePopup(name_buf)) { if(drawRenamePopup(name_buf)) {
@ -257,17 +257,17 @@ void SaveTool::drawGeneralInfo() {
ImGui::CloseCurrentPopup(); ImGui::CloseCurrentPopup();
} }
for(const auto& sp : story_progress) { for(const auto& sp : story_progress) {
if(ImGui::BeginMenu(sp.chapter.data())) { if(ImGui::BeginMenu(sp.chapter)) {
if(!sp.after) { if(!sp.after) {
if(ImGui::MenuItem(sp.point.data())) { if(ImGui::MenuItem(sp.point)) {
if(!_currentProfile->setStoryProgress(sp.id)) { if(!_currentProfile->setStoryProgress(sp.id)) {
_queue.addToast(Toast::Type::Error, _currentProfile->lastError()); _queue.addToast(Toast::Type::Error, _currentProfile->lastError());
} }
} }
} }
else { else {
if(ImGui::BeginMenu(sp.after.data())) { if(ImGui::BeginMenu(sp.after)) {
if(ImGui::MenuItem(sp.point.data())) { if(ImGui::MenuItem(sp.point)) {
if(!_currentProfile->setStoryProgress(sp.id)) { if(!_currentProfile->setStoryProgress(sp.id)) {
_queue.addToast(Toast::Type::Error, _currentProfile->lastError()); _queue.addToast(Toast::Type::Error, _currentProfile->lastError());
} }
@ -388,7 +388,7 @@ void SaveTool::drawResearchInventory() {
} }
template<typename Getter, typename Setter> template<typename Getter, typename Setter>
void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter getter, Setter setter) { void SaveTool::drawMaterialRow(const char* name, Int tier, Getter getter, Setter setter) {
static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments."); static_assert(std::is_same<decltype(getter()), Int>::value, "getter doesn't return an Int, and/or doesn't take zero arguments.");
static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument."); static_assert(std::is_same<decltype(setter(0)), bool>::value, "setter doesn't return a bool, and/or doesn't take a single Int as an argument.");
@ -396,13 +396,13 @@ void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter get
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name);
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
if(getter() != -1) { if(getter() != -1) {
ImGui::Text("%i", getter()); ImGui::Text("%i", getter());
if(_cheatMode) { if(_cheatMode) {
ImGui::TableSetColumnIndex(3); ImGui::TableSetColumnIndex(3);
ImGui::PushID(name.data()); ImGui::PushID(name);
static Int var = 0; static Int var = 0;
if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) { if(drawUnsafeWidget(ImGui::SmallButton, ICON_FA_EDIT)) {
(var) = getter(); (var) = getter();
@ -421,12 +421,12 @@ void SaveTool::drawMaterialRow(Containers::StringView name, Int tier, Getter get
} }
} }
void SaveTool::drawUnavailableMaterialRow(Containers::StringView name, Int tier) { void SaveTool::drawUnavailableMaterialRow(const char* name, Int tier) {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("T%i", tier); ImGui::Text("T%i", tier);
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name);
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION); ImGui::TextDisabled("Unavailable as of game version " SUPPORTED_GAME_VERSION);
} }
@ -472,7 +472,7 @@ void SaveTool::drawMassManager() {
drag_drop_index = i; drag_drop_index = i;
ImGui::SetDragDropPayload("Mass", &drag_drop_index, sizeof(int)); ImGui::SetDragDropPayload("Mass", &drag_drop_index, sizeof(int));
ImGui::Text("%s - Hangar %.2d", _massManager->hangar(i).name().data(), i + 1); ImGui::Text("%s - Hangar %.2d", (*_massManager->hangar(i).name()).c_str(), i + 1);
ImGui::EndDragDropSource(); ImGui::EndDragDropSource();
} }
@ -518,7 +518,7 @@ void SaveTool::drawMassManager() {
ImGui::TextDisabled("<invalid>"); ImGui::TextDisabled("<invalid>");
break; break;
case Mass::State::Valid: case Mass::State::Valid:
ImGui::TextUnformatted(_massManager->hangar(i).name().data()); ImGui::TextUnformatted((*_massManager->hangar(i).name()).c_str());
break; break;
} }
@ -557,7 +557,7 @@ void SaveTool::drawMassManager() {
drawDeleteMassPopup(mass_to_delete); drawDeleteMassPopup(mass_to_delete);
static ImGuiID staged_mass_deletion_popup_ID = drawDeleteStagedMassPopup(""); static ImGuiID staged_mass_deletion_popup_ID = drawDeleteStagedMassPopup("");
static Containers::StringView staged_mass_to_delete; static Containers::Reference<const std::string> staged_mass_to_delete{empty_str};
if(ImGui::BeginTable("##StagingArea", 2, if(ImGui::BeginTable("##StagingArea", 2,
ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg)) ImGuiTableFlags_ScrollY|ImGuiTableFlags_BordersOuter|ImGuiTableFlags_RowBg))
@ -587,15 +587,15 @@ void SaveTool::drawMassManager() {
if(ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) { if(ImGui::BeginDragDropSource(ImGuiDragDropFlags_SourceNoHoldToOpenOthers)) {
ImGui::SetDragDropPayload("StagedMass", &(pair.first), sizeof(std::string)); ImGui::SetDragDropPayload("StagedMass", &(pair.first), sizeof(std::string));
ImGui::Text("%s - Staged", pair.second.data()); ImGui::Text("%s - Staged", pair.second.c_str());
ImGui::EndDragDropSource(); ImGui::EndDragDropSource();
} }
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
ImGui::PushID(pair.first.data()); ImGui::PushID(pair.first.c_str());
if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) { if(ImGui::SmallButton(ICON_FA_TRASH_ALT)) {
staged_mass_to_delete = pair.first; staged_mass_to_delete = Containers::Reference<const std::string>{pair.first};
ImGui::OpenPopup(staged_mass_deletion_popup_ID); ImGui::OpenPopup(staged_mass_deletion_popup_ID);
} }
ImGui::PopID(); ImGui::PopID();
@ -622,7 +622,7 @@ void SaveTool::drawMassManager() {
ImGui::EndDragDropTarget(); ImGui::EndDragDropTarget();
} }
drawDeleteStagedMassPopup(staged_mass_to_delete); drawDeleteStagedMassPopup(staged_mass_to_delete.get());
} }
auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID { auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
@ -651,7 +651,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
} }
else { else {
ImGui::Text("Are you sure you want to delete the M.A.S.S. named %s in hangar %.2i ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the M.A.S.S. named %s in hangar %.2i ? This operation is irreversible.",
_massManager->hangar(mass_index).name().data(), mass_index + 1); (*_massManager->hangar(mass_index).name()).c_str(), mass_index + 1);
} }
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
@ -681,7 +681,7 @@ auto SaveTool::drawDeleteMassPopup(int mass_index) -> ImGuiID {
return 0; return 0;
} }
auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImGuiID { auto SaveTool::drawDeleteStagedMassPopup(const std::string& filename) -> ImGuiID {
if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr, if(!ImGui::BeginPopupModal("Confirmation##DeleteStagedMassConfirmation", nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove)) ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoCollapse|ImGuiWindowFlags_NoMove))
{ {
@ -690,7 +690,7 @@ auto SaveTool::drawDeleteStagedMassPopup(Containers::StringView filename) -> ImG
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
ImGui::Text("Are you sure you want to delete the staged M.A.S.S. named %s ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the staged M.A.S.S. named %s ? This operation is irreversible.",
_massManager->stagedMasses().at(filename).data()); _massManager->stagedMasses().at(filename).c_str());
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();
if(ImGui::BeginTable("##DeleteStagedMassLayout", 2)) { if(ImGui::BeginTable("##DeleteStagedMassLayout", 2)) {

View file

@ -61,8 +61,8 @@ void SaveTool::drawMassViewer() {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::Text("M.A.S.S.: %s", _currentMass->name().data()); ImGui::Text("M.A.S.S.: %s", (*_currentMass->name()).c_str());
drawTooltip(_currentMass->filename()); drawTooltip(_currentMass->filename().c_str());
ImGui::TableSetColumnIndex(2); ImGui::TableSetColumnIndex(2);
if(_currentMass->dirty()) { if(_currentMass->dirty()) {
@ -298,14 +298,14 @@ auto SaveTool::drawCustomStyle(CustomStyle& style) -> DCSResult {
} }
if(ImGui::BeginMenuBar()) { if(ImGui::BeginMenuBar()) {
ImGui::TextUnformatted(style.name.data()); ImGui::TextUnformatted(style.name.c_str());
static Containers::StaticArray<33, char> name_buf{ValueInit}; static Containers::StaticArray<33, char> name_buf{ValueInit};
if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) { if(ImGui::SmallButton(ICON_FA_EDIT " Rename")) {
for(auto& c : name_buf) { for(auto& c : name_buf) {
c = '\0'; c = '\0';
} }
std::strncpy(name_buf.data(), style.name.data(), 32); std::strncpy(name_buf.data(), style.name.c_str(), 32);
ImGui::OpenPopup("name_edit"); ImGui::OpenPopup("name_edit");
} }
if(drawRenamePopup(name_buf)) { if(drawRenamePopup(name_buf)) {
@ -516,9 +516,9 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::BeginGroup(); ImGui::BeginGroup();
ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth()); ImGui::PushMultiItemsWidths(2, ImGui::CalcItemWidth());
if(ImGui::BeginCombo("##Style1", getStyleName(accessory.styles[0], style_view).data())) { if(ImGui::BeginCombo("##Style1", getStyleName(accessory.styles[0], style_view))) {
for(const auto& style : style_names) { for(const auto& style : style_names) {
if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[0] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, style_view), accessory.styles[0] == style.first)) {
accessory.styles[0] = style.first; accessory.styles[0] = style.first;
} }
} }
@ -527,9 +527,9 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
} }
ImGui::PopItemWidth(); ImGui::PopItemWidth();
ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x); ImGui::SameLine(0.0f, ImGui::GetStyle().ItemInnerSpacing.x);
if(ImGui::BeginCombo("##Style2", getStyleName(accessory.styles[1], style_view).data())) { if(ImGui::BeginCombo("##Style2", getStyleName(accessory.styles[1], style_view))) {
for(const auto& style : style_names) { for(const auto& style : style_names) {
if(ImGui::Selectable(getStyleName(style.first, style_view).data(), accessory.styles[1] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, style_view), accessory.styles[1] == style.first)) {
accessory.styles[1] = style.first; accessory.styles[1] = style.first;
} }
} }
@ -594,12 +594,12 @@ void SaveTool::drawAccessoryEditor(Accessory& accessory, Containers::ArrayView<C
ImGui::EndGroup(); ImGui::EndGroup();
} }
auto SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> Containers::StringView { auto SaveTool::getStyleName(Int id, Containers::ArrayView<CustomStyle> view) -> const char* {
if(id >= 0 && id <= 15) { if(id >= 0 && id <= 15) {
return view[id].name; return view[id].name.c_str();
} }
else if(id >= 50 && id <= 65) { else if(id >= 50 && id <= 65) {
return _currentMass->globalStyles()[id - 50].name; return _currentMass->globalStyles()[id - 50].name.c_str();
} }
else { else {
return style_names.at(id); return style_names.at(id);

View file

@ -35,10 +35,10 @@ void SaveTool::drawArmour() {
return; return;
} }
static Containers::StringView slot_labels[] = { static const char* slot_labels[] = {
#define c(enumerator, strenum, name) name, #define c(enumerator, strenum, name) name,
#include "../Maps/ArmourSlots.hpp" #include "../Maps/ArmourSlots.hpp"
#undef c #undef c
}; };
for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) { for(UnsignedInt i = 0; i < _currentMass->armourParts().size(); i++) {
@ -51,10 +51,10 @@ void SaveTool::drawArmour() {
std::memset(header, '\0', 129); std::memset(header, '\0', 129);
if(armour_sets.find(part.id) != armour_sets.cend()) { if(armour_sets.find(part.id) != armour_sets.cend()) {
std::snprintf(header, 128, "%s: %s###%u", slot_labels[UnsignedInt(part.slot)].data(), armour_sets.at(part.id).name.data(), UnsignedInt(part.slot)); std::snprintf(header, 128, "%s: %s###%u", slot_labels[UnsignedInt(part.slot)], armour_sets.at(part.id).name, UnsignedInt(part.slot));
} }
else { else {
std::snprintf(header, 128, "%s: %i###%u", slot_labels[UnsignedInt(part.slot)].data(), part.id, UnsignedInt(part.slot)); std::snprintf(header, 128, "%s: %i###%u", slot_labels[UnsignedInt(part.slot)], part.id, UnsignedInt(part.slot));
} }
if(ImGui::CollapsingHeader(header)) { if(ImGui::CollapsingHeader(header)) {
@ -62,9 +62,9 @@ void SaveTool::drawArmour() {
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() * 0.491f); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() * 0.491f);
if(ImGui::BeginListBox("##ChangePart")) { if(ImGui::BeginListBox("##ChangePart")) {
if(std::strncmp("Neck", slot_labels[UnsignedInt(part.slot)].data(), 4) != 0) { if(std::strncmp("Neck", slot_labels[UnsignedInt(part.slot)], 4) != 0) {
for(auto& set : armour_sets) { for(auto& set : armour_sets) {
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) { if(ImGui::Selectable(set.second.name, set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first; part.id = set.first;
} }
} }
@ -75,7 +75,7 @@ void SaveTool::drawArmour() {
continue; continue;
} }
if(ImGui::Selectable(set.second.name.data(), set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) { if(ImGui::Selectable(set.second.name, set.first == part.id, ImGuiSelectableFlags_SpanAvailWidth)) {
part.id = set.first; part.id = set.first;
} }
} }
@ -103,9 +103,9 @@ void SaveTool::drawArmour() {
ImGui::PushID(j); ImGui::PushID(j);
ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() - 2.0f); ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() - 2.0f);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[j], _currentMass->armourCustomStyles()).data())) { if(ImGui::BeginCombo("##Style", getStyleName(part.styles[j], _currentMass->armourCustomStyles()))) {
for(const auto& style : style_names) { for(const auto& style : style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()).data(), part.styles[j] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, _currentMass->armourCustomStyles()), part.styles[j] == style.first)) {
part.styles[j] = style.first; part.styles[j] = style.first;
} }
} }

View file

@ -205,9 +205,9 @@ void SaveTool::drawFrameStyles() {
ImGui::PushID(i); ImGui::PushID(i);
if(ImGui::BeginCombo("##Style", getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()).data())) { if(ImGui::BeginCombo("##Style", getStyleName(_currentMass->frameStyles()[i], _currentMass->frameCustomStyles()))) {
for(const auto& style : style_names) { for(const auto& style : style_names) {
if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()).data(), _currentMass->frameStyles()[i] == style.first)) { if(ImGui::Selectable(getStyleName(style.first, _currentMass->frameCustomStyles()), _currentMass->frameStyles()[i] == style.first)) {
_currentMass->frameStyles()[i] = style.first; _currentMass->frameStyles()[i] = style.first;
_stylesDirty = true; _stylesDirty = true;
} }

View file

@ -234,14 +234,14 @@ void SaveTool::drawWeapons() {
ImGui::EndGroup(); ImGui::EndGroup();
} }
void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::ArrayView<Weapon> weapons_view, bool& dirty, void SaveTool::drawWeaponCategory(const char* name, Containers::ArrayView<Weapon> weapons_view, bool& dirty,
Containers::StringView payload_type, Containers::StringView payload_tooltip) const char* payload_type, const char* payload_tooltip)
{ {
ImGui::TableNextRow(ImGuiTableRowFlags_Headers); ImGui::TableNextRow(ImGuiTableRowFlags_Headers);
ImGui::TableNextColumn(); ImGui::TableNextColumn();
ImGui::TextUnformatted(name.data()); ImGui::TextUnformatted(name);
ImGui::PushID(payload_type.data()); ImGui::PushID(payload_type);
for(UnsignedInt i = 0; i < weapons_view.size(); i++) { for(UnsignedInt i = 0; i < weapons_view.size(); i++) {
auto& weapon = weapons_view[i]; auto& weapon = weapons_view[i];
@ -251,21 +251,21 @@ void SaveTool::drawWeaponCategory(Containers::StringView name, Containers::Array
ImGui::PushID(i); ImGui::PushID(i);
if(ImGui::Selectable(weapon.name.data(), _currentWeapon == &weapon)) { if(ImGui::Selectable(weapon.name.c_str(), _currentWeapon == &weapon)) {
_currentWeapon = &weapon; _currentWeapon = &weapon;
} }
if(ImGui::BeginDragDropSource()) { if(ImGui::BeginDragDropSource()) {
ImGui::SetDragDropPayload(payload_type.data(), &i, sizeof(UnsignedInt)); ImGui::SetDragDropPayload(payload_type, &i, sizeof(UnsignedInt));
if(ImGui::GetIO().KeyCtrl) { if(ImGui::GetIO().KeyCtrl) {
ImGui::Text("%s %i - %s (copy)", payload_tooltip.data(), i + 1, weapon.name.data()); ImGui::Text("%s %i - %s (copy)", payload_tooltip, i + 1, weapon.name.c_str());
} }
else { else {
ImGui::Text("%s %i - %s", payload_tooltip.data(), i + 1, weapon.name.data()); ImGui::Text("%s %i - %s", payload_tooltip, i + 1, weapon.name.c_str());
} }
ImGui::EndDragDropSource(); ImGui::EndDragDropSource();
} }
if(ImGui::BeginDragDropTarget()) { if(ImGui::BeginDragDropTarget()) {
if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(payload_type.data())) { if(const ImGuiPayload* payload = ImGui::AcceptDragDropPayload(payload_type)) {
int index = *static_cast<int*>(payload->Data); int index = *static_cast<int*>(payload->Data);
if(!ImGui::GetIO().KeyCtrl) { if(!ImGui::GetIO().KeyCtrl) {
@ -302,15 +302,13 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
return; return;
} }
static Containers::StringView labels[] { static const char* labels[] {
#define c(enumerator, strenum, name) name, #define c(enumerator, strenum, name) name,
#include "../Maps/WeaponTypes.hpp" #include "../Maps/WeaponTypes.hpp"
#undef c #undef c
}; };
//test drawAlignedText("%s: %s", labels[UnsignedInt(weapon.type)], weapon.name.c_str());
drawAlignedText("%s: %s", labels[UnsignedInt(weapon.type)], weapon.name.data());
ImGui::SameLine(); ImGui::SameLine();
@ -319,7 +317,7 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
for(auto& c : name_buf) { for(auto& c : name_buf) {
c = '\0'; c = '\0';
} }
std::strncpy(name_buf.data(), weapon.name.data(), 32); std::strncpy(name_buf.data(), weapon.name.c_str(), 32);
ImGui::OpenPopup("name_edit"); ImGui::OpenPopup("name_edit");
} }
if(drawRenamePopup(name_buf)) { if(drawRenamePopup(name_buf)) {
@ -427,9 +425,9 @@ void SaveTool::drawWeaponEditor(Weapon& weapon) {
ImGui::PushID(i); ImGui::PushID(i);
if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles).data())) { if(ImGui::BeginCombo("##Style", getStyleName(part.styles[i], weapon.customStyles))) {
for(const auto& style: style_names) { for(const auto& style: style_names) {
if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles).data(), if(ImGui::Selectable(getStyleName(style.first, weapon.customStyles),
part.styles[i] == style.first)) { part.styles[i] == style.first)) {
part.styles[i] = style.first; part.styles[i] = style.first;
} }

View file

@ -50,7 +50,7 @@ void SaveTool::drawProfileManager() {
ImGui::TableSetColumnIndex(1); ImGui::TableSetColumnIndex(1);
if(ImGui::SmallButton("Refresh")) { if(ImGui::SmallButton("Refresh")) {
if(!_profileManager->refreshProfiles()) { if(!_profileManager->refreshProfiles()) {
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error in ProfileManager", _profileManager->lastError().data(), window()); SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Error in ProfileManager", _profileManager->lastError().c_str(), window());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
} }
@ -81,7 +81,7 @@ void SaveTool::drawProfileManager() {
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::PushID(i); ImGui::PushID(i);
if(ImGui::Selectable(_profileManager->profiles()[i].companyName().data(), false, if(ImGui::Selectable(_profileManager->profiles()[i].companyName().c_str(), false,
ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap)) ImGuiSelectableFlags_SpanAllColumns|ImGuiSelectableFlags_AllowItemOverlap))
{ {
_currentProfile = _profileManager->getProfile(i); _currentProfile = _profileManager->getProfile(i);
@ -132,7 +132,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
{ {
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.", ImGui::Text("Are you sure you want to restore the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? Any existing data will be overwritten.",
_profileManager->backups()[backup_index].company.data(), _profileManager->backups()[backup_index].company.c_str(),
_profileManager->backups()[backup_index].timestamp.year, _profileManager->backups()[backup_index].timestamp.year,
_profileManager->backups()[backup_index].timestamp.month, _profileManager->backups()[backup_index].timestamp.month,
_profileManager->backups()[backup_index].timestamp.day, _profileManager->backups()[backup_index].timestamp.day,
@ -171,7 +171,7 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
{ {
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the %s backup from %.4i-%.2i-%.2i %.2i:%.2i:%.2i ? This operation is irreversible.",
_profileManager->backups()[backup_index].company.data(), _profileManager->backups()[backup_index].company.c_str(),
_profileManager->backups()[backup_index].timestamp.year, _profileManager->backups()[backup_index].timestamp.year,
_profileManager->backups()[backup_index].timestamp.month, _profileManager->backups()[backup_index].timestamp.month,
_profileManager->backups()[backup_index].timestamp.day, _profileManager->backups()[backup_index].timestamp.day,
@ -249,11 +249,11 @@ auto SaveTool::drawBackupListPopup() -> ImGuiID {
ImGui::TableNextRow(); ImGui::TableNextRow();
ImGui::TableSetColumnIndex(0); ImGui::TableSetColumnIndex(0);
ImGui::TextUnformatted(_profileManager->backups()[i].company.data()); ImGui::TextUnformatted(_profileManager->backups()[i].company.c_str());
if(ImGui::IsItemHovered()) { if(ImGui::IsItemHovered()) {
ImGui::BeginTooltip(); ImGui::BeginTooltip();
for(const auto& file : _profileManager->backups()[i].includedFiles) { for(const auto& file : _profileManager->backups()[i].includedFiles) {
ImGui::TextUnformatted(file.data()); ImGui::TextUnformatted(file.c_str());
} }
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
@ -361,7 +361,7 @@ auto SaveTool::drawDeleteProfilePopup(std::size_t profile_index) -> ImGuiID {
ImGui::PushTextWrapPos(windowSize().x() * 0.40f); ImGui::PushTextWrapPos(windowSize().x() * 0.40f);
ImGui::Text("Are you sure you want to delete the %s %s profile ? This operation is irreversible.", ImGui::Text("Are you sure you want to delete the %s %s profile ? This operation is irreversible.",
_profileManager->profiles()[profile_index].companyName().data(), _profileManager->profiles()[profile_index].companyName().c_str(),
_profileManager->profiles()[profile_index].type() == ProfileType::Demo ? "demo" : "full game"); _profileManager->profiles()[profile_index].type() == ProfileType::Demo ? "demo" : "full game");
ImGui::PopTextWrapPos(); ImGui::PopTextWrapPos();

View file

@ -17,7 +17,6 @@
#include "SaveTool.h" #include "SaveTool.h"
#include <Corrade/version.h> #include <Corrade/version.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/version.h> #include <Magnum/version.h>
#include <Magnum/versionIntegration.h> #include <Magnum/versionIntegration.h>
@ -58,7 +57,7 @@ void SaveTool::drawAbout() {
ImGui::TextWrapped("This application, made for the M.A.S.S. Builder community by Guillaume Jacquemin (aka William JCM), " ImGui::TextWrapped("This application, made for the M.A.S.S. Builder community by Guillaume Jacquemin (aka William JCM), "
"is a rewrite of the wxWidgets-powered M.A.S.S. Builder Save Tool (formerly known as wxMASSManager)."); "is a rewrite of the wxWidgets-powered M.A.S.S. Builder Save Tool (formerly known as wxMASSManager).");
auto repo = "https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool"; const char* repo = "https://williamjcm.ovh/git/williamjcm/MassBuilderSaveTool";
drawAlignedText(ICON_FA_GIT_ALT " %s", repo); drawAlignedText(ICON_FA_GIT_ALT " %s", repo);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -75,9 +74,9 @@ void SaveTool::drawAbout() {
ImGui::TextWrapped("This application is made available under the terms of the GNU General Public License, version 3, the full text of which is available below:"); ImGui::TextWrapped("This application is made available under the terms of the GNU General Public License, version 3, the full text of which is available below:");
if(ImGui::BeginChild("##GPL", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##GPL", {0.0f, windowSize().y() * 0.3f}, true)) {
static auto licence = _rs.getRaw("COPYING"); static const auto licence = _rs.get("COPYING");
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(licence); ImGui::TextUnformatted(licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -90,7 +89,7 @@ void SaveTool::drawAbout() {
if(ImGui::TreeNodeEx("Corrade", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("Corrade", ImGuiTreeNodeFlags_SpanAvailWidth)) {
ImGui::Text("Version used: %s", CORRADE_VERSION_STRING); ImGui::Text("Version used: %s", CORRADE_VERSION_STRING);
auto corrade_website = "https://magnum.graphics/corrade"; const char* corrade_website = "https://magnum.graphics/corrade";
drawAlignedText(ICON_FA_GLOBE " %s", corrade_website); drawAlignedText(ICON_FA_GLOBE " %s", corrade_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -103,10 +102,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto corrade_licence = _rs.getRaw("COPYING.Corrade"); static const auto corrade_licence = _rs.get("COPYING.Corrade");
if(ImGui::BeginChild("##CorradeLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##CorradeLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(corrade_licence); ImGui::TextUnformatted(corrade_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -118,7 +117,7 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Versions used:"); ImGui::TextUnformatted("Versions used:");
ImGui::BulletText("Magnum: %s", MAGNUM_VERSION_STRING); ImGui::BulletText("Magnum: %s", MAGNUM_VERSION_STRING);
ImGui::BulletText("Integration: %s", MAGNUMINTEGRATION_VERSION_STRING); ImGui::BulletText("Integration: %s", MAGNUMINTEGRATION_VERSION_STRING);
auto magnum_website = "https://magnum.graphics"; const char* magnum_website = "https://magnum.graphics";
drawAlignedText(ICON_FA_GLOBE " %s", magnum_website); drawAlignedText(ICON_FA_GLOBE " %s", magnum_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -131,10 +130,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto magnum_licence = _rs.getRaw("COPYING.Magnum"); static const auto magnum_licence = _rs.get("COPYING.Magnum");
if(ImGui::BeginChild("##MagnumLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##MagnumLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(magnum_licence); ImGui::TextUnformatted(magnum_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -144,7 +143,7 @@ void SaveTool::drawAbout() {
if(ImGui::TreeNodeEx("Dear ImGui", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("Dear ImGui", ImGuiTreeNodeFlags_SpanAvailWidth)) {
ImGui::Text("Version used: %s", IMGUI_VERSION); ImGui::Text("Version used: %s", IMGUI_VERSION);
auto imgui_repo = "https://github.com/ocornut/imgui"; const char* imgui_repo = "https://github.com/ocornut/imgui";
drawAlignedText(ICON_FA_GITHUB " %s", imgui_repo); drawAlignedText(ICON_FA_GITHUB " %s", imgui_repo);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -157,10 +156,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto imgui_licence = _rs.getRaw("LICENSE.ImGui"); static const auto imgui_licence = _rs.get("LICENSE.ImGui");
if(ImGui::BeginChild("##ImGuiLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##ImGuiLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(imgui_licence); ImGui::TextUnformatted(imgui_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -170,7 +169,7 @@ void SaveTool::drawAbout() {
if(ImGui::TreeNodeEx("Simple DirectMedia Layer (SDL) 2", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("Simple DirectMedia Layer (SDL) 2", ImGuiTreeNodeFlags_SpanAvailWidth)) {
ImGui::Text("Version used: %i.%i.%i", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL); ImGui::Text("Version used: %i.%i.%i", SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL);
auto sdl_website = "https://www.libsdl.org/"; const char* sdl_website = "https://www.libsdl.org/";
drawAlignedText(ICON_FA_GLOBE " %s", sdl_website); drawAlignedText(ICON_FA_GLOBE " %s", sdl_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -183,10 +182,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: zlib"); ImGui::TextUnformatted("Licence: zlib");
static auto sdl_licence = _rs.getRaw("LICENSE.SDL"); static const auto sdl_licence = _rs.get("LICENSE.SDL");
if(ImGui::BeginChild("##SDLLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##SDLLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(sdl_licence); ImGui::TextUnformatted(sdl_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -196,7 +195,7 @@ void SaveTool::drawAbout() {
if(ImGui::TreeNodeEx("libzip", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("libzip", ImGuiTreeNodeFlags_SpanAvailWidth)) {
ImGui::Text("Version used: %s", LIBZIP_VERSION); ImGui::Text("Version used: %s", LIBZIP_VERSION);
auto libzip_website = "https://libzip.org/"; const char* libzip_website = "https://libzip.org/";
drawAlignedText(ICON_FA_GLOBE " %s", libzip_website); drawAlignedText(ICON_FA_GLOBE " %s", libzip_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -209,10 +208,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: 3-clause BSD"); ImGui::TextUnformatted("Licence: 3-clause BSD");
static auto libzip_licence = _rs.getRaw("LICENSE.libzip"); static const auto libzip_licence = _rs.get("LICENSE.libzip");
if(ImGui::BeginChild("##libzipLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##libzipLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(libzip_licence); ImGui::TextUnformatted(libzip_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -221,11 +220,11 @@ void SaveTool::drawAbout() {
} }
if(ImGui::TreeNodeEx("Entropia File System Watcher (efsw)", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("Entropia File System Watcher (efsw)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
auto efsw_repo = "https://github.com/SpartanJ/efsw"; const char* efsw_repo = "https://github.com/SpartanJ/efsw";
drawAlignedText(ICON_FA_GITHUB " %s", efsw_repo); drawAlignedText(ICON_FA_GITHUB " %s", efsw_repo);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
ImGui::SetClipboardText(efsw_repo.data()); ImGui::SetClipboardText(efsw_repo);
} }
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Open in browser")) { if(ImGui::Button("Open in browser")) {
@ -234,10 +233,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto efsw_licence = _rs.getRaw("LICENSE.efsw"); static const auto efsw_licence = _rs.get("LICENSE.efsw");
if(ImGui::BeginChild("##efswLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##efswLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(efsw_licence); ImGui::TextUnformatted(efsw_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -246,7 +245,7 @@ void SaveTool::drawAbout() {
} }
if(ImGui::TreeNodeEx("C++ Requests (cpr)", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("C++ Requests (cpr)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
auto cpr_website = "https://whoshuu.github.io/cpr/"; const char* cpr_website = "https://whoshuu.github.io/cpr/";
drawAlignedText(ICON_FA_GLOBE " %s", cpr_website); drawAlignedText(ICON_FA_GLOBE " %s", cpr_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -259,10 +258,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto cpr_licence = _rs.getRaw("LICENSE.cpr"); static const auto cpr_licence = _rs.get("LICENSE.cpr");
if(ImGui::BeginChild("##cprLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##cprLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(cpr_licence); ImGui::TextUnformatted(cpr_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -271,7 +270,7 @@ void SaveTool::drawAbout() {
} }
if(ImGui::TreeNodeEx("JSON for Modern C++ (aka json.hpp)", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("JSON for Modern C++ (aka json.hpp)", ImGuiTreeNodeFlags_SpanAvailWidth)) {
auto json_website = "https://json.nlohmann.me/"; const char* json_website = "https://json.nlohmann.me/";
drawAlignedText(ICON_FA_GLOBE " %s", json_website); drawAlignedText(ICON_FA_GLOBE " %s", json_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -284,10 +283,10 @@ void SaveTool::drawAbout() {
ImGui::TextUnformatted("Licence: MIT"); ImGui::TextUnformatted("Licence: MIT");
static auto json_licence = _rs.getRaw("LICENSE.json"); static const auto json_licence = _rs.get("LICENSE.json");
if(ImGui::BeginChild("##jsonLicence", {0.0f, windowSize().y() * 0.3f}, true)) { if(ImGui::BeginChild("##jsonLicence", {0.0f, windowSize().y() * 0.3f}, true)) {
ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]); ImGui::PushFont(ImGui::GetIO().Fonts->Fonts[1]);
ImGui::TextUnformatted(json_licence); ImGui::TextUnformatted(json_licence.c_str());
ImGui::PopFont(); ImGui::PopFont();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -297,7 +296,7 @@ void SaveTool::drawAbout() {
if(ImGui::TreeNodeEx("Font Awesome", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("Font Awesome", ImGuiTreeNodeFlags_SpanAvailWidth)) {
ImGui::TextUnformatted("Version used: 5.15.3"); ImGui::TextUnformatted("Version used: 5.15.3");
auto fa_website = "https://fontawesome.com/"; const char* fa_website = "https://fontawesome.com/";
drawAlignedText(ICON_FA_GLOBE " %s", fa_website); drawAlignedText(ICON_FA_GLOBE " %s", fa_website);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {
@ -314,7 +313,7 @@ void SaveTool::drawAbout() {
} }
if(ImGui::TreeNodeEx("IconFontCppHeaders", ImGuiTreeNodeFlags_SpanAvailWidth)) { if(ImGui::TreeNodeEx("IconFontCppHeaders", ImGuiTreeNodeFlags_SpanAvailWidth)) {
auto icon_repo = "https://github.com/juliettef/IconFontCppHeaders"; const char* icon_repo = "https://github.com/juliettef/IconFontCppHeaders";
drawAlignedText(ICON_FA_GITHUB " %s", icon_repo); drawAlignedText(ICON_FA_GITHUB " %s", icon_repo);
ImGui::SameLine(); ImGui::SameLine();
if(ImGui::Button("Copy to clipboard")) { if(ImGui::Button("Copy to clipboard")) {

View file

@ -117,7 +117,7 @@ void SaveTool::drawMainMenu() {
} }
if(_updateAvailable) { if(_updateAvailable) {
drawAlignedText("Version %s is available.", _latestVersion.data()); drawAlignedText("Version %s is available.", _latestVersion.c_str());
if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) { if(ImGui::Button(ICON_FA_FILE_SIGNATURE " Release notes")) {
openUri(_releaseLink); openUri(_releaseLink);
} }

View file

@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Utility/Format.h> #include <Corrade/Utility/FormatStl.h>
#include <Magnum/Math/Functions.h> #include <Magnum/Math/Functions.h>
@ -24,7 +24,7 @@
#include "ToastQueue.h" #include "ToastQueue.h"
using namespace Containers::Literals; using namespace Corrade;
constexpr UnsignedInt success_colour = 0xff67d23bu; constexpr UnsignedInt success_colour = 0xff67d23bu;
constexpr UnsignedInt info_colour = 0xffcc832fu; constexpr UnsignedInt info_colour = 0xffcc832fu;
@ -36,7 +36,7 @@ constexpr Float base_opacity = 1.0f;
constexpr Vector2 padding{20.0f, 20.0f}; constexpr Vector2 padding{20.0f, 20.0f};
constexpr Float toast_spacing = 10.0f; constexpr Float toast_spacing = 10.0f;
Toast::Toast(Type type, Containers::StringView message, std::chrono::milliseconds timeout): Toast::Toast(Type type, const std::string& message, std::chrono::milliseconds timeout):
_type{type}, _message{message}, _timeout{timeout}, _creationTime{std::chrono::steady_clock::now()} _type{type}, _message{message}, _timeout{timeout}, _creationTime{std::chrono::steady_clock::now()}
{ {
_phaseTrack = Animation::Track<UnsignedInt, Phase>{{ _phaseTrack = Animation::Track<UnsignedInt, Phase>{{
@ -51,7 +51,7 @@ auto Toast::type() -> Type {
return _type; return _type;
} }
auto Toast::message() -> Containers::StringView { auto Toast::message() -> const std::string& {
return _message; return _message;
} }
@ -89,7 +89,7 @@ void ToastQueue::addToast(Toast&& toast) {
_toasts.push_back(std::move(toast)); _toasts.push_back(std::move(toast));
} }
void ToastQueue::addToast(Toast::Type type, Containers::StringView message, std::chrono::milliseconds timeout) { void ToastQueue::addToast(Toast::Type type, const std::string& message, std::chrono::milliseconds timeout) {
_toasts.emplace_back(type, message, timeout); _toasts.emplace_back(type, message, timeout);
} }
@ -104,14 +104,14 @@ void ToastQueue::draw(Vector2i viewport_size) {
continue; continue;
} }
Containers::String win_id = Utility::format("##Toast{}", i); std::string win_id = Utility::formatString("##Toast{}", i);
Float opacity = base_opacity * current->opacity(); Float opacity = base_opacity * current->opacity();
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity); ImGui::PushStyleVar(ImGuiStyleVar_Alpha, opacity);
ImGui::SetNextWindowPos({viewport_size.x() - padding.x(), viewport_size.y() - padding.y() - height}, ImGuiCond_Always, {1.0f, 1.0f}); ImGui::SetNextWindowPos({viewport_size.x() - padding.x(), viewport_size.y() - padding.y() - height}, ImGuiCond_Always, {1.0f, 1.0f});
if(ImGui::Begin(win_id.data(), nullptr, if(ImGui::Begin(win_id.c_str(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration| ImGuiWindowFlags_AlwaysAutoResize|ImGuiWindowFlags_NoDecoration|
ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing)) ImGuiWindowFlags_NoInputs|ImGuiWindowFlags_NoNav|ImGuiWindowFlags_NoFocusOnAppearing))
{ {
@ -142,11 +142,11 @@ void ToastQueue::draw(Vector2i viewport_size) {
ImGui::SameLine(); ImGui::SameLine();
} }
if(current->message().size() > 127) { if(current->message().length() > 127) {
ImGui::TextColored(colour, "%.*s...", 127, current->message().data()); ImGui::TextColored(colour, "%.*s...", 127, current->message().c_str());
} }
else { else {
ImGui::TextColored(colour, current->message().data()); ImGui::TextColored(colour, current->message().c_str());
} }
height += ImGui::GetWindowHeight() + toast_spacing; height += ImGui::GetWindowHeight() + toast_spacing;

View file

@ -17,14 +17,12 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <chrono> #include <chrono>
#include <string>
#include <vector> #include <vector>
#include <Corrade/Containers/String.h>
#include <Magnum/Magnum.h> #include <Magnum/Magnum.h>
#include <Magnum/Animation/Track.h> #include <Magnum/Animation/Track.h>
using namespace Corrade;
using namespace Magnum; using namespace Magnum;
class Toast { class Toast {
@ -37,7 +35,7 @@ class Toast {
FadeIn, Wait, FadeOut, TimedOut FadeIn, Wait, FadeOut, TimedOut
}; };
explicit Toast(Type type, Containers::StringView message, explicit Toast(Type type, const std::string& message,
std::chrono::milliseconds timeout = std::chrono::milliseconds{3000}); std::chrono::milliseconds timeout = std::chrono::milliseconds{3000});
Toast(const Toast& other) = delete; Toast(const Toast& other) = delete;
@ -48,7 +46,7 @@ class Toast {
auto type() -> Type; auto type() -> Type;
auto message() -> Containers::StringView; auto message() -> std::string const&;
auto timeout() -> std::chrono::milliseconds; auto timeout() -> std::chrono::milliseconds;
@ -62,7 +60,7 @@ class Toast {
private: private:
Type _type{Type::Default}; Type _type{Type::Default};
Containers::StringView _message; std::string _message;
std::chrono::milliseconds _timeout; std::chrono::milliseconds _timeout;
std::chrono::steady_clock::time_point _creationTime; std::chrono::steady_clock::time_point _creationTime;
Animation::Track<UnsignedInt, Phase> _phaseTrack; Animation::Track<UnsignedInt, Phase> _phaseTrack;
@ -72,7 +70,7 @@ class ToastQueue {
public: public:
void addToast(Toast&& toast); void addToast(Toast&& toast);
void addToast(Toast::Type type, Containers::StringView message, void addToast(Toast::Type type, const std::string& message,
std::chrono::milliseconds timeout = std::chrono::milliseconds{3000}); std::chrono::milliseconds timeout = std::chrono::milliseconds{3000});
void draw(Vector2i viewport_size); void draw(Vector2i viewport_size);

View file

@ -16,16 +16,15 @@
#include <cstring> #include <cstring>
#include <Corrade/Containers/Array.h> #include <string>
#include <Corrade/Containers/String.h>
#include "BinaryReader.h" #include "BinaryReader.h"
BinaryReader::BinaryReader(Containers::StringView filename) { BinaryReader::BinaryReader(const std::string& filename) {
_file = std::fopen(filename.data(), "rb"); _file = std::fopen(filename.c_str(), "rb");
if(!_file) { if(!_file) {
Utility::Error{} << "Couldn't open" << filename << "for reading:\n" Utility::Error{} << "Couldn't open" << filename.c_str() << "for reading:\n"
<< std::strerror(errno); << std::strerror(errno);
} }
} }
@ -107,15 +106,16 @@ auto BinaryReader::readArray(Containers::Array<char>& array, std::size_t count)
return std::fread(array.data(), sizeof(char), count, _file) == count; return std::fread(array.data(), sizeof(char), count, _file) == count;
} }
auto BinaryReader::readUEString(Containers::String& str) -> bool { auto BinaryReader::readUEString(std::string& str) -> bool {
UnsignedInt length = 0; UnsignedInt length = 0;
if(!readUnsignedInt(length) || length == 0) { if(!readUnsignedInt(length) || length == 0) {
return false; return false;
} }
str = Containers::String{ValueInit, length - 1}; str = std::string{};
str.resize(length - 1);
return std::fread(str.data(), sizeof(char), length, _file) == length; return std::fread(&str[0], sizeof(char), length, _file) == length;
} }
auto BinaryReader::peekChar() -> Int { auto BinaryReader::peekChar() -> Int {

View file

@ -18,9 +18,9 @@
#include <cstdio> #include <cstdio>
#include <Corrade/Containers/Containers.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Utility/StlForwardString.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -29,7 +29,7 @@ using namespace Magnum;
class BinaryReader { class BinaryReader {
public: public:
explicit BinaryReader(Containers::StringView filename); explicit BinaryReader(const std::string& filename);
~BinaryReader(); ~BinaryReader();
auto open() -> bool; auto open() -> bool;
@ -63,7 +63,7 @@ class BinaryReader {
return std::fread(array.data(), sizeof(char), S, _file) == S; return std::fread(array.data(), sizeof(char), S, _file) == S;
} }
auto readUEString(Containers::String& str) -> bool; auto readUEString(std::string& str) -> bool;
auto peekChar() -> Int; auto peekChar() -> Int;

View file

@ -16,14 +16,14 @@
#include <cstring> #include <cstring>
#include <string>
#include "BinaryWriter.h" #include "BinaryWriter.h"
using namespace Containers::Literals; BinaryWriter::BinaryWriter(const std::string& filename) {
_file = std::fopen(filename.c_str(), "wb");
BinaryWriter::BinaryWriter(Containers::StringView filename) {
_file = std::fopen(filename.data(), "wb");
if(!_file) { if(!_file) {
Utility::Error{} << "Couldn't open"_s << filename << "for reading:\n"_s Utility::Error{} << "Couldn't open" << filename.c_str() << "for reading:\n"
<< std::strerror(errno); << std::strerror(errno);
} }
} }
@ -114,25 +114,24 @@ auto BinaryWriter::writeArray(Containers::ArrayView<const char> array) -> bool {
return std::fwrite(array.data(), sizeof(char), array.size(), _file) == array.size(); return std::fwrite(array.data(), sizeof(char), array.size(), _file) == array.size();
} }
auto BinaryWriter::writeUEString(Containers::StringView str) -> bool { auto BinaryWriter::writeUEString(const std::string& str) -> bool {
if(str.size() > UINT32_MAX) { if(str.length() > UINT32_MAX) {
Utility::Error{} << "BinaryWriter::writeUEString(): string is too big."_s; Utility::Error{} << "BinaryWriter::writeUEString(): string is too big.";
return false; return false;
} }
writeUnsignedInt(static_cast<UnsignedInt>(str.size()) + 1); writeUnsignedInt(static_cast<UnsignedInt>(str.length()) + 1);
if(str.size() > 0) { if(str.length() > 0) {
std::size_t count = std::fwrite(str.data(), sizeof(char), str.size(), _file); std::size_t count = std::fwrite(&str[0], sizeof(char), str.length(), _file);
if(count != str.size()) { if(count != str.length()) {
return false; return false;
} }
} }
return writeChar('\0'); return writeChar('\0');
} }
auto BinaryWriter::writeUEStringToArray(Containers::StringView value) -> UnsignedLong { auto BinaryWriter::writeUEStringToArray(const std::string& value) -> UnsignedLong {
return writeValueToArray<UnsignedInt>(UnsignedInt(value.size()) + 1u) + Containers::ArrayView<const char> view{value.c_str(), value.length()};
writeDataToArray(Containers::ArrayView<const char>{value}) + return writeValueToArray<UnsignedInt>(UnsignedInt(value.length()) + 1u) + writeDataToArray(view) + writeValueToArray<char>('\0');
writeValueToArray<char>('\0');
} }

View file

@ -21,7 +21,7 @@
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h> #include <Corrade/Utility/StlForwardString.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -30,7 +30,7 @@ using namespace Magnum;
class BinaryWriter { class BinaryWriter {
public: public:
explicit BinaryWriter(Containers::StringView filename); explicit BinaryWriter(const std::string& filename);
~BinaryWriter(); ~BinaryWriter();
BinaryWriter(const BinaryWriter& other) = delete; BinaryWriter(const BinaryWriter& other) = delete;
@ -71,7 +71,7 @@ class BinaryWriter {
return std::fwrite(array.data(), sizeof(char), S, _file) == S; return std::fwrite(array.data(), sizeof(char), S, _file) == S;
} }
auto writeUEString(Containers::StringView str) -> bool; auto writeUEString(const std::string& str) -> bool;
template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>> template<typename T, typename U = std::conditional_t<std::is_trivially_copyable<T>::value, T, T&>>
auto writeValueToArray(U value) -> UnsignedLong { auto writeValueToArray(U value) -> UnsignedLong {
@ -79,7 +79,7 @@ class BinaryWriter {
return writeDataToArray(view); return writeDataToArray(view);
} }
auto writeUEStringToArray(Containers::StringView value) -> UnsignedLong; auto writeUEStringToArray(const std::string& value) -> UnsignedLong;
template<typename T> template<typename T>
void writeValueToArrayAt(T& value, UnsignedLong position) { void writeValueToArrayAt(T& value, UnsignedLong position) {

View file

@ -23,18 +23,18 @@
#include "Debug.h" #include "Debug.h"
Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop) { Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop) {
return debug << (*prop->name) << Utility::Debug::nospace << ":" << return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType; prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
} }
Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) { Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) {
return debug << (*prop->name) << Utility::Debug::nospace << ":" << return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType; prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
} }
Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) { Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
debug << (*prop->name) << Utility::Debug::nospace << ":" << debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace <<
") Contents:"; ") Contents:";
for(const auto& item : prop->properties) { for(const auto& item : prop->properties) {
debug << "\n " << Utility::Debug::nospace << item.get(); debug << "\n " << Utility::Debug::nospace << item.get();
@ -48,8 +48,8 @@ Utility::Debug& operator<<(Utility::Debug& debug, const StructProperty* prop) {
return debug << cast; return debug << cast;
} }
return debug << (*prop->name) << Utility::Debug::nospace << ":" << return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ")"; prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace << ")";
} }
Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) { Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop) {
@ -72,5 +72,5 @@ Utility::Debug& operator<<(Utility::Debug& debug, const UnrealPropertyBase* prop
} }
} }
return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType; return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" << prop->propertyType.c_str();
} }

View file

@ -42,6 +42,7 @@
#include "PropertySerialiser.h" #include "PropertySerialiser.h"
PropertySerialiser::PropertySerialiser() { PropertySerialiser::PropertySerialiser() {
arrayAppend(_serialisers, Containers::pointer<ArrayPropertySerialiser>()); arrayAppend(_serialisers, Containers::pointer<ArrayPropertySerialiser>());
arrayAppend(_serialisers, Containers::pointer<BoolPropertySerialiser>()); arrayAppend(_serialisers, Containers::pointer<BoolPropertySerialiser>());
@ -70,7 +71,7 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
return nullptr; return nullptr;
} }
Containers::String name; std::string name;
if(!reader.readUEString(name)) { if(!reader.readUEString(name)) {
return nullptr; return nullptr;
} }
@ -79,7 +80,7 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
return Containers::pointer<NoneProperty>(); return Containers::pointer<NoneProperty>();
} }
Containers::String type; std::string type;
if(!reader.readUEString(type)) { if(!reader.readUEString(type)) {
return nullptr; return nullptr;
} }
@ -92,8 +93,7 @@ auto PropertySerialiser::read(BinaryReader& reader) -> UnrealPropertyBase::ptr {
return deserialise(std::move(name), std::move(type), value_length, reader); return deserialise(std::move(name), std::move(type), value_length, reader);
} }
auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, auto PropertySerialiser::readItem(BinaryReader& reader, std::string type, UnsignedLong value_length, std::string name) -> UnrealPropertyBase::ptr {
Containers::String name) -> UnrealPropertyBase::ptr {
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; return nullptr;
} }
@ -101,9 +101,7 @@ auto PropertySerialiser::readItem(BinaryReader& reader, Containers::String type,
return deserialise(std::move(name), std::move(type), value_length, reader); return deserialise(std::move(name), std::move(type), value_length, reader);
} }
auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView item_type, auto PropertySerialiser::readSet(BinaryReader& reader, const std::string& item_type, UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr> {
UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>
{
if(reader.peekChar() < 0 || reader.eof()) { if(reader.peekChar() < 0 || reader.eof()) {
return nullptr; return nullptr;
} }
@ -113,12 +111,12 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
Containers::Array<UnrealPropertyBase::ptr> array; Containers::Array<UnrealPropertyBase::ptr> array;
if(serialiser) { if(serialiser) {
Containers::String name; std::string name;
if(!reader.readUEString(name)) { if(!reader.readUEString(name)) {
return nullptr; return nullptr;
} }
Containers::String type; std::string type;
if(!reader.readUEString(type)) { if(!reader.readUEString(type)) {
return nullptr; return nullptr;
} }
@ -146,7 +144,7 @@ auto PropertySerialiser::readSet(BinaryReader& reader, Containers::StringView it
return array; return array;
} }
auto PropertySerialiser::deserialise(Containers::String name, Containers::String type, UnsignedLong value_length, auto PropertySerialiser::deserialise(std::string name, std::string type, UnsignedLong value_length,
BinaryReader& reader) -> UnrealPropertyBase::ptr BinaryReader& reader) -> UnrealPropertyBase::ptr
{ {
UnrealPropertyBase::ptr prop; UnrealPropertyBase::ptr prop;
@ -169,8 +167,8 @@ auto PropertySerialiser::deserialise(Containers::String name, Containers::String
return prop; return prop;
} }
auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, auto PropertySerialiser::serialise(UnrealPropertyBase::ptr& prop, const std::string& item_type, UnsignedLong& bytes_written,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool BinaryWriter& writer) -> bool
{ {
auto serialiser = getSerialiser(item_type); auto serialiser = getSerialiser(item_type);
if(!serialiser) { if(!serialiser) {
@ -202,7 +200,7 @@ auto PropertySerialiser::write(UnrealPropertyBase::ptr& prop, UnsignedLong& byte
return ret; return ret;
} }
auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, const std::string& item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
{ {
if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) { if(prop->name == "None" && prop->propertyType == "NoneProperty" && dynamic_cast<NoneProperty*>(prop.get())) {
@ -213,9 +211,8 @@ auto PropertySerialiser::writeItem(UnrealPropertyBase::ptr& prop, Containers::St
return serialise(prop, item_type, bytes_written, writer); return serialise(prop, item_type, bytes_written, writer);
} }
auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, const std::string& item_type,
Containers::StringView item_type, UnsignedLong& bytes_written, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool
BinaryWriter& writer) -> bool
{ {
auto serialiser = getCollectionSerialiser(item_type); auto serialiser = getCollectionSerialiser(item_type);
if(serialiser) { if(serialiser) {
@ -232,9 +229,9 @@ auto PropertySerialiser::writeSet(Containers::ArrayView<UnrealPropertyBase::ptr>
} }
} }
auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser* { auto PropertySerialiser::getSerialiser(const std::string& item_type) -> AbstractUnrealPropertySerialiser* {
for(auto& item : _serialisers) { for(auto& item : _serialisers) {
for(Containers::StringView serialiser_type : item->types()) { for(const std::string& serialiser_type : item->types()) {
if(item_type == serialiser_type) { if(item_type == serialiser_type) {
return item.get(); return item.get();
} }
@ -244,9 +241,9 @@ auto PropertySerialiser::getSerialiser(Containers::StringView item_type) -> Abst
return nullptr; return nullptr;
} }
auto PropertySerialiser::getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser* { auto PropertySerialiser::getCollectionSerialiser(const std::string& item_type) -> AbstractUnrealCollectionPropertySerialiser* {
for(auto& item : _collectionSerialisers) { for(auto& item : _collectionSerialisers) {
for(Containers::StringView serialiser_type : item->types()) { for(const std::string& serialiser_type : item->types()) {
if(item_type == serialiser_type) { if(item_type == serialiser_type) {
return item.get(); return item.get();
} }

View file

@ -17,8 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "Serialisers/AbstractUnrealPropertySerialiser.h" #include "Serialisers/AbstractUnrealPropertySerialiser.h"
#include "Serialisers/AbstractUnrealCollectionPropertySerialiser.h" #include "Serialisers/AbstractUnrealCollectionPropertySerialiser.h"
@ -35,23 +33,18 @@ class PropertySerialiser {
PropertySerialiser(); PropertySerialiser();
auto read(BinaryReader& reader) -> UnrealPropertyBase::ptr; auto read(BinaryReader& reader) -> UnrealPropertyBase::ptr;
auto readItem(BinaryReader& reader, Containers::String type, UnsignedLong value_length, auto readItem(BinaryReader& reader, std::string type, UnsignedLong value_length, std::string name) -> UnrealPropertyBase::ptr;
Containers::String name) -> UnrealPropertyBase::ptr; auto readSet(BinaryReader& reader, const std::string& item_type, UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>;
auto readSet(BinaryReader& reader, Containers::StringView item_type, UnsignedInt count) -> Containers::Array<UnrealPropertyBase::ptr>; auto deserialise(std::string name, std::string type, UnsignedLong value_length, BinaryReader& reader) -> UnrealPropertyBase::ptr;
auto deserialise(Containers::String name, Containers::String type, UnsignedLong value_length,
BinaryReader& reader) -> UnrealPropertyBase::ptr;
auto serialise(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, auto serialise(UnrealPropertyBase::ptr& prop, const std::string& item_type, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
BinaryWriter& writer) -> bool;
auto write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool; auto write(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
auto writeItem(UnrealPropertyBase::ptr& prop, Containers::StringView item_type, UnsignedLong& bytes_written, auto writeItem(UnrealPropertyBase::ptr& prop, const std::string& item_type, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
BinaryWriter& writer) -> bool; auto writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, const std::string& item_type, UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
auto writeSet(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type,
UnsignedLong& bytes_written, BinaryWriter& writer) -> bool;
private: private:
auto getSerialiser(Containers::StringView item_type) -> AbstractUnrealPropertySerialiser*; auto getSerialiser(const std::string& item_type) -> AbstractUnrealPropertySerialiser*;
auto getCollectionSerialiser(Containers::StringView item_type) -> AbstractUnrealCollectionPropertySerialiser*; auto getCollectionSerialiser(const std::string& item_type) -> AbstractUnrealCollectionPropertySerialiser*;
Containers::Array<AbstractUnrealPropertySerialiser::ptr> _serialisers; Containers::Array<AbstractUnrealPropertySerialiser::ptr> _serialisers;
Containers::Array<AbstractUnrealCollectionPropertySerialiser::ptr> _collectionSerialisers; Containers::Array<AbstractUnrealCollectionPropertySerialiser::ptr> _collectionSerialisers;

View file

@ -16,10 +16,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -38,12 +39,9 @@ class AbstractUnrealCollectionPropertySerialiser {
virtual ~AbstractUnrealCollectionPropertySerialiser() = default; virtual ~AbstractUnrealCollectionPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0; virtual auto types() -> Containers::ArrayView<const std::string> = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type, virtual auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> = 0;
UnsignedLong value_length, UnsignedInt count, BinaryReader& reader,
PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> = 0;
virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, virtual auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, const std::string& item_type, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
}; };

View file

@ -16,9 +16,10 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -37,11 +38,9 @@ class AbstractUnrealPropertySerialiser {
virtual ~AbstractUnrealPropertySerialiser() = default; virtual ~AbstractUnrealPropertySerialiser() = default;
virtual auto types() -> Containers::ArrayView<const Containers::StringView> = 0; virtual auto types() -> Containers::ArrayView<const std::string> = 0;
virtual auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, virtual auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr = 0;
virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, virtual auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
PropertySerialiser& serialiser) -> bool = 0;
}; };

View file

@ -16,10 +16,11 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Array.h> #include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayView.h> #include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -37,10 +38,9 @@ class AbstractUnrealStructSerialiser {
virtual ~AbstractUnrealStructSerialiser() = default; virtual ~AbstractUnrealStructSerialiser() = default;
virtual auto supportsType(Containers::StringView type) -> bool = 0; virtual auto supportsType(const std::string& type) -> bool = 0;
virtual auto deserialise(BinaryReader& reader) -> UnrealPropertyBase::ptr = 0; virtual auto deserialise(BinaryReader& reader) -> UnrealPropertyBase::ptr = 0;
virtual auto serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, virtual auto serialise(UnrealPropertyBase::ptr& structProp, BinaryWriter& writer, UnsignedLong& bytes_written) -> bool = 0;
UnsignedLong& bytes_written) -> bool = 0;
}; };

View file

@ -14,19 +14,16 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/String.h>
#include "../BinaryReader.h" #include "../BinaryReader.h"
#include "../BinaryWriter.h" #include "../BinaryWriter.h"
#include "../PropertySerialiser.h" #include "../PropertySerialiser.h"
#include "ArrayPropertySerialiser.h" #include "ArrayPropertySerialiser.h"
auto ArrayPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto ArrayPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
Containers::String item_type; std::string item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
return nullptr; return nullptr;
} }

View file

@ -16,24 +16,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/ArrayProperty.h" #include "../Types/ArrayProperty.h"
using namespace Corrade;
using namespace Magnum;
class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> { class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
public: public:
using ptr = Containers::Pointer<ArrayPropertySerialiser>; using ptr = Containers::Pointer<ArrayPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,15 +19,13 @@
#include "BoolPropertySerialiser.h" #include "BoolPropertySerialiser.h"
auto BoolPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> { auto BoolPropertySerialiser::types() -> Containers::ArrayView<const std::string> {
using namespace Containers::Literals; static const Containers::Array<std::string> types{InPlaceInit, {"BoolProperty"}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"BoolProperty"_s}};
return types; return types;
} }
auto BoolPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, auto BoolPropertySerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
if(value_length != 0) { if(value_length != 0) {
return nullptr; return nullptr;

View file

@ -16,24 +16,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/BoolProperty.h" #include "../Types/BoolProperty.h"
using namespace Corrade;
class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser { class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<BoolPropertySerialiser>; using ptr = Containers::Pointer<BoolPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,15 +19,13 @@
#include "BytePropertySerialiser.h" #include "BytePropertySerialiser.h"
auto BytePropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> { auto BytePropertySerialiser::types() -> Containers::ArrayView<const std::string> {
using namespace Containers::Literals; static const Containers::Array<std::string> types{InPlaceInit, {"ByteProperty"}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"ByteProperty"_s}};
return types; return types;
} }
auto BytePropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, auto BytePropertySerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<ByteProperty>(); auto prop = Containers::pointer<ByteProperty>();

View file

@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/ByteProperty.h" #include "../Types/ByteProperty.h"
@ -27,11 +24,9 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<BytePropertySerialiser>; using ptr = Containers::Pointer<BytePropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,9 +19,8 @@
#include "ColourPropertySerialiser.h" #include "ColourPropertySerialiser.h"
auto ColourPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto ColourPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<ColourStructProperty>(); auto prop = Containers::pointer<ColourStructProperty>();

View file

@ -16,21 +16,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/ColourStructProperty.h" #include "../Types/ColourStructProperty.h"
using namespace Corrade;
class ColourPropertySerialiser : public UnrealPropertySerialiser<ColourStructProperty> { class ColourPropertySerialiser : public UnrealPropertySerialiser<ColourStructProperty> {
public: public:
using ptr = Containers::Pointer<ColourPropertySerialiser>; using ptr = Containers::Pointer<ColourPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,9 +19,8 @@
#include "DateTimePropertySerialiser.h" #include "DateTimePropertySerialiser.h"
auto DateTimePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto DateTimePropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<DateTimeStructProperty>(); auto prop = Containers::pointer<DateTimeStructProperty>();

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/DateTimeStructProperty.h" #include "../Types/DateTimeStructProperty.h"
@ -27,8 +25,6 @@ class DateTimePropertySerialiser : public UnrealPropertySerialiser<DateTimeStruc
using ptr = Containers::Pointer<DateTimePropertySerialiser>; using ptr = Containers::Pointer<DateTimePropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,15 +19,13 @@
#include "EnumPropertySerialiser.h" #include "EnumPropertySerialiser.h"
auto EnumPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> { auto EnumPropertySerialiser::types() -> Containers::ArrayView<const std::string> {
using namespace Containers::Literals; static const Containers::Array<std::string> types{InPlaceInit, {"EnumProperty"}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"EnumProperty"_s}};
return types; return types;
} }
auto EnumPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, auto EnumPropertySerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<EnumProperty>(); auto prop = Containers::pointer<EnumProperty>();

View file

@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/EnumProperty.h" #include "../Types/EnumProperty.h"
@ -27,11 +24,9 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<EnumPropertySerialiser>; using ptr = Containers::Pointer<EnumPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,16 +19,13 @@
#include "FloatPropertySerialiser.h" #include "FloatPropertySerialiser.h"
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const std::string> {
auto FloatPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> { static const Containers::Array<std::string> types{InPlaceInit, {"FloatProperty"}};
using namespace Containers::Literals;
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"FloatProperty"_s}};
return types; return types;
} }
auto FloatPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, auto FloatPropertySerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<FloatProperty>(); auto prop = Containers::pointer<FloatProperty>();

View file

@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/FloatProperty.h" #include "../Types/FloatProperty.h"
@ -27,11 +24,9 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<FloatPropertySerialiser>; using ptr = Containers::Pointer<FloatPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,16 +19,13 @@
#include "GuidPropertySerialiser.h" #include "GuidPropertySerialiser.h"
using namespace Containers::Literals; auto GuidPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
auto GuidPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<GuidStructProperty>(); auto prop = Containers::pointer<GuidStructProperty>();
if(!reader.readStaticArray(prop->guid)) { if(!reader.readStaticArray(prop->guid)) {
Utility::Error{} << "Couldn't read GUID in"_s << __func__; Utility::Error{} << "Couldn't read guid in" << __func__;
return nullptr; return nullptr;
} }

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/GuidStructProperty.h" #include "../Types/GuidStructProperty.h"
@ -27,8 +25,7 @@ class GuidPropertySerialiser : public UnrealPropertySerialiser<GuidStructPropert
using ptr = Containers::Pointer<GuidPropertySerialiser>; using ptr = Containers::Pointer<GuidPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,9 +19,8 @@
#include "IntPropertySerialiser.h" #include "IntPropertySerialiser.h"
auto IntPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto IntPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<IntProperty>(); auto prop = Containers::pointer<IntProperty>();

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/IntProperty.h" #include "../Types/IntProperty.h"
@ -27,8 +25,6 @@ class IntPropertySerialiser : public UnrealPropertySerialiser<IntProperty> {
using ptr = Containers::Pointer<IntPropertySerialiser>; using ptr = Containers::Pointer<IntPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -22,11 +22,8 @@
#include "MapPropertySerialiser.h" #include "MapPropertySerialiser.h"
using namespace Containers::Literals; auto MapPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<MapProperty>(); auto prop = Containers::pointer<MapProperty>();
@ -61,7 +58,7 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
for(UnsignedInt i = 0; i < count; i++) { for(UnsignedInt i = 0; i < count; i++) {
MapProperty::KeyValuePair pair; MapProperty::KeyValuePair pair;
if(prop->keyType == "IntProperty"_s || prop->keyType == "StrProperty"_s) { if(prop->keyType == "IntProperty" || prop->keyType == "StrProperty") {
pair.key = serialiser.readItem(reader, prop->keyType, -1, name); pair.key = serialiser.readItem(reader, prop->keyType, -1, name);
if(pair.key == nullptr) { if(pair.key == nullptr) {
return nullptr; return nullptr;
@ -72,19 +69,19 @@ auto MapPropertySerialiser::deserialiseProperty(Containers::StringView name, Con
} }
UnrealPropertyBase::ptr value_item; UnrealPropertyBase::ptr value_item;
if(prop->valueType == "StructProperty"_s) { if(prop->valueType == "StructProperty") {
while((value_item = serialiser.read(reader)) != nullptr) { while((value_item = serialiser.read(reader)) != nullptr) {
arrayAppend(pair.values, std::move(value_item)); arrayAppend(pair.values, std::move(value_item));
if(pair.values.back()->name == "None"_s && if(pair.values.back()->name == "None" &&
pair.values.back()->propertyType == "NoneProperty"_s && pair.values.back()->propertyType == "NoneProperty" &&
dynamic_cast<NoneProperty*>(pair.values.back().get()) != nullptr) dynamic_cast<NoneProperty*>(pair.values.back().get()) != nullptr)
{ {
break; break;
} }
} }
} }
else if(prop->valueType == "ByteProperty"_s) { else if(prop->valueType == "ByteProperty") {
if((value_item = serialiser.readItem(reader, prop->valueType, -1, name)) == nullptr) { if((value_item = serialiser.readItem(reader, prop->valueType, -1, name)) == nullptr) {
return nullptr; return nullptr;
} }
@ -124,7 +121,7 @@ auto MapPropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop, Uns
} }
for(auto& value : pair.values) { for(auto& value : pair.values) {
if(map_prop->valueType == "StructProperty"_s) { if(map_prop->valueType == "StructProperty") {
if(!serialiser.write(value, dummy_bytes_written, writer)) { if(!serialiser.write(value, dummy_bytes_written, writer)) {
return false; return false;
} }

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/MapProperty.h" #include "../Types/MapProperty.h"
@ -27,8 +25,6 @@ class MapPropertySerialiser : public UnrealPropertySerialiser<MapProperty> {
using ptr = Containers::Pointer<MapPropertySerialiser>; using ptr = Containers::Pointer<MapPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -23,20 +23,17 @@
#include "ResourcePropertySerialiser.h" #include "ResourcePropertySerialiser.h"
using namespace Containers::Literals; auto ResourcePropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type,
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<ResourceItemValue>(); auto prop = Containers::pointer<ResourceItemValue>();
Containers::String str; std::string str;
if(!reader.readUEString(str) || str != "ID_4_AAE08F17428E229EC7A2209F51081A21"_s) { if(!reader.readUEString(str) || str != "ID_4_AAE08F17428E229EC7A2209F51081A21") {
return nullptr; return nullptr;
} }
if(!reader.readUEString(str) || str != "IntProperty"_s) { if(!reader.readUEString(str) || str != "IntProperty") {
return nullptr; return nullptr;
} }
@ -53,11 +50,11 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name
return nullptr; return nullptr;
} }
if(!reader.readUEString(str) || str != "Quantity_3_560F09B5485C365D3041888910019CE3"_s) { if(!reader.readUEString(str) || str != "Quantity_3_560F09B5485C365D3041888910019CE3") {
return nullptr; return nullptr;
} }
if(!reader.readUEString(str) || str != "IntProperty"_s) { if(!reader.readUEString(str) || str != "IntProperty") {
return nullptr; return nullptr;
} }
@ -73,7 +70,7 @@ auto ResourcePropertySerialiser::deserialiseProperty(Containers::StringView name
return nullptr; return nullptr;
} }
if(!reader.readUEString(str) || str != "None"_s) { if(!reader.readUEString(str) || str != "None") {
return nullptr; return nullptr;
} }
@ -88,19 +85,19 @@ auto ResourcePropertySerialiser::serialiseProperty(UnrealPropertyBase::ptr& prop
return false; return false;
} }
bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21"_s) + bytes_written += writer.writeUEStringToArray("ID_4_AAE08F17428E229EC7A2209F51081A21") +
writer.writeUEStringToArray("IntProperty"_s) + writer.writeUEStringToArray("IntProperty") +
writer.writeValueToArray<UnsignedLong>(4ull) + writer.writeValueToArray<UnsignedLong>(4ull) +
writer.writeValueToArray<char>('\0') + writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->id); writer.writeValueToArray<Int>(res_prop->id);
bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3"_s) + bytes_written += writer.writeUEStringToArray("Quantity_3_560F09B5485C365D3041888910019CE3") +
writer.writeUEStringToArray("IntProperty"_s) + writer.writeUEStringToArray("IntProperty") +
writer.writeValueToArray<UnsignedLong>(4ull) + writer.writeValueToArray<UnsignedLong>(4ull) +
writer.writeValueToArray<char>('\0') + writer.writeValueToArray<char>('\0') +
writer.writeValueToArray<Int>(res_prop->quantity); writer.writeValueToArray<Int>(res_prop->quantity);
bytes_written += writer.writeUEStringToArray("None"_s); bytes_written += writer.writeUEStringToArray("None");
return true; return true;
} }

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/ResourceItemValue.h" #include "../Types/ResourceItemValue.h"
@ -27,8 +25,6 @@ class ResourcePropertySerialiser : public UnrealPropertySerialiser<ResourceItemV
using ptr = Containers::Pointer<ResourcePropertySerialiser>; using ptr = Containers::Pointer<ResourcePropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,9 +19,8 @@
#include "RotatorPropertySerialiser.h" #include "RotatorPropertySerialiser.h"
auto RotatorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto RotatorPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<RotatorStructProperty>(); auto prop = Containers::pointer<RotatorStructProperty>();

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/RotatorStructProperty.h" #include "../Types/RotatorStructProperty.h"
@ -27,8 +25,6 @@ class RotatorPropertySerialiser : public UnrealPropertySerialiser<RotatorStructP
using ptr = Containers::Pointer<RotatorPropertySerialiser>; using ptr = Containers::Pointer<RotatorPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -20,11 +20,10 @@
#include "SetPropertySerialiser.h" #include "SetPropertySerialiser.h"
auto SetPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto SetPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
Containers::String item_type; std::string item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
return nullptr; return nullptr;
} }

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/SetProperty.h" #include "../Types/SetProperty.h"
@ -27,8 +25,6 @@ class SetPropertySerialiser : public UnrealPropertySerialiser<SetProperty> {
using ptr = Containers::Pointer<SetPropertySerialiser>; using ptr = Containers::Pointer<SetPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,17 +19,13 @@
#include "StringPropertySerialiser.h" #include "StringPropertySerialiser.h"
auto StringPropertySerialiser::types() -> Containers::ArrayView<const Containers::StringView> { auto StringPropertySerialiser::types() -> Containers::ArrayView<const std::string> {
using namespace Containers::Literals; static const Containers::Array<std::string> types{InPlaceInit, {"NameProperty", "StrProperty", "SoftObjectProperty", "ObjectProperty"}};
static const Containers::Array<Containers::StringView> types{InPlaceInit,
{"NameProperty"_s, "StrProperty"_s,
"SoftObjectProperty"_s, "ObjectProperty"_s}};
return types; return types;
} }
auto StringPropertySerialiser::deserialise(Containers::StringView name, Containers::StringView type, auto StringPropertySerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<StringProperty>(type); auto prop = Containers::pointer<StringProperty>(type);

View file

@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/StringProperty.h" #include "../Types/StringProperty.h"
@ -27,11 +24,9 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<StringPropertySerialiser>; using ptr = Containers::Pointer<StringPropertySerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/String.h>
#include "../BinaryReader.h" #include "../BinaryReader.h"
#include "../BinaryWriter.h" #include "../BinaryWriter.h"
#include "../PropertySerialiser.h" #include "../PropertySerialiser.h"
@ -25,16 +23,15 @@
#include "StructSerialiser.h" #include "StructSerialiser.h"
auto StructSerialiser::types() -> Containers::ArrayView<const Containers::StringView> { auto StructSerialiser::types() -> Containers::ArrayView<const std::string> {
using namespace Containers::Literals; static const Containers::Array<std::string> types{InPlaceInit, {"StructProperty"}};
static const Containers::Array<Containers::StringView> types{InPlaceInit, {"StructProperty"_s}};
return types; return types;
} }
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto StructSerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr>
{ {
Containers::String item_type; std::string item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
return nullptr; return nullptr;
} }
@ -79,10 +76,10 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return array; return array;
} }
auto StructSerialiser::deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto StructSerialiser::deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
Containers::String item_type; std::string item_type;
if(!reader.readUEString(item_type)) { if(!reader.readUEString(item_type)) {
return nullptr; return nullptr;
} }
@ -113,7 +110,7 @@ auto StructSerialiser::deserialise(Containers::StringView name, Containers::Stri
return prop; return prop;
} }
auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, auto StructSerialiser::serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, const std::string& item_type,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool
{ {
bytes_written += writer.writeUEStringToArray(*(props.front()->name)); bytes_written += writer.writeUEStringToArray(*(props.front()->name));
@ -179,7 +176,7 @@ auto StructSerialiser::serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& by
return true; return true;
} }
auto StructSerialiser::readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto StructSerialiser::readStructValue(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr
{ {
auto st_prop = Containers::pointer<GenericStructProperty>(); auto st_prop = Containers::pointer<GenericStructProperty>();

View file

@ -16,9 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealCollectionPropertySerialiser.h" #include "AbstractUnrealCollectionPropertySerialiser.h"
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "AbstractUnrealStructSerialiser.h" #include "AbstractUnrealStructSerialiser.h"
@ -29,20 +26,20 @@ class StructSerialiser : public AbstractUnrealPropertySerialiser, public Abstrac
public: public:
using ptr = Containers::Pointer<StructSerialiser>; using ptr = Containers::Pointer<StructSerialiser>;
auto types() -> Containers::ArrayView<const Containers::StringView> override; auto types() -> Containers::ArrayView<const std::string> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, UnsignedInt count,
UnsignedInt count, BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override; BinaryReader& reader, PropertySerialiser& serialiser) -> Containers::Array<UnrealPropertyBase::ptr> override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, Containers::StringView item_type, auto serialise(Containers::ArrayView<UnrealPropertyBase::ptr> props, const std::string& item_type, UnsignedLong& bytes_written,
UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written,
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override; BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
private: private:
auto readStructValue(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto readStructValue(const std::string& name, const std::string& type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr; BinaryReader& reader, PropertySerialiser& serialiser) -> StructProperty::ptr;
auto writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool; auto writeStructValue(StructProperty* prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool;
}; };

View file

@ -14,16 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/String.h>
#include "../BinaryReader.h" #include "../BinaryReader.h"
#include "../BinaryWriter.h" #include "../BinaryWriter.h"
#include "TextPropertySerialiser.h" #include "TextPropertySerialiser.h"
auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto TextPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<TextProperty>(); auto prop = Containers::pointer<TextProperty>();
@ -52,7 +49,7 @@ auto TextPropertySerialiser::deserialiseProperty(Containers::StringView name, Co
auto interval = reader.position() - start_position; auto interval = reader.position() - start_position;
do { do {
Containers::String str; std::string str;
if(!reader.readUEString(str)) { if(!reader.readUEString(str)) {
return nullptr; return nullptr;

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/TextProperty.h" #include "../Types/TextProperty.h"
@ -27,8 +25,6 @@ class TextPropertySerialiser : public UnrealPropertySerialiser<TextProperty> {
using ptr = Containers::Pointer<TextPropertySerialiser>; using ptr = Containers::Pointer<TextPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -18,10 +18,6 @@
#include <type_traits> #include <type_traits>
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/ArrayView.h>
#include <Corrade/Containers/StringView.h>
#include "AbstractUnrealPropertySerialiser.h" #include "AbstractUnrealPropertySerialiser.h"
#include "../Types/StructProperty.h" #include "../Types/StructProperty.h"
@ -32,38 +28,31 @@ class UnrealPropertySerialiser : public AbstractUnrealPropertySerialiser {
public: public:
using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>; using ptr = Containers::Pointer<UnrealPropertySerialiser<T>>;
auto types() -> Containers::ArrayView<const Containers::StringView> override { auto types() -> Containers::ArrayView<const std::string> override {
static const Containers::Array<Containers::StringView> types = []{ static const Containers::Array<std::string> types = []{
Containers::Array<Containers::StringView> array; Containers::Array<std::string> array;
Containers::Pointer<T> p(new T); Containers::Pointer<T> p(new T);
if(std::is_base_of<StructProperty, T>::value) { if(std::is_base_of<StructProperty, T>::value) {
array = Containers::Array<Containers::StringView>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}}; array = Containers::Array<std::string>{InPlaceInit, {dynamic_cast<StructProperty*>(p.get())->structType}};
} }
else { else {
array = Containers::Array<Containers::StringView>{InPlaceInit, {p->propertyType}}; array = Containers::Array<std::string>{InPlaceInit, {p->propertyType}};
} }
return array; return array;
}(); }();
return types; return types;
} }
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override {
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override
{
return deserialiseProperty(name, type, value_length, reader, serialiser); return deserialiseProperty(name, type, value_length, reader, serialiser);
} }
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override {
PropertySerialiser& serialiser) -> bool override
{
return serialiseProperty(prop, bytes_written, writer, serialiser); return serialiseProperty(prop, bytes_written, writer, serialiser);
} }
private: private:
virtual auto deserialiseProperty(Containers::StringView name, Containers::StringView type, virtual auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> typename UnrealPropertyBase::ptr = 0;
UnsignedLong value_length, BinaryReader& reader,
PropertySerialiser& serialiser) -> typename UnrealPropertyBase::ptr = 0;
virtual auto serialiseProperty(typename UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, virtual auto serialiseProperty(typename UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
BinaryWriter& writer, PropertySerialiser& serialiser) -> bool = 0;
}; };

View file

@ -19,9 +19,8 @@
#include "Vector2DPropertySerialiser.h" #include "Vector2DPropertySerialiser.h"
auto Vector2DPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto Vector2DPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<Vector2DStructProperty>(); auto prop = Containers::pointer<Vector2DStructProperty>();

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/Vector2DStructProperty.h" #include "../Types/Vector2DStructProperty.h"
@ -27,8 +25,6 @@ class Vector2DPropertySerialiser : public UnrealPropertySerialiser<Vector2DStruc
using ptr = Containers::Pointer<Vector2DPropertySerialiser>; using ptr = Containers::Pointer<Vector2DPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -19,9 +19,8 @@
#include "VectorPropertySerialiser.h" #include "VectorPropertySerialiser.h"
auto VectorPropertySerialiser::deserialiseProperty(Containers::StringView name, Containers::StringView type, auto VectorPropertySerialiser::deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length,
UnsignedLong value_length, BinaryReader& reader, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr
{ {
auto prop = Containers::pointer<VectorStructProperty>(); auto prop = Containers::pointer<VectorStructProperty>();

View file

@ -16,8 +16,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertySerialiser.h" #include "UnrealPropertySerialiser.h"
#include "../Types/VectorStructProperty.h" #include "../Types/VectorStructProperty.h"
@ -27,8 +25,6 @@ class VectorPropertySerialiser : public UnrealPropertySerialiser<VectorStructPro
using ptr = Containers::Pointer<VectorPropertySerialiser>; using ptr = Containers::Pointer<VectorPropertySerialiser>;
private: private:
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length, auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override; auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
}; };

View file

@ -17,9 +17,6 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
@ -27,8 +24,7 @@ struct ArrayProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<ArrayProperty>; using ptr = Containers::Pointer<ArrayProperty>;
ArrayProperty() { ArrayProperty() {
using namespace Containers::Literals; propertyType = "ArrayProperty";
propertyType = "ArrayProperty"_s;
} }
template<typename T> template<typename T>
@ -41,6 +37,6 @@ struct ArrayProperty : public UnrealPropertyBase {
return static_cast<T*>(items[index].get()); return static_cast<T*>(items[index].get());
} }
Containers::String itemType; std::string itemType;
Containers::Array<UnrealPropertyBase::ptr> items; Containers::Array<UnrealPropertyBase::ptr> items;
}; };

View file

@ -16,18 +16,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade;
struct BoolProperty : public UnrealProperty<bool> { struct BoolProperty : public UnrealProperty<bool> {
using ptr = Containers::Pointer<BoolProperty>; using ptr = Containers::Pointer<BoolProperty>;
BoolProperty() { BoolProperty() {
using namespace Containers::Literals; propertyType = "BoolProperty";
propertyType = "BoolProperty"_s;
} }
}; };

View file

@ -17,23 +17,17 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade;
struct ByteProperty : public UnrealProperty<Containers::Array<char>> { struct ByteProperty : public UnrealProperty<Containers::Array<char>> {
using ptr = Containers::Pointer<ByteProperty>; using ptr = Containers::Pointer<ByteProperty>;
ByteProperty() { ByteProperty() {
using namespace Containers::Literals; propertyType = "ByteProperty";
propertyType = "ByteProperty"_s;
} }
// For some reason, M.A.S.S. Builder stores EnumProperties as ByteProperties. Ugh... // For some reason, M.A.S.S. Builder stores EnumProperties as ByteProperties. Ugh...
Containers::String enumType; std::string enumType;
Containers::String enumValue; std::string enumValue;
}; };

View file

@ -16,18 +16,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
struct ColourStructProperty : public StructProperty { struct ColourStructProperty : public StructProperty {
using ptr = Containers::Pointer<ColourStructProperty>; using ptr = Containers::Pointer<ColourStructProperty>;
ColourStructProperty() { ColourStructProperty() {
using namespace Containers::Literals; structType = "LinearColor";
structType = "LinearColor"_s;
} }
Float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f; Float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
}; };

View file

@ -16,22 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
using namespace Magnum;
struct DateTimeStructProperty : public StructProperty { struct DateTimeStructProperty : public StructProperty {
using ptr = Containers::Pointer<DateTimeStructProperty>; using ptr = Containers::Pointer<DateTimeStructProperty>;
DateTimeStructProperty() { DateTimeStructProperty() {
using namespace Containers::Literals; structType = "DateTime";
structType = "DateTime"_s;
} }
UnsignedLong timestamp = 0; UnsignedLong timestamp = 0;

View file

@ -16,21 +16,14 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade; struct EnumProperty : public UnrealProperty<std::string> {
struct EnumProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<EnumProperty>; using ptr = Containers::Pointer<EnumProperty>;
EnumProperty() { EnumProperty() {
using namespace Containers::Literals; propertyType = "EnumProperty";
propertyType = "EnumProperty"_s;
} }
Containers::String enumType; std::string enumType;
}; };

View file

@ -16,21 +16,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade;
using namespace Magnum;
struct FloatProperty : public UnrealProperty<Float> { struct FloatProperty : public UnrealProperty<Float> {
using ptr = Containers::Pointer<FloatProperty>; using ptr = Containers::Pointer<FloatProperty>;
FloatProperty() { FloatProperty() {
using namespace Containers::Literals; propertyType = "FloatProperty";
propertyType = "FloatProperty"_s;
} }
}; };

View file

@ -16,22 +16,18 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <type_traits> #include <algorithm>
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
struct GenericStructProperty : public StructProperty { struct GenericStructProperty : public StructProperty {
using ptr = Containers::Pointer<GenericStructProperty>; using ptr = Containers::Pointer<GenericStructProperty>;
template<typename T> template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*> std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, T*>
at(Containers::StringView name) { at(const std::string& name) {
for(auto& item : properties) { for(auto& item : properties) {
if(item->name == name) { if(item->name == name) {
return static_cast<T*>(item.get()); return static_cast<T*>(item.get());
@ -42,7 +38,7 @@ struct GenericStructProperty : public StructProperty {
template<typename T> template<typename T>
std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, typename T::ptr> std::enable_if_t<std::is_base_of<UnrealPropertyBase, T>::value, typename T::ptr>
atMove(Containers::StringView name) { atMove(const std::string& name) {
for(auto& item : properties) { for(auto& item : properties) {
if(item && item->name == name) { if(item && item->name == name) {
return Containers::Pointer<T>{static_cast<T*>(item.release())}; return Containers::Pointer<T>{static_cast<T*>(item.release())};

View file

@ -16,20 +16,15 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
struct GuidStructProperty : public StructProperty { struct GuidStructProperty : public StructProperty {
using ptr = Containers::Pointer<GuidStructProperty>; using ptr = Containers::Pointer<GuidStructProperty>;
GuidStructProperty() { GuidStructProperty() {
using namespace Containers::Literals; structType = "Guid";
structType = "Guid"_s;
} }
Containers::StaticArray<16, char> guid{ValueInit}; Containers::StaticArray<16, char> guid{ValueInit};

View file

@ -16,18 +16,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade;
struct IntProperty : public UnrealProperty<Int> { struct IntProperty : public UnrealProperty<Int> {
using ptr = Containers::Pointer<IntProperty>; using ptr = Containers::Pointer<IntProperty>;
IntProperty() { IntProperty() {
using namespace Containers::Literals; propertyType = "IntProperty";
propertyType = "IntProperty"_s;
} }
}; };

View file

@ -16,24 +16,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
using namespace Corrade;
struct MapProperty : public UnrealPropertyBase { struct MapProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<MapProperty>; using ptr = Containers::Pointer<MapProperty>;
MapProperty() { MapProperty() {
using namespace Containers::Literals; propertyType = "MapProperty";
propertyType = "MapProperty"_s;
} }
Containers::String keyType; std::string keyType;
Containers::String valueType; std::string valueType;
struct KeyValuePair { struct KeyValuePair {
UnrealPropertyBase::ptr key; UnrealPropertyBase::ptr key;

View file

@ -16,19 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
using namespace Corrade;
struct NoneProperty : UnrealPropertyBase { struct NoneProperty : UnrealPropertyBase {
using ptr = Containers::Pointer<NoneProperty>; using ptr = Containers::Pointer<NoneProperty>;
NoneProperty() { NoneProperty() {
using namespace Containers::Literals; name.emplace("None");
name.emplace("None"_s); propertyType = "NoneProperty";
propertyType = "NoneProperty"_s;
} }
}; };

View file

@ -16,22 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
using namespace Magnum;
struct ResourceItemValue : public StructProperty { struct ResourceItemValue : public StructProperty {
using ptr = Containers::Pointer<ResourceItemValue>; using ptr = Containers::Pointer<ResourceItemValue>;
ResourceItemValue() { ResourceItemValue() {
using namespace Containers::Literals; structType = "sttResourceItemValue";
structType = "sttResourceItemValue"_s;
structGuid = Containers::StaticArray<16, char>{'\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55'}; structGuid = Containers::StaticArray<16, char>{'\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55'};
} }

View file

@ -16,22 +16,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StringView.h>
#include <Magnum/Types.h>
#include "StructProperty.h" #include "StructProperty.h"
using namespace Corrade;
using namespace Magnum;
struct RotatorStructProperty : public StructProperty { struct RotatorStructProperty : public StructProperty {
using ptr = Containers::Pointer<RotatorStructProperty>; using ptr = Containers::Pointer<RotatorStructProperty>;
RotatorStructProperty() { RotatorStructProperty() {
using namespace Containers::Literals; structType = "Rotator";
structType = "Rotator"_s;
} }
Float x = 0.0f, y = 0.0f, z = 0.0f; Float x = 0.0f, y = 0.0f, z = 0.0f;

View file

@ -17,20 +17,14 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/GrowableArray.h> #include <Corrade/Containers/GrowableArray.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
using namespace Corrade;
struct SetProperty : public UnrealPropertyBase { struct SetProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<SetProperty>; using ptr = Containers::Pointer<SetProperty>;
SetProperty() { SetProperty() {
using namespace Containers::Literals; propertyType = "SetProperty";
propertyType = "SetProperty"_s;
} }
auto at(std::size_t index) -> UnrealPropertyBase* { auto at(std::size_t index) -> UnrealPropertyBase* {
@ -41,6 +35,6 @@ struct SetProperty : public UnrealPropertyBase {
return items[index].get(); return items[index].get();
} }
Containers::String itemType; std::string itemType;
Containers::Array<UnrealPropertyBase::ptr> items; Containers::Array<UnrealPropertyBase::ptr> items;
}; };

View file

@ -16,19 +16,12 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade; struct StringProperty : public UnrealProperty<std::string> {
using namespace Containers::Literals;
struct StringProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<StringProperty>; using ptr = Containers::Pointer<StringProperty>;
explicit StringProperty(Containers::StringView type = "StrProperty"_s) { explicit StringProperty(const std::string& type = "StrProperty") {
propertyType = type; propertyType = type;
} }
}; };

View file

@ -16,23 +16,17 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/StaticArray.h> #include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
using namespace Corrade;
struct StructProperty : public UnrealPropertyBase { struct StructProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<StructProperty>; using ptr = Containers::Pointer<StructProperty>;
StructProperty() { StructProperty() {
using namespace Containers::Literals; std::string propertyType = "StructProperty";
propertyType = "StructProperty"_s;
} }
Containers::StaticArray<16, char> structGuid{ValueInit}; Containers::StaticArray<16, char> structGuid{ValueInit};
Containers::String structType; std::string structType;
}; };

View file

@ -16,24 +16,16 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealProperty.h" #include "UnrealProperty.h"
using namespace Corrade; struct TextProperty : public UnrealProperty<std::string> {
struct TextProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<TextProperty>; using ptr = Containers::Pointer<TextProperty>;
TextProperty() { TextProperty() {
using namespace Containers::Literals; propertyType = "TextProperty";
propertyType = "TextProperty"_s;
} }
Containers::Array<char> flags; Containers::Array<char> flags;
char id = 0; char id = 0;
Containers::Array<Containers::String> data; Containers::Array<std::string> data;
}; };

View file

@ -16,12 +16,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <Corrade/Containers/Pointer.h>
#include "UnrealPropertyBase.h" #include "UnrealPropertyBase.h"
using namespace Corrade;
template<typename T> template<typename T>
struct UnrealProperty : public UnrealPropertyBase { struct UnrealProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<UnrealProperty<T>>; using ptr = Containers::Pointer<UnrealProperty<T>>;

View file

@ -16,9 +16,10 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. // along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <string>
#include <Corrade/Containers/Optional.h> #include <Corrade/Containers/Optional.h>
#include <Corrade/Containers/Pointer.h> #include <Corrade/Containers/Pointer.h>
#include <Corrade/Containers/String.h>
#include <Magnum/Types.h> #include <Magnum/Types.h>
@ -30,7 +31,7 @@ struct UnrealPropertyBase {
virtual ~UnrealPropertyBase() = default; virtual ~UnrealPropertyBase() = default;
Containers::Optional<Containers::String> name = Containers::NullOpt; Containers::Optional<std::string> name = Containers::NullOpt;
Containers::String propertyType; std::string propertyType;
UnsignedLong valueLength = 0; UnsignedLong valueLength = 0;
}; };

Some files were not shown because too many files have changed in this diff Show more