@@ -364,7 +364,11 @@ private void InitializeData()
364364 var maxsize = maxX - minX > maxY - minY ? maxX - minX : maxY - minY ;
365365 // Take up to next 500
366366 maxsize = ( int ) ( ( maxsize / 100 ) + 1 ) * 500 ;
367- mapResolutionUpDown . Maximum = ( decimal ) maxsize ;
367+ if ( ( decimal ) maxsize < mapResolutionUpDown . Maximum )
368+ {
369+ // do not make maximum larger then the maximum defined in the Designer
370+ mapResolutionUpDown . Maximum = ( decimal ) maxsize ;
371+ }
368372 Inited = true ;
369373
370374 if ( simulator . TDB == null || simulator . TDB . TrackDB == null || simulator . TDB . TrackDB . TrItemTable == null )
@@ -1345,7 +1349,12 @@ void UITimer_Tick(object sender, EventArgs e)
13451349 if ( Viewer . MapViewerEnabledSetToTrue )
13461350 {
13471351 GenerateView ( ) ;
1348- GameForm . Focus ( ) ;
1352+ if ( ! mapBehindGameForm ( ) )
1353+ {
1354+ // do not return focus to the main OR game window
1355+ // when map is (partially) overlapping the game window
1356+ GameForm . Focus ( ) ;
1357+ }
13491358 Viewer . MapViewerEnabledSetToTrue = false ;
13501359 }
13511360
@@ -1357,6 +1366,25 @@ void UITimer_Tick(object sender, EventArgs e)
13571366 GenerateView ( ) ;
13581367 }
13591368
1369+ private bool mapBehindGameForm ( )
1370+ {
1371+ int mapX0 = Bounds . X ;
1372+ int mapY0 = Bounds . Y ;
1373+ int mapX1 = mapX0 + Size . Width ;
1374+ int mapY1 = mapY0 + Size . Height ;
1375+
1376+ int gameX0 = GameForm . Bounds . X ;
1377+ int gameY0 = GameForm . Bounds . Y ;
1378+ int gameX1 = gameX0 + GameForm . Size . Width ;
1379+ int gameY1 = gameY0 + GameForm . Size . Height ;
1380+
1381+ return
1382+ ( ( ( mapX0 > gameX0 ) && ( mapX0 < gameX1 ) ) && ( ( mapY0 > gameY0 ) && ( mapY0 < gameY1 ) ) ) ||
1383+ ( ( ( mapX0 > gameX0 ) && ( mapX0 < gameX1 ) ) && ( ( mapY1 > gameY0 ) && ( mapY1 < gameY1 ) ) ) ||
1384+ ( ( ( mapX1 > gameX0 ) && ( mapX1 < gameX1 ) ) && ( ( mapY0 > gameY0 ) && ( mapY0 < gameY1 ) ) ) ||
1385+ ( ( ( mapX1 > gameX0 ) && ( mapX1 < gameX1 ) ) && ( ( mapY1 > gameY0 ) && ( mapY1 < gameY1 ) ) ) ;
1386+ }
1387+
13601388 private void allowJoiningCheckbox_CheckedChanged ( object sender , EventArgs e )
13611389 {
13621390 MPManager . Instance ( ) . AllowNewPlayer = allowJoiningCheckbox . Checked ;
0 commit comments