mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-10 14:58:10 -05:00
IW4 dump simple menu file fields
This commit is contained in:
47
src/ObjWriting/Menu/MenuDumper.cpp
Normal file
47
src/ObjWriting/Menu/MenuDumper.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include "MenuDumper.h"
|
||||
|
||||
MenuDumper::MenuDumper(std::ostream& stream)
|
||||
: m_stream(stream),
|
||||
m_indent(0u)
|
||||
{
|
||||
}
|
||||
|
||||
void MenuDumper::IncIndent()
|
||||
{
|
||||
m_indent++;
|
||||
}
|
||||
|
||||
void MenuDumper::DecIndent()
|
||||
{
|
||||
if (m_indent > 0)
|
||||
m_indent--;
|
||||
}
|
||||
|
||||
void MenuDumper::Indent() const
|
||||
{
|
||||
for (auto i = 0u; i < m_indent; i++)
|
||||
m_stream << " ";
|
||||
}
|
||||
|
||||
void MenuDumper::Start()
|
||||
{
|
||||
Indent();
|
||||
m_stream << "{\n";
|
||||
IncIndent();
|
||||
}
|
||||
|
||||
void MenuDumper::End()
|
||||
{
|
||||
for (auto i = 0u; i < m_indent; i++)
|
||||
{
|
||||
DecIndent();
|
||||
Indent();
|
||||
m_stream << "}\n";
|
||||
}
|
||||
}
|
||||
|
||||
void MenuDumper::IncludeMenu(const std::string& menuPath) const
|
||||
{
|
||||
Indent();
|
||||
m_stream << "loadMenu { \"" << menuPath << "\" }\n";
|
||||
}
|
23
src/ObjWriting/Menu/MenuDumper.h
Normal file
23
src/ObjWriting/Menu/MenuDumper.h
Normal file
@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
|
||||
class MenuDumper
|
||||
{
|
||||
protected:
|
||||
std::ostream& m_stream;
|
||||
size_t m_indent;
|
||||
|
||||
void IncIndent();
|
||||
void DecIndent();
|
||||
void Indent() const;
|
||||
|
||||
public:
|
||||
explicit MenuDumper(std::ostream& stream);
|
||||
|
||||
void Start();
|
||||
void End();
|
||||
|
||||
void IncludeMenu(const std::string& menuPath) const;
|
||||
};
|
Reference in New Issue
Block a user