Skip to content

Commit 3dcf086

Browse files
committed
Automatic merge of T1.5.1-1741-gf80cfb5d1 and 21 pull requests
- Pull request #570 at f11a428: glTF 2.0 support with PBR lighting - Pull request #1030 at d3ae4a2: Refactor settings, in prep for settings exporter - Pull request #1052 at 3b5cb90: Content Manager: Add axle count, and lowest derail force - Pull request #1062 at bbc0013: Train Forces popup Window. - Pull request #1064 at cb510d6: Add Train Info tab to Help window (F1) - Pull request #1066 at 62c89c1: Log derailment, using TraceInformation. - Pull request #1082 at a3128ae: Allow variable water level in glass gauge - Pull request #892 at 1f5ba4c: Signal Function OPP_SIG_ID_TRAINPATH - Pull request #1049 at 6a0c471: Re-organise document storage and access - Pull request #1057 at 84592f7: Switchable brake system - Pull request #1069 at 99fc9ac: Mouse wheel control only with Alt – Followup for #1051 - Pull request #1070 at f818e40: Fix a NullReferenceException in TCS scripts - Pull request #1071 at 722dd3f: Change cover image for v1.6 - Pull request #1074 at e9a66c1: Gradient - commit 2024-16-12 - Pull request #1076 at 3bbd537: Allow depart early - Pull request #1077 at 7e73abd: Fix SME brakes not working - Pull request #1078 at 9ab642e: Default PowerSupply script for steam locomotives - Pull request #1079 at 5e37059: Adds Polish transations - Pull request #1080 at a637cb8: arranges Options > System tab for longer texts - Pull request #1083 at 7e6fb60: Menu contents route name clash - Pull request #1081 at 689494b: Brake cuts power unification
23 parents bbc16aa + f80cfb5 + f11a428 + d3ae4a2 + 3b5cb90 + bbc0013 + cb510d6 + 62c89c1 + a3128ae + 1f5ba4c + 6a0c471 + 84592f7 + 99fc9ac + f818e40 + 722dd3f + e9a66c1 + 3bbd537 + 7e73abd + 9ab642e + 5e37059 + a637cb8 + 7e6fb60 + 689494b commit 3dcf086

File tree

2 files changed

+103
-8
lines changed

2 files changed

+103
-8
lines changed

Source/Menu/ContentForm.Designer.cs

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Source/Menu/ContentForm.cs

Lines changed: 99 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public partial class ContentForm : Form
6161
private bool In_dataGridViewManualInstall_SelectionChanged = false;
6262
private bool In_buttonManualInstallAdd_Click = false;
6363

64+
private bool ManualInstallChangesMade = false;
65+
6466
public ContentForm(UserSettings settings, string baseDocumentationUrl)
6567
{
6668
InitializeComponent();
@@ -93,6 +95,10 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
9395
route.Installed ? route.DateInstalled.ToString(CultureInfo.CurrentCulture.DateTimeFormat) : "",
9496
route.Url });
9597
dataGridViewAutoInstall.Rows[indexAdded].Cells[2].ToolTipText = route.Url;
98+
if (!route.Installed)
99+
{
100+
changeManualInstallRoute(routeName);
101+
}
96102
}
97103

98104
dataGridViewAutoInstall.Sort(dataGridViewAutoInstall.Columns[0], ListSortDirection.Ascending);
@@ -113,6 +119,10 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
113119
// set focus to datagridview so that arrow keys can be used to scroll thru the list
114120
dataGridViewAutoInstall.Select();
115121

122+
// tab "Auto Installed" does not contain a Cancel button
123+
// it's too difficult and not logical to rollback an "Auto Installed" route
124+
buttonCancel.Hide();
125+
116126
//
117127
// "Manually Installed" tab
118128
//
@@ -130,6 +140,43 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
130140
dataGridViewManualInstall.Sort(dataGridViewManualInstall.Columns[0], ListSortDirection.Ascending);
131141

132142
ManualInstallBrouwseDir = determineBrowseDir();
143+
buttonCancel.Enabled = false;
144+
}
145+
146+
void changeManualInstallRoute(string Route)
147+
{
148+
bool found = false;
149+
150+
foreach (var folder in Settings.Folders.Folders)
151+
{
152+
if (folder.Key == Route)
153+
{
154+
// Route found in folder settings
155+
found = true;
156+
}
157+
}
158+
159+
if (found)
160+
{
161+
// search for the next route (1), (2) etc. not found in folder settings
162+
int seqNr = 1;
163+
string route = Route + " (" + seqNr + ")";
164+
while (found)
165+
{
166+
found = false;
167+
foreach (var folder in Settings.Folders.Folders)
168+
{
169+
if (folder.Key == route)
170+
{
171+
found = true;
172+
seqNr++;
173+
route = Route + " (" + seqNr + ")";
174+
}
175+
}
176+
}
177+
Settings.Folders.Folders[route] = Settings.Folders.Folders[Route];
178+
Settings.Folders.Folders.Remove(Route);
179+
}
133180
}
134181

135182
private void tabControlContent_Selecting(object sender, TabControlCancelEventArgs e)
@@ -138,9 +185,12 @@ private void tabControlContent_Selecting(object sender, TabControlCancelEventArg
138185
{
139186
case "tabPageAutoInstall":
140187
dataGridViewAutoInstall.Select();
188+
buttonCancel.Hide();
141189
break;
142190
case "tabPageManuallyInstall":
143191
dataGridViewManualInstall.Select();
192+
buttonCancel.Show();
193+
buttonCancel.Enabled = ManualInstallChangesMade;
144194
break;
145195
}
146196
}
@@ -1051,7 +1101,6 @@ private void DisableAutoInstallButtons()
10511101
buttonAutoInstallUpdate.Enabled = false;
10521102
buttonAutoInstallDelete.Enabled = false;
10531103
buttonOK.Enabled = false;
1054-
buttonCancel.Enabled = false;
10551104
}
10561105

