1
0
mirror of synced 2024-12-05 04:17:59 +01:00
Switch-Toolbox/File_Format_Library/Scenes/SMO_Scene.cs

113 lines
4.4 KiB
C#
Raw Normal View History

2019-07-13 15:58:44 +02:00
using System;
using System.Collections.Generic;
using System.Linq;
2019-07-13 16:56:21 +02:00
using System.IO;
2019-07-13 15:58:44 +02:00
using System.Threading.Tasks;
using Toolbox.Library;
using Toolbox.Library.IO;
using Toolbox.Library.Forms;
2019-07-13 16:56:21 +02:00
using ByamlExt.Byaml;
using OdysseyEditor;
2019-07-13 17:55:53 +02:00
using FirstPlugin.Forms;
2019-07-13 15:58:44 +02:00
namespace FirstPlugin
{
2019-07-13 16:56:21 +02:00
//Code off of https://github.com/exelix11/OdysseyEditor
//Note this will purely be for viewing, performance tests, and ripping
2019-07-13 15:58:44 +02:00
public class SMO_Scene
{
2019-07-13 16:56:21 +02:00
public static void LoadStage(string MapName)
{
2019-07-13 17:55:53 +02: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)
{
BFRES bfresFile = (BFRES)STFileLoader.OpenFileFormat(ob.Name, bfresData);
bfresFile.BFRESRender.ModelTransform = Transform;
editor.AddNode(bfresFile);
bfresFile.LoadEditors(null);
DiableLoadCheck();
}
}
}
TextureSzs = null;
GC.Collect();
}
2019-07-21 20:09:25 +02:00
BfresEditor bfresEditor = (BfresEditor)LibraryGUI.GetActiveContent(typeof(BfresEditor));
bfresEditor.DisplayAll = true;
2019-07-13 17:55:53 +02: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 16:56:21 +02:00
{
2019-07-13 17:55:53 +02: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 16:56:21 +02:00
}
2019-07-13 17:55:53 +02:00
return null;
2019-07-13 16:56:21 +02:00
}
public static Dictionary<string, string> OdysseyStages = new Dictionary<string, string>()
2019-07-13 15:58:44 +02:00
{
//Main
{ "CapWorldHomeStage","Cap Kingdom" },
{ "WaterfallWorldHomeStage","Cascade Kingdom" },
{ "SandWorldHomeStage","Sand Kindom" },
2019-07-13 16:56:21 +02:00
{ "ForestWorldHomeStage","Wodded Kingdom" },
2019-07-13 15:58:44 +02: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)" },
};
}
}