rewrite New World Computing scene layout using Universal Editor's Component Designer editor; UWT preliminary implementation

This commit is contained in:
Michael Becker 2020-05-16 07:17:02 -04:00
parent f105a2323c
commit b727feb700
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7
21 changed files with 761 additions and 52 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkWindow">
<property name="can_focus">False</property>
<child type="titlebar">
<placeholder/>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkDrawingArea" id="designer">
<property name="name">UniversalEditor.Plugins.Designer.UserInterface.Editors.Designer.Controls.DesignerControl</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -10,7 +10,7 @@
</Filter>
</Filters>
<ObjectModels>
<ObjectModel TypeName="UniversalEditor.ObjectModels.NWCSceneLayout.NWCSceneLayoutObjectModel" />
<ObjectModel TypeName="UniversalEditor.ObjectModels.Designer.DesignerObjectModel" />
</ObjectModels>
<DataFormats>
<DataFormat TypeName="UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN.BINDataFormat" />

View File

@ -733,6 +733,7 @@
<Content Include="Extensions\AudioWorkstation\Extensions\Vocaloid\Associations\SynthesizedAudio\VSQX.uexml" />
<Content Include="Extensions\AudioWorkstation\Extensions\Vocaloid\Associations\SynthesizedAudio\VPR.uexml" />
<Content Include="Editors\Binary\Commands.uexml" />
<Content Include="Editors\Designer\DesignerEditor.glade" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />

View File

@ -0,0 +1,135 @@
//
// DesignerControl.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using MBS.Framework.Drawing;
using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Drawing;
using MBS.Framework.UserInterface.Input.Mouse;
using UniversalEditor.ObjectModels.Designer;
namespace UniversalEditor.Plugins.Designer.UserInterface.Editors.Designer.Controls
{
public class DesignerControl : CustomControl
{
private DesignerObjectModel m_ObjectModel = null;
public DesignerObjectModel ObjectModel { get { return m_ObjectModel; } set { m_ObjectModel = value; Refresh(); } }
private Design _SelectedDesign = null;
public Design SelectedDesign { get { return _SelectedDesign; } set { _SelectedDesign = value; Refresh(); } }
public ComponentInstance.ComponentInstanceCollection SelectedComponents { get; } = new ComponentInstance.ComponentInstanceCollection();
private int margin_x = 13, margin_y = 13, margin_r = 13, margin_b = 13;
public ComponentInstance HitTest(Vector2D location)
{
for (int i = SelectedDesign.ComponentInstances.Count - 1; i >= 0; i--)
{
ComponentInstance inst = SelectedDesign.ComponentInstances[i];
if (location.X >= inst.X.Value && location.X <= inst.X.Value + inst.Width.Value && location.Y >= inst.Y.Value && location.Y <= inst.Y.Value + inst.Height.Value)
return inst;
}
return null;
}
private ComponentInstance dragging = null;
private double cx = 0, cy = 0;
private double dx = 0, dy = 0;
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (e.Buttons == MouseButtons.Primary || SelectedComponents.Count == 0)
{
ComponentInstance hit = HitTest(e.Location);
if (hit != null)
{
SelectedComponents.Clear();
SelectedComponents.Add(hit);
Refresh();
if (e.Buttons == MouseButtons.Primary)
{
dragging = hit;
cx = e.X;
cy = e.Y;
dx = hit.X.Value;
dy = hit.Y.Value;
}
}
else
{
dragging = null;
}
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
if (e.Buttons == MouseButtons.Primary && dragging != null)
{
dragging.X = new ObjectModels.Designer.Measurement(dx + (e.X - cx), ObjectModels.Designer.MeasurementUnit.Pixel);
dragging.Y = new ObjectModels.Designer.Measurement(dy + (e.Y - cy), ObjectModels.Designer.MeasurementUnit.Pixel);
Refresh();
}
else
{
ComponentInstance hit = HitTest(e.Location);
if (hit != null)
{
Cursor = Cursors.Move;
}
else
{
Cursor = Cursors.Default;
}
}
}
protected override void OnPaint(PaintEventArgs e)
{
if (m_ObjectModel == null) return;
if (_SelectedDesign == null && m_ObjectModel.Designs.Count > 0) _SelectedDesign = m_ObjectModel.Designs[0];
if (_SelectedDesign == null) return;
e.Graphics.DrawRectangle(new Pen(Colors.DarkGray), new Rectangle(margin_x, margin_y, _SelectedDesign.Size.Width - margin_x - margin_r, _SelectedDesign.Size.Height - margin_y - margin_b));
for (int i = 0; i < SelectedDesign.ComponentInstances.Count; i++)
{
ComponentInstance inst = SelectedDesign.ComponentInstances[i];
Rectangle componentRect = new MBS.Framework.Drawing.Rectangle(margin_x + inst.X.Value, margin_y + inst.Y.Value, inst.Width.Value, inst.Height.Value);
inst.Component.Render(inst, e, componentRect);
if (SelectedComponents.Contains(inst))
{
e.Graphics.DrawRectangle(new Pen(SystemColors.HighlightBackground), componentRect);
}
else
{
e.Graphics.DrawRectangle(new Pen(Colors.DarkGray), componentRect);
}
}
base.OnPaint(e);
}
}
}

