IW4 dump simple menu file fields

This commit is contained in:
Jan
2021-08-27 23:08:05 +02:00
parent 636034d87c
commit 163ac55fed
9 changed files with 561 additions and 2 deletions

View 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";
}

View 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;
};