Start on SMO kingdom loading

This commit is contained in:
KillzXGaming 2019-07-13 10:56:21 -04:00
parent 384185ab4a
commit 716e2c254f
15 changed files with 1295 additions and 3 deletions

Binary file not shown.

View file

@ -95,12 +95,21 @@ namespace FirstPlugin
public MenuExt()
{
toolsExt[0] = new STToolStripItem("Super Mario Odyssey");
toolsExt[0].DropDownItems.Add(new STToolStripItem(" Kingdom Selector", OpenKingdomSelector));
toolsExt[0].DropDownItems.Add(new STToolStripItem(" Costume Selector", OpenSelector));
toolsExt[1] = new STToolStripItem("Mario Kart 8");
toolsExt[1].DropDownItems.Add(new STToolStripItem("Probe Light Converter", GenerateProbeLightBounds));
}
private void OpenKingdomSelector(object sender, EventArgs args)
{
SceneSelector sceneSelect = new SceneSelector();
sceneSelect.LoadDictionary(SMO_Scene.OdysseyStages);
if (sceneSelect.ShowDialog() == DialogResult.OK)
SMO_Scene.LoadStage(sceneSelect.SelectedFile);
}
private void GenerateProbeLightBounds(object sender, EventArgs args) {
AAMP.GenerateProbeBoundings();
}

View file

@ -0,0 +1,230 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Xml;
using System.Diagnostics;
using System.Drawing;
using OpenTK;
namespace OdysseyEditor
{
static class InputDialog
{
public static DialogResult Show(string title, string promptText, ref string value)
{
Form form = new Form();
Label label = new Label();
TextBox textBox = new TextBox();
Button buttonOk = new Button();
Button buttonCancel = new Button();
form.Text = title;
label.Text = promptText;
textBox.Text = value;
buttonOk.Text = "OK";
buttonCancel.Text = "Cancel";
buttonOk.DialogResult = DialogResult.OK;
buttonCancel.DialogResult = DialogResult.Cancel;
label.SetBounds(9, 20, 372, 13);
textBox.SetBounds(12, 36, 372, 20);
buttonOk.SetBounds(228, 72, 75, 23);
buttonCancel.SetBounds(309, 72, 75, 23);
label.AutoSize = true;
textBox.Anchor = textBox.Anchor | AnchorStyles.Right;
buttonOk.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
form.ClientSize = new Size(396, 107);
form.Controls.AddRange(new Control[] { label, textBox, buttonOk, buttonCancel });
form.ClientSize = new Size(Math.Max(300, label.Right + 10), form.ClientSize.Height);
form.FormBorderStyle = FormBorderStyle.FixedDialog;
form.StartPosition = FormStartPosition.CenterScreen;
form.MinimizeBox = false;
form.MaximizeBox = false;
form.AcceptButton = buttonOk;
form.CancelButton = buttonCancel;
DialogResult dialogResult = form.ShowDialog();
value = textBox.Text;
return dialogResult;
}
}
static class DeepCloneDictArr
{
public static Dictionary<string, dynamic> DeepClone(Dictionary<string, dynamic> d)
{
var res = new Dictionary<string, dynamic>();
foreach (string k in d.Keys)
{
if (d[k] is Dictionary<string, dynamic> || d[k] is List<dynamic>)
res.Add(k, DeepClone(d[k]));
else if (d[k] is ICloneable)
res.Add(k, d[k].Clone());
else res.Add(k, d[k]);
}
return res;
}
public static List<dynamic> DeepClone(List<dynamic> l)
{
var res = new List<dynamic>();
foreach (var o in l)
{
if (o is Dictionary<string, dynamic> || o is List<dynamic>)
res.Add(DeepClone(o));
else if (o is ICloneable)
res.Add(o.Clone());
else res.Add(o);
}
return res;
}
}
class CustomStringWriter : System.IO.StringWriter
{
private readonly Encoding encoding;
public CustomStringWriter(Encoding encoding)
{
this.encoding = encoding;
}
public override Encoding Encoding
{
get { return encoding; }
}
}
public class CustomStack<T> : IEnumerable<T>
{
private List<T> items = new List<T>();
public int MaxItems = 50;
public int Count
{ get { return items.Count(); } }
public void Remove(int index)
{
items.RemoveAt(index);
}
public void Push(T item)
{
items.Add(item);
if (items.Count > MaxItems)
{
for (int i = MaxItems; i < items.Count; i++) Remove(0);
}
}
public T Pop()
{
if (items.Count > 0)
{
T tmp = items[items.Count - 1];
items.RemoveAt(items.Count - 1);
return tmp;
}
else return default(T);
}
public void RemoveAt(int index) => items.RemoveAt(index);
public T Peek() { return items[items.Count - 1]; }
public T[] ToArray()
{
return items.ToArray();
}
public void Clear()
{
items.Clear();
}
public IEnumerator<T> GetEnumerator()
{
return items.GetEnumerator();
}
IEnumerator IEnumerable.GetEnumerator()
{
return items.GetEnumerator();
}
}
public class UndoAction
{
public string actionName;
public Action<dynamic> _act;
public dynamic _arg;
public void Undo()
{
_act.Invoke(_arg);
}
public override string ToString()
{
return actionName;
}
public UndoAction(string name, Action<dynamic> Act, dynamic arg)
{
actionName = name;
_act = Act;
_arg = arg;
}
}
public class ClipBoardItem
{
public enum ClipboardType
{
NotSet = 0,
Position = 1,
Rotation = 2,
Scale = 3,
IntArray = 4,
Objects = 5,
Transform = 8,
}
public Transform transform;
public int[] Args = null;
public ClipboardType Type = 0;
public LevelObj[] Objs = null;
public override string ToString()
{
switch (Type)
{
case ClipboardType.Position:
return $"Position - {transform.Pos}";
case ClipboardType.Rotation:
return $"Rotation - {transform.Rot}";
case ClipboardType.Scale:
return $"Scale - {transform.Scale}";
case ClipboardType.IntArray:
return "Args[]";
case ClipboardType.Transform:
return $"Transform - Pos {transform.Pos}, Rot {transform.Rot}, Scale {transform.Scale}";
case ClipboardType.Objects:
return "Object[" + Objs.Length.ToString() + "]";
default:
return "Not set";
}
}
}
}

