Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Possible Bug?  (Read 2633 times)
Nelson
Community Member
*
Posts: 47


« on: January 17, 2006, 10:35:07 PM »

Hello,

Let me say you guys have quite an engine here so good job with that! I however am having a really weird problem and I'm not sure if it's just a quirk in my code or a bug in the engine.

Background info: I'm writing a GUI library for a game I'm writing and I'm using the 2D features of TV3D to do so.

Now the logic behind the code is: Pass an object as a paramater to "AddWindow" which in term adds it to a collection and in the render loop renders all the windows in that collection

So I call
Code:

    Dim tmpWindow As New clsWinObj
    Dim tmpWindow1 As New clsWinObj
   
    tmpWindow.SetWindowTitle = "My Test Window"
    tmpWindow.SetWindowHeight = 500
    tmpWindow.SetWindowWidth = 300
    tmpWindow.SetXPos = 100
    tmpWindow.SetYPos = 120
    tmpWindow.SetWindowFlags = 0
   
    Call stUI.CreateWindow(tmpWindow)

    tmpWindow1.SetWindowTitle = "My Test Window2"
    tmpWindow1.SetWindowHeight = 500
    tmpWindow1.SetWindowWidth = 300
    tmpWindow1.SetXPos = 800
    tmpWindow1.SetYPos = 120
    tmpWindow1.SetWindowFlags = 0
   
    Call stUI.CreateWindow(tmpWindow1)


To create the two windows and pass it to the class stUI to create a window
Now in stUI I have

Code:

Public Sub CreateWindow(WinObj As Object)
    stWindowCol.WinCol.Add WinObj
End Sub

Public Sub RedrawGUI()
    Dim i As Integer
   
    For i = 1 To stWindowCol.WinCol.Count Step 1

        Set CurObj = stWindowCol.WinCol.Item(i)
       
        ST_Screen.ACTION_Begin2D
        ST_Screen.DRAW_FilledBox CurObj.GetXPos, CurObj.GetYPos, CurObj.GetWindowWidth, _
                           CurObj.GetWindowHeight, RGBA(&H8B, &H68, &H0, 0.5)
        ST_Screen.DRAW_Box CurObj.GetXPos, CurObj.GetYPos, CurObj.GetWindowWidth, _
                           CurObj.GetWindowHeight, -1
       
        ST_Text.NormalFont_DrawText CurObj.GetWindowTitle, CurObj.GetXPos + 25, CurObj.GetYPos + 3, -1
        ST_Screen.ACTION_End2D
       
        Set CurObj = Nothing
    Next i
   
End Sub


AddWindow adds it to a collection and RedrawGUI redraws all the windows according to the values set in the Window Object.

Here is the code for the window object which is instanced and added to the collection:
Code:

Private Title As String
Private Flags As Long

Private Width As Integer
Private Height As Integer
Private XPos As Integer
Private YPos As Integer

Public Property Get GetWindowTitle() As String
    GetWindowTitle = Title
End Property
           
Public Property Let SetWindowTitle(WinTitle As String)
    Title = WinTitle
End Property

Public Property Get GetWindowFlags() As Long
    GetWindowFlags = Flags
End Property
           
Public Property Let SetWindowFlags(WinFlags As Long)
    Flags = WinFlags
End Property

Public Property Get GetWindowWidth() As Long
    GetWindowWidth = Width
End Property
           
Public Property Let SetWindowWidth(WinWidth As Long)
    Width = WinWidth
End Property

Public Property Get GetWindowHeight() As Long
    GetWindowHeight = Height
End Property
           
Public Property Let SetWindowHeight(WinHeight As Long)
    Height = WinHeight
End Property

Public Property Get GetXPos() As Long
    GetXPos = XPos
End Property
           
Public Property Let SetXPos(WinXPos As Long)
    XPos = WinXPos
End Property

Public Property Get GetYPos() As Long
    GetYPos = YPos
End Property
           
Public Property Let SetYPos(WinYPos As Long)
    YPos = WinYPos
End Property


Now when I run all of this I get a weird result, it seems as though the old width of the window is used as the XCoord for the new window when I obviously provide my own XCoord.  I have checked that the XCoords from both objects are what they should be upon draw as well.

Here is the result:

http://www.javaop.com/uploads/guest/TVWindowError.PNG

Can someone confirm this as an error and if it isn't one perhaps move this to development and help me troubleshoot my code? Thanks in advance.

- Nelson
Logged
Nelson
Community Member
*
Posts: 47


« Reply #1 on: January 18, 2006, 09:02:54 PM »

