-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
371 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using duduluu.MVVM; | ||
using RimTrans.Lite.Controls; | ||
using RimTrans.Lite.Util; | ||
|
||
namespace RimTrans.Lite.Windows | ||
{ | ||
public class ToolsViewModel : ViewModelBase | ||
{ | ||
public ToolsViewModel() | ||
{ | ||
|
||
} | ||
|
||
public ToolsWindow View { get; set; } | ||
|
||
// TemplateExport | ||
private bool CanExecuteExport(object parameter) { | ||
return !string.IsNullOrWhiteSpace(UserSettings.All.DefTemplateOutputPath); | ||
} | ||
private RelayCommand _commandTemplateExport; | ||
public RelayCommand CommandTemplateExport { | ||
get { return _commandTemplateExport ?? (_commandTemplateExport = new RelayCommand(ExecuteTemplateExport, CanExecuteExport)); } | ||
} | ||
private void ExecuteTemplateExport(object parameter) { | ||
string defsPath = Path.Combine(UserSettings.All.RimWorldInstallDir, "Mods", "Core", "Defs"); | ||
string outputPath = UserSettings.All.DefTemplateOutputPath; | ||
string arguments = $"\"{defsPath}\" \"{outputPath}\""; | ||
if (UserSettings.All.DefTemplateOpenFolder) { | ||
Process.Start("explorer.exe", $"\"{outputPath}\""); | ||
} | ||
Process.Start("TemplateExporter.exe", arguments); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<Window x:Class="RimTrans.Lite.Windows.ToolsWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:local="clr-namespace:RimTrans.Lite.Windows" | ||
xmlns:u="clr-namespace:RimTrans.Lite.Util" | ||
xmlns:c="clr-namespace:RimTrans.Lite.Controls" | ||
xmlns:co="clr-namespace:RimTrans.Lite.Converters" | ||
mc:Ignorable="d" | ||
x:Name="Tools" | ||
Title="{DynamicResource MainWindow.Button.Tools}" | ||
Height="{Binding Source={x:Static u:UserSettings.All}, Path=ToolsWindowHeight, Mode=TwoWay}" | ||
Width="{Binding Source={x:Static u:UserSettings.All}, Path=ToolsWindowWidth, Mode=TwoWay}" | ||
MinHeight="500" MinWidth="809" ResizeMode="CanResizeWithGrip" | ||
WindowStartupLocation="CenterOwner" | ||
Background="{StaticResource Lite.Main.Background}" | ||
SnapsToDevicePixels="True"> | ||
<Window.DataContext> | ||
<local:ToolsViewModel x:Name="vm"/> | ||
</Window.DataContext> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="auto"/> | ||
<ColumnDefinition Width="*"/> | ||
</Grid.ColumnDefinitions> | ||
|
||
<StackPanel Grid.RowSpan="2" Style="{StaticResource Style.Sidebar}"> | ||
<c:AwesomeRadioButton x:Name="templateExport" | ||
IsChecked="True" | ||
Icon="FileCodeOutline" Text="Def Template Exporter" | ||
Style="{StaticResource Style.AwesomeRadioButton.Sidebar.Content}"/> | ||
</StackPanel> | ||
|
||
<!-- All Panel --> | ||
<Grid Grid.Column="1" ScrollViewer.VerticalScrollBarVisibility="Auto" Margin="20"> | ||
|
||
<!-- TemplateExport --> | ||
<StackPanel Grid.Column="1" Visibility="{Binding IsChecked, ElementName=templateExporter, Converter={StaticResource BooleanToVisibilityConverter}}" | ||
Orientation="Vertical" HorizontalAlignment="Stretch"> | ||
<GroupBox Header="Def Template Output Path" Margin="10" Style="{StaticResource Style.GroupBox}"> | ||
<StackPanel Orientation="Vertical" HorizontalAlignment="Stretch"> | ||
<TextBox Text="{Binding Source={x:Static u:UserSettings.All}, Path=DefTemplateOutputPath}" | ||
Margin="4" Style="{StaticResource Style.TextBox.Label}"/> | ||
<Grid HorizontalAlignment="Stretch"> | ||
<CheckBox Content="Open folder after exporting" IsChecked="{Binding Source={x:Static u:UserSettings.All}, Path=DefTemplateOpenFolder}" | ||
Margin="10,0" Style="{StaticResource Style.AwesomeCheckBox.Content}"/> | ||
<Button Command="{Binding CommandTemplateExport}" | ||
HorizontalAlignment="Right" | ||
Content="Export" Margin="5" Style="{StaticResource Sylte.Button.Wide}"/> | ||
</Grid> | ||
</StackPanel> | ||
</GroupBox> | ||
</StackPanel> | ||
<!-- TemplateExport End --> | ||
</Grid> | ||
</Grid> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Shapes; | ||
|
||
namespace RimTrans.Lite.Windows { | ||
/// <summary> | ||
/// Tools.xaml 的交互逻辑 | ||
/// </summary> | ||
public partial class ToolsWindow : Window { | ||
public ToolsWindow() { | ||
InitializeComponent(); | ||
vm.View = this; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using RimTrans.Builder; | ||
using RimTrans.Builder.Crawler; | ||
|
||
namespace RimTrans.TemplateExporter { | ||
class Program { | ||
static void Main(string[] args) { | ||
|
||
#region Application Info | ||
|
||
Assembly asm = Assembly.GetExecutingAssembly(); | ||
string title = asm.GetCustomAttribute<AssemblyTitleAttribute>().Title; | ||
Console.Title = title; | ||
Console.OutputEncoding = Encoding.Unicode; | ||
|
||
#endregion | ||
|
||
if (args.Length != 2) { | ||
Log.Error(); | ||
Log.WriteLine("Need 2 arguments: defsPath and outputPath."); | ||
} else if (string.IsNullOrEmpty(args[0]) || string.IsNullOrEmpty(args[1])) { | ||
Log.Error(); | ||
Log.WriteLine("Need 2 arguments: defsPath and outputPath."); | ||
} else { | ||
Gen_DefsTemplate(args[0], args[1]); | ||
} | ||
Log.WriteLine(); | ||
Log.Write("Press any key to exit..."); | ||
Console.ReadKey(); | ||
return; | ||
} | ||
|
||
public static void Gen_DefsTemplate(string defsPath, string outputPath) { | ||
if (!Directory.Exists(defsPath)) { | ||
Log.Error(); | ||
Log.WriteLine($"Directory no found: {defsPath}"); | ||
return; | ||
} | ||
|
||
string sourceCodePath = Path.Combine(Directory.GetCurrentDirectory(), "Assembly-CSharp"); | ||
if (Directory.Exists(sourceCodePath)) { | ||
Log.Info(); | ||
Log.WriteLine(); | ||
} else { | ||
sourceCodePath = null; | ||
} | ||
|
||
DefinitionData coreDefinitionData = DefinitionData.Load(defsPath); | ||
|
||
Capture capture = Capture.Parse(coreDefinitionData); | ||
capture.ProcessFieldNames(coreDefinitionData); | ||
coreDefinitionData.Save(Path.Combine(outputPath, "CoreDefsProcessed")); | ||
|
||
Capture templates = Capture.Parse(coreDefinitionData, sourceCodePath, true); | ||
templates.Save(Path.Combine(outputPath, "Templates")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("RimTrans.TemplateExporter")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("RimTrans.TemplateExporter")] | ||
[assembly: AssemblyCopyright("Copyright © 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("4a841417-f517-4b5b-af88-f29bc0a0095f")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 | ||
// 方法是按如下所示使用“*”: : | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("0.18.2.3")] | ||
[assembly: AssemblyFileVersion("0.18.2.3")] |
Binary file not shown.
Oops, something went wrong.