/** * Draw the button on screen */ void GuiButton::draw(CVideo *v) { if(!this->isVisible()) return; // draw image if(isStateSet(STATE_SELECTED | STATE_CLICKED | STATE_HELD) && imageOver) imageOver->draw(v); else if(image) image->draw(v); if(isStateSet(STATE_SELECTED | STATE_CLICKED | STATE_HELD) && iconOver) iconOver->draw(v); else if(icon) icon->draw(v); // draw text for(int i = 0; i < 4; i++) { if(isStateSet(STATE_SELECTED | STATE_CLICKED | STATE_HELD) && labelOver[i]) labelOver[i]->draw(v); else if(label[i]) label[i]->draw(v); } }
void GuiFrame::update(GuiController * c) { if(isStateSet(STATE_DISABLED) && parentElement) return; //! update appended items next frame u32 size = elements.size(); for (u32 i = 0; i < size && i < elements.size(); ++i) { elements[i]->update(c); } }
void GuiGameCarousel::update(GuiController * c) { if (isStateSet(STATE_DISABLED) || !pagesize) return; GuiGameBrowser::update(c); for(u32 i = 0; i < drawOrder.size(); i++) { int idx = drawOrder[i]; game[idx]->update(c); } }
void GuiGameCarousel::loadBgImage(int idx) { if(idx < 0 || idx >= GameList::instance()->size()) return; std::string filepath = GameList::instance()->at(idx)->gamepath + META_PATH + "/bootTvTex.tga"; //! remove image that is possibly still loading //! TODO: fix (state != STATE_DISABLED) its a cheap trick to make the thread not create new images when fading out because it causes issues if(bgNewImageDataAsync && !isStateSet(STATE_DISABLED)) { GuiImageAsync::removeFromQueue(bgNewImageDataAsync); AsyncDeleter::pushForDelete(bgNewImageDataAsync); bgNewImageDataAsync = new GuiImageAsync(filepath, NULL); } else { delete bgNewImageDataAsync; bgNewImageDataAsync = new GuiImageAsync(filepath, NULL); } }
void GameLauncherMenu::loadBgImage() { if(header == NULL) return; std::string filepath = header->gamepath + META_PATH + "/bootTvTex.tga"; //! remove image that is possibly still loading //! TODO: fix (state != STATE_DISABLED) its a cheap trick to make the thread not create new images when fading out because it causes issues if(bgNewImageDataAsync && !isStateSet(STATE_DISABLED)) { bgNewImageDataAsync->imageLoaded.disconnect_all(); GuiImageAsync::removeFromQueue(bgNewImageDataAsync); AsyncDeleter::pushForDelete(bgNewImageDataAsync); bgNewImageDataAsync = new GuiImageAsync(filepath, NULL); } else { delete bgNewImageDataAsync; bgNewImageDataAsync = new GuiImageAsync(filepath, NULL); } bgNewImageDataAsync->imageLoaded.connect(this, &GameLauncherMenu::OnBgLoadedFinished); }
void GuiButton::update(GuiController * c) { if(!c || isStateSet(STATE_DISABLED, c->chan)) return; else if(parentElement && parentElement->isStateSet(STATE_DISABLED, c->chan)) return; if(selectable) { if(!c->vpad.tpdata.invalid && this->isInside(c->vpadTvX, c->vpadTvY)) { if(!isStateSet(STATE_SELECTED, c->chan)) { setState(STATE_SELECTED, c->chan); //if(this->isRumbleActive()) // this->rumble(t->chan); if(soundOver) soundOver->Play(); if(effectsOver && !effects) { // initiate effects effects = effectsOver; effectAmount = effectAmountOver; effectTarget = effectTargetOver; } selected(this, c); } } else { if(isStateSet(STATE_SELECTED, c->chan)) { this->clearState(STATE_SELECTED); deSelected(this, c); } if(effectTarget == effectTargetOver && effectAmount == effectAmountOver) { // initiate effects (in reverse) effects = effectsOver; effectAmount = -effectAmountOver; effectTarget = 100; } } } for(int i = 0; i < 4; i++) { if(!trigger[i]) continue; // button triggers if(clickable) { bool isClicked = trigger[i]->clicked(c); if( !clickedTrigger && isClicked && (trigger[i]->isClickEverywhere() || (isStateSet(STATE_SELECTED, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->vpadTvX, c->vpadTvY))) { if(soundClick) soundClick->Play(); clickedTrigger = trigger[i]; if(!isStateSet(STATE_CLICKED, c->chan)) setState(STATE_CLICKED, c->chan); clicked(this, c, trigger[i]); } else if(isStateSet(STATE_CLICKED, c->chan) && (clickedTrigger == trigger[i]) && !isStateSet(STATE_HELD, c->chan) && !trigger[i]->held(c) && (!isClicked || trigger[i]->released(c))) { clickedTrigger = NULL; clearState(STATE_CLICKED, c->chan); released(this, c, trigger[i]); } } if(holdable) { bool isHeld = trigger[i]->held(c); if( (!heldTrigger || heldTrigger == trigger[i]) && isHeld && (trigger[i]->isHoldEverywhere() || (isStateSet(STATE_SELECTED, c->chan) && trigger[i]->isSelectionClickEverywhere()) || this->isInside(c->vpadTvX, c->vpadTvY))) { heldTrigger = trigger[i]; if(!isStateSet(STATE_HELD, c->chan)) setState(STATE_HELD, c->chan); held(this, c, trigger[i]); } else if(isStateSet(STATE_HELD, c->chan) && (heldTrigger == trigger[i]) && (!isHeld || trigger[i]->released(c))) { //! click is removed at this point and converted to held if(clickedTrigger == trigger[i]) { clickedTrigger = NULL; clearState(STATE_CLICKED, c->chan); } heldTrigger = NULL; clearState(STATE_HELD, c->chan); released(this, c, trigger[i]); } } } }
void GuiIconCarousel::updateDrawMap(void) { //! create a multimap of Z position which will sort the items by z coordinate std::multimap< float, std::pair<float, int> > drawMap; std::multimap< float, std::pair<float, int> >::const_iterator itr; size_t i; for(i = 0; i < gameIcons.size(); i++) { int idx = i; float currDegree = DegToRad(360.0f / (radiusScale * gameIcons.size()) * i + circlePosition + 90.0f); float posX = radiusScale * circleRadius * cosf(currDegree); float posZ = radiusScale * circleRadius * sinf(currDegree) + RADIUS - gameIcons.size() * (RADIUS / 12.0f); drawMap.insert(std::pair<float, std::pair<float, int> >(posZ, std::pair<float, int>(posX, i))); float rgbReduction = std::min((circleRadius + posZ / 2.0f + fIconRgbDrop) / (2.0f * circleRadius), 1.0f); if(rgbReduction < 0.0f) rgbReduction = 0.0f; float alphaReduction = std::min((circleRadius + posZ + fOpacy * (circleRadius * 2.0f)) / (2.0f * circleRadius), 1.0f); if(alphaReduction < 0.0f) alphaReduction = 0.0f; gameIcons[idx]->setColorIntensity(glm::vec4(rgbReduction, rgbReduction, rgbReduction, 1.0f)); gameIcons[idx]->setAlpha(alphaReduction); gameIcons[idx]->setRenderReflection(true); gameIcons[idx]->setRotationX(-cam_X_rot); gameIcons[idx]->setPosition(posX * width * 0.5f, Yoffset * height * 0.5f, posZ * width * 0.5f); } for(itr = drawMap.begin(), i = 0; itr != drawMap.end(); i++, itr++) { int idx = itr->second.second; itr++; bool bSelected = (itr == drawMap.end()); itr--; if(!bSelected) { float rgbReduction = 0.8f; glm::vec4 intensity = gameIcons[idx]->getColorIntensity(); gameIcons[idx]->setColorIntensity(glm::vec4(rgbReduction * intensity[0], rgbReduction * intensity[1], rgbReduction * intensity[2], intensity[3])); } else { gameTitle.setText(GameList::instance()->at(idx)->name.c_str()); if(selectedGame != idx || !bgUsedImageDataAsync) { selectedGame = idx; std::string filepath = GameList::instance()->at(idx)->gamepath + META_PATH + "/bootTvTex.tga"; //! remove image that is possibly still loading //! TODO: fix (state != STATE_DISABLED) its a cheap trick to make the thread not create new images when fading out because it causes issues //! TODO: this is probably not needed anymore -> verify if(bgNewImageDataAsync && !isStateSet(STATE_DISABLED)) { GuiImageAsync::removeFromQueue(bgNewImageDataAsync); AsyncDeleter::pushForDelete(bgNewImageDataAsync); bgNewImageDataAsync = new GameBgImage(filepath, NULL); } else { delete bgNewImageDataAsync; bgNewImageDataAsync = new GameBgImage(filepath, NULL); } } glm::vec4 intensity = gameIcons[idx]->getColorIntensity(); gameIcons[idx]->setColorIntensity(glm::vec4(intensity[0], intensity[1], intensity[2], 1.2f * intensity[3])); } drawOrder[i] = idx; gameIcons[idx]->setSelected(bSelected); } }