Hi guys, hi Rob,
I'm currently working on the UI part of my game. I came across an issue when I wanted to place all UI images in a cell sheet. I'll describe my findings below and would be happy to discuss the optimal solution with you.
Initial situation:
My UI consists of many different graphical elements like buttons, sliders, windows, separators, etc. Each of these is a separate image. Instead of having many image files which must be loaded separately I want to use a cell sheet. In a cell sheet all images are in one file and the IgeCellSheet._cells[] array contains the coordinates of every single image.
1) I used the program TexturePacker to create the cell sheet and Stuart's TexturePacker Atlas loader (thanks Stuart btw!) to load the cell data. So far everything worked fine.
2) My problems started when I tried to use IgeEntity.cellById() to reference a specific cell image from the cell sheet. It doesn't work because IgeUiEntity stores the texture in ._patternTexture and not in ._texture as is required by cellById().
3) When digging further to find the reason for that I realized that IgeUiEntity is duplicating quite a lot from IgeEntity, for example the pattern fill code, but is missing other things from IgeEntity such as the caching functionality.
Now I see the following possible solutions:
a) I could extend IgeEntity and write my own UI classes. I would more or less duplicate Rob's work, especially the part with applying different styles.
b) I could change the IgeUiEntity implementation to use IgeEntity's texture rendering code. I would probably have to extend it (or IgeTexture's rendering code respectively) to provide for the other rendering features currently present in IgeUiEntity. As there is already a TON of dependencies on IgeEntity I'm a bit worried I might break some functionality.
c) I could write my own cellById() implementation that works with IgeUiEntity._patternTexture.
What do you guys think? From an architectural perspective it doesn't make much sense that the rendering code is duplicated in IgeUiEntity, right? Would you create a feature branch in Git and adapt this whole part?
Looking forward to reading your comments,
Christian