Jump to content

Rendering to the main menu.


Recoil

Recommended Posts

All I want to do at first is draw the background image, the menu panel, and 2 bars that are going to be used for buttons.  I will wrk out the threading on all this later, and maybe a better way to display it without a black screen initially.

I am initializing this stuff first in the same spot everything else is initialized.  I am calling the Render_Menu() at the top of the UpdateUI, before any of the panels that are there are drawn.

#Region "Imports"
Imports System.Drawing
Imports System.Windows.Forms
Imports System.IO
Imports OrionRevampedGeneral.Core.Constants
Imports OrionRevampedGeneral.Core.Enumerations
Imports SFML.Graphics
Imports SFML.Window
#End Region

Module ClientMenu

#Region "Constants"

    Public Const MENUWINDOW_PATH As String = "Menu\"

#End Region

#Region "Globals"

    Public MainMenuIsVisible As Boolean
    Public IpConfigIsVisible As Boolean
    Public CreditsIsVisible As Boolean
    Public LoginIsVisible As Boolean
    Public NewCharIsVisible As Boolean
    Public NewAccountIsVisible As Boolean

    Public MenuWindow As RenderWindow

    Public Background As OrionGfxControl

    Public MenuBackground As OrionGfxControl
    Public HeaderBar As OrionGfxControl
    Public SectionBar As OrionGfxControl
    Public MenuButton As OrionGfxControl

#End Region

#Region "Initilization"

    Public Sub InitMenuGraphics()

        'MenuWindow = New RenderWindow(frmMenu.MenuScreen.Handle)

        Background = New OrionGfxControl(False)
        If FileExist(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "Background" & GFX_EXT) Then
            Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "Background" & GFX_EXT)
            Background.Init(bmp)
        End If

        MenuBackground = New OrionGfxControl(False)
        If FileExist(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "MenuBackground" & GFX_EXT) Then
            Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "MenuBackground" & GFX_EXT)
            MenuBackground.Init(bmp)
        End If

        HeaderBar = New OrionGfxControl(False)
        If FileExist(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "HeaderBar" & GFX_EXT) Then
            Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "HeaderBar" & GFX_EXT)
            HeaderBar.Init(bmp)
        End If

        SectionBar = New OrionGfxControl(False)
        If FileExist(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "SectionBar" & GFX_EXT) Then
            Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "SectionBar" & GFX_EXT)
            SectionBar.Init(bmp)
        End If

        MenuButton = New OrionGfxControl(False)
        If FileExist(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "Button" & GFX_EXT) Then
            Dim bmp As New Bitmap(Application.StartupPath & GFX_PATH & MENUWINDOW_PATH & "Button" & GFX_EXT)
            MenuButton.Init(bmp)
        End If

    End Sub

#End Region

#Region "Drawing"

    Public Sub DrawMainMenu()

        ' Draw all main menu controls here
        MenuBackground.DrawControl(MenuWindow, MenuBackground.ControlLocation.X, MenuBackground.ControlLocation.Y)

        HeaderBar.DrawControl(MenuWindow, MenuBackground.ControlLocation.X, (MenuBackground.ControlLocation.Y + MenuBackground.ControlLocation.Height) - (HeaderBar.ControlLocation.Height))

        SectionBar.DrawControl(MenuWindow, (MenuWindow.Size.X / 2) - SectionBar.ControlLocation.Width / 2, MenuBackground.ControlLocation.Y + 10)

    End Sub

    Public Sub DrawIpConfig()

    End Sub

    Public Sub DrawCredits()

    End Sub

    Public Sub DrawLogin()

    End Sub

    Public Sub DrawNewChar()

    End Sub

    Public Sub DrawNewAccount()

    End Sub

#End Region

#Region "Rendering"

    Public Sub Render_Menu()

        If InGame Then Exit Sub

        DoEvents()

        MenuWindow.DispatchEvents()
        MenuWindow.Clear(SFML.Graphics.Color.Black)

        Background.DrawControl(MenuWindow, 0, 0)

        If MainMenuIsVisible Then
            DrawMainMenu()
        End If
        If IpConfigIsVisible Then
            'DrawIpConfig()
        End If
        If CreditsIsVisible Then
            'DrawCredits()
        End If
        If LoginIsVisible Then
            'DrawLogin()
        End If
        If NewCharIsVisible Then
            'DrawNewChar()
        End If
        If NewAccountIsVisible Then
            'DrawNewAccount()
        End If
        
        MenuWindow.Display()

    End Sub

#End Region

End Module

Right now this is slow, and very buggy.  The background draws as expected, but the panel background draws down at the bottom right, then shifts into place...then other controls pop onto it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...