Problem with 1.103
Archives Forums/Blitz3D Bug Reports/Problem with 1.103
| ||
| Sometimes it runs normal, but intermittently I get the message "Unable to set graphics mode", sometimes a few times in a row. PC Specs: Pentium 4 @ 3.0 GHZ GeForce 5200 FX @ 128 MB 512 MB Ram Using IDEal IDE Here's the piece of code I was testing.
;#Region Custom Types
Type Menu
Field menuName$
Field itemList$ ;Sub menu items
Field itemListVisible ;True = Show items : False = Hide items
Field x, y ;Screen coordinates of Menu
Field nameBoxWidth ;Width of menu name box
Field nameBoxHeight ;Height of menu name box
Field itemBoxWidth ;Width of item box
Field itemBoxHeight ;Height of item box
End Type
;#End Region
Function CreateMenu(x, y, menuName$, itemList$)
Local firstTag
Local lastTag
Local itemNameStart
Local itemNameEnd
Local itemNameLength
Local itemName$
Local nameWidth
Local m.Menu
m.Menu = New Menu
m\menuName$ = menuName$
m\itemList$ = itemList$
m\itemListVisible = False
m\x = x
m\y = y
m\itemBoxWidth = 0
m\itemBoxHeight = 0
;Loop until (opening) tag is found
For firstTag = 1 To Len(m\itemList$)
If Mid$(m\itemList$, firstTag, 1) = "["
;Loop Until (closing) tag is found
For lastTag = firstTag To Len(m\itemList$)
If Mid$(m\itemList$, lastTag, 1) = "]"
itemNameStart = (firstTag + 1)
itemNameEnd = lastTag
itemNameLength = (lastTag - firstTag) - 1
itemName$ = Mid$(m\itemList$, itemNameStart, itemNameLength)
nameWidth = StringWidth(itemName$)
If nameWidth > m\itemBoxWidth
m\itemBoxWidth = nameWidth
EndIf
m\itemBoxHeight = m\itemBoxHeight + StringHeight("")
firstTag = (lastTag + 1)
EndIf
Next
EndIf
Next
End Function
Function UpdateMenu()
Local m.Menu
For m.Menu = Each Menu
If MouseX() > m\x And MouseX() < (m\x + StringWidth(m\menuName$))
If MouseY() > m\y And MouseY() < (m\y + StringHeight(m\menuName$))
If MouseHit(1)
m\itemListVisible = m\itemListVisible Xor True
EndIf
EndIf
EndIf
Next
End Function
Function DrawMenu()
Local firstTag
Local lastTag
Local itemNameStart
Local itemNameEnd
Local itemNameLength
Local itemName$
Local m.Menu
Local itemX
Local itemY
For m.Menu = Each Menu
Color 0, 100, 255
Rect m\x, m\y, StringWidth(m\menuName$), StringHeight(m\menuName$), True
Color 255, 255, 255
Text m\x, m\y, m\menuName$
If m\itemListVisible = True
Color 0, 100, 255
Rect m\x, (m\y + StringHeight("")), m\itemBoxWidth, m\itemBoxHeight, True
EndIf
itemX = m\x
itemY = (m\y + StringHeight(""))
;Loop until (opening) tag is found
For firstTag = 1 To Len(m\itemList$)
If Mid$(m\itemList$, firstTag, 1) = "["
;Loop Until (closing) tag is found
For lastTag = firstTag To Len(m\itemList$)
If Mid$(m\itemList$, lastTag, 1) = "]"
itemNameStart = (firstTag + 1)
itemNameEnd = lastTag
itemNameLength = (lastTag - firstTag) - 1
itemName$ = Mid$(m\itemList$, itemNameStart, itemNameLength)
If m\itemListVisible = True
If MouseX() > itemX And MouseX() < (itemX + StringWidth(itemName))
If MouseY() > itemY And MouseY() < (itemY + StringHeight(itemName))
Color 255, 0, 0
HighlightItem(itemX, itemY, itemName$)
EndIf
EndIf
EndIf
Color 0, 0, 0
Text itemX, itemY, itemName$
itemY = itemY + StringHeight("")
firstTag = (lastTag + 1)
EndIf
Next
EndIf
Next
Next
End Function
Function HighlightItem(x, y, itemName$)
Rect x, y, StringWidth(itemName$), StringHeight(itemName$), True
End Function
Function DisposeMenu()
Local m.Menu
For m.Menu = Each Menu
Delete m
Next
End Function
Graphics 800, 600
SetBuffer BackBuffer()
Include "Pointer.bb"
CreateMenu(0, 0, "Menu1", "[MenuItem1][Item2][Item3][Item4]")
CreateMenu(100, 0, "Menu2", "[Item1][Item2][Item3]")
Repeat
UpdateMenu()
Cls
DrawMenu()
DrawPointer()
Flip
Until KeyHit(1)
DisposeMenu()
End
|
| ||
no problems here, try:Graphics 800, 600, 32, 1 bye |
| ||
| That seems to have cured it, thanx Bud. ;) |