neptools

Modding tools to Neptunia games
git clone https://git.neptards.moe/neptards/neptools.git
Log | Files | Refs | Submodules | README | LICENSE

gbnl.hpp (1863B)


      1 #ifndef UUID_C8313FD1_2CD9_4882_BDAD_E751A14AA2DF
      2 #define UUID_C8313FD1_2CD9_4882_BDAD_E751A14AA2DF
      3 #pragma once
      4 
      5 #include "../item.hpp"
      6 #include "../gbnl.hpp"
      7 #include "file.hpp"
      8 
      9 namespace Neptools { class RawItem; }
     10 
     11 namespace Neptools::Stcm
     12 {
     13 
     14   class GbnlItem final : public Item, public Gbnl
     15   {
     16     LIBSHIT_DYNAMIC_OBJECT;
     17   public:
     18     GbnlItem(Key k, Context& ctx, Source src)
     19       : Item{k, ctx}, Gbnl{std::move(src)}
     20     { PostCtor(ctx); }
     21     GbnlItem(Key k, Context& ctx, Endian endian, bool is_gstl, uint32_t flags,
     22              uint32_t field_28, uint32_t field_30,
     23              Libshit::AT<Gbnl::Struct::TypePtr> type)
     24       : Item{k, ctx},
     25         Gbnl{endian, is_gstl, flags, field_28, field_30, std::move(type)}
     26     { PostCtor(ctx); }
     27 #if LIBSHIT_WITH_LUA
     28     GbnlItem(
     29       Key k, Context& ctx, Libshit::Lua::StateRef vm, Endian endian,
     30       bool is_gstl, uint32_t flags, uint32_t field_28, uint32_t field_30,
     31       Libshit::AT<Gbnl::Struct::TypePtr> type,
     32       Libshit::Lua::RawTable messages)
     33       : Item{k, ctx},
     34         Gbnl{vm, endian, is_gstl, flags, field_28, field_30, std::move(type),
     35              messages}
     36     { PostCtor(ctx); }
     37 #endif
     38 
     39     void Dispose() noexcept override;
     40 
     41     static GbnlItem& CreateAndInsert(ItemPointer ptr);
     42 
     43     void Fixup() override { Gbnl::Fixup(); }
     44     FilePosition GetSize() const noexcept override { return Gbnl::GetSize(); }
     45 
     46   private:
     47     void PostCtor(Context& ctx) noexcept
     48     {
     49       if (auto file = dynamic_cast<File*>(&ctx))
     50         file->SetGbnl(*this);
     51     }
     52 
     53     void Dump_(Sink& sink) const override { Gbnl::Dump_(sink); }
     54     void Inspect_(std::ostream& os, unsigned indent) const override
     55     { Item::Inspect_(os, indent); Gbnl::InspectGbnl(os, indent); }
     56   };
     57 
     58   inline Libshit::Lua::DynamicObject& GetDynamicObject(GbnlItem& item)
     59   { return static_cast<Item&>(item); }
     60 
     61 }
     62 #endif