Skip to content

Commit af8431c

Browse files
committed
Automatic merge of T1.6-145-g7915033ac and 12 pull requests
- Pull request #1082 at 8538170: Allow variable water level in glass gauge - Pull request #1156 at f46d5f2: Fix incorrectly disabled options in train operations window - Pull request #1091 at 492795a: Automatic speed control - Pull request #1122 at 73c47b4: Wagon Size and Centering Controls - Pull request #1124 at e241a0d: Built-in PBL2 brake controller - Pull request #1128 at d116396: Particle Emitter Overhaul - Pull request #1157 at 39cd994: Dynamic brake authorization by TCS - Pull request #1166 at 51e7f7a: Simplify loading of internal and game textures - Pull request #1167 at 115325f: Fix: RunActivity slow to terminate because of long sleep in Host Process - Pull request #1168 at 6e2942f: Fix exception when exiting with MapForm or SoundDebugForm open. - Pull request #1169 at 8fe03b1: Better Handling of Wagons with Invalid Bogie Configuration - Pull request #1171 at 8fd2066: no internet connection is available, not possible to open the Menu Content Form
14 parents a166792 + 7915033 + 8538170 + f46d5f2 + 492795a + 73c47b4 + e241a0d + d116396 + 39cd994 + 51e7f7a + 115325f + 6e2942f + 8fe03b1 + 8fd2066 commit af8431c

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

Source/Menu/ContentForm.cs

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ public partial class ContentForm : Form
6363

6464
private bool ManualInstallChangesMade = false;
6565

66+
private readonly bool NoInternet = false;
67+
6668
public ContentForm(UserSettings settings, string baseDocumentationUrl)
6769
{
6870
InitializeComponent();
@@ -84,7 +86,14 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
8486
//
8587
// "Auto Installed" tab
8688
//
87-
Settings.Content.ContentRouteSettings.LoadContent();
89+
string errorMsg = "";
90+
Settings.Content.ContentRouteSettings.LoadContent(ref errorMsg);
91+
if (!string.IsNullOrEmpty(errorMsg))
92+
{
93+
string message = Catalog.GetStringFmt("Not connected to internet, automatic download not available. Error: {0}", errorMsg);
94+
MessageBox.Show(message, Catalog.GetString("Attention"), MessageBoxButtons.OK, MessageBoxIcon.Error);
95+
NoInternet = true;
96+
}
8897
AutoInstallRoutes = Settings.Content.ContentRouteSettings.Routes;
8998
for (int index = 0; index < AutoInstallRoutes.Count; index++)
9099
{
@@ -143,6 +152,19 @@ public ContentForm(UserSettings settings, string baseDocumentationUrl)
143152
buttonCancel.Enabled = false;
144153

145154
setTextBoxesManualInstall();
155+
156+
if (NoInternet)
157+
{
158+
// open the Manually Installed tab since the Auto Installed tab needs internet
159+
tabControlContent.SelectTab(tabPageManuallyInstall);
160+
}
161+
162+
if (dataGridViewAutoInstall.Rows.Count == 0)
163+
{
164+
// disable all auto install buttons for a complete empty auto install grid
165+
// might be the case when no internet available
166+
DisableAutoInstallButtonsWithoutWait();
167+
}
146168
}
147169

148170
void changeManualInstallRoute(string Route)
@@ -272,9 +294,9 @@ private void dataGridViewAutoInstall_SelectionChanged(object sender, EventArgs e
272294
try
273295
{
274296
using (WebClient myWebClient = new WebClient())
275-
{
297+
{
276298
myWebClient.DownloadFile(AutoInstallRoutes[AutoInstallRouteName].Image, ImageTempFilename);
277-
}
299+
}
278300
if (File.Exists(ImageTempFilename))
279301
{
280302
pictureBoxAutoInstallRoute.Image = new Bitmap(ImageTempFilename);
@@ -1094,7 +1116,11 @@ void buttonAutoInstallOK_Click(object sender, EventArgs e)
10941116
private void DisableAutoInstallButtons()
10951117
{
10961118
setCursorToWaitCursor();
1119+
DisableAutoInstallButtonsWithoutWait();
1120+
}
10971121

1122+
private void DisableAutoInstallButtonsWithoutWait()
1123+
{
10981124
dataGridViewAutoInstall.Enabled = false;
10991125
textBoxAutoInstallPath.Enabled = false;
11001126
buttonAutoInstallBrowse.Enabled = false;
@@ -1119,9 +1145,9 @@ private void EnableAutoInstalButtons()
11191145
dataGridViewAutoInstall.Enabled = true;
11201146
textBoxAutoInstallPath.Enabled = true;
11211147
buttonAutoInstallBrowse.Enabled = true;
1122-
buttonAutoInstallInfo.Enabled = true;
1123-
buttonAutoInstallInstall.Enabled = !route.Installed;
1124-
buttonAutoInstallUpdate.Enabled = route.Installed && (route.getDownloadType() == ContentRouteSettings.DownloadType.github);
1148+
buttonAutoInstallInfo.Enabled = !NoInternet;
1149+
buttonAutoInstallInstall.Enabled = !(route.Installed || NoInternet);
1150+
buttonAutoInstallUpdate.Enabled = route.Installed && (route.getDownloadType() == ContentRouteSettings.DownloadType.github) && !NoInternet;
11251151
buttonAutoInstallDelete.Enabled = route.Installed;
11261152
buttonOK.Enabled = true;
11271153

Source/Orts.Settings/ContentRouteSettings.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public ContentRouteSettings()
120120
Routes = new Dictionary<string, Route>();
121121
}
122122

123-
public void LoadContent()
123+
public void LoadContent(ref string errorMsg)
124124
{
125125
// only for debug purposes
126126
string definedContentJsonName = @"c:\content\routes.json";
@@ -142,8 +142,8 @@ public void LoadContent()
142142
definedContentJsonName = Path.Combine(definedContentJsonDirectoryName, "routes.json");
143143
}
144144
catch (Exception error)
145-
{
146-
throw new Exception("Error during retrieving routes.json from \"" + githubUrl + "\": " + error.Message, error);
145+
{
146+
errorMsg = error.Message;
147147
}
148148
}
149149

0 commit comments

Comments
 (0)