mirror of
https://github.com/dreamforceinc/wContainerSorter.git
synced 2025-12-12 19:22:36 +03:00
Add project files.
This commit is contained in:
39
.editorconfig
Normal file
39
.editorconfig
Normal file
@@ -0,0 +1,39 @@
|
||||
# Rules in this file were initially inferred by Visual Studio IntelliCode from the D:\YandexDisk\SRC\SpaceEngineers\wContainerSorter codebase based on best match to current usage at 24.01.2023
|
||||
# You can modify the rules from these initially generated values to suit your own policies
|
||||
# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
|
||||
[*.cs]
|
||||
|
||||
|
||||
#Core editorconfig formatting - indentation
|
||||
|
||||
#use soft tabs (spaces) for indentation
|
||||
indent_style = space
|
||||
|
||||
#Formatting - spacing options
|
||||
|
||||
#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
|
||||
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||
#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
|
||||
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||
|
||||
#Style - expression bodied member options
|
||||
|
||||
#prefer block bodies for constructors
|
||||
csharp_style_expression_bodied_constructors = false:suggestion
|
||||
|
||||
#Style - implicit and explicit types
|
||||
|
||||
#prefer var over explicit type in all cases, unless overridden by another code style rule
|
||||
csharp_style_var_elsewhere = true:suggestion
|
||||
|
||||
#Style - modifier options
|
||||
|
||||
#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
|
||||
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
|
||||
|
||||
#Style - Modifier preferences
|
||||
|
||||
#when this rule is set to a list of modifiers, prefer the specified ordering.
|
||||
csharp_preferred_modifier_order = static,public:suggestion
|
||||
insert_final_newline=true
|
||||
csharp_new_line_before_open_brace=all
|
||||
27
wContainerSorter.sln
Normal file
27
wContainerSorter.sln
Normal file
@@ -0,0 +1,27 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.33214.272
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "wContainerSorter", "wContainerSorter\wContainerSorter.csproj", "{1EDEB5E2-21FC-4571-999C-DC4CEDE78067}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E471A6FA-5174-4D81-AA71-CEF6C130194A}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1EDEB5E2-21FC-4571-999C-DC4CEDE78067}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1EDEB5E2-21FC-4571-999C-DC4CEDE78067}.Debug|x64.Build.0 = Debug|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9CACD287-2581-4CD8-9010-F1A2DBACB58B}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
5
wContainerSorter/Instructions.readme
Normal file
5
wContainerSorter/Instructions.readme
Normal file
@@ -0,0 +1,5 @@
|
||||
R e a d m e
|
||||
-----------
|
||||
|
||||
In this file you can include any instructions or other comments you want to have injected onto the
|
||||
top of your final script. You can safely delete this file if you do not want any such comments.
|
||||
27
wContainerSorter/MDK/Bootstrapper.cs
Normal file
27
wContainerSorter/MDK/Bootstrapper.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Malware.MDKUtilities;
|
||||
|
||||
namespace IngameScript.MDK
|
||||
{
|
||||
public class TestBootstrapper
|
||||
{
|
||||
// All the files in this folder, as well as all files containing the file ".debug.", will be excluded
|
||||
// from the build process. You can use this to create utilites for testing your scripts directly in
|
||||
// Visual Studio.
|
||||
|
||||
static TestBootstrapper()
|
||||
{
|
||||
// Initialize the MDK utility framework
|
||||
MDKUtilityFramework.Load();
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
// In order for your program to actually run, you will need to provide a mockup of all the facilities
|
||||
// your script uses from the game, since they're not available outside of the game.
|
||||
|
||||
// Create and configure the desired program.
|
||||
var program = MDKFactory.CreateProgram<Program>();
|
||||
MDKFactory.Run(program);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
wContainerSorter/MDK/MDK.options.props
Normal file
18
wContainerSorter/MDK/MDK.options.props
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
Contains basic settings that should be included in code repositories
|
||||
-->
|
||||
<MDKVersion>1.4.12</MDKVersion>
|
||||
<MDKTrimTypes>
|
||||
<Enabled>no</Enabled>
|
||||
</MDKTrimTypes>
|
||||
<MDKMinify>
|
||||
<Level>None</Level>
|
||||
</MDKMinify>
|
||||
<MDKIgnore>
|
||||
<Folder>mdk</Folder>
|
||||
</MDKIgnore>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
81
wContainerSorter/MDK/MDK.paths.props
Normal file
81
wContainerSorter/MDK/MDK.paths.props
Normal file
@@ -0,0 +1,81 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<!--
|
||||
You can safely exclude this file from code repositories and use different
|
||||
user settings per machine.
|
||||
-->
|
||||
<MDKVersion>1.4.12</MDKVersion>
|
||||
<MDKUseGameBinPath>no</MDKUseGameBinPath>
|
||||
<MDKGameBinPath>V:\Steam\SteamApps\common\SpaceEngineers\Bin64</MDKGameBinPath>
|
||||
<MDKInstallPath>c:\users\w0lf\appdata\local\microsoft\visualstudio\16.0_4163267d\extensions\3itxx5kv.f04</MDKInstallPath>
|
||||
<MDKOutputPath>C:\Users\W0LF\AppData\Roaming\SpaceEngineers\IngameScripts\local</MDKOutputPath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Collections.Immutable">
|
||||
<HintPath>$(MDKGameBinPath)\System.Collections.Immutable.dll</HintPath>
|
||||
<Private>false</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Common">
|
||||
<HintPath>$(MDKGameBinPath)\Sandbox.Common.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Game">
|
||||
<HintPath>$(MDKGameBinPath)\Sandbox.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Sandbox.Graphics">
|
||||
<HintPath>$(MDKGameBinPath)\Sandbox.Graphics.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.Game">
|
||||
<HintPath>$(MDKGameBinPath)\SpaceEngineers.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SpaceEngineers.ObjectBuilders">
|
||||
<HintPath>$(MDKGameBinPath)\SpaceEngineers.ObjectBuilders.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Audio">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Audio.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Game">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Game.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Input">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Input.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Library">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Library.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Math">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Math.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Render.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Render11">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Render11.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="VRage.Scripting">
|
||||
<HintPath>$(MDKGameBinPath)\VRage.Scripting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="MDKUtilities">
|
||||
<HintPath>$(MDKInstallPath)\MDKUtilities.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Analyzer Include="$(MDKInstallPath)\Analyzers\MDKAnalyzer.dll" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
88
wContainerSorter/Program.cs
Normal file
88
wContainerSorter/Program.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using Sandbox.Game.EntityComponents;
|
||||
using Sandbox.ModAPI.Ingame;
|
||||
using Sandbox.ModAPI.Interfaces;
|
||||
|
||||
using SpaceEngineers.Game.ModAPI.Ingame;
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
using VRage;
|
||||
using VRage.Collections;
|
||||
using VRage.Game;
|
||||
using VRage.Game.Components;
|
||||
using VRage.Game.GUI.TextPanel;
|
||||
using VRage.Game.ModAPI.Ingame;
|
||||
using VRage.Game.ModAPI.Ingame.Utilities;
|
||||
using VRage.Game.ObjectBuilders.Definitions;
|
||||
|
||||
using VRageMath;
|
||||
|
||||
namespace IngameScript
|
||||
{
|
||||
partial class Program : MyGridProgram
|
||||
{
|
||||
|
||||
// ----------
|
||||
// wContainerSorter, v0.2
|
||||
// Copyright (c) 2023 by W0LF aka 'dreamforce'
|
||||
//
|
||||
// This script sorts the content of the containers.
|
||||
|
||||
// Type of sorting.
|
||||
// By default (empty string) - sort by item's Type (MyObjectBuilder_Component/Computer, MyObjectBuilder_Ore/Stone, etc).
|
||||
// It can be a "Name" string - sort by SubtypeId (Computer, Stone).
|
||||
static readonly string sortType = "";
|
||||
|
||||
// NO CHANGES BELOW //
|
||||
static List<IMyTerminalBlock> containers = new List<IMyTerminalBlock>();
|
||||
static List<MyInventoryItem> containerItems = new List<MyInventoryItem>();
|
||||
|
||||
public Program()
|
||||
{
|
||||
Runtime.UpdateFrequency = UpdateFrequency.Update100;
|
||||
}
|
||||
|
||||
public void Main(string argument, UpdateType updateSource)
|
||||
{
|
||||
IMyTextPanel lcd = GridTerminalSystem.GetBlockWithName("LCD") as IMyTextPanel;
|
||||
lcd.ContentType = ContentType.TEXT_AND_IMAGE;
|
||||
lcd.WriteText("");
|
||||
|
||||
containers.Clear();
|
||||
|
||||
GridTerminalSystem.GetBlocksOfType<IMyCargoContainer>(containers);
|
||||
|
||||
foreach (var container in containers)
|
||||
{
|
||||
containerItems.Clear();
|
||||
IMyInventory containerInventory = container.GetInventory();
|
||||
containerInventory.GetItems(containerItems);
|
||||
|
||||
if (sortType.ToUpper() == "NAME") containerItems.Sort((MyInventoryItem x, MyInventoryItem y) => x.Type.SubtypeId.ToString().CompareTo(y.Type.SubtypeId.ToString()));
|
||||
else containerItems.Sort((MyInventoryItem x, MyInventoryItem y) => x.Type.ToString().CompareTo(y.Type.ToString()));
|
||||
|
||||
foreach (MyInventoryItem item in containerItems)
|
||||
{
|
||||
for (int i = 0; i < containerInventory.ItemCount; i++)
|
||||
{
|
||||
MyInventoryItem item2 = (MyInventoryItem)containerInventory.GetItemAt(i);
|
||||
if (item.Equals(item2)) containerInventory.TransferItemTo(containerInventory, i, i + containerInventory.ItemCount, true);
|
||||
}
|
||||
}
|
||||
|
||||
lcd.WriteText($"{container.CustomName}:\n", true);
|
||||
foreach (MyInventoryItem item in containerItems) lcd.WriteText($"{item.Type} - {item.Amount}\n", true);
|
||||
lcd.WriteText("\n", true);
|
||||
}
|
||||
}
|
||||
// ----------
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
BIN
wContainerSorter/thumb.png
Normal file
BIN
wContainerSorter/thumb.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 385 KiB |
58
wContainerSorter/wContainerSorter.csproj
Normal file
58
wContainerSorter/wContainerSorter.csproj
Normal file
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1EDEB5E2-21FC-4571-999C-DC4CEDE78067}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>IngameScript</RootNamespace>
|
||||
<AssemblyName>wContainerSorter</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<LangVersion>6</LangVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="netstandard" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<Import Project="MDK/MDK.options.props" />
|
||||
<Import Project="MDK/MDK.paths.props" Condition="exists('MDK/MDK.paths.props')" />
|
||||
<ItemGroup>
|
||||
<Compile Include="MDK\Bootstrapper.cs" />
|
||||
<AdditionalFiles Include="MDK\MDK.options.props">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</AdditionalFiles>
|
||||
<AdditionalFiles Include="MDK\MDK.paths.props">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</AdditionalFiles>
|
||||
<Compile Include="Program.cs" />
|
||||
<AdditionalFiles Include="Instructions.readme" />
|
||||
<AdditionalFiles Include="thumb.png" />
|
||||
<AdditionalFiles Include="MDK\whitelist.cache" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterBuild">
|
||||
<Copy SourceFiles="MDK\MDK.options.props" DestinationFolder="$(TargetDir)\MDK" />
|
||||
<Copy SourceFiles="MDK\MDK.paths.props" DestinationFolder="$(TargetDir)\MDK" />
|
||||
</Target>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user