Compare commits

...

2 commits

Author SHA1 Message Date
8791eb32ac Use Corrade's String(View) types where possible.
Utility::Directory, efsw, cpr, and json.hpp are the only obstacles to a
complete removal of std::string usages.
2022-03-04 21:18:55 +01:00
2648e1103e Update Corrade and Magnum.
MBST doesn't fully compile yet, but I'm fixing that.
2022-03-02 16:11:19 +01:00
107 changed files with 1634 additions and 1293 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -23,18 +23,18 @@
#include "Debug.h"
Utility::Debug& operator<<(Utility::Debug& debug, const ArrayProperty* prop) {
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
return debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType;
}
Utility::Debug& operator<<(Utility::Debug& debug, const SetProperty* prop) {
return debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->propertyType.c_str() << "of" << prop->items.size() << prop->itemType.c_str();
return debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->propertyType << "of" << prop->items.size() << prop->itemType;
}
Utility::Debug& operator<<(Utility::Debug& debug, const GenericStructProperty* prop) {
debug << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace <<
debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace <<
") Contents:";
for(const auto& item : prop->properties) {
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 << (*prop->name).c_str() << Utility::Debug::nospace << ":" <<
prop->structType.c_str() << "(" << Utility::Debug::nospace << prop->propertyType.c_str() << Utility::Debug::nospace << ")";
return debug << (*prop->name) << Utility::Debug::nospace << ":" <<
prop->structType << "(" << Utility::Debug::nospace << prop->propertyType << Utility::Debug::nospace << ")";
}
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).c_str() << Utility::Debug::nospace << ":" << prop->propertyType.c_str();
return debug << (*prop->name) << Utility::Debug::nospace << ":" << prop->propertyType;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,15 +16,24 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/ArrayProperty.h"
using namespace Corrade;
using namespace Magnum;
class ArrayPropertySerialiser : public UnrealPropertySerialiser<ArrayProperty> {
public:
using ptr = Containers::Pointer<ArrayPropertySerialiser>;
private:
auto deserialiseProperty(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto deserialiseProperty(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialiseProperty(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

@ -16,17 +16,24 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/BoolProperty.h"
using namespace Corrade;
class BoolPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BoolPropertySerialiser>;
auto types() -> Containers::ArrayView<const std::string> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

@ -16,6 +16,9 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/ByteProperty.h"
@ -24,9 +27,11 @@ class BytePropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<BytePropertySerialiser>;
auto types() -> Containers::ArrayView<const std::string> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,9 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/EnumProperty.h"
@ -24,9 +27,11 @@ class EnumPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<EnumPropertySerialiser>;
auto types() -> Containers::ArrayView<const std::string> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

@ -16,6 +16,9 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/FloatProperty.h"
@ -24,9 +27,11 @@ class FloatPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<FloatPropertySerialiser>;
auto types() -> Containers::ArrayView<const std::string> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,6 +16,9 @@
// You should have received a copy of the GNU General Public License
// 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 "../Types/StringProperty.h"
@ -24,9 +27,11 @@ class StringPropertySerialiser : public AbstractUnrealPropertySerialiser {
public:
using ptr = Containers::Pointer<StringPropertySerialiser>;
auto types() -> Containers::ArrayView<const std::string> override;
auto types() -> Containers::ArrayView<const Containers::StringView> override;
auto deserialise(const std::string& name, const std::string& type, UnsignedLong value_length, BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto deserialise(Containers::StringView name, Containers::StringView type, UnsignedLong value_length,
BinaryReader& reader, PropertySerialiser& serialiser) -> UnrealPropertyBase::ptr override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer, PropertySerialiser& serialiser) -> bool override;
auto serialise(UnrealPropertyBase::ptr& prop, UnsignedLong& bytes_written, BinaryWriter& writer,
PropertySerialiser& serialiser) -> bool override;
};

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -16,12 +16,18 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
struct BoolProperty : public UnrealProperty<bool> {
using ptr = Containers::Pointer<BoolProperty>;
BoolProperty() {
propertyType = "BoolProperty";
using namespace Containers::Literals;
propertyType = "BoolProperty"_s;
}
};

View file

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

View file

@ -16,12 +16,18 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
struct ColourStructProperty : public StructProperty {
using ptr = Containers::Pointer<ColourStructProperty>;
ColourStructProperty() {
structType = "LinearColor";
using namespace Containers::Literals;
structType = "LinearColor"_s;
}
Float r = 0.0f, g = 0.0f, b = 0.0f, a = 0.0f;
};

View file

@ -16,13 +16,22 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
using namespace Magnum;
struct DateTimeStructProperty : public StructProperty {
using ptr = Containers::Pointer<DateTimeStructProperty>;
DateTimeStructProperty() {
structType = "DateTime";
using namespace Containers::Literals;
structType = "DateTime"_s;
}
UnsignedLong timestamp = 0;

View file

@ -16,14 +16,21 @@
// You should have received a copy of the GNU General Public License
// 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"
struct EnumProperty : public UnrealProperty<std::string> {
using namespace Corrade;
struct EnumProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<EnumProperty>;
EnumProperty() {
propertyType = "EnumProperty";
using namespace Containers::Literals;
propertyType = "EnumProperty"_s;
}
std::string enumType;
Containers::String enumType;
};

View file

@ -16,12 +16,21 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
using namespace Magnum;
struct FloatProperty : public UnrealProperty<Float> {
using ptr = Containers::Pointer<FloatProperty>;
FloatProperty() {
propertyType = "FloatProperty";
using namespace Containers::Literals;
propertyType = "FloatProperty"_s;
}
};

View file

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

View file

@ -16,15 +16,20 @@
// You should have received a copy of the GNU General Public License
// 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/StringView.h>
#include "StructProperty.h"
using namespace Corrade;
struct GuidStructProperty : public StructProperty {
using ptr = Containers::Pointer<GuidStructProperty>;
GuidStructProperty() {
structType = "Guid";
using namespace Containers::Literals;
structType = "Guid"_s;
}
Containers::StaticArray<16, char> guid{ValueInit};

View file

@ -16,12 +16,18 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
struct IntProperty : public UnrealProperty<Int> {
using ptr = Containers::Pointer<IntProperty>;
IntProperty() {
propertyType = "IntProperty";
using namespace Containers::Literals;
propertyType = "IntProperty"_s;
}
};

View file

@ -16,17 +16,24 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
struct MapProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<MapProperty>;
MapProperty() {
propertyType = "MapProperty";
using namespace Containers::Literals;
propertyType = "MapProperty"_s;
}
std::string keyType;
std::string valueType;
Containers::String keyType;
Containers::String valueType;
struct KeyValuePair {
UnrealPropertyBase::ptr key;

View file

@ -16,13 +16,19 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
struct NoneProperty : UnrealPropertyBase {
using ptr = Containers::Pointer<NoneProperty>;
NoneProperty() {
name.emplace("None");
propertyType = "NoneProperty";
using namespace Containers::Literals;
name.emplace("None"_s);
propertyType = "NoneProperty"_s;
}
};

View file

@ -16,13 +16,22 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
using namespace Magnum;
struct ResourceItemValue : public StructProperty {
using ptr = Containers::Pointer<ResourceItemValue>;
ResourceItemValue() {
structType = "sttResourceItemValue";
using namespace Containers::Literals;
structType = "sttResourceItemValue"_s;
structGuid = Containers::StaticArray<16, char>{'\xB7', '\xA7', '\x77', '\xAB', '\xD3', '\x1B', '\xA6', '\x43', '\xAF', '\x42', '\xE5', '\x9E', '\xBF', '\xFD', '\x37', '\x55'};
}

View file

@ -16,13 +16,22 @@
// You should have received a copy of the GNU General Public License
// 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"
using namespace Corrade;
using namespace Magnum;
struct RotatorStructProperty : public StructProperty {
using ptr = Containers::Pointer<RotatorStructProperty>;
RotatorStructProperty() {
structType = "Rotator";
using namespace Containers::Literals;
structType = "Rotator"_s;
}
Float x = 0.0f, y = 0.0f, z = 0.0f;

View file

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

View file

@ -16,12 +16,19 @@
// You should have received a copy of the GNU General Public License
// 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"
struct StringProperty : public UnrealProperty<std::string> {
using namespace Corrade;
using namespace Containers::Literals;
struct StringProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<StringProperty>;
explicit StringProperty(const std::string& type = "StrProperty") {
explicit StringProperty(Containers::StringView type = "StrProperty"_s) {
propertyType = type;
}
};

View file

@ -16,17 +16,23 @@
// You should have received a copy of the GNU General Public License
// 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/String.h>
#include <Corrade/Containers/StringView.h>
#include "UnrealPropertyBase.h"
using namespace Corrade;
struct StructProperty : public UnrealPropertyBase {
using ptr = Containers::Pointer<StructProperty>;
StructProperty() {
std::string propertyType = "StructProperty";
using namespace Containers::Literals;
propertyType = "StructProperty"_s;
}
Containers::StaticArray<16, char> structGuid{ValueInit};
std::string structType;
Containers::String structType;
};

View file

@ -16,16 +16,24 @@
// You should have received a copy of the GNU General Public License
// 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"
struct TextProperty : public UnrealProperty<std::string> {
using namespace Corrade;
struct TextProperty : public UnrealProperty<Containers::String> {
using ptr = Containers::Pointer<TextProperty>;
TextProperty() {
propertyType = "TextProperty";
using namespace Containers::Literals;
propertyType = "TextProperty"_s;
}
Containers::Array<char> flags;
char id = 0;
Containers::Array<std::string> data;
Containers::Array<Containers::String> data;
};

View file

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

View file

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

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