void ShowInventoryMenu() { // Draw the dialog boxes and associated data inside them DrawInventoryScreen(); // Store an item pointer which is set every time the user clicks on a new item CItem *pItem = NULL; // Let's loop until we get some valid input from the user while(!g_Menu.EscapePressed()) { // Strange, but let's loop again :) This loop handles prompts while(!g_Menu.EscapePressed() && !g_Menu.ChoiceMade()) g_Menu.HandleInput(); // Check if the item isn't the same as the last item if(g_Menu.GetSelectedItem() && pItem != g_Menu.GetSelectedItem()) { // Get the selected item and draw the stats for that item at the bottom pItem = g_Menu.GetSelectedItem(); DrawStatsString(); g_Menu.ResetMenuChoice(); } // If the item is the same, let's display a prompt to the user else if(pItem && pItem == g_Menu.GetSelectedItem()) { // Display a prompt, which will do a new input loop. After that is done // it will come back here and we will redraw the inventory menu again. ShowItemPrompt(pItem); DrawInventoryScreen(); pItem = NULL; // Reset the last clicked on item } } // Let's redraw the main menu after we have chosen to exit from the inventory menu g_Menu.RedrawMenu(); }
void DrawInventoryScreen() { char szItem[25] = {0}; char szHead[80] = {0}; char szChest[80] = {0}; char szWeapon[80] = {0}; char szFeet[80] = {0}; // Reset all the menu flags to start over on a new menu g_Menu.ResetButtons(); g_Menu.ResetEscapeFlag(); g_Menu.ResetMenuChoice(); // Let's redraw the map so it destroys the previous menu artifacts. We then // want to draw new dialog boxes to house the inventory and stats information. g_Map.SetDrawFlag(true); g_Map.Draw(); // Draw the 3 boxes that will make up the inventory screen: TopLeft, TopRight, Bottom g_Menu.DrawBox(kEqMenuWidth, kEqMenuHeight, kEqMenuX, kEqMenuY); g_Menu.DrawBox(kInvMenuWidth, kInvMenuHeight, kInvMenuX, kInvMenuY); g_Menu.DrawBox(kStatsMenuWidth, kStatsMenuHeight, kStatsMenuX, kStatsMenuY); // If the user has anything equipped, let's get pointers to those items CItem *pHead = g_Player.GetEquipment(kHead); CItem *pChest = g_Player.GetEquipment(kChest); CItem *pWeapon = g_Player.GetEquipment(kWeapon); CItem *pFeet = g_Player.GetEquipment(kFeet); // We there is an item equipped then we want to insert it's name in the EQ menu if(pHead) sprintf(szHead, "Head: %s", pHead->GetItemName()); else sprintf(szHead, "Head: "); if(pChest) sprintf(szChest, "Chest: %s", pChest->GetItemName()); else sprintf(szChest, "Chest: "); if(pWeapon) sprintf(szWeapon, "Weapon: %s", pWeapon->GetItemName()); else sprintf(szWeapon, "Weapon: "); if(pFeet) sprintf(szFeet, "Feet: %s", pFeet->GetItemName()); else sprintf(szFeet, "Feet: "); // Now we draw the current player's equipment and pass in the item pointers for clicking on g_Menu.DrawString(szHead, (int)strlen(szHead), kEqMenuX + kTileWidth, kEqMenuY + 115, pHead); g_Menu.DrawString(szChest, (int)strlen(szChest), kEqMenuX + kTileWidth, kEqMenuY + 147, pChest); g_Menu.DrawString(szWeapon, (int)strlen(szWeapon), kEqMenuX + kTileWidth, kEqMenuY + 179, pWeapon); g_Menu.DrawString(szFeet, (int)strlen(szFeet), kEqMenuX + kTileWidth, kEqMenuY + 211, pFeet); // Let's draw the stats screen that goes at the bottom of the inventory menu DrawStatsString(); // Go through all of the items in our inventory and draw them for(int i = 0; i < g_Player.GetInventorySize(); i++) { // Get the current item and set it's default position CItem *pInvItem = g_Player.GetItem(i); int xOffset = kTileWidth, yOffset = kTileHeight + i * kFontHeight; // If the current column has more items than it should hold we need to // go to the next column on the right and start drawing the next items. if(i >= kMaxItemHeight) { // Increase the x and y position accordingly for each item xOffset += (kMaxItemWidth * (i / kMaxItemHeight)) * kTileWidth; yOffset = (i - ((i/kMaxItemHeight) * kMaxItemHeight)) * kFontHeight + kTileHeight; } // Get the item's name and create a button for it, then display it to the screen sprintf(szItem, "%s", pInvItem->GetItemName()); g_Menu.DrawString(szItem, (int)strlen(szItem), kInvMenuX + xOffset, kInvMenuY + yOffset, pInvItem); } // After the items are drawn, let's load and draw a small picture of the player HBITMAP hPlayerBust = g_Buffer.LoadABitmap((LPSTR)kPlayerBust); g_Buffer.DisplayBitmap(hPlayerBust, kPlayerBustX, kPlayerBustY); // Swap the backbuffers to display the bitmaps to the screen g_Buffer.SwapBackBuffer(FALSE); Sleep(100); // Since the picture is drawn, we don't need it anymore, let's delete it DeleteObject(hPlayerBust); }
void DrawInventoryScreen() { char szItem[25] = {0}; char szHead[80] = {0}; char szChest[80] = {0}; char szWeapon[80] = {0}; char szFeet[80] = {0}; // Reset all the menu flags to start over on a new menu g_Menu.ResetButtons(); g_Menu.ResetEscapeFlag(); g_Menu.ResetMenuChoice(); g_Menu.ResetItemChoice(); // Let's redraw the map so it destroys the previous menu artifacts. We then // want to draw new dialog boxes to house the inventory and stats information. g_Map.Draw(); g_Menu.DrawBox(kEqMenuWidth, kEqMenuHeight, kEqMenuX, kEqMenuY); g_Menu.DrawBox(kInvMenuWidth, kInvMenuHeight, kInvMenuX, kInvMenuY); g_Menu.DrawBox(kStatsMenuWidth, kStatsMenuHeight, kStatsMenuX, kStatsMenuY); // If the user has anything equipped, let's get pointers to those items CItem *pHead = g_Player.GetEquipment(kHead); CItem *pChest = g_Player.GetEquipment(kChest); CItem *pWeapon = g_Player.GetEquipment(kWeapon); CItem *pFeet = g_Player.GetEquipment(kFeet); // We there is an item equipped then we want to insert it's name in the EQ menu if(pHead) sprintf(szHead, "Head: %s", pHead->GetItemName()); else sprintf(szHead, "Head: "); if(pChest) sprintf(szChest, "Chest: %s", pChest->GetItemName()); else sprintf(szChest, "Chest: "); if(pWeapon) sprintf(szWeapon, "Weapon: %s", pWeapon->GetItemName()); else sprintf(szWeapon, "Weapon: "); if(pFeet) sprintf(szFeet, "Feet: %s", pFeet->GetItemName()); else sprintf(szFeet, "Feet: "); // Now we draw the current player's equipment and pass in the item pointers for clicking on g_Menu.DrawString(szHead, (int)strlen(szHead), kEqMenuX + 3, kEqMenuY + 5, pHead); g_Menu.DrawString(szChest, (int)strlen(szChest), kEqMenuX + 3, kEqMenuY + 9, pChest); g_Menu.DrawString(szWeapon, (int)strlen(szWeapon), kEqMenuX + 3, kEqMenuY + 13, pWeapon); g_Menu.DrawString(szFeet, (int)strlen(szFeet), kEqMenuX + 3, kEqMenuY + 17, pFeet); // Let's draw the stats screen that goes at the bottom of the inventory menu DrawStatsString(); // Go through all of the items in our inventory and draw them for(int i = 0; i < g_Player.GetInventorySize(); i++) { // Get the current item and set it's default position CItem *pInvItem = g_Player.GetItem(i); int xOffset = 3, yOffset = i + 2; // If the current column has more items than it should hold we need to // go to the next column on the right and start drawing the next items. if(i >= kMaxItemHeight) { // Increase the x offset to a new column and reset the y // offset to start at the top of the next column. xOffset += kMaxItemWidth * (i / kMaxItemHeight); yOffset = i - ((i/kMaxItemHeight) * kMaxItemHeight) + 2; } // Get the item's name and create a button for it, then display it to the screen sprintf(szItem, "%s", pInvItem->GetItemName()); g_Menu.DrawString(szItem, (int)strlen(szItem), kInvMenuX + xOffset, kInvMenuY + yOffset, pInvItem); } }