10571106
private void setCursorToWaitCursor()
@@ -1073,7 +1122,6 @@ private void EnableAutoInstalButtons()
10731122
buttonAutoInstallUpdate.Enabled = route.Installed && (route.getDownloadType() == ContentRouteSettings.DownloadType.github);
10741123
buttonAutoInstallDelete.Enabled = route.Installed;
10751124
buttonOK.Enabled = true;
1076-
buttonCancel.Enabled = true;
10771125

10781126
setCursorToDefaultCursor();
10791127
}
@@ -1398,6 +1446,18 @@ private void textBoxManualInstallRoute_TextChanged(object sender, EventArgs e)
13981446
{
13991447
// only update the grid when user is filling/changing the route in the textbox
14001448
dataGridViewManualInstall.CurrentRow.Cells[0].Value = textBoxManualInstallRoute.Text;
1449+
ManualInstallChangesMade = true;
1450+
buttonCancel.Enabled = true;
1451+
}
1452+
}
1453+
1454+
private void textBoxManualInstallRoute_Leave(object sender, EventArgs e)
1455+
{
1456+
string route = textBoxManualInstallRoute.Text;
1457+
textBoxManualInstallRoute.Text = determineUniqueRoute(route);
1458+
if (textBoxManualInstallRoute.Text != route)
1459+
{
1460+
dataGridViewManualInstall.CurrentRow.Cells[0].Value = textBoxManualInstallRoute.Text;
14011461
}
14021462
}
14031463

@@ -1452,6 +1512,8 @@ private void buttonManualInstallAdd_Click(object sender, EventArgs e)
14521512
string route = determineUniqueRoute(Path.GetFileName(folderBrowser.SelectedPath));
14531513
dataGridViewManualInstall.CurrentRow.Cells[0].Value = route;
14541514
dataGridViewManualInstall.CurrentRow.Cells[1].Value = folderBrowser.SelectedPath;
1515+
ManualInstallChangesMade = true;
1516+
buttonCancel.Enabled = ManualInstallChangesMade;
14551517
}
14561518
else
14571519
{
@@ -1477,6 +1539,8 @@ private void buttonManualInstallDelete_Click(object sender, EventArgs e)
14771539
if (dataGridViewManualInstall.CurrentRow != null)
14781540
{
14791541
dataGridViewManualInstall.Rows.Remove(dataGridViewManualInstall.CurrentRow);
1542+
ManualInstallChangesMade = true;
1543+
buttonCancel.Enabled = ManualInstallChangesMade;
14801544
}
14811545
}
14821546

@@ -1512,17 +1576,18 @@ private void setTextBoxesManualInstall()
15121576
string determineUniqueRoute(string Route)
15131577
{
15141578
string route = Route;
1515-
1579+
long seqNr = 0;
15161580
bool found = false;
15171581

15181582
while (!found)
15191583
{
15201584
found = true;
15211585
for (int i = 0; i < dataGridViewManualInstall.Rows.Count - 1; i++)
15221586
{
1523-
if (dataGridViewManualInstall.Rows[i].Cells[0].Value.ToString() == route)
1524-
{
1525-
route += " copy";
1587+
if (((dataGridViewManualInstall.Rows[i].Cells[0].Value.ToString() == route) && (!dataGridViewManualInstall.Rows[i].Selected)) ||
1588+
(AutoInstallRoutes.ContainsKey(route))) {
1589+
seqNr++;
1590+
route = Route + " (" + seqNr + ")";
15261591
found = false;
15271592
}
15281593
}
@@ -1588,6 +1653,21 @@ private static bool isWrongPath(string path, GettextResourceManager catalog)
15881653
return false;
15891654
}
15901655

1656+
private void buttonCancel_Click(object sender, EventArgs e)
1657+
{
1658+
string message = Catalog.GetString("Cancel: changes made in the 'Manually Installed' tab will not be saved, are you sure?");
1659+
if (MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
1660+
{
1661+
// not sure, cancel the cancel
1662+
this.DialogResult = DialogResult.None;
1663+
}
1664+
else
1665+
{
1666+
// sure to cancel the changes
1667+
ManualInstallChangesMade = false;
1668+
}
1669+
}
1670+
15911671
private void buttonOK_Click(object sender, EventArgs e)
15921672
{
15931673
// save "Manually Installed" tab changes into the registry/ini file via Settings.Folders.Folders
@@ -1641,6 +1721,8 @@ private void buttonOK_Click(object sender, EventArgs e)
16411721

16421722
Settings.Save();
16431723

1724+
ManualInstallChangesMade = false;
1725+
16441726
this.Close();
16451727
}
16461728

@@ -1672,6 +1754,17 @@ private int findIndexDgvManualInstall(string route)
16721754

16731755
private void DownloadContentForm_FormClosing(object sender, FormClosingEventArgs formClosingEventArgs)
16741756
{
1757+
if (ManualInstallChangesMade)
1758+
{
1759+
string message = Catalog.GetString("Cancel: changes made in the 'Manually Installed' tab will not be saved, are you sure?");
1760+
if (MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
1761+
{
1762+
// not sure, cancel the cancel
1763+
formClosingEventArgs.Cancel = true;
1764+
return;
1765+
}
1766+
}
1767+
16751768
if (AutoInstallClosingBlocked)
16761769
{
16771770
// cancelled event, so continue

0 commit comments

Comments
 (0)