Пример #1
0
void GuiOptionBrowser::Update(GuiTrigger * t)
{
	if (state == STATE_DISABLED || !t) return;

	int listSize = optionBtn.size();
	static int pressedChan = -1;

	if((t->wpad.btns_d & (WPAD_BUTTON_B | WPAD_BUTTON_DOWN | WPAD_BUTTON_UP | WPAD_BUTTON_LEFT | WPAD_BUTTON_RIGHT |
						  WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_RIGHT)) ||
		(t->pad.btns_d & (PAD_BUTTON_UP | PAD_BUTTON_DOWN)) ||
		(t->wupcdata.btns_d & (WPAD_CLASSIC_BUTTON_B | WPAD_CLASSIC_BUTTON_UP | WPAD_CLASSIC_BUTTON_DOWN | WPAD_CLASSIC_BUTTON_LEFT | WPAD_CLASSIC_BUTTON_RIGHT)))
		pressedChan = t->chan;

	// update the location of the scroll box based on the position in the option list
	scrollBar.Update(t);

	if(pressedChan == -1 || (!t->wpad.btns_h && !t->pad.btns_h && !t->wupcdata.btns_h))
	{
		for(int i = 0; i < listSize; i++)
		{
			if (i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED)
			{
				optionBtn[i]->ResetState();
			}
			else if (i == selectedItem && optionBtn[i]->GetState() == STATE_DEFAULT)
			{
				optionBtn[selectedItem]->SetState(STATE_SELECTED);
			}

			optionBtn[i]->Update(t);

			if (optionBtn[i]->GetState() == STATE_SELECTED)
				selectedItem = i;
		}
	}

	if(pressedChan == t->chan && !t->wpad.btns_d && !t->wpad.btns_h && !t->wupcdata.btns_d && !t->wupcdata.btns_h)
		pressedChan = -1;

	if(selectedItem != oldSelectedItem)
	{
		if(oldSelectedItem >= 0 && oldSelectedItem < listSize)
			optionVal[oldSelectedItem]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2 + scrollBar.GetWidth()+10), DOTTED);
		if(selectedItem >= 0 && selectedItem < listSize)
			optionVal[selectedItem]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2 + scrollBar.GetWidth()+10), SCROLL_HORIZONTAL);

		oldSelectedItem = selectedItem;
	}

	scrollBar.SetPageSize(listSize);
	scrollBar.SetSelectedItem(selectedItem);
	scrollBar.SetSelectedIndex(listOffset);
	scrollBar.SetEntrieCount(options->GetLength());

	if (options->IsChanged())
		UpdateListEntries();
}
Пример #2
0
void GuiGameBrowser::Reload(struct discHdr * l, int count)
{
	LOCK(this);
	gameList = l;
	gameCnt = count;
	scrollbaron = (gameCnt > pagesize) ? 1 : 0;
	selectedItem = 0;
	listOffset = 0;
	focus = 1;
	UpdateListEntries();

	for(int i=0; i<pagesize; i++)
		game[i]->ResetState();
}
Пример #3
0
void GuiGameBrowser::Update(GuiTrigger * t)
{
	LOCK(this);
	if(state == STATE_DISABLED || !t || !gameCnt)
		return;

	int next, prev;
	int old_listOffset = listOffset;
	static int position2;
	// scrolldelay affects how fast the list scrolls
	// when the arrows are clicked
	float scrolldelay = 3.5;

	if (scrollbaron == 1) {
		// update the location of the scroll box based on the position in the option list
		arrowUpBtn->Update(t);
		arrowDownBtn->Update(t);
		scrollbarBoxBtn->Update(t);
	}

	next = listOffset;

    u32 buttonshold = ButtonsHold();

    if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) {

        for(int i=0; i<pagesize; i++)
        {
            if(next >= 0)
                next = this->FindMenuItem(next, 1);

            if(focus)
            {
                if(i != selectedItem && game[i]->GetState() == STATE_SELECTED)
                    game[i]->ResetState();
                else if(i == selectedItem && game[i]->GetState() == STATE_DEFAULT)
                    game[selectedItem]->SetState(STATE_SELECTED, t->chan);
            }

            game[i]->Update(t);

            if(game[i]->GetState() == STATE_SELECTED)
            {
                selectedItem = i;
            }
        }
    }

	// pad and joystick navigation
	if(!focus || !gameCnt)
		return; // skip navigation

	if (scrollbaron == 1)
	{

		if (t->Down() || arrowDownBtn->GetState() == STATE_CLICKED || arrowDownBtn->GetState() == STATE_HELD) //down
		{

			next = this->FindMenuItem(gameIndex[selectedItem], 1);

			if(next >= 0)
			{
				if(selectedItem == pagesize-1)
				{
					// move list down by 1
					listOffset = this->FindMenuItem(listOffset, 1);
				}
				else if(game[selectedItem+1]->IsVisible())
				{
					game[selectedItem]->ResetState();
					game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
					selectedItem++;
				}
//				scrollbarBoxBtn->Draw();
				usleep(10000 * scrolldelay);
			}
			if (!(ButtonsHold() & WPAD_BUTTON_A))
				arrowDownBtn->ResetState();
		}
		else if(t->Up() || arrowUpBtn->GetState() == STATE_CLICKED || arrowUpBtn->GetState() == STATE_HELD) //up
		{
			prev = this->FindMenuItem(gameIndex[selectedItem], -1);

			if(prev >= 0)
			{
				if(selectedItem == 0)
				{
					// move list up by 1
					listOffset = prev;
				}
				else
				{
					game[selectedItem]->ResetState();
					game[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
					selectedItem--;
				}
//				scrollbarBoxBtn->Draw();
				usleep(10000 * scrolldelay);
			}
			if (!(ButtonsHold() & WPAD_BUTTON_A))
				arrowUpBtn->ResetState();
		}
		int position1 = t->wpad.ir.y;

		if (position2 == 0 && position1 > 0)
		{
			position2 = position1;
		}

		if ((buttonshold & WPAD_BUTTON_B) && position1 > 0)
		{
			scrollbarBoxBtn->ScrollIsOn(1);
			if (position2 > position1)
			{

				prev = this->FindMenuItem(gameIndex[selectedItem], -1);

				if(prev >= 0)
				{
					if(selectedItem == 0)
					{
						// move list up by 1
						listOffset = prev;
					}
					else
					{
						game[selectedItem]->ResetState();
						game[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
						selectedItem--;
					}
//					scrollbarBoxBtn->Draw();
					usleep(10000 * scrolldelay);
				}
			}
			else if (position2 < position1)
			{
				next = this->FindMenuItem(gameIndex[selectedItem], 1);

				if(next >= 0)
				{
					if(selectedItem == pagesize-1)
					{
						// move list down by 1
						listOffset = this->FindMenuItem(listOffset, 1);
					}
					else if(game[selectedItem+1]->IsVisible())
					{
						game[selectedItem]->ResetState();
						game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
						selectedItem++;
					}
//					scrollbarBoxBtn->Draw();
					usleep(10000 * scrolldelay);
				}
			}

		}
		else if(!(buttonshold & WPAD_BUTTON_B))
		{
			scrollbarBoxBtn->ScrollIsOn(0);
			position2 = 0;
		}

		if(scrollbarBoxBtn->GetState() == STATE_HELD && scrollbarBoxBtn->GetStateChan() == t->chan && t->wpad.ir.valid && gameCnt > pagesize)
		{
			// allow dragging of scrollbar box
			scrollbarBoxBtn->SetPosition(width/2-18+7,0);
			int position = t->wpad.ir.y - 32 - scrollbarBoxBtn->GetTop();

			listOffset = (position * gameCnt)/(25.2 * pagesize) - selectedItem;

			if(listOffset <= 0)
			{
				listOffset = 0;
				selectedItem = 0;
			}
			else if(listOffset+pagesize >= gameCnt)
			{
				listOffset = gameCnt - pagesize;
				selectedItem = pagesize-1;
			}

		}
		int positionbar = (25.2 * pagesize)*(listOffset + selectedItem) / gameCnt;

		if(positionbar > (24 * pagesize))
			positionbar = (24 * pagesize);
		scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);


		if(t->Right()) //skip pagesize # of games if right is pressed
		{
			if(listOffset < gameCnt && gameCnt > pagesize)
			{
				listOffset =listOffset+ pagesize;
				if(listOffset+pagesize >= gameCnt)
					listOffset = gameCnt-pagesize;
			}
		}
		else if(t->Left())
		{
			if(listOffset > 0)
			{
				listOffset =listOffset- pagesize;
				if(listOffset < 0)
					listOffset = 0;
			}
		}

	}
	else
	{
		if(t->Down()) //if there isn't a scrollbar and down is pressed
		{
			next = this->FindMenuItem(gameIndex[selectedItem], 1);

			if(next >= 0)
			{
				if(selectedItem == pagesize-1)
				{
					// move list down by 1
					listOffset = this->FindMenuItem(listOffset, 1);
				}
				else if(game[selectedItem+1]->IsVisible())
				{
					game[selectedItem]->ResetState();
					game[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
					selectedItem++;
				}
			}
		}
		else if(t->Up()) //up
		{
			prev = this->FindMenuItem(gameIndex[selectedItem], -1);

			if(prev >= 0)
			{
				if(selectedItem == 0)
				{
					// move list up by 1
					listOffset = prev;
				}
				else
				{
					game[selectedItem]->ResetState();
					game[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
					selectedItem--;
				}
			}
		}
	}

	if(old_listOffset != listOffset)
		UpdateListEntries();

	if(updateCB)
		updateCB(this);
}
Пример #4
0
/**
 * Constructor for the GuiGameBrowser class.
 */
GuiGameBrowser::GuiGameBrowser(int w, int h, struct discHdr * l, int gameCnt, const char *themePath, const u8 *imagebg, int selected, int offset)
{
	width = w;
	height = h;
	this->gameCnt = gameCnt;
	gameList = l;
	pagesize = THEME.pagesize;
	scrollbaron = (gameCnt > pagesize) ? 1 : 0;
	selectable = true;
	listOffset = MAX(0,MIN(offset,(gameCnt-pagesize)));
	selectedItem = selected - offset;
	focus = 1; // allow focus
	char imgPath[100];

	trigA = new GuiTrigger;
	trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
    trigHeldA = new GuiTrigger;
	trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
	btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);

	snprintf(imgPath, sizeof(imgPath), "%sbg_options.png", themePath);
	bgGames = new GuiImageData(imgPath, imagebg);

	snprintf(imgPath, sizeof(imgPath), "%snew.png", themePath);
	newGames = new GuiImageData(imgPath, new_png);

	bgGameImg = new GuiImage(bgGames);
	bgGameImg->SetParent(this);
	bgGameImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
	
	maxTextWidth = bgGameImg->GetWidth() - 24 - 4;

	snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath);
	bgGamesEntry = new GuiImageData(imgPath, bg_options_entry_png);

	snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath);
	scrollbar = new GuiImageData(imgPath, scrollbar_png);
	scrollbarImg = new GuiImage(scrollbar);
	scrollbarImg->SetParent(this);
	scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	scrollbarImg->SetPosition(0, 4);

	maxTextWidth -= scrollbarImg->GetWidth() + 4;

	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", themePath);
	arrowDown = new GuiImageData(imgPath, scrollbar_arrowdown_png);
	arrowDownImg = new GuiImage(arrowDown);
	arrowDownOver = new GuiImageData(imgPath, scrollbar_arrowdown_png);
	arrowDownOverImg = new GuiImage(arrowDownOver);
	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", themePath);
	arrowUp = new GuiImageData(imgPath, scrollbar_arrowup_png);
	arrowUpImg = new GuiImage(arrowUp);
	arrowUpOver = new GuiImageData(imgPath, scrollbar_arrowup_png);
	arrowUpOverImg = new GuiImage(arrowUpOver);
	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_box.png", themePath);
	scrollbarBox = new GuiImageData(imgPath, scrollbar_box_png);
	scrollbarBoxImg = new GuiImage(scrollbarBox);
	scrollbarBoxOver = new GuiImageData(imgPath, scrollbar_box_png);
	scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver);

	arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
	arrowUpBtn->SetParent(this);
	arrowUpBtn->SetImage(arrowUpImg);
	arrowUpBtn->SetImageOver(arrowUpOverImg);
	arrowUpBtn->SetImageHold(arrowUpOverImg);
	arrowUpBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	arrowUpBtn->SetPosition(width/2-18+7,-18);
	arrowUpBtn->SetSelectable(false);
	arrowUpBtn->SetTrigger(trigA);
	arrowUpBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
	arrowUpBtn->SetSoundClick(btnSoundClick);

	arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
	arrowDownBtn->SetParent(this);
	arrowDownBtn->SetImage(arrowDownImg);
	arrowDownBtn->SetImageOver(arrowDownOverImg);
	arrowDownBtn->SetImageHold(arrowDownOverImg);
	arrowDownBtn->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	arrowDownBtn->SetPosition(width/2-18+7,18);
	arrowDownBtn->SetSelectable(false);
	arrowDownBtn->SetTrigger(trigA);
	arrowDownBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
	arrowDownBtn->SetSoundClick(btnSoundClick);

	scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
	scrollbarBoxBtn->SetParent(this);
	scrollbarBoxBtn->SetImage(scrollbarBoxImg);
	scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
	scrollbarBoxBtn->SetImageHold(scrollbarBoxOverImg);
	scrollbarBoxBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	scrollbarBoxBtn->SetSelectable(false);
	scrollbarBoxBtn->SetEffectOnOver(EFFECT_SCALE, 50, 120);
   	scrollbarBoxBtn->SetMinY(0);
	scrollbarBoxBtn->SetMaxY(height-30);
	scrollbarBoxBtn->SetHoldable(true);
	scrollbarBoxBtn->SetTrigger(trigHeldA);

	gameIndex = new int[pagesize];
	game = new GuiButton * [pagesize];
	gameTxt = new GuiText * [pagesize];
	gameTxtOver = new GuiText * [pagesize];
	gameBg = new GuiImage * [pagesize];
	newImg = new GuiImage * [pagesize];

	for(int i=0; i < pagesize; i++)
	{
		gameTxt[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
		gameTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
		gameTxt[i]->SetPosition(24,0);
		gameTxt[i]->SetMaxWidth(maxTextWidth, GuiText::DOTTED);


		gameTxtOver[i] = new GuiText(get_title(&gameList[i]), 20, THEME.gametext);
		gameTxtOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
		gameTxtOver[i]->SetPosition(24,0);
		gameTxtOver[i]->SetMaxWidth(maxTextWidth, GuiText::SCROLL);

		gameBg[i] = new GuiImage(bgGamesEntry);

		newImg[i] = new GuiImage(newGames);
		newImg[i]->SetAlignment(ALIGN_RIGHT, ALIGN_MIDDLE);
		newImg[i]->SetVisible(false);

		game[i] = new GuiButton(width-28,GAMESELECTSIZE);
		game[i]->SetParent(this);
		game[i]->SetLabel(gameTxt[i]);
		game[i]->SetLabelOver(gameTxtOver[i]);
		game[i]->SetIcon(newImg[i]);
		game[i]->SetImageOver(gameBg[i]);
		game[i]->SetPosition(5,GAMESELECTSIZE*i+4);
		game[i]->SetRumble(false);
		game[i]->SetTrigger(trigA);
		game[i]->SetSoundClick(btnSoundClick);

		gameIndex[i] = i;
	}
	UpdateListEntries();
}
void GuiCustomOptionBrowser::Update(GuiTrigger * t)
{
	LOCK(this);
	int next, prev, lang = options->GetLength();

	if(state == STATE_DISABLED || !t)
		return;

	if(options->IsChanged()) {
		coL2 = 0;
		UpdateListEntries();
	}
	int old_listOffset = listOffset;

	if (scrollbaron == 1)
	{
		// update the location of the scroll box based on the position in the option list
		arrowUpBtn->Update(t);
		arrowDownBtn->Update(t);
		scrollbarBoxBtn->Update(t);
	}

	next = listOffset;

	u32 buttonshold = ButtonsHold();

	if(buttonshold != WPAD_BUTTON_UP && buttonshold != WPAD_BUTTON_DOWN) {
		for(int i=0; i < size; i++)
		{
			if(next >= 0)
				next = this->FindMenuItem(next, 1);

			if(focus)
			{
				if(i != selectedItem && optionBtn[i]->GetState() == STATE_SELECTED) {
					optionBtn[i]->ResetState();
				} else if(i == selectedItem && optionBtn[i]->GetState() == STATE_DEFAULT) {
					optionBtn[selectedItem]->SetState(STATE_SELECTED);
				}
			}


			optionBtn[i]->Update(t);

			if(optionBtn[i]->GetState() == STATE_SELECTED)
			{
				selectedItem = i;
			}
		}
	}

	// pad/joystick navigation
	if(!focus)
		return; // skip navigation

	if(t->Down())
	{
		next = this->FindMenuItem(optionIndex[selectedItem], 1);

		if(next >= 0)
		{
			if(selectedItem == size-1)
			{
				// move list down by 1
				listOffset = this->FindMenuItem(listOffset, 1);
			}
			else if(optionBtn[selectedItem+1]->IsVisible())
			{
				optionBtn[selectedItem]->ResetState();
				optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
				selectedItem++;
			}
		}
	}
	else if(t->Up())
	{
		prev = this->FindMenuItem(optionIndex[selectedItem], -1);

		if(prev >= 0)
		{
			if(selectedItem == 0)
			{
				// move list up by 1
				listOffset = prev;
			}
			else
			{
				optionBtn[selectedItem]->ResetState();
				optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
				selectedItem--;
			}
		}
	}

	if (scrollbaron == 1)
	{
		if (arrowDownBtn->GetState() == STATE_CLICKED ||
			arrowDownBtn->GetState() == STATE_HELD)
		{

			next = this->FindMenuItem(optionIndex[selectedItem], 1);

			if(next >= 0)
			{
				if(selectedItem == size-1)
				{
					// move list down by 1
					listOffset = this->FindMenuItem(listOffset, 1);
				}
				else if(optionBtn[selectedItem+1]->IsVisible())
				{
					optionBtn[selectedItem]->ResetState();
					optionBtn[selectedItem+1]->SetState(STATE_SELECTED, t->chan);
					selectedItem++;
				}
				scrollbarBoxBtn->Draw();
				usleep(35000);
			}
			if (buttonshold != WPAD_BUTTON_A) {
				arrowDownBtn->ResetState();
			}
		}
		else if(arrowUpBtn->GetState() == STATE_CLICKED ||
				arrowUpBtn->GetState() == STATE_HELD)
		{
			prev = this->FindMenuItem(optionIndex[selectedItem], -1);

			if(prev >= 0)
			{
				if(selectedItem == 0)
				{
					// move list up by 1
					listOffset = prev;
				}
				else
				{
					optionBtn[selectedItem]->ResetState();
					optionBtn[selectedItem-1]->SetState(STATE_SELECTED, t->chan);
					selectedItem--;
				}
				scrollbarBoxBtn->Draw();
				usleep(35000);
			}
			if (buttonshold != WPAD_BUTTON_A) {
				arrowUpBtn->ResetState();
			}
		}

		if(scrollbarBoxBtn->GetState() == STATE_HELD &&
			scrollbarBoxBtn->GetStateChan() == t->chan &&
			t->wpad.ir.valid && options->GetLength() > size)
		{
			scrollbarBoxBtn->SetPosition(width/2-18+7,0);

			int position = t->wpad.ir.y - 50 - scrollbarBoxBtn->GetTop();

			listOffset = (position * lang)/180 - selectedItem;

			if(listOffset <= 0) {
				listOffset = 0;
				selectedItem = 0;
			} else if(listOffset+size >= lang) {
				listOffset = lang-size;
				selectedItem = size-1;
			}
		}
		int positionbar = 237*(listOffset + selectedItem) / lang;

		if(positionbar > 216)
			positionbar = 216;
		scrollbarBoxBtn->SetPosition(width/2-18+7, positionbar+8);

		if(t->Right())
		{
			if(listOffset < lang && lang > size)
			{
				listOffset =listOffset+ size;
				if(listOffset+size >= lang)
				listOffset = lang-size;
			}
		}
		else if(t->Left())
		{
			if(listOffset > 0)
			{
				listOffset =listOffset- size;
				if(listOffset < 0)
					listOffset = 0;
			}
		}
	}

	if(old_listOffset != listOffset)
		UpdateListEntries();

	if(updateCB)
		updateCB(this);
}
/**
 * Constructor for the GuiCustomOptionBrowser class.
 */
