Finally fix the dpi scaling issues when opengl gets loaded

This commit is contained in:
KillzXGaming 2019-08-10 19:20:39 -04:00
parent bd8a5af254
commit aed38de591
20 changed files with 263 additions and 78 deletions

Binary file not shown.

View file

@ -6,6 +6,7 @@ using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.Forms;
using System.IO;
using OpenTK;
namespace FirstPlugin
{
@ -17,6 +18,8 @@ namespace FirstPlugin
private static string ActorPath = $"/Actor/Pack/";
private static string CachedActorsPath = $"/Pack/";
private static string ActorInfoTable = $"/Actor/ActorInfo.product.sbyml";
public enum ActorCategory
{
Armour,
@ -37,6 +40,87 @@ namespace FirstPlugin
}
}
public class ActorInfo
{
private const string N_name = "name";
private const string N_bfres = "bfres";
private const string N_aabbMin = "aabbMin";
private const string N_aabbMax = "aabbMax";
public string Name
{
get { return this[N_name] != null ? this[N_name] : ""; }
set { this[N_name] = value; }
}
public string BfresName
{
get { return this[N_bfres] != null ? this[N_bfres] : ""; }
set { this[N_bfres] = value; }
}
public Vector3 AABMin
{
get
{
if (this[N_aabbMin] == null)
return new Vector3(0, 0, 0);
return new Vector3(
this[N_aabbMin]["X"] != null ? this[N_aabbMin]["X"] : 0,
this[N_aabbMin]["Y"] != null ? this[N_aabbMin]["Y"] : 0,
this[N_aabbMin]["Z"] != null ? this[N_aabbMin]["Z"] : 0);
}
set
{
this[N_aabbMin]["X"] = value.X;
this[N_aabbMin]["Y"] = value.Y;
this[N_aabbMin]["Z"] = value.Z;
}
}
public Vector3 AABMax
{
get
{
if (this[N_aabbMax] == null)
return new Vector3(0, 0, 0);
return new Vector3(
this[N_aabbMax]["X"] != null ? this[N_aabbMax]["X"] : 0,
this[N_aabbMax]["Y"] != null ? this[N_aabbMax]["Y"] : 0,
this[N_aabbMax]["Z"] != null ? this[N_aabbMax]["Z"] : 0);
}
set
{
this[N_aabbMax]["X"] = value.X;
this[N_aabbMax]["Y"] = value.Y;
this[N_aabbMax]["Z"] = value.Z;
}
}
public ActorInfo(dynamic node)
{
if (node is Dictionary<string, dynamic>) Prop = (Dictionary<string, dynamic>)node;
}
public Dictionary<string, dynamic> Prop { get; set; } = new Dictionary<string, dynamic>();
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 static Dictionary<string, ActorDefineInfo> ArmorActorDefine = new Dictionary<string, ActorDefineInfo>()
{
{"001", new ActorDefineInfo("Hylian Tunic Set") },
@ -89,7 +173,35 @@ namespace FirstPlugin
return;
}
//Load all our actors into a class
Dictionary<string, TreeNode> ActorIDS = new Dictionary<string, TreeNode>();
Dictionary<string, ActorInfo> Actors = new Dictionary<string, ActorInfo>();
if (File.Exists($"{Runtime.BotwGamePath}{ActorInfoTable}"))
{
var byml = EveryFileExplorer.YAZ0.Decompress($"{Runtime.BotwGamePath}{ActorInfoTable}");
var actorInfoProductRoot = ByamlExt.Byaml.ByamlFile.FastLoadN(new MemoryStream(byml)).RootNode;
if (actorInfoProductRoot.ContainsKey("Actors"))
{
foreach (var actor in actorInfoProductRoot["Actors"])
{
ActorInfo info = new ActorInfo(actor);
if (info.Name != string.Empty)
{
Actors.Add(info.Name, info);
}
}
}
}
foreach (var info in Actors)
{
ActorEntry entry = new ActorEntry();
entry.Text = info.Key;
ArmourFolder.Nodes.Add(entry);
}
/* //Load all our actors into a class
foreach (var file in Directory.GetFiles($"{Runtime.BotwGamePath}{ActorPath}"))
{
string name = Path.GetFileNameWithoutExtension(file);
@ -104,12 +216,7 @@ namespace FirstPlugin
{
ActorDefineInfo info = ArmorActorDefine[actorID];
ActorEntry entry = new ActorEntry();
entry.Text = info.Name;
entry.FilePath = file;
entry.FileName = name;
entry.Category = ActorCategory.Armour;
ArmourFolder.Nodes.Add(entry);
}
}
else if (actorType == "Animal")
@ -120,7 +227,7 @@ namespace FirstPlugin
{
}
}
}*/
//The game also caches certain actors to the pack folder at boot

View file

@ -7,8 +7,9 @@ using Toolbox;
using System.Windows.Forms;
using Toolbox.Library;
using Toolbox.Library.IO;
using HyruleWarriors.G1M;
namespace FirstPlugin
namespace HyruleWarriors.G1M
{
public class G1M : TreeNodeFile, IFileFormat
{
@ -52,6 +53,8 @@ namespace FirstPlugin
{
}
public G1MS Skeleton { get; set; }
public void Read(FileReader reader)
{
reader.ByteOrder = Syroot.BinaryData.ByteOrder.BigEndian;
@ -78,16 +81,21 @@ namespace FirstPlugin
}
reader.SeekBegin(firstChunkOffset);
for (int i =0; i < numChunks; i++)
for (int i = 0; i < numChunks; i++)
{
long chunkPos = reader.Position;
G1MChunkCommon chunk = new G1MChunkCommon();
long chunkPosition = reader.Position;
string chunkMagic = reader.ReadString(4, Encoding.ASCII);
uint version = reader.ReadUInt32();
uint chunkVersion = reader.ReadUInt32();
uint chunkSize = reader.ReadUInt32();
if (chunkMagic == "G1MF")
{
}
else if (chunkMagic == "SM1G")
{
Skeleton = new G1MS(reader);
}
else if (chunkMagic == "G1MS")
{
@ -130,7 +138,9 @@ namespace FirstPlugin
}
reader.SeekBegin(chunkPos + chunkSize);
reader.SeekBegin(chunk.ChunkPosition + chunk.ChunkSize);
}
}
}

View file

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HyruleWarriors.G1M
{
public class G1MChunkCommon
{
public string Magic { get; set; }
public long ChunkPosition { get; set; }
public uint ChunkSize { get; set; }
public uint ChunkVersion { get; set; }
}
}

View file

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HyruleWarriors.G1M
{
public enum VertexAttriubte
{
Position,
Weights,
BoneIndices,
Normals,
Unknown,
TexCoord0,
Tangent,
Bitangent,
Color = 0x0A,
Fog = 0x0B,
}
}

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
using Toolbox.Library;
namespace HyruleWarriors.G1M
{
public class G1MG : G1MChunkCommon
{
private string Type { get; set; }
public G1MG(FileReader reader)
{
Type = reader.ReadString(3, Encoding.ASCII);
reader.ReadByte();//padding
if (Type == "DX1" || Type == "NX_")
{
}
}
}
}

View file

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Toolbox.Library.IO;
namespace HyruleWarriors.G1M
{
public class G1MS : G1MChunkCommon
{
public G1MS(FileReader reader)
{
}
}
}

View file

@ -211,6 +211,10 @@
<Compile Include="FileFormats\CrashBandicoot\IGZ_Structure.cs" />
<Compile Include="FileFormats\Grezzo\CMB_Enums.cs" />
<Compile Include="FileFormats\Grezzo\CSAB.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\G1MChunkCommon.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\G1MEnums.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\G1MG.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\G1MS.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1T.cs" />
<Compile Include="FileFormats\HyruleWarriors\HWBinGzResource.cs" />
<Compile Include="FileFormats\CrashBandicoot\IGA_PAK.cs" />
@ -275,7 +279,7 @@
<Compile Include="FileFormats\Audio\Archives\BFGRP.cs" />
<Compile Include="FileFormats\Font\BffntCharSet2Xlor.cs" />
<Compile Include="FileFormats\Font\BFTTF.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M.cs" />
<Compile Include="FileFormats\HyruleWarriors\G1M\G1M.cs" />
<Compile Include="FileFormats\HyruleWarriors\LINKDATA.cs" />
<Compile Include="FileFormats\Message\MSBP.cs" />
<Compile Include="FileFormats\CrashBandicoot\IGZ_TEX.cs" />

View file

@ -6,6 +6,7 @@ using Toolbox.Library.IO;
using static GL_EditorFramework.EditorDrawables.EditorSceneBase;
using FirstPlugin.Turbo.CourseMuuntStructs;
using FirstPlugin.Turbo;
using System.Collections.Generic;
namespace GL_EditorFramework.EditorDrawables
{
@ -32,14 +33,19 @@ namespace GL_EditorFramework.EditorDrawables
public Vector4 Color = new Vector4(0f, 0.25f, 1f, 1f);
public RenderablePathPoint(Vector4 color, Vector3 pos, Vector3 rot, Vector3 sca, object nodeObject) {
public Vector3 Position;
public Vector3 Scale;
public RenderablePathPoint(Vector4 color, Vector3 pos, Vector3 rot, Vector3 sca, object nodeObject)
{
NodeObject = nodeObject;
Color = color;
UpdateTransform(pos, rot, sca);
}
public RenderablePathPoint(Vector3 pos, Vector3 normal, Vector3 tangent, Vector3 sca) {
public RenderablePathPoint(Vector3 pos, Vector3 normal, Vector3 tangent, Vector3 sca)
{
UpdateTransform(pos, normal, tangent, sca);
}
@ -168,46 +174,43 @@ namespace GL_EditorFramework.EditorDrawables
public virtual void Translate(Vector3 lastPos, Vector3 translate, int subObj)
{
position = lastPos + translate;
UpdateNodePosition();
}
public virtual void UpdatePosition(int subObj) {
public virtual void UpdatePosition(int subObj)
{
}
public override BoundingBox GetSelectionBox() => new BoundingBox(
position.X - scale.X,
position.X + scale.X,
position.Y - scale.Y,
position.Y + scale.Y,
position.Z - scale.Z,
position.Z + scale.Z
);
public override void GetSelectionBox(ref BoundingBox boundingBox)
{
public override uint SelectAll(GL_ControlBase control)
}
public override uint SelectAll(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint SelectDefault(GL_ControlBase control)
public override uint SelectDefault(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint Select(int partIndex, GL_ControlBase control)
public override uint Select(int partIndex, GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint Deselect(int partIndex, GL_ControlBase control)
public override uint Deselect(int partIndex, GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = false;
return REDRAW;
}
public override uint DeselectAll(GL_ControlBase control)
public override uint DeselectAll(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = false;
return REDRAW;
@ -227,7 +230,7 @@ namespace GL_EditorFramework.EditorDrawables
public override bool IsInRange(float range, float rangeSquared, Vector3 pos)
{
return (pos - position).LengthSquared < rangeSquared;
return true;
}
private void UpdateNodePosition()
@ -257,17 +260,5 @@ namespace GL_EditorFramework.EditorDrawables
}
}
}
public override Vector3 Position
{
get
{
return position;
}
set
{
position = value;
}
}
}
}

View file

@ -534,7 +534,9 @@ namespace FirstPlugin.Forms
if (newSelection.Count > 0)
{
viewport.scene.SelectedObjects = newSelection;
foreach (var ob in newSelection)
viewport.scene.ToogleSelected(ob, true);
viewport.UpdateViewport();
}
}

View file

@ -36,6 +36,8 @@ namespace FirstPlugin.Forms
public void LoadMSBT(MSBT msbt)
{
listViewCustom1.Items.Clear();
activeMessageFile = msbt;
if (msbt.header.Text2 != null)

View file

@ -13,8 +13,6 @@ namespace FirstPlugin
{
public class FirstPlugin : IPlugin
{
private static FirstPlugin _instance;
public static FirstPlugin Instance { get { return _instance == null ? _instance = new FirstPlugin() : _instance; } }
public static string executableDir;
@ -92,7 +90,7 @@ namespace FirstPlugin
public STToolStripItem[] ToolsMenuExtensions => toolsExt;
public STToolStripItem[] TitleBarExtensions => null;
readonly STToolStripItem[] toolsExt = new STToolStripItem[2];
readonly STToolStripItem[] toolsExt = new STToolStripItem[3];
public MenuExt()
{
toolsExt[0] = new STToolStripItem("Super Mario Odyssey");
@ -103,8 +101,8 @@ namespace FirstPlugin
toolsExt[1].DropDownItems.Add(new STToolStripItem("Probe Light Converter", GenerateProbeLightBounds));
// toolsExt[2] = new STToolStripItem("Breath Of The Wild");
// toolsExt[2].DropDownItems.Add(new STToolStripItem("Actor Editor", ActorEditor));
toolsExt[2] = new STToolStripItem("Breath Of The Wild");
toolsExt[2].DropDownItems.Add(new STToolStripItem("Actor Editor", ActorEditor));
}
private void ActorEditor(object sender, EventArgs args)
@ -387,7 +385,7 @@ namespace FirstPlugin
Formats.Add(typeof(XLINK));
Formats.Add(typeof(BFSAR));
Formats.Add(typeof(GFA));
Formats.Add(typeof(G1M));
Formats.Add(typeof(HyruleWarriors.G1M.G1M));
Formats.Add(typeof(MSBP));
}

View file

@ -128,7 +128,13 @@ namespace Toolbox.Library
public bool ContainsDrawable(AbstractGlDrawable Drawable)
{
return scene.staticObjects.Contains(Drawable) || scene.objects.Contains(Drawable);
if (Drawable is GL_EditorFramework.EditorDrawables.IEditableObject)
{
return scene.staticObjects.Contains(Drawable) ||
scene.objects.Contains((GL_EditorFramework.EditorDrawables.IEditableObject)Drawable);
}
else
return scene.staticObjects.Contains(Drawable);
}
private void shadingToolStripMenuItem_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)

View file

@ -172,13 +172,13 @@ namespace Toolbox.Library
private void DrawBoundingBoxes()
{
var boundings = GetSelectionBox();
/* var boundings = GetSelectionBox();
DrawableBoundingBox.DrawBoundingBox(
new Vector3(boundings.minX, boundings.minY, boundings.minZ),
new Vector3(boundings.maxX, boundings.maxY, boundings.maxZ),
new Vector3(0)
);
);*/
return;
}
@ -427,17 +427,13 @@ namespace Toolbox.Library
}
}
public override BoundingBox GetSelectionBox()
public override void GetSelectionBox(ref BoundingBox boundingBox)
{
BoundingBox box = BoundingBox.Default;
for (int i = 1; i < bones.Count; i++)
{
box.Include(bones[i - 1].pos);
box.Include(bones[i].pos);
boundingBox.Include(bones[i - 1].pos);
boundingBox.Include(bones[i].pos);
}
return box;
}
public override LocalOrientation GetLocalOrientation(int partIndex)
@ -471,46 +467,34 @@ namespace Toolbox.Library
return false;
}
public override uint SelectAll(GL_ControlBase control)
public override uint SelectAll(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint SelectDefault(GL_ControlBase control)
public override uint SelectDefault(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint Select(int partIndex, GL_ControlBase control)
public override uint Select(int partIndex, GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = true;
return REDRAW;
}
public override uint Deselect(int partIndex, GL_ControlBase control)
public override uint Deselect(int partIndex, GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = false;
return REDRAW;
}
public override uint DeselectAll(GL_ControlBase control)
public override uint DeselectAll(GL_ControlBase control, ISet<object> selectedObjects)
{
Selected = false;
return REDRAW;
}
public override Vector3 Position
{
get
{
return position;
}
set
{
position = value;
}
}
}
}

Binary file not shown.

Binary file not shown.