コード例 #1
0
ファイル: Adventure.c プロジェクト: Belphemur/MiniDungeon
void GoUsingStamina(void) { 
	if (SpendStamina()) {
		if(!UpdateAdventure()) {
			const char * stam = UpdateStaminaText();
			const uint8_t size = 12 * sizeof(char);
			char *avail = malloc(size);
			snprintf(avail, size, "%s%s", "Stamina: ", stam);
			SetMenuDescription(avail);
			free(avail);
		}
	} else {
		SetMenuDescription("Stamina depleted.");
	}
}
コード例 #2
0
ファイル: Menu.c プロジェクト: BlackLamb/MiniDungeon
void MenuAppear(Window *window)
{
	int i;
	bool setSelected = false;
		
	MenuWindow *menuWindow = window_get_user_data(window);
	if(menuWindow)
	{
		SetCurrentMenu(menuWindow->menu);
	}
	WindowAppear(window);
	if(!currentMenuDef)
	{
		HideAllMenuLayers();
		SetMenuDescription(NULL);
		return;
	}

	currentMenuDef->currentSelection = -1;
	for(i = 0; i < MAX_MENU_ENTRIES; ++i)
	{
		MenuEntry *entry = &currentMenuDef->menuEntries[i];
		if(MenuEntryIsActive(entry))
		{
			ShowMenuLayer(i, entry->text);
			if(setSelected)
			{
				SetMenuHighlight(i, false);
			}
			else
			{
				SetMenuHighlight(i, true);
				setSelected = true;
				currentMenuDef->currentSelection = i;
				SetMenuDescription(entry->description);
			}
		}
		else
		{
			HideMenuLayer(i);
		}
	}

	if(menuWindow && menuWindow->menu && menuWindow->menu->mainImageId != -1)
	{
		LoadMainBmpImage(window, menuWindow->menu->mainImageId, menuWindow->menu->useFloorImage ? menuWindow->menu->floorImageId : -1);
	}
}
コード例 #3
0
ファイル: Menu.c プロジェクト: BlackLamb/MiniDungeon
void IterateMenuEntries(int direction)
{
	int iterator,newSelection;

	if(!currentMenuDef)
		return;

	iterator = newSelection = currentMenuDef->currentSelection;
	
	if(currentMenuDef->currentSelection == -1)
		return;

	do
	{
		MenuEntry *entry;
		iterator += direction;
		if(iterator > MAX_MENU_ENTRIES-1)
			iterator = 0;
		else if(iterator < 0)
			iterator = MAX_MENU_ENTRIES-1;

		entry = &currentMenuDef->menuEntries[iterator];
		if(MenuEntryIsActive(entry))
		{
			newSelection = iterator;
			break;
		}
	}
	while(iterator != currentMenuDef->currentSelection);

	if(newSelection != currentMenuDef->currentSelection)
	{
		MenuEntry *entry = &currentMenuDef->menuEntries[newSelection];
		SetMenuHighlight(currentMenuDef->currentSelection, false);
		SetMenuHighlight(newSelection, true);
		currentMenuDef->currentSelection = newSelection;
		SetMenuDescription(entry->description);
	}
}