diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 00000000..aa79b108 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,15 @@ +# These are supported funding model platforms + +#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +#patreon: # Replace with a single Patreon username +#open_collective: # Replace with a single Open Collective username +ko_fi: remaarn +#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +#liberapay: # Replace with a single Liberapay username +#issuehunt: # Replace with a single IssueHunt username +#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry +#polar: # Replace with a single Polar username +#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username +#thanks_dev: # Replace with a single thanks.dev username +#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/issue_template.md b/.github/issue_template.md index af68a343..b0fbf645 100644 --- a/.github/issue_template.md +++ b/.github/issue_template.md @@ -1,19 +1,20 @@ -- [ ] Ensure you have installed the latest version of SEToolbox installed. Visit [latest release](https://github.com/midspace/SEToolbox/releases/latest) to verify. -- [ ] Ensure that the issue is reproducible for testing. You may be requested to provide a link to a test world if we cannot reproduce it with your information. -- [ ] Retrieve the Event Log from when SEToolbox crashed. Read the following [instructions](https://github.com/midspace/SEToolbox/wiki/Reporting-bugs) on retrieving the event log. +- [ ] Ensure you are using the latest version of SEToolbox. You can get it from [here.](https://github.com/mmusu3/SEToolbox/releases/latest) +- [ ] Ensure that the issue is reproducible, that you can make it occur more than once. +- [ ] If the issue involves a world / blueprint, please provide the relevant files if possible. +- [ ] In the case of a crash find the log.txt file in the application folder. +Please provide the relevant version numbers. +**SEToolbox Version:** `1.xxx.xxx.x` +**SE Version:** `1.xxx.xxx` -**SEToolbox Version:** 1.x.xxx.xxx -**SE Version:** 1.xxx.xxx - -### SEToolbox crashed -What were you doing with SEToolbox when it happened? +### Issue Description +What is the issue and what were you doing with SEToolbox when it occurred? ### Steps to Reproduce 1. How did this issue get triggered? 2. Write all of the steps here. -### SEToolbox Event Log +### SEToolbox Log File ``` -Paste your event log here. +Paste the contents of your log file here or upload the file if it is large. ``` \ No newline at end of file diff --git a/.gitignore b/.gitignore index 53a15860..14e77cbe 100644 --- a/.gitignore +++ b/.gitignore @@ -233,12 +233,6 @@ FakesAssemblies/ # Visual Studio 6 workspace options file *.opt - - - -# Shader generated files. -*.ps - *.props *.vsprops user.targets diff --git a/Dev/SEToolbox/BuildScripts/Build.proj b/Dev/SEToolbox/BuildScripts/Build.proj deleted file mode 100644 index 6594d0ed..00000000 --- a/Dev/SEToolbox/BuildScripts/Build.proj +++ /dev/null @@ -1,187 +0,0 @@ - - - - - - - - - $(ProgramFiles) (x86) - - - - - $(ProgramFiles) - - - - - - $(ProgramFilesPath)\Microsoft Visual Studio 10.0\Common7\IDE - - $(ReleaseRoot)\binaries - $(SolutionRoot)\SEToolbox\SEToolbox\Properties\AssemblyInfo.cs - - Release - Debug - - - - - - - - - true - - - Never - - - - - Bug - - - System.Reason=Build Failure;System.Description=Start the build using Team Build - - - Build failure in build: - - - This work item was created by Team Build on a build failure. - - - The build log file is at: - - - The errors/warnings log file is at: - - - false - - - - - - - - - - - - true - - - $(MSBuildProjectDirectory)/Build.TestSettings - - - - - $(ComputeSolutionListDependsOn);SetupSolutionList - - - - - - - true - - - - - false - - - - - - - - - Platform=Any CPU - - - - - - - - - Debug - Any CPU - - - Release - Any CPU - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Dev/SEToolbox/BuildScripts/Microsoft.Build.targets b/Dev/SEToolbox/BuildScripts/Microsoft.Build.targets deleted file mode 100644 index f1a63e2c..00000000 --- a/Dev/SEToolbox/BuildScripts/Microsoft.Build.targets +++ /dev/null @@ -1,1772 +0,0 @@ - - - - - - - - 4.0 - - - $(TeamBuildRefPath) - - - false - - - false - - - false - - - true - - - 2 - - - - 4 - - - $(MSBuildProjectDirectory) - - - false - - - false - - - true - - - false - - - false - - - - - - false - - - - - - false - - - - - - true - - - - - - - - true - - - true - - - true - - - false - - - false - - - false - - - GetTargetPath;GetNativeManifest;GetCopyToOutputDirectoryItems - - - $(MSBuildProjectDirectory)\..\.. - - - src - - - $(MSBuildProjectDirectory)\..\$(SourcesSubdirectory) - - - bin - - - $(SolutionRoot)\..\$(BinariesSubdirectory) - - - TestResults - - - $(SolutionRoot)\..\$(TestResultsSubdirectory) - - - $(COMPUTERNAME)_$(BuildDefinitionId)_$(BuildAgentId) - - - Workspace created by Team Build - - - true - - - false - - - true - - - $(SourceGetVersion) - - - - - - false - - - true - - - true - - - true - - - true - - - Replace - - - Label created by Team Build - - - - - - $/ - - - $/$(TeamProject) - - - - - - - - - - - - - - - %3C?xml version=%221.0%22?%3E%0D%0A%3CVisualStudioPropertySheet ProjectType=%22Visual C++%22 Version=%228.00%22 Name=%22Team Build Overrides%22 - - - %3C/VisualStudioPropertySheet%3E - - - %3C?xml version=%221.0%22?%3E%0D%0A%3CProject ToolsVersion=%224.0%22 xmlns=%22http://schemas.microsoft.com/developer/msbuild/2003%22%3E - - - %3C/Project%3E - - - false - - - false - - - false - - - $(TeamBuildOutDir) - - - $(TeamBuildPublishDir) - - - true - - - - - - - - - - - - - <_SolutionRoot>@(SolutionRootItem->'%(FullPath)') - <_BinariesRoot>@(BinariesRootItem->'%(FullPath)') - <_TestResultsRoot>@(TestResultsRootItem->'%(FullPath)') - - - - - - - $(NetSamplePath)\..\..\Common7\IDE - $(DevEnvDir)\PrivateAssemblies - - - $(TeamBuildRefPath) - - - $(NetSamplePath)\..\.. - $(VSINSTALLDIR)\Team Tools\Static Analysis Tools\FxCop - - - - - - - - $(_SolutionRoot) - $(_BinariesRoot) - $(_TestResultsRoot) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - false - - true - false - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - Compile; - Test; - GenerateDocumentation; - PackageBinaries; - - - - - - - - Clean; - DesktopBuild; - - - - - - - - - - - - - CheckSettingsForEndToEndIteration; - InitializeBuildProperties; - BeforeEndToEndIteration; - BuildNumberOverrideTarget; - InitializeEndToEndIteration; - InitializeWorkspace; - TeamBuild; - DropBuild; - RevertWorkspace; - AfterEndToEndIteration; - - - - - - - - - - - - - - true - true - false - - - - - true - true - false - - - - - - - $(BuildNumber) - - - - - - - - BeforeClean; - CoreCleanAll; - AfterClean; - - - - - - - - BeforeClean; - CallClean; - AfterClean; - - - - - - - - - - - BeforeClean; - CoreClean; - AfterClean; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ComputeConfigurationList; - - - - - - - - - - - - - - - - - - - - BeforeCleanConfiguration; - CoreCleanConfiguration; - AfterCleanConfiguration; - - - - - - - - - - ComputeSolutionList; - - - - - - - - - - - - - $(Platform) - $(Configuration) - - - - - - - - - - - - BeforeCleanSolution; - CoreCleanSolution; - AfterCleanSolution; - - - - - - - - - - - $(Solution).$(Platform).$(Configuration).vsprops - $(Solution).$(Configuration).vsprops - $(Solution).$(Platform).$(Configuration).ForceImportBeforeCppTargets.props - $(Solution).$(Configuration).ForceImportBeforeCppTargets.props - OutDir=$(TeamBuildOutDir) - PublishDir=$(TeamBuildPublishDir) - - - - - - - - - - - - - - - - - - - - CleanAll; - InitializeBuild; - PreBuild; - CleanCompilationOutput; - Compile; - PostBuild; - GetImpactedTests; - Test; - GenerateDocumentation; - PackageBinaries; - - - - - - - - - - - - - - - Get; - Label; - - - - - - - - - - BeforeInitializeWorkspace; - CoreInitializeWorkspace; - AfterInitializeWorkspace; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BeforeGet; - CoreGet; - AfterGet; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(GetVersion) - - - - - - - - - - BeforeLabel; - CoreLabel; - AfterLabel; - - - - - - - - - - - - - - - - W$(WorkspaceName) - - - - - - - - - - - - - - - - BeforeCompile; - CallCompile; - AfterCompile; - - - - - - - - - - - - - - - - - $(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\ - $(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\ - - - - - - - - - - - - - <_CoreCompileDependsOn> - ComputeConfigurationList; - - - - - - - - - - - - - - - - - - - BeforeCompileConfiguration; - CoreCompileConfiguration; - AfterCompileConfiguration; - - - - - - - - - - - - ComputeSolutionList; - - - - - - - - - - - - - $(Platform) - $(Configuration) - - - - - - - - - - - BeforeCompileSolution; - CoreCompileSolution; - AfterCompileSolution; - - - - - - - - - - - - _TEAM_BUILD_ - - - - - RunCodeAnalysis=true - %09%3CTool Name=%22VCCLCompilerTool%22 EnablePREfast=%22true%22 /%3E%0D%0A%09%3CTool Name=%22VCFxCopTool%22 EnableFxCop=%22true%22 /%3E%0D%0A - RunCodeAnalysis=false - %09%3CTool Name=%22VCCLCompilerTool%22 EnablePREfast=%22false%22 /%3E%0D%0A%09%3CTool Name=%22VCFxCopTool%22 EnableFxCop=%22false%22 /%3E%0D%0A - %09%3CItemDefinitionGroup%3E%0D%0A%09%09%3CClCompile%3E%0D%0A%09%09%09%3CEnablePREfast%3Etrue%3C/EnablePREfast%3E%0D%0A%09%09%3C/ClCompile%3E%0D%0A%09%3C/ItemDefinitionGroup%3E - %09%3CItemDefinitionGroup%3E%0D%0A%09%09%3CClCompile%3E%0D%0A%09%09%09%3CEnablePREfast%3Efalse%3C/EnablePREfast%3E%0D%0A%09%09%3C/ClCompile%3E%0D%0A%09%3C/ItemDefinitionGroup%3E - $(Solution).$(Platform).$(Configuration).vsprops - $(Solution).$(Configuration).vsprops - $(Solution).$(Platform).$(Configuration).ForceImportBeforeCppTargets.props - $(Solution).$(Configuration).ForceImportBeforeCppTargets.props - ReferencePath=$(ReferencePath);@(AdditionalReferencePath) - OutDir=$(TeamBuildOutDir) - PublishDir=$(TeamBuildPublishDir) - FxCopDir=$(FxCopDir) - - - - - - - - - - - - - - - - - - - $(Solution) - - - - - - - - GetChangesetsAndUpdateWorkItems; - - - - - - - - - - BeforeGetChangesetsAndUpdateWorkItems; - CoreGetChangesetsAndUpdateWorkItems; - AfterGetChangesetsAndUpdateWorkItems; - - - - - - - - - - - - - - - - - - - - - - - - - - - BeforeTest; - CoreTest; - AfterTest; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ComputeConfigurationList; - - - - - - - - - - - - - - - - - - - BeforeTestConfiguration; - CoreTestConfiguration; - AfterTestConfiguration; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ResolveTestFilesForEndToEndIteration; - - - - - - - - - true - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - $(Platform) - $(Configuration) - - - - $(Platform) - $(Configuration) - - - - $(Platform) - $(Configuration) - - - - - - - - - - - - - - - - - BeforeDropBuild; - CoreDropBuild; - AfterDropBuild; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BeforeRevertWorkspace; - CoreRevertWorkspace; - AfterRevertWorkspace; - - - - - - - - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - true - - - - - - - - - - - - - - - - BeforeOnBuildBreak; - CoreOnBuildBreak; - AfterOnBuildBreak; - - - - - - - - - - GetChangesetsOnBuildBreak; - DropBuild; - CreateWorkItem; - RevertWorkspace; - - - - - - - - - - BeforeGetChangesetsOnBuildBreak; - CoreGetChangesetsOnBuildBreak; - AfterGetChangesetsOnBuildBreak; - - - - - - - - - - - - - - - - - - - - - - - BeforeCreateWorkItem; - CoreCreateWorkItem; - AfterCreateWorkItem; - - - - - - - - - - - - - - - $(WorkItemTitle) $(BuildNumber) - $(BuildlogText) <a href='file:///$(DropLocation)\$(BuildNumber)\BuildLog.txt'>$(DropLocation)\$(BuildNumber)\BuildLog.txt</a >. - - $(ErrorWarningLogText) <a href='file:///$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt'>$(DropLocation)\$(BuildNumber)\ErrorsWarningsLog.txt</a >. - $(DescriptionText) %3CBR%2F%3E $(BuildlogText) %3CBR%2F%3E $(ErrorWarningLogText) - - - - - - - - - - - - - Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.PlatformToBuild)\%(ConfigurationToBuild.FlavorToBuild)\ - - - - Configuration=%(ConfigurationToBuild.FlavorToBuild);Platform=%(ConfigurationToBuild.PlatformToBuild);TeamBuildOutDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\;TeamBuildPublishDir=$(BinariesRoot)\%(ConfigurationToBuild.FlavorToBuild)\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ResolveSolutionPathsForDesktopBuild; - ResolveSolutionPathsForEndToEndIteration; - - - - - - - - Solution=%(LocalSolutionToBuild.Identity);Targets=%(LocalSolutionToBuild.Targets);CustomProperties=%(LocalSolutionToBuild.Properties) - - - - Solution=%(LocalSolutionToPublish.Identity);Targets=Publish;CustomProperties=%(LocalSolutionToPublish.Properties) - - - - - - - - - - - - - - - - - - - diff --git a/Dev/SEToolbox/BuildScripts/SEToolbox.targets b/Dev/SEToolbox/BuildScripts/SEToolbox.targets deleted file mode 100644 index b1792e11..00000000 --- a/Dev/SEToolbox/BuildScripts/SEToolbox.targets +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - $([System.DateTime]::Now.ToString('$(DateTimeFormat)')) - $(SolutionRoot)/SEToolbox/SEToolbox/bin/$(Configuration)/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \[assembly: AssemblyFileVersion\("(\d+\.\d+\.\d+\.\d+) - @(ItemsFromFile) - $([System.Text.RegularExpressions.Regex]::Match($(In), $(Pattern), System.Text.RegularExpressions.RegexOptions.Multiline).Groups[1].Value) - - - - - diff --git a/Dev/SEToolbox/References/HelixToolkit.Wpf.dll b/Dev/SEToolbox/References/HelixToolkit.Wpf.dll deleted file mode 100644 index 5a862589..00000000 Binary files a/Dev/SEToolbox/References/HelixToolkit.Wpf.dll and /dev/null differ diff --git a/Dev/SEToolbox/SEToolbox.Image.Library/Properties/AssemblyInfo.cs b/Dev/SEToolbox/SEToolbox.Image.Library/Properties/AssemblyInfo.cs deleted file mode 100644 index b3a68590..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Library/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SEToolbox.ImageLibrary")] -[assembly: AssemblyDescription("Space Engineers Toolbox - Image Library")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Mid-Space Productions")] -[assembly: AssemblyProduct("SEToolbox.ImageLibrary")] -[assembly: AssemblyCopyright("Copyright © MidSpace 2013-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("a3a1cbdf-a9b3-4695-a84f-b43dc8ae4ed4")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] - diff --git a/Dev/SEToolbox/SEToolbox.Image.Library/SEToolbox.ImageLibrary.csproj b/Dev/SEToolbox/SEToolbox.Image.Library/SEToolbox.ImageLibrary.csproj deleted file mode 100644 index e0067692..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Library/SEToolbox.ImageLibrary.csproj +++ /dev/null @@ -1,102 +0,0 @@ - - - - - Debug - AnyCPU - {E78476CB-BC3D-4265-806D-96F09229A449} - Library - Properties - SEToolbox.ImageLibrary - SEToolbox.ImageLibrary - v4.0 - 512 - SAK - SAK - SAK - SAK - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - true - - - none - true - bin\Release\ - TRACE - prompt - 4 - true - - - true - - - ..\SEToolbox.snk - - - true - bin\x64\Debug\ - DEBUG;TRACE - true - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - true - x64 - prompt - MinimumRecommendedRules.ruleset - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox.Image.Shaders/Properties/AssemblyInfo.cs b/Dev/SEToolbox/SEToolbox.Image.Shaders/Properties/AssemblyInfo.cs deleted file mode 100644 index c38d7acb..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Shaders/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,44 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SEToolbox.ImageShaders")] -[assembly: AssemblyDescription("Space Engineers Toolbox - Image Shaders Library")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Mid-Space Productions")] -[assembly: AssemblyProduct("SEToolbox.ImageShadersy")] -[assembly: AssemblyCopyright("Copyright © MidSpace 2013-2015")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: CLSCompliant(true)] - -//Establish Minimum security permissions -//[assembly: SecurityPermission(SecurityAction.RequestMinimum.RequestMinimum, Execution=true)] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("62f802b1-45f5-429c-849c-a981db31c2e0")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Dev/SEToolbox/SEToolbox.Image.Shaders/SEToolbox.ImageShaders.csproj b/Dev/SEToolbox/SEToolbox.Image.Shaders/SEToolbox.ImageShaders.csproj deleted file mode 100644 index 4f857954..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Shaders/SEToolbox.ImageShaders.csproj +++ /dev/null @@ -1,106 +0,0 @@ - - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {967D61A9-C8F0-4C2A-A784-6CDA648ECB19} - Library - Properties - SEToolbox.ImageShaders - SEToolbox.ImageShaders - v4.0 - 512 - SAK - SAK - SAK - SAK - - - - - 3.5 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - none - true - bin\Release\ - TRACE - prompt - 4 - - - - - true - - - ..\SEToolbox.snk - - - true - bin\x64\Debug\ - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - - - bin\x64\Release\ - TRACE - true - x64 - prompt - MinimumRecommendedRules.ruleset - - - - - - 3.5 - - - 3.5 - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - EffectCompile;$(PrepareResourcesDependsOn) - - \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Desaturate.fx b/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Desaturate.fx deleted file mode 100644 index 4c65921f..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Desaturate.fx +++ /dev/null @@ -1,59 +0,0 @@ -//-------------------------------------------------------------------------------------- -// -// WPF ShaderEffect HLSL -- DesaturateEffect -// -//-------------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------------- -// Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) -//----------------------------------------------------------------------------------------- - - -//-------------------------------------------------------------------------------------- -// Sampler Inputs (Brushes, including ImplicitInput) -//-------------------------------------------------------------------------------------- - -sampler2D implicitInputSampler : register(S0); - -//-------------------------------------------------------------------------------------- -// Pixel Shader -//-------------------------------------------------------------------------------------- - -float4 main(float2 uv : TEXCOORD) : COLOR -{ - float2 texuv = uv; - float4 finalColor; - float maxColor; - float minColor; - float gColor; - - float4 srcColor = tex2D(implicitInputSampler, texuv); - - if( srcColor.a == 0 ) - { - finalColor = srcColor; - } - else - { - // Desaturate algorithm. Replicates the Photoshop Desaturate filter. - // However this may not properly take into account the Alpha Channel. - - maxColor = srcColor.r; - if (maxColor < srcColor.g) - maxColor = srcColor.g; - if (maxColor < srcColor.b) - maxColor = srcColor.b; - - minColor = srcColor.r; - if (minColor > srcColor.g) - minColor = srcColor.g; - if (minColor > srcColor.b) - minColor = srcColor.b; - - float4 luminance = (minColor + maxColor) / 2.00; - luminance.a = srcColor.a; - finalColor = luminance; - } - return finalColor; -} - diff --git a/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Greyscale.fx b/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Greyscale.fx deleted file mode 100644 index 8dcfc958..00000000 --- a/Dev/SEToolbox/SEToolbox.Image.Shaders/ShaderSource/Greyscale.fx +++ /dev/null @@ -1,40 +0,0 @@ -//-------------------------------------------------------------------------------------- -// -// WPF ShaderEffect HLSL -- GreyscaleEffect -// -//-------------------------------------------------------------------------------------- - -//----------------------------------------------------------------------------------------- -// Shader constant register mappings (scalars - float, double, Point, Color, Point3D, etc.) -//----------------------------------------------------------------------------------------- - - -//-------------------------------------------------------------------------------------- -// Sampler Inputs (Brushes, including ImplicitInput) -//-------------------------------------------------------------------------------------- - -sampler2D implicitInputSampler : register(S0); - -//-------------------------------------------------------------------------------------- -// Pixel Shader -//-------------------------------------------------------------------------------------- - -float4 main(float2 uv : TEXCOORD) : COLOR -{ - float2 texuv = uv; - float4 finalColor; - - float4 srcColor = tex2D(implicitInputSampler, texuv); - - if( srcColor.a == 0 ) - { - finalColor = srcColor; - } - else - { - float4 luminance = srcColor.r*0.30 + srcColor.g*0.59 + srcColor.b*0.11; - luminance.a = srcColor.a; - finalColor = luminance; - } - return finalColor; -} diff --git a/Dev/SEToolbox/SEToolbox/App.xaml.cs b/Dev/SEToolbox/SEToolbox/App.xaml.cs deleted file mode 100644 index 7fc1cd45..00000000 --- a/Dev/SEToolbox/SEToolbox/App.xaml.cs +++ /dev/null @@ -1,150 +0,0 @@ -namespace SEToolbox -{ - using System; - using System.Diagnostics; - using System.Globalization; - using System.IO; - using System.Threading; - using System.Windows; - using System.Windows.Input; - using System.Windows.Threading; - - using SEToolbox.Interfaces; - using SEToolbox.Interop; - using SEToolbox.Services; - using SEToolbox.Support; - using SEToolbox.Views; - using WPFLocalizeExtension.Engine; - using Res = SEToolbox.Properties.Resources; - - /// - /// Interaction logic for App.xaml - /// - public partial class App : Application - { - #region Fields - - private CoreToolbox _toolboxApplication; - - #endregion - - #region events - - private void OnStartup(Object sender, StartupEventArgs e) - { - if ((NativeMethods.GetKeyState(System.Windows.Forms.Keys.ShiftKey) & KeyStates.Down) == KeyStates.Down) - { - // Reset User Settings when Shift is held down during start up. - GlobalSettings.Default.Reset(); - GlobalSettings.Default.PromptUser = true; - - // Clear app bin cache. - var binCache = ToolboxUpdater.GetBinCachePath(); - if (Directory.Exists(binCache)) - { - try - { - Directory.Delete(binCache, true); - } - catch - { - // File is locked and cannot be deleted at this time. - } - } - } - - LocalizeDictionary.Instance.SetCurrentThreadCulture = false; - LocalizeDictionary.Instance.Culture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode); - Thread.CurrentThread.CurrentUICulture = LocalizeDictionary.Instance.Culture; - - Splasher.Splash = new WindowSplashScreen(); - Splasher.ShowSplash(); - - log4net.Config.XmlConfigurator.Configure(); - - var update = CodeRepositoryReleases.CheckForUpdates(GlobalSettings.GetAppVersion()); - if (update != null) - { - var dialogResult = MessageBox.Show(string.Format(Res.DialogNewVersionMessage, update.Version), Res.DialogNewVersionTitle, MessageBoxButton.YesNo, MessageBoxImage.Information); - if (dialogResult == MessageBoxResult.Yes) - { - Process.Start(update.Link); - GlobalSettings.Default.Save(); - Application.Current.Shutdown(); - return; - } - - if (dialogResult == MessageBoxResult.No) - { - GlobalSettings.Default.IgnoreUpdateVersion = update.Version.ToString(); - } - } - - // Configure service locator. - ServiceLocator.RegisterSingleton(); - ServiceLocator.Register(); - ServiceLocator.Register(); - ServiceLocator.Register(); - ServiceLocator.Register(); - - System.Windows.FrameworkCompatibilityPreferences.KeepTextBoxDisplaySynchronizedWithTextProperty = false; - - _toolboxApplication = new CoreToolbox(); - if (_toolboxApplication.Init(e.Args)) - _toolboxApplication.Load(e.Args); - else - Application.Current.Shutdown(); - } - - private void OnExit(object sender, ExitEventArgs e) - { - if (_toolboxApplication != null) - _toolboxApplication.Exit(); - } - - private void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) - { - var comException = e.Exception as System.Runtime.InteropServices.COMException; - - if (comException != null && comException.ErrorCode == -2147221040) - { - // To fix 'OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN)' - // http://stackoverflow.com/questions/12769264/openclipboard-failed-when-copy-pasting-data-from-wpf-datagrid - - e.Handled = true; - return; - } - - // Log details to Application Event Log. - DiagnosticsLogging.LogException(e.Exception); - - string message; - - if (e.Exception is ToolboxException) - { - message = e.Exception.Message; - } - else - { - // Unhandled Exception. - if (DiagnosticsLogging.LoggingSourceExists()) - message = string.Format(Res.DialogUnhandledExceptionEventMessage, e.Exception.Message); - else - message = string.Format(Res.DialogUnhandledExceptionMessage, e.Exception.Message); - } - - MessageBox.Show(message, string.Format(Res.DialogUnhandledExceptionTitle, GlobalSettings.GetAppVersion()), MessageBoxButton.OK, MessageBoxImage.Error); - - TempfileUtil.Dispose(); - - e.Handled = true; - - if (Application.Current != null) - { - Application.Current.Shutdown(); - } - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Converters/ResouceToImageConverter.cs b/Dev/SEToolbox/SEToolbox/Converters/ResouceToImageConverter.cs deleted file mode 100644 index cdba904b..00000000 --- a/Dev/SEToolbox/SEToolbox/Converters/ResouceToImageConverter.cs +++ /dev/null @@ -1,75 +0,0 @@ -namespace SEToolbox.Converters -{ - using System; - using System.IO; - using System.Reflection; - using System.Windows.Data; - using System.Windows.Media.Imaging; - - public class ResouceToImageConverter : IValueConverter - { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - var imageParameter = value as string; - if (imageParameter == null) - imageParameter = parameter as string; - - if (!string.IsNullOrEmpty(imageParameter as string)) - { - System.Drawing.Bitmap bitmap = null; - var bitmapImage = new BitmapImage(); - - // Application Resource - File Build Action is marked as None, but stored in Resources.resx - // parameter= myresourceimagename - try - { - bitmap = Properties.Resources.ResourceManager.GetObject(imageParameter) as System.Drawing.Bitmap; - } - catch { } - - if (bitmap != null) - { - using (var ms = new MemoryStream()) - { - bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); - bitmapImage.BeginInit(); - bitmapImage.StreamSource = ms; - bitmapImage.CacheOption = BitmapCacheOption.OnLoad; - bitmapImage.EndInit(); - } - return bitmapImage; - } - - // Embedded Resource - File Build Action is marked as Embedded Resource - // parameter= MyWpfApplication.EmbeddedResource.myotherimage.png - var asm = Assembly.GetExecutingAssembly(); - var stream = asm.GetManifestResourceStream(imageParameter); - if (stream != null) - { - bitmapImage.BeginInit(); - bitmapImage.StreamSource = stream; - bitmapImage.EndInit(); - return bitmapImage; - } - - // This is the standard way of using Image.SourceDependancyProperty. You shouldn't need to use a converter to to this. - //// Resource - File Build Action is marked as Resource - //// parameter= pack://application:,,,/MyWpfApplication;component/Images/myfunkyimage.png - //Uri imageUriSource = null; - //if (Uri.TryCreate(imageParameter, UriKind.RelativeOrAbsolute, out imageUriSource)) - //{ - // bitmapImage.BeginInit(); - // bitmapImage.UriSource = imageUriSource; - // bitmapImage.EndInit(); - // return bitmapImage; - //} - } - return null; - } - - public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) - { - return null; - } - } -} \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/CoreToolbox.cs b/Dev/SEToolbox/SEToolbox/CoreToolbox.cs deleted file mode 100644 index b9485dd3..00000000 --- a/Dev/SEToolbox/SEToolbox/CoreToolbox.cs +++ /dev/null @@ -1,320 +0,0 @@ -namespace SEToolbox -{ - using System; - using System.Diagnostics; - using System.IO; - using System.Linq; - using System.Reflection; - using System.Windows; - - using SEToolbox.Interop; - using SEToolbox.Models; - using SEToolbox.Support; - using SEToolbox.ViewModels; - using SEToolbox.Views; - using Res = SEToolbox.Properties.Resources; - - public class CoreToolbox - { - //private string _tempBinPath; - - #region methods - - public bool Init(string[] args) - { - // Detection and correction of local settings of SE install location. - var filePath = ToolboxUpdater.GetApplicationFilePath(); - - var validApps = new string[] { - "SpaceEngineers.exe", - "SpaceEngineersDedicated.exe", - //"MedievalEngineers.exe", - //"MedievalEngineersDedicated.exe" - }; - - if (GlobalSettings.Default.PromptUser || !ToolboxUpdater.ValidateSpaceEngineersInstall(filePath)) - { - if (Directory.Exists(filePath)) - { - foreach (var validApp in validApps) - { - var testPath = Path.Combine(filePath, validApp); - if (File.Exists(testPath)) - { - filePath = testPath; - break; - } - } - } - - var faModel = new FindApplicationModel() - { - GameApplicationPath = filePath - }; - var faViewModel = new FindApplicationViewModel(faModel); - var faWindow = new WindowFindApplication(faViewModel); - - if (faWindow.ShowDialog() == true) - { - filePath = faModel.GameBinPath; - } - else - { - return false; - } - } - - // Update and save user path. - GlobalSettings.Default.SEBinPath = filePath; - GlobalSettings.Default.Save(); - - var ignoreUpdates = args.Any(a => a.ToUpper() == "/X" || a.ToUpper() == "-X"); - var oldDlls = true; // args.Any(a => a.ToUpper() == "/OLDDLL" || a.ToUpper() == "-OLDDLL"); - var altDlls = !oldDlls; - - // Go looking for any changes in the Dependant Space Engineers assemblies and immediately attempt to update. - if (!ignoreUpdates && !altDlls && ToolboxUpdater.IsBaseAssembliesChanged() && !Debugger.IsAttached) - { - ToolboxUpdater.RunElevated(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SEToolboxUpdate"), "/B " + String.Join(" ", args), false, false); - return false; - } - - var proc = Process.GetCurrentProcess(); - if (Process.GetProcessesByName(proc.ProcessName).Length == 1) - { - // Clean up Temp files if this is the only instance running. - TempfileUtil.DestroyTempFiles(); - } - - // Dot not load any of the Space Engineers assemblies or dependant classes before this point. - // ============================================ - - // Alternate experimental method for loading the Space Engineers API assemblies. - // Copy them to temporary path, then load with reflection on demand through the AppDomain. - //if (altDlls) - //{ - // _tempBinPath = ToolboxUpdater.GetBinCachePath(); - // var searchPath = GlobalSettings.Default.SEBinPath; - - // DirectoryInfo checkDir = null; - // var counter = 0; - - // while (checkDir == null && counter < 10) - // { - // if (Directory.Exists(_tempBinPath)) - // break; - - // checkDir = Directory.CreateDirectory(_tempBinPath); - - // if (checkDir == null) - // { - // // wait a while, as the drive may be processing Windows Explorer which had a lock on the Directory after prior cleanup. - // System.Threading.Thread.Sleep(100); - // } - - // counter++; - // } - - // foreach (var file in ToolboxUpdater.CoreSpaceEngineersFiles) - // { - // var filename = Path.Combine(searchPath, file); - // var destFilename = Path.Combine(_tempBinPath, file); - - // if (ToolboxUpdater.DoFilesDiffer(searchPath, _tempBinPath, file)) - // { - // try - // { - // File.Copy(filename, destFilename, true); - // } - // catch { } - // } - // } - - // // Copy directories which contain Space Engineers language resources. - // var dirs = Directory.GetDirectories(searchPath); - - // foreach (var sourceDir in dirs) - // { - // var dirName = Path.GetFileName(sourceDir); - // var destDir = Path.Combine(_tempBinPath, dirName); - // Directory.CreateDirectory(destDir); - - // foreach (string oldFile in Directory.GetFiles(sourceDir, "*.*", SearchOption.AllDirectories)) - // { - // try - // { - // File.Copy(oldFile, Path.Combine(destDir, Path.GetFileName(oldFile)), true); - // } - // catch { } - // } - // } - - // AppDomain currentDomain = AppDomain.CurrentDomain; - // currentDomain.AssemblyResolve += currentDomain_AssemblyResolve; - //} - -#if DEBUG - // This will make it hairy for testing the AppDomain stuff. - #warning Force the local debugger to load the Types allowing inspection. - var settings0 = new VRage.Game.MyObjectBuilder_SessionSettings(); - var settings1 = new Sandbox.Common.ObjectBuilders.MyObjectBuilder_InteriorLight(); -#endif - - return true; - } - - public bool Load(string[] args) - { - // Fetch the game version and store, so it can be retrieved during crash if the toolbox makes it this far. - Version gameVersion = SpaceEngineersConsts.GetSEVersion(); - bool newVersion = GlobalSettings.Default.SEVersion != gameVersion; - GlobalSettings.Default.SEVersion = gameVersion; - - // Test the Space Engineers version to make sure users are using an version that is new enough for SEToolbox to run with! - // This is usually because a user has not updated a manual install of a Dedicated Server, or their Steam did not update properly. - if (GlobalSettings.Default.SEVersion < GlobalSettings.GetAppVersion(true)) - { - MessageBox.Show(string.Format(Res.DialogOldSEVersionMessage, SpaceEngineersConsts.GetSEVersion(), GlobalSettings.Default.SEBinPath, GlobalSettings.GetAppVersion()), Res.DialogOldSEVersionTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation); - Application.Current.Shutdown(); - return false; - } - - // the /B argument indicates the SEToolboxUpdate had started SEToolbox after fetching updated game binaries. - if (newVersion && args.Any(a => a.Equals("/B", StringComparison.OrdinalIgnoreCase) || a.Equals("-B", StringComparison.OrdinalIgnoreCase))) - { - // Reset the counter used to indicate if the game binaries have updated. - GlobalSettings.Default.TimesStartedLastGameUpdate = null; - } - - //string loadWorld = null; - - //foreach (var arg in args) - //{ - // if (arg.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 && !File.Exists(arg)) - // continue; - - // string file = Path.GetFileName(arg); - // if (file.Equals("Sandbox.sbc", StringComparison.InvariantCultureIgnoreCase) - // || file.Equals("SANDBOX_0_0_0_.sbs", StringComparison.InvariantCultureIgnoreCase)) - // loadWorld = Path.GetDirectoryName(arg); - //} - - // Force pre-loading of any Space Engineers resources. - SpaceEngineersCore.LoadDefinitions(); - - // Load the Space Engineers assemblies, or dependant classes after this point. - var explorerModel = new ExplorerModel(); - - if (args.Any(a => a.ToUpper() == "/WR" || a.ToUpper() == "-WR")) - { - ResourceReportModel.GenerateOfflineReport(explorerModel, args); - Application.Current.Shutdown(); - return false; - } - - var eViewModel = new ExplorerViewModel(explorerModel); - var eWindow = new WindowExplorer(eViewModel); - //if (allowClose) - //{ - eViewModel.CloseRequested += (sender, e) => - { - SaveSettings(eWindow); - Application.Current.Shutdown(); - }; - //} - eWindow.Loaded += (sender, e) => - { - Splasher.CloseSplash(); - - double left = GlobalSettings.Default.WindowLeft ?? eWindow.Left; - double top = GlobalSettings.Default.WindowTop ?? eWindow.Top; - double width = GlobalSettings.Default.WindowWidth ?? eWindow.Width; - double height = GlobalSettings.Default.WindowHeight ?? eWindow.Height; - - System.Drawing.Rectangle windowRect = new System.Drawing.Rectangle((int)left, (int)top, (int)width, (int)height); - bool isInsideDesktop = false; - - foreach (System.Windows.Forms.Screen screen in System.Windows.Forms.Screen.AllScreens) - { - try - { - isInsideDesktop |= screen.Bounds.IntersectsWith(windowRect); - } - catch - { - // some virtual screens have been know to cause issues. - } - } - if (isInsideDesktop) - { - eWindow.Left = left; - eWindow.Top = top; - eWindow.Width = width; - eWindow.Height = height; - if (GlobalSettings.Default.WindowState.HasValue) eWindow.WindowState = GlobalSettings.Default.WindowState.Value; - } - }; - - if (!GlobalSettings.Default.TimesStartedTotal.HasValue) - GlobalSettings.Default.TimesStartedTotal = 0; - GlobalSettings.Default.TimesStartedTotal++; - if (!GlobalSettings.Default.TimesStartedLastReset.HasValue) - GlobalSettings.Default.TimesStartedLastReset = 0; - GlobalSettings.Default.TimesStartedLastReset++; - if (!GlobalSettings.Default.TimesStartedLastGameUpdate.HasValue) - GlobalSettings.Default.TimesStartedLastGameUpdate = 0; - GlobalSettings.Default.TimesStartedLastGameUpdate++; - GlobalSettings.Default.Save(); - - eWindow.ShowDialog(); - - return true; - } - - public void Exit() - { - if (VRage.Plugins.MyPlugins.Loaded) - { - VRage.Plugins.MyPlugins.Unload(); - } - TempfileUtil.Dispose(); - } - - private static void SaveSettings(WindowExplorer eWindow) - { - GlobalSettings.Default.WindowState = eWindow.WindowState; - eWindow.WindowState = WindowState.Normal; // Reset the State before getting the window size. - GlobalSettings.Default.WindowHeight = eWindow.Height; - GlobalSettings.Default.WindowWidth = eWindow.Width; - GlobalSettings.Default.WindowTop = eWindow.Top; - GlobalSettings.Default.WindowLeft = eWindow.Left; - GlobalSettings.Default.Save(); - } - - //Assembly currentDomain_AssemblyResolve(object sender, ResolveEventArgs args) - //{ - // // Retrieve the list of referenced assemblies in an array of AssemblyName. - // var filename = args.Name.Substring(0, args.Name.IndexOf(",", StringComparison.Ordinal)) + ".dll"; - - // const string filter = @"^(?(?:\w+(?:\.?\w+)+))\s*(?:,\s?Version=(?\d+\.\d+\.\d+\.\d+))?(?:,\s?Culture=(?[\w-]+))?(?:,\s?PublicKeyToken=(?\w+))?$"; - // var match = Regex.Match(args.Name, filter); - // if (match.Success) - // { - // filename = match.Groups["assembly"].Value + ".dll"; - // } - - // if (ToolboxUpdater.CoreSpaceEngineersFiles.Any(f => string.Equals(f, filename, StringComparison.OrdinalIgnoreCase))) - // { - // var assemblyPath = Path.Combine(_tempBinPath, filename); - - // // Load the assembly from the specified path. - // // Return the loaded assembly. - // return Assembly.LoadFrom(assemblyPath); - // } - - // return null; - //} - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelBuilder.cs b/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelBuilder.cs deleted file mode 100644 index 3a6c6de5..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelBuilder.cs +++ /dev/null @@ -1,439 +0,0 @@ -namespace SEToolbox.Interop.Asteroids -{ - using System; - using System.Diagnostics; - using System.Threading.Tasks; - using System.Windows.Media.Media3D; - - using SEToolbox.Support; - using VRage.Voxels; - using VRageMath; - - public static class MyVoxelBuilder - { - private static readonly object Locker = new object(); - - #region methods - - public static void ConvertAsteroid(string loadFile, string saveFile, string defaultMaterial, string material) - { - var voxelMap = new MyVoxelMap(); - voxelMap.Load(loadFile); - voxelMap.ForceBaseMaterial(defaultMaterial, material); - voxelMap.Save(saveFile); - voxelMap.Dispose(); - } - - public static void StripMaterial(string loadFile, string saveFile, string defaultMaterial, string stripMaterial, string replaceFillMaterial) - { - var voxelMap = new MyVoxelMap(); - voxelMap.Load(loadFile); - voxelMap.RemoveContent(stripMaterial, replaceFillMaterial); - voxelMap.Save(saveFile); - } - - #region BuildAsteroid standard tools - - public static MyVoxelMap BuildAsteroidCube(bool multiThread, int width, int height, int depth, - byte materialIndex, byte faceMaterialIndex, bool hollow = false, int shellWidth = 0, float safeSize = 0f) - { - // offset by 1, to allow for the 3 faces on the origin side. - var size = new Vector3I(width, height, depth) + 1; - - // offset by 1, to allow for the 3 faces on opposite side. - var buildSize = size + 1; - - var action = (Action)delegate(MyVoxelBuilderArgs e) - { - if (e.CoordinatePoint.X <= safeSize || e.CoordinatePoint.Y <= safeSize || - e.CoordinatePoint.Z <= safeSize - || e.CoordinatePoint.X >= size.X - safeSize || e.CoordinatePoint.Y >= size.Y - safeSize || - e.CoordinatePoint.Z >= size.Z - safeSize) - { - e.Volume = 0x00; - } - else if (hollow && - (e.CoordinatePoint.X <= safeSize + shellWidth || e.CoordinatePoint.Y <= safeSize + shellWidth || - e.CoordinatePoint.Z <= safeSize + shellWidth - || e.CoordinatePoint.X >= size.X - (safeSize + shellWidth) || - e.CoordinatePoint.Y >= size.Y - (safeSize + shellWidth) || - e.CoordinatePoint.Z >= size.Z - (safeSize + shellWidth))) - { - e.Volume = 0xFF; - } - else if (hollow) - { - e.Volume = 0x00; - } - else //if (!hollow) - { - e.Volume = 0xFF; - } - }; - - return BuildAsteroid(multiThread, buildSize, materialIndex, faceMaterialIndex, action); - } - - public static MyVoxelMap BuildAsteroidCube(bool multiThread, Vector3I min, Vector3I max, byte materialIndex, byte faceMaterialIndex) - { - // correct for allowing sizing. - var buildSize = CalcRequiredSize(max); - - var action = (Action)delegate(MyVoxelBuilderArgs e) - { - if (e.CoordinatePoint.X < min.X || e.CoordinatePoint.Y < min.Y || e.CoordinatePoint.Z < min.Z - || e.CoordinatePoint.X > max.X || e.CoordinatePoint.Y > max.Y || e.CoordinatePoint.Z > max.Z) - { - e.Volume = 0x00; - } - else //if (!hollow) - { - e.Volume = 0xFF; - } - }; - - return BuildAsteroid(multiThread, buildSize, materialIndex, faceMaterialIndex, action); - } - - public static MyVoxelMap BuildAsteroidSphere(bool multiThread, double radius, byte materialIndex, byte faceMaterialIndex, - bool hollow = false, int shellWidth = 0) - { - var length = (int)((radius * 2) + 2); - var buildSize = CalcRequiredSize(length); - var origin = new Vector3I(buildSize.X / 2, buildSize.Y / 2, buildSize.Z / 2); - - var action = (Action)delegate(MyVoxelBuilderArgs e) - { - VRageMath.Vector3D voxelPosition = e.CoordinatePoint; - - int v = GetSphereVolume(ref voxelPosition, radius, origin); - if (hollow) - { - int h = GetSphereVolume(ref voxelPosition, radius - shellWidth, origin); - e.Volume = (byte)(v - h); - } - else - e.Volume = (byte)v; - }; - - return BuildAsteroid(multiThread, buildSize, materialIndex, faceMaterialIndex, action); - } - - public static byte GetSphereVolume(ref VRageMath.Vector3D voxelPosition, double radius, VRageMath.Vector3D center) - { - double num = (voxelPosition - center).Length(); - double signedDistance = num - radius; - - signedDistance = MathHelper.Clamp(-signedDistance, -1f, 1f) * 0.5f + 0.5f; - return (byte)(signedDistance * 255); - } - - public static MyVoxelMap BuildAsteroidFromModel(bool multiThread, string sourceVolumetricFile, byte materialIndex, byte faceMaterialIndex, bool fillObject, byte? interiorMaterialIndex, ModelTraceVoxel traceType, double scale, Transform3D transform) - { - return BuildAsteroidFromModel(multiThread, sourceVolumetricFile, materialIndex, faceMaterialIndex, fillObject, interiorMaterialIndex, traceType, scale, transform, null, null); - } - - public static MyVoxelMap BuildAsteroidFromModel(bool multiThread, string sourceVolumetricFile, byte materialIndex, byte faceMaterialIndex, bool fillObject, byte? interiorMaterialIndex, ModelTraceVoxel traceType, double scale, Transform3D transform, Action resetProgress, Action incrementProgress) - { - var volmeticMap = Modelling.ReadModelVolmetic(sourceVolumetricFile, scale, transform, traceType, resetProgress, incrementProgress); - // these large values were to fix issue with large square gaps in voxlized asteroid model. - var size = new Vector3I(volmeticMap.Length + 12, volmeticMap[0].Length + 12, volmeticMap[0][0].Length + 12); - - var action = (Action)delegate(MyVoxelBuilderArgs e) - { - if (e.CoordinatePoint.X > 5 && e.CoordinatePoint.Y > 5 && e.CoordinatePoint.Z > 5 && - (e.CoordinatePoint.X <= volmeticMap.Length + 5) && (e.CoordinatePoint.Y <= volmeticMap[0].Length + 5) && (e.CoordinatePoint.Z <= volmeticMap[0][0].Length + 5)) - { - var cube = volmeticMap[e.CoordinatePoint.X - 6][e.CoordinatePoint.Y - 6][e.CoordinatePoint.Z - 6]; - if (cube == CubeType.Interior && fillObject) - { - e.Volume = 0xff; // 100% - if (interiorMaterialIndex != null) - { - e.MaterialIndex = interiorMaterialIndex.Value; - } - } - else if (cube == CubeType.Cube) - e.Volume = 0xff; // 100% "11111111" - else if (cube.ToString().StartsWith("InverseCorner")) - e.Volume = 0xD4; // 83% "11010100" - else if (cube.ToString().StartsWith("Slope")) - e.Volume = 0x7F; // 50% "01111111" - else if (cube.ToString().StartsWith("NormalCorner")) - e.Volume = 0x2B; // 16% "00101011" - else - e.Volume = 0x00; // 0% "00000000" - } - else - { - e.Volume = 0x00; - } - }; - - return BuildAsteroid(multiThread, size, materialIndex, faceMaterialIndex, action); - } - - #endregion - - #region BuildAsteroid - - /// - /// Builds an asteroid Voxel. Voxel detail will be completed by function callbacks. - /// This allows for muti-threading, and generating content via algorithims. - /// - public static MyVoxelMap BuildAsteroid(bool multiThread, Vector3I size, byte materialIndex, byte? faceMaterialIndex, Action func) - { - var voxelMap = new MyVoxelMap(); - - var buildSize = CalcRequiredSize(size); - voxelMap.Create(buildSize, materialIndex); - ProcessAsteroid(voxelMap, multiThread, materialIndex, func, true); - - // This should no longer be required. - //if (faceMaterialIndex != null) - //{ - // voxelMap.ForceVoxelFaceMaterial(faceMaterialIndex.Value); - //} - - return voxelMap; - } - - #endregion - - #region ProcessAsteroid - - /// - /// Processes an asteroid Voxel using function callbacks. - /// This allows for muti-threading, and generating content via algorithims. - /// - public static void ProcessAsteroid(MyVoxelMap voxelMap, bool multiThread, byte materialIndex, Action func, bool readWrite = true) - { - long counterTotal = (long)voxelMap.Size.X * voxelMap.Size.Y * voxelMap.Size.Z; - long counter = 0; - decimal progress = 0; - var timer = new Stopwatch(); - Debug.Write($"Building Asteroid : {progress:000},"); - Console.Write($"Building Asteroid : {progress:000},"); - Exception threadException = null; - - timer.Start(); - - if (!multiThread) - { - #region single thread processing - - Vector3I block; - const int cellSize = 64; - var cacheSize = Vector3I.Min(new Vector3I(cellSize), voxelMap.Storage.Size); - var oldCache = new MyStorageData(); - - // read the asteroid in chunks of 64 to avoid the Arithmetic overflow issue. - for (block.Z = 0; block.Z < voxelMap.Storage.Size.Z; block.Z += cellSize) - for (block.Y = 0; block.Y < voxelMap.Storage.Size.Y; block.Y += cellSize) - for (block.X = 0; block.X < voxelMap.Storage.Size.X; block.X += cellSize) - { - oldCache.Resize(cacheSize); - // LOD0 is required to read if you intend to write back to the voxel storage. - Vector3I maxRange = block + cacheSize - 1; - voxelMap.Storage.ReadRange(oldCache, MyStorageDataTypeFlags.ContentAndMaterial, 0, block, maxRange); - - Vector3I p; - for (p.Z = 0; p.Z < cacheSize.Z; ++p.Z) - for (p.Y = 0; p.Y < cacheSize.Y; ++p.Y) - for (p.X = 0; p.X < cacheSize.X; ++p.X) - { - var coords = block + p; - - byte volume = 0x0; - byte cellMaterial = materialIndex; - - if (readWrite) - { - volume = oldCache.Content(ref p); - cellMaterial = oldCache.Material(ref p); - } - - var args = new MyVoxelBuilderArgs(voxelMap.Size, coords, cellMaterial, volume); - - try - { - func(args); - } - catch (Exception ex) - { - threadException = ex; - break; - } - - if (args.Volume != volume) - { - oldCache.Set(MyStorageDataTypeEnum.Content, ref p, args.Volume); - } - - if (args.MaterialIndex != cellMaterial) - { - oldCache.Set(MyStorageDataTypeEnum.Material, ref p, args.MaterialIndex); - } - - counter++; - var prog = Math.Floor(counter / (decimal)counterTotal * 100); - if (prog != progress) - { - progress = prog; - Debug.Write($"{progress:000},"); - } - - } - - voxelMap.Storage.WriteRange(oldCache, MyStorageDataTypeFlags.ContentAndMaterial, block, maxRange); - } - - #endregion - } - else - { - #region multi thread processing - - // TODO: re-write the multi thread processing to be more stable. - // But still try and max out the processors. - - Vector3I block; - const int cellSize = 64; - var cacheSize = Vector3I.Min(new Vector3I(cellSize), voxelMap.Storage.Size); - long threadCounter = counterTotal / cellSize / cellSize / cellSize; - - for (block.Z = 0; block.Z < voxelMap.Storage.Size.Z; block.Z += cellSize) - for (block.Y = 0; block.Y < voxelMap.Storage.Size.Y; block.Y += cellSize) - for (block.X = 0; block.X < voxelMap.Storage.Size.X; block.X += cellSize) - { - var oldCache = new MyStorageData(); - oldCache.Resize(cacheSize); - // LOD1 is not detailed enough for content information on asteroids. - Vector3I maxRange = block + cacheSize - 1; - voxelMap.Storage.ReadRange(oldCache, MyStorageDataTypeFlags.ContentAndMaterial, 0, block, maxRange); - - var task = new Task(obj => - { - var bgw = (MyVoxelTaskWorker)obj; - - Vector3I p; - for (p.Z = 0; p.Z < cacheSize.Z; ++p.Z) - for (p.Y = 0; p.Y < cacheSize.Y; ++p.Y) - for (p.X = 0; p.X < cacheSize.X; ++p.X) - { - var coords = bgw.BaseCoords + p; - - byte volume = 0x0; - byte cellMaterial = materialIndex; - - if (readWrite) - { - // read the existing material and volume into the arguments before passing the to args for processing. - volume = bgw.VoxelCache.Content(ref p); - cellMaterial = bgw.VoxelCache.Material(ref p); - } - - var args = new MyVoxelBuilderArgs(voxelMap.Size, coords, cellMaterial, volume); - - try - { - func(args); - } - catch (Exception ex) - { - threadException = ex; - threadCounter = 0; - break; - } - - if (args.Volume != volume) - { - bgw.VoxelCache.Set(MyStorageDataTypeEnum.Content, ref p, args.Volume); - } - - if (args.MaterialIndex != cellMaterial) - { - bgw.VoxelCache.Set(MyStorageDataTypeEnum.Material, ref p, args.MaterialIndex); - } - - counter++; - var prog = Math.Floor(counter / (decimal)counterTotal * 100); - if (prog != progress) - { - progress = prog; - Debug.Write($"{progress:000},"); - } - } - - lock (Locker) - { - var b = bgw.BaseCoords; - Vector3I mr = bgw.BaseCoords + cacheSize - 1; - voxelMap.Storage.WriteRange(bgw.VoxelCache, MyStorageDataTypeFlags.ContentAndMaterial, b, mr); - - counter += (long)cellSize * cellSize * cellSize; - var prog = Math.Floor(counter / (decimal)counterTotal * 100); - if (prog != progress) - { - progress = prog; - Debug.Write($"{progress:000},"); - Console.Write($"{progress:000},"); - GC.Collect(); - } - threadCounter--; - } - - }, new MyVoxelTaskWorker(block, oldCache)); - - task.Start(); - } - - - - GC.Collect(); - - while (threadCounter > 0) - { - System.Windows.Forms.Application.DoEvents(); - } - - System.Threading.Thread.Sleep(100); - System.Windows.Forms.Application.DoEvents(); - - #endregion - } - - timer.Stop(); - - if (threadException != null) - throw threadException; - - voxelMap.RefreshAssets(); - - //voxelMap.UpdateContentBounds(); - - Debug.WriteLine($" Done. | {timer.Elapsed} | VoxCells {voxelMap.VoxCells:#,##0}"); - Console.WriteLine($" Done. | {timer.Elapsed} | VoxCells {voxelMap.VoxCells:#,##0}"); - } - - #endregion - - private static Vector3I CalcRequiredSize(int size) - { - // the size of 4x4x4 is too small. the game allows it, but the physics is broken. - // So I'm restricting the smallest to 8x8x8. - // All voxels are cubic, and powers of 2 in size. - return new Vector3I(MathHelper.GetNearestBiggerPowerOfTwo(Math.Max(8, size))); - } - - public static Vector3I CalcRequiredSize(Vector3I size) - { - // the size of 4x4x4 is too small. the game allows it, but the physics is broken. - // So I'm restricting the smallest to 8x8x8. - // All voxels are cubic, and powers of 2 in size. - return new Vector3I(MathHelper.GetNearestBiggerPowerOfTwo(SpaceEngineersExtensions.Max(8, size.X, size.Y, size.Z))); - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelRayTracer.cs b/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelRayTracer.cs deleted file mode 100644 index e2555aad..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/Asteroids/MyVoxelRayTracer.cs +++ /dev/null @@ -1,790 +0,0 @@ -namespace SEToolbox.Interop.Asteroids -{ - using System; - using System.Collections.Generic; - using System.Diagnostics; - using System.Linq; - using System.Threading.Tasks; - using System.Windows.Media.Media3D; - - using SEToolbox.Support; - using VRageMath; - - public static class MyVoxelRayTracer - { - private static readonly object Locker = new object(); - private enum MeshFace : byte { Undefined, Nearside, Farside }; - - #region ReadModelAsteroidVolmetic - - // For a 1024 cubed asteroid, it takes approximately 6.5Gb of system memory. - - public static MyVoxelMap ReadModelAsteroidVolmetic(Model3DGroup model, IList mappedMesh, ScaleTransform3D scale, Transform3D rotateTransform, TraceType traceType, TraceCount traceCount, TraceDirection traceDirection, - Action resetProgress, Action incrementProgress, Func checkCancel, Action complete) - { - var traceDirectionCount = 0; - var materials = new List(); - var faceMaterials = new List(); - foreach (var mesh in mappedMesh) - { - materials.Add(mesh.MaterialIndex ?? SpaceEngineersConsts.EmptyVoxelMaterial); - faceMaterials.Add(mesh.FaceMaterialIndex ?? SpaceEngineersConsts.EmptyVoxelMaterial); - } - - // How far to check in from the proposed Volumetric edge. - // This number is just made up, but small enough that it still represents the corner edge of the Volumetric space. - // But still large enough that it isn't the exact corner. - const double offset = 0.0000045f; - - if (scale.ScaleX > 0 && scale.ScaleY > 0 && scale.ScaleZ > 0 && scale.ScaleX != 1.0f && scale.ScaleY != 1.0f && scale.ScaleZ != 1.0f) - { - model.TransformScale(scale.ScaleX, scale.ScaleY, scale.ScaleZ); - } - - // Attempt to offset the model, so it's only caulated from zero (0) and up, instead of using zero (0) as origin. - //model.Transform = new TranslateTransform3D(-model.Bounds.X, -model.Bounds.Y, -model.Bounds.Z); - - var tbounds = model.Bounds; - Matrix3D? rotate = null; - if (rotateTransform != null) - { - rotate = rotateTransform.Value; - tbounds = rotateTransform.TransformBounds(tbounds); - } - - //model.Transform = new TranslateTransform3D(-tbounds.X, -tbounds.Y, -tbounds.Z); - - // Add 2 to either side, to allow for material padding to expose internal materials. - const int bufferSize = 2; - var xMin = (int)Math.Floor(tbounds.X) - bufferSize; - var yMin = (int)Math.Floor(tbounds.Y) - bufferSize; - var zMin = (int)Math.Floor(tbounds.Z) - bufferSize; - - var xMax = (int)Math.Ceiling(tbounds.X + tbounds.SizeX) + bufferSize; - var yMax = (int)Math.Ceiling(tbounds.Y + tbounds.SizeY) + bufferSize; - var zMax = (int)Math.Ceiling(tbounds.Z + tbounds.SizeZ) + bufferSize; - - // Do not rounnd up the array size, as this really isn't required, and it increases the calculation time. - var xCount = (xMax - xMin); - var yCount = (yMax - yMin); - var zCount = (zMax - zMin); - - Debug.WriteLine("Approximate Size: {0}x{1}x{2}", Math.Ceiling(tbounds.X + tbounds.SizeX) - Math.Floor(tbounds.X), Math.Ceiling(tbounds.Y + tbounds.SizeY) - Math.Floor(tbounds.Y), Math.Ceiling(tbounds.Z + tbounds.SizeZ) - Math.Floor(tbounds.Z)); - Debug.WriteLine("Bounds Size: {0}x{1}x{2}", xCount, yCount, zCount); - - var finalCubic = ArrayHelper.Create(xCount, yCount, zCount); - var finalMater = ArrayHelper.Create(xCount, yCount, zCount); - - if (resetProgress != null) - { - long triangles = (from GeometryModel3D gm in model.Children select gm.Geometry as MeshGeometry3D).Aggregate(0, (current, g) => current + (g.TriangleIndices.Count / 3)); - long rays = 0; - - if ((traceDirection & TraceDirection.X) == TraceDirection.X) - rays += ((yMax - yMin) * (zMax - zMin)); - if ((traceDirection & TraceDirection.Y) == TraceDirection.Y) - rays += ((xMax - xMin) * (zMax - zMin)); - if ((traceDirection & TraceDirection.Z) == TraceDirection.Z) - rays += ((xMax - xMin) * (yMax - yMin)); - - resetProgress.Invoke(0, rays * triangles); - } - - if (checkCancel != null && checkCancel.Invoke()) - { - complete?.Invoke(); - return null; - } - - #region basic ray trace of every individual triangle. - - // Start from the last mesh, which represents the bottom of the UI stack, and overlay each other mesh on top of it. - for (var modelIdx = mappedMesh.Count - 1; modelIdx >= 0; modelIdx--) - { - Debug.WriteLine("Model {0}", modelIdx); - - var modelCubic = new byte[xCount][][]; - var modelMater = new byte[xCount][][]; - - for (var x = 0; x < xCount; x++) - { - modelCubic[x] = new byte[yCount][]; - modelMater[x] = new byte[yCount][]; - for (var y = 0; y < yCount; y++) - { - modelCubic[x][y] = new byte[zCount]; - modelMater[x][y] = new byte[zCount]; - } - } - - var meshes = mappedMesh[modelIdx]; - var threadCounter = 0; - - var geometries = new GeometeryDetail[meshes.Geometery.Length]; - for (var i = 0; i < meshes.Geometery.Length; i++) - geometries[i] = new GeometeryDetail(meshes.Geometery[i]); - - var startOffset = 0.5f; - var endOffset = 0.5f; - var volumeOffset = 0.5f; - Func roundFunc = null; - if (traceType == TraceType.Odd) - { - startOffset = 0.5f; - endOffset = 0.5f; - volumeOffset = 0.5f; - roundFunc = delegate (double d) { return (int)Math.Round(d, 0); }; - } - else if (traceType == TraceType.Even) - { - startOffset = 0.0f; - endOffset = 1.0f; - volumeOffset = 1.0f; - roundFunc = delegate (double d) { return (int)Math.Floor(d); }; - } - - #region X ray trace - - if ((traceDirection & TraceDirection.X) == TraceDirection.X) - { - Debug.WriteLine("X Rays"); - traceDirectionCount++; - threadCounter = (yMax - yMin) * (zMax - zMin); - - for (var y = yMin; y < yMax; y++) - { - for (var z = zMin; z < zMax; z++) - { - if (checkCancel != null && checkCancel.Invoke()) - { - complete?.Invoke(); - return null; - } - - List testRays = null; - if (traceType == TraceType.Odd) - testRays = new List - { - new [] {new Point3D(xMin, y + offset, z + offset), new Point3D(xMax, y + offset, z + offset)}, - new [] {new Point3D(xMin, y -0.5f + offset, z -0.5f + offset), new Point3D(xMax, y -0.5f + offset, z -0.5f + offset)}, - new [] {new Point3D(xMin, y + 0.5f - offset, z -0.5f + offset), new Point3D(xMax, y + 0.5f - offset, z -0.5f + offset)}, - new [] {new Point3D(xMin, y -0.5f + offset, z + 0.5f - offset), new Point3D(xMax, y -0.5f + offset, z + 0.5f - offset)}, - new [] {new Point3D(xMin, y + 0.5f - offset, z + 0.5f - offset), new Point3D(xMax, y + 0.5f - offset, z + 0.5f - offset)} - }; - else if (traceType == TraceType.Even) - testRays = new List - { - new [] {new Point3D(xMin, y + 0.5f - offset, z + 0.5f - offset), new Point3D(xMax, y + 0.5f - offset, z + 0.5f - offset)}, - new [] {new Point3D(xMin, y + offset, z + offset), new Point3D(xMax, y + offset, z + offset)}, - new [] {new Point3D(xMin, y + 1.0f - offset, z + offset), new Point3D(xMax, y + 1.0f - offset, z + offset)}, - new [] {new Point3D(xMin, y + offset, z + 1.0f - offset), new Point3D(xMax, y + offset, z + 1.0f - offset)}, - new [] {new Point3D(xMin, y + 1.0f - offset, z + 1.0f - offset), new Point3D(xMax, y + 1.0f - offset, z + 1.0f - offset)} - }; - - var task = new Task(obj => - { - var bgw = (RayTracerTaskWorker)obj; - var tracers = new List(); - - foreach (var geometery in geometries) - { - for (var t = 0; t < geometery.Triangles.Length; t += 3) - { - if (checkCancel != null && checkCancel.Invoke()) - return; - - if (incrementProgress != null) - { - lock (Locker) - { - incrementProgress.Invoke(); - } - } - - var p1 = geometery.Positions[geometery.Triangles[t]]; - var p2 = geometery.Positions[geometery.Triangles[t + 1]]; - var p3 = geometery.Positions[geometery.Triangles[t + 2]]; - - if (rotate.HasValue) - { - p1 = rotate.Value.Transform(p1); - p2 = rotate.Value.Transform(p2); - p3 = rotate.Value.Transform(p3); - } - - foreach (var ray in testRays) - { - if ((p1.Y < ray[0].Y && p2.Y < ray[0].Y && p3.Y < ray[0].Y) || - (p1.Y > ray[0].Y && p2.Y > ray[0].Y && p3.Y > ray[0].Y) || - (p1.Z < ray[0].Z && p2.Z < ray[0].Z && p3.Z < ray[0].Z) || - (p1.Z > ray[0].Z && p2.Z > ray[0].Z && p3.Z > ray[0].Z)) - continue; - - Point3D intersect; - int normal; - if (MeshHelper.RayIntersetTriangleRound(p1, p2, p3, ray[0], ray[1], out intersect, out normal)) - { - tracers.Add(new Trace(intersect, normal)); - } - } - } - } - - if (tracers.Count > 1) - { - var order = tracers.GroupBy(t => new { t.Point, t.Face }).Select(g => g.First()).OrderBy(k => k.Point.X).ToArray(); - var startCoord = roundFunc(order[0].Point.X); - var endCoord = roundFunc(order[order.Length - 1].Point.X); - var surfaces = 0; - - for (var x = startCoord; x <= endCoord; x++) - { - var points = order.Where(p => p.Point.X > x - startOffset && p.Point.X < x + endOffset).ToArray(); - var volume = (byte)(0xff / testRays.Count * surfaces); - - foreach (var point in points) - { - if (point.Face == MeshFace.Farside) - { - volume += (byte)(Math.Round(Math.Abs(x + volumeOffset - point.Point.X) * 255 / testRays.Count, 0)); - surfaces++; - } - else if (point.Face == MeshFace.Nearside) - { - volume -= (byte)(Math.Round(Math.Abs(x + volumeOffset - point.Point.X) * 255 / testRays.Count, 0)); - surfaces--; - } - } - - // TODO: retest detailed model export. - //volume = volume.RoundUpToNearest(8); - - modelCubic[x - xMin][bgw.Y - yMin][bgw.Z - zMin] = volume; - modelMater[x - xMin][bgw.Y - yMin][bgw.Z - zMin] = materials[bgw.ModelIdx]; - } - - if (faceMaterials[bgw.ModelIdx] != 0xff) - { - for (var i = 1; i < 6; i++) - { - if (xMin < startCoord - i && modelCubic[startCoord - i - xMin][bgw.Y - yMin][bgw.Z - zMin] == 0) - { - modelMater[startCoord - i - xMin][bgw.Y - yMin][bgw.Z - zMin] = faceMaterials[bgw.ModelIdx]; - } - if (endCoord + i < xMax && modelCubic[endCoord + i - xMin][bgw.Y - yMin][bgw.Z - zMin] == 0) - { - modelMater[endCoord + i - xMin][bgw.Y - yMin][bgw.Z - zMin] = faceMaterials[bgw.ModelIdx]; - } - } - } - } - - lock (Locker) - { - threadCounter--; - } - }, new RayTracerTaskWorker(modelIdx, 0, y, z)); - - task.Start(); - } - } - - // Wait for Multithread parts to finish. - while (threadCounter > 0) - { - System.Windows.Forms.Application.DoEvents(); - if (checkCancel != null && checkCancel.Invoke()) - break; - } - - GC.Collect(); - } - - #endregion - - #region Y rays trace - - if ((traceDirection & TraceDirection.Y) == TraceDirection.Y) - { - Debug.WriteLine("Y Rays"); - traceDirectionCount++; - threadCounter = (xMax - xMin) * (zMax - zMin); - - for (var x = xMin; x < xMax; x++) - { - for (var z = zMin; z < zMax; z++) - { - if (checkCancel != null && checkCancel.Invoke()) - { - if (complete != null) - complete.Invoke(); - return null; - } - - List testRays = null; - if (traceType == TraceType.Odd) - testRays = new List - { - new [] {new Point3D(x + offset, yMin, z + offset), new Point3D(x + offset, yMax, z + offset)}, - new [] {new Point3D(x -0.5f + offset, yMin, z -0.5f + offset), new Point3D(x -0.5f + offset, yMax, z -0.5f + offset)}, - new [] {new Point3D(x + 0.5f - offset, yMin, z -0.5f + offset), new Point3D(x + 0.5f - offset, yMax, z -0.5f + offset)}, - new [] {new Point3D(x -0.5f + offset, yMin, z + 0.5f - offset), new Point3D(x -0.5f + offset, yMax, z + 0.5f - offset)}, - new [] {new Point3D(x + 0.5f - offset, yMin, z + 0.5f - offset), new Point3D(x + 0.5f - offset, yMax, z + 0.5f - offset)} - }; - else if (traceType == TraceType.Even) - testRays = new List - { - new [] {new Point3D(x + 0.5f - offset, yMin, z + 0.5f - offset), new Point3D(x + 0.5f - offset, yMax, z + 0.5f - offset)}, - new [] {new Point3D(x + offset, yMin, z + offset), new Point3D(x + offset, yMax, z + offset)}, - new [] {new Point3D(x + 1.0f - offset, yMin, z + offset), new Point3D(x + 1.0f - offset, yMax, z + offset)}, - new [] {new Point3D(x + offset, yMin, z + 1.0f - offset), new Point3D(x + offset, yMax, z + 1.0f - offset)}, - new [] {new Point3D(x + 1.0f - offset, yMin, z + 1.0f - offset), new Point3D(x + 1.0f - offset, yMax, z + 1.0f - offset)} - }; - - var task = new Task(obj => - { - var bgw = (RayTracerTaskWorker)obj; - var tracers = new List(); - - foreach (var geometery in geometries) - { - for (var t = 0; t < geometery.Triangles.Length; t += 3) - { - if (checkCancel != null && checkCancel.Invoke()) - return; - - if (incrementProgress != null) - { - lock (Locker) - { - incrementProgress.Invoke(); - } - } - - var p1 = geometery.Positions[geometery.Triangles[t]]; - var p2 = geometery.Positions[geometery.Triangles[t + 1]]; - var p3 = geometery.Positions[geometery.Triangles[t + 2]]; - - if (rotate.HasValue) - { - p1 = rotate.Value.Transform(p1); - p2 = rotate.Value.Transform(p2); - p3 = rotate.Value.Transform(p3); - } - - foreach (var ray in testRays) - { - if ((p1.X < ray[0].X && p2.X < ray[0].X && p3.X < ray[0].X) || - (p1.X > ray[0].X && p2.X > ray[0].X && p3.X > ray[0].X) || - (p1.Z < ray[0].Z && p2.Z < ray[0].Z && p3.Z < ray[0].Z) || - (p1.Z > ray[0].Z && p2.Z > ray[0].Z && p3.Z > ray[0].Z)) - continue; - - Point3D intersect; - int normal; - if (MeshHelper.RayIntersetTriangleRound(p1, p2, p3, ray[0], ray[1], out intersect, out normal)) - { - tracers.Add(new Trace(intersect, normal)); - } - } - } - } - - if (tracers.Count > 1) - { - var order = tracers.GroupBy(t => new { t.Point, t.Face }).Select(g => g.First()).OrderBy(k => k.Point.Y).ToArray(); - var startCoord = roundFunc(order[0].Point.Y); - var endCoord = roundFunc(order[order.Length - 1].Point.Y); - var surfaces = 0; - - for (var y = startCoord; y <= endCoord; y++) - { - var points = order.Where(p => p.Point.Y > y - startOffset && p.Point.Y < y + endOffset).ToArray(); - var volume = (byte)(0xff / testRays.Count * surfaces); - - foreach (var point in points) - { - if (point.Face == MeshFace.Farside) - { - volume += (byte)(Math.Round(Math.Abs(y + volumeOffset - point.Point.Y) * 255 / testRays.Count, 0)); - surfaces++; - } - else if (point.Face == MeshFace.Nearside) - { - volume -= (byte)(Math.Round(Math.Abs(y + volumeOffset - point.Point.Y) * 255 / testRays.Count, 0)); - surfaces--; - } - } - - if (traceDirectionCount > 1) - { - var prevolumme = modelCubic[bgw.X - xMin][y - yMin][bgw.Z - zMin]; - if (prevolumme != 0) - { - // average with the pre-existing X volume. - volume = (byte)Math.Round(((float)prevolumme + (float)volume) / (float)traceDirectionCount, 0); - } - } - - //volume = volume.RoundUpToNearest(8); - - modelCubic[bgw.X - xMin][y - yMin][bgw.Z - zMin] = volume; - modelMater[bgw.X - xMin][y - yMin][bgw.Z - zMin] = materials[bgw.ModelIdx]; - } - - if (faceMaterials[bgw.ModelIdx] != 0xff) - { - for (var i = 1; i < 6; i++) - { - if (yMin < startCoord - i && modelCubic[bgw.X - xMin][startCoord - i - yMin][bgw.Z - zMin] == 0) - { - modelMater[bgw.X - xMin][startCoord - i - yMin][bgw.Z - zMin] = faceMaterials[bgw.ModelIdx]; - } - if (endCoord + i < yMax && modelCubic[bgw.X - xMin][endCoord + i - yMin][bgw.Z - zMin] == 0) - { - modelMater[bgw.X - xMin][endCoord + i - yMin][bgw.Z - zMin] = faceMaterials[bgw.ModelIdx]; - } - } - } - } - - lock (Locker) - { - threadCounter--; - } - }, new RayTracerTaskWorker(modelIdx, x, 0, z)); - - task.Start(); - } - } - - // Wait for Multithread parts to finish. - while (threadCounter > 0) - { - System.Windows.Forms.Application.DoEvents(); - if (checkCancel != null && checkCancel.Invoke()) - break; - } - - GC.Collect(); - } - - #endregion - - #region Z ray trace - - if ((traceDirection & TraceDirection.Z) == TraceDirection.Z) - { - Debug.WriteLine("Z Rays"); - traceDirectionCount++; - threadCounter = (xMax - xMin) * (yMax - yMin); - - for (var x = xMin; x < xMax; x++) - { - for (var y = yMin; y < yMax; y++) - { - if (checkCancel != null && checkCancel.Invoke()) - { - if (complete != null) - complete.Invoke(); - return null; - } - - List testRays = null; - if (traceType == TraceType.Odd) - testRays = new List - { - new [] {new Point3D(x + offset, y + offset, zMin), new Point3D(x + offset, y + offset, zMax)}, - new [] {new Point3D(x -0.5f + offset, y -0.5f + offset, zMin), new Point3D(x -0.5f + offset, y -0.5f + offset, zMax)}, - new [] {new Point3D(x + 0.5f - offset, y -0.5f + offset, zMin), new Point3D(x + 0.5f - offset, y -0.5f + offset, zMax)}, - new [] {new Point3D(x -0.5f + offset, y + 0.5f - offset, zMin), new Point3D(x -0.5f + offset, y + 0.5f - offset, zMax)}, - new [] {new Point3D(x + 0.5f - offset, y + 0.5f - offset, zMin), new Point3D(x + 0.5f - offset, y + 0.5f - offset, zMax)} - }; - else if (traceType == TraceType.Even) - testRays = new List - { - new [] {new Point3D(x + 0.5f - offset, y + 0.5f - offset, zMin), new Point3D(x + 0.5f - offset, y + 0.5f - offset, zMax)}, - new [] {new Point3D(x + offset, y + offset, zMin), new Point3D(x + offset, y + offset, zMax)}, - new [] {new Point3D(x + 1.0f - offset, y + offset, zMin), new Point3D(x + 1.0f - offset, y + offset, zMax)}, - new [] {new Point3D(x + offset, y + 1.0f - offset, zMin), new Point3D(x + offset, y + 1.0f - offset, zMax)}, - new [] {new Point3D(x + 1.0f - offset, y + 1.0f - offset, zMin), new Point3D(x + 1.0f - offset, y + 1.0f - offset, zMax)} - }; - - var task = new Task(obj => - { - var bgw = (RayTracerTaskWorker)obj; - var tracers = new List(); - - foreach (var geometery in geometries) - { - for (var t = 0; t < geometery.Triangles.Length; t += 3) - { - if (checkCancel != null && checkCancel.Invoke()) - return; - - if (incrementProgress != null) - { - lock (Locker) - { - incrementProgress.Invoke(); - } - } - - var p1 = geometery.Positions[geometery.Triangles[t]]; - var p2 = geometery.Positions[geometery.Triangles[t + 1]]; - var p3 = geometery.Positions[geometery.Triangles[t + 2]]; - - if (rotate.HasValue) - { - p1 = rotate.Value.Transform(p1); - p2 = rotate.Value.Transform(p2); - p3 = rotate.Value.Transform(p3); - } - - foreach (var ray in testRays) - { - if ((p1.X < ray[0].X && p2.X < ray[0].X && p3.X < ray[0].X) || - (p1.X > ray[0].X && p2.X > ray[0].X && p3.X > ray[0].X) || - (p1.Y < ray[0].Y && p2.Y < ray[0].Y && p3.Y < ray[0].Y) || - (p1.Y > ray[0].Y && p2.Y > ray[0].Y && p3.Y > ray[0].Y)) - continue; - - Point3D intersect; - int normal; - if (MeshHelper.RayIntersetTriangleRound(p1, p2, p3, ray[0], ray[1], out intersect, out normal)) - { - tracers.Add(new Trace(intersect, normal)); - } - } - } - } - - if (tracers.Count > 1) - { - var order = tracers.GroupBy(t => new { t.Point, t.Face }).Select(g => g.First()).OrderBy(k => k.Point.Z).ToArray(); - var startCoord = roundFunc(order[0].Point.Z); - var endCoord = roundFunc(order[order.Length - 1].Point.Z); - var surfaces = 0; - - for (var z = startCoord; z <= endCoord; z++) - { - var points = order.Where(p => p.Point.Z > z - startOffset && p.Point.Z < z + endOffset).ToArray(); - var volume = (byte)(0xff / testRays.Count * surfaces); - - foreach (var point in points) - { - if (point.Face == MeshFace.Farside) - { - volume += (byte)(Math.Round(Math.Abs(z + volumeOffset - point.Point.Z) * 255 / testRays.Count, 0)); - surfaces++; - } - else if (point.Face == MeshFace.Nearside) - { - volume -= (byte)(Math.Round(Math.Abs(z + volumeOffset - point.Point.Z) * 255 / testRays.Count, 0)); - surfaces--; - } - } - - if (traceDirectionCount > 1) - { - var prevolumme = modelCubic[bgw.X - xMin][bgw.Y - yMin][z - zMin]; - if (prevolumme != 0) - { - // average with the pre-existing X and Y volumes. - volume = (byte)Math.Round((((float)prevolumme * (traceDirectionCount - 1)) + (float)volume) / (float)traceDirectionCount, 0); - } - } - - //volume = volume.RoundUpToNearest(8); - - modelCubic[bgw.X - xMin][bgw.Y - yMin][z - zMin] = volume; - modelMater[bgw.X - xMin][bgw.Y - yMin][z - zMin] = materials[bgw.ModelIdx]; - } - - if (faceMaterials[bgw.ModelIdx] != 0xff) - { - for (var i = 1; i < 6; i++) - { - if (zMin < startCoord - i && modelCubic[bgw.X - xMin][bgw.Y - yMin][startCoord - i - zMin] == 0) - { - modelMater[bgw.X - xMin][bgw.Y - yMin][startCoord - i - zMin] = faceMaterials[bgw.ModelIdx]; - } - if (endCoord + i < zMax && modelCubic[bgw.X - xMin][bgw.Y - yMin][endCoord + i - zMin] == 0) - { - modelMater[bgw.X - xMin][bgw.Y - yMin][endCoord + i - zMin] = faceMaterials[bgw.ModelIdx]; - } - } - } - } - - lock (Locker) - { - threadCounter--; - } - }, new RayTracerTaskWorker(modelIdx, x, y, 0)); - - task.Start(); - } - } - - // Wait for Multithread parts to finish. - while (threadCounter > 0) - { - System.Windows.Forms.Application.DoEvents(); - if (checkCancel != null && checkCancel.Invoke()) - break; - } - - GC.Collect(); - } - - #endregion - - if (checkCancel != null && checkCancel.Invoke()) - { - complete?.Invoke(); - return null; - } - - #region merge individual model results into final - - for (var x = 0; x < xCount; x++) - { - for (var y = 0; y < yCount; y++) - { - for (var z = 0; z < zCount; z++) - { - if (modelMater[x][y][z] == 0xff && modelCubic[x][y][z] != 0) - { - finalCubic[x][y][z] = (byte)Math.Max(finalCubic[x][y][z] - modelCubic[x][y][z], 0); - } - else if (modelCubic[x][y][z] != 0) - { - finalCubic[x][y][z] = Math.Max(finalCubic[x][y][z], modelCubic[x][y][z]); - finalMater[x][y][z] = modelMater[x][y][z]; - } - else if (finalCubic[x][y][z] == 0 && finalMater[x][y][z] == 0 && modelMater[x][y][z] != 0xff) - { - finalMater[x][y][z] = modelMater[x][y][z]; - } - } - } - } - - #endregion - - } // end models - - #endregion - - if (checkCancel != null && checkCancel.Invoke()) - { - complete?.Invoke(); - return null; - } - - var size = new Vector3I(xCount, yCount, zCount); - // TODO: at the moment the Mesh list is not complete, so the faceMaterial setting is kind of vague. - var defaultMaterial = mappedMesh[0].MaterialIndex; // Use the FaceMaterial from the first Mesh in the object list. - var faceMaterial = mappedMesh[0].FaceMaterialIndex; // Use the FaceMaterial from the first Mesh in the object list. - - var action = (Action)delegate (MyVoxelBuilderArgs e) - { - // center the finalCubic structure within the voxel Volume. - Vector3I pointOffset = (e.Size - size) / 2; - - // the model is only shaped according to its volume, not the voxel which is cubic. - if (e.CoordinatePoint.X >= pointOffset.X && e.CoordinatePoint.X < pointOffset.X + xCount && - e.CoordinatePoint.Y >= pointOffset.Y && e.CoordinatePoint.Y < pointOffset.Y + yCount && - e.CoordinatePoint.Z >= pointOffset.Z && e.CoordinatePoint.Z < pointOffset.Z + zCount) - { - e.Volume = finalCubic[e.CoordinatePoint.X - pointOffset.X][e.CoordinatePoint.Y - pointOffset.Y][e.CoordinatePoint.Z - pointOffset.Z]; - e.MaterialIndex = finalMater[e.CoordinatePoint.X - pointOffset.X][e.CoordinatePoint.Y - pointOffset.Y][e.CoordinatePoint.Z - pointOffset.Z]; - } - }; - - var voxelMap = MyVoxelBuilder.BuildAsteroid(true, size, defaultMaterial.Value, faceMaterial, action); - - complete?.Invoke(); - - return voxelMap; - } - - #endregion - - #region support classes - - public class MyMeshModel - { - public MyMeshModel(MeshGeometry3D[] geometery, byte? materialIndex, byte? faceMaterialIndex) - { - Geometery = geometery; - MaterialIndex = materialIndex; - FaceMaterialIndex = faceMaterialIndex; - } - - public MeshGeometry3D[] Geometery { get; set; } - public byte? MaterialIndex { get; set; } - public byte? FaceMaterialIndex { get; set; } - } - - public class GeometeryDetail - { - public GeometeryDetail(MeshGeometry3D meshGeometry) : - this(meshGeometry.TriangleIndices.ToArray(), meshGeometry.Positions.ToArray()) - { - } - - public GeometeryDetail(int[] triangles, Point3D[] positions) - { - Triangles = triangles; - Positions = positions; - } - - public int[] Triangles { get; set; } - public Point3D[] Positions { get; set; } - } - - private class Trace - { - public Trace(Point3D point, int normal) - { - Point = point; - Face = MeshFace.Undefined; - if (normal == 1) - Face = MeshFace.Nearside; - else if (normal == -1) - Face = MeshFace.Farside; - } - - public Point3D Point { get; } - public MeshFace Face { get; } - } - - private class RayTracerTaskWorker - { - #region ctor - - public RayTracerTaskWorker(int modelIdx, int x, int y, int z) - { - ModelIdx = modelIdx; - X = x; - Y = y; - Z = z; - } - - #endregion - - #region properties - - public int ModelIdx { get; } - public int X { get; } - public int Y { get; } - public int Z { get; } - - #endregion - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/MySteamService.cs b/Dev/SEToolbox/SEToolbox/Interop/MySteamService.cs deleted file mode 100644 index e53f3578..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/MySteamService.cs +++ /dev/null @@ -1,28 +0,0 @@ -using SEToolbox.Support; -using Steamworks; -using MySteamServiceBase = VRage.Steam.MySteamService; - -namespace SEToolbox.Interop -{ - /// - /// Wrapper Keen's MySteamService, so we have to override the default behavior. - /// - public class MySteamService : MySteamServiceBase - { - internal CSteamID SteamUserId; - - public MySteamService(bool isDedicated, uint appId) - : base(true, appId) - { - bool isActive = SteamAPI.Init(); - ReflectionUtil.SetObjectFieldValue(this, "IsActive", isActive); - - if (IsActive) - { - SteamUserId = SteamUser.GetSteamID(); - UserId = (ulong)SteamUserId; - ReflectionUtil.SetObjectFieldValue(this, "m_remoteStorage", new VRage.Steam.MySteamRemoteStorage()); - } - } - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersCore.cs b/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersCore.cs deleted file mode 100644 index 4b42df4a..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersCore.cs +++ /dev/null @@ -1,178 +0,0 @@ -namespace SEToolbox.Interop -{ - using System; - using System.Collections.Generic; - using System.Globalization; - using System.IO; - using System.Reflection; - using System.Threading; - using Sandbox; - using Sandbox.Engine.Utils; - using Sandbox.Engine.Voxels; - using Sandbox.Game; - using Sandbox.Game.GameSystems; - using Sandbox.Game.Multiplayer; - using SEToolbox.Models; - using SpaceEngineers.Game; - using Support; - using VRage; - using VRage.FileSystem; - using VRage.Game; - using VRage.GameServices; - using VRage.Utils; - using VRageRender; - using MySteamServiceBase = VRage.Steam.MySteamService; - - /// - /// core interop for loading up Space Engineers content. - /// - public class SpaceEngineersCore - { - protected static readonly uint AppId = 244850; // Game - //protected static readonly uint AppId = 298740; // Dedicated Server - - #region fields - - public static SpaceEngineersCore Default = new SpaceEngineersCore(); - private WorldResource _worldResource; - private readonly SpaceEngineersResources _stockDefinitions; - private readonly List _manageDeleteVoxelList; - protected MyCommonProgramStartup _startup; - private MySteamServiceBase _steamService; - - #endregion - - #region ctor - - public SpaceEngineersCore() - { - var contentPath = ToolboxUpdater.GetApplicationContentPath(); - string userDataPath = SpaceEngineersConsts.BaseLocalPath.DataPath; - - MyFileSystem.ExePath = Path.GetDirectoryName(Assembly.GetAssembly(typeof(FastResourceLock)).Location); - - MyLog.Default = MySandboxGame.Log; - SpaceEngineersGame.SetupBasicGameInfo(); - _startup = new MyCommonProgramStartup(new string[] { }); - - //var appDataPath = _startup.GetAppDataPath(); - //MyInitializer.InvokeBeforeRun(AppId, MyPerGameSettings.BasicGameInfo.ApplicationName + "SEToolbox", appDataPath); - //MyInitializer.InitCheckSum(); - - MyFileSystem.Reset(); - MyFileSystem.Init(contentPath, userDataPath); - - // This will start the Steam Service, and Steam will think SE is running. - // TODO: we don't want to be doing this all the while SEToolbox is running, - // perhaps a once off during load to fetch of mods then disconnect/Dispose. - _steamService = new MySteamService(MySandboxGame.IsDedicated, AppId); - MyServiceManager.Instance.AddService(_steamService); - - MyFileSystem.InitUserSpecific(SpaceEngineersWorkshop.MySteam.UserId.ToString()); // This sets the save file/path to load games from. - //MyFileSystem.InitUserSpecific(null); - //SpaceEngineersWorkshop.MySteam.Dispose(); - - MySandboxGame.Config = new MyConfig("SpaceEngineers.cfg"); // TODO: Is specific to SE, not configurable to ME. - MySandboxGame.Config.Load(); - - SpaceEngineersGame.SetupPerGameSettings(); - - VRageRender.MyRenderProxy.Initialize(new MyNullRender()); - // We create a whole instance of MySandboxGame! - // If this is causing an exception, then there is a missing dependency. - MySandboxGame gameTemp = new MySandboxGame(new string[] { "-skipintro" }); - - // creating MySandboxGame will reset the CurrentUICulture, so I have to reapply it. - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfoByIetfLanguageTag(GlobalSettings.Default.LanguageCode); - SpaceEngineersApi.LoadLocalization(); - MyStorageBase.UseStorageCache = false; - - #region MySession creation - - // Replace the private constructor on MySession, so we can create it without getting involed with Havok and other depdancies. - var keenStart = typeof(Sandbox.Game.World.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null); - var ourStart = typeof(SEToolbox.Interop.MySession).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(MySyncLayer), typeof(bool) }, null); - ReflectionUtil.ReplaceMethod(ourStart, keenStart); - - // Create an empty instance of MySession for use by low level code. - Sandbox.Game.World.MySession mySession = ReflectionUtil.ConstructPrivateClass(new Type[0], new object[0]); - ReflectionUtil.ConstructField(mySession, "m_sessionComponents"); // Required as the above code doesn't populate it during ctor of MySession. - mySession.Settings = new MyObjectBuilder_SessionSettings { EnableVoxelDestruction = true }; - - VRage.MyVRage.Init(new ToolboxPlatform()); - - // change for the Clone() method to use XML cloning instead of Protobuf because of issues with MyObjectBuilder_CubeGrid.Clone() - ReflectionUtil.SetFieldValue(typeof(VRage.ObjectBuilders.MyObjectBuilderSerializer), "ENABLE_PROTOBUFFERS_CLONING", false); - - // Assign the instance back to the static. - Sandbox.Game.World.MySession.Static = mySession; - - Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static = new MyHeightMapLoadingSystem(); - Sandbox.Game.GameSystems.MyHeightMapLoadingSystem.Static.LoadData(); - - #endregion - - _stockDefinitions = new SpaceEngineersResources(); - _stockDefinitions.LoadDefinitions(); - _manageDeleteVoxelList = new List(); - } - - #endregion - - #region LoadDefinitions - - /// - /// Forces static ctor to load stock defintiions. - /// - public static void LoadDefinitions() - { - } - - #endregion - - #region properties - - public static SpaceEngineersResources Resources - { - get - { - if (Default._worldResource != null) - return Default._worldResource.Resources; - - return Default._stockDefinitions; - } - } - - public static string GetDataPathOrDefault(string key, string defaultValue) - { - if (Default._worldResource != null) - return Default._worldResource.Resources.GetDataPathOrDefault(key, defaultValue); - - return Default._stockDefinitions.GetDataPathOrDefault(key, defaultValue); - } - - public static Dictionary MaterialIndex - { - get - { - if (Default._worldResource != null) - return Default._worldResource.Resources.MaterialIndex; - - return Default._stockDefinitions.MaterialIndex; - } - } - - public static WorldResource WorldResource - { - get { return Default._worldResource; } - set { Default._worldResource = value; } - } - - public static List ManageDeleteVoxelList - { - get { return Default._manageDeleteVoxelList; } - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersExtensions.cs b/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersExtensions.cs deleted file mode 100644 index 333dc03b..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersExtensions.cs +++ /dev/null @@ -1,744 +0,0 @@ -namespace SEToolbox.Interop -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.Globalization; - using System.IO; - using System.Linq; - using Sandbox.Common.ObjectBuilders; - using Sandbox.Definitions; - using SEToolbox.Models; - using SEToolbox.Support; - using VRage; - using VRage.Game; - using VRage.Game.ObjectBuilders.Components; - using VRage.Game.ObjectBuilders.ComponentSystem; - using VRage.Voxels; - using VRage.ObjectBuilders; - using VRageMath; - - /// - /// Contains Extension methods specifically for Keen classes and structures. - /// - public static class SpaceEngineersExtensions - { - internal static SerializableVector3I Mirror(this SerializableVector3I vector, Mirror xMirror, int xAxis, Mirror yMirror, int yAxis, Mirror zMirror, int zAxis) - { - var newVector = new Vector3I(vector.X, vector.Y, vector.Z); - switch (xMirror) - { - case Support.Mirror.Odd: newVector.X = xAxis - (vector.X - xAxis); break; - case Support.Mirror.EvenUp: newVector.X = xAxis - (vector.X - xAxis) + 1; break; - case Support.Mirror.EvenDown: newVector.X = xAxis - (vector.X - xAxis) - 1; break; - } - switch (yMirror) - { - case Support.Mirror.Odd: newVector.Y = yAxis - (vector.Y - yAxis); break; - case Support.Mirror.EvenUp: newVector.Y = yAxis - (vector.Y - yAxis) + 1; break; - case Support.Mirror.EvenDown: newVector.Y = yAxis - (vector.Y - yAxis) - 1; break; - } - switch (zMirror) - { - case Support.Mirror.Odd: newVector.Z = zAxis - (vector.Z - zAxis); break; - case Support.Mirror.EvenUp: newVector.Z = zAxis - (vector.Z - zAxis) + 1; break; - case Support.Mirror.EvenDown: newVector.Z = zAxis - (vector.Z - zAxis) - 1; break; - } - return newVector; - } - - public static double LinearVector(this Vector3 vector) - { - return Math.Sqrt(Math.Pow(vector.X, 2) + Math.Pow(vector.Y, 2) + Math.Pow(vector.Z, 2)); - } - - public static Vector3I ToVector3I(this SerializableVector3I vector) - { - return new Vector3I(vector.X, vector.Y, vector.Z); - } - - public static Vector3I RoundToVector3I(this Vector3 vector) - { - return new Vector3I((int)Math.Round(vector.X, 0, MidpointRounding.ToEven), (int)Math.Round(vector.Y, 0, MidpointRounding.ToEven), (int)Math.Round(vector.Z, 0, MidpointRounding.ToEven)); - } - - public static Vector3I RoundToVector3I(this Vector3D vector) - { - return new Vector3I((int)Math.Round(vector.X, 0, MidpointRounding.ToEven), (int)Math.Round(vector.Y, 0, MidpointRounding.ToEven), (int)Math.Round(vector.Z, 0, MidpointRounding.ToEven)); - } - - public static Vector3 ToVector3(this SerializableVector3I vector) - { - return new Vector3(vector.X, vector.Y, vector.Z); - } - - public static Vector3D ToVector3D(this SerializableVector3I vector) - { - return new Vector3D(vector.X, vector.Y, vector.Z); - } - - public static Vector3 ToVector3(this SerializableVector3 vector) - { - return new Vector3(vector.X, vector.Y, vector.Z); - } - - public static Vector3I SizeInt(this BoundingBox box) - { - var size = box.Size; - return new Vector3I((int)size.X, (int)size.Y, (int)size.Z); - } - - public static Vector3I SizeInt(this BoundingBoxD box) - { - var size = box.Size; - return new Vector3I((int)size.X, (int)size.Y, (int)size.Z); - } - - public static System.Windows.Media.Media3D.Vector3D ToVector3D(this SerializableVector3 vector) - { - return new System.Windows.Media.Media3D.Vector3D(vector.X, vector.Y, vector.Z); - } - - public static System.Windows.Media.Media3D.Vector3D ToVector3D(this Vector3 vector) - { - return new System.Windows.Media.Media3D.Vector3D(vector.X, vector.Y, vector.Z); - } - - public static System.Windows.Media.Media3D.Point3D ToPoint3D(this Vector3D vector) - { - return new System.Windows.Media.Media3D.Point3D(vector.X, vector.Y, vector.Z); - } - - public static System.Windows.Media.Media3D.Point3D ToPoint3D(this SerializableVector3 point) - { - return new System.Windows.Media.Media3D.Point3D(point.X, point.Y, point.Z); - } - - public static System.Windows.Media.Media3D.Point3D ToPoint3D(this SerializableVector3D point) - { - return new System.Windows.Media.Media3D.Point3D(point.X, point.Y, point.Z); - } - - public static System.Windows.Point ToPoint(this Vector2 vector) - { - return new System.Windows.Point(vector.X, vector.Y); - } - - public static Vector3 ToVector3(this System.Windows.Media.Media3D.Point3D point) - { - return new Vector3((float)point.X, (float)point.Y, (float)point.Z); - } - - public static Vector3D ToVector3D(this System.Windows.Media.Media3D.Point3D point) - { - return new Vector3D(point.X, point.Y, point.Z); - } - - public static Vector3 ToVector3(this System.Windows.Media.Media3D.Size3D size3D) - { - return new Vector3((float)size3D.X, (float)size3D.Y, (float)size3D.Z); - } - - public static Vector3D ToVector3D(this System.Windows.Media.Media3D.Size3D size3D) - { - return new Vector3D(size3D.X, size3D.Y, size3D.Z); - } - - public static Vector3 ToVector3(this System.Windows.Media.Media3D.Vector3D size3D) - { - return new Vector3((float)size3D.X, (float)size3D.Y, (float)size3D.Z); - } - - public static Vector3D ToVector3D(this System.Windows.Media.Media3D.Vector3D size3D) - { - return new Vector3D(size3D.X, size3D.Y, size3D.Z); - } - - public static Quaternion ToQuaternion(this SerializableBlockOrientation blockOrientation) - { - var matrix = Matrix.CreateFromDir(Base6Directions.GetVector(blockOrientation.Forward), Base6Directions.GetVector(blockOrientation.Up)); - return Quaternion.CreateFromRotationMatrix(matrix); - } - - public static Quaternion ToQuaternion(this MyPositionAndOrientation positionOrientation) - { - return Quaternion.CreateFromForwardUp(positionOrientation.Forward, positionOrientation.Up); - } - - public static QuaternionD ToQuaternionD(this MyPositionAndOrientation positionOrientation) - { - return QuaternionD.CreateFromForwardUp(new Vector3D(positionOrientation.Forward), new Vector3D(positionOrientation.Up)); - } - - public static Matrix ToMatrix(this MyPositionAndOrientation positionOrientation) - { - return Matrix.CreateFromQuaternion(Quaternion.CreateFromForwardUp(positionOrientation.Forward, positionOrientation.Up)); - } - - public static Matrix ToMatrix(this Quaternion quaternion) - { - return Matrix.CreateFromQuaternion(quaternion); - } - - public static Vector3 Transform(this Vector3 vector, SerializableBlockOrientation orientation) - { - var matrix = Matrix.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); - return Vector3.Transform(vector, matrix); - } - - public static Vector3D Transform(this Vector3D vector, SerializableBlockOrientation orientation) - { - var matrix = MatrixD.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); - return Vector3D.Transform(vector, matrix); - } - - public static Vector3I Transform(this SerializableVector3I size, SerializableBlockOrientation orientation) - { - var matrix = Matrix.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); - var rotation = Quaternion.CreateFromRotationMatrix(matrix); - return Vector3I.Transform(size.ToVector3I(), rotation); - } - - public static Vector3I Transform(this Vector3I size, SerializableBlockOrientation orientation) - { - var matrix = Matrix.CreateFromDir(Base6Directions.GetVector(orientation.Forward), Base6Directions.GetVector(orientation.Up)); - var rotation = Quaternion.CreateFromRotationMatrix(matrix); - return Vector3I.Transform(size, rotation); - } - - public static SerializableVector3I Add(this SerializableVector3I size, int value) - { - return new SerializableVector3I(size.X + value, size.Y + value, size.Z + value); - } - - public static Vector3I Add(this Vector3I size, int value) - { - return new Vector3I(size.X + value, size.Y + value, size.Z + value); - } - - public static Vector3I Abs(this Vector3I size) - { - return new Vector3I(Math.Abs(size.X), Math.Abs(size.Y), Math.Abs(size.Z)); - } - - public static Vector3D ToVector3D(this Vector3I vector) - { - return new Vector3D(vector.X, vector.Y, vector.Z); - } - - public static BoundingBoxD ToBoundingBoxD(this BoundingBoxI box) - { - return new BoundingBoxD(box.Min, box.Max); - } - - public static SerializableVector3 RoundOff(this SerializableVector3 vector, float roundTo) - { - return new SerializableVector3((float)Math.Round(vector.X / roundTo, 0, MidpointRounding.ToEven) * roundTo, (float)Math.Round(vector.Y / roundTo, 0, MidpointRounding.ToEven) * roundTo, (float)Math.Round(vector.Z / roundTo, 0, MidpointRounding.ToEven) * roundTo); - } - - public static SerializableVector3D RoundOff(this SerializableVector3D vector, float roundTo) - { - return new SerializableVector3D(Math.Round(vector.X / roundTo, 0, MidpointRounding.ToEven) * roundTo, Math.Round(vector.Y / roundTo, 0, MidpointRounding.ToEven) * roundTo, Math.Round(vector.Z / roundTo, 0, MidpointRounding.ToEven) * roundTo); - } - - public static MatrixD ToMatrixD(this QuaternionD value) - { - double num = value.X * value.X; - double num2 = value.Y * value.Y; - double num3 = value.Z * value.Z; - double num4 = value.X * value.Y; - double num5 = value.Z * value.W; - double num6 = value.Z * value.X; - double num7 = value.Y * value.W; - double num8 = value.Y * value.Z; - double num9 = value.X * value.W; - MatrixD result = new MatrixD( - (1.0d - 2.0d * (num2 + num3)), - (2.0d * (num4 + num5)), - (2.0d * (num6 - num7)), - 0d, - (2.0d * (num4 - num5)), - (1.0d - 2.0d * (num3 + num)), - (2.0d * (num8 + num9)), - 0d, - (2.0d * (num6 + num7)), - (2.0d * (num8 - num9)), - (1.0d - 2.0d * (num2 + num)), - 0d, - 0d, - 0d, - 0d, - 1d); - return result; - } - - public static SerializableVector3 RoundToAxis(this SerializableVector3 vector) - { - if (Math.Abs(vector.X) > Math.Abs(vector.Y) && Math.Abs(vector.X) > Math.Abs(vector.Z)) - return new SerializableVector3(Math.Sign(vector.X), 0, 0); - - if (Math.Abs(vector.Y) > Math.Abs(vector.X) && Math.Abs(vector.Y) > Math.Abs(vector.Z)) - return new SerializableVector3(0, Math.Sign(vector.Y), 0); - - if (Math.Abs(vector.Z) > Math.Abs(vector.X) && Math.Abs(vector.Z) > Math.Abs(vector.Y)) - return new SerializableVector3(0, 0, Math.Sign(vector.Z)); - - return new SerializableVector3(); - } - - private static decimal Clamp(decimal value, decimal min, decimal max) - { - value = (value > max) ? max : value; - value = (value < min) ? min : value; - return value; - } - - /// - /// Converts from Keen's HSV stored format to RGB matching the in game color picker palatte. - /// - /// the HSV stored value in the range of Hue=X=0.0 to +1.0, Saturation=Y=-1.0 to +1.0, Value=Z=-1.0 to +1.0 - /// converted red value - /// converted green value - /// converted blue value - /// sourced from wikipedia. - private static void FromHsvMaskToPaletteColor(SerializableVector3 hsv, out int red, out int green, out int blue) - { - // I've used decimal because of floating point aberation during calculations. - // This needs to maintain the color accuracy as much as possible. - // I'm still not happy with this, as the game color palette picker is not exactly representative of the in game colors, - // and looking through the calculations, the picker is actually ignoring part of the saturation and value. - decimal hue = (decimal)hsv.X * 360; - decimal saturation = Clamp((decimal)hsv.Y + (decimal)MyColorPickerConstants.SATURATION_DELTA, 0, 1); - decimal value = Clamp((decimal)hsv.Z + (decimal)MyColorPickerConstants.VALUE_DELTA - (decimal)MyColorPickerConstants.VALUE_COLORIZE_DELTA, 0, 1); - - decimal chroma = value * saturation; - decimal hue1 = hue / 60; - decimal x = chroma * (1 - Math.Abs(hue1 % 2 - 1)); - decimal r1 = 0; - decimal g1 = 0; - decimal b1 = 0; - - if (hue1 < 0) - { - // nothing. Need to ignore values less than zero. - } - else if (hue1 <= 1) - { - r1 = chroma; - g1 = x; - } - else if (hue1 <= 2) - { - r1 = x; - g1 = chroma; - } - else if (hue1 <= 3) - { - g1 = chroma; - b1 = x; - } - else if (hue1 <= 4) - { - g1 = x; - b1 = chroma; - } - else if (hue1 <= 5) - { - r1 = x; - b1 = chroma; - } - else if (hue1 <= 6) - { - r1 = chroma; - b1 = x; - } - - decimal m = value - chroma; - - // Need to round off (not up or truncate down) values to correct for aberration. - red = (int)Math.Round((r1 + m) * 255); - green = (int)Math.Round((g1 + m) * 255); - blue = (int)Math.Round((b1 + m) * 255); - } - - public static System.Drawing.Color FromHsvMaskToPaletteColor(this SerializableVector3 hsv) - { - int r, g, b; - FromHsvMaskToPaletteColor(hsv, out r, out g, out b); - return System.Drawing.Color.FromArgb(r, g, b); - } - - public static System.Windows.Media.Color FromHsvMaskToPaletteMediaColor(this SerializableVector3 hsv) - { - int r, g, b; - FromHsvMaskToPaletteColor(hsv, out r, out g, out b); - return System.Windows.Media.Color.FromArgb(255, (byte)r, (byte)g, (byte)b); - } - - /// - /// Converts from RGB matching the in game color picker palatte, to Keen's HSV stored format. - /// - /// the System RGB color - /// the System RGB color - /// the System RGB color - /// the HSV stored value. - /// sourced from wikipedia - private static SerializableVector3 FromPaletteColorToHsvMask(decimal r, decimal g, decimal b) - { - decimal max = Math.Max(r, Math.Max(g, b)); - decimal min = Math.Min(r, Math.Min(g, b)); - decimal chroma = max - min; - - decimal hue1 = 0; - - if (chroma == 0) - hue1 = 0; - else if (max == r) - hue1 = ((g - b) / chroma) % 6; - else if (max == g) - hue1 = ((b - r) / chroma) + 2; - else if (max == b) - hue1 = ((r - g) / chroma) + 4; - - decimal hue = 60 * hue1; - decimal value = max; - - decimal saturation = 0; - - if (value != 0) - saturation = chroma / value; - - return new SerializableVector3((float)hue / 360, (float)saturation - MyColorPickerConstants.SATURATION_DELTA, (float)value - MyColorPickerConstants.VALUE_DELTA + MyColorPickerConstants.VALUE_COLORIZE_DELTA); - } - - public static SerializableVector3 FromPaletteColorToHsvMask(this System.Drawing.Color color) - { - return FromPaletteColorToHsvMask((decimal)color.R / 255, (decimal)color.G / 255, (decimal)color.B / 255); - } - - public static SerializableVector3 FromPaletteColorToHsvMask(this System.Windows.Media.Color color) - { - return FromPaletteColorToHsvMask((decimal)color.R / 255, (decimal)color.G / 255, (decimal)color.B / 255); - } - - /// - /// Returns block size. - /// - /// see: http://spaceengineerswiki.com/index.php?title=FAQs - /// Why are the blocks 0.5 and 2.5 meter blocks? - /// - /// - /// - public static float ToLength(this MyCubeSize cubeSize) - { - return MyDefinitionManager.Static.GetCubeSize(cubeSize); - } - - public static MyFixedPoint ToFixedPoint(this decimal value) - { - return MyFixedPoint.DeserializeString(value.ToString(CultureInfo.InvariantCulture)); - } - - public static MyFixedPoint ToFixedPoint(this double value) - { - return MyFixedPoint.DeserializeString(value.ToString(CultureInfo.InvariantCulture)); - } - - public static MyFixedPoint ToFixedPoint(this float value) - { - return MyFixedPoint.DeserializeString(value.ToString(CultureInfo.InvariantCulture)); - } - - public static MyFixedPoint ToFixedPoint(this int value) - { - return MyFixedPoint.DeserializeString(value.ToString(CultureInfo.InvariantCulture)); - } - - public static Vector3D? IntersectsRayAt(this BoundingBoxD boundingBox, Vector3D position, Vector3D rayTo) - { - var corners = boundingBox.GetCorners(); - var tariangles = new int[][] { - new [] {2,1,0}, - new [] {3,2,0}, - new [] {4,5,6}, - new [] {4,6,7}, - new [] {0,1,5}, - new [] {0,5,4}, - new [] {7,6,2}, - new [] {7,2,3}, - new [] {0,4,7}, - new [] {0,7,3}, - new [] {5,1,2}, - new [] {5,2,6}}; - - foreach (var triangle in tariangles) - { - System.Windows.Media.Media3D.Point3D intersection; - int norm; - - if (MeshHelper.RayIntersetTriangleRound(corners[triangle[0]].ToPoint3D(), corners[triangle[1]].ToPoint3D(), corners[triangle[2]].ToPoint3D(), position.ToPoint3D(), rayTo.ToPoint3D(), out intersection, out norm)) - { - return intersection.ToVector3D(); - } - } - - return null; - } - - public static SerializableVector3UByte Transform(this SerializableVector3UByte value, Quaternion rotation) - { - var vector = Vector3I.Transform(new Vector3I(value.X - 127, value.Y - 127, value.Z - 127), rotation); - return new SerializableVector3UByte((byte)(vector.X + 127), (byte)(vector.Y + 127), (byte)(vector.Z + 127)); - } - - public static Vector3D Transform(this Vector3D value, QuaternionD rotation) - { - double num = (rotation.X + rotation.X); - double num2 = (rotation.Y + rotation.Y); - double num3 = (rotation.Z + rotation.Z); - double num4 = rotation.W * num; - double num5 = rotation.W * num2; - double num6 = rotation.W * num3; - double num7 = rotation.X * num; - double num8 = rotation.X * num2; - double num9 = rotation.X * num3; - double num10 = rotation.Y * num2; - double num11 = rotation.Y * num3; - double num12 = rotation.Z * num3; - double x = value.X * (1.0 - num10 - num12) + value.Y * (num8 - num6) + value.Z * (num9 + num5); - double y = value.X * (num8 + num6) + value.Y * (1.0 - num7 - num12) + value.Z * (num11 - num4); - double z = value.X * (num9 - num5) + value.Y * (num11 + num4) + value.Z * (1.0 - num7 - num10); - Vector3D result = new Vector3D(x, y, z); - return result; - } - - public static int Read7BitEncodedInt(this BinaryReader reader) - { - int num = 0; - int num2 = 0; - while (num2 != 35) - { - byte b = reader.ReadByte(); - num |= (int)(b & 127) << num2; - num2 += 7; - if ((b & 128) == 0) - { - return num; - } - } - return -1; - } - - //public static ObservableCollection GetInventory(this MyObjectBuilder_EntityBase objectBuilderBase) - //{ - // var inventoryEditors = new ObservableCollection(); - - // if (objectBuilderBase.ComponentContainer != null) - // { - // var inventoryBase = objectBuilderBase.ComponentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase"); - - // if (inventoryBase != null) - // { - // var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory; - // if (singleInventory != null) - // { - // var iem = ParseInventory(singleInventory); - // if (iem != null) - // inventoryEditors.Add(iem); - // } - - // var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate; - // if (aggregate != null) - // foreach (var field in aggregate.Inventories) - // { - // var iem = ParseInventory(field as MyObjectBuilder_Inventory); - // if (iem != null) - // inventoryEditors.Add(iem); - // } - // } - // } - // return inventoryEditors; - //} - - public static List GetHierarchyCharacters(this MyObjectBuilder_CubeBlock cube) - { - List list = new List(); - - MyObjectBuilder_Cockpit cockpit = cube as MyObjectBuilder_Cockpit; - if (cockpit == null) - return list; - - var hierarchyBase = cockpit.ComponentContainer.Components.FirstOrDefault(e => e.TypeId == "MyHierarchyComponentBase")?.Component as MyObjectBuilder_HierarchyComponentBase; - if (hierarchyBase != null) - { - list.AddRange(hierarchyBase.Children.Where(e => e is MyObjectBuilder_Character).Cast()); - } - return list; - } - - /// - /// Removes all sign of a pilot/characrter from a cockpit cube. - /// - /// The specific cube. - /// Specific character to remove, if required, otherwise ANY chararcter will be removed. - /// Returns true if a character was removed. - public static bool RemoveHierarchyCharacter(this MyObjectBuilder_Cockpit cockpit, MyObjectBuilder_Character character = null) - { - bool retValue = false; - - MyObjectBuilder_ComponentContainer.ComponentData hierarchyComponentBase = cockpit.ComponentContainer?.Components?.FirstOrDefault(e => e.TypeId == "MyHierarchyComponentBase"); - var hierarchyBase = hierarchyComponentBase?.Component as MyObjectBuilder_HierarchyComponentBase; - if (hierarchyBase != null && hierarchyBase.Children.Count > 0) - { - for (int i = 0; i < hierarchyBase.Children.Count; i++) - { - if (character != null && hierarchyBase.Children[i] == character) - { - retValue = true; - hierarchyBase.Children.RemoveAt(i); - i--; - break; - } - - if (character == null && hierarchyBase.Children[i] is MyObjectBuilder_Character) - { - retValue = true; - hierarchyBase.Children.RemoveAt(i); - i--; - } - } - - if (hierarchyBase.Children.Count == 0) - { - cockpit.ComponentContainer.Components.Remove(hierarchyComponentBase); - } - } - - if (retValue) - { - cockpit.ClearPilotAndAutopilot(); - cockpit.PilotRelativeWorld = null; // This should also clear Pilot. - cockpit.Pilot = null; - } - - return retValue; - } - - /// - /// Remove all pilots, co-pilots and any other character entities from consoles, cockpits and passenger seats. - /// - public static void RemoveHierarchyCharacter(this MyObjectBuilder_CubeGrid cubeGrid) - { - cubeGrid.CubeBlocks.Where(c => c.TypeId == SpaceEngineersTypes.Cockpit).Select(c => - { - ((MyObjectBuilder_Cockpit)c).RemoveHierarchyCharacter(); - return c; - }).ToArray(); - } - - public static ObservableCollection GetInventory(this MyObjectBuilder_ComponentContainer componentContainer, MyCubeBlockDefinition definition = null) - { - var inventoryEditors = new ObservableCollection(); - - if (componentContainer != null) - { - var inventoryBase = componentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase"); - - if (inventoryBase != null) - { - var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory; - if (singleInventory != null) - { - var iem = ParseInventory(singleInventory, definition); - if (iem != null) - inventoryEditors.Add(iem); - } - - var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate; - if (aggregate != null) - foreach (var field in aggregate.Inventories) - { - var iem = ParseInventory(field as MyObjectBuilder_Inventory, definition); - if (iem != null) - inventoryEditors.Add(iem); - } - } - } - return inventoryEditors; - } - - private static InventoryEditorModel ParseInventory(MyObjectBuilder_Inventory inventory, MyCubeBlockDefinition definition = null) - { - if (inventory == null) - return null; - float volumeMultiplier = 1f; // Unsure if there should be a default of 1 if there isn't a InventorySize defined. - - if (definition == null) - volumeMultiplier = 0.4f; - else - { - var definitionType = definition.GetType(); - var invSizeField = definitionType.GetField("InventorySize"); - var inventoryMaxVolumeField = definitionType.GetField("InventoryMaxVolume"); - if (invSizeField != null) - { - var invSize = (Vector3)invSizeField.GetValue(definition); - volumeMultiplier = invSize.X * invSize.Y * invSize.Z; - } - if (inventoryMaxVolumeField != null) - { - var maxSize = (float)inventoryMaxVolumeField.GetValue(definition); - volumeMultiplier = MathHelper.Min(volumeMultiplier, maxSize); - } - } - - var settings = SpaceEngineersCore.WorldResource.Checkpoint.Settings; - return new InventoryEditorModel(inventory, volumeMultiplier * 1000 * settings.InventorySizeMultiplier, null) { Name = inventory.InventoryFlags.ToString(), IsValid = true }; - } - - public static List GetGasDefinitions(this MyDefinitionManager definitionManager) - { - return definitionManager.GetAllDefinitions().Where(e => e.Id.TypeId == typeof(VRage.Game.ObjectBuilders.Definitions.MyObjectBuilder_GasProperties)).Cast().ToList(); - } - - public static MyDefinitionBase GetDefinition(this MyDefinitionManager definitionManager, MyObjectBuilderType typeId, string subTypeId) - { - return definitionManager.GetAllDefinitions().FirstOrDefault(e => e.Id.TypeId == typeId && e.Id.SubtypeName == subTypeId); - } - - public static string GetVoxelDisplayTexture(this MyVoxelMaterialDefinition voxelMaterialDefinition) - { - string texture = null; - - texture = voxelMaterialDefinition.RenderParams.TextureSets[0].ColorMetalXZnY; - - if (texture == null) - texture = voxelMaterialDefinition.RenderParams.TextureSets[0].NormalGlossXZnY; - - if (texture == null) - // The VoxelHandPreview texture is oddly shaped, and not suitable for SEToolbox. - // It is a texture of last resort. - texture = voxelMaterialDefinition.VoxelHandPreview; - - return texture; - } - - public static void GetMaterialContent(this VRage.Game.Voxels.IMyStorage self, ref Vector3I voxelCoords, out byte material, out byte content) - { - MyStorageData myStorageData = new MyStorageData(MyStorageDataTypeFlags.ContentAndMaterial); - myStorageData.Resize(Vector3I.One); - myStorageData.ClearMaterials(0); - self.ReadRange(myStorageData, MyStorageDataTypeFlags.ContentAndMaterial, 0, voxelCoords, voxelCoords); - - material = myStorageData.Material(0); - content = myStorageData.Content(0); - } - - public static int Max(int a, int b, int c, int d) - { - int abMax = a > b ? a : b; - int cdMax = c > d ? c : d; - return abMax > cdMax ? abMax : cdMax; - } - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersResources.cs b/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersResources.cs deleted file mode 100644 index 9c2b82f1..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersResources.cs +++ /dev/null @@ -1,154 +0,0 @@ -namespace SEToolbox.Interop -{ - using Sandbox.Definitions; - using SEToolbox.Support; - using System.Collections.Generic; - using System.Linq; - using VRage.Game; - using VRage.ObjectBuilders; - - /// - /// Encapsulates the game definitions, either stock or loaded for a specific save game world. - /// - public class SpaceEngineersResources - { - #region LoadDefinitions - - /// - /// Loads Stock definitions from default path, useful for tests. - /// - public void LoadDefinitions() - { - // Call the PrepareBaseDefinitions(), to load DefinitionsToPreload.sbc file first. - // otherwise LoadData() may throw an InvalidOperationException due to a modified collection. - MyDefinitionManager.Static.PrepareBaseDefinitions(); - MyDefinitionManager.Static.LoadData(new List()); - MaterialIndex = new Dictionary(); - } - - public void LoadDefinitionsAndMods(string userModspath, MyObjectBuilder_Checkpoint.ModItem[] mods) - { - LoadDefinitionsAndMods(ToolboxUpdater.GetApplicationContentPath(), userModspath, mods); - } - - public void LoadDefinitionsAndMods(string applicationContentPath, string userModspath, MyObjectBuilder_Checkpoint.ModItem[] mods) - { - // Call the PrepareBaseDefinitions(), to load DefinitionsToPreload.sbc file first. - // otherwise LoadData() may throw an InvalidOperationException due to a modified collection. - MyDefinitionManager.Static.PrepareBaseDefinitions(); - MyDefinitionManager.Static.LoadData(mods.ToList()); - MaterialIndex = new Dictionary(); - } - - #endregion - - #region properties - - public Dictionary MaterialIndex { get; private set; } - - #endregion - - #region methods - - public string GetDataPathOrDefault(string key, string defaultValue) - { - // TODO: this code is obsolete and needs to be cleaned up. - // #31 https://github.com/midspace/SEToolbox/commit/354fd4cba31d1d8accac4c8188189dd1b114209b#diff-816c9c8868fbb3625db0cc45485797ef - - return defaultValue; - } - - private static readonly object MatindexLock = new object(); - - public byte GetMaterialIndex(string materialName) - { - lock (MatindexLock) - { - return MyDefinitionManager.Static.GetVoxelMaterialDefinition(materialName).Index; - } - } - - public IList BlueprintDefinitions - { - get { return MyDefinitionManager.Static.GetBlueprintDefinitions().ToList(); } - } - - public IList CubeBlockDefinitions - { - get { return MyDefinitionManager.Static.GetAllDefinitions().Where(e => e is MyCubeBlockDefinition).Cast().ToList(); } - } - - public IList ComponentDefinitions - { - get { return MyDefinitionManager.Static.GetPhysicalItemDefinitions().Where(e => e is MyComponentDefinition).Cast().ToList(); } - } - - public IList PhysicalItemDefinitions - { - get { return MyDefinitionManager.Static.GetPhysicalItemDefinitions().Where(e => !(e is MyComponentDefinition)).ToList(); } - } - - public IList AmmoMagazineDefinitions - { - get { return MyDefinitionManager.Static.GetAllDefinitions().Where(e => e is MyAmmoMagazineDefinition).Cast().ToList(); } - } - - public IList VoxelMaterialDefinitions - { - get { return MyDefinitionManager.Static.GetVoxelMaterialDefinitions().ToList(); } - } - - public IList VoxelMapStorageDefinitions - { - get { return MyDefinitionManager.Static.GetVoxelMapStorageDefinitions().ToList(); } - } - - public IList CharacterDefinitions - { - get { return MyDefinitionManager.Static.Characters.ToList(); } - } - - public string GetMaterialName(byte materialIndex, byte defaultMaterialIndex) - { - if (materialIndex <= MyDefinitionManager.Static.GetVoxelMaterialDefinitions().Count) - return MyDefinitionManager.Static.GetVoxelMaterialDefinition(materialIndex).Id.SubtypeName; - - return MyDefinitionManager.Static.GetVoxelMaterialDefinition(defaultMaterialIndex).Id.SubtypeName; - - //if (materialIndex <= _definitions.VoxelMaterials.Length) - // return _definitions.VoxelMaterials[materialIndex].Id.SubtypeId; - - //return _definitions.VoxelMaterials[defaultMaterialIndex].Id.SubtypeId; - } - - public string GetMaterialName(byte materialIndex) - { - return MyDefinitionManager.Static.GetVoxelMaterialDefinition(materialIndex).Id.SubtypeName; - //return _definitions.VoxelMaterials[materialIndex].Id.SubtypeId; - } - - public string GetDefaultMaterialName() - { - return MyDefinitionManager.Static.GetDefaultVoxelMaterialDefinition().Id.SubtypeName; - } - - public byte GetDefaultMaterialIndex() - { - return MyDefinitionManager.Static.GetDefaultVoxelMaterialDefinition().Index; - } - - public T CreateNewObject() - where T : MyObjectBuilder_Base - { - return (T)MyObjectBuilderSerializer.CreateNewObject(typeof(T)); - } - - public T CreateNewObject(MyObjectBuilderType typeId, string subtypeId) - where T : MyObjectBuilder_Base - { - return (T)MyObjectBuilderSerializer.CreateNewObject(typeId, subtypeId); - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersWorkshop.cs b/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersWorkshop.cs deleted file mode 100644 index b78821ba..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SpaceEngineersWorkshop.cs +++ /dev/null @@ -1,90 +0,0 @@ -using Sandbox; -using Sandbox.Engine.Networking; -using System.Collections.Generic; -using VRage; -using VRage.Game; - -namespace SEToolbox.Interop -{ - public class SpaceEngineersWorkshop : MyWorkshop - { - public static MySteamService MySteam { get => (MySteamService)MyServiceManager.Instance.GetService(); } - - public static void GetModItems(List mods) - { - ResultData ret = new ResultData(); - ret.Success = true; - - if (mods != null && mods.Count > 0) - { - var publishedFileIds = new List(); - foreach (var mod in mods) - { - if (mod.PublishedFileId != 0) - { - if (!publishedFileIds.Contains(mod.PublishedFileId)) - { - publishedFileIds.Add(mod.PublishedFileId); - } - } - } - - publishedFileIds.Sort(); - CheckModDependencies(mods, publishedFileIds); - } - } - - private static void CheckModDependencies(List mods, List publishedFileIds) - { - List resultModList = new List(); - HashSet rootMods = new HashSet(); - foreach (var mod in mods) - { - if (mod.IsDependency) - { - continue; - } - - if (mod.PublishedFileId == 0) - { - resultModList.Add(mod); - } - else - { - rootMods.Add(mod.PublishedFileId); - } - } - - bool hasReferenceIssue; - if (MySteam.IsActive) - { - MySandboxGame.IsDedicated = true; - var dependencies = GetModsDependencyHiearchy(rootMods, out hasReferenceIssue); - MySandboxGame.IsDedicated = false; - foreach (var depMod in dependencies) - { - bool isDependency = !rootMods.Contains(depMod.Id); - - var newMod = new MyObjectBuilder_Checkpoint.ModItem(depMod.Id, isDependency); - newMod.FriendlyName = depMod.Title; - depMod.UpdateState(); - - // Exclude mods that have not been downloaded. - if (depMod.Folder != null) - { - newMod.SetModData(depMod); - } - - resultModList.Add(newMod); - if (!publishedFileIds.Contains(depMod.Id)) - { - publishedFileIds.Add(depMod.Id); - } - } - } - - mods.Clear(); - mods.AddRange(resultModList); - } - } -} diff --git a/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.cs b/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.cs deleted file mode 100644 index a40752e9..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.cs +++ /dev/null @@ -1,638 +0,0 @@ -namespace SEToolbox.Interop -{ - /// - /// Generated by Text Templating on Game Engine data file 'CubeBlocks.sbc'. - /// - public enum SubtypeId - { - Empty = 0, - - // Although not enumerated in the Space Engineers API, I'm autogenerating enumerations - // direct from the game source here to make sure we have strongly typed names when generating content, - // rather than relying upon hardcoded 'strings' which required maintenance. - // When checking content read from 'world' saves however, we will have to rely upon the game data. - - Monolith, - Stereolith, - DeadAstronaut, - LargeBlockBatteryBlock, - SmallBlockBatteryBlock, - LargeBlockArmorBlock, - LargeBlockArmorBlockRed, - LargeBlockArmorBlockYellow, - LargeBlockArmorBlockBlue, - LargeBlockArmorBlockGreen, - LargeBlockArmorBlockBlack, - LargeBlockArmorBlockWhite, - LargeBlockArmorSlope, - LargeBlockArmorSlopeRed, - LargeBlockArmorSlopeYellow, - LargeBlockArmorSlopeBlue, - LargeBlockArmorSlopeGreen, - LargeBlockArmorSlopeBlack, - LargeBlockArmorSlopeWhite, - LargeBlockArmorCorner, - LargeBlockArmorCornerRed, - LargeBlockArmorCornerYellow, - LargeBlockArmorCornerBlue, - LargeBlockArmorCornerGreen, - LargeBlockArmorCornerBlack, - LargeBlockArmorCornerWhite, - LargeBlockArmorCornerInv, - LargeBlockArmorCornerInvRed, - LargeBlockArmorCornerInvYellow, - LargeBlockArmorCornerInvBlue, - LargeBlockArmorCornerInvGreen, - LargeBlockArmorCornerInvBlack, - LargeBlockArmorCornerInvWhite, - LargeRoundArmor_Slope, - LargeRoundArmor_SlopeRed, - LargeRoundArmor_SlopeYellow, - LargeRoundArmor_SlopeBlue, - LargeRoundArmor_SlopeGreen, - LargeRoundArmor_SlopeBlack, - LargeRoundArmor_SlopeWhite, - LargeRoundArmor_Corner, - LargeRoundArmor_CornerRed, - LargeRoundArmor_CornerYellow, - LargeRoundArmor_CornerBlue, - LargeRoundArmor_CornerGreen, - LargeRoundArmor_CornerBlack, - LargeRoundArmor_CornerWhite, - LargeRoundArmor_CornerInv, - LargeRoundArmor_CornerInvRed, - LargeRoundArmor_CornerInvYellow, - LargeRoundArmor_CornerInvBlue, - LargeRoundArmor_CornerInvGreen, - LargeRoundArmor_CornerInvBlack, - LargeRoundArmor_CornerInvWhite, - LargeHeavyBlockArmorBlock, - LargeHeavyBlockArmorBlockRed, - LargeHeavyBlockArmorBlockYellow, - LargeHeavyBlockArmorBlockBlue, - LargeHeavyBlockArmorBlockGreen, - LargeHeavyBlockArmorBlockBlack, - LargeHeavyBlockArmorBlockWhite, - LargeHeavyBlockArmorSlope, - LargeHeavyBlockArmorSlopeRed, - LargeHeavyBlockArmorSlopeYellow, - LargeHeavyBlockArmorSlopeBlue, - LargeHeavyBlockArmorSlopeGreen, - LargeHeavyBlockArmorSlopeBlack, - LargeHeavyBlockArmorSlopeWhite, - LargeHeavyBlockArmorCorner, - LargeHeavyBlockArmorCornerRed, - LargeHeavyBlockArmorCornerYellow, - LargeHeavyBlockArmorCornerBlue, - LargeHeavyBlockArmorCornerGreen, - LargeHeavyBlockArmorCornerBlack, - LargeHeavyBlockArmorCornerWhite, - LargeHeavyBlockArmorCornerInv, - LargeHeavyBlockArmorCornerInvRed, - LargeHeavyBlockArmorCornerInvYellow, - LargeHeavyBlockArmorCornerInvBlue, - LargeHeavyBlockArmorCornerInvGreen, - LargeHeavyBlockArmorCornerInvBlack, - LargeHeavyBlockArmorCornerInvWhite, - SmallBlockArmorBlock, - SmallBlockArmorBlockRed, - SmallBlockArmorBlockYellow, - SmallBlockArmorBlockBlue, - SmallBlockArmorBlockGreen, - SmallBlockArmorBlockBlack, - SmallBlockArmorBlockWhite, - SmallBlockArmorSlope, - SmallBlockArmorSlopeRed, - SmallBlockArmorSlopeYellow, - SmallBlockArmorSlopeBlue, - SmallBlockArmorSlopeGreen, - SmallBlockArmorSlopeBlack, - SmallBlockArmorSlopeWhite, - SmallBlockArmorCorner, - SmallBlockArmorCornerRed, - SmallBlockArmorCornerYellow, - SmallBlockArmorCornerBlue, - SmallBlockArmorCornerGreen, - SmallBlockArmorCornerBlack, - SmallBlockArmorCornerWhite, - SmallBlockArmorCornerInv, - SmallBlockArmorCornerInvRed, - SmallBlockArmorCornerInvYellow, - SmallBlockArmorCornerInvBlue, - SmallBlockArmorCornerInvGreen, - SmallBlockArmorCornerInvBlack, - SmallBlockArmorCornerInvWhite, - SmallHeavyBlockArmorBlock, - SmallHeavyBlockArmorBlockRed, - SmallHeavyBlockArmorBlockYellow, - SmallHeavyBlockArmorBlockBlue, - SmallHeavyBlockArmorBlockGreen, - SmallHeavyBlockArmorBlockBlack, - SmallHeavyBlockArmorBlockWhite, - SmallHeavyBlockArmorSlope, - SmallHeavyBlockArmorSlopeRed, - SmallHeavyBlockArmorSlopeYellow, - SmallHeavyBlockArmorSlopeBlue, - SmallHeavyBlockArmorSlopeGreen, - SmallHeavyBlockArmorSlopeBlack, - SmallHeavyBlockArmorSlopeWhite, - SmallHeavyBlockArmorCorner, - SmallHeavyBlockArmorCornerRed, - SmallHeavyBlockArmorCornerYellow, - SmallHeavyBlockArmorCornerBlue, - SmallHeavyBlockArmorCornerGreen, - SmallHeavyBlockArmorCornerBlack, - SmallHeavyBlockArmorCornerWhite, - SmallHeavyBlockArmorCornerInv, - SmallHeavyBlockArmorCornerInvRed, - SmallHeavyBlockArmorCornerInvYellow, - SmallHeavyBlockArmorCornerInvBlue, - SmallHeavyBlockArmorCornerInvGreen, - SmallHeavyBlockArmorCornerInvBlack, - SmallHeavyBlockArmorCornerInvWhite, - LargeHalfArmorBlock, - LargeHeavyHalfArmorBlock, - LargeHalfSlopeArmorBlock, - LargeHeavyHalfSlopeArmorBlock, - HalfArmorBlock, - HeavyHalfArmorBlock, - HalfSlopeArmorBlock, - HeavyHalfSlopeArmorBlock, - LargeBlockArmorRoundSlope, - LargeBlockArmorRoundSlopeRed, - LargeBlockArmorRoundSlopeYellow, - LargeBlockArmorRoundSlopeBlue, - LargeBlockArmorRoundSlopeGreen, - LargeBlockArmorRoundSlopeBlack, - LargeBlockArmorRoundSlopeWhite, - LargeBlockArmorRoundCorner, - LargeBlockArmorRoundCornerRed, - LargeBlockArmorRoundCornerYellow, - LargeBlockArmorRoundCornerBlue, - LargeBlockArmorRoundCornerGreen, - LargeBlockArmorRoundCornerBlack, - LargeBlockArmorRoundCornerWhite, - LargeBlockArmorRoundCornerInv, - LargeBlockArmorRoundCornerInvRed, - LargeBlockArmorRoundCornerInvYellow, - LargeBlockArmorRoundCornerInvBlue, - LargeBlockArmorRoundCornerInvGreen, - LargeBlockArmorRoundCornerInvBlack, - LargeBlockArmorRoundCornerInvWhite, - LargeHeavyBlockArmorRoundSlope, - LargeHeavyBlockArmorRoundSlopeRed, - LargeHeavyBlockArmorRoundSlopeYellow, - LargeHeavyBlockArmorRoundSlopeBlue, - LargeHeavyBlockArmorRoundSlopeGreen, - LargeHeavyBlockArmorRoundSlopeBlack, - LargeHeavyBlockArmorRoundSlopeWhite, - LargeHeavyBlockArmorRoundCorner, - LargeHeavyBlockArmorRoundCornerRed, - LargeHeavyBlockArmorRoundCornerYellow, - LargeHeavyBlockArmorRoundCornerBlue, - LargeHeavyBlockArmorRoundCornerGreen, - LargeHeavyBlockArmorRoundCornerBlack, - LargeHeavyBlockArmorRoundCornerWhite, - LargeHeavyBlockArmorRoundCornerInv, - LargeHeavyBlockArmorRoundCornerInvRed, - LargeHeavyBlockArmorRoundCornerInvYellow, - LargeHeavyBlockArmorRoundCornerInvBlue, - LargeHeavyBlockArmorRoundCornerInvGreen, - LargeHeavyBlockArmorRoundCornerInvBlack, - LargeHeavyBlockArmorRoundCornerInvWhite, - SmallBlockArmorRoundSlope, - SmallBlockArmorRoundSlopeRed, - SmallBlockArmorRoundSlopeYellow, - SmallBlockArmorRoundSlopeBlue, - SmallBlockArmorRoundSlopeGreen, - SmallBlockArmorRoundSlopeBlack, - SmallBlockArmorRoundSlopeWhite, - SmallBlockArmorRoundCorner, - SmallBlockArmorRoundCornerRed, - SmallBlockArmorRoundCornerYellow, - SmallBlockArmorRoundCornerBlue, - SmallBlockArmorRoundCornerGreen, - SmallBlockArmorRoundCornerBlack, - SmallBlockArmorRoundCornerWhite, - SmallBlockArmorRoundCornerInv, - SmallBlockArmorRoundCornerInvRed, - SmallBlockArmorRoundCornerInvYellow, - SmallBlockArmorRoundCornerInvBlue, - SmallBlockArmorRoundCornerInvGreen, - SmallBlockArmorRoundCornerInvBlack, - SmallBlockArmorRoundCornerInvWhite, - SmallHeavyBlockArmorRoundSlope, - SmallHeavyBlockArmorRoundSlopeRed, - SmallHeavyBlockArmorRoundSlopeYellow, - SmallHeavyBlockArmorRoundSlopeBlue, - SmallHeavyBlockArmorRoundSlopeGreen, - SmallHeavyBlockArmorRoundSlopeBlack, - SmallHeavyBlockArmorRoundSlopeWhite, - SmallHeavyBlockArmorRoundCorner, - SmallHeavyBlockArmorRoundCornerRed, - SmallHeavyBlockArmorRoundCornerYellow, - SmallHeavyBlockArmorRoundCornerBlue, - SmallHeavyBlockArmorRoundCornerGreen, - SmallHeavyBlockArmorRoundCornerBlack, - SmallHeavyBlockArmorRoundCornerWhite, - SmallHeavyBlockArmorRoundCornerInv, - SmallHeavyBlockArmorRoundCornerInvRed, - SmallHeavyBlockArmorRoundCornerInvYellow, - SmallHeavyBlockArmorRoundCornerInvBlue, - SmallHeavyBlockArmorRoundCornerInvGreen, - SmallHeavyBlockArmorRoundCornerInvBlack, - SmallHeavyBlockArmorRoundCornerInvWhite, - LargeBlockArmorSlope2Base, - LargeBlockArmorSlope2BaseRed, - LargeBlockArmorSlope2BaseYellow, - LargeBlockArmorSlope2BaseBlue, - LargeBlockArmorSlope2BaseGreen, - LargeBlockArmorSlope2BaseBlack, - LargeBlockArmorSlope2BaseWhite, - LargeBlockArmorSlope2Tip, - LargeBlockArmorSlope2TipRed, - LargeBlockArmorSlope2TipYellow, - LargeBlockArmorSlope2TipBlue, - LargeBlockArmorSlope2TipGreen, - LargeBlockArmorSlope2TipBlack, - LargeBlockArmorSlope2TipWhite, - LargeBlockArmorCorner2Base, - LargeBlockArmorCorner2BaseRed, - LargeBlockArmorCorner2BaseYellow, - LargeBlockArmorCorner2BaseBlue, - LargeBlockArmorCorner2BaseGreen, - LargeBlockArmorCorner2BaseBlack, - LargeBlockArmorCorner2BaseWhite, - LargeBlockArmorCorner2Tip, - LargeBlockArmorCorner2TipRed, - LargeBlockArmorCorner2TipYellow, - LargeBlockArmorCorner2TipBlue, - LargeBlockArmorCorner2TipGreen, - LargeBlockArmorCorner2TipBlack, - LargeBlockArmorCorner2TipWhite, - LargeBlockArmorInvCorner2Base, - LargeBlockArmorInvCorner2BaseRed, - LargeBlockArmorInvCorner2BaseYellow, - LargeBlockArmorInvCorner2BaseBlue, - LargeBlockArmorInvCorner2BaseGreen, - LargeBlockArmorInvCorner2BaseBlack, - LargeBlockArmorInvCorner2BaseWhite, - LargeBlockArmorInvCorner2Tip, - LargeBlockArmorInvCorner2TipRed, - LargeBlockArmorInvCorner2TipYellow, - LargeBlockArmorInvCorner2TipBlue, - LargeBlockArmorInvCorner2TipGreen, - LargeBlockArmorInvCorner2TipBlack, - LargeBlockArmorInvCorner2TipWhite, - LargeHeavyBlockArmorSlope2Base, - LargeHeavyBlockArmorSlope2BaseRed, - LargeHeavyBlockArmorSlope2BaseYellow, - LargeHeavyBlockArmorSlope2BaseBlue, - LargeHeavyBlockArmorSlope2BaseGreen, - LargeHeavyBlockArmorSlope2BaseBlack, - LargeHeavyBlockArmorSlope2BaseWhite, - LargeHeavyBlockArmorSlope2Tip, - LargeHeavyBlockArmorSlope2TipRed, - LargeHeavyBlockArmorSlope2TipYellow, - LargeHeavyBlockArmorSlope2TipBlue, - LargeHeavyBlockArmorSlope2TipGreen, - LargeHeavyBlockArmorSlope2TipBlack, - LargeHeavyBlockArmorSlope2TipWhite, - LargeHeavyBlockArmorCorner2Base, - LargeHeavyBlockArmorCorner2BaseRed, - LargeHeavyBlockArmorCorner2BaseYellow, - LargeHeavyBlockArmorCorner2BaseBlue, - LargeHeavyBlockArmorCorner2BaseGreen, - LargeHeavyBlockArmorCorner2BaseBlack, - LargeHeavyBlockArmorCorner2BaseWhite, - LargeHeavyBlockArmorCorner2Tip, - LargeHeavyBlockArmorCorner2TipRed, - LargeHeavyBlockArmorCorner2TipYellow, - LargeHeavyBlockArmorCorner2TipBlue, - LargeHeavyBlockArmorCorner2TipGreen, - LargeHeavyBlockArmorCorner2TipBlack, - LargeHeavyBlockArmorCorner2TipWhite, - LargeHeavyBlockArmorInvCorner2Base, - LargeHeavyBlockArmorInvCorner2BaseRed, - LargeHeavyBlockArmorInvCorner2BaseYellow, - LargeHeavyBlockArmorInvCorner2BaseBlue, - LargeHeavyBlockArmorInvCorner2BaseGreen, - LargeHeavyBlockArmorInvCorner2BaseBlack, - LargeHeavyBlockArmorInvCorner2BaseWhite, - LargeHeavyBlockArmorInvCorner2Tip, - LargeHeavyBlockArmorInvCorner2TipRed, - LargeHeavyBlockArmorInvCorner2TipYellow, - LargeHeavyBlockArmorInvCorner2TipBlue, - LargeHeavyBlockArmorInvCorner2TipGreen, - LargeHeavyBlockArmorInvCorner2TipBlack, - LargeHeavyBlockArmorInvCorner2TipWhite, - SmallBlockArmorSlope2Base, - SmallBlockArmorSlope2BaseRed, - SmallBlockArmorSlope2BaseYellow, - SmallBlockArmorSlope2BaseBlue, - SmallBlockArmorSlope2BaseGreen, - SmallBlockArmorSlope2BaseBlack, - SmallBlockArmorSlope2BaseWhite, - SmallBlockArmorSlope2Tip, - SmallBlockArmorSlope2TipRed, - SmallBlockArmorSlope2TipYellow, - SmallBlockArmorSlope2TipBlue, - SmallBlockArmorSlope2TipGreen, - SmallBlockArmorSlope2TipBlack, - SmallBlockArmorSlope2TipWhite, - SmallBlockArmorCorner2Base, - SmallBlockArmorCorner2BaseRed, - SmallBlockArmorCorner2BaseYellow, - SmallBlockArmorCorner2BaseBlue, - SmallBlockArmorCorner2BaseGreen, - SmallBlockArmorCorner2BaseBlack, - SmallBlockArmorCorner2BaseWhite, - SmallBlockArmorCorner2Tip, - SmallBlockArmorCorner2TipRed, - SmallBlockArmorCorner2TipYellow, - SmallBlockArmorCorner2TipBlue, - SmallBlockArmorCorner2TipGreen, - SmallBlockArmorCorner2TipBlack, - SmallBlockArmorCorner2TipWhite, - SmallBlockArmorInvCorner2Base, - SmallBlockArmorInvCorner2BaseRed, - SmallBlockArmorInvCorner2BaseYellow, - SmallBlockArmorInvCorner2BaseBlue, - SmallBlockArmorInvCorner2BaseGreen, - SmallBlockArmorInvCorner2BaseBlack, - SmallBlockArmorInvCorner2BaseWhite, - SmallBlockArmorInvCorner2Tip, - SmallBlockArmorInvCorner2TipRed, - SmallBlockArmorInvCorner2TipYellow, - SmallBlockArmorInvCorner2TipBlue, - SmallBlockArmorInvCorner2TipGreen, - SmallBlockArmorInvCorner2TipBlack, - SmallBlockArmorInvCorner2TipWhite, - SmallHeavyBlockArmorSlope2Base, - SmallHeavyBlockArmorSlope2BaseRed, - SmallHeavyBlockArmorSlope2BaseYellow, - SmallHeavyBlockArmorSlope2BaseBlue, - SmallHeavyBlockArmorSlope2BaseGreen, - SmallHeavyBlockArmorSlope2BaseBlack, - SmallHeavyBlockArmorSlope2BaseWhite, - SmallHeavyBlockArmorSlope2Tip, - SmallHeavyBlockArmorSlope2TipRed, - SmallHeavyBlockArmorSlope2TipYellow, - SmallHeavyBlockArmorSlope2TipBlue, - SmallHeavyBlockArmorSlope2TipGreen, - SmallHeavyBlockArmorSlope2TipBlack, - SmallHeavyBlockArmorSlope2TipWhite, - SmallHeavyBlockArmorCorner2Base, - SmallHeavyBlockArmorCorner2BaseRed, - SmallHeavyBlockArmorCorner2BaseYellow, - SmallHeavyBlockArmorCorner2BaseBlue, - SmallHeavyBlockArmorCorner2BaseGreen, - SmallHeavyBlockArmorCorner2BaseBlack, - SmallHeavyBlockArmorCorner2BaseWhite, - SmallHeavyBlockArmorCorner2Tip, - SmallHeavyBlockArmorCorner2TipRed, - SmallHeavyBlockArmorCorner2TipYellow, - SmallHeavyBlockArmorCorner2TipBlue, - SmallHeavyBlockArmorCorner2TipGreen, - SmallHeavyBlockArmorCorner2TipBlack, - SmallHeavyBlockArmorCorner2TipWhite, - SmallHeavyBlockArmorInvCorner2Base, - SmallHeavyBlockArmorInvCorner2BaseRed, - SmallHeavyBlockArmorInvCorner2BaseYellow, - SmallHeavyBlockArmorInvCorner2BaseBlue, - SmallHeavyBlockArmorInvCorner2BaseGreen, - SmallHeavyBlockArmorInvCorner2BaseBlack, - SmallHeavyBlockArmorInvCorner2BaseWhite, - SmallHeavyBlockArmorInvCorner2Tip, - SmallHeavyBlockArmorInvCorner2TipRed, - SmallHeavyBlockArmorInvCorner2TipYellow, - SmallHeavyBlockArmorInvCorner2TipBlue, - SmallHeavyBlockArmorInvCorner2TipGreen, - SmallHeavyBlockArmorInvCorner2TipBlack, - SmallHeavyBlockArmorInvCorner2TipWhite, - ControlPanel, - SmallProgrammableBlock, - SmallControlPanel, - SmallGatlingTurret, - SmallMissileTurret, - LargeInteriorTurret, - LargeBlockRadioAntenna, - LargeBlockBeacon, - SmallBlockBeacon, - LargeBlockFrontLight, - SmallLight, - SmallBlockSmallLight, - LargeBlockLight_1corner, - LargeBlockLight_2corner, - SmallBlockLight_1corner, - SmallBlockLight_2corner, - LargeWindowSquare, - LargeWindowEdge, - LargeStairs, - LargeRamp, - LargeSteelCatwalk, - LargeSteelCatwalk2Sides, - LargeSteelCatwalkCorner, - LargeSteelCatwalkPlate, - LargeCoverWall, - LargeCoverWallHalf, - LargeWarhead, - SmallWarhead, - LargeDecoy, - SmallDecoy, - LargeBlockInteriorWall, - LargeInteriorPillar, - LargeBlockLandingGear, - LargeProjector, - SmallProjector, - LargeRefinery, - Blast_Furnace, // 'Blast Furnace' - LargeAssembler, - LargeOreDetector, - LargeMedicalRoom, - LargeJumpDrive, - LargeBlockCockpit, - LargeBlockCockpitSeat, - SmallBlockCockpit, - DBSmallBlockFighterCockpit, - CockpitOpen, - PassengerSeatLarge, - PassengerSeatSmall, - LargeBlockCryoChamber, - SmallBlockLandingGear, - SmallBlockFrontLight, - LargeMissileLauncher, - SmallRocketLauncherReload, - SmallBlockDrill, - LargeBlockDrill, - SmallBlockOreDetector, - SmallBlockSensor, - LargeBlockSensor, - SmallBlockSoundBlock, - LargeBlockSoundBlock, - SmallTextPanel, - SmallLCDPanelWide, - SmallLCDPanel, - LargeBlockCorner_LCD_1, - LargeBlockCorner_LCD_2, - LargeBlockCorner_LCD_Flat_1, - LargeBlockCorner_LCD_Flat_2, - SmallBlockCorner_LCD_1, - SmallBlockCorner_LCD_2, - SmallBlockCorner_LCD_Flat_1, - SmallBlockCorner_LCD_Flat_2, - OxygenTankSmall, - OxygenGeneratorSmall, - LargeTextPanel, - LargeLCDPanel, - LargeLCDPanelWide, - SmallBlockRadioAntenna, - LargeBlockRemoteControl, - SmallBlockRemoteControl, - SmallAirVent, - LargeHydrogenTank, - SmallHydrogenTank, - LargeProductivityModule, - LargeEffectivenessModule, - LargeEnergyModule, - SmallBlockSmallContainer, - SmallBlockMediumContainer, - SmallBlockLargeContainer, - LargeBlockSmallContainer, - LargeBlockLargeContainer, - SmallBlockSmallThrust, - SmallBlockLargeThrust, - LargeBlockSmallThrust, - LargeBlockLargeThrust, - LargeBlockLargeHydrogenThrust, - LargeBlockSmallHydrogenThrust, - SmallBlockLargeHydrogenThrust, - SmallBlockSmallHydrogenThrust, - LargeBlockLargeAtmosphericThrust, - LargeBlockSmallAtmosphericThrust, - SmallBlockLargeAtmosphericThrust, - SmallBlockSmallAtmosphericThrust, - SmallCameraBlock, - LargeCameraBlock, - LargeBlockGyro, - SmallBlockGyro, - SmallBlockSmallGenerator, - SmallBlockLargeGenerator, - LargeBlockSmallGenerator, - LargeBlockLargeGenerator, - LargePistonBase, - LargePistonTop, - SmallPistonBase, - SmallPistonTop, - LargeStator, - Suspension3x3, - Suspension5x5, - Suspension1x1, - SmallSuspension3x3, - SmallSuspension5x5, - SmallSuspension1x1, - Suspension3x3mirrored, - Suspension5x5mirrored, - Suspension1x1mirrored, - SmallSuspension3x3mirrored, - SmallSuspension5x5mirrored, - SmallSuspension1x1mirrored, - LargeRotor, - SmallStator, - SmallRotor, - LargeAdvancedStator, - LargeAdvancedRotor, - SmallAdvancedStator, - SmallAdvancedRotor, - ButtonPanelLarge, - ButtonPanelSmall, - TimerBlockLarge, - TimerBlockSmall, - LargeRailStraight, - LargeBlockSolarPanel, - SmallBlockSolarPanel, - LargeBlockOxygenFarm, - Window1x2Slope, - Window1x2Inv, - Window1x2Face, - Window1x2SideLeft, - Window1x2SideLeftInv, - Window1x2SideRight, - Window1x2SideRightInv, - Window1x1Slope, - Window1x1Face, - Window1x1Side, - Window1x1SideInv, - Window1x1Inv, - Window1x2Flat, - Window1x2FlatInv, - Window1x1Flat, - Window1x1FlatInv, - Window3x3Flat, - Window3x3FlatInv, - Window2x3Flat, - Window2x3FlatInv, - SmallBlockConveyor, - LargeBlockConveyor, - Collector, - CollectorSmall, - Connector, - ConnectorSmall, - ConnectorMedium, - ConveyorTube, - ConveyorTubeSmall, - ConveyorTubeMedium, - ConveyorFrameMedium, - ConveyorTubeCurved, - ConveyorTubeSmallCurved, - ConveyorTubeCurvedMedium, - SmallShipConveyorHub, - LargeBlockConveyorSorter, - MediumBlockConveyorSorter, - SmallBlockConveyorSorter, - VirtualMassLarge, - VirtualMassSmall, - SpaceBallLarge, - SpaceBallSmall, - SmallRealWheel1x1, - SmallRealWheel, - SmallRealWheel5x5, - RealWheel1x1, - RealWheel, - RealWheel5x5, - SmallRealWheel1x1mirrored, - SmallRealWheelmirrored, - SmallRealWheel5x5mirrored, - RealWheel1x1mirrored, - RealWheelmirrored, - RealWheel5x5mirrored, - Wheel1x1, - SmallWheel1x1, - Wheel3x3, - SmallWheel3x3, - Wheel5x5, - SmallWheel5x5, - LargeShipGrinder, - SmallShipGrinder, - LargeShipWelder, - SmallShipWelder, - LargeShipMergeBlock, - SmallShipMergeBlock, - ArmorAlpha, - ArmorCenter, - LargeProgrammableBlock, - ArmorCorner, - ArmorInvCorner, - ArmorSide, - SmallArmorCenter, - SmallArmorCorner, - SmallArmorInvCorner, - SmallArmorSide, - LargeBlockLaserAntenna, - SmallBlockLaserAntenna, - LargeBlockSlideDoor, - LgParachute, - SmParachute, - DebugSphereLarge, - }; -} \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.tt b/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.tt deleted file mode 100644 index b2be6c5d..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/SubtypeId.tt +++ /dev/null @@ -1,95 +0,0 @@ -<#@ template debug="false" hostspecific="false" language="C#" #> -<#@ assembly name="System.Core" #> -<#@ assembly name="System.Xml" #> -<#@ assembly name="$(TargetDir)SEToolbox.exe" #> -<#@ assembly name="$(TargetDir)SpaceEngineers.ObjectBuilders.XmlSerializers.dll" #> -<#@ import namespace="System.Linq" #> -<#@ import namespace="System.Text" #> -<#@ import namespace="System.IO" #> -<#@ import namespace="System.Xml" #> -<#@ import namespace="System.Collections.Generic" #> -<#@ import namespace="SEToolbox.Support" #> -<#@ output extension=".cs" #> -namespace SEToolbox.Interop -{ - /// - /// Generated by Text Templating on Game Engine data file 'CubeBlocks.sbc'. - /// - public enum SubtypeId - { - Empty = 0, - - // Although not enumerated in the Space Engineers API, I'm autogenerating enumerations - // direct from the game source here to make sure we have strongly typed names when generating content, - // rather than relying upon hardcoded 'strings' which required maintenance. - // When checking content read from 'world' saves however, we will have to rely upon the game data. - -<# - - // Open the file @"C:\Program Files (x86)\Steam\SteamApps\common\SpaceEngineers\Content\Data\CubeBlocks.sbc"; - string appPath = ToolboxUpdater.GetApplicationFilePath(); - if (appPath != null) - appPath = Path.Combine(appPath, ".."); - else - appPath = ToolboxUpdater.GetGameRegistryFilePath(); - if (appPath == null) - { - Write("#warning Could not generate enums, because Space Engineers is not installed on the Developer machine. \r\n\r\n"); - } - else - { - try - { - var filename = Path.Combine(appPath, @"Content\Data\CubeBlocks.sbc"); - - XmlDocument xDoc = new XmlDocument(); - xDoc.Load(filename); - - var nav = xDoc.CreateNavigator(); - - var list = new List(); - - var definitions = nav.Select("Definitions/CubeBlocks/Definition"); - while (definitions.MoveNext()) - { - var fullName = definitions.Current.SelectSingleNode("Id/SubtypeId").Value; - var name = fullName.Replace(" ", "_"); - var originalName = fullName != name ? fullName : ""; - - if (list.Contains(name)) - continue; - - if (definitions.Current.SelectSingleNode("Variants") != null) - { - Write(string.Format(" {0},\r\n", name)); - - var variants = definitions.Current.Select("Variants/Variant"); - while (variants.MoveNext()) - { - var variant = variants.Current.SelectSingleNode("@Color").Value; - Write(string.Format(" {0}{1},\r\n", name, variant)); - } - } - else - { - if (!string.IsNullOrEmpty(originalName)) - { - Write(string.Format(" {0}, // '{1}'\r\n", name, originalName)); - } - else if (!string.IsNullOrEmpty(name)) - { - Write(string.Format(" {0},\r\n", name)); - } - list.Add(name); - } - } - } - catch (Exception ex) - { - Write(string.Format("#warning An exception occured during transformation. {0}\r\n\r\n", ex.Message.Replace("\r\n", ""))); - } - } - -#> - }; -} \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/Interop/ToolboxPlatform.cs b/Dev/SEToolbox/SEToolbox/Interop/ToolboxPlatform.cs deleted file mode 100644 index 48feddf7..00000000 --- a/Dev/SEToolbox/SEToolbox/Interop/ToolboxPlatform.cs +++ /dev/null @@ -1,152 +0,0 @@ -using System; -using System.Collections.Generic; -using VRage; -using VRage.Input; -using VRage.Library.Exceptions; -using VRage.Utils; -using VRageMath; - -namespace SEToolbox.Interop -{ - public class ToolboxPlatform : VRage.IVRagePlatform - { - public float CPUCounter { get; set; } - - public float RAMCounter { get; set; } - - public string Clipboard { get; set; } - - public bool IsAllocationReady { get; set; } - - public IAnsel Ansel { get; set; } - - public IAfterMath AfterMath { get; set; } - - public IVRageInput Input { get; set; } - - public IVRageWindow Window { get; set; } - - public bool SessionReady { set; get; } - - public IMyAnalytics Analytics { get; set; } - - public IMyImeProcessor ImeProcessor - { - get - { - throw new NotImplementedException(); - } - } - - public void CreateToolWindow(IntPtr windowHandle) - { - - } - - public IVideoPlayer CreateVideoPlayer() - { - return null; - } - - public void CreateWindow(string gameName, string gameIcon, Type imeCandidateType) - { - - } - - public IntPtr FindWindowInParent(string parent, string child) - { - return IntPtr.Zero; - } - - public ulong GetGlobalAllocationsStamp() - { - return 0; - } - - public string GetInfoCPU(out uint frequency) - { - frequency = 0; - return null; - } - - public string GetOsName() - { - return null; - } - - public List GetProcessesLockingFile(string path) - { - return new List(); - } - - public ulong GetThreadAllocationStamp() - { - return 0; - } - - public ulong GetTotalPhysicalMemory() - { - return 0; - } - - public List GetVideoDriverDetails() - { - return new List(); - } - - public void HideSplashScreen() - { - } - - public void InitAnalytics(string projectId, string version) - { - } - - public void InitGameAnalytics(string projectId, string version) - { - throw new NotImplementedException(); - } - - public void InitializeInput(bool dummy, IMyControlNameLookup controlLookup, Dictionary defaultGameControls, bool enableDevKeys) - { - throw new NotImplementedException(); - } - - public void LogEnvironmentInformation() - { - } - - public MessageBoxResult MessageBox(string text, string caption, MessageBoxOptions options) - { - return MessageBoxResult.Cancel; - } - - public bool MessageBoxCrashForm(ref MyCrashScreenTexts texts, out string message, out string email) - { - message = null; - email = null; - return false; - } - - public void MessageBoxModCrashForm(ref MyModCrashScreenTexts texts) - { - } - - public void PostMessage(IntPtr handle, uint wm, IntPtr wParam, IntPtr lParam) - { - } - - public void ResetColdStartRegister() - { - } - - public void ShowSplashScreen(string image, Vector2 scale) - { - } - - public bool WriteMiniDump(string dumpPath, MyMiniDump.Options dumpFlags, MyMiniDump.ExceptionInfo info) - { - return false; - } - } -} diff --git a/Dev/SEToolbox/SEToolbox/Models/GenerateFloatingObjectModel.cs b/Dev/SEToolbox/SEToolbox/Models/GenerateFloatingObjectModel.cs deleted file mode 100644 index 81969efa..00000000 --- a/Dev/SEToolbox/SEToolbox/Models/GenerateFloatingObjectModel.cs +++ /dev/null @@ -1,418 +0,0 @@ -namespace SEToolbox.Models -{ - using System; - using System.Collections.Generic; - using System.Collections.ObjectModel; - using System.IO; - using System.Linq; - - using SEToolbox.Interop; - using SEToolbox.Support; - using VRage; - - public class GenerateFloatingObjectModel : BaseModel - { - public const int UniqueUnits = 1; - - #region Fields - - private MyPositionAndOrientation _characterPosition; - private ObservableCollection _stockItemList; - private ComponentItemModel _stockItem; - - private bool _isValidItemToImport; - - private double? _volume; - private double? _mass; - private int? _units; - private decimal? _decimalUnits; - private bool _isDecimal; - private bool _isInt; - private bool _isUnique; - private int _multiplier; - private float _maxFloatingObjects; - - #endregion - - #region ctor - - public GenerateFloatingObjectModel() - { - _stockItemList = new ObservableCollection(); - Multiplier = 1; - } - - #endregion - - #region Properties - - public MyPositionAndOrientation CharacterPosition - { - get - { - return _characterPosition; - } - - set - { - //if (value != characterPosition) // Unable to check for equivilence, without long statement. And, mostly uncessary. - _characterPosition = value; - OnPropertyChanged(nameof(CharacterPosition)); - } - } - - public ObservableCollection StockItemList - { - get - { - return _stockItemList; - } - - set - { - if (value != _stockItemList) - { - _stockItemList = value; - OnPropertyChanged(nameof(StockItemList)); - } - } - } - - public ComponentItemModel StockItem - { - get - { - return _stockItem; - } - - set - { - if (value != _stockItem) - { - _stockItem = value; - OnPropertyChanged(nameof(StockItem)); - SetMassVolume(); - } - } - } - - public bool IsValidItemToImport - { - get - { - return _isValidItemToImport; - } - - set - { - if (value != _isValidItemToImport) - { - _isValidItemToImport = value; - OnPropertyChanged(nameof(IsValidItemToImport)); - } - } - } - - public double? Volume - { - get - { - return _volume; - } - - set - { - if (value != _volume) - { - _volume = value; - OnPropertyChanged(nameof(Volume)); - } - } - } - - public double? Mass - { - get - { - return _mass; - } - - set - { - if (value != _mass) - { - _mass = value; - OnPropertyChanged(nameof(Mass)); - } - } - } - - public int? Units - { - get - { - return _units; - } - - set - { - if (value != _units) - { - _units = value; - OnPropertyChanged(nameof(Units)); - SetMassVolume(); - } - } - } - - public decimal? DecimalUnits - { - get - { - return _decimalUnits; - } - - set - { - if (value != _decimalUnits) - { - _decimalUnits = value; - OnPropertyChanged(nameof(DecimalUnits)); - SetMassVolume(); - } - } - } - - public bool IsDecimal - { - get - { - return _isDecimal; - } - - set - { - if (value != _isDecimal) - { - _isDecimal = value; - OnPropertyChanged(nameof(IsDecimal)); - } - } - } - - public bool IsInt - { - get - { - return _isInt; - } - - set - { - if (value != _isInt) - { - _isInt = value; - OnPropertyChanged(nameof(IsInt)); - } - } - } - - public bool IsUnique - { - get - { - return _isUnique; - } - - set - { - if (value != _isUnique) - { - _isUnique = value; - OnPropertyChanged(nameof(IsUnique)); - } - } - } - - /// - /// Generates this many individual items. - /// - public int Multiplier - { - get - { - return _multiplier; - } - - set - { - if (value != _multiplier) - { - _multiplier = value; - OnPropertyChanged(nameof(Multiplier)); - } - } - } - - /// - /// The maximum number of floating objects as defined in the World. - /// - public float MaxFloatingObjects - { - get - { - return _maxFloatingObjects; - } - - set - { - if (value != _maxFloatingObjects) - { - _maxFloatingObjects = value; - OnPropertyChanged(nameof(MaxFloatingObjects)); - } - } - } - - #endregion - - #region methods - - public void Load(MyPositionAndOrientation characterPosition, float maxFloatingObjects) - { - MaxFloatingObjects = maxFloatingObjects; - CharacterPosition = characterPosition; - StockItemList.Clear(); - var list = new List(); - var contentPath = ToolboxUpdater.GetApplicationContentPath(); - - foreach (var componentDefinition in SpaceEngineersCore.Resources.ComponentDefinitions) - { - var bp = SpaceEngineersApi.GetBlueprint(componentDefinition.Id.TypeId, componentDefinition.Id.SubtypeName); - list.Add(new ComponentItemModel - { - Name = componentDefinition.DisplayNameText, - TypeId = componentDefinition.Id.TypeId, - SubtypeId = componentDefinition.Id.SubtypeName, - Mass = componentDefinition.Mass, - TextureFile = componentDefinition.Icons == null ? null : SpaceEngineersCore.GetDataPathOrDefault(componentDefinition.Icons.First(), Path.Combine(contentPath, componentDefinition.Icons.First())), - Volume = componentDefinition.Volume * SpaceEngineersConsts.VolumeMultiplyer, - Accessible = componentDefinition.Public, - Time = bp != null ? TimeSpan.FromSeconds(bp.BaseProductionTimeInSeconds) : (TimeSpan?)null, - }); - } - - foreach (var physicalItemDefinition in SpaceEngineersCore.Resources.PhysicalItemDefinitions) - { - if (physicalItemDefinition.Id.SubtypeName == "CubePlacerItem" || physicalItemDefinition.Id.SubtypeName == "WallPlacerItem") - continue; - - var bp = SpaceEngineersApi.GetBlueprint(physicalItemDefinition.Id.TypeId, physicalItemDefinition.Id.SubtypeName); - list.Add(new ComponentItemModel - { - Name = physicalItemDefinition.DisplayNameText, - TypeId = physicalItemDefinition.Id.TypeId, - SubtypeId = physicalItemDefinition.Id.SubtypeName, - Mass = physicalItemDefinition.Mass, - Volume = physicalItemDefinition.Volume * SpaceEngineersConsts.VolumeMultiplyer, - TextureFile = physicalItemDefinition.Icons == null ? null : SpaceEngineersCore.GetDataPathOrDefault(physicalItemDefinition.Icons.First(), Path.Combine(contentPath, physicalItemDefinition.Icons.First())), - Accessible = physicalItemDefinition.Public, - Time = bp != null ? TimeSpan.FromSeconds(bp.BaseProductionTimeInSeconds) : (TimeSpan?)null, - }); - } - - foreach (var item in list.OrderBy(i => i.FriendlyName)) - { - StockItemList.Add(item); - } - - //list.Clear(); - - //foreach (var cubeDefinition in SpaceEngineersAPI.CubeBlockDefinitions) - //{ - // list.Add(new ComponentItemModel - // { - // Name = cubeDefinition.DisplayName, - // TypeId = cubeDefinition.Id.TypeId, - // SubtypeId = cubeDefinition.Id.SubtypeName, - // CubeSize = cubeDefinition.CubeSize, - // TextureFile = cubeDefinition.Icon == null ? null : Path.Combine(contentPath, cubeDefinition.Icon), - // Accessible = !string.IsNullOrEmpty(cubeDefinition.Model), - // }); - //} - - //foreach (var item in list.OrderBy(i => i.FriendlyName)) - //{ - // StockItemList.Add(item); - //} - } - - private void SetMassVolume() - { - if (StockItem == null) - { - Mass = null; - Volume = null; - } - else - { - if (StockItem.TypeId == SpaceEngineersTypes.Ore || - StockItem.TypeId == SpaceEngineersTypes.Ingot) - { - IsDecimal = true; - IsUnique = IsInt = false; - if (DecimalUnits.HasValue) - { - Mass = (double)DecimalUnits * StockItem.Mass; - Volume = (double)DecimalUnits * StockItem.Volume; - } - else - { - Mass = null; - Volume = null; - } - } - else if (StockItem.TypeId == SpaceEngineersTypes.Component || - StockItem.TypeId == SpaceEngineersTypes.AmmoMagazine) - { - IsInt = true; - IsUnique = IsDecimal = false; - if (Units.HasValue) - { - Mass = Units.Value * StockItem.Mass; - Volume = Units.Value * StockItem.Volume; - } - else - { - Mass = null; - Volume = null; - } - } - else if (StockItem.TypeId == SpaceEngineersTypes.PhysicalGunObject) - { - IsUnique = true; - IsInt = IsDecimal = false; - Mass = UniqueUnits * StockItem.Mass; - Volume = UniqueUnits * StockItem.Volume; - } - else if (StockItem.TypeId == SpaceEngineersTypes.OxygenContainerObject) - { - IsUnique = true; - IsInt = IsDecimal = false; - Mass = UniqueUnits * StockItem.Mass; - Volume = UniqueUnits * StockItem.Volume; - } - else - { - // Assume any new objects are whole objects that cannot be stacked (for safety). - IsUnique = true; - IsInt = IsDecimal = false; - Mass = UniqueUnits * StockItem.Mass; - Volume = UniqueUnits * StockItem.Volume; - } - } - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Models/Import3DAsteroidModel.cs b/Dev/SEToolbox/SEToolbox/Models/Import3DAsteroidModel.cs deleted file mode 100644 index 14542f5d..00000000 --- a/Dev/SEToolbox/SEToolbox/Models/Import3DAsteroidModel.cs +++ /dev/null @@ -1,553 +0,0 @@ -namespace SEToolbox.Models -{ - using System.Collections.ObjectModel; - using System.Windows.Media.Media3D; - using SEToolbox.Interop; - using SEToolbox.Interop.Asteroids; - using VRage; - - public class Import3DAsteroidModel : BaseModel - { - #region Fields - - private string _filename; - private Model3D _model; - private bool _isValidModel; - private bool _isValidEntity; - - private BindableSize3DModel _originalModelSize; - private BindableSize3DIModel _newModelSize; - private BindablePoint3DModel _newModelScale; - private BindablePoint3DModel _position; - private BindableVector3DModel _forward; - private BindableVector3DModel _up; - private MyPositionAndOrientation _characterPosition; - private TraceType _traceType; - private TraceCount _traceCount; - private TraceDirection _traceDirection; - private double _multipleScale; - private double _maxLengthScale; - private double _buildDistance; - private bool _isMultipleScale; - private bool _isMaxLengthScale; - private bool _isAbsolutePosition; - private bool _isInfrontofPlayer; - private readonly ObservableCollection _outsideMaterialsCollection; - private readonly ObservableCollection _insideMaterialsCollection; - private MaterialSelectionModel _outsideStockMaterial; - private MaterialSelectionModel _insideStockMaterial; - private int _outsideMaterialDepth; - private string _sourceFile; - private double _rotateYaw; - private double _rotatePitch; - private double _rotateRoll; - private bool _beepWhenFinished; - private bool _saveWhenFinsihed; - private bool _shutdownWhenFinished; - private bool _runInLowPrioity; - // TODO: pause - - #endregion - - #region ctor - - public Import3DAsteroidModel() - { - _outsideMaterialsCollection = new ObservableCollection(); - _insideMaterialsCollection = new ObservableCollection(); - - foreach (var material in SpaceEngineersCore.Resources.VoxelMaterialDefinitions) - { - _outsideMaterialsCollection.Add(new MaterialSelectionModel { Value = material.Id.SubtypeName, DisplayName = material.Id.SubtypeName }); - _insideMaterialsCollection.Add(new MaterialSelectionModel { Value = material.Id.SubtypeName, DisplayName = material.Id.SubtypeName }); - } - - InsideStockMaterial = InsideMaterialsCollection[0]; - OutsideStockMaterial = OutsideMaterialsCollection[0]; - - TraceType = TraceType.Odd; - TraceCount = TraceCount.Trace5; - TraceDirection = TraceDirection.X; - - BeepWhenFinished = true; - RunInLowPrioity = true; - } - - #endregion - - #region Properties - - public string Filename - { - get { return _filename; } - - set - { - if (value != _filename) - { - _filename = value; - OnPropertyChanged(nameof(Filename)); - } - } - } - - public Model3D Model - { - get { return _model; } - - set - { - if (value != _model) - { - _model = value; - OnPropertyChanged(nameof(Model)); - } - } - } - - /// - /// Indicates if the selected model file the user has specified is a valid model. - /// - public bool IsValidModel - { - get { return _isValidModel; } - - set - { - if (value != _isValidModel) - { - _isValidModel = value; - OnPropertyChanged(nameof(IsValidModel)); - } - } - } - - /// - /// Indicates if the Entity created at the end of processing is valid. - /// - public bool IsValidEntity - { - get { return _isValidEntity; } - - set - { - if (value != _isValidEntity) - { - _isValidEntity = value; - OnPropertyChanged(nameof(IsValidEntity)); - } - } - } - - public BindableSize3DModel OriginalModelSize - { - get { return _originalModelSize; } - - set - { - if (value != _originalModelSize) - { - _originalModelSize = value; - OnPropertyChanged(nameof(OriginalModelSize)); - } - } - } - - public BindableSize3DIModel NewModelSize - { - get { return _newModelSize; } - - set - { - if (value != _newModelSize) - { - _newModelSize = value; - OnPropertyChanged(nameof(NewModelSize)); - } - } - } - - public BindablePoint3DModel NewModelScale - { - get { return _newModelScale; } - - set - { - if (value != _newModelScale) - { - _newModelScale = value; - OnPropertyChanged(nameof(NewModelScale)); - } - } - } - - public BindablePoint3DModel Position - { - get { return _position; } - - set - { - if (value != _position) - { - _position = value; - OnPropertyChanged(nameof(Position)); - } - } - } - - public BindableVector3DModel Forward - { - get { return _forward; } - - set - { - if (value != _forward) - { - _forward = value; - OnPropertyChanged(nameof(Forward)); - } - } - } - - public BindableVector3DModel Up - { - get { return _up; } - - set - { - if (value != _up) - { - _up = value; - OnPropertyChanged(nameof(Up)); - } - } - } - - public MyPositionAndOrientation CharacterPosition - { - get { return _characterPosition; } - - set - { - //if (value != characterPosition) // Unable to check for equivilence, without long statement. And, mostly uncessary. - _characterPosition = value; - OnPropertyChanged(nameof(CharacterPosition)); - } - } - - public TraceType TraceType - { - get { return _traceType; } - - set - { - if (value != _traceType) - { - _traceType = value; - OnPropertyChanged(nameof(TraceType)); - } - } - } - - public TraceCount TraceCount - { - get { return _traceCount; } - - set - { - if (value != _traceCount) - { - _traceCount = value; - OnPropertyChanged(nameof(TraceCount)); - } - } - } - - public TraceDirection TraceDirection - { - get { return _traceDirection; } - - set - { - if (value != _traceDirection) - { - _traceDirection = value; - OnPropertyChanged(nameof(TraceDirection)); - } - } - } - - public double MultipleScale - { - get { return _multipleScale; } - - set - { - if (value != _multipleScale) - { - _multipleScale = value; - OnPropertyChanged(nameof(MultipleScale)); - } - } - } - - public double MaxLengthScale - { - get { return _maxLengthScale; } - - set - { - if (value != _maxLengthScale) - { - _maxLengthScale = value; - OnPropertyChanged(nameof(MaxLengthScale)); - } - } - } - - public double BuildDistance - { - get { return _buildDistance; } - - set - { - if (value != _buildDistance) - { - _buildDistance = value; - OnPropertyChanged(nameof(BuildDistance)); - } - } - } - - public bool IsMultipleScale - { - get { return _isMultipleScale; } - - set - { - if (value != _isMultipleScale) - { - _isMultipleScale = value; - OnPropertyChanged(nameof(IsMultipleScale)); - } - } - } - - public bool IsMaxLengthScale - { - get { return _isMaxLengthScale; } - - set - { - if (value != _isMaxLengthScale) - { - _isMaxLengthScale = value; - OnPropertyChanged(nameof(IsMaxLengthScale)); - } - } - } - - public bool IsAbsolutePosition - { - get { return _isAbsolutePosition; } - - set - { - if (value != _isAbsolutePosition) - { - _isAbsolutePosition = value; - OnPropertyChanged(nameof(IsAbsolutePosition)); - } - } - } - - public bool IsInfrontofPlayer - { - get { return _isInfrontofPlayer; } - - set - { - if (value != _isInfrontofPlayer) - { - _isInfrontofPlayer = value; - OnPropertyChanged(nameof(IsInfrontofPlayer)); - } - } - } - - public ObservableCollection OutsideMaterialsCollection - { - get { return _outsideMaterialsCollection; } - } - - public int OutsideMaterialDepth - { - get { return _outsideMaterialDepth; } - - set - { - if (value != _outsideMaterialDepth) - { - _outsideMaterialDepth = value; - OnPropertyChanged(nameof(OutsideMaterialDepth)); - } - } - } - - public ObservableCollection InsideMaterialsCollection - { - get { return _insideMaterialsCollection; } - } - - public MaterialSelectionModel OutsideStockMaterial - { - get { return _outsideStockMaterial; } - - set - { - if (value != _outsideStockMaterial) - { - _outsideStockMaterial = value; - OnPropertyChanged(nameof(OutsideStockMaterial)); - } - } - } - - public MaterialSelectionModel InsideStockMaterial - { - get { return _insideStockMaterial; } - - set - { - if (value != _insideStockMaterial) - { - _insideStockMaterial = value; - OnPropertyChanged(nameof(InsideStockMaterial)); - } - } - } - - public string SourceFile - { - get { return _sourceFile; } - - set - { - if (value != _sourceFile) - { - _sourceFile = value; - OnPropertyChanged(nameof(SourceFile)); - } - } - } - - public double RotateYaw - { - get { return _rotateYaw; } - - set - { - if (value != _rotateYaw) - { - _rotateYaw = value; - OnPropertyChanged(nameof(RotateYaw)); - } - } - } - - public double RotatePitch - { - get { return _rotatePitch; } - - set - { - if (value != _rotatePitch) - { - _rotatePitch = value; - OnPropertyChanged(nameof(RotatePitch)); - } - } - } - - public double RotateRoll - { - get { return _rotateRoll; } - - set - { - if (value != _rotateRoll) - { - _rotateRoll = value; - OnPropertyChanged(nameof(RotateRoll)); - } - } - } - - public bool BeepWhenFinished - { - get { return _beepWhenFinished; } - - set - { - if (value != _beepWhenFinished) - { - _beepWhenFinished = value; - OnPropertyChanged(nameof(BeepWhenFinished)); - } - } - } - - public bool SaveWhenFinsihed - { - get { return _saveWhenFinsihed; } - - set - { - if (value != _saveWhenFinsihed) - { - _saveWhenFinsihed = value; - OnPropertyChanged(nameof(SaveWhenFinsihed)); - } - } - } - - public bool ShutdownWhenFinished - { - get { return _shutdownWhenFinished; } - - set - { - if (value != _shutdownWhenFinished) - { - _shutdownWhenFinished = value; - OnPropertyChanged(nameof(ShutdownWhenFinished)); - } - } - } - - public bool RunInLowPrioity - { - get { return _runInLowPrioity; } - - set - { - if (value != _runInLowPrioity) - { - _runInLowPrioity = value; - OnPropertyChanged(nameof(RunInLowPrioity)); - } - } - } - - #endregion - - #region methods - - public void Load(MyPositionAndOrientation characterPosition) - { - CharacterPosition = characterPosition; - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Models/StructureVoxelModel.cs b/Dev/SEToolbox/SEToolbox/Models/StructureVoxelModel.cs deleted file mode 100644 index 0980bda1..00000000 --- a/Dev/SEToolbox/SEToolbox/Models/StructureVoxelModel.cs +++ /dev/null @@ -1,569 +0,0 @@ -namespace SEToolbox.Models -{ - using Interfaces; - using SEToolbox.Interop; - using SEToolbox.Interop.Asteroids; - using SEToolbox.Support; - using System; - using System.Collections.Generic; - using System.ComponentModel; - using System.IO; - using System.Linq; - using System.Runtime.Serialization; - using System.Xml.Serialization; - using VRage.Game; - using VRage.ObjectBuilders; - using VRage.Voxels; - using VRageMath; - using Res = SEToolbox.Properties.Resources; - - [Serializable] - public class StructureVoxelModel : StructureBaseModel - { - #region fields - - private string _sourceVoxelFilepath; - private string _voxelFilepath; - private Vector3I _size; - private BoundingBoxI _contentBounds; - private BoundingBoxI _inflatedContentBounds; - private long _voxCells; - - [NonSerialized] - private BackgroundWorker _asyncWorker; - - [NonSerialized] - private MyVoxelMap _voxelMap; - - [NonSerialized] - private VoxelMaterialAssetModel _selectedMaterialAsset; - - [NonSerialized] - private List _materialAssets; - - [NonSerialized] - private List _gameMaterialList; - - [NonSerialized] - private List _editMaterialList; - - [NonSerialized] - private bool _isLoadingAsync; - - #endregion - - #region ctor - - public StructureVoxelModel(MyObjectBuilder_EntityBase entityBase, string voxelPath) - : base(entityBase) - { - var contentPath = ToolboxUpdater.GetApplicationContentPath(); - - if (voxelPath != null) - { - VoxelFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V2FileExtension); - var previewFile = VoxelFilepath; - - if (!File.Exists(VoxelFilepath)) - { - var oldFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V1FileExtension); - if (File.Exists(oldFilepath)) - { - SourceVoxelFilepath = oldFilepath; - previewFile = oldFilepath; - SpaceEngineersCore.ManageDeleteVoxelList.Add(oldFilepath); - } - } - - ReadVoxelDetails(previewFile); - } - - var materialList = new Dictionary(); - foreach (MyVoxelMaterialDefinition item in SpaceEngineersCore.Resources.VoxelMaterialDefinitions.OrderBy(m => m.Id.SubtypeName)) - { - string texture = item.GetVoxelDisplayTexture(); - materialList.Add(item.Id.SubtypeName, texture == null ? null : SpaceEngineersCore.GetDataPathOrDefault(texture, Path.Combine(contentPath, texture))); - } - - GameMaterialList = new List(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value })); - EditMaterialList = new List { new VoxelMaterialAssetModel { MaterialName = null, DisplayName = Res.CtlVoxelMnuRemoveMaterial } }; - EditMaterialList.AddRange(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value })); - } - - #endregion - - #region Properties - - [XmlIgnore] - public MyObjectBuilder_VoxelMap VoxelMap - { - get { return EntityBase as MyObjectBuilder_VoxelMap; } - } - - [XmlIgnore] - public string Name - { - get { return VoxelMap.StorageName; } - - set - { - if (value != VoxelMap.StorageName) - { - VoxelMap.StorageName = value; - OnPropertyChanged(nameof(Name)); - } - } - } - - /// - /// This is the location of the temporary source file for importing/generating a Voxel file. - /// - public string SourceVoxelFilepath - { - get { return _sourceVoxelFilepath; } - - set - { - if (value != _sourceVoxelFilepath) - { - _sourceVoxelFilepath = value; - OnPropertyChanged(nameof(SourceVoxelFilepath)); - ReadVoxelDetails(SourceVoxelFilepath); - } - } - } - - /// - /// This is the actual file/path for the Voxel file. It may not exist yet. - /// - public string VoxelFilepath - { - get { return _voxelFilepath; } - - set - { - if (value != _voxelFilepath) - { - _voxelFilepath = value; - OnPropertyChanged(nameof(VoxelFilepath)); - } - } - } - - [XmlIgnore] - public Vector3I Size - { - get { return _size; } - - set - { - if (value != _size) - { - _size = value; - OnPropertyChanged(nameof(Size)); - } - } - } - - [XmlIgnore] - public Vector3I ContentSize - { - get { return _contentBounds.Size + 1; } // Content size - } - - /// - /// Represents the Cell content, not the Cell boundary. - /// So Min and Max values are both inclusive. - /// - [XmlIgnore] - public BoundingBoxI ContentBounds - { - get { return _contentBounds; } - - set - { - if (value != _contentBounds) - { - _contentBounds = value; - OnPropertyChanged(nameof(ContentBounds)); - } - } - } - - [XmlIgnore] - public BoundingBoxI InflatedContentBounds => _inflatedContentBounds; - - [XmlIgnore] - public long VoxCells - { - get { return _voxCells; } - - set - { - if (value != _voxCells) - { - _voxCells = value; - OnPropertyChanged(nameof(VoxCells), nameof(Volume)); - } - } - } - - [XmlIgnore] - public double Volume - { - get { return (double)_voxCells / 255; } - } - - /// - /// This is detail of the breakdown of ores in the asteroid. - /// - [XmlIgnore] - public List MaterialAssets - { - get { return _materialAssets; } - - set - { - if (value != _materialAssets) - { - _materialAssets = value; - OnPropertyChanged(nameof(MaterialAssets)); - } - } - } - - [XmlIgnore] - public VoxelMaterialAssetModel SelectedMaterialAsset - { - get { return _selectedMaterialAsset; } - - set - { - if (value != _selectedMaterialAsset) - { - _selectedMaterialAsset = value; - OnPropertyChanged(nameof(SelectedMaterialAsset)); - } - } - } - - [XmlIgnore] - public List GameMaterialList - { - get { return _gameMaterialList; } - - set - { - if (value != _gameMaterialList) - { - _gameMaterialList = value; - OnPropertyChanged(nameof(GameMaterialList)); - } - } - } - - [XmlIgnore] - public List EditMaterialList - { - get { return _editMaterialList; } - - set - { - if (value != _editMaterialList) - { - _editMaterialList = value; - OnPropertyChanged(nameof(EditMaterialList)); - } - } - } - - #endregion - - #region methods - - [OnSerializing] - private void OnSerializingMethod(StreamingContext context) - { - SerializedEntity = SpaceEngineersApi.Serialize(VoxelMap); - } - - [OnDeserialized] - private void OnDeserializedMethod(StreamingContext context) - { - EntityBase = SpaceEngineersApi.Deserialize(SerializedEntity); - } - - public override void UpdateGeneralFromEntityBase() - { - ClassType = ClassType.Voxel; - DisplayName = Name; - } - - public override void InitializeAsync() - { - _asyncWorker = new BackgroundWorker { WorkerSupportsCancellation = true }; - _asyncWorker.DoWork += delegate - { - if (!_isLoadingAsync) - { - _isLoadingAsync = true; - - IsBusy = true; - LoadDetailsSync(); - IsBusy = false; - - _isLoadingAsync = false; - } - }; - _asyncWorker.RunWorkerCompleted += delegate - { - OnPropertyChanged(nameof(Size), nameof(ContentSize), nameof(ContentBounds), nameof(Center), nameof(VoxCells), nameof(Volume)); - }; - - _asyncWorker.RunWorkerAsync(); - } - - public void LoadDetailsSync() - { - if (_voxelMap != null && (MaterialAssets == null || MaterialAssets.Count == 0)) - { - Dictionary details = _voxelMap.RefreshAssets(); - _contentBounds = _voxelMap.BoundingContent; - _inflatedContentBounds = _voxelMap.InflatedBoundingContent; - _voxCells = _voxelMap.VoxCells; - Center = new Vector3D(_voxelMap.ContentCenter.X + 0.5f + PositionX, _voxelMap.ContentCenter.Y + 0.5f + PositionY, _voxelMap.ContentCenter.Z + 0.5f + PositionZ); - - var sum = details.Values.ToList().Sum(); - var list = new List(); - - foreach (var kvp in details) - list.Add(new VoxelMaterialAssetModel {MaterialName = kvp.Key, Volume = (double) kvp.Value/255, Percent = (double) kvp.Value/(double) sum}); - - MaterialAssets = list; - } - } - - public override void CancelAsync() - { - if (_asyncWorker != null && _asyncWorker.IsBusy && _asyncWorker.WorkerSupportsCancellation) - { - _asyncWorker.CancelAsync(); - } - } - - private void ReadVoxelDetails(string filename) - { - if (_voxelMap == null && filename != null && File.Exists(filename)) - { - _voxelMap = new MyVoxelMap(); - _voxelMap.Load(filename); - - Size = _voxelMap.Size; - ContentBounds = _voxelMap.BoundingContent; - IsValid = _voxelMap.IsValid; - - OnPropertyChanged(nameof(Size), nameof(ContentSize), nameof(IsValid)); - Center = new Vector3D(_voxelMap.ContentCenter.X + 0.5f + PositionX, _voxelMap.ContentCenter.Y + 0.5f + PositionY, _voxelMap.ContentCenter.Z + 0.5f + PositionZ); - WorldAABB = new BoundingBoxD(PositionAndOrientation.Value.Position, PositionAndOrientation.Value.Position + new Vector3D(Size)); - } - } - - public override void RecalcPosition(Vector3D playerPosition) - { - base.RecalcPosition(playerPosition); - if (IsValid) - { - Center = new Vector3D(_voxelMap.ContentCenter.X + 0.5f + PositionX, _voxelMap.ContentCenter.Y + 0.5f + PositionY, _voxelMap.ContentCenter.Z + 0.5f + PositionZ); - WorldAABB = new BoundingBoxD(PositionAndOrientation.Value.Position, PositionAndOrientation.Value.Position + new Vector3D(Size)); - } - } - - public void UpdateNewSource(MyVoxelMap newMap, string fileName) - { - if (_voxelMap != null) - _voxelMap.Dispose(); - _voxelMap = newMap; - SourceVoxelFilepath = fileName; - - Size = _voxelMap.Size; - ContentBounds = _voxelMap.BoundingContent; - IsValid = _voxelMap.IsValid; - - OnPropertyChanged(nameof(Size), nameof(ContentSize), nameof(IsValid)); - Center = new Vector3D(_voxelMap.ContentCenter.X + 0.5f + PositionX, _voxelMap.ContentCenter.Y + 0.5f + PositionY, _voxelMap.ContentCenter.Z + 0.5f + PositionZ); - WorldAABB = new BoundingBoxD(PositionAndOrientation.Value.Position, PositionAndOrientation.Value.Position + new Vector3D(Size)); - } - - public void RotateAsteroid(Quaternion quaternion) - { - var sourceFile = SourceVoxelFilepath ?? VoxelFilepath; - - var asteroid = new MyVoxelMap(); - asteroid.Load(sourceFile); - - var newAsteroid = new MyVoxelMap(); - var newSize = asteroid.Size; - newAsteroid.Create(newSize, SpaceEngineersCore.Resources.GetDefaultMaterialIndex()); - - Vector3I block; - var halfSize = asteroid.Storage.Size / 2; - - // Don't use anything smaller than 64 for smaller voxels, as it trashes the cache. - var cacheSize = new Vector3I(64); - var halfCacheSize = new Vector3I(32); // This should only be used for the Transform, not the cache. - - // read the asteroid in chunks of 64 to avoid the Arithmetic overflow issue. - for (block.Z = 0; block.Z < asteroid.Storage.Size.Z; block.Z += 64) - for (block.Y = 0; block.Y < asteroid.Storage.Size.Y; block.Y += 64) - for (block.X = 0; block.X < asteroid.Storage.Size.X; block.X += 64) - { - #region source voxel - - var cache = new MyStorageData(); - cache.Resize(cacheSize); - // LOD1 is not detailed enough for content information on asteroids. - asteroid.Storage.ReadRange(cache, MyStorageDataTypeFlags.ContentAndMaterial, 0, block, block + cacheSize - 1); - - #endregion - - #region target Voxel - - // the block is a cubiod. The entire space needs to rotate, to be able to gauge where the new block position starts from. - var newBlockMin = Vector3I.Transform(block - halfSize, quaternion) + halfSize; - var newBlockMax = Vector3I.Transform(block + 64 - halfSize, quaternion) + halfSize; - var newBlock = Vector3I.Min(newBlockMin, newBlockMax); - - var newCache = new MyStorageData(); - newCache.Resize(cacheSize); - newAsteroid.Storage.ReadRange(newCache, MyStorageDataTypeFlags.ContentAndMaterial, 0, newBlock, newBlock + cacheSize - 1); - - #endregion - - bool changed = false; - Vector3I p; - for (p.Z = 0; p.Z < cacheSize.Z; ++p.Z) - for (p.Y = 0; p.Y < cacheSize.Y; ++p.Y) - for (p.X = 0; p.X < cacheSize.X; ++p.X) - { - byte volume = cache.Content(ref p); - byte cellMaterial = cache.Material(ref p); - - var newP1 = Vector3I.Transform(p - halfCacheSize, quaternion) + halfCacheSize; - var newP2 = Vector3I.Transform(p + 1 - halfCacheSize, quaternion) + halfCacheSize; - var newP = Vector3I.Min(newP1, newP2); - - newCache.Content(ref newP, volume); - newCache.Material(ref newP, cellMaterial); - changed = true; - } - - if (changed) - newAsteroid.Storage.WriteRange(newCache, MyStorageDataTypeFlags.ContentAndMaterial, newBlock, newBlock + cacheSize - 1); - } - - - var tempfilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension); - newAsteroid.Save(tempfilename); - - SourceVoxelFilepath = tempfilename; - } - - public bool ExtractStationIntersect(IMainView mainViewModel, bool tightIntersection) - { - // Make a shortlist of station Entities in the bounding box of the asteroid. - var asteroidWorldAABB = new BoundingBoxD((Vector3D)ContentBounds.Min + PositionAndOrientation.Value.Position, (Vector3D)ContentBounds.Max + PositionAndOrientation.Value.Position); - var stations = mainViewModel.GetIntersectingEntities(asteroidWorldAABB).Where(e => e.ClassType == ClassType.LargeStation).Cast().ToList(); - - if (stations.Count == 0) - return false; - - var modified = false; - var sourceFile = SourceVoxelFilepath ?? VoxelFilepath; - var asteroid = new MyVoxelMap(); - asteroid.Load(sourceFile); - - var total = stations.Sum(s => s.CubeGrid.CubeBlocks.Count); - mainViewModel.ResetProgress(0, total); - - // Search through station entities cubes for intersection with this voxel. - foreach (var station in stations) - { - var quaternion = station.PositionAndOrientation.Value.ToQuaternion(); - - foreach (var cube in station.CubeGrid.CubeBlocks) - { - mainViewModel.IncrementProgress(); - - var definition = SpaceEngineersApi.GetCubeDefinition(cube.TypeId, station.CubeGrid.GridSizeEnum, cube.SubtypeName); - - var orientSize = definition.Size.Transform(cube.BlockOrientation).Abs(); - var min = cube.Min.ToVector3() * station.CubeGrid.GridSizeEnum.ToLength(); - var max = (cube.Min + orientSize) * station.CubeGrid.GridSizeEnum.ToLength(); - var p1 = Vector3D.Transform(min, quaternion) + station.PositionAndOrientation.Value.Position - (station.CubeGrid.GridSizeEnum.ToLength() / 2); - var p2 = Vector3D.Transform(max, quaternion) + station.PositionAndOrientation.Value.Position - (station.CubeGrid.GridSizeEnum.ToLength() / 2); - var cubeWorldAABB = new BoundingBoxD(Vector3.Min(p1, p2), Vector3.Max(p1, p2)); - - // find worldAABB of block. - if (asteroidWorldAABB.Intersects(cubeWorldAABB)) - { - Vector3I block; - var cacheSize = new Vector3I(64); - Vector3D position = PositionAndOrientation.Value.Position; - - // read the asteroid in chunks of 64 to avoid the Arithmetic overflow issue. - for (block.Z = 0; block.Z < asteroid.Storage.Size.Z; block.Z += 64) - for (block.Y = 0; block.Y < asteroid.Storage.Size.Y; block.Y += 64) - for (block.X = 0; block.X < asteroid.Storage.Size.X; block.X += 64) - { - var cache = new MyStorageData(); - cache.Resize(cacheSize); - // LOD1 is not detailed enough for content information on asteroids. - Vector3I maxRange = block + cacheSize - 1; - asteroid.Storage.ReadRange(cache, MyStorageDataTypeFlags.Content, 0, block, maxRange); - - bool changed = false; - Vector3I p; - for (p.Z = 0; p.Z < cacheSize.Z; ++p.Z) - for (p.Y = 0; p.Y < cacheSize.Y; ++p.Y) - for (p.X = 0; p.X < cacheSize.X; ++p.X) - { - BoundingBoxD voxelCellBox = new BoundingBoxD(position + p + block, position + p + block + 1); - ContainmentType contains = cubeWorldAABB.Contains(voxelCellBox); - - // TODO: finish tightIntersection. Will require high interpretation of voxel content volumes. - - if (contains == ContainmentType.Contains || contains == ContainmentType.Intersects) - { - cache.Content(ref p, 0); - changed = true; - } - } - - if (changed) - { - asteroid.Storage.WriteRange(cache, MyStorageDataTypeFlags.Content, block, maxRange); - modified = true; - } - } - - } - } - } - - mainViewModel.ClearProgress(); - - if (modified) - { - var tempfilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension); - asteroid.Save(tempfilename); - // replaces the existing asteroid file, as it is still the same size and dimentions. - UpdateNewSource(asteroid, tempfilename); - MaterialAssets = null; - InitializeAsync(); - } - return modified; - } - - #endregion - } -} diff --git a/Dev/SEToolbox/SEToolbox/Properties/AssemblyInfo.cs b/Dev/SEToolbox/SEToolbox/Properties/AssemblyInfo.cs deleted file mode 100644 index 93f53a1b..00000000 --- a/Dev/SEToolbox/SEToolbox/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; -using System.Runtime.InteropServices; -using System.Windows; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("SEToolbox")] -[assembly: AssemblyDescription("Space Engineers Toolbox")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Mid-Space Productions")] -[assembly: AssemblyProduct("SEToolbox")] -[assembly: AssemblyCopyright("Copyright © MidSpace 2013-2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -//In order to begin building localizable applications, set -//CultureYouAreCodingWith in your .csproj file -//inside a . For example, if you are using US english -//in your source files, set the to en-US. Then uncomment -//the NeutralResourceLanguage attribute below. Update the "en-US" in -//the line below to match the UICulture setting in the project file. - -//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] - - -[assembly: ThemeInfo( - ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) - ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) -)] - - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] - -// First 3 numbers to match the current Space Engineers release. -// http://forums.keenswh.com/post/about-change-log-6578819 -// Forth number to indicate my own build of SEToolbox to match. Remember to reset it back to 1 every time there is a new release of SpaceEngineers. -[assembly: AssemblyFileVersion("01.191.20.3")] - diff --git a/Dev/SEToolbox/SEToolbox/Properties/Resources.zh-cn.resx b/Dev/SEToolbox/SEToolbox/Properties/Resources.zh-cn.resx deleted file mode 100644 index cefb7be9..00000000 --- a/Dev/SEToolbox/SEToolbox/Properties/Resources.zh-cn.resx +++ /dev/null @@ -1,2378 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - 试验test - - - 试验test - - - - No - - - 是的 - Yes - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 有新版本可用 - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 太空工程师 工具箱 - {0} ({1}) - SE Toolbox - {0} ({1}) - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - Specify file for imaage - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - 试验test - - - - ..\Resources\SEToolbox_splash_zh-cn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/SEToolbox.csproj b/Dev/SEToolbox/SEToolbox/SEToolbox.csproj deleted file mode 100644 index a53677e4..00000000 --- a/Dev/SEToolbox/SEToolbox/SEToolbox.csproj +++ /dev/null @@ -1,925 +0,0 @@ - - - - Debug - x86 - 8.0.30703 - 2.0 - {476405E8-27C7-4CD8-B75F-00B8DE0B4BD5} - WinExe - Properties - SEToolbox - SEToolbox - v4.6.1 - - - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - SAK - SAK - SAK - SAK - - - app.ico - - - false - - - ..\SEToolbox.snk - - - true - bin\Debug\ - TRACE;DEBUG;STABLE - full - AnyCPU - prompt - MinimumRecommendedRules.ruleset - false - - - bin\Release\ - TRACE;STABLE - false - AnyCPU - prompt - MinimumRecommendedRules.ruleset - full - true - false - - - false - - - true - bin\x64\Debug\ - TRACE;DEBUG;STABLE - full - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - - - true - bin\x64\Release\ - TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - false - - - - - - - - - - - - - - - - - - - 4.0 - - - - - - - - - ..\References\HelixToolkit.Wpf.dll - - - $(BinPath)\Sandbox.Common.dll - - - $(BinPath)\Sandbox.Game.dll - - - $(BinPath)\SharpDX.DXGI.dll - - - $(BinPath)\SpaceEngineers.Game.dll - - - $(BinPath)\SpaceEngineers.ObjectBuilders.dll - - - $(BinPath)\System.Data.SQLite.dll - - - $(BinPath)\netstandard.dll - - - $(BinPath)\VRage.dll - - - $(BinPath)\VRage.Game.dll - - - $(BinPath)\VRage.Input.dll - - - $(BinPath)\VRage.Library.dll - - - $(BinPath)\VRage.Math.dll - - - $(BinPath)\VRage.Native.dll - - - $(BinPath)\VRage.Render.dll - - - $(BinPath)\VRage.Render11.dll - - - $(BinPath)\VRage.Steam.dll - - - $(BinPath)\Steamworks.NET.dll - - - {e78476cb-bc3d-4265-806d-96f09229a449} - SEToolbox.ImageLibrary - - - {967d61a9-c8f0-4c2a-a784-6cda648ecb19} - SEToolbox.ImageShaders - - - - - MSBuild:Compile - Designer - - - - - Component - - - - - - - - - - - - - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - - - - - - - - - - True - True - Resources.resx - - - - - Code - - - Code - - - - - - - - - - - - True - True - SubtypeId.tt - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ControlBaseState.xaml - - - ControlCharacter.xaml - - - ControlCubeGrid.xaml - - - ControlSaveState.xaml - - - ControlInventoryBag.xaml - - - ControlPlanet.xaml - - - ControlVoxel.xaml - - - ControlFloatingObject.xaml - - - ControlPosition.xaml - - - ControlMultiple.xaml - - - ControlUnknown.xaml - - - ControlMeteor.xaml - - - ControlInventory.xaml - - - WindowBlueprintDialog.xaml - - - WindowErrorDialog.xaml - - - WindowRegeneratePlanet.xaml - - - WindowSettings.xaml - - - WindowVoxelMerge.xaml - - - WindowChangeOwner.xaml - - - WindowProgressCancel.xaml - - - WindowResourceReport.xaml - - - WindowSelectCube.xaml - - - WindowFrameworkBuild.xaml - - - WindowFindApplication.xaml - - - WindowGenerateFloatingObject.xaml - - - WindowComponentList.xaml - - - WindowGroupMove.xaml - - - WindowImportAsteroidModel.xaml - - - WindowSplashScreen.xaml - - - WindowGenerateVoxelField.xaml - - - WindowAbout.xaml - - - WindowExplorer.xaml - - - App.xaml - Code - - - WindowImportImage.xaml - - - WindowImportModel.xaml - - - WindowImportVoxel.xaml - - - WindowLoad.xaml - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - Designer - MSBuild:Compile - - - - - Code - - - Designer - - - Designer - - - Designer - - - PublicResXFileCodeGenerator - Designer - Resources.Designer.cs - - - Designer - - - TextTemplatingFileGenerator - SubtypeId.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - steam_api64.dll - Always - - - VRage.Native.dll - Always - - - Always - - - - - - - - 2.0.8 - - - 0.32.0 - - - 4.5.0 - - - 2.0.20525 - - - 3.1.2 - - - - - - - - - - \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/Services/BubbleScrollBehavior.cs b/Dev/SEToolbox/SEToolbox/Services/BubbleScrollBehavior.cs deleted file mode 100644 index 711dacd8..00000000 --- a/Dev/SEToolbox/SEToolbox/Services/BubbleScrollBehavior.cs +++ /dev/null @@ -1,30 +0,0 @@ -namespace SEToolbox.Services -{ - using System.Windows; - using System.Windows.Input; - using System.Windows.Interactivity; - - // Used on sub-controls of an expander to bubble the mouse wheel scroll event up - public sealed class BubbleScrollBehavior : Behavior - { - protected override void OnAttached() - { - base.OnAttached(); - AssociatedObject.PreviewMouseWheel += AssociatedObject_PreviewMouseWheel; - } - - protected override void OnDetaching() - { - AssociatedObject.PreviewMouseWheel -= AssociatedObject_PreviewMouseWheel; - base.OnDetaching(); - } - - void AssociatedObject_PreviewMouseWheel(object sender, MouseWheelEventArgs e) - { - e.Handled = true; - var e2 = new MouseWheelEventArgs(e.MouseDevice, e.Timestamp, e.Delta); - e2.RoutedEvent = UIElement.MouseWheelEvent; - AssociatedObject.RaiseEvent(e2); - } - } -} \ No newline at end of file diff --git a/Dev/SEToolbox/SEToolbox/Services/ButtonDropDownMenuBehavior.cs b/Dev/SEToolbox/SEToolbox/Services/ButtonDropDownMenuBehavior.cs deleted file mode 100644 index 30818cf2..00000000 --- a/Dev/SEToolbox/SEToolbox/Services/ButtonDropDownMenuBehavior.cs +++ /dev/null @@ -1,29 +0,0 @@ -namespace SEToolbox.Services -{ - using System.Windows; - using System.Windows.Controls; - using System.Windows.Interactivity; - - /// - /// For enabling DropDown menu on Button - /// - public class ButtonDropDownMenuBehavior : Behavior - - - - - - - - - - - - - - - - - - - - - - - - - - -