2019-07-13 13:58:44 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2019-07-13 14:56:21 +00:00
|
|
|
|
using System.IO;
|
2019-07-13 13:58:44 +00:00
|
|
|
|
using System.Threading.Tasks;
|
2019-07-16 21:35:21 +00:00
|
|
|
|
using Toolbox.Library;
|
|
|
|
|
using Toolbox.Library.IO;
|
|
|
|
|
using Toolbox.Library.Forms;
|
2019-07-13 14:56:21 +00:00
|
|
|
|
using ByamlExt.Byaml;
|
|
|
|
|
using OdysseyEditor;
|
2019-07-13 15:55:53 +00:00
|
|
|
|
using FirstPlugin.Forms;
|
2019-07-13 13:58:44 +00:00
|
|
|
|
|
|
|
|
|
namespace FirstPlugin
|
|
|
|
|
{
|
2019-07-13 14:56:21 +00:00
|
|
|
|
//Code off of https://github.com/exelix11/OdysseyEditor
|
|
|
|
|
//Note this will purely be for viewing, performance tests, and ripping
|
2019-07-13 13:58:44 +00:00
|
|
|
|
public class SMO_Scene
|
|
|
|
|
{
|
2019-07-13 14:56:21 +00:00
|
|
|
|
public static void LoadStage(string MapName)
|
|
|
|
|
{
|
2019-07-13 15:55:53 +00:00
|
|
|
|
string StageByml = $"{Runtime.SmoGamePath}\\StageData\\{MapName}Map.szs";
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"{StageByml} {File.Exists($"{StageByml}")}");
|
|
|
|
|
if (File.Exists($"{StageByml}"))
|
|
|
|
|
{
|
|
|
|
|
var TextureSzs = $"{Runtime.SmoGamePath}\\ObjectData\\{MapName}Texture.szs";
|
|
|
|
|
|
|
|
|
|
ObjectEditor editor = new ObjectEditor();
|
|
|
|
|
LibraryGUI.CreateMdiWindow(editor);
|
|
|
|
|
|
|
|
|
|
var level = new Level(StageByml, -1);
|
|
|
|
|
foreach (var obj in level.objs)
|
|
|
|
|
{
|
|
|
|
|
foreach (var ob in obj.Value)
|
|
|
|
|
{
|
|
|
|
|
var Transform = Utils.TransformValues(ob.transform.Pos, ob.transform.Rot, ob.transform.Scale);
|
|
|
|
|
|
|
|
|
|
var bfresData = BfresFromSzs(ob.Name);
|
|
|
|
|
|
|
|
|
|
if (bfresData != null)
|
|
|
|
|
{
|
2019-09-15 23:13:01 +00:00
|
|
|
|
BFRES bfresFile = (BFRES)STFileLoader.OpenFileFormat(new MemoryStream(bfresData), ob.Name);
|
2019-07-13 15:55:53 +00:00
|
|
|
|
bfresFile.BFRESRender.ModelTransform = Transform;
|
|
|
|
|
|
|
|
|
|
editor.AddNode(bfresFile);
|
|
|
|
|
bfresFile.LoadEditors(null);
|
|
|
|
|
DiableLoadCheck();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TextureSzs = null;
|
|
|
|
|
GC.Collect();
|
|
|
|
|
}
|
2019-07-21 18:09:25 +00:00
|
|
|
|
|
|
|
|
|
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
|
|
|
|
|
bfresEditor.DisplayAll = true;
|
2019-07-13 15:55:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void DiableLoadCheck()
|
|
|
|
|
{
|
|
|
|
|
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
|
|
|
|
|
bfresEditor.IsLoaded = false;
|
|
|
|
|
bfresEditor.DisplayAllDDrawables();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static byte[] BfresFromSzs(string fileName)
|
|
|
|
|
{
|
|
|
|
|
if (File.Exists($"{Runtime.SmoGamePath}\\ObjectData\\{fileName}.szs"))
|
2019-07-13 14:56:21 +00:00
|
|
|
|
{
|
2019-07-13 15:55:53 +00:00
|
|
|
|
var SzsFiles = SARCExt.SARC.UnpackRamN(EveryFileExplorer.YAZ0.Decompress($"{Runtime.SmoGamePath}\\ObjectData\\{fileName}.szs")).Files;
|
|
|
|
|
if (SzsFiles.ContainsKey(fileName + ".bfres"))
|
|
|
|
|
{
|
|
|
|
|
return SzsFiles[fileName + ".bfres"];
|
|
|
|
|
}
|
2019-07-13 14:56:21 +00:00
|
|
|
|
}
|
2019-07-13 15:55:53 +00:00
|
|
|
|
return null;
|
2019-07-13 14:56:21 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Dictionary<string, string> OdysseyStages = new Dictionary<string, string>()
|
2019-07-13 13:58:44 +00:00
|
|
|
|
{
|
|
|
|
|
//Main
|
|
|
|
|
{ "CapWorldHomeStage","Cap Kingdom" },
|
|
|
|
|
{ "WaterfallWorldHomeStage","Cascade Kingdom" },
|
|
|
|
|
{ "SandWorldHomeStage","Sand Kindom" },
|
2019-07-13 14:56:21 +00:00
|
|
|
|
{ "ForestWorldHomeStage","Wodded Kingdom" },
|
2019-07-13 13:58:44 +00:00
|
|
|
|
{ "SnowWorldHomeStage","Snow Kingdom" },
|
|
|
|
|
{ "SeaWorldHomeStage", "Seaside Kingdom" },
|
|
|
|
|
{ "ClashWorldHomeStage","Lost Kingdom" },
|
|
|
|
|
{ "CityWorldHomeStage","Metro Kingdom" },
|
|
|
|
|
{ "LakeWorldHomeStage","Lake Kingdom(Starting Area)" },
|
|
|
|
|
{ "SkyWorldHomeStage","Bowser\'s Kingdom" },
|
|
|
|
|
{ "BossRaidWorldHomeStage","Ruined Kingdom" },
|
|
|
|
|
{ "MoonWorldHomeStage","Moon Kingdom" },
|
|
|
|
|
{ "LavaWorldHomeStage","Luncheon Kingdom" },
|
|
|
|
|
{"PeachWorldHomeStage", "Mushroom Kingdom" },
|
|
|
|
|
|
|
|
|
|
{"Special1WorldHomeStage", "Dark Side of the Moon"},
|
|
|
|
|
{"Special2WorldHomeStage", "Darker Side of the Moon"},
|
|
|
|
|
|
|
|
|
|
//Sub areas
|
|
|
|
|
{ "MeganeLiftExStage","MoEye moving Platform" },
|
|
|
|
|
{ "SandWorldPyramid000Stage","Pyramid(Starting Area)" },
|
|
|
|
|
{ "SandWorldPyramid001Stage","Pyramid(Bullet Bill Parkour)" },
|
|
|
|
|
{ "SandWorldUnderground000Stage","Ice Underground before Boss" },
|
|
|
|
|
{ "SandWorldUnderground001Stage","Ice Underground Boss" },
|
|
|
|
|
{ "LakeWorldTownZone","LakeKingdom (Town Area)" },
|
|
|
|
|
{ "DemoCrashHomeFallStage","Cloud Kingdom(1. Bowser Fight)" },
|
|
|
|
|
{ "Theater2DExStage","Theater (smb 1-1)" },
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|