GDWindow::GDWindow(BRect frame) : BWindow(frame, "GrafDemo 4.6", B_DOCUMENT_WINDOW,0) { Lock(); // Add the graph to the window BRect grafRect = Bounds(); grafRect.top += mb_height + 2; mGraphView= new GDView(grafRect); AddChild(mGraphView); SetSizeLimits(frame.right - frame.left,9999,frame.bottom - frame.top,9999); // Add the main menu bar and menus BRect menuRect(0,0,1000,mb_height); BMenuBar* menuBar = new BMenuBar(menuRect,"MB"); BMenu* fileMenu = new BMenu("File"); BMenuItem* aboutItem = new BMenuItem("About...",new BMessage(B_ABOUT_REQUESTED)); aboutItem->SetTarget(be_app); fileMenu->AddItem(aboutItem); fileMenu->AddSeparatorItem(); fileMenu->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED))); menuBar->AddItem(fileMenu); BMenu* editMenu = new BMenu("Edit"); editMenu->AddItem(new BMenuItem("Erase",new BMessage(G_erase_data))); editMenu->AddItem(new BMenuItem("Reset Axes",new BMessage(G_reset_axes))); editMenu->SetTargetForItems(mGraphView); menuBar->AddItem(editMenu); BMenu* paramsMenu = new BMenu("Params"); BMessage* cFitMesg = new BMessage(G_set_params); cFitMesg->AddInt16(pName,0); BMessage* p2Mesg = new BMessage(G_set_params); p2Mesg->AddInt16(pName,2); BMessage* p3Mesg = new BMessage(G_set_params); p3Mesg->AddInt16(pName,3); BMessage* p4Mesg = new BMessage(G_set_params); p4Mesg->AddInt16(pName,4); paramsMenu->AddItem(new BMenuItem("Cubic Spline",cFitMesg)); paramsMenu->AddSeparatorItem(); paramsMenu->AddItem(new BMenuItem("1st Order",p2Mesg)); paramsMenu->AddItem(new BMenuItem("2nd Order",p3Mesg)); paramsMenu->AddItem(new BMenuItem("3rd Order",p4Mesg)); paramsMenu->SetRadioMode(true); paramsMenu->FindItem("2nd Order")->SetMarked(true); paramsMenu->SetTargetForItems(mGraphView); menuBar->AddItem(paramsMenu); BMenu* axisMenu = new BMenu("Axes"); axisMenu->AddItem(new BMenuItem("Set Axes"B_UTF8_ELLIPSIS,new BMessage(G_change_axis))); axisMenu->SetTargetForItems(mGraphView); menuBar->AddItem(axisMenu); AddChild(menuBar); Unlock(); }
void RLIDisplayWidget::paintGL() { if (!_initialized) return; int curr_second = QTime::currentTime().second(); if (curr_second != _last_second) { _last_second = curr_second; emit per_second(); } glViewport(0, 0, width(), height()); // Fill widget with black glClearColor(0.33f, 0.33f, 0.33f, 1.0f); glClear(GL_COLOR_BUFFER_BIT); // Push back the current matrices and go orthographic for background rendering. glMatrixMode( GL_PROJECTION ); glPushMatrix(); glLoadIdentity(); glOrtho(0, width(), height(), 0, -1, 1 ); QPoint hole_center = _maskEngine->getCenter(); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); glTranslatef(hole_center.x()+.5f, hole_center.y()+.5f, 0); float radar_rad = _radarEngine->getSize() / 2.f; QRectF radarRect(-radar_rad, -radar_rad, 2*radar_rad, 2*radar_rad); fillRectWithTexture(radarRect, _chartEngine->getTextureId()); fillRectWithTexture(radarRect, _radarEngine->getTextureId()); glMatrixMode( GL_MODELVIEW ); glPopMatrix(); QPoint center = _controlsEngine->getCenterPos(); glMatrixMode( GL_MODELVIEW ); glPushMatrix(); glLoadIdentity(); glTranslatef(center.x()+.5f, center.y()+.5f, 0); //_scale - радиус дырки в маске в пикселях // scale в update - метров/пиксель float scale = (_rli_scale.len*1852.f) / _maskEngine->getRadius(); if (_route_edition) { QVector2D _route_last = _routeEngine->getLastPoint(); QPointF v_pos = RLIMath::coords_to_pos(_world_coords, _route_last, QPoint(0, 0), scale); _controlsEngine->setVisorShift(v_pos.toPoint()); } else { _controlsEngine->setVisorShift(QPoint(0, 0)); } glEnable(GL_BLEND); _controlsEngine->draw(); _targetEngine->draw(_world_coords, scale); _routeEngine->draw(_world_coords, scale); glMatrixMode( GL_MODELVIEW ); glPopMatrix(); fillWithTexture(_maskEngine->getTextureId()); for (int i = 0; i < _infoEngine->getBlockCount(); i++) fillRectWithTexture(_infoEngine->getBlockGeometry(i), _infoEngine->getBlockTextId(i)); QRectF menuRect(_menuEngine->position(), _menuEngine->size()); fillRectWithTexture(menuRect, _menuEngine->getTextureId()); if (_is_magnifier_visible) { QRectF magRect(_magnifierEngine->position(), _magnifierEngine->size()); fillRectWithTexture(magRect, _magnifierEngine->getTextureId()); } glMatrixMode( GL_PROJECTION ); glPopMatrix(); glFlush(); _radarEngine->updateTexture(); _maskEngine->update(); _menuEngine->update(); _magnifierEngine->update(); _infoEngine->update(); glEnable(GL_BLEND); _chartEngine->update(_world_coords, scale, 0.f, center-hole_center); glFlush(); }
int MainMenu::handle(int dim) { int command = -1; uint8 colorMap[16]; memset(colorMap, 0, sizeof(colorMap)); _screen->setTextColorMap(colorMap); Screen::FontId oldFont = _screen->setFont(_static.font); int charWidthBackUp = _screen->_charWidth; if (_vm->game() != GI_LOL) _screen->_charWidth = -2; _screen->setScreenDim(dim); int backUpX = _screen->_curDim->sx; int backUpY = _screen->_curDim->sy; int backUpWidth = _screen->_curDim->w; int backUpHeight = _screen->_curDim->h; _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 0, 3); int x = _screen->_curDim->sx << 3; int y = _screen->_curDim->sy; int width = _screen->_curDim->w << 3; int height = _screen->_curDim->h; drawBox(x, y, width, height, 1); drawBox(x + 1, y + 1, width - 2, height - 2, 0); int selected = 0; draw(selected); while (!_screen->isMouseVisible()) _screen->showMouse(); int fh = _screen->getFontHeight(); if (_vm->gameFlags().lang == Common::JA_JPN) fh++; int textPos = ((_screen->_curDim->w >> 1) + _screen->_curDim->sx) << 3; Common::Rect menuRect(x + 16, y + 4, x + width - 16, y + 4 + fh * _static.menuTable[3]); while (!_vm->shouldQuit()) { updateAnimation(); bool mousePressed = getInput(); Common::Point mouse = _vm->getMousePos(); if (menuRect.contains(mouse)) { int item = (mouse.y - menuRect.top) / fh; if (item != selected) { printString("%s", textPos, menuRect.top + selected * fh, _static.menuTable[5], 0, 5, _static.strings[selected]); printString("%s", textPos, menuRect.top + item * fh, _static.menuTable[6], 0, 5, _static.strings[item]); selected = item; } if (mousePressed) { for (int i = 0; i < 3; i++) { printString("%s", textPos, menuRect.top + selected * fh, _static.menuTable[5], 0, 5, _static.strings[selected]); _screen->updateScreen(); _system->delayMillis(50); printString("%s", textPos, menuRect.top + selected * fh, _static.menuTable[6], 0, 5, _static.strings[selected]); _screen->updateScreen(); _system->delayMillis(50); } command = item; break; } } _system->delayMillis(10); } if (_vm->shouldQuit()) command = -1; _screen->copyRegion(backUpX, backUpY, backUpX, backUpY, backUpWidth, backUpHeight, 3, 0); _screen->_charWidth = charWidthBackUp; _screen->setFont(oldFont); return command; }
void LevelListScene::_build() { cocos2d::Vec2 visibleOrigin = cocos2d::Director::getInstance()->getVisibleOrigin(); cocos2d::Size visibleSize = cocos2d::Director::getInstance()->getVisibleSize(); //auto background = cocos2d::Sprite::create("background.png"); //background->setAnchorPoint(cocos2d::Vec2::ZERO); //background->setPosition(cocos2d::Vec2::ZERO); //background->setOpacity(0); //addChild(background); //background->runAction(cocos2d::FadeIn::create(0.5)); auto levelPack = _game->getLevelPack(_packIndex); const std::vector<LevelPackEntry>& entries = levelPack->getEntries(); cocos2d::Rect menuRect(visibleOrigin.x + 100, visibleOrigin.y + 100, visibleSize.width - 200, visibleSize.height - 140); cocos2d::Size cellSize(menuRect.size.width / 5, menuRect.size.height / 5); cocos2d::Vec2 point(0, menuRect.size.height - cellSize.height); bool prevLevelCompleted = true; for (size_t i = 0; i + _startLevelIndex < entries.size() && i < 25; i++) { int levelIndex =_startLevelIndex + i; auto& record = _game->getHighscores()->getRecord(_packIndex, levelIndex); bool canStart = prevLevelCompleted || record.tried; auto button = cocos2d::ui::Button::create(canStart ? "slide-north-0001.png" : "floor.png", "", "", cocos2d::ui::Widget::TextureResType::PLIST); button->setAnchorPoint(cocos2d::Vec2(0.5f, 0.5f)); button->setPosition(menuRect.origin + point + cocos2d::Vec2(cellSize) * 0.5f - cocos2d::Vec2(0, 100)); button->setScale(0); button->setEnabled(canStart); button->addTouchEventListener([this, levelIndex](cocos2d::Ref* sender, cocos2d::ui::Widget::TouchEventType type) { if (type == cocos2d::ui::Widget::TouchEventType::ENDED) { auto director = cocos2d::Director::getInstance(); director->pushScene(LevelScene::create(_game, _packIndex, _startLevelIndex + levelIndex)); } }); if (canStart) { auto buttonLabel = cocos2d::Label::createWithTTF(std::to_string(i + 1), "fonts/Marker Felt.ttf", 24); buttonLabel->setPosition(cocos2d::Vec2(button->getContentSize()) * 0.5f); buttonLabel->setAnchorPoint(cocos2d::Vec2(0.5f, 0.5f)); buttonLabel->enableOutline(cocos2d::Color4B::BLACK, 2); button->addChild(buttonLabel); } addChild(button); if (record.completed) { auto star = cocos2d::Sprite::createWithSpriteFrameName("ic-chip.png"); star->setPosition(cocos2d::Vec2(button->getContentSize().width - 10, 11)); button->addChild(star); } if (i % 5 != 4) { point.x += cellSize.width; } else { point.x = 0; point.y -= cellSize.height; } button->runAction(cocos2d::Sequence::create( cocos2d::DelayTime::create(0.01 * i), cocos2d::Spawn::create( cocos2d::EaseBounceIn::create(cocos2d::ScaleTo::create(0.25, 1)), cocos2d::MoveBy::create(0.25, cocos2d::Vec2(0, 100)), nullptr ), nullptr )); prevLevelCompleted = record.completed; } /*auto backButton = cocos2d::MenuItemSprite::create(cocos2d::Sprite::create("boots-ice.png"), nullptr, CC_CALLBACK_1(LevelsScene::_backCallback, this)); backButton->setPosition(cocos2d::Vec2(100, 60)); menu->addChild(backButton);*/ }