private static RenderOverlaySolid ( double ax, double ay, double bx, double by ) : void | ||
ax | double | |
ay | double | |
bx | double | |
by | double | |
Результат | void |
// // DRAW LOADING SCREEN // /// <summary>Draws on OpenGL canvas the route/train loading screen</summary> internal static void DrawLoadingScreen() { // begin HACK // if (!BlendEnabled) { GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); BlendEnabled = true; } if (LightingEnabled) { GL.Disable(EnableCap.Lighting); LightingEnabled = false; } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.PushMatrix(); // fill the screen with background colour GL.Color4(bkgR, bkgG, bkgB, bkgA); Renderer.RenderOverlaySolid(0.0, 0.0, (double)Screen.Width, (double)Screen.Height); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); // BACKGROUND IMAGE int fontHeight = (int)Fonts.SmallFont.FontSize; int logoBottom; // int versionTop; int halfWidth = Screen.Width / 2; if (TextureLoadingBkg != null) { int bkgHeight, bkgWidth; // stretch the background image to fit at least one screen dimension double ratio = (double)TextureLoadingBkg.Width / (double)TextureLoadingBkg.Height; if (Screen.Width / ratio > Screen.Height) // if screen ratio is shorter than bkg... { bkgHeight = Screen.Height; // set height to screen height bkgWidth = (int)(Screen.Height * ratio); // and scale width proprtionally } else // if screen ratio is wider than bkg... { bkgWidth = Screen.Width; // set width to screen width bkgHeight = (int)(Screen.Width / ratio); // and scale height accordingly } // draw the background image down from the top screen edge DrawRectangle(TextureLoadingBkg, new Point((Screen.Width - bkgWidth) / 2, 0), new Size(bkgWidth, bkgHeight), Color128.White); } // if the route has no custom loading image, add the openBVE logo // (the route custom image is loaded in OldParsers/CsvRwRouteParser.cs) if (!customLoadScreen) { if (TextureLogo != null) { // place the centre of the logo at from the screen top int logoTop = (int)(Screen.Height * logoCentreYFactor - TextureLogo.Height / 2.0); logoBottom = logoTop + TextureLogo.Height; DrawRectangle(TextureLogo, new Point((Screen.Width - TextureLogo.Width) / 2, logoTop), new Size(TextureLogo.Width, TextureLogo.Height), Color128.White); } } else { // if custom route image, no logo and leave a conventional black area below the potential logo } logoBottom = Screen.Height / 2; // take the height remaining below the logo and divide in 3 horiz. parts int blankHeight = (Screen.Height - logoBottom) / 3; // VERSION NUMBER // place the version above the first division int versionTop = logoBottom + blankHeight - fontHeight; DrawString(Fonts.NormalFont, "API Version: " + RAGLINKCommons.RPlatform.SettingsContent.simulatorVersion.ToString(), new Point(65, 5), TextAlignment.TopMiddle, Color128.White); // for the moment, do not show any URL; would go right below the first division // DrawString(Fonts.SmallFont, "https://sites.google.com/site/openbvesim/home", // new Point(halfWidth, versionTop + fontHeight+2), // TextAlignment.TopMiddle, Color128.White); // PROGRESS MESSAGE AND BAR // place progress bar right below the second division //int progressTop = Screen.Height - blankHeight; int progressTop = Screen.Height - 6; //int progressWidth = Screen.Width - progrMargin * 2; int progressWidth = Screen.Width; double routeProgress = Math.Max(0.0, Math.Min(1.0, Loading.RouteProgress)); double trainProgress = Math.Max(0.0, Math.Min(1.0, Loading.TrainProgress)); // sum of route progress and train progress arrives up to 2.0: // => times 50.0 to convert to % double percent = 50.0 * (routeProgress + trainProgress); string percStr = percent.ToString("0") + "%"; // draw progress message right above the second division string text = Translations.GetInterfaceString( routeProgress < 1.0 ? "loading_loading_route" : (trainProgress < 1.0 ? "loading_loading_train" : "message_loading")) + " (" + percStr + ")"; DrawString(Fonts.NormalFont, text, new Point(halfWidth, progressTop - fontHeight - 8), TextAlignment.TopMiddle, Color128.White); // progress frame //DrawRectangle(null, new Point(progrMargin-progrBorder, progressTop-progrBorder), // new Size(progressWidth+progrBorder*2, fontHeight+6), Color128.White); // progress bar DrawRectangle(null, new Point(0, progressTop), new Size(progressWidth * (int)percent / 100, fontHeight + 4), ColourProgressBar); // progress percent //DrawString(Fonts.SmallFont, percStr, new Point(halfWidth, progressTop), // TextAlignment.TopMiddle, Color128.Black); GL.PopMatrix(); }
// // DRAW MENU // /// <summary>Draws the current menu as a screen overlay</summary> internal void Draw() { int i; if (CurrMenu < 0 || CurrMenu >= Menus.Length) { return; } SingleMenu menu = Menus[CurrMenu]; // overlay background GL.Color4(overlayColor.R, overlayColor.G, overlayColor.B, overlayColor.A); Renderer.RenderOverlaySolid(0.0, 0.0, (double)Screen.Width, (double)Screen.Height); GL.Color4(1.0f, 1.0f, 1.0f, 1.0f); // HORIZONTAL PLACEMENT: centre the menu in the main window int itemLeft = (Screen.Width - menu.ItemWidth) / 2; // item left edge // if menu alignment is left, left-align items, otherwise centre them in the screen int itemX = (menu.Align & TextAlignment.Left) != 0 ? itemLeft : Screen.Width / 2; int menuBottomItem = menu.TopItem + visibleItems - 1; // draw the menu background GL.Color4(backgroundColor.R, backgroundColor.G, backgroundColor.B, backgroundColor.A); Renderer.RenderOverlaySolid(menuXmin - MenuBorderX, menuYmin - MenuBorderY, menuXmax + MenuBorderX, menuYmax + MenuBorderY); // if not starting from the top of the menu, draw a dimmed ellipsis item if (menu.Selection == menu.TopItem - 1 && !isCustomisingControl) { GL.Color4(highlightColor.R, highlightColor.G, highlightColor.B, highlightColor.A); Renderer.RenderOverlaySolid(itemLeft - MenuItemBorderX, menuYmin /*-MenuItemBorderY*/, itemLeft + menu.ItemWidth + MenuItemBorderX, menuYmin + em + MenuItemBorderY * 2); } if (menu.TopItem > 0) { Renderer.DrawString(MenuFont, "...", new Point(itemX, menuYmin), menu.Align, ColourDimmed, false); } // draw the items int itemY = topItemY; for (i = menu.TopItem; i <= menuBottomItem && i < menu.Items.Length; i++) { if (menu.Items[i] == null) { continue; } if (i == menu.Selection) { // draw a solid highlight rectangle under the text // HACK! the highlight rectangle has to be shifted a little down to match // the text body. OpenGL 'feature'? GL.Color4(highlightColor.R, highlightColor.G, highlightColor.B, highlightColor.A); Renderer.RenderOverlaySolid(itemLeft - MenuItemBorderX, itemY /*-MenuItemBorderY*/, itemLeft + menu.ItemWidth + MenuItemBorderX, itemY + em + MenuItemBorderY * 2); // draw the text Renderer.DrawString(MenuFont, menu.Items[i].Text, new Point(itemX, itemY), menu.Align, ColourHighlight, false); } else if (menu.Items[i] is MenuCaption) { Renderer.DrawString(MenuFont, menu.Items[i].Text, new Point(itemX, itemY), menu.Align, ColourCaption, false); } else { Renderer.DrawString(MenuFont, menu.Items[i].Text, new Point(itemX, itemY), menu.Align, ColourNormal, false); } itemY += lineHeight; } if (menu.Selection == menu.TopItem + visibleItems) { GL.Color4(highlightColor.R, highlightColor.G, highlightColor.B, highlightColor.A); Renderer.RenderOverlaySolid(itemLeft - MenuItemBorderX, itemY /*-MenuItemBorderY*/, itemLeft + menu.ItemWidth + MenuItemBorderX, itemY + em + MenuItemBorderY * 2); } // if not at the end of the menu, draw a dimmed ellipsis item at the bottom if (i < menu.Items.Length - 1) { Renderer.DrawString(MenuFont, "...", new Point(itemX, itemY), menu.Align, ColourDimmed, false); } }