various stuff
This commit is contained in:
parent
7bb1ac7930
commit
af360a0753
@ -66,7 +66,7 @@ namespace UniversalEditor
|
||||
/// </summary>
|
||||
/// <value>The accessor.</value>
|
||||
[Obsolete("ObjectModels should be Accessor-agnostic and not rely on being able to communicate with the Accessor"), NonSerializedProperty]
|
||||
public Accessor Accessor { get; internal set; }
|
||||
public Accessor Accessor { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Clears all data from this <see cref="ObjectModel" /> and returns it to a pristine state.
|
||||
|
||||
@ -856,7 +856,8 @@ namespace UniversalEditor.UserInterface
|
||||
DataFormatReference dfr = Document.DataFormat.MakeReference();
|
||||
if (dfr.ExportOptions != null)
|
||||
{
|
||||
list.Add(dfr.ExportOptions);
|
||||
// FIXME
|
||||
list.Add(dfr.ExportOptions.Clone(dfr.Title));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -20,15 +20,10 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Dialogs;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
using UniversalEditor.UserInterface.Editors.Database.Dialogs;
|
||||
using UniversalEditor.ObjectModels.Database;
|
||||
using UniversalEditor.UserInterface;
|
||||
using UniversalEditor.UserInterface.Editors.Database.Dialogs;
|
||||
|
||||
namespace UniversalEditor.UserInterface.Editors.Database
|
||||
{
|
||||
@ -161,10 +156,17 @@ namespace UniversalEditor.UserInterface.Editors.Database
|
||||
|
||||
private void DatabaseEditor_ContextMenu_Columns_Add(object sender, EventArgs e)
|
||||
{
|
||||
if (DesignView.Table == null)
|
||||
return;
|
||||
|
||||
ColumnPropertiesDialog dlg = new ColumnPropertiesDialog();
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
DatabaseField field = new DatabaseField();
|
||||
dlg.UpdateProperties(field);
|
||||
DesignView.Table.Fields.Add(field);
|
||||
|
||||
DesignView.AddColumn(field.Name, field.DataType?.ToString(), false /*field.Required*/, false /*field.Identity*/, field.Value);
|
||||
}
|
||||
}
|
||||
|
||||
@ -200,6 +202,9 @@ namespace UniversalEditor.UserInterface.Editors.Database
|
||||
|
||||
EndEdit();
|
||||
|
||||
// FIXME: the node collection needs to notify the Document Explorer panel that a new item has been added
|
||||
// we do this so many times in various places that there really should be a better way to connect these notifications
|
||||
// perhaps a ListViewControl.Observe(ICollection) method ?
|
||||
EditorDocumentExplorerNode node = new EditorDocumentExplorerNode(dt.Name);
|
||||
node.SetExtraData<DatabaseTable>("table", dt);
|
||||
DocumentExplorer.Nodes[0].Nodes.Add(node);
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
using System;
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using UniversalEditor.ObjectModels.Database;
|
||||
|
||||
namespace UniversalEditor.UserInterface.Editors.Database.Dialogs
|
||||
{
|
||||
@ -34,6 +35,13 @@ namespace UniversalEditor.UserInterface.Editors.Database.Dialogs
|
||||
private TextBox txtDescription;
|
||||
private GroupBox fraDataTypeSpecificProperties;
|
||||
|
||||
public void UpdateProperties(DatabaseField field)
|
||||
{
|
||||
field.Name = txtColumnName.Text;
|
||||
// field.DataType = cboDataType.SelectedItem
|
||||
// field.Description = txtDescription.Text;
|
||||
}
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
|
||||
@ -78,7 +78,7 @@ namespace UniversalEditor.UserInterface.Editors.Database.Views
|
||||
((ToolbarItemButton)tbColumns.Items["tsbColumnMoveDown"]).Click += tsbColumnMoveDown_Click;
|
||||
}
|
||||
|
||||
private void tsbColumnAdd_Click(object sender, EventArgs e)
|
||||
public void AddColumn()
|
||||
{
|
||||
TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[]
|
||||
{
|
||||
@ -92,6 +92,25 @@ namespace UniversalEditor.UserInterface.Editors.Database.Views
|
||||
tvColumns.Model.Rows.Add(row);
|
||||
tvColumns.Focus(row, tvColumns.Columns[0], tvColumns.Columns[0].Renderers[0], true);
|
||||
}
|
||||
public void AddColumn(string name, string dataType, bool notNull, bool identity, object defaultValue)
|
||||
{
|
||||
TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[]
|
||||
{
|
||||
new TreeModelRowColumn(tvColumns.Model.Columns[0], name), // Name
|
||||
new TreeModelRowColumn(tvColumns.Model.Columns[1], dataType), // Data type
|
||||
new TreeModelRowColumn(tvColumns.Model.Columns[2], notNull), // Not null
|
||||
new TreeModelRowColumn(tvColumns.Model.Columns[3], identity), // Identity
|
||||
new TreeModelRowColumn(tvColumns.Model.Columns[4], defaultValue) // Default value
|
||||
});
|
||||
|
||||
tvColumns.Model.Rows.Add(row);
|
||||
tvColumns.Focus(row, tvColumns.Columns[0], tvColumns.Columns[0].Renderers[0], true);
|
||||
}
|
||||
|
||||
private void tsbColumnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
AddColumn();
|
||||
}
|
||||
private void tsbColumnEdit_Click(object sender, EventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
@ -1086,7 +1086,14 @@ namespace UniversalEditor.Editors.FileSystem
|
||||
File f = (fso as File);
|
||||
|
||||
string filePath = System.IO.Path.Combine(new string[] { fileName, System.IO.Path.GetFileName(f.Name) });
|
||||
System.IO.File.WriteAllBytes(filePath, f.GetData());
|
||||
try
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filePath, f.GetData());
|
||||
}
|
||||
catch (System.IO.IOException ex)
|
||||
{
|
||||
// FIXME: should this be an error dialog, a warning in the messages list, or ignored?
|
||||
}
|
||||
}
|
||||
else if (fso is Folder)
|
||||
{
|
||||
|
||||
@ -0,0 +1,125 @@
|
||||
//
|
||||
// TextEditor.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2019
|
||||
//
|
||||
// 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 UniversalEditor.ObjectModels.Text.Formatted;
|
||||
using UniversalEditor.UserInterface;
|
||||
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace UniversalEditor.Editors.Text.Formatted
|
||||
{
|
||||
public class FormattedTextEditor : TextEditor
|
||||
{
|
||||
protected override Selection CreateSelectionInternal(object content)
|
||||
{
|
||||
if (content is string)
|
||||
{
|
||||
txt.SelectedText = (string)content;
|
||||
return new TextEditorSelection(this, (string)content);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public override void UpdateSelections()
|
||||
{
|
||||
Selections.Clear();
|
||||
Selections.Add(new TextEditorSelection(this, txt.SelectedText, txt.SelectionStart, txt.SelectionLength));
|
||||
}
|
||||
private TextBox txt = null;
|
||||
|
||||
internal override void ClearSelectedText()
|
||||
{
|
||||
txt.SelectedText = null;
|
||||
}
|
||||
|
||||
private static EditorReference _er = null;
|
||||
public override EditorReference MakeReference ()
|
||||
{
|
||||
if (_er == null) {
|
||||
_er = base.MakeReference ();
|
||||
_er.SupportedObjectModels.Add (typeof (FormattedTextObjectModel));
|
||||
}
|
||||
return _er;
|
||||
}
|
||||
|
||||
bool working = false;
|
||||
|
||||
private void txt_Changed(object sender, EventArgs e)
|
||||
{
|
||||
FormattedTextObjectModel om = (this.ObjectModel as FormattedTextObjectModel);
|
||||
if (om == null)
|
||||
return;
|
||||
|
||||
if (!IsCreated)
|
||||
return;
|
||||
|
||||
if (!working)
|
||||
{
|
||||
if (!InEdit)
|
||||
{
|
||||
BeginEdit();
|
||||
}
|
||||
|
||||
// om.Text = txt.Text;
|
||||
txt.ResetChangedByUser();
|
||||
|
||||
OnDocumentEdited(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnObjectModelSaving(CancelEventArgs e)
|
||||
{
|
||||
base.OnObjectModelSaving(e);
|
||||
|
||||
if (InEdit)
|
||||
EndEdit();
|
||||
}
|
||||
|
||||
public FormattedTextEditor ()
|
||||
{
|
||||
txt = new TextBox();
|
||||
txt.Changed += txt_Changed;
|
||||
txt.Multiline = true;
|
||||
|
||||
this.Layout = new BoxLayout(Orientation.Vertical);
|
||||
this.Controls.Add(txt, new BoxLayout.Constraints(true, true));
|
||||
}
|
||||
|
||||
protected override void OnObjectModelChanged(EventArgs e)
|
||||
{
|
||||
base.OnObjectModelChanged(e);
|
||||
|
||||
working = true;
|
||||
txt.Text = String.Empty;
|
||||
working = false;
|
||||
|
||||
FormattedTextObjectModel om = (this.ObjectModel as FormattedTextObjectModel);
|
||||
if (om == null) return;
|
||||
|
||||
working = true;
|
||||
// txt.Text = om.Text;
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -140,6 +140,7 @@
|
||||
<Compile Include="SettingsGuids.cs" />
|
||||
<Compile Include="Panels\ToolboxPanel.cs" />
|
||||
<Compile Include="PanelReference.cs" />
|
||||
<Compile Include="Editors\Text\Formatted\FormattedTextEditor.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
@ -199,6 +200,7 @@
|
||||
<Folder Include="PrintHandlers\" />
|
||||
<Folder Include="SettingsProviders\" />
|
||||
<Folder Include="Editors\Database\Dialogs\" />
|
||||
<Folder Include="Editors\Text\Formatted\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="SettingsProviders\DefaultSettingsProvider.xml" />
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter HintComparison="FilterOnly" ContentType="application/x-merscom-scene" Title="Merscom scene graph">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.op</FileNameFilter>
|
||||
<FileNameFilter>*.vhs</FileNameFilter>
|
||||
<FileNameFilter>*.vob</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.FileSystem.FileSystemObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.Plugins.Merscom.DataFormats.Scene.SceneDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -0,0 +1,31 @@
|
||||
//
|
||||
// SceneChunk.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2022 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 UniversalEditor.ObjectModels.Chunked;
|
||||
|
||||
namespace UniversalEditor.Plugins.Merscom.DataFormats.Scene
|
||||
{
|
||||
public class SceneChunk : RIFFGroupChunk
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public byte[] Data { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,64 @@
|
||||
//
|
||||
// SceneChunkDataFormat.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2022 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 UniversalEditor.ObjectModels.Chunked;
|
||||
|
||||
namespace UniversalEditor.Plugins.Merscom.DataFormats.Scene
|
||||
{
|
||||
/// <summary>
|
||||
/// ChunkedObjectModel implementation of scene base data format.
|
||||
/// </summary>
|
||||
public class SceneChunkDataFormat : DataFormat
|
||||
{
|
||||
protected override void LoadInternal(ref ObjectModel objectModel)
|
||||
{
|
||||
ChunkedObjectModel chunked = (objectModel as ChunkedObjectModel);
|
||||
|
||||
while (!Accessor.Reader.EndOfStream)
|
||||
{
|
||||
RIFFChunk chunk = ReadChunk(Accessor.Reader);
|
||||
}
|
||||
}
|
||||
|
||||
private RIFFChunk ReadChunk(IO.Reader reader)
|
||||
{
|
||||
RIFFChunk chunk = null;
|
||||
string chunkID = reader.ReadFixedLengthString(4);
|
||||
uint preambleLength = reader.ReadUInt32();
|
||||
uint totalChunkSize = reader.ReadUInt32();
|
||||
|
||||
uint unknown1 = reader.ReadUInt32(); // offset to floats
|
||||
uint dataLength = reader.ReadUInt32();
|
||||
|
||||
byte[] data = reader.ReadBytes(dataLength);
|
||||
|
||||
chunk = new SceneChunk();
|
||||
((SceneChunk)chunk).ID = chunkID;
|
||||
((SceneChunk)chunk).Data = data;
|
||||
return chunk;
|
||||
}
|
||||
|
||||
protected override void SaveInternal(ObjectModel objectModel)
|
||||
{
|
||||
ChunkedObjectModel chunked = (objectModel as ChunkedObjectModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,45 @@
|
||||
//
|
||||
// SceneDataFormat.cs
|
||||
//
|
||||
// Author:
|
||||
// Michael Becker <alcexhim@gmail.com>
|
||||
//
|
||||
// Copyright (c) 2022 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 System.Collections.Generic;
|
||||
using UniversalEditor.DataFormats.Chunked.RIFF;
|
||||
using UniversalEditor.ObjectModels.Chunked;
|
||||
|
||||
namespace UniversalEditor.Plugins.Merscom.DataFormats.Scene
|
||||
{
|
||||
public class SceneDataFormat : SceneChunkDataFormat
|
||||
{
|
||||
protected override void BeforeLoadInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
base.BeforeLoadInternal(objectModels);
|
||||
|
||||
ChunkedObjectModel chunked = new ChunkedObjectModel();
|
||||
objectModels.Push(chunked);
|
||||
}
|
||||
protected override void AfterLoadInternal(Stack<ObjectModel> objectModels)
|
||||
{
|
||||
base.AfterLoadInternal(objectModels);
|
||||
|
||||
ChunkedObjectModel chunked = (objectModels.Pop() as ChunkedObjectModel);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<UniversalEditor Version="4.0">
|
||||
<Associations>
|
||||
<Association>
|
||||
<Filters>
|
||||
<Filter HintComparison="MagicThenFilter" Title="Intrinsic Graphics Binary (Alchemy) IGB scene graph">
|
||||
<FileNameFilters>
|
||||
<FileNameFilter>*.igb</FileNameFilter>
|
||||
</FileNameFilters>
|
||||
<MagicByteSequences>
|
||||
<MagicByteSequence Offset="40">
|
||||
<MagicByte Type="HexString">DAFA</MagicByte>
|
||||
</MagicByteSequence>
|
||||
</MagicByteSequences>
|
||||
</Filter>
|
||||
</Filters>
|
||||
<ObjectModels>
|
||||
<ObjectModel TypeName="UniversalEditor.ObjectModels.Multimedia3D.Scene.SceneObjectModel" />
|
||||
</ObjectModels>
|
||||
<DataFormats>
|
||||
<DataFormat TypeName="UniversalEditor.DataFormats.Multimedia3D.Model.Alchemy.IntrinsicGraphicsBinaryDataFormat" />
|
||||
</DataFormats>
|
||||
</Association>
|
||||
</Associations>
|
||||
</UniversalEditor>
|
||||
@ -53,6 +53,8 @@ namespace UniversalEditor.Plugins.Sega.DataFormats.PropertyList.A3DA
|
||||
if (signature != "#A3DA__________")
|
||||
throw new InvalidDataFormatException("File does not begin with '#A3DA__________'");
|
||||
|
||||
long lastreadpos = reader.Accessor.Position;
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string line = reader.ReadLine();
|
||||
@ -61,7 +63,14 @@ namespace UniversalEditor.Plugins.Sega.DataFormats.PropertyList.A3DA
|
||||
line = line.Substring(0, line.IndexOf('#'));
|
||||
|
||||
if (String.IsNullOrEmpty(line))
|
||||
{
|
||||
if (lastreadpos == reader.Accessor.Position)
|
||||
{
|
||||
// exit out of infinite loop
|
||||
return;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
string[] values = line.Split(new char[] { '=' }, 2);
|
||||
string key = values[0];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user