View File

@ -0,0 +1,74 @@
//
// DesignerEditor.cs - provides a UWT-based Editor for manipulating component designer layouts
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.UserInterface;
using UniversalEditor.ObjectModels.Designer;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Plugins.Designer.UserInterface.Editors.Designer
{
/// <summary>
/// Provides a UWT-based <see cref="Editor" /> for manipulating component designer layouts.
/// </summary>
[ContainerLayout("~/Editors/Designer/DesignerEditor.glade")]
public class DesignerEditor : Editor
{
private static EditorReference _er = null;
public override EditorReference MakeReference()
{
if (_er == null)
{
_er = base.MakeReference();
_er.SupportedObjectModels.Add(typeof(DesignerObjectModel));
}
return _er;
}
private Controls.DesignerControl designer;
public override void UpdateSelections()
{
throw new System.NotImplementedException();
}
protected override EditorSelection CreateSelectionInternal(object content)
{
throw new System.NotImplementedException();
}
protected override void OnCreated(EventArgs e)
{
base.OnCreated(e);
OnObjectModelChanged(EventArgs.Empty);
}
protected override void OnObjectModelChanged(EventArgs e)
{
base.OnObjectModelChanged(e);
if (!IsCreated) return;
DesignerObjectModel dsn = (ObjectModel as DesignerObjectModel);
designer.ObjectModel = dsn;
}
}
}

View File