GuiCustomOptionBrowser::GuiCustomOptionBrowser(int w, int h, customOptionList * l, const char *themePath, const char *custombg, const u8 *imagebg, int scrollon,int col2)
{
	width = w;
	height = h;
	options = l;
	size = PAGESIZE;
	scrollbaron = scrollon;
	selectable = true;
	listOffset = this->FindMenuItem(-1, 1);
	selectedItem = 0;
	focus = 1; // allow focus
	coL2 = col2;
	char imgPath[100];

	trigA = new GuiTrigger;
	trigA->SetSimpleTrigger(-1, WPAD_BUTTON_A | WPAD_CLASSIC_BUTTON_A, PAD_BUTTON_A);
	trigHeldA = new GuiTrigger;
	trigHeldA->SetHeldTrigger(-1, WPAD_BUTTON_A, PAD_BUTTON_A);
	btnSoundClick = new GuiSound(button_click_pcm, button_click_pcm_size, Settings.sfxvolume);

	snprintf(imgPath, sizeof(imgPath), "%s%s", themePath, custombg);
	bgOptions = new GuiImageData(imgPath, imagebg);

	bgOptionsImg = new GuiImage(bgOptions);
	bgOptionsImg->SetParent(this);
	bgOptionsImg->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);

	snprintf(imgPath, sizeof(imgPath), "%sbg_options_entry.png", themePath);
	bgOptionsEntry = new GuiImageData(imgPath, bg_options_entry_png);

	snprintf(imgPath, sizeof(imgPath), "%sscrollbar.png", themePath);
	scrollbar = new GuiImageData(imgPath, scrollbar_png);
	scrollbarImg = new GuiImage(scrollbar);
	scrollbarImg->SetParent(this);
	scrollbarImg->SetAlignment(ALIGN_RIGHT, ALIGN_TOP);
	scrollbarImg->SetPosition(0, 4);

	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowdown.png", themePath);
	arrowDown = new GuiImageData(imgPath, scrollbar_arrowdown_png);
	arrowDownImg = new GuiImage(arrowDown);
	arrowDownOver = new GuiImageData(imgPath, scrollbar_arrowdown_png);
	arrowDownOverImg = new GuiImage(arrowDownOver);
	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_arrowup.png", themePath);
	arrowUp = new GuiImageData(imgPath, scrollbar_arrowup_png);
	arrowUpImg = new GuiImage(arrowUp);
	arrowUpOver = new GuiImageData(imgPath, scrollbar_arrowup_png);
	arrowUpOverImg = new GuiImage(arrowUpOver);
	snprintf(imgPath, sizeof(imgPath), "%sscrollbar_box.png", themePath);
	scrollbarBox = new GuiImageData(imgPath, scrollbar_box_png);
	scrollbarBoxImg = new GuiImage(scrollbarBox);
	scrollbarBoxOver = new GuiImageData(imgPath, scrollbar_box_png);
	scrollbarBoxOverImg = new GuiImage(scrollbarBoxOver);

	arrowUpBtn = new GuiButton(arrowUpImg->GetWidth(), arrowUpImg->GetHeight());
	arrowUpBtn->SetParent(this);
	arrowUpBtn->SetImage(arrowUpImg);
	arrowUpBtn->SetImageOver(arrowUpOverImg);
	arrowUpBtn->SetImageHold(arrowUpOverImg);
	arrowUpBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	arrowUpBtn->SetPosition(width/2-18+7,-18);
	arrowUpBtn->SetSelectable(false);
	arrowUpBtn->SetTrigger(trigA);
	arrowUpBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
	arrowUpBtn->SetSoundClick(btnSoundClick);

	arrowDownBtn = new GuiButton(arrowDownImg->GetWidth(), arrowDownImg->GetHeight());
	arrowDownBtn->SetParent(this);
	arrowDownBtn->SetImage(arrowDownImg);
	arrowDownBtn->SetImageOver(arrowDownOverImg);
	arrowDownBtn->SetImageHold(arrowDownOverImg);
	arrowDownBtn->SetAlignment(ALIGN_CENTRE, ALIGN_BOTTOM);
	arrowDownBtn->SetPosition(width/2-18+7,18);
	arrowDownBtn->SetSelectable(false);
	arrowDownBtn->SetTrigger(trigA);
	arrowDownBtn->SetEffectOnOver(EFFECT_SCALE, 50, 130);
	arrowDownBtn->SetSoundClick(btnSoundClick);

	scrollbarBoxBtn = new GuiButton(scrollbarBoxImg->GetWidth(), scrollbarBoxImg->GetHeight());
	scrollbarBoxBtn->SetParent(this);
	scrollbarBoxBtn->SetImage(scrollbarBoxImg);
	scrollbarBoxBtn->SetImageOver(scrollbarBoxOverImg);
	scrollbarBoxBtn->SetImageHold(scrollbarBoxOverImg);
	scrollbarBoxBtn->SetAlignment(ALIGN_CENTRE, ALIGN_TOP);
	scrollbarBoxBtn->SetSelectable(false);
	scrollbarBoxBtn->SetEffectOnOver(EFFECT_SCALE, 50, 120);
	scrollbarBoxBtn->SetMinY(0);
	scrollbarBoxBtn->SetMaxY(height-30);
	scrollbarBoxBtn->SetHoldable(true);
	scrollbarBoxBtn->SetTrigger(trigHeldA);

	optionIndex = new int[size];
	optionVal = new GuiText * [size];
	optionValOver = new GuiText * [size];
	optionBtn = new GuiButton * [size];
	optionTxt = new GuiText * [size];
	optionBg = new GuiImage * [size];

	for(int i=0; i < size; i++)
	{
		optionTxt[i] = new GuiText(options->GetName(i), 20, THEME.settingstext);
		optionTxt[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);
		optionTxt[i]->SetPosition(24,0);
		optionTxt[i]->SetMaxWidth(bgOptionsImg->GetWidth() - (coL2+24), GuiText::DOTTED);

		optionBg[i] = new GuiImage(bgOptionsEntry);

		optionVal[i] = new GuiText(NULL, 20, THEME.settingstext);
		optionVal[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);

		optionValOver[i] = new GuiText(NULL, 20, THEME.settingstext);
		optionValOver[i]->SetAlignment(ALIGN_LEFT, ALIGN_MIDDLE);

		optionBtn[i] = new GuiButton(width-28,GAMESELECTSIZE);
		optionBtn[i]->SetParent(this);
		optionBtn[i]->SetLabel(optionTxt[i], 0);
		optionBtn[i]->SetLabel(optionVal[i], 1);
		optionBtn[i]->SetLabelOver(optionValOver[i], 1);
		optionBtn[i]->SetImageOver(optionBg[i]);
		optionBtn[i]->SetPosition(10,GAMESELECTSIZE*i+4);
		optionBtn[i]->SetRumble(false);
		optionBtn[i]->SetTrigger(trigA);
		optionBtn[i]->SetSoundClick(btnSoundClick);

	}
	UpdateListEntries();
}
Пример #7
0
void GuiOptionBrowser::onListChange(int SelItem, int SelInd)
{
	selectedItem = SelItem;
	listOffset = SelInd;
	UpdateListEntries();
}