Extend IGlass Window Problems
BlitzMax Forums/BlitzMax Programming/Extend IGlass Window Problems
| ||
Hi Filax and All, I've been working a bit with IGlass and I'm attempting to create a simple tilemap editor (I know, not another one!). However I'm attempting to Extend IGlass's basic window to create a simple tile selection window: ' This is a class that combines the IGlass elements to create a window that ' allows the selection of tiles. Include "../IGlass PC 1.5.1/IGL_Classe/Inc_IGlass.bmx" Type TileWindow Extends IGL_Window Field tilesWidth:Int = 0 Field tilesHeight:Int = 0 Field tileSize:Int = 0 Field numTiles:Int = 0 Field tiledImages:TImage Field sbarTexture:IGL_Scrollbar Method CreateIt:TileWindow(Caption:String,Px:Int,Py:Int,Tx:Int,Ty:Int, images:TImage, TileSize:Int, NumTiles:Int ) Self.tileSize = TileSize Self.numTiles = NumTiles tiledImages = images tilesWidth = Tx / tileSize tilesHeight = Ty / tileSize BLock:Byte=True 'Can be locked in place BMinimize:Byte=True 'Can be minimized BClose:Byte=True 'Can be closed ClassType:Int=IGL_NormalWindow 'Is a normal window Super.Create(Caption,Px,Py,Tx,Ty,BLock, BMinimize, BClose, ClassType) sbarTx:Int = 8 sbarPx:Int = sbarTx - 8 sbarTexture = IGL_Scrollbar.Create(Super,"",sbarPx,0,sbarTx,Ty,0.0,0.0,Float(NumTiles),1) Return Self End Method Method Refresh() 'Super.Refresh() 'Draw array of textures on texture window Local posx:Int = Px+5 Local posy:Int = Py+25 Local index:Int = sbarTexture.Value For Local x:Int = 0 To tilesWidth-1 For Local y:Int = 0 To tilesHeight-1 DrawImage( tiledImages, posx, posy, index ) index:+1 index:Mod numTiles posy:+tileSize Next posy = Py+tileSize posx:+tileSize Next End Method End Type 'Rem 'Test Harness Graphics 640, 480, 0 IGL_InitGUI(1) ' Build an editor window e.g. list of textures and scroll bar! Global wndTexture:TileWindow Global tileImage:TImage = LoadAnimImage("spiral.png", 32, 32, 0, 100, FILTEREDIMAGE|MASKEDIMAGE) 'CreateIt:TileWindow(Caption:String,Px:Int,Py:Int,Tx:Int,Ty:Int, images:TImage, TileSize:Int, NumTiles:Int ) wndTexture= New TileWindow.CreateIt("Textures",10,10,135,395,tileImage,32,100) ' Why does field not surface in child wndTexture.Alpha=1.0 While Not KeyHit(KEY_ESCAPE) Cls IGL_RefreshGUI() wndTexture.Refresh() Flip FlushMem Wend 'End Rem However I'm unable to get the new window to refresh without directly calling it's refresh method. I'm at a loss at the moment as this is basic OO stuff (althoght I've probably missed something;o)! So how do I extend a window and it's Refresh method to create my own windows? Regards Merx |
| ||
It's not very easy because the Window widget is the BASE of all widget :) but write me a detailled email with your request, i'll see what can i do for you :) maybe a new control creation is possible :) Maybe a canvas system is possible :) But for the moment blitzmax have not a "camera viewport like command" but maybe it's possible to pass by an image ? It is really a problem to use screen for build map with tile (don't forget that IGlass can pas control directly on the screen ! :) ? See ya :) |
| ||
BlitzMax does have viewport commands currently: SetViewport( x, y, width, height ) and GetViewport( x Var, y Var, width Var, height Var ) Muttley |
| ||
Yes i know :) i use them massively under Iglass, but it's only a drawing part of the screen. not a really drawing viewport like setcamera viewport like blitz3D. |
| ||
Hi I've resolved the problem! I changed the IGL_Window Create Function in IGlass to use a Setup Method that does all the work. So now I can create a TileWindow that includes images and works within Filax's refresh framework! Now I just have to tidy up the layout and I can try and get the map editor to work. |
| ||
Iglass + object power + your creativity = no problem :) |
| ||
Ahm when done merx, could u post an easy example? I'm still trying to find an easy way for displaying and changeing and title map within a window.... |
| ||
Here's an example, it's still a work in progress. Remember you need to make the changes I mentiond previously to IGlass's IGL_Window class before this will work! ' This is a class that combines the IGlass elements to create a window that ' allows the selection of tiles. Include "../IGlass_1.5.2/IGL_Classe/Inc_IGlass.bmx" Type TileWindow Extends IGL_Window Field tilesWidth:Int = 0 Field tilesHeight:Int = 0 Field tileSize:Int = 0 Field numTiles:Int = 0 Field tiledImages:TImage Field sbarTexture:IGL_Scrollbar Function CreateIt:TileWindow(Caption:String, Px:Int, Py:Int, Tx:Int, Ty:Int) Local NewWindow:TileWindow NewWindow=New TileWindow BLock:Byte=True 'Can be locked in place BMinimize:Byte=True 'Can be minimized BClose:Byte=True 'Can be closed ClassType:Int=IGL_NormalWindow 'Is a normal window NewWindow.Setup(Caption,Px,Py,Tx,Ty,BLock, BMinimize, BClose, ClassType) Return NewWindow End Function Method SetImages(images:TImage, TileSize:Int, NumTiles:Int ) Self.tileSize = TileSize Self.numTiles = NumTiles tiledImages = images tilesWidth = Tx / tileSize tilesHeight = Ty / tileSize sbarTx:Int = 16 sbarPx:Int = sbarTx - 16 sbarTexture = IGL_Scrollbar.Create(Super,"",sbarPx,0,sbarTx,Ty-2,0.0,0.0,Float(NumTiles),1,True) End Method Method Refresh() DebugLog("TileWindow Refresh"+sbarTexture.Value) Super.Refresh() 'Draw array of textures on texture window Local posx:Int = Px+16 Local posy:Int = Py+22 Local index:Int = sbarTexture.Value index:Mod numTiles For Local x:Int = 0 To tilesWidth-1 For Local y:Int = 0 To tilesHeight-1 DrawImage( tiledImages, posx, posy, index ) index:+1 index:Mod numTiles posy:+tileSize Next posy = Py+22 posx:+tileSize Next End Method End Type 'Rem 'Test Harness Graphics 640, 480, 0 IGL_InitGUI(1) ' Build an editor window e.g. list of textures and scroll bar! Global wndTexture:TileWindow Global tileImage:TImage = LoadAnimImage("C:\spiral.png", 32, 32, 0, 100, FILTEREDIMAGE|MASKEDIMAGE) 'CreateIt:TileWindow(Caption:String,Px:Int,Py:Int,Tx:Int,Ty:Int, images:TImage, TileSize:Int, NumTiles:Int ) wndTexture= New TileWindow.CreateIt("Textures",10,10,145,415) wndTexture.setImages(tileImage,32,100) ' Why does field not surface in child wndTexture.Alpha=1.0 While Not KeyHit(KEY_ESCAPE) Cls IGL_RefreshGUI() wndTexture.Refresh() Flip FlushMem Wend 'End Rem |
| ||
If you need any further code example you can look at http://www.blitzbasic.com/Community/posts.php?topic=48222 It's an editor I build with iGlass that includes a tile selection window. |