Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map Editor MultiSDS support #117

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Mafia2Libs/Core/IO/FileFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public static FileBase ConstructFromFileInfo(FileInfo info)
break;
case "FR":
return new FileFrameResource(info);
case "MES":
return new MapEditorSession(info);
case "MTL":
return new FileMaterialLibrary(info);
case "LUA":
Expand Down
62 changes: 62 additions & 0 deletions Mafia2Libs/Core/IO/FileMapEditorSession.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using Mafia2Tool;
using System;
using System.IO;

namespace Core.IO
{
public class MapEditorSession : FileBase
{
private bool bForceBigEndian;

public MapEditorSession(FileInfo info) : base(info)
{
}

public override bool Open()
{
//make sure to load materials.
MaterialData.Load();

//we now build scene data from GameExplorer rather than d3d viewer.
string[] scenepaths = ReadMESScenePaths();

MapEditor d3dForm = new MapEditor(file,scenepaths);
d3dForm.Dispose();
return true;
}

public override void Save()
{
throw new NotImplementedException();
}

public override string GetExtensionUpper()
{
return "MES";
}

private string[] ReadMESScenePaths()
{
// Otevření streamu pro čtení souboru
byte[] fileData = File.ReadAllBytes(file.FullName);
using (var ms = new MemoryStream(fileData))
using (var reader = new BinaryReader(ms))
{
int version = reader.ReadInt32();
int numberOfScenes = reader.ReadInt32();

string[] scenePaths = new string[numberOfScenes];

for (int i = 0; i < numberOfScenes; i++)
{
int stringLength = reader.ReadInt32();

scenePaths[i] = new string(reader.ReadChars(stringLength));
}

return scenePaths;
}
}

}
}
15 changes: 15 additions & 0 deletions Mafia2Libs/Forms/Docking/DockSceneTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,21 @@ public bool ObjectGroupHasObject(TreeNode ogNode, ulong frameRefHash)
}
return false;
}

public TreeNode GetSceneDataTreeNode(string ScenePath)
{

for (int i = 0; i < TreeView_Explorer.Nodes.Count; i++)
{
if (TreeView_Explorer.Nodes[i].Text.Equals(ScenePath))
{
return TreeView_Explorer.Nodes[i];
}
}

// We have failed, return null.
return null;
}
}
}
public class TreeViewDragEventArgs : EventArgs
Expand Down
22 changes: 20 additions & 2 deletions Mafia2Libs/Forms/MapEditor.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading