Exemplo n.º 1
0
void ShowItemPrompt(CItem *pItem)
{
	// Let's reset the buttons and the menu choice since we entered a new menu
	g_Menu.ResetMenuChoice();
	g_Menu.ResetButtons();

	// Draw the surrounding dialog box for the menu
	g_Menu.DrawBox(kMenuWidth, kMenuHeight - 3, kMenuX, kMenuY);
	
	// Create buttons for each option in the prompt menu
	g_Menu.DrawString("Equip/Use", 9, kMenuX + 5, kMenuY + 3, NULL,  ItemPromptUse);
	g_Menu.DrawString("Drop",      4, kMenuX + 5, kMenuY + 6, NULL,  ItemPromptDrop);
	g_Menu.DrawString("Cancel",    6, kMenuX + 5, kMenuY + 9, NULL,  ItemPromptCancel);

	// Let's start the menu loop, which waits for input.  It will continue until 
	// the user hits escape or chooses an option from the menu.
	while(!g_Menu.EscapePressed() && !g_Menu.ChoiceMade())
	{
		// Check input from the user to know what to do in the menu
		g_Menu.HandleInput();
	}

	// If there was a choice made in the menu, let's call that buttons function pointer
	if(g_Menu.ChoiceMade())
		g_Menu.ChoiceMade()->m_function();

	// Regardless of the option, we still need to redraw the inventory screen
	DrawInventoryScreen();
}
Exemplo n.º 2
0
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();

        if(g_Menu.EscapePressed())
            break;

        Sleep(100);

        // 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 redraw the inventory screen
            pItem = g_Menu.GetSelectedItem();
            g_Map.SetDrawFlag(true);
            g_Map.Draw();
            DrawInventoryScreen();
            g_Menu.ResetMenuChoice();
            g_Buffer.SwapBackBuffer(FALSE);
        }
        // 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
            ShowItemPrompt(pItem);
            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();
}
Exemplo n.º 3
0
void ShowItemPrompt(CItem *pItem)
{
    // Redraw the inventory screen and the map
    g_Map.SetDrawFlag(true);
    g_Map.Draw();
    DrawInventoryScreen();

    // Let's reset the buttons and the menu choice since we entered a new menu
    g_Menu.ResetMenuChoice();
    g_Menu.ResetButtons();

    // Draw the surrounding dialog box for the menu
    g_Menu.DrawBox(kMenuWidth, kTileHeight*4, kMenuX, kMenuY);

    // Create buttons for each option
    g_Menu.DrawString("Equip/Use", 9, kMenuX + kTileWidth, kMenuY + kTileHeight-3,  NULL, ItemPromptUse);
    g_Menu.DrawString("Drop",      4, kMenuX + kTileWidth, kMenuY + kTileHeight+29, NULL, ItemPromptDrop);
    g_Menu.DrawString("Cancel",    6, kMenuX + kTileWidth, kMenuY + kTileHeight+61, NULL, ItemPromptCancel);

    // Swap the backbuffers to display the bitmaps to the screen
    g_Buffer.SwapBackBuffer(FALSE);
    Sleep(100);

    // Let's start the menu loop, which waits for input.  It will continue until
    // the user hits escape or chooses an option from the menu.
    while(!g_Menu.EscapePressed() && !g_Menu.ChoiceMade())
    {
        // Check input from the user to know what to do in the menu
        g_Menu.HandleInput();
    }

    // If there was a choice made in the menu, let's call that buttons function pointer
    if(g_Menu.ChoiceMade())
        g_Menu.ChoiceMade()->m_function();

    // Regardless of the option, we still need to redraw the inventory screen since
    // the user made an option or cancel and wants to go back to the main inventory menu.
    DrawInventoryScreen();
}
Exemplo n.º 4
0
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();
}
Exemplo n.º 5
0
void ShowConfirmPrompt(CItem *pItem, bool bBuying)
{
	// First, let's reset the input from the menu delete all old buttons
	g_Shop.ResetMenuChoice();
	g_Shop.ResetButtons();

	// If we aren't buying, but selling, then give a gold quote to the player for their item
	if(!bBuying)
	{
		char szMessage[80] = {0};
		sprintf(szMessage, "I'll give you %d for it...", CalculateItemPrice(pItem, false));
		g_Shop.DrawMessageBox(szMessage);
		Sleep(1500);
	}

	// Now we actually want to draw the prompt menu for the user to confirm their decision
	g_Shop.DrawBox(kMenuWidth - 3, kMenuHeight - 6, kMenuX, kMenuY);
	
	// If we are buying, then display a buying button, otherwise create a selling button
	if(bBuying)
		g_Shop.DrawString("Buy", 3, kMenuX + 5, kMenuY + 3, NULL,  ItemPromptBuy);
	else
		g_Shop.DrawString("Sell", 4, kMenuX + 5, kMenuY + 3, NULL,  ItemPromptSell);

	// Add a cancel button (or you can just hit ESC to cancel)
	g_Shop.DrawString("Cancel", 6, kMenuX + 5, kMenuY + 6, NULL,  ItemPromptCancel);

	// Now we do our input loop where we wait for either escape or a menu choice
	while(!g_Shop.EscapePressed() && !g_Shop.ChoiceMade())
	{
		// Handle the input from the user (The same function as CMenu uses)
		g_Shop.HandleInput();
	}

	// If a button was clicked, let's go to it's associated function
	if(g_Shop.ChoiceMade())
		g_Shop.ChoiceMade()->m_function();

	// Let's go back to the main inventory screen after the user confirms their choice
	DrawInventoryScreen();
}