Skip to content

Commit

Permalink
オプション追加
Browse files Browse the repository at this point in the history
  • Loading branch information
yosxpeee committed Mar 24, 2019
1 parent b120030 commit 3aa9b73
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 26 deletions.
6 changes: 6 additions & 0 deletions Civ6IconCreator/Civ6IconCreator/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
<setting name="outputDirName" serializeAs="String">
<value />
</setting>
<setting name="checkedDX10" serializeAs="String">
<value>False</value>
</setting>
<setting name="checkedNoGPU" serializeAs="String">
<value>False</value>
</setting>
</Civ6IconCreator.Properties.Settings>
</userSettings>
</configuration>
4 changes: 3 additions & 1 deletion Civ6IconCreator/Civ6IconCreator/Civ6IconCreator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,9 @@
<None Include="template\tex\UnitPortraits\UnitPortraitsTemplate38.tex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="template\tex\UnitPortraits\UnitPortraitsTemplate50.tex" />
<None Include="template\tex\UnitPortraits\UnitPortraitsTemplate50.tex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="template\tex\UnitPortraits\UnitPortraitsTemplate70.tex">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
Expand Down
30 changes: 29 additions & 1 deletion Civ6IconCreator/Civ6IconCreator/Form1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

103 changes: 79 additions & 24 deletions Civ6IconCreator/Civ6IconCreator/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ namespace Civ6IconCreator
{
public partial class Form1 : Form
{
//グローバル変数定義
//Form内共通変数、定数
string outputDirName;
string inputFilePath;
string texConvPath;
string sedPath;

int[] sizesLeaders = new int[] {256, 80,64,55,50,45,32};
int[] sizesCivilizations = new int[] {256, 80,64,50,48,45,44,36,30,22};
int[] sizesUnitFlags = new int[] {256, 80,50,38,32,22};
Expand All @@ -29,6 +30,7 @@ public partial class Form1 : Form
int[] sizesDistricts = new int[] {256,128,80,50,38,32,22};
int[] sizesImprovements = new int[] {256, 80,50,38};

//コンストラクタ
public Form1()
{
InitializeComponent();
Expand Down Expand Up @@ -70,8 +72,13 @@ public Form1()
outputTextBox.Text = "";
outputDirDialog.SelectedPath = System.Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
}
//DirectX10互換モード
checkBoxDirectX10.Checked = Properties.Settings.Default.checkedDX10;

//GPU使用有無
checkBoxNoGPU.Checked = Properties.Settings.Default.checkedNoGPU;

//外部アプリケーションは直下にあるものとして処理する
//外部アプリケーションは直下にあるものとして設定する
texConvPath = System.Windows.Forms.Application.StartupPath + @"\texconv.exe";
sedPath = System.Windows.Forms.Application.StartupPath + @"\onigsed.exe";

Expand All @@ -84,6 +91,13 @@ public Form1()
#endif
}

//========================================
// イベント
//========================================
//====================
// メイン
//====================
//Inputの開くボタンが押されたとき
private void inputButton_Click(object sender, EventArgs e)
{
//Inputの画像を開くボタン
Expand Down Expand Up @@ -124,9 +138,9 @@ private void inputButton_Click(object sender, EventArgs e)
}
}

//Outputの開くボタンが押されたとき
private void outputButton_Click(object sender, EventArgs e)
{
//Optput先を開くボタン
if (DialogResult.OK == outputDirDialog.ShowDialog())
{
outputDirName = outputDirDialog.SelectedPath;
Expand All @@ -143,10 +157,9 @@ private void outputButton_Click(object sender, EventArgs e)
}
}

//生成ボタンが押されたとき
private void generateButton_Click(object sender, EventArgs e)
{
//Generate

//チェックされてるものに合わせてDDS変換とTex生成を実施する
if (radioButton1.Checked) {
_generateDDS(sizesLeaders);
Expand Down Expand Up @@ -183,28 +196,78 @@ private void generateButton_Click(object sender, EventArgs e)
_generateTex("Improvements", sizesImprovements);
toolStripStatusLabel1.Text = "変換完了(Improvements)";
};
}

