MaxGui - Q&A

BlitzMax Forums/BlitzMax Programming/MaxGui - Q&A

Sean Doherty(Posted 2006) [#1]
I'm going to do a title screen in MaxGui? I assume the following:

- Load the background image with standard BlitzMax command LoadImage.
- Draw the background image with a standard BlitzMax Command Draw Image.
- If the menu is going to be in a window I need to use Panels with SetPanelPixelMap.
- I use CreateButton to create the Buttons for my menu?

I don't see how to create Custom Image Buttons?

Thanks


Sean Doherty(Posted 2006) [#2]
Also, do I have to create a window to create a panel or can I just pass it null?


skidracer(Posted 2006) [#3]
Buttons are intended for windows style forms and requesters.

For anything fancy try an active panel or canvas using the documented mouse events for detecting when they are "pressed".


Sean Doherty(Posted 2006) [#4]
Also, how do I render the panel over and over with page flipping? Or do I have to stop page flipping when using MaxGUI?

Thanks


assari(Posted 2006) [#5]
Sean, have you gone thru the MaxGUI tutorials? Specifically this http://www.2dgamecreators.com/maxgui/Mouseevents.html


WendellM(Posted 2006) [#6]
Hi, Sean. It's quite possible to do a GUI title screen with panels/buttons. Image buttons can be fairly easily handled in Windows with some win32 calls. For a cross-platform solution, you'd need to simulate image buttons using only MaxGUI commands (an old example: MaxGUI Panel Image Buttons).

You don't need to worry about Flip for panel images. Panels are redrawn automatically when covered/uncovered.

A sample title screen using the win32 approach:

Strict

Local window:TGadget = CreateWindow( "Title Screen Test", 200,200, 300,180, Null,..
  WINDOW_TITLEBAR | WINDOW_CLIENTCOORDS )

Local panel:TGadget = CreatePanel( 0,0, 600,360, window )
SetPanelPixmap( panel,LoadPixmap( "background.jpg" ) )

' with 64 x 32 images, button size is 64+4 x 32+4
Local btn1:TGadget = CreateImageButton( "button1.bmp", 10,10, 64+4,32+4, panel )
Local btn2:TGadget = CreateImageButton( "button2.bmp", 10,60, 64+4,32+4, panel )

Repeat
	WaitEvent
	If EventID() = EVENT_GADGETACTION Then
		If EventSource() = btn1 Then Notify ("Button 1 pressed")
		If EventSource() = btn2 Then Notify ("Button 2 pressed") 
	EndIf
Until EventID() = EVENT_WINDOWCLOSE

End



Function CreateImageButton:TGadget( imagefile$, x,y, width,height, group:TGadget )

	Extern "win32"
		Function LoadImageA:Int (hInst%, lpsz$z, un1%, n1%, n2%, un2%)
		Function SetWindowLongA:Int ( hWnd%, Val%, Lng% )
		Function GetWindowLongA% ( hWnd%, Val% )
		Function SendMessageA% ( hWnd%, Msg%, wParam%, lParam% )
	End Extern
	
	Const LR_LOADFROMFILE = 16
	Const GWL_STYLE = -16
	Const BS_BITMAP = 128
	Const BM_SETIMAGE = 247
	Const IMAGE_BITMAP = 0
	Const IMAGE_ICON = 1
	
	Local i = LoadImageA( 0, imagefile$, IMAGE_BITMAP, 0,0, LR_LOADFROMFILE )
	If Not i Then Notify imagefile + " not found.", True ; End
	Local button:Tgadget = CreateButton( "", x,y, width,height, group )
	Local hbutton = QueryGadget( button, QUERY_HWND_CLIENT )
	Local flags = GetWindowLongA( hbutton, GWL_STYLE ) + BS_BITMAP
	SetWindowLongA hbutton, GWL_STYLE,flags
	SendMessageA hbutton, BM_SETIMAGE, IMAGE_BITMAP, i

	Return button
	
End Function
This produces:




Here's the media used in this example:

http://neonavis.com/wendellm/button1.bmp
http://neonavis.com/wendellm/button2.bmp
neonavis.com/wendellm/background.jpg


Sean Doherty(Posted 2006) [#7]
The tutorial site is cool. However, one thing is unclear. Do I have to create a window? Generally, full screen games do not have windows? How can I hide all the features of a window?


WendellM(Posted 2006) [#8]
If using MaxGUI, you'll need a window. However, you can make it titlebar-less/border-less and the same size as the desktop, which is sort of like fullscreen, but not quite (since you're forced to use desktop size): http://blitzbasic.com/Community/posts.php?topic=59941#668569


Sean Doherty(Posted 2006) [#9]
Well that was a total waste of time! I don't see any sense using MaxGUI for a full screen application because even though it is possible to fake full screen, your window is going to be the size of the desktop.

Basically, if you game is 1024 by 768 and your desktop is 1280 by 1024. The MaxGui part of the game will be 1280 by 1024!

I also have a version of IGlass; and it was a good library 6 months ago. However, with no updates in a long time and none really planned I wouldn't recommend using it.

Maybe, I'll code something custom. Really surprised there isn't more choices when it comes to BlitzMax GUI libraries.


WendellM(Posted 2006) [#10]
I understand your annoyance (been there myself <g>), but I think that the days of good ol' fixed-res, fullscreen games/apps may be numbered. With so many different aspect ratios for displays out there, the ability to rescale is becoming essential. For example, see http://blitzbasic.com/Community/posts.php?topic=60240 (and just try to ignore the football comments <g>).

While it's more work to develop scaleable apps/games, it does seem the "right" thing to do, since you can no longer impose 4:3 aspect ratio fullscreen without it looking stretched/cropped on the displays of those using widescreen monitors or many laptops. However, I don't think that there's anything like a consensus on the best approach yet.

As for GUI libraries, I liked XLnt ii for Blitz3D since the source was included. That way, even if a feature weren't included, I could kludge it in. With pre-compiled BlitzMax modules, though, you're forced to rely on the module's developer to make adjustments.


Russell(Posted 2006) [#11]
Of course, you can do real full screen games without using MaxGUI and just write your own very simple button gadget routines to work in Graphics mode (This can be done easily: I've done it, it looks good, and I am by no means an expert).

That being said, however, I do agree that Image buttons should be supported cross-platform, since I believe this feature is indeed available natively on all OSes.

Russell


Sean Doherty(Posted 2006) [#12]
WendellM,

I don't want to get into the wide screen monitor debate. So lets just say that I decided to write my game for 1024 by 768 full screen.

Likely, 800 by 600 and 1024 by 768 are the two most popular formats for games currently being played. Shouldn't MaxGUI support these modes so I can do a %^&$ title screen without having the computer default back to the size of the users desktop? I mean it seems insane that it doesn't? BlitzMax is a game development language more than anything else?

On the IGlass front, you get a lot of the source. That said, do you really want to alter the source of a GUI library that is hopefully going to come out with new releases? I would prefer to apply the new release without having to reapply a bunch of custom code.

Thanks


WendellM(Posted 2006) [#13]
I don't think that lack of fullscreen support is a MaxGUI problem - I believe(?) that's a limitation of Windows. I don't recall ever seeing a true fullscreen app using native Windows gadgets.

Good to know about some source being included with IGlass, thanks. Naturally I'd prefer not to have to customize stuff that'd require me to manually update it with each new official update, but being able to is a helpful fallback. For example, with XLnt, I once needed the ability to have controls floating in a transparent window, so I just stuck a few Alphas where they did the most good and hey-presto! <g> And now that Yappy has seemingly gone away, I still have the ability to make any future updates I might need to XLnt since I have full source.