GameConfig.cfg generation for trenchbroom available in the menubar

This commit is contained in:
Antoine Pilote
2024-04-29 00:59:12 -04:00
parent b9c5aca688
commit 5166dd878f
3 changed files with 119 additions and 24 deletions

View File

@@ -33,4 +33,102 @@ namespace NuakeEditor
return true;
}
bool CreateTrenchbroomGameConfig::Execute()
{
const std::string& cleanProjectName = String::Sanitize(mProject->Name);
const std::string& gameConfigPath = mProject->TrenchbroomPath + "/../games/" + cleanProjectName + "/GameConfig.cfg";
FileSystem::BeginWriteFile(gameConfigPath, true);
std::string templateFile = R"(
{
"version": 8,
"name": ")" + cleanProjectName + R"(",
"icon": "Icon.png",
"experimental": true,
"fileformats": [
{ "format": "Valve" }, { "format": "Standard" }
],
"filesystem": {
"searchpath": "",
"packageformat": { "extension": ".zip", "format": "zip" }
},
"textures": {
"root": "textures",
"extensions": [ ".jpg", ".png", ".tga" ]
},
"entities": {
"definitions": [ ")" + cleanProjectName + R"(.fgd" ],
"defaultcolor": "0.6 0.6 0.6 1.0"
},
"tags": {
"brush": [
{
"name": "Trigger",
"attribs": [ "transparent" ],
"match": "classname",
"pattern": "trigger_*",
"texture": "trigger"
}
],
"brushface": [
{
"name": "Caulk",
"attribs": [ "transparent" ],
"match": "texture",
"pattern": "*caulk"
},
{
"name": "Clip",
"attribs": [ "transparent" ],
"match": "surfaceparm",
"pattern": [ "playerclip", "monsterclip" ]
},
{
"name": "Detail",
"match": "contentflag",
"flags": [ "detail" ]
},
{
"name": "Hint",
"attribs": [ "transparent" ],
"match": "texture",
"pattern": "common/hint*"
},
{
"name": "Liquid",
"match": "surfaceparm",
"pattern": [ "water", "lava", "slime" ]
},
{
"name": "Skip",
"attribs": [ "transparent" ],
"match": "texture",
"pattern": "common/*skip"
},
{
"name": "Translucent",
"attribs": [ "transparent" ],
"match": "surfaceparm",
"pattern": [ "trans", "fog" ]
}
]
},
"faceattribs": {
"defaults": {
"scale": [1.0, 1.0]
},
"surfaceflags": [],
"contentflags": [
]
},
"softMapBounds":"-65536 -65536 -65536 65536 65536 65536"
}
)";
FileSystem::WriteLine(templateFile);
FileSystem::EndWriteFile();
return true;
}
}

View File

@@ -46,4 +46,18 @@ namespace NuakeEditor {
bool Execute() override;
};
class CreateTrenchbroomGameConfig : public ICommand
{
private:
Ref<Project> mProject;
public:
CreateTrenchbroomGameConfig(Ref<Project> project) :
mProject(project)
{
}
bool Execute() override;
};
}

View File

@@ -2027,30 +2027,6 @@ namespace Nuake {
ImGui::SetNextWindowPos(window_pos, ImGuiCond_Always, window_pos_pivot);
ImGui::SetNextWindowViewport(viewport->ID);
}
ImGui::SetNextWindowBgAlpha(0.35f); // Transparent background
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 32.0f);
if (ImGui::Begin("Example: Simple overlay", &m_ShowOverlay, window_flags))
{
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 100);
if (ImGui::Button(ICON_FA_ARROWS_ALT) || Input::IsKeyDown(Key::W))
{
CurrentOperation = ImGuizmo::OPERATION::TRANSLATE;
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_SYNC_ALT) || Input::IsKeyDown(Key::E))
{
CurrentOperation = ImGuizmo::OPERATION::ROTATE;
}
ImGui::SameLine();
if (ImGui::Button(ICON_FA_EXPAND_ALT) || Input::IsKeyDown(Key::R))
{
CurrentOperation = ImGuizmo::OPERATION::SCALE;
}
ImGui::PopStyleVar();
}
ImGui::PopStyleVar();
ImGui::End();
int corner2 = 1;
window_flags |= ImGuiWindowFlags_NoMove;
@@ -2318,6 +2294,7 @@ namespace Nuake {
SetStatusMessage("Visual studio solution generated succesfully.");
}
#ifdef NK_DEBUG
if (ImGui::MenuItem("Copy Nuake.NET", NULL))
{
@@ -2339,6 +2316,12 @@ namespace Nuake {
Nuake::Logger::Log("Shaders Rebuilt.");
SetStatusMessage("Shaders rebuilt.");
}
if (ImGui::MenuItem("Create trenchbroom config", NULL))
{
PushCommand(CreateTrenchbroomGameConfig(Engine::GetProject()));
}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Quit")) ImGui::EndMenu();