summaryrefslogtreecommitdiff
path: root/src/factories/sm64/MacroFactory.h
blob: 633646251ffa3b8581112ffb2fde8f30003c7895 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include "factories/BaseFactory.h"
#include "types/Vec3D.h"
#include "macro/MacroPresets.h"

namespace SM64 {

struct MacroObject {
    MacroPresets preset;
    int16_t yaw;
    int16_t posX;
    int16_t posY;
    int16_t posZ;
    int16_t behParam;
    MacroObject(MacroPresets preset, int16_t yaw, int16_t posX, int16_t posY, int16_t posZ, int16_t behParam) : preset(preset), yaw(yaw), posX(posX), posY(posY), posZ(posZ), behParam(behParam) {}
};

class MacroData : public IParsedData {
public:
    std::vector<MacroObject> mMacroData;

    MacroData(std::vector<MacroObject> macroData) : mMacroData(macroData) {}
};

class MacroDataAlt : public IParsedData {
public:
    std::vector<int16_t> mMacroData;

    MacroDataAlt(std::vector<int16_t> macroData) : mMacroData(macroData) {}
};

class MacroHeaderExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class MacroBinaryExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class MacroCodeExporter : public BaseExporter {
    ExportResult Export(std::ostream& write, std::shared_ptr<IParsedData> data, std::string& entryName, YAML::Node& node, std::string* replacement) override;
};

class MacroFactory : public BaseFactory {
public:
    bool CanPreviewCode() override { return true; }
    std::optional<std::shared_ptr<IParsedData>> parse(std::vector<uint8_t>& buffer, YAML::Node& data) override;
    inline std::unordered_map<ExportType, std::shared_ptr<BaseExporter>> GetExporters() override {
        return {
            REGISTER(Code, MacroCodeExporter)
            REGISTER(Header, MacroHeaderExporter)
            REGISTER(Binary, MacroBinaryExporter)
        };
    }
};
}