forked from Telanor/DDS4KSP
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FolderDialog.cs
131 lines (126 loc) · 3.89 KB
/
FolderDialog.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace DDS4KSPcs
{
public partial class FolderDialog
{
public FolderDialog()
{
InitializeComponent();
}
//Button/OK
private void OK_Button_Click(Object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
//Button/Cancel
private void Cancel_Button_Click(Object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
//Button/Reset
private void Button1_Click(Object sender, EventArgs e)
{
ResetWindow();
}
//loading the window
private void dlg_Folder_Load(Object sender, EventArgs e)
{
ResetWindow();
}
//a custom function to call ShowDialog(), so parameters can be updated before the window is closed
public DialogResult CustomShowDialog(string sPath, FolderProcessingParams CFG)
{
if (ShowDialog() == DialogResult.OK) {
//(assume CFG is already instantiated)
//Format
CFG.Compressed = RB_format_compressed.Checked;
CFG.ProcessMBMs = CB_format_incMBM.Checked;
CFG.ProcessTGAs = CB_format_incTGA.Checked;
CFG.ProcessPNGs = CB_format_incPNG.Checked;
CFG.FlipImages = CB_format_FLIPImages.Checked;
//normals
CFG.NormalsManagement = CB_normal_ConvSelect.SelectedIndex;
//mipmaps
CFG.GenerateMipmaps = CB_mipmap_Generate.Checked;
//resize
if (CB_resize_MinResolution.Checked)
{
CFG.MinRes_Resize_Width = Convert.ToInt32(NUD_resize_MinWidth.Value);
CFG.MinRes_Resize_Height = Convert.ToInt32(NUD_resize_MinHeight.Value);
} else {
CFG.MinRes_Resize_Width = 1;
CFG.MinRes_Resize_Height = 1;
}
switch (CB_resize_Ratio.SelectedIndex) {
case 0:
CFG.ResizeRatio = 1;
break;
case 1:
CFG.ResizeRatio = 0.75;
break;
case 2:
CFG.ResizeRatio = 0.5;
break;
case 3:
CFG.ResizeRatio = 0.25;
break;
default:
CFG.ResizeRatio = 1;
break;
}
//misc
CFG.MinRes_Process_Width = Convert.ToInt32(NUD_misc_MinWidth.Value);
CFG.MinRes_Process_Height = Convert.ToInt32(NUD_misc_MinHeight.Value);
CFG.DeleteFilesOnSuccess = RB_misc_DeleteFiles.Checked;
CFG.BackupFile = RB_misc_KeepBackups.Checked;
CFG.IgnoreExceptions = CB_misc_IgnoreExceptions.Checked;
return DialogResult.OK;
} else {
return DialogResult.Cancel;
}
}
//LinkLabel to ModsExceptions.txt
private void LinkLabel1_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e)
{
//if the files doesn't exist, an empty one is created...
if (!File.Exists(FolderLoader.ModExceptionPath)) {
var st = File.Create(FolderLoader.ModExceptionPath);
st.Close();
}
//...and launched
Process.Start(FolderLoader.ModExceptionPath);
}
//resetting the controls to something accurate
private void ResetWindow()
{
//create a new cfg to reset automatic parameters
var folderCFG = new FolderProcessingParams();
//Format
RB_format_compressed.Checked = folderCFG.Compressed;
CB_format_incMBM.Checked = folderCFG.ProcessMBMs;
CB_format_incTGA.Checked = folderCFG.ProcessTGAs;
CB_format_incPNG.Checked = folderCFG.ProcessPNGs;
CB_format_FLIPImages.Checked = folderCFG.FlipImages;
//normals
CB_normal_ConvSelect.SelectedIndex = folderCFG.NormalsManagement;
//mipmaps
CB_mipmap_Generate.Checked = folderCFG.GenerateMipmaps;
//resize
CB_resize_Ratio.SelectedIndex = 0;
CB_resize_MinResolution.Checked = true;
NUD_resize_MinWidth.Value = folderCFG.MinRes_Resize_Width;
NUD_resize_MinHeight.Value = folderCFG.MinRes_Resize_Height;
//misc
NUD_misc_MinWidth.Value = folderCFG.MinRes_Process_Height;
NUD_misc_MinHeight.Value = folderCFG.MinRes_Process_Width;
RB_misc_DeleteFiles.Checked = folderCFG.DeleteFilesOnSuccess;
RB_misc_KeepBackups.Checked = folderCFG.BackupFile;
CB_misc_IgnoreExceptions.Checked = folderCFG.IgnoreExceptions;
}
}
}