0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-19 07:59:47 +03:00

texm viewer

This commit is contained in:
bird_egop
2024-11-18 23:48:42 +03:00
parent f9f89d9703
commit 08c8d07d91
17 changed files with 403 additions and 227 deletions

View File

@ -4,17 +4,20 @@ using NativeFileDialogSharp;
using NResLib;
using NResUI.Abstractions;
using NResUI.Models;
using TexmLib;
namespace NResUI.ImGuiUI
{
public class MainMenuBar : IImGuiPanel
{
private readonly ExplorerViewModel _explorerViewModel;
private readonly NResExplorerViewModel _nResExplorerViewModel;
private readonly TexmExplorerViewModel _texmExplorerViewModel;
private readonly MessageBoxModalPanel _messageBox;
public MainMenuBar(ExplorerViewModel explorerViewModel, MessageBoxModalPanel messageBox)
public MainMenuBar(NResExplorerViewModel nResExplorerViewModel, TexmExplorerViewModel texmExplorerViewModel, MessageBoxModalPanel messageBox)
{
_explorerViewModel = explorerViewModel;
_nResExplorerViewModel = nResExplorerViewModel;
_texmExplorerViewModel = texmExplorerViewModel;
_messageBox = messageBox;
}
@ -34,11 +37,29 @@ namespace NResUI.ImGuiUI
var parseResult = NResParser.ReadFile(path);
_explorerViewModel.SetParseResult(parseResult, path);
_nResExplorerViewModel.SetParseResult(parseResult, path);
Console.WriteLine("Read NRES");
}
}
if (_explorerViewModel.HasFile)
if (ImGui.MenuItem("Open TEXM"))
{
var result = Dialog.FileOpen();
if (result.IsOk)
{
var path = result.Path;
using var fs = new FileStream(path, FileMode.Open);
var parseResult = TexmParser.ReadFromStream(fs, path);
_texmExplorerViewModel.SetParseResult(parseResult, path);
Console.WriteLine("Read TEXM");
}
}
if (_nResExplorerViewModel.HasFile)
{
if (ImGui.MenuItem("Экспортировать"))
{
@ -48,32 +69,13 @@ namespace NResUI.ImGuiUI
{
var path = result.Path;
NResExporter.Export(_explorerViewModel.Archive!, path, _explorerViewModel.Path!);
NResExporter.Export(_nResExplorerViewModel.Archive!, path, _nResExplorerViewModel.Path!);
_messageBox.Show("Успешно экспортировано");
}
}
}
if (ImGui.BeginMenu("Open Recent"))
{
ImGui.EndMenu();
}
if (ImGui.MenuItem("Exit"))
{
App.Instance.Exit();
}
ImGui.EndMenu();
}
if (ImGui.BeginMenu("Windows"))
{
if (ImGui.MenuItem("Settings"))
{
}
ImGui.EndMenu();
}

View File

@ -4,18 +4,18 @@ using NResUI.Models;
namespace NResUI.ImGuiUI;
public class ExplorerPanel : IImGuiPanel
public class NResExplorerPanel : IImGuiPanel
{
private readonly ExplorerViewModel _viewModel;
private readonly NResExplorerViewModel _viewModel;
public ExplorerPanel(ExplorerViewModel viewModel)
public NResExplorerPanel(NResExplorerViewModel viewModel)
{
_viewModel = viewModel;
}
public void OnImGuiRender()
{
if (ImGui.Begin("Explorer"))
if (ImGui.Begin("NRes Explorer"))
{
if (!_viewModel.HasFile)
{

View File

@ -0,0 +1,73 @@
using ImGuiNET;
using NResUI.Abstractions;
using NResUI.Models;
namespace NResUI.ImGuiUI;
public class TexmExplorer : IImGuiPanel
{
private readonly TexmExplorerViewModel _viewModel;
public TexmExplorer(TexmExplorerViewModel viewModel)
{
_viewModel = viewModel;
}
public void OnImGuiRender()
{
if (ImGui.Begin("TEXM Explorer"))
{
if (!_viewModel.HasFile)
{
ImGui.Text("No TEXM opened");
}
else
{
if (_viewModel.TexmFile is not null)
{
ImGui.Text("File: ");
ImGui.SameLine();
ImGui.Text(_viewModel.Path);
ImGui.Text("Header: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.TexmAscii);
ImGui.Text("Width: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Width.ToString());
ImGui.Text("Height: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Height.ToString());
ImGui.Text("MipMap Count: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.MipmapCount.ToString());
ImGui.Text("Stride: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Stride.ToString());
ImGui.Text("Magic1: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Magic1.ToString());
ImGui.Text("Magic2: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Magic2.ToString());
ImGui.Text("Format: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.Header.Format.ToString());
ImGui.Text("IsIndexed: ");
ImGui.SameLine();
ImGui.Text(_viewModel.TexmFile.IsIndexed.ToString());
}
}
ImGui.End();
}
}
}