Quote:
Originally Posted by Torankusu
I am making a mock up of an inventory system, and I want to have grid alignment.
Ex:
0 0 0 0
0 0 0 0
Not:
00 0 0
0 0 00
At the moment, I am using a frames control, And showimg for the icons (32x32 pix), and that works fine.
What I want to do, is, say for example I have an icon that id 32 pix wide, and 64 pixels in height. I need that to take up grid space like this:
0 0 X 0
0 0 X 0
Without allowing anything else To display in that slot (X's refer to 32x64 item.)
I have thought of checking for the width/height of the image and basically chopping it in two and displaying two halves (one half in each corresponding frame) but that seems messy.
|
If you already have a way to check the width/height of the images, when you set the amount per line to show read each one its putting in as it comes in a loop, and check the width/height there, set a temp.var in the order, then on the next line (i'd imagine also in your loop) do checks to see, and if it the temp.var is set, on that next line when the loop comes to it, make it null on that spot for the image, erase the temp.var, and if there are anymore the set above for the temp.var will reset it to the next one.
e.g.
PHP Code:
for (temp.i = 0; temp.i < array.size(); temp.i++) {
// set up a checker for what position in the line it is (#1 - 6 in each line)
if (!temp.itemPos) {
temp.itemPos = 0;
temp.line = 0;
}
// since this is for the line, if it's past the 6 max for the line, reset
if (itemPos > 6) {
itemPos = 0;
line++;
}
new GuiImgCtrl("whatever"@someID/Name) {
x = set x's
y = line + adjustment space here
// set everything else, including where you read for your width/height
}
// see if the width or height (or both) is more than 32
if (getimgwidth(whaterver.image) > 32) {
temp.checkW = true;
temp.checkWID = itemPos + 1;
}
if (getimgheight(whaterver.image) > 32) {
temp.checkH = true;
temp.checkHID = itemPos + 6;
}
// now check the width/height
if (checkW && itemPos == checkWID) {
this.checkW = false;
// set the next image to move over
(@"whatever"@someID/Name).x = adjust over to next;
itemPos += 2;
}else if (checkH && itemPos == checkHID) {
this.checkH = false;
// set the image under to move over when you get there
(@"whatever"@someID/Name).x = adjusted over 1 however u wanna do it;
itemPos += 2;
}else itemPos++;
// make sure to add the img ctrl to a parent, either a scroll or window.
}
I haven't tested the above, just going off how I would start. It may not be the best; I'm not the best scripter. Someone might have a better way.