Hi everyone! After a 3+ year abscence, I decided to come back and make yet another game! Glad to see the forums still alive.
I have a work in progress game in which I, with a loooooot of help (like 95%), managed to make a shop GUI to buy and sell items, which can get grouped by quantity. For example, 6 donuts, you click once, and buy 1 donut, so the shopkeeper has 5 and you have 1. That's working fine. The problem is, if I have 2 or more donuts, my inventory only shows one (I disabled "group inventory items"). Somebody (I think it was Khris) helped me to show the inventory item quantity in said GUI shop, but I couldn't translate the code to work in the regular inventory. And now I mostly forgot everything about everything, so I'm trying to reverse engineer things. But it seems I couldn't do it even at my best, according to the last answer I made in the original post.
The original post: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55564.msg636577866#msg636577866
The part of the shop's code which (I think) displays item quantities:
Code: ags
Any help in how to do this would be greatly appreciated!
I have a work in progress game in which I, with a loooooot of help (like 95%), managed to make a shop GUI to buy and sell items, which can get grouped by quantity. For example, 6 donuts, you click once, and buy 1 donut, so the shopkeeper has 5 and you have 1. That's working fine. The problem is, if I have 2 or more donuts, my inventory only shows one (I disabled "group inventory items"). Somebody (I think it was Khris) helped me to show the inventory item quantity in said GUI shop, but I couldn't translate the code to work in the regular inventory. And now I mostly forgot everything about everything, so I'm trying to reverse engineer things. But it seems I couldn't do it even at my best, according to the last answer I made in the original post.
The original post: https://www.adventuregamestudio.co.uk/forums/index.php?topic=55564.msg636577866#msg636577866
The part of the shop's code which (I think) displays item quantities:
void DrawQuantities(DrawingSurface* ds, InvWindow* iw) {
InventoryItem* ii;
Character* c;
int i = iw.TopItem, iq, w, h;
String s;
for (int y = iw.Y; y < iw.Y + iw.Height; y += iw.ItemHeight) {
for (int x = iw.X; x < iw.X + iw.Width; x += iw.ItemWidth) {
ii = iw.ItemAtIndex[i];
if (ii != null) {
c = iw.CharacterToUse;
if (c == null) c = player;
iq = c.InventoryQuantity[ii.ID];
if (iq > 1) {
s = String.Format("x%d", iq);
w = GetTextWidth(s, shopFont);
h = GetTextHeight(s, shopFont, 1000);
ds.DrawingColor = 0;
ds.DrawString(x + iw.ItemWidth - w, y + iw.ItemHeight - h, shopOutlineFont, s);
ds.DrawingColor = 31;
ds.DrawString(x + iw.ItemWidth - w, y + iw.ItemHeight - h, shopFont, s);
}
}
i++;
}
}
}
void ShowQuantities() {
if (quantities == null) quantities = DynamicSprite.Create(gShop.Width, gShop.Height, true);
DrawingSurface* ds = quantities.GetDrawingSurface();
ds.Clear(COLOR_TRANSPARENT);
btnShopQuantities.Height = 1;
DrawQuantities(ds, invShopPlayer);
DrawQuantities(ds, invShopMerchant);
btnShopQuantities.Height = gShop.Height;
ds.Release();
btnShopQuantities.NormalGraphic = quantities.Graphic;
}
Any help in how to do this would be greatly appreciated!