preliminary implementation of New World Computing map editor for Heroes of Might and Magic II
This commit is contained in:
parent
854ba278c8
commit
477ebaed5a
@ -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="mapView">
|
||||
<property name="name">UniversalEditor.Plugins.NewWorldComputing.UserInterface.Editors.NewWorldComputing.Map.Controls.MapViewControl</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>
|
||||
@ -739,6 +739,7 @@
|
||||
<Content Include="Editors\Multimedia\Audio\Waveform\Controls\WaveformAudioEditorTrackControlPanel.glade" />
|
||||
<Content Include="Editors\Multimedia\Audio\Waveform\Controls\WaveformAudioEditorTrack.glade" />
|
||||
<Content Include="Editors\Multimedia\Audio\Synthesized\Views\MIDIEvents\MIDIEventsView.glade" />
|
||||
<Content Include="Editors\NewWorldComputing\Map\MapEditor.glade" />
|
||||
<Content Include="Editors\Multimedia\PictureCollection\PictureCollectionEditor.glade" />
|
||||
<Content Include="Editors\Multimedia\PictureCollection\Dialogs\AnimationPropertiesDialog.glade" />
|
||||
</ItemGroup>
|
||||
|
||||
@ -0,0 +1,108 @@
|
||||
//
|
||||
// MapViewControl.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.UserInterface;
|
||||
using MBS.Framework.UserInterface.Drawing;
|
||||
using UniversalEditor.Accessors;
|
||||
using UniversalEditor.DataFormats.FileSystem.NewWorldComputing.AGG;
|
||||
using UniversalEditor.DataFormats.Multimedia.Picture.NewWorldComputing.ICN;
|
||||
using UniversalEditor.DataFormats.Multimedia.Picture.NewWorldComputing.TIL;
|
||||
using UniversalEditor.ObjectModels.FileSystem;
|
||||
using UniversalEditor.ObjectModels.Multimedia.Picture;
|
||||
using UniversalEditor.ObjectModels.Multimedia.Picture.Collection;
|
||||
using UniversalEditor.ObjectModels.NewWorldComputing.Map;
|
||||
|
||||
using UniversalEditor.Plugins.Multimedia.UserInterface;
|
||||
|
||||
namespace UniversalEditor.Plugins.NewWorldComputing.UserInterface.Editors.NewWorldComputing.Map.Controls
|
||||
{
|
||||
public class MapViewControl : CustomControl
|
||||
{
|
||||
private int _TileSize = 32;
|
||||
public int TileSize { get { return _TileSize; } set { _TileSize = value; } }
|
||||
|
||||
private MBS.Framework.UserInterface.Drawing.Pen pbk = new MBS.Framework.UserInterface.Drawing.Pen(SystemColors.HighlightBackground);
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
|
||||
MapEditor ed = (Parent as MapEditor);
|
||||
if (ed == null) return;
|
||||
|
||||
MapObjectModel map = (ed.ObjectModel as MapObjectModel);
|
||||
e.Graphics.DrawRectangle(pbk, new MBS.Framework.Drawing.Rectangle(0, 0, map.Width * TileSize, map.Height * TileSize));
|
||||
|
||||
int x = 0, y = 0;
|
||||
for (int i = 0; i < map.Tiles.Count; i++)
|
||||
{
|
||||
if (x >= (TileSize * map.Width))
|
||||
{
|
||||
x = 0;
|
||||
y += TileSize;
|
||||
}
|
||||
|
||||
if (!(x >= HorizontalAdjustment.Value + Size.Width || y >= VerticalAdjustment.Value + Size.Height))
|
||||
{
|
||||
DrawTile(e.Graphics, map.Tiles[i], x, y);
|
||||
}
|
||||
|
||||
x += TileSize;
|
||||
}
|
||||
}
|
||||
|
||||
PictureCollectionObjectModel spriteTile = null;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the <see cref="spriteTile" /> <see cref="PictureCollectionObjectModel" /> with tile images from the game. This function should be called only once.
|
||||
/// </summary>
|
||||
private void InitSpriteTile()
|
||||
{
|
||||
if (spriteTile != null) return; // already done
|
||||
|
||||
string aggpath = @"/opt/fheroes2/data/HEROES2.AGG";
|
||||
string tilepath = "GROUND32.TIL";
|
||||
|
||||
FileSystemObjectModel fsomAgg = new FileSystemObjectModel();
|
||||
using (Document.Load(fsomAgg, new AGGDataFormat(), new FileAccessor(aggpath), false))
|
||||
{
|
||||
File fileTile = fsomAgg.Files[tilepath];
|
||||
if (fileTile == null) return;
|
||||
|
||||
byte[] dataTile = fileTile.GetData();
|
||||
MemoryAccessor maTile = new MemoryAccessor(dataTile);
|
||||
|
||||
TILDataFormat icndf = new TILDataFormat();
|
||||
|
||||
spriteTile = new PictureCollectionObjectModel();
|
||||
Document.Load(spriteTile, icndf, maTile);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawTile(Graphics graphics, MapTile tile, int x, int y)
|
||||
{
|
||||
InitSpriteTile();
|
||||
|
||||
PictureObjectModel pic = spriteTile.Pictures[tile.IndexName2];
|
||||
graphics.DrawImage(pic.ToImage(), x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,74 @@
|
||||
//
|
||||
// MyClass.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.UserInterface;
|
||||
using UniversalEditor.ObjectModels.NewWorldComputing.Map;
|
||||
using UniversalEditor.UserInterface;
|
||||
|
||||
namespace UniversalEditor.Plugins.NewWorldComputing.UserInterface.Editors.NewWorldComputing.Map
|
||||
{
|
||||
[ContainerLayout("~/Editors/NewWorldComputing/Map/MapEditor.glade")]
|
||||
public class MapEditor : Editor
|
||||
{
|
||||
private Controls.MapViewControl mapView;
|
||||
|
||||
private static EditorReference _er = null;
|
||||
public override EditorReference MakeReference()
|
||||
{
|
||||
if (_er == null)
|
||||
{
|
||||
_er = base.MakeReference();
|
||||
_er.SupportedObjectModels.Add(typeof(MapObjectModel));
|
||||
}
|
||||
return _er;
|
||||
}
|
||||
|
||||
public override void UpdateSelections()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override EditorSelection CreateSelectionInternal(object content)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
protected override void OnCreated(EventArgs e)
|
||||
{
|
||||
base.OnCreated(e);
|
||||
OnObjectModelChanged(e);
|
||||
}
|
||||
|
||||
protected override void OnObjectModelChanged(EventArgs e)
|
||||
{
|
||||
base.OnObjectModelChanged(e);
|
||||
|
||||
if (!IsCreated) return;
|
||||
|
||||
MapObjectModel map = (ObjectModel as MapObjectModel);
|
||||
if (map == null) return;
|
||||
|
||||
mapView.Refresh();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@ -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.NewWorldComputing.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("")]
|
||||
@ -0,0 +1,79 @@
|
||||
<?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>{03B0D6C8-1C3C-4972-B102-3350FB628C5D}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>UniversalEditor.Plugins.NewWorldComputing.UserInterface</RootNamespace>
|
||||
<AssemblyName>UniversalEditor.Plugins.NewWorldComputing.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\NewWorldComputing\Map\MapEditor.cs" />
|
||||
<Compile Include="Editors\NewWorldComputing\Map\Controls\MapViewControl.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Editors\" />
|
||||
<Folder Include="Editors\NewWorldComputing\" />
|
||||
<Folder Include="Editors\NewWorldComputing\Map\" />
|
||||
<Folder Include="Editors\NewWorldComputing\Map\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.NewWorldComputing\UniversalEditor.Plugins.NewWorldComputing.csproj">
|
||||
<Project>{26095090-3F7D-4DB5-A9BF-4C687230FC0F}</Project>
|
||||
<Name>UniversalEditor.Plugins.NewWorldComputing</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>
|
||||
<ProjectReference Include="..\..\Plugins\UniversalEditor.Plugins.Multimedia\UniversalEditor.Plugins.Multimedia.csproj">
|
||||
<Project>{BE4D0BA3-0888-42A5-9C09-FC308A4509D2}</Project>
|
||||
<Name>UniversalEditor.Plugins.Multimedia</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\UniversalEditor.Plugins.Multimedia.UserInterface\UniversalEditor.Plugins.Multimedia.UserInterface.csproj">
|
||||
<Project>{D9D5AC3B-9AC0-4D4E-B295-2134FDCF166C}</Project>
|
||||
<Name>UniversalEditor.Plugins.Multimedia.UserInterface</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@ -171,6 +171,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Ami
|
||||
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
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.NewWorldComputing.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.NewWorldComputing.UserInterface\UniversalEditor.Plugins.NewWorldComputing.UserInterface.csproj", "{03B0D6C8-1C3C-4972-B102-3350FB628C5D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -495,6 +497,10 @@ Global
|
||||
{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
|
||||
{03B0D6C8-1C3C-4972-B102-3350FB628C5D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{03B0D6C8-1C3C-4972-B102-3350FB628C5D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{03B0D6C8-1C3C-4972-B102-3350FB628C5D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{03B0D6C8-1C3C-4972-B102-3350FB628C5D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{6F0AB1AF-E1A1-4D19-B19C-05BBB15C94B2} = {05D15661-E684-4EC9-8FBD-C014BA433CC5}
|
||||
@ -575,6 +581,7 @@ Global
|
||||
{C8953DB2-AE48-4F04-87EC-549E6A3E30D8} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
|
||||
{BCEB66A6-24E3-4877-B8D4-83FCF8EC748B} = {2ED32D16-6C06-4450-909A-40D32DA67FB4}
|
||||
{08168BEA-E652-4493-8D89-5AB72B225841} = {7B535D74-5496-4802-B809-89ED88274A91}
|
||||
{03B0D6C8-1C3C-4972-B102-3350FB628C5D} = {7B535D74-5496-4802-B809-89ED88274A91}
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
Policies = $0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user