void menu::drawExitMenu() { text exitM = text((const unsigned char*) "EXIT GAME?", orgWidth/2-100,orgHeight/2-30,0.2,0.2); text yes = text((const unsigned char*) "YES", orgWidth/2-150,orgHeight/2+30,0.2,0.2); text no = text((const unsigned char*) "NO", orgWidth/2+60,orgHeight/2+30,0.2,0.2); //Draw text for Exit Menu glColor4f(1.0,1.0,1.0,1.0); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0); exitM.drawText(); yes.drawText(); no.drawText(); //Exit Yes textbox if (isMouseInside(orgWidth/2-170,orgHeight/2,100,40,xOffset,yOffset)) { yes.drawTextBox(orgWidth/2-170,orgHeight/2,100,40); if (wasclicked_LB) exit(0); } // Exit No textbox if (isMouseInside(orgWidth/2+40,orgHeight/2,100,40,xOffset,yOffset)) { no.drawTextBox(orgWidth/2+40,orgHeight/2,100,40); if (wasclicked_LB) inExitMenu = false; } }
void OsuUISongBrowserScoreButton::update() { CBaseUIButton::update(); if (!m_bVisible) return; // HACKHACK: this should really be part of the UI base // right click detection if (engine->getMouse()->isRightDown()) { if (!m_bRightClickCheck) { m_bRightClickCheck = true; m_bRightClick = isMouseInside(); } } else { if (m_bRightClick) { if (isMouseInside()) onRightMouseUpInside(); } m_bRightClickCheck = false; m_bRightClick = false; } // tooltip (extra stats) if (isMouseInside()) { if (!isContextMenuVisible()) { if (m_fIndexNumberAnim > 0.0f) { m_osu->getTooltipOverlay()->begin(); { for (int i=0; i<m_tooltipLines.size(); i++) { if (m_tooltipLines[i].length() > 0) m_osu->getTooltipOverlay()->addLine(m_tooltipLines[i]); } } m_osu->getTooltipOverlay()->end(); } } else { anim->deleteExistingAnimation(&m_fIndexNumberAnim); m_fIndexNumberAnim = 0.0f; } } // update elapsed time string updateElapsedTimeString(); // stuck anim reset if (!isMouseInside() && !anim->isAnimating(&m_fIndexNumberAnim)) m_fIndexNumberAnim = 0.0f; }
void menu::drawInGameMenu() { text resume = text((const unsigned char*) "Resume",100,250,0.2,0.2); text save = text((const unsigned char*) "Save",100,300,0.2,0.2); text load = text((const unsigned char*) "Load",100,350,0.2,0.2); text opt = text((const unsigned char*) "Option",100,400,0.2,0.2); text ext = text((const unsigned char*) "Exit",100,600,0.2,0.2); glColor4f(1.0,1.0,1.0,1.0); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0); resume.drawText(); save.drawText(); load.drawText(); opt.drawText(); ext.drawText(); if (isMouseInside(90,220,200,40,xOffset,yOffset)) { resume.drawTextBox(90,220,200,40); if (wasclicked_LB) { ingame = true; inGameMenu = false; } } if (isMouseInside(90,270,200,40,xOffset,yOffset)) { save.drawTextBox(90,270,200,40); } if (isMouseInside(90,320,200,40,xOffset,yOffset)) { load.drawTextBox(90,320,200,40); } if (isMouseInside(90,370,200,40,xOffset,yOffset)) { opt.drawTextBox(90,370,200,40); } if (isMouseInside(90,570,200,40,xOffset,yOffset)) { ext.drawTextBox(90,570,200,40); if (wasclicked_LB) inExitMenu = true; } }
void menu::drawHUD() { glColor4f(1,1,1,0.3); hudBack.drawSprites(0,screenheight-100, screenwidth,100); text menu = text((const unsigned char*) "Menu",screenwidth-110,screenheight-35,0.3,0.3); menu.setTextBoxColor(0,0,0,1); menu.drawTextBox(screenwidth-120,screenheight-80,115,60); glColor4f(1,1,1,1); glEnable(GL_LINE_SMOOTH); glLineWidth(3.0); menu.drawText(); if (isMouseInside(screenwidth-120,screenheight-80,115,60,1,1)) { menu.setTextBoxColor(1,1,1,1); menu.drawTextBox(screenwidth-120,screenheight-80,115,60); glColor4f(0,0,0,1); menu.drawText(); if(wasclicked_LB) { ingame = false; inGameMenu = true; drawMenu(); } } drawHpBar(100); drawMpBar(100); }
void OsuUISongBrowserInfoLabel::update() { CBaseUIButton::update(); if (!m_bVisible) return; // detail info tooltip when hovering over diff info if (isMouseInside() && !m_osu->getOptionsMenu()->isMouseInside()) { OsuBeatmap *beatmap = m_osu->getSelectedBeatmap(); if (beatmap != NULL) { const float speedMultiplierInv = (1.0f / m_osu->getSpeedMultiplier()); const float approachTimeRoundedCompensated = ((int)OsuGameRules::getApproachTime(beatmap)) * speedMultiplierInv; const float hitWindow300RoundedCompensated = ((int)OsuGameRules::getHitWindow300(beatmap) - 0.5f) * speedMultiplierInv; const float hitWindow100RoundedCompensated = ((int)OsuGameRules::getHitWindow100(beatmap) - 0.5f) * speedMultiplierInv; const float hitWindow50RoundedCompensated = ((int)OsuGameRules::getHitWindow50(beatmap) - 0.5f) * speedMultiplierInv; const float hitobjectRadiusRoundedCompensated = (OsuGameRules::getRawHitCircleDiameter(beatmap->getCS()) / 2.0f); m_osu->getTooltipOverlay()->begin(); m_osu->getTooltipOverlay()->addLine(UString::format("Approach time: %.2fms", approachTimeRoundedCompensated)); m_osu->getTooltipOverlay()->addLine(UString::format("300: +-%.2fms", hitWindow300RoundedCompensated)); m_osu->getTooltipOverlay()->addLine(UString::format("100: +-%.2fms", hitWindow100RoundedCompensated)); m_osu->getTooltipOverlay()->addLine(UString::format(" 50: +-%.2fms", hitWindow50RoundedCompensated)); m_osu->getTooltipOverlay()->addLine(UString::format("Spinner difficulty: %.2f", OsuGameRules::getSpinnerSpins(beatmap))); m_osu->getTooltipOverlay()->addLine(UString::format("Hit object radius: %.2f", hitobjectRadiusRoundedCompensated)); m_osu->getTooltipOverlay()->end(); } } }
void TopMenu::onRender() { _widgetsVisible = isMouseInside() && StarkUserInterface->isInteractive(); if (!_widgetsVisible) { return; } _inventoryButton->render(); _exitButton->render(); _optionsButton->render(); }
void menu::drawMainMenu() { //each char has height of around 20 pixel text newGame = text((const unsigned char*) "Newgame",100,350,0.2,0.2); text cont = text((const unsigned char*) "Continue",100,400,0.2,0.2); text opt = text((const unsigned char*) "Option",100,450,0.2,0.2); text ext = text((const unsigned char*) "Exit",100,620,0.2,0.2); glColor4f(1.0,1.0,1.0,1.0); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0); newGame.drawText(); cont.drawText(); opt.drawText(); ext.drawText(); if (isMouseInside(90,320,200,40,xOffset,yOffset)) { newGame.drawTextBox(90,320,200,40); if (wasclicked_LB) { ingame = true; inMainMenu = false; } } if (isMouseInside(90,370,200,40,xOffset,yOffset)) cont.drawTextBox(90,370,200,40); if (isMouseInside(90,420,200,40,xOffset,yOffset)) opt.drawTextBox(90,420,200,40); if (isMouseInside(90,590,200,40,xOffset,yOffset)) { ext.drawTextBox(90,590,200,40); if (wasclicked_LB) inExitMenu = true; } }
void OsuUICheckbox::update() { CBaseUICheckbox::update(); if (!m_bVisible) return; if (isMouseInside() && m_tooltipTextLines.size() > 0 && !m_bFocusStolenDelay) { m_osu->getTooltipOverlay()->begin(); for (int i=0; i<m_tooltipTextLines.size(); i++) { m_osu->getTooltipOverlay()->addLine(m_tooltipTextLines[i]); } m_osu->getTooltipOverlay()->end(); } m_bFocusStolenDelay = false; }
void SaveDataWidget::onMouseMove(const Common::Point &mousePos) { StaticLocationWidget::onMouseMove(mousePos); _isMouseHovered = isMouseInside(mousePos); }
void MGuiEditText::onEvent(MWinEvent * windowEvent) { MGuiWindow * parent = getParentWindow(); MMouse * mouse = MMouse::getInstance(); switch(windowEvent->type) { case MWIN_EVENT_MOUSE_WHEEL_MOVE: case MWIN_EVENT_MOUSE_MOVE: if(parent->isHighLight() && isMouseInside()) { setHighLight(true); if(m_pointerEvent) // send mouse move gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_MOVE; guiEvent.data[0] = windowEvent->data[0]; guiEvent.data[1] = windowEvent->data[1]; m_pointerEvent(this, &guiEvent); } // break events if(parent->breakEvents()) return; } else { setHighLight(false); } if(isPressed() && mouse->isLeftButtonPushed()) { m_endSelectionId = getFont()->findPointedCharacter( getText(), getPosition(), getTextSize(), getMouseLocalPosition() ); autoScrolling(); } break; case MWIN_EVENT_MOUSE_BUTTON_DOWN: if(isHighLight()) { if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT) { // unpress all edit text unsigned int i; unsigned int size = parent->getEditTextsNumber(); for(i=0; i<size; i++) parent->getEditText(i)->setPressed(false); setPressed(true); setCharId( getFont()->findPointedCharacter( getText(), getPosition(), getTextSize(), getMouseLocalPosition() ) ); // start select setSelection(getCharId(), getCharId()); } if(m_pointerEvent) // send mouse button down gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_BUTTON_DOWN; guiEvent.data[0] = windowEvent->data[0]; m_pointerEvent(this, &guiEvent); } } else { if(isPressed() && windowEvent->data[0] == MMOUSE_BUTTON_LEFT) { setPressed(false); sendVariable(); } } break; case MWIN_EVENT_CHAR: case MWIN_EVENT_KEY_DOWN: if(isPressed()) { editText(windowEvent); autoScrolling(); } break; } }
void MGuiWindow::onEvent(MWinEvent * windowEvent) { MMouse * mouse = MMouse::getInstance(); switch(windowEvent->type) { case MWIN_EVENT_WINDOW_RESIZE: if(m_pointerEvent) // send gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_RESIZE; m_pointerEvent(this, &guiEvent); } resizeScroll(); break; case MWIN_EVENT_KEY_DOWN: switch(windowEvent->data[0]) { case MKEY_TAB: { // editTexts unsigned int eSize = m_editTexts.size(); unsigned int i; // select next edit text for(i=0; i<eSize; i++) { if(m_editTexts[i]->isSingleLine() && m_editTexts[i]->isPressed()) { m_editTexts[i]->setPressed(false); m_editTexts[i]->sendVariable(); unsigned int nextId = i + 1; if(nextId >= eSize) nextId = 0; m_editTexts[nextId]->setPressed(true); m_editTexts[nextId]->setCharId(0); m_editTexts[nextId]->setSelection(0, strlen(m_editTexts[nextId]->getText())); return; } } break; } case MKEY_DOWN: { // editTexts unsigned int eSize = m_editTexts.size(); unsigned int i; // select next edit text for(i=0; i<eSize; i++) { if(m_editTexts[i]->isSingleLine() && m_editTexts[i]->isPressed()) { m_editTexts[i]->setPressed(false); m_editTexts[i]->sendVariable(); unsigned int nextId = i + 1; if(nextId >= eSize) nextId = 0; m_editTexts[nextId]->setPressed(true); m_editTexts[nextId]->setCharId(m_editTexts[i]->getCharId()); return; } } break; } case MKEY_UP: { // editTexts unsigned int eSize = m_editTexts.size(); unsigned int i; // select previous edit text for(i=0; i<eSize; i++) { if(m_editTexts[i]->isSingleLine() && m_editTexts[i]->isPressed()) { m_editTexts[i]->setPressed(false); m_editTexts[i]->sendVariable(); int nextId = i - 1; if(nextId < 0) nextId = eSize - 1; m_editTexts[nextId]->setPressed(true); m_editTexts[nextId]->setCharId(m_editTexts[i]->getCharId()); return; } } break; } } break; case MWIN_EVENT_MOUSE_WHEEL_MOVE: if(isHighLight()) moveScroll(MVector2(0, mouse->getWheelDirection() * (getTextSize() * 3))); break; case MWIN_EVENT_MOUSE_MOVE: if(isScrolled()) moveScroll(MVector2((float)mouse->getXDirection(), (float)mouse->getYDirection())); if(isMouseInside()){ setHighLight(true); if(m_pointerEvent) // send mouse move gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_MOVE; guiEvent.data[0] = windowEvent->data[0]; guiEvent.data[1] = windowEvent->data[1]; m_pointerEvent(this, &guiEvent); } } else{ setHighLight(false); } break; case MWIN_EVENT_MOUSE_BUTTON_DOWN: if(isHighLight()) { if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT){ setPressed(true); } if(windowEvent->data[0] == MMOUSE_BUTTON_MIDDLE){ resizeScroll(); setScrolled(true); } } if(m_pointerEvent) // send mouse button down gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_BUTTON_DOWN; guiEvent.data[0] = windowEvent->data[0]; m_pointerEvent(this, &guiEvent); } break; case MWIN_EVENT_MOUSE_BUTTON_UP: if(windowEvent->data[0] == MMOUSE_BUTTON_MIDDLE) setScrolled(false); if(windowEvent->data[0] == MMOUSE_BUTTON_LEFT) setPressed(false); if(isHighLight()) { if(m_pointerEvent) // send mouse button up gui event { MGuiEvent guiEvent; guiEvent.type = MGUI_EVENT_MOUSE_BUTTON_UP; guiEvent.data[0] = windowEvent->data[0]; m_pointerEvent(this, &guiEvent); } } break; } internalEvent(windowEvent); }