View file

@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using SARCExt;
using ByamlExt.Byaml;
using EveryFileExplorer;
namespace OdysseyEditor
{
public class ObjList : List<LevelObj>
{
IList<dynamic> bymlNode;
public ObjList(string _name, IList<dynamic> _bymlNode)
{
name = _name;
if (_bymlNode == null)
{
bymlNode = new List<dynamic>();
return;
}
bymlNode = _bymlNode;
foreach (var o in bymlNode) this.Add(new LevelObj(o));
}
public void ApplyToNode()
{
bymlNode.Clear();
foreach (var o in this) bymlNode.Add(o.Prop);
}
public bool IsHidden = false;
public string name = "";
}
public class Level
{
public Dictionary<string, byte[]> SzsFiles;
public Dictionary<string, ObjList> objs = new Dictionary<string, ObjList>();
dynamic LoadedByml = null;
public string Filename = "";
int _ScenarioIndex = -1;
public Level(bool empty, string levelN)
{
if (!empty) throw new Exception();
SzsFiles = new Dictionary<string, byte[]>();
Filename = levelN;
LoadedByml = new dynamic[15];
for (int i = 0; i < 15; i++)
LoadedByml[i] = new Dictionary<string, dynamic>();
// SzsFiles.Add(Path.GetFileNameWithoutExtension(Filename) + ".byml", ByamlFile.SaveN(LoadedByml,false, Syroot.BinaryData.ByteOrder.LittleEndian));
LoadObjects();
}
public Level (string path, int scenarioIndex = -1)
{
Filename = path;
Load(File.ReadAllBytes(path), scenarioIndex);
}
void Load(byte[] file, int scenarioIndex = -1)
{
SzsFiles = SARC.UnpackRamN(YAZ0.Decompress(file)).Files;
LoadObjects(scenarioIndex);
}
void LoadObjects(int scenarioIndex = -1)
{
Stream s = new MemoryStream(SzsFiles[Path.GetFileNameWithoutExtension(Filename) + ".byml"]);
LoadedByml = ByamlFile.LoadN(s,false, Syroot.BinaryData.ByteOrder.LittleEndian);
if (scenarioIndex == -1)
{
string res = "0";
InputDialog.Show("Select scenario", $"enter scenario value [0,{LoadedByml.Count- 1}]", ref res);
if (!int.TryParse(res, out scenarioIndex)) scenarioIndex = 0;
}
_ScenarioIndex = scenarioIndex;
var Scenario = (Dictionary<string, dynamic>)LoadedByml[scenarioIndex];
if (Scenario.Keys.Count == 0)
Scenario.Add("ObjectList", new List<dynamic>());
foreach (string k in Scenario.Keys)
{
objs.Add(k, new ObjList(k,Scenario[k]));
}
}
public void OpenBymlViewer()
{
}
void ApplyChangesToByml() //this makes sure new objects are added
{
objs.OrderBy(k => k.Key);
for (int i = 0; i < objs.Count; i++)
{
var values = objs.Values.ToArray();
if (values[i].Count == 0) objs.Remove(objs.Keys.ToArray()[i--]);
else values[i].ApplyToNode();
}
}
public byte[] ToByaml()
{
ApplyChangesToByml();
MemoryStream mem = new MemoryStream();
// ByamlFile.Save(mem, LoadedByml, false, Syroot.BinaryData.ByteOrder.LittleEndian);
var res = mem.ToArray();
return res;
}
public byte[] SaveSzs()
{
SzsFiles[Path.GetFileNameWithoutExtension(Filename) + ".byml"] = ToByaml();
return YAZ0.Compress(SARC.pack(SzsFiles));
}
public bool HasList(string name) { return objs.ContainsKey(name); }
public struct SearchResult
{
public LevelObj obj;
public int Index;
public string ListName;
}
public SearchResult FindObjById(string ID)
{
foreach (string k in objs.Keys)
{
for (int i = 0; i < objs[k].Count; i++)
{
if (objs[k][i].ID == ID)
return new SearchResult
{
obj = objs[k][i],
Index = i,
ListName = k
};
}
}
return new SearchResult
{
obj = null,
Index = -1,
ListName = ""
};
}
public ObjList FindListByObj(LevelObj o)
{
foreach (string k in objs.Keys)
{
if (objs[k].Contains(o)) return objs[k];
}
return null;
}
}
}

