-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
1,366 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{1DBF8727-B98A-46B4-B9DD-6DCC698A42F8}</ProjectGuid> | ||
<OutputType>WinExe</OutputType> | ||
<RootNamespace>_7sCarletSceneEditor</RootNamespace> | ||
<AssemblyName>7sCarletSceneEditor</AssemblyName> | ||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Be.Windows.Forms.HexBox, Version=1.6.1.0, Culture=neutral, processorArchitecture=MSIL"> | ||
<HintPath>..\packages\Be.Windows.Forms.HexBox.1.6.1\lib\net40\Be.Windows.Forms.HexBox.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Deployment" /> | ||
<Reference Include="System.Drawing" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Windows.Forms" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="InstructionByteProvider.cs" /> | ||
<Compile Include="InstructionDataSource.cs" /> | ||
<Compile Include="InstructionListViewItem.cs" /> | ||
<Compile Include="Instructions.cs" /> | ||
<Compile Include="InstructionTextBox.cs"> | ||
<SubType>Component</SubType> | ||
</Compile> | ||
<Compile Include="MainWindow.cs"> | ||
<SubType>Form</SubType> | ||
</Compile> | ||
<Compile Include="MainWindow.Designer.cs"> | ||
<DependentUpon>MainWindow.cs</DependentUpon> | ||
</Compile> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
<Compile Include="Scenario.cs" /> | ||
<Compile Include="Utility.cs" /> | ||
<EmbeddedResource Include="MainWindow.resx"> | ||
<DependentUpon>MainWindow.cs</DependentUpon> | ||
</EmbeddedResource> | ||
<EmbeddedResource Include="Properties\Resources.resx"> | ||
<Generator>ResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> | ||
<SubType>Designer</SubType> | ||
</EmbeddedResource> | ||
<Compile Include="Properties\Resources.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
<None Include="packages.config" /> | ||
<None Include="Properties\Settings.settings"> | ||
<Generator>SettingsSingleFileGenerator</Generator> | ||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> | ||
</None> | ||
<Compile Include="Properties\Settings.Designer.cs"> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Settings.settings</DependentUpon> | ||
<DesignTimeSharedInput>True</DesignTimeSharedInput> | ||
</Compile> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Be.Windows.Forms; | ||
|
||
namespace _7sCarletSceneEditor | ||
{ | ||
public class InstructionByteProvider : IByteProvider | ||
{ | ||
private bool _ignoreNextChange = false; | ||
|
||
public List<byte> Bytes { get; set; } | ||
private InstructionDataSource DataSource { get; } | ||
public IBinaryRepresentable Instruction { get; } | ||
public long Length => Bytes.Count; | ||
|
||
public event EventHandler LengthChanged; | ||
public event EventHandler Changed; | ||
|
||
public InstructionByteProvider(IBinaryRepresentable instruction) | ||
{ | ||
Instruction = instruction; | ||
Bytes = new List<byte>(instruction.Data); | ||
} | ||
|
||
public InstructionByteProvider(InstructionDataSource dataSource) | ||
{ | ||
var data = dataSource.Data; | ||
this.DataSource = dataSource; | ||
if (data == null) | ||
this.Bytes = new List<byte>(); | ||
else this.Bytes = new List<byte>(data); | ||
dataSource.DataChanged += val => | ||
{ | ||
if (_ignoreNextChange) | ||
_ignoreNextChange = false; | ||
else this.Bytes = new List<byte>(val); | ||
}; | ||
this.Changed += (a, b) => ApplyChanges(); | ||
} | ||
|
||
public void ApplyChanges() | ||
{ | ||
_ignoreNextChange = true; | ||
DataSource.Data = Bytes.ToArray(); | ||
//Instruction.Data = Bytes.ToArray(); | ||
} | ||
|
||
public void DeleteBytes(long index, long length) | ||
{ | ||
Bytes.RemoveRange((int)index, (int)length); | ||
LengthChanged?.Invoke(this, new EventArgs()); | ||
Changed?.Invoke(this, new EventArgs()); | ||
} | ||
|
||
public bool HasChanges() | ||
{ | ||
// TODO: does this get called often? If not, equality check with loop will do | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void InsertBytes(long index, byte[] bs) | ||
{ | ||
Bytes.InsertRange((int)index, bs); | ||
LengthChanged?.Invoke(this, new EventArgs()); | ||
Changed?.Invoke(this, new EventArgs()); | ||
} | ||
|
||
public byte ReadByte(long index) | ||
{ | ||
return Bytes[(int)index]; | ||
} | ||
|
||
public void WriteByte(long index, byte value) | ||
{ | ||
Bytes[(int)index] = value; | ||
Changed?.Invoke(this, new EventArgs()); | ||
} | ||
|
||
public bool SupportsDeleteBytes() | ||
{ | ||
return true; | ||
} | ||
|
||
public bool SupportsInsertBytes() | ||
{ | ||
return true; | ||
} | ||
|
||
public bool SupportsWriteByte() | ||
{ | ||
return true; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace _7sCarletSceneEditor | ||
{ | ||
public class InstructionDataSource | ||
{ | ||
private Instruction _instruction; | ||
|
||
public string Text | ||
{ | ||
get | ||
{ | ||
if (_instruction is ITextRepresentable tr) | ||
return tr.Text; | ||
return null; | ||
} | ||
set | ||
{ | ||
if (_instruction is ITextRepresentable tr) | ||
tr.Text = value; | ||
else throw new ArgumentException("Current instruction does not support text data!"); | ||
} | ||
} | ||
|
||
public byte[] Data | ||
{ | ||
get | ||
{ | ||
if (_instruction is IBinaryRepresentable br) | ||
return br.Data; | ||
return null; | ||
} | ||
set | ||
{ | ||
if (_instruction is IBinaryRepresentable br) | ||
br.Data = value; | ||
else throw new ArgumentException("Current instruction does not support binary data!"); | ||
} | ||
} | ||
|
||
public Instruction Instruction | ||
{ | ||
get => _instruction; | ||
set | ||
{ | ||
if (_instruction != null) | ||
_instruction.ContentChanged -= OnInstructionChanged; | ||
value.ContentChanged += OnInstructionChanged; | ||
_instruction = value; | ||
OnInstructionChanged(value, EventArgs.Empty); | ||
} | ||
} | ||
|
||
public event Action<string> TextChanged; | ||
public event Action<byte[]> DataChanged; | ||
|
||
private void OnInstructionChanged(object sender, EventArgs args) | ||
{ | ||
if (_instruction is ITextRepresentable tr) | ||
TextChanged?.Invoke(tr.Text); | ||
if (_instruction is IBinaryRepresentable br) | ||
DataChanged?.Invoke(br.Data); | ||
} | ||
|
||
/* | ||
public void SetText(string text) | ||
{ | ||
if (_instruction is ITextRepresentable tr) | ||
tr.Text = text; | ||
else throw new ArgumentException("Current instruction does not support text data!"); | ||
} | ||
public void SetData(byte[] data) | ||
{ | ||
if (_instruction is IBinaryRepresentable br) | ||
br.Data = data; | ||
else throw new ArgumentException("Current instruction does not support binary data!"); | ||
} | ||
*/ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace _7sCarletSceneEditor | ||
{ | ||
public class InstructionListViewItem : ListViewItem | ||
{ | ||
public Instruction Instruction { get; } | ||
public InstructionListViewItem(Instruction instruction) | ||
{ | ||
Instruction = instruction; | ||
this.Text = $"0x{instruction.Opcode:X4}"; | ||
SubItems.Add(instruction.Name); | ||
SubItems.Add(instruction.ContentType); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace _7sCarletSceneEditor | ||
{ | ||
public class InstructionTextBox : TextBox | ||
{ | ||
private bool _ignoreNextChange = false; | ||
public InstructionDataSource DataSource { get; } | ||
|
||
public InstructionTextBox(InstructionDataSource dataSource) | ||
{ | ||
Multiline = true; | ||
|
||
Text = dataSource.Text ?? string.Empty; | ||
this.DataSource = dataSource; | ||
dataSource.TextChanged += text => | ||
{ | ||
if (_ignoreNextChange) | ||
_ignoreNextChange = false; | ||
else this.Text = text; | ||
}; | ||
this.TextChanged += (a, b) => | ||
{ | ||
_ignoreNextChange = true; | ||
DataSource.Text = Text; | ||
}; | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.