//====================
// オプション
//====================
//記憶場所消去のボタンが押されたとき
private void ResetButton_Click(object sender, EventArgs e)
{
inputFilePath = "";
outputDirName = "";
inputTextBox.Text = "";
outputTextBox.Text = "";
Properties.Settings.Default.inputFile = "";
Properties.Settings.Default.outputDirName = "";
Properties.Settings.Default.Save();

toolStripStatusLabel1.Text = "ディレクトリの記憶情報を消去しました。";
}

//DirectX互換モードのチェックが変わったとき
private void checkBoxDirectX10_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.checkedDX10 = checkBoxDirectX10.Checked;
Properties.Settings.Default.Save();
}

//GPUを使用しないのチェックが変わったとき
private void checkBoxNoGPU_CheckedChanged(object sender, EventArgs e)
{
Properties.Settings.Default.checkedNoGPU = checkBoxNoGPU.Checked;
Properties.Settings.Default.Save();
}

//========================================
// 内部関数
//========================================
//DDS変換関数(texconvに丸投げ)
private void _generateDDS(int[] sizes)
{
string optDx10 = "";
string optNoGPU = "";

//DirectX10互換モードの有無
if (checkBoxDirectX10.Checked)
{
optDx10 = "-dx10 ";
}
//GPU使用の有無
if (checkBoxNoGPU.Checked)
{
optNoGPU = "-nogpu ";
}

foreach (int imgSize in sizes)
{
//PNGからDDSに変換
var app = new ProcessStartInfo();
app.FileName = texConvPath;
app.Arguments = " -y -f R8G8B8A8_UNORM -if BOX -w " + imgSize + " -h " + imgSize + " -m 1 -sx " + imgSize + " -o \"" + outputDirName + "\" \""+ inputFilePath + "\"";
app.WorkingDirectory = System.IO.Path.GetDirectoryName(texConvPath);
app.CreateNoWindow = true;
app.RedirectStandardOutput = true;
app.UseShellExecute = false;
var app = new ProcessStartInfo
{
FileName = texConvPath,
Arguments = " -y -f R8G8B8A8_UNORM " + optDx10 + optNoGPU + "-if BOX -w " + imgSize + " -h " + imgSize + " -m 1 -sx " + imgSize + " -o \"" + outputDirName + "\" \"" + inputFilePath + "\"",
WorkingDirectory = System.IO.Path.GetDirectoryName(texConvPath),
CreateNoWindow = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
#if DEBUG
File.AppendAllText("debug.log", app.FileName + @" " + app.Arguments + "\r\n");

Process p = Process.Start(app);
string output = p.StandardOutput.ReadToEnd(); // 標準出力の読み取り
output = output.Replace("\r\r\n", "\n"); // 改行コードの修正

File.AppendAllText("debug.log", output);
#else
Process.Start(app);
Expand Down Expand Up @@ -239,20 +302,12 @@ private void _generateTex(string type, int[] sizes)
File.AppendAllText("debug.log", app.FileName + @" " + app.Arguments + "\r\n");
#endif
string output = p.StandardOutput.ReadToEnd(); // 標準出力の読み取り
#if DEBUG
File.AppendAllText("debug.log", "========================================\r\n");
File.AppendAllText("debug.log", output+"\r\n");
#endif
File.WriteAllText(outputPath, output);
}
}

private void ResetButton_Click(object sender, EventArgs e)
{
//記憶場所消去ボタン
inputFilePath = "";
outputDirName = "";
inputTextBox.Text = "";
outputTextBox.Text = "";
Properties.Settings.Default.inputFile = "";
Properties.Settings.Default.outputDirName = "";
Properties.Settings.Default.Save();
}
}
}
24 changes: 24 additions & 0 deletions Civ6IconCreator/Civ6IconCreator/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Civ6IconCreator/Civ6IconCreator/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
<Setting Name="outputDirName" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="checkedDX10" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="checkedNoGPU" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>

0 comments on commit 3aa9b73

Please sign in to comment.