View file

@ -0,0 +1,633 @@

using OpenTK;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace OdysseyEditor
{
public struct Transform
{
public Vector3 Pos, Rot, Scale;
}
public class LevelObj : ICloneable
{
public const string N_Translate = "Translate";
public const string N_Rotate = "Rotate";
public const string N_Scale = "Scale";
public const string N_Id = "Id";
public const string N_Name = "UnitConfigName";
public const string N_Links = "Links";
public Dictionary<string, dynamic> Prop = new Dictionary<string, dynamic>();
public LevelObj(dynamic bymlNode)
{
if (bymlNode is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)bymlNode;
else throw new Exception("Not a dictionary");
if (Prop.ContainsKey(N_Links)) Prop[N_Links] = new LinksNode(Prop[N_Links]);
}
public LevelObj(bool empty = false)
{
if (empty) return;
Prop.Add(N_Translate, new Dictionary<string, dynamic>());
Prop[N_Translate].Add("X", (Single)0);
Prop[N_Translate].Add("Y", (Single)0);
Prop[N_Translate].Add("Z", (Single)0);
Prop.Add(N_Rotate, new Dictionary<string, dynamic>());
Prop[N_Rotate].Add("X", (Single)0);
Prop[N_Rotate].Add("Y", (Single)0);
Prop[N_Rotate].Add("Z", (Single)0);
Prop.Add(N_Scale, new Dictionary<string, dynamic>());
Prop[N_Scale].Add("X", (Single)1);
Prop[N_Scale].Add("Y", (Single)1);
Prop[N_Scale].Add("Z", (Single)1);
Prop.Add(N_Links, new LinksNode());
this[N_Name] = "newObj";
this[N_Id] = "obj0";
}
public dynamic this [string name]
{
get
{
if (Prop.ContainsKey(name)) return Prop[name];
else return null;
}
set
{
if (Prop.ContainsKey(name)) Prop[name] = value;
else Prop.Add(name,value);
}
}
public Vector3 Pos
{
get { return new Vector3(this[N_Translate]["X"], this[N_Translate]["Y"], this[N_Translate]["Z"]); }
set {
this[N_Translate]["X"] = (Single)value.X;
this[N_Translate]["Y"] = (Single)value.Y;
this[N_Translate]["Z"] = (Single)value.Z;
}
}
public Vector3 Rot
{
get { return new Vector3(this[N_Rotate]["X"], this[N_Rotate]["Y"], this[N_Rotate]["Z"]); }
set
{
this[N_Rotate]["X"] = (Single)value.X;
this[N_Rotate]["Y"] = (Single)value.Y;
this[N_Rotate]["Z"] = (Single)value.Z;
}
}
[Browsable(false)]
public Vector3 ModelView_Pos
{
get { return new Vector3(this[N_Translate]["X"], -this[N_Translate]["Z"], this[N_Translate]["Y"]); }
set //set when dragging
{
this[N_Translate]["X"] = (Single)value.X;
this[N_Translate]["Y"] = (Single)value.Z;
this[N_Translate]["Z"] = -(Single)value.Y;
}
}
[Browsable(false)]
public Vector3 ModelView_Rot
{
get { return new Vector3(this[N_Rotate]["X"], -this[N_Rotate]["Z"], this[N_Rotate]["Y"]); } //TODO: check if it matches in-game
}
public Vector3 Scale
{
get { return new Vector3(this[N_Scale]["X"], this[N_Scale]["Y"], this[N_Scale]["Z"]); }
set
{
this[N_Scale]["X"] = (Single)value.X;
this[N_Scale]["Y"] = (Single)value.Y;
this[N_Scale]["Z"] = (Single)value.Z;
}
}
[Browsable(false)]
public Vector3 ModelView_Scale
{
get { return new Vector3(this[N_Scale]["X"], this[N_Scale]["Z"], this[N_Scale]["Y"]); }
}
[Browsable(false)]
public Transform transform
{
get => new Transform() { Pos = Pos, Rot = Rot, Scale = Scale };
set
{
Pos = value.Pos;
Rot = value.Rot;
Scale = value.Scale;
}
}
public string ID
{
get { return this[N_Id]; }
set { this[N_Id] = value;}
}
public string Name
{
get { return this.ToString(); }
set { this[N_Name] = value; }
}
public override string ToString()
{
string name = this[N_Name];
if (name == null) name = "LevelObj id: " + this[N_Id];
if (name == null) name = "LevelObj";
return name;
}
public LevelObj Clone()
{
return new LevelObj(DeepCloneDictArr.DeepClone(Prop));
}
object ICloneable.Clone()
{
return Clone();
}
//[Editor(typeof(LevelObjEditor), typeof(UITypeEditor))]
[Description("This contains every property of this object")]
public Dictionary<string, dynamic> Properties
{
get { return Prop; }
set { Prop = value; }
}
public Transform transform_screen => new Transform() { Pos = ModelView_Pos, Rot = ModelView_Rot, Scale = ModelView_Scale };
}
class LinksNode : Dictionary<string, dynamic>, ICloneable //wrapper so we can use the custom editor
{
public LinksNode(Dictionary<string, dynamic> dict) : base(dict)
{
}
public LinksNode() : base()
{
}
public LinksNode Clone()
{
return new LinksNode(DeepCloneDictArr.DeepClone(this));
}
object ICloneable.Clone()
{
return Clone();
}
}
///*
//class LevelObjEditor : UITypeEditor
//{
// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
// {
// return UITypeEditorEditStyle.Modal;
// }
// public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
// {
// IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
// Dictionary<string, dynamic> v = value as Dictionary<string, dynamic>;
// if (svc != null && v != null)
// {
// using (FrmObjEditor form = new FrmObjEditor(v))
// {
// form.ShowDialog();
// v = form.Value.Prop;
// }
// }
// return v; // can also replace the wrapper object here
// }
//}*/
////[Editor(typeof(C0ListEditor), typeof(UITypeEditor))]
//public class C0List : ICloneable
//{
// List<LevelObj> l = new List<LevelObj>();
// public List<LevelObj> List
// {
// get { return l; }
// set { l = value; }
// }
// public C0List Clone()
// {
// C0List C = new C0List();
// foreach (LevelObj lev in l) C.l.Add(lev.Clone());
// return C;
// }
// public override string ToString()
// {
// return "C0 list";
// }
// object ICloneable.Clone()
// {
// return Clone();
// }
//}
///*
//class C0ListEditor : UITypeEditor
//{
// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
// {
// return UITypeEditorEditStyle.Modal;
// }
// public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
// {
// IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
// C0List v = value as C0List;
// if (svc != null && v != null)
// {
// ((Form1)System.Windows.Forms.Application.OpenForms["Form1"]).EditC0List(v.List);
// }
// return v;
// }
//}
//*/
//[TypeConverter(typeof(ExpandableObjectConverter))]
//public class Rail : ICloneable
//{
// public object this[string propertyName]
// {
// get { return this.GetType().GetProperty(propertyName).GetValue(this, null); }
// set { this.GetType().GetProperty(propertyName).SetValue(this, value, null); }
// }
// public Point3D[] GetPointArray()
// {
// List<Point3D> points = new List<Point3D>();
// foreach (Rail.Point p in Points) points.Add(new Point3D(p.X, -p.Z, p.Y));
// return points.ToArray();
// }
// List<int> _Args = new List<int>();
// string _LayerName;
// internal List<Point> _points = new List<Point>();
// //Multi file name ?
// public string _closed;
// int _l_id;
// string _name;
// int _no;
// string _type;
// public Rail(bool Adding = false, Vector3d? BasePosition = null)
// {
// _LayerName = "共通";
// _closed = "FALSE";
// _name = "empty rail";
// _type = "Bezier";
// if (Adding) _points.Add(new Point());
// if (Adding) _points.Add(new Point(1));
// if (BasePosition != null)
// {
// _points[0].X = (float)((Vector3d)BasePosition).X;
// _points[0].Y = (float)((Vector3d)BasePosition).Z;
// _points[0].Z = -(float)((Vector3d)BasePosition).Y;
// _points[1].X = (float)((Vector3d)BasePosition).X;
// _points[1].Y = (float)((Vector3d)BasePosition).Z;
// _points[1].Z = -(float)((Vector3d)BasePosition).Y;
// }
// }
// public override string ToString()
// {
// return _name;
// }
// public string Name
// {
// set
// {
// _name = JapChars(value);
// }
// get { return _name; }
// }
// public string Type
// {
// set { _type = value; }
// get { return _type; }
// }
// public bool Closed
// {
// set { _closed = value == false ? "OPEN" : "CLOSE"; }
// get { return _closed == "OPEN" ? false : true; }
// }
// public int no
// {
// set { _no = value; }
// get { return _no; }
// }
// public int l_id
// {
// set { _l_id = value; }
// get { return _l_id; }
// }
// public List<int> Arg
// {
// set { _Args = value; }
// get { return _Args; }
// }
// internal string JapChars(string input)
// {
// byte[] bytes = Encoding.Default.GetBytes(input);
// Encoding Enc = Encoding.GetEncoding(932);
// return input;//Enc.GetString(bytes);
// }
// public Rail Clone()
// {
// Rail R = new Rail();
// foreach (int i in _Args) R._Args.Add(i);
// R.LayerName = (string)_LayerName.Clone();
// foreach (Point p in _points) R._points.Add(p.Clone());
// R._closed = (string)_closed.Clone();
// R.l_id = _l_id;
// R.Name = (string)_name.Clone();
// R.no = _no;
// R.Type = (string)_type.Clone();
// return R;
// }
// object ICloneable.Clone()
// {
// return Clone();
// }
// public string LayerName
// {
// set {
// _LayerName = JapChars(value);
// }
// get { return _LayerName; }
// }
// // [Editor(typeof(RailPointEditor), typeof(UITypeEditor))]
// public List<Point> Points
// {
// set { _points = value; }
// get { return _points; }
// }
// // [TypeConverter(typeof(ExpandableObjectConverter))]
// public class Point : ICloneable
// {
// List<int> _Args = new List<int>();
// int _ID;
// public List<Single> _X = new List<Single>();
// public List<Single> _Y = new List<Single>();
// public List<Single> _Z = new List<Single>();
// public Point(int id = 0)
// {
// _ID = id;
// }
// public override string ToString()
// {
// return "Point ID: " + _ID.ToString();
// }
// public Point Clone()
// {
// Point N = new Point();
// foreach (int i in _Args) N._Args.Add(i);
// N.ID = _ID;
// foreach (int s in _X) N._X.Add(s);
// foreach (int s in _Y) N._Y.Add(s);
// foreach (int s in _Z) N._Z.Add(s);
// return N;
// }
// public Point Clone_increment()
// {
// Point N = new Point();
// foreach (int i in _Args) N._Args.Add(i);
// N.ID = _ID + 1;
// foreach (int s in _X) N._X.Add(s + 100);
// foreach (int s in _Y) N._Y.Add(s);
// foreach (int s in _Z) N._Z.Add(s);
// return N;
// }
// object ICloneable.Clone()
// {
// return Clone();
// }
// public List<int> Args
// {
// set { _Args = value; }
// get { return _Args; }
// }
// public int ID
// {
// set { _ID = value; }
// get { return _ID; }
// }
// public Single X
// {
// set { _X.Clear(); _X.Add(value); _X.Add(value); _X.Add(value); }
// get {
// if (_X.Count == 0) X = 0;
// return _X[0];
// }
// }
// public Single Y
// {
// set { _Y.Clear(); _Y.Add(value); _Y.Add(value); _Y.Add(value); }
// get {
// if (_Y.Count == 0) Y = 0;
// return _Y[0];
// }
// }
// public Single Z
// {
// set { _Z.Clear(); _Z.Add(value); _Z.Add(value); _Z.Add(value); }
// get {
// if (_Z.Count == 0) Z = 0;
// return _Z[0];
// }
// }
// }
//}
///*
//class RailPointEditor : UITypeEditor
//{
// public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
// {
// return UITypeEditorEditStyle.Modal;
// }
// public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
// {
// IWindowsFormsEditorService svc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
// List<Rail.Point> v = value as List<Rail.Point>;
// if (svc != null && v != null)
// {
// using (FrmRailPointEditor form = new FrmRailPointEditor(v))
// {
// form.ShowDialog();
// v = form.Value;
// }
// }
// return v; // can also replace the wrapper object here
// }
//}*/
//[TypeConverter(typeof(ExpandableObjectConverter))]
//class Node : ICloneable
//{
// string _StringValue;
// public string _StringNodeType;
// NodeTypes _NodeType;
// [Description("This is the value of this node as a string, change it respecting the type")]
// public string StringValue
// {
// set
// {
// if (_NodeType == NodeTypes.Int) Int32.Parse(value); //Crashes if the value is invalid
// else if (_NodeType == NodeTypes.Single) Single.Parse(value);
// _StringValue = value;
// }
// get { return _StringValue; }
// }
// [Description("The node type can't be changed, it tells what kind of data contains the node")]
// public NodeTypes NodeType
// {
// //set { _NodeType = value; }
// get { return _NodeType; }
// }
// public override string ToString()
// {
// string Prev = "";
// if (_NodeType == NodeTypes.Empty) Prev += "Empty";
// else if (_NodeType == NodeTypes.String) Prev += "String";
// else if (_NodeType == NodeTypes.Int) Prev += "Int";
// else if (_NodeType == NodeTypes.Single) Prev += "Single";
// else Prev += string.Format("Unk Type ({0})", _StringNodeType);
// Prev += " : ";
// Prev += _StringValue;
// return Prev;
// }
// public enum NodeTypes
// {
// String = 0xA0,
// Empty = 0xA1,
// Int = 0xD1,
// Single = 0xD2,
// Other
// }
// string JapChars(string input)
// {
// byte[] bytes = Encoding.Default.GetBytes(input);
// Encoding Enc = Encoding.GetEncoding(932);
// return input; //Enc.GetString(bytes);
// }
// public Node(string _stringValue, string _type)
// {
// _NodeType = NodeTypes.Other;
// if (_type == "A0") _NodeType = NodeTypes.String;
// else if (_type == "A1") _NodeType = NodeTypes.Empty;
// else if (_type == "D1") _NodeType = NodeTypes.Int;
// else if (_type == "D2") _NodeType = NodeTypes.Single;
// _StringNodeType = _type;
// ApplyValue(_stringValue, _NodeType);
// }
// void ApplyValue(string _stringValue, NodeTypes _type)
// {
// _StringValue = _stringValue;
// switch (_type)
// {
// case NodeTypes.String:
// _StringValue = JapChars(_StringValue);
// _NodeType = NodeTypes.String;
// break;
// case NodeTypes.Empty:
// _NodeType = NodeTypes.Empty;
// break;
// default:
// _NodeType = _type;
// break;
// }
// }
// public Node Clone()
// {
// return new Node(this._StringValue, this._StringNodeType);
// }
// object ICloneable.Clone()
// {
// return Clone();
// }
// public static bool operator ==(Node first, Node second)
// {
// return first.NodeType == second.NodeType && first.StringValue == second.StringValue;
// }
// public static bool operator !=(Node first, Node second)
// {
// return first.NodeType != second.NodeType || first.StringValue != second.StringValue;
// }
// public override bool Equals(object Obj)
// {
// return (Node)Obj == this;
// }
//}
/*String = 0xA0,
Empty = 0xA1,
Int = 0xD1,
Single = 0xD2,
*/
}

View file

@ -1,19 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading.Tasks;
using Switch_Toolbox.Library;
using ByamlExt.Byaml;
using OdysseyEditor;
namespace FirstPlugin
{
//Code off of https://github.com/exelix11/OdysseyEditor
//Note this will purely be for viewing, performance tests, and ripping
public class SMO_Scene
{
public Dictionary<string, string> OdysseyStages = new Dictionary<string, string>()
public static void LoadStage(string MapName)
{
if (File.Exists($"{Runtime.SmoGamePath}StageData\\{MapName}Map.szs"))
{
string StageByml = $"{Runtime.SmoGamePath}StageData\\{MapName}Map.szs";
new Level(StageByml, -1);
}
}
public static Dictionary<string, string> OdysseyStages = new Dictionary<string, string>()
{
//Main
{ "CapWorldHomeStage","Cap Kingdom" },
{ "WaterfallWorldHomeStage","Cascade Kingdom" },
{ "SandWorldHomeStage","Sand Kindom" },
{ "ForestWorldHomeStage","Wodded Kingdom" },
{ "SnowWorldHomeStage","Snow Kingdom" },
{ "SeaWorldHomeStage", "Seaside Kingdom" },
{ "ClashWorldHomeStage","Lost Kingdom" },
@ -35,7 +50,6 @@ namespace FirstPlugin
{ "SandWorldUnderground000Stage","Ice Underground before Boss" },
{ "SandWorldUnderground001Stage","Ice Underground Boss" },
{ "LakeWorldTownZone","LakeKingdom (Town Area)" },
{ "ForestWorldHomeStage","Wodded Kingdom" },
{ "DemoCrashHomeFallStage","Cloud Kingdom(1. Bowser Fight)" },
{ "Theater2DExStage","Theater (smb 1-1)" },
};

View file

@ -322,6 +322,9 @@
<Compile Include="GUI\BFRES\SmoothNormalsMultiMeshForm.Designer.cs">
<DependentUpon>SmoothNormalsMultiMeshForm.cs</DependentUpon>
</Compile>
<Compile Include="Scenes\SMO\CustomClasses.cs" />
<Compile Include="Scenes\SMO\Level.cs" />
<Compile Include="Scenes\SMO\LevelObj.cs" />
<Compile Include="Scenes\SMO_Scene.cs" />
<Compile Include="Scenes\ZTP_Scene.cs" />
<Compile Include="YAML\YamlAamp.cs" />

View file

@ -0,0 +1,68 @@
namespace Switch_Toolbox.Library.Forms
{
partial class SceneSelector
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.treeView1 = new System.Windows.Forms.TreeView();
this.contentContainer.SuspendLayout();
this.SuspendLayout();
//
// contentContainer
//
this.contentContainer.Controls.Add(this.treeView1);
this.contentContainer.Size = new System.Drawing.Size(315, 452);
this.contentContainer.Controls.SetChildIndex(this.treeView1, 0);
//
// treeView1
//
this.treeView1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.treeView1.Location = new System.Drawing.Point(5, 27);
this.treeView1.Name = "treeView1";
this.treeView1.Size = new System.Drawing.Size(307, 422);
this.treeView1.TabIndex = 11;
this.treeView1.DoubleClick += new System.EventHandler(this.treeView1_DoubleClick);
//
// SceneSelector
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(321, 457);
this.Name = "SceneSelector";
this.Text = "Scene Selector";
this.contentContainer.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TreeView treeView1;
}
}

View file

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Switch_Toolbox.Library.Forms
{
public partial class SceneSelector : STForm
{
public string SelectedFile = "";
public SceneSelector()
{
InitializeComponent();
treeView1.BackColor = FormThemes.BaseTheme.FormBackColor;
treeView1.ForeColor = FormThemes.BaseTheme.FormForeColor;
}
public void LoadDictionary(Dictionary<string,string> Files)
{
treeView1.BeginUpdate();
foreach (var file in Files)
treeView1.Nodes.Add(new TreeNode(file.Value) { Tag = file.Key, });
treeView1.EndUpdate();
}
private void treeView1_DoubleClick(object sender, EventArgs e)
{
SelectedFile = (string)treeView1.SelectedNode.Tag;
DialogResult = DialogResult.OK;
}
}
}

View file

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View file

@ -215,6 +215,12 @@
<Compile Include="Compression\YAZ0.cs" />
<Compile Include="Compression\ZCMP.cs" />
<Compile Include="Config.cs" />
<Compile Include="Forms\SceneSelector.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\SceneSelector.Designer.cs">
<DependentUpon>SceneSelector.cs</DependentUpon>
</Compile>
<Compile Include="Interfaces\ITextureContainer.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericModelRenderer.cs" />
<Compile Include="Rendering\GenericModelRenderer\GenericRenderedObject.cs" />
@ -904,6 +910,9 @@
<EmbeddedResource Include="Forms\HintHelpDialog.resx">
<DependentUpon>HintHelpDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\SceneSelector.resx">
<DependentUpon>SceneSelector.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\STConsoleForm.resx">
<DependentUpon>STConsoleForm.cs</DependentUpon>
</EmbeddedResource>