@ -0,0 +1,46 @@
//
// AssemblyInfo.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.
[assembly: AssemblyTitle("UniversalEditor.Plugins.Designer.UserInterface")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Mike Becker's Software")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("Mike Becker's Software")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion("1.0.*")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{08168BEA-E652-4493-8D89-5AB72B225841}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Plugins.Designer.UserInterface</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.Designer.UserInterface</AssemblyName>
<TargetFrameworkVersion>v4.7</TargetFrameworkVersion>
<ReleaseVersion>4.0.2019.12</ReleaseVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Editors\Designer\DesignerEditor.cs" />
<Compile Include="Editors\Designer\Controls\DesignerControl.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Editors\" />
<Folder Include="Editors\Designer\" />
<Folder Include="Editors\Designer\Controls\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.UserInterface\UniversalEditor.UserInterface.csproj">
<Project>{8622EBC4-8E20-476E-B284-33D472081F5C}</Project>
<Name>UniversalEditor.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\Plugins\UniversalEditor.Plugins.Designer\UniversalEditor.Plugins.Designer.csproj">
<Project>{899E3DD6-EA65-4168-AAE3-867A4F9650A6}</Project>
<Name>UniversalEditor.Plugins.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework.UserInterface\Libraries\MBS.Framework.UserInterface\MBS.Framework.UserInterface.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -20,6 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
namespace UniversalEditor.ObjectModels.Designer
{
@ -31,7 +32,31 @@ namespace UniversalEditor.ObjectModels.Designer
public class ComponentCollection
: System.Collections.ObjectModel.Collection<Component>
{
public Component this[Guid id]
{
get
{
for (int i = 0; i < Count; i++)
{
if (this[i].ID == id)
return this[i];
}
return null;
}
}
}
public Component(Guid id, string title, Property[] properties = null, Action<ComponentInstance, MBS.Framework.UserInterface.PaintEventArgs, Rectangle> renderDelegate = null)
{
ID = id;
Title = title;
if (properties != null)
{
for (int i = 0; i < properties.Length; i++)
Properties.Add(properties[i]);
}
if (renderDelegate != null)
RenderDelegate += renderDelegate;
}
/// <summary>
@ -44,6 +69,14 @@ namespace UniversalEditor.ObjectModels.Designer
/// </summary>
/// <value>The title of this <see cref="Component" />.</value>
public string Title { get; set; } = String.Empty;
public event Action<ComponentInstance, MBS.Framework.UserInterface.PaintEventArgs, Rectangle> RenderDelegate = null;
public void Render(ComponentInstance instance, MBS.Framework.UserInterface.PaintEventArgs e, Rectangle bounds)
{
RenderDelegate?.Invoke(instance, e, bounds);
}
/// <summary>
/// Gets a collection of <see cref="Property" /> instances representing properties associated with this <see cref="Component" />.
/// </summary>

View File

@ -20,6 +20,7 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
namespace UniversalEditor.ObjectModels.Designer
{
@ -34,6 +35,22 @@ namespace UniversalEditor.ObjectModels.Designer
}
public ComponentInstance(Component component, Rectangle rectangle, PropertyValue[] propertyValues = null)
{
Component = component;
X = new Measurement(rectangle.X, MeasurementUnit.Pixel);
Y = new Measurement(rectangle.Y, MeasurementUnit.Pixel);
Width = new Measurement(rectangle.Width, MeasurementUnit.Pixel);
Height = new Measurement(rectangle.Height, MeasurementUnit.Pixel);
if (propertyValues != null)
{
for (int i = 0; i < propertyValues.Length; i++)
{
PropertyValues.Add(propertyValues[i]);
}
}
}
/// <summary>
/// Gets or sets the globally-unique identifier for this <see cref="ComponentInstance" />.
/// </summary>

View File

@ -19,6 +19,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using MBS.Framework.Drawing;
namespace UniversalEditor.ObjectModels.Designer
{
/// <summary>
@ -38,5 +40,6 @@ namespace UniversalEditor.ObjectModels.Designer
/// <value>The instances of components in this component designer layout.</value>
public ComponentInstance.ComponentInstanceCollection ComponentInstances { get; } = new ComponentInstance.ComponentInstanceCollection();
public Dimension2D Size { get; set; } = new Dimension2D(600, 400);
}
}

View File

@ -21,6 +21,8 @@
using System;
using MBS.Framework.Drawing;
namespace UniversalEditor.ObjectModels.Designer
{
/// <summary>
@ -31,7 +33,8 @@ namespace UniversalEditor.ObjectModels.Designer
public override void Clear()
{
throw new NotImplementedException();
Designs.Clear();
Libraries.Clear();
}
public override void CopyTo(ObjectModel where)

View File

@ -19,6 +19,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.ObjectModels.Designer
{
/// <summary>
@ -29,6 +31,29 @@ namespace UniversalEditor.ObjectModels.Designer
public class PropertyCollection
: System.Collections.ObjectModel.Collection<Property>
{
public Property this[Guid id]
{
get
{
for (int i = 0; i < Count; i++)
{
if (this[i].ID == id)
return this[i];
}
return null;
}
}
}
public Guid ID { get; private set; } = Guid.Empty;
public string Title { get; set; } = String.Empty;
public object DefaultValue { get; set; } = null;
public Property(Guid id, string title, object defaultValue = null)
{
ID = id;
Title = title;
DefaultValue = defaultValue;
}
}
}

View File

@ -29,9 +29,27 @@ namespace UniversalEditor.ObjectModels.Designer
public class PropertyValueCollection
: System.Collections.ObjectModel.Collection<PropertyValue>
{
public PropertyValue this[Property property]
{
get
{
for (int i = 0; i < Count; i++)
{
if (this[i].Property == property)
return this[i];
}
return null;
}
}
}
public PropertyValue(Property property, object value = null)
{
Property = property;
Value = value;
}
/// <summary>
/// Gets or sets the property associated with this <see cref="PropertyValue" />.
/// </summary>

View File

@ -58,6 +58,14 @@
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework.UserInterface\Libraries\MBS.Framework.UserInterface\MBS.Framework.UserInterface.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

View File

@ -0,0 +1,32 @@
//
// BINComponentType.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
{
public enum BINComponentType
{
None = 0x00,
Image = 0x01,
Unknown0x02 = 0x02,
Label = 0x08,
Unknown0x10 = 0x10
}
}

View File

@ -0,0 +1,173 @@
//
// BINDataFormat.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.Drawing;
using MBS.Framework.UserInterface;
using UniversalEditor.IO;
using UniversalEditor.ObjectModels.Designer;
using UniversalEditor.ObjectModels.NWCSceneLayout;
namespace UniversalEditor.DataFormats.NWCSceneLayout.NewWorldComputing.BIN
{
public class BINDataFormat : DataFormat
{
private static DataFormatReference _dfr = null;
protected override DataFormatReference MakeReferenceInternal()
{
if (_dfr == null)
{
_dfr = base.MakeReferenceInternal();
_dfr.Capabilities.Add(typeof(DesignerObjectModel), DataFormatCapabilities.All);
}
return _dfr;
}
public static Library NWCSceneLayoutLibrary { get; private set; } = null;
static BINDataFormat()
{
NWCSceneLayoutLibrary = new Library();
NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.Button, "Button", new Property[]
{
new Property(ScenePropertyGuids.Button.BackgroundImageFileName, "Background image file name"),
new Property(ScenePropertyGuids.Button.BackgroundImageIndex, "Background image index")
}, Button_Render));
NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.Image, "Image", new Property[]
{
new Property(ScenePropertyGuids.Image.BackgroundImageFileName, "Background image file name"),
new Property(ScenePropertyGuids.Image.BackgroundImageIndex, "Background image index")
}, Image_Render));
NWCSceneLayoutLibrary.Components.Add(new Component(SceneObjectGuids.Label, "Label", new Property[]
{
new Property(ScenePropertyGuids.Label.Text, "Text"),
new Property(ScenePropertyGuids.Label.FontFileName, "Font file name")
}, Label_Render));
}
static void Button_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
{
}
static void Image_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
{
}
static void Label_Render(ComponentInstance instance, PaintEventArgs e, Rectangle bounds)
{
e.Graphics.DrawText(instance.PropertyValues[instance.Component.Properties[ScenePropertyGuids.Label.Text]].Value?.ToString(), null, bounds, new MBS.Framework.UserInterface.Drawing.SolidBrush(SystemColors.WindowForeground));
}
protected override void LoadInternal(ref ObjectModel objectModel)
{
DesignerObjectModel designer = (objectModel as DesignerObjectModel);
if (designer == null)
throw new ObjectModelNotSupportedException();
if (!designer.Libraries.Contains(NWCSceneLayoutLibrary))
designer.Libraries.Add(NWCSceneLayoutLibrary);
if (designer.Designs.Count == 0)
designer.Designs.Add(new Design());
Reader reader = Accessor.Reader;
ushort canvasWidth = reader.ReadUInt16();
ushort canvasHeight = reader.ReadUInt16();
designer.Designs[0].Size = new MBS.Framework.Drawing.Dimension2D(canvasWidth, canvasHeight);
ushort componentCount = reader.ReadUInt16();
bool breakout = false;
while (!reader.EndOfStream && !breakout)
{
BINComponentType componentType = (BINComponentType)reader.ReadUInt16();
ushort x = reader.ReadUInt16();
ushort y = reader.ReadUInt16();
ushort width = reader.ReadUInt16();
ushort height = reader.ReadUInt16();
switch (componentType)
{
case BINComponentType.Image:
{
ushort i1 = reader.ReadUInt16();
ushort i2 = reader.ReadUInt16();
string icnFileName = reader.ReadFixedLengthString(13);
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image], new Rectangle(x, y, width, height), new PropertyValue[]
{
new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Image].Properties[ScenePropertyGuids.Image.BackgroundImageFileName], icnFileName)
}));
break;
}
case BINComponentType.Label:
{
ushort textLength = reader.ReadUInt16();
string text = reader.ReadFixedLengthString(textLength).TrimNull();
string fontFileName = reader.ReadFixedLengthString(13);
ushort b01 = reader.ReadUInt16();
ushort b02 = reader.ReadUInt16();
ushort b03 = reader.ReadUInt16();
ushort b04 = reader.ReadUInt16();
designer.Designs[0].ComponentInstances.Add(new ComponentInstance(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Label], new Rectangle(x, y, width, height), new PropertyValue[]
{
new PropertyValue(NWCSceneLayoutLibrary.Components[SceneObjectGuids.Label].Properties[ScenePropertyGuids.Label.Text], text)
}));
break;
}
case BINComponentType.Unknown0x10:
{
string fileName = reader.ReadFixedLengthString(13);
ushort b01 = reader.ReadUInt16();
ushort b02 = reader.ReadUInt16();
ushort b03 = reader.ReadUInt16();
ushort b04 = reader.ReadUInt16();
ushort b05 = reader.ReadUInt16();
break;
}
case BINComponentType.Unknown0x02:
{
string fileName = reader.ReadFixedLengthString(13).TrimNull();
ushort b01 = reader.ReadUInt16();
ushort b02 = reader.ReadUInt16();
ushort b03 = reader.ReadUInt16();
ushort b04 = reader.ReadUInt16();
ushort b05 = reader.ReadUInt16();
ushort b06 = reader.ReadUInt16();
break;
}
case BINComponentType.None:
{
breakout = true;
break;
}
default:
{
break;
}
}
}
}
protected override void SaveInternal(ObjectModel objectModel)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,49 +0,0 @@
//
// NWCSceneLayoutObjectModel.cs - provides an ObjectModel for manipulating New World Computing game dialogs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2011-2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.ObjectModels.NWCSceneLayout
{
/// <summary>
/// Provides an <see cref="ObjectModel" /> for manipulating New World Computing game dialogs.
/// </summary>
public class NWCSceneLayoutObjectModel : ObjectModel
{
public override void Clear()
{
Objects.Clear();
}
public override void CopyTo(ObjectModel where)
{
throw new NotImplementedException();
}
public ushort Width { get; set; } = 0;
public ushort Height { get; set; } = 0;
public SceneObject.SceneObjectCollection Objects { get; } = new SceneObject.SceneObjectCollection();
public string BackgroundImageFileName { get; set; } = String.Empty;
public int BackgroundImageIndex { get; set; } = 0;
}
}

View File

@ -0,0 +1,30 @@
//
// SceneObjectGuids.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.ObjectModels.NWCSceneLayout
{
public class SceneObjectGuids
{
public static Guid Button { get; } = new Guid("{621e6323-5b10-4fb4-843b-9aa607751a7b}");
public static Guid Image { get; } = new Guid("{6f8d562e-8473-4872-be57-9fc04e575e9b}");
public static Guid Label { get; } = new Guid("{061ded85-99fd-43b0-b23d-e31c904ba397}");
}
}

View File

@ -0,0 +1,42 @@
//
// ScenePropertyGuids.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2020 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.ObjectModels.NWCSceneLayout
{
public static class ScenePropertyGuids
{
public static class Button
{
public static Guid BackgroundImageFileName { get; } = new Guid("{df3a8c45-a6bf-44d3-bf46-d8569e78bc71}");
public static Guid BackgroundImageIndex { get; } = new Guid("{e4226ed5-0ffa-468a-972f-146c934b0aa2}");
}
public static class Image
{
public static Guid BackgroundImageFileName { get; } = new Guid("{df3a8c45-a6bf-44d3-bf46-d8569e78bc71}");
public static Guid BackgroundImageIndex { get; } = new Guid("{e4226ed5-0ffa-468a-972f-146c934b0aa2}");
}
public static class Label
{
public static Guid Text { get; } = new Guid("{25abbdfa-5b9d-491c-9b96-33dc0fd25156}");
public static Guid FontFileName { get; } = new Guid("{eca4baa1-9f92-4c80-82fa-490a758083d0}");
}
}
}

View File

@ -52,7 +52,6 @@
<Compile Include="DataFormats\FileSystem\NewWorldComputing\Heroes3SNDDataFormat.cs" />
<Compile Include="DataFormats\FileSystem\NewWorldComputing\Heroes3VIDDataFormat.cs" />
<Compile Include="HoMM2Palette.cs" />
<Compile Include="ObjectModels\NWCSceneLayout\NWCSceneLayoutObjectModel.cs" />
<Compile Include="ObjectModels\NewWorldComputing\Campaign\CampaignObjectModel.cs" />
<Compile Include="ObjectModels\NewWorldComputing\Font\FontObjectModel.cs" />
<Compile Include="ObjectModels\NewWorldComputing\Map\MapGroundType.cs" />
@ -80,6 +79,10 @@
<Compile Include="ObjectModels\NWCSceneLayout\SceneObjects\SceneObjectImage.cs" />
<Compile Include="ObjectModels\NWCSceneLayout\SceneObjects\SceneObjectLabel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ObjectModels\NWCSceneLayout\SceneObjectGuids.cs" />
<Compile Include="ObjectModels\NWCSceneLayout\ScenePropertyGuids.cs" />
<Compile Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\BINDataFormat.cs" />
<Compile Include="DataFormats\NWCSceneLayout\NewWorldComputing\BIN\BINComponentType.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Compression\UniversalEditor.Compression.csproj">
@ -102,6 +105,14 @@
<Project>{00266B21-35C9-4A7F-A6BA-D54D7FDCC25C}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\UniversalEditor.Plugins.Designer\UniversalEditor.Plugins.Designer.csproj">
<Project>{899E3DD6-EA65-4168-AAE3-867A4F9650A6}</Project>
<Name>UniversalEditor.Plugins.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\MBS.Framework.UserInterface\Libraries\MBS.Framework.UserInterface\MBS.Framework.UserInterface.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>MBS.Framework.UserInterface</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="ObjectModels\NewWorldComputing\Map\MapLoseCondition.cs" />

View File

@ -167,6 +167,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Ado
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Vocaloid", "Plugins\UniversalEditor.Plugins.Vocaloid\UniversalEditor.Plugins.Vocaloid.csproj", "{C8953DB2-AE48-4F04-87EC-549E6A3E30D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Designer.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.Designer.UserInterface\UniversalEditor.Plugins.Designer.UserInterface.csproj", "{08168BEA-E652-4493-8D89-5AB72B225841}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -483,6 +485,10 @@ Global
{C8953DB2-AE48-4F04-87EC-549E6A3E30D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C8953DB2-AE48-4F04-87EC-549E6A3E30D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C8953DB2-AE48-4F04-87EC-549E6A3E30D8}.Release|Any CPU.Build.0 = Release|Any CPU
{08168BEA-E652-4493-8D89-5AB72B225841}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{08168BEA-E652-4493-8D89-5AB72B225841}.Debug|Any CPU.Build.0 = Debug|Any CPU
{08168BEA-E652-4493-8D89-5AB72B225841}.Release|Any CPU.ActiveCfg = Release|Any CPU
{08168BEA-E652-4493-8D89-5AB72B225841}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5}
@ -561,6 +567,7 @@ Global
{553DFD37-805C-4553-980A-D5696D88241A} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{FD46EA8D-7711-4BAF-A486-719D754504F8} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{C8953DB2-AE48-4F04-87EC-549E6A3E30D8} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
{08168BEA-E652-4493-8D89-5AB72B225841} = {7B535D74-5496-4802-B809-89ED88274A91}
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
Policies = $0