mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-08-25 19:55:50 +00:00
VideoCommon: add graphics mod editor control for mesh assets
This commit is contained in:
parent
1aa85c12bd
commit
3e5ee5db65
2 changed files with 102 additions and 0 deletions
|
@ -0,0 +1,71 @@
|
||||||
|
// Copyright 2023 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#include "VideoCommon/GraphicsModEditor/Controls/MeshControl.h"
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
|
#include "VideoCommon/Assets/TextureAsset.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/Controls/AssetDisplay.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/EditorEvents.h"
|
||||||
|
|
||||||
|
namespace GraphicsModEditor::Controls
|
||||||
|
{
|
||||||
|
MeshControl::MeshControl(EditorState& state) : m_state(state)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void MeshControl::DrawImGui(const VideoCommon::CustomAssetLibrary::AssetID& asset_id,
|
||||||
|
VideoCommon::MeshData* mesh_data, const std::filesystem::path& path,
|
||||||
|
VideoCommon::CustomAsset::TimeType* last_data_write,
|
||||||
|
AbstractTexture* mesh_preview)
|
||||||
|
{
|
||||||
|
if (ImGui::BeginTable("MeshForm", 2))
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("ID");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", asset_id.c_str());
|
||||||
|
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("Name");
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::TextWrapped("%s", PathToString(path.stem()).c_str());
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::CollapsingHeader("Materials", ImGuiTreeNodeFlags_DefaultOpen))
|
||||||
|
{
|
||||||
|
if (ImGui::BeginTable("MeshMaterialsForm", 2))
|
||||||
|
{
|
||||||
|
for (auto& [mesh_material, material_asset_id] :
|
||||||
|
mesh_data->m_mesh_material_to_material_asset_id)
|
||||||
|
{
|
||||||
|
ImGui::TableNextRow();
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
ImGui::Text("%s", mesh_material.c_str());
|
||||||
|
ImGui::TableNextColumn();
|
||||||
|
|
||||||
|
if (AssetDisplay(mesh_material, &m_state, &material_asset_id,
|
||||||
|
AssetDataType::RasterMaterial))
|
||||||
|
{
|
||||||
|
*last_data_write = VideoCommon::CustomAsset::ClockType::now();
|
||||||
|
GraphicsModEditor::EditorEvents::AssetReloadEvent::Trigger(material_asset_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ImGui::EndTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mesh_preview)
|
||||||
|
{
|
||||||
|
const auto ratio = mesh_preview->GetWidth() / mesh_preview->GetHeight();
|
||||||
|
ImGui::Image(*mesh_preview, ImVec2{ImGui::GetContentRegionAvail().x,
|
||||||
|
ImGui::GetContentRegionAvail().x * ratio});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // namespace GraphicsModEditor::Controls
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright 2023 Dolphin Emulator Project
|
||||||
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
|
#include "VideoCommon/Assets/CustomAsset.h"
|
||||||
|
#include "VideoCommon/GraphicsModEditor/EditorState.h"
|
||||||
|
|
||||||
|
namespace VideoCommon
|
||||||
|
{
|
||||||
|
class AbstractTexture;
|
||||||
|
struct MeshData;
|
||||||
|
} // namespace VideoCommon
|
||||||
|
|
||||||
|
namespace GraphicsModEditor::Controls
|
||||||
|
{
|
||||||
|
class MeshControl
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit MeshControl(EditorState& state);
|
||||||
|
void DrawImGui(const VideoCommon::CustomAssetLibrary::AssetID& asset_id,
|
||||||
|
VideoCommon::MeshData* mesh_data, const std::filesystem::path& path,
|
||||||
|
VideoCommon::CustomAsset::TimeType* last_data_write,
|
||||||
|
AbstractTexture* texture_preview);
|
||||||
|
|
||||||
|
private:
|
||||||
|
EditorState& m_state;
|
||||||
|
};
|
||||||
|
} // namespace GraphicsModEditor::Controls
|
Loading…
Add table
Add a link
Reference in a new issue