I'm beggining to think this is normal behavior, anyone know of any alternatives?
Logged
Lil`Buh
Community Member
*
Posts: 60


« Reply #2 on: January 19, 2006, 02:38:52 AM »

i ll try to figure out this tonight
tho i wouldn t have written the window class like that

i have to run to work Cry

see you Smiley
Logged
Nelson
Community Member
*
Posts: 47


« Reply #3 on: January 20, 2006, 09:27:51 AM »

It seems it's using the Width of the old window as the X of the new one..it also seems to be possibly adding the WindowY and WindowHeight together somehow..hard to explain it's REALLY weird.

Anyhow I updated the code to see if it would be fixed..it's really odd..

Code:

Option Explicit

Dim ScreenCanvas As TVScreen2DImmediate
Dim ScreenText As TVScreen2DText

Private BorderColor As Long
Private WinX As Long
Private WinY As Integer
Private WinWidth As Long
Private WinHeight As Long
Private WinCaption As String
Private IsFocused As Boolean

Public Sub Show()
        ScreenCanvas.DRAW_FilledBox WinX, WinY, WinWidth, WinHeight, RGBA(&H8B, &H68, &H0, 0.5)
        ScreenCanvas.DRAW_Box WinX, WinY, WinWidth, WinHeight, -1
       
        ScreenText.ACTION_BeginText
            ScreenText.NormalFont_DrawText WinCaption, WinX + 3, WinY + 3, -1
        ScreenText.ACTION_EndText
End Sub

Public Property Get Caption() As String
    Caption = WinCaption
End Property

Public Property Let Caption(ByVal myCaption As String)
    WinCaption = myCaption
End Property

Public Property Get XPos() As Long
    XPos = WinX
End Property

Public Property Let XPos(ByVal myXPos As Long)
    WinX = myXPos
End Property

Public Property Get YPos() As Long
    YPos = WinY
End Property

Public Property Let YPos(ByVal myYPos As Long)
    WinY = myYPos
End Property

Public Property Get Width() As Long
    Width = WinWidth
End Property

Public Property Let Width(ByVal myWidth As Long)
    WinWidth = myWidth
End Property

Public Property Get Height() As Long
    Height = WinHeight
End Property

Public Property Let Height(ByVal myHeight As Long)
    WinHeight = myHeight
End Property

Private Sub Class_Initialize()
    Set ScreenCanvas = New TVScreen2DImmediate
    Set ScreenText = New TVScreen2DText
End Sub

Private Sub Class_Terminate()
    Set ScreenCanvas = Nothing
    Set ScreenText = Nothing
End Sub


I call it forth using:

Code:

    Set MyWindows(0) = New clsWinObj
    Set MyWindows(1) = New clsWinObj

    MyWindows(0).XPos = 100
    MyWindows(0).YPos = 200
    MyWindows(0).Width = 300
    MyWindows(0).Height = 100
    MyWindows(0).Caption = "Test Window"

    MyWindows(1).XPos = 600
    MyWindows(1).YPos = 300
    MyWindows(1).Width = 300
    MyWindows(1).Height = 100
    MyWindows(1).Caption = "Test Window 2"


and in the loop:

Code:

            MyWindows(0).Show
            MyWindows(1).Show


And here's a screenshot:
http://www.javaop.com/uploads/guest/WindowErrWithTV3D.PNG

Also, I downloaded the "Lite" installation so is there any chance of maybe it's a badly compiled version? Of course I wouldn't want to blame the engine so fast if it's an error on my part.
Logged
Lil`Buh
Community Member
*
Posts: 60


« Reply #4 on: January 20, 2006, 02:21:57 PM »

i ve started working on your problem Smiley hang on Wink

( note i m writing it in VB.NET express edition wich is free, not much syntax changes execpt in the properties of the classes Smiley u ll be able to convert it easlily Smiley )

EDIT :

http://lilbuh.free.fr/tvgui.png

here's the full code:

the Window Class

Code:

Public Class clsGuiWindow

    Private m_Title As String
    Private m_Flags As Long
    Private m_size As Size
    Private m_location As System.Drawing.Point
    Private m_BackColor As Integer = oGlobals.RGBA(0.9, 0.9, 0.9, 1)
    Private m_FontColor As Integer = oGlobals.RGBA(1, 1, 1, 1)
    Public Property GetWindowTitle() As String
        Get
            Return m_Title
        End Get
        Set(ByVal value As String)
            m_Title = value
        End Set
    End Property

    Public Property GetWindowFlags() As Long
        Get
            Return m_Flags
        End Get
        Set(ByVal value As Long)
            m_Flags = value
        End Set
    End Property

    Public Property Size() As Size
        Get
            Return m_Size
        End Get
        Set(ByVal value As Size)
            m_size = value
        End Set
    End Property

    Public Property Location() As System.Drawing.Point
        Get
            Return m_location
        End Get
        Set(ByVal value As System.Drawing.Point)
            m_location = value
        End Set
    End Property

    Public Property BackColor() As Integer
        Get
            Return m_BackColor
        End Get
        Set(ByVal value As Integer)
            m_BackColor = value
        End Set
    End Property

    Public Property FontColor() As Integer
        Get
            Return m_FontColor
        End Get
        Set(ByVal value As Integer)
            m_FontColor = value
        End Set
    End Property

    Public Sub Render()
        o2D.ACTION_Begin2D()
        o2D.DRAW_FilledBox(m_location.X, m_location.Y, m_location.X + m_size.Width, m_location.Y + m_size.Height, m_BackColor)

        'White Lines
        o2D.DRAW_Line(m_location.X + 1, m_location.Y + 1, m_location.X + 1, m_location.Y + m_size.Height - 2, oGlobals.RGBA(1, 1, 1, 1))
        o2D.DRAW_Line(m_location.X + 1, m_location.Y + 1, m_location.X + m_size.Width - 2, m_location.Y + 1, oGlobals.RGBA(1, 1, 1, 1))

        'Gray Lines
        o2D.DRAW_Line(m_location.X + m_size.Width - 2, m_location.Y + 1, m_location.X + m_size.Width - 2, m_location.Y + m_size.Height - 2, oGlobals.RGBA(0.5, 0.5, 0.5, 1))
        o2D.DRAW_Line(m_location.X + m_size.Width - 1, m_location.Y + m_size.Height - 2, m_location.X + 1, m_location.Y + m_size.Height - 2, oGlobals.RGBA(0.5, 0.5, 0.5, 1))
        'Black Lines
        o2D.DRAW_Line(m_location.X + m_size.Width - 1, m_location.Y, m_location.X + m_size.Width - 1, m_location.Y + m_size.Height - 1, oGlobals.RGBA(0, 0, 0, 1))
        o2D.DRAW_Line(m_location.X + m_size.Width - 1, m_location.Y + m_size.Height - 1, m_location.X, m_location.Y + m_size.Height - 1, oGlobals.RGBA(0, 0, 0, 1))

        'Title Bar
        o2D.DRAW_FilledBox(m_location.X + 3, m_location.Y + 3, m_location.X + m_size.Width - 3, m_location.Y + 20, oGlobals.RGBA(0, 0, 0.5, 1), oGlobals.RGBA(0.651, 0.792, 0.941, 1), oGlobals.RGBA(0, 0, 0.5, 1), oGlobals.RGBA(0.651, 0.792, 0.941, 1))

        oText.NormalFont_DrawText(m_Title, m_location.X + 5, m_location.Y + 5, m_FontColor)
        o2D.ACTION_End2D()
    End Sub
End Class


the GUI Class

Code:

Public Class clsGui

    Private stWindowCol As New Collection

    Public Sub CreateWindow(ByVal win As clsGuiWindow)
        stWindowCol.Add(win)
    End Sub

    Public Sub RedrawGUI()
        Dim window As New clsGuiWindow
        For Each window In stWindowCol
            window.Render()
        Next
    End Sub
End Class


The Render Loop:

Code:


        Dim gui As New clsGui
        Dim myWindow1 As New clsGuiWindow
        Dim myWindow2 As New clsGuiWindow

        myWindow1.Location = New System.Drawing.Point(10, 20)
        myWindow1.Size = New Size(200, 100)
        myWindow1.GetWindowTitle = "My Window 1"

        myWindow2.Location = New System.Drawing.Point(150, 150)
        myWindow2.Size = New Size(200, 200)
        myWindow2.GetWindowTitle = "My Window 2"
        gui.CreateWindow(myWindow1)
        gui.CreateWindow(myWindow2)


        Do
            Application.DoEvents()
            oTV.Clear()

            gui.RedrawGUI()

            oTV.RenderToScreen()

        Loop Until oInput.IsKeyPressed(TrueVision3D.CONST_TV_KEY.TV_KEY_ESCAPE) = True

        Engine_CleanUp()

Logged
Nelson
Community Member
*
Posts: 47


« Reply #5 on: January 20, 2006, 09:04:53 PM »

Wow that's some pretty code you have there. Nice!

I actually figured my error out, it seems that the width of the object was added to the XValue (as well as the height) so I'd need to take that into account when creating the window. Pretty odd but okay.

Anyhow, I got everything working nicely, input etc..
Thanks!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks