Exemplo n.º 1
0
void AddContactBox::onSave() {
	if (_addRequest) return;

	QString firstName = prepareText(_first->getLastText());
	QString lastName = prepareText(_last->getLastText());
	QString phone = _phone->getLastText().trimmed();
	if (firstName.isEmpty() && lastName.isEmpty()) {
		if (_invertOrder) {
			_last->setFocus();
			_last->showError();
		} else {
			_first->setFocus();
			_first->showError();
		}
		return;
	} else if (!_user && !App::isValidPhone(phone)) {
		_phone->setFocus();
		_phone->showError();
		return;
	}
	if (firstName.isEmpty()) {
		firstName = lastName;
		lastName = QString();
	}
	_sentName = firstName;
	if (_user) {
		_contactId = rand_value<uint64>();
		QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(_user->phone()), MTP_string(firstName), MTP_string(lastName)));
		_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onSaveUserDone), rpcFail(&AddContactBox::onSaveUserFail));
	} else {
		_contactId = rand_value<uint64>();
		QVector<MTPInputContact> v(1, MTP_inputPhoneContact(MTP_long(_contactId), MTP_string(phone), MTP_string(firstName), MTP_string(lastName)));
		_addRequest = MTP::send(MTPcontacts_ImportContacts(MTP_vector<MTPInputContact>(v), MTP_bool(false)), rpcDone(&AddContactBox::onImportDone));
	}
}
Exemplo n.º 2
0
QuestState::QuestState(SystemManager* system) :
textShown(), marginRectangle(20.f), positionText(0), fontSize(20), textFinish(false), radius(10) {
    quest = static_cast<SystemQuest*>
            (system->getSystem(TypeSystem::QUEST));

    graphics = static_cast<SystemGraphic*>
            (system->getSystem(TypeSystem::GRAPHIC));

    
    text = quest->toString();//L"Mostrando algunas quests...";
    

    textShown.setCharacterSize(fontSize);
    font = &(graphics->getFonts().get(IDFonts::Main));
    textShown.setFont(*font);
    marginPhrases = font->getLineSpacing(fontSize);

    sf::RenderTarget& target = graphics->getTarget();
    sf::View view = target.getView();
    sf::Vector2f sizeView = view.getSize();
    sizeRectangle = sizeView;
    sizeRectangle.y = sizeRectangle.y * 0.15;
    //minima altura
    sizeRectangle.y = std::min(sizeRectangle.y, 100.f);
    //maxima altura
    sizeRectangle.y = std::max(sizeRectangle.y, 150.f);

    prepareText();
}
Exemplo n.º 3
0
bool QuestState::handleEvent(const sf::Event& event) {
    if (event.type == sf::Event::KeyPressed && event.key.code == sf::Keyboard::Return) {
        setEnded();
    } else if (event.type == sf::Event::KeyPressed) {
        prepareText();
    }
    return true;
}
Exemplo n.º 4
0
void MMSLabelWidget::calcContentSize() {
    int width, height;

    if (prepareText(&width, &height, true)) {
        // text is translated and font is set
        setContentSize(width, height);
    }
}
Exemplo n.º 5
0
void TextOutDisplay::callbackText( const std_msgs::String::ConstPtr& msg )
{
    text_ = prepareText( msg->data );
    if( user_input_ )
    {
       reset_timer_->start( text_.length() * 10  );
    }
}
Exemplo n.º 6
0
void FestivalSynthesizer::callbackSynth( const std_msgs::String::ConstPtr& msg )
{
    text_for_synth_ = prepareText( msg->data );
    if( text_for_synth_.length() > 0 )
    {
        synth_speech_ = true;
    }
}
Exemplo n.º 7
0
Game::Game()
: mWindow(sf::VideoMode(windowWidth, windowHeight), "Silkworm's Tetris", sf::Style::Close)
, grid(mWindow.getSize())
, silkworm()
{
    framesSinceBlocksMoved = 0;
    font.loadFromFile(resourcePath() + "sansation.ttf");
    prepareText(linesScoredText, 20);
    prepareText(scoreText, 20 + 1.1 * Game::characterSize);
    prepareText(levelText, 20 + 2 * 1.1 * Game::characterSize);
    
    theBoys.loadFromFile("/Users/clavery/Desktop/chown_laudie/jounce_with-my_friends.png");
    theMusicians.setTexture(theBoys);
    theMusicians.setPosition(450.f, 500.f);
    
    if (!silkworm.openFromFile(resourcePath() + "slow_hands.ogg"))
    {
        std::cout << "THE F****N' MUSIC ISN'T PLAYING!";
    }
    silkworm.setLoop(true);
    silkworm.play();
}
Exemplo n.º 8
0
void QcTextEdit::keyPressEvent( QKeyEvent *e )
{
  if( _interpretSelection && e->modifiers() & (Qt::ControlModifier|Qt::ShiftModifier)
      && ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) )
  {
    QTextCursor c(textCursor());

    if ( !c.hasSelection() ) {
      c.movePosition( QTextCursor::StartOfLine );
      c.movePosition( QTextCursor::EndOfLine, QTextCursor::KeepAnchor );
    }

    if ( c.hasSelection() ) {
      QString selection( c.selectedText() );
      Q_EMIT( interpret( prepareText(selection) ) );
    }

    return;
  }

  QTextEdit::keyPressEvent( e );
}
Exemplo n.º 9
0
void initGame(XStuff* xs, GameState* gs) {
	int ww, wh;
	
	glerr("left over error on game init");
	
	
	gs->activeTool = 0;
	
	gs->debugMode = 0;
	gs->sunSpeed = 0;
	
	
	ww = xs->winAttr.width;
	wh = xs->winAttr.height;
	
	gs->screen.wh.x = (float)ww;
	gs->screen.wh.y = (float)wh;
	
	gs->screen.aspect = gs->screen.wh.x / gs->screen.wh.y;
	gs->screen.resized = 0;
	
	
	printf("w: %d, h: %d\n", ww, wh);
	
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	
	glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
	
	initTexBuffers(gs, 0);

	glBindTexture(GL_TEXTURE_2D, 0);
	
	glGenFramebuffers(1, &gs->framebuffer);
	glBindFramebuffer(GL_FRAMEBUFFER, gs->framebuffer);
	glexit("fbo creation");
	
	// The depth buffer
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gs->diffuseTexBuffer, 0);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, gs->normalTexBuffer, 0);
	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, gs->selectionTexBuffer, 0);
 	glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, gs->depthTexBuffer, 0);
	glexit("fb tex2d");
	
//glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, gs->depthTexBuffer, 0);
	
	GLenum DrawBuffers[] = {
		GL_COLOR_ATTACHMENT0,
		GL_COLOR_ATTACHMENT1,
		GL_COLOR_ATTACHMENT2
	};
	glDrawBuffers(3, DrawBuffers);
	glexit("drawbuffers");
	
	GLenum status;
	status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
	if(status != GL_FRAMEBUFFER_COMPLETE) {
		printf("fbo status invalid\n");
		exit(1);
	}
	printf("FBO created.\n");
	

	shadingProg = loadCombinedProgram("shading");
	initFSQuad();
	
	// check some prerequisites
// 	GLint MaxDrawBuffers = 0;
// 	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &MaxDrawBuffers);
// 	printf("MAX_DRAW_BUFFERS: %d\n", MaxDrawBuffers);
//  	if(MaxDrawBuffers < 4) {
// 		fprintf(stderr, "FATAL: GL_MAX_DRAW_BUFFERS is too low: %d. Minimum required value is 4.\n", MaxDrawBuffers);
// 		exit(3);
// 	};

	getPrintGLEnum(GL_MAX_COLOR_ATTACHMENTS, "meh");
	getPrintGLEnum(GL_MAX_DRAW_BUFFERS, "meh");
	getPrintGLEnum(GL_MAX_FRAMEBUFFER_WIDTH, "meh");
	getPrintGLEnum(GL_MAX_FRAMEBUFFER_HEIGHT, "meh");
	getPrintGLEnum(GL_MAX_FRAMEBUFFER_LAYERS, "meh");
	getPrintGLEnum(GL_MAX_FRAMEBUFFER_SAMPLES, "meh");
	getPrintGLEnum(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, "meh");
	getPrintGLEnum(GL_MAX_TESS_EVALUATION_TEXTURE_IMAGE_UNITS, "meh");
	getPrintGLEnum(GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS, "meh");
	getPrintGLEnum(GL_MAX_TEXTURE_IMAGE_UNITS, "meh");
	getPrintGLEnum(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, "meh");
	getPrintGLEnum(GL_MAX_ARRAY_TEXTURE_LAYERS, "meh");
	getPrintGLEnum(GL_MAX_SAMPLES, "meh");
	
	
	// set up matrix stacks
	MatrixStack* view, *proj;
	
	view = &gs->view;
	proj = &gs->proj;
	
	msAlloc(2, view);
	msAlloc(2, proj);

	msIdent(view);
	msIdent(proj);
	

	
	
	// perspective matrix, pretty standard
// 	msPerspective(60, 1.0, 01000.0f, 100000.0f, proj);
// 		msOrtho(0, 1, 0, 1, .01, 100000, proj);

	gs->zoom = -760.0;
	gs->direction = 0.0f;
	gs->lookCenter.x = 128;
	gs->lookCenter.y = 128;
	
	
	// initialize all those magic globals
	initMap(&gs->map);
	
	initUI(gs);
	initMarker();
	
	// text rendering stuff
	arial = LoadFont("Arial", 64, NULL);
	glerr("clearing before text program load");
	textProg = loadCombinedProgram("text");
	
	unsigned int colors[] = {
		0xFF0000FF, 2,
		0x00FF00FF, 4,
		0x0000FFFF, INT_MAX
	};
	
	strRI = prepareText(arial, "FPS: --", -1, colors);
	/*
	OBJContents cube;
	loadOBJFile("assets/models/untitled.obj", 0, &cube);
	Mesh* cubem = OBJtoMesh(&cube);
	*/
	
}
Exemplo n.º 10
0
QString QcTextEdit::selectedString() const
{
  QString selection( textCursor().selectedText() );
  return prepareText(selection);
}
Exemplo n.º 11
0
bool MMSLabelWidget::draw(bool *backgroundFilled) {
    int width, height, x, y;
    bool myBackgroundFilled = false;

    if(!surface)
        return false;

    if (backgroundFilled) {
        if (this->has_own_surface)
            *backgroundFilled = false;
    }
    else
        backgroundFilled = &myBackgroundFilled;

    // lock
    this->surface->lock();

    // draw widget basics
    if (MMSWidget::draw(backgroundFilled)) {
        // draw my things
        if (prepareText(&width, &height)) {
            // text is translated and font is set
            MMSFBRectangle surfaceGeom = getSurfaceGeometry();

            // save the width of the text
            this->slide_width = width;

            switch ((!this->swap_left_right) ? getAlignment() : swapAlignmentHorizontal(getAlignment())) {
            case MMSALIGNMENT_LEFT:
                x = surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_LEFT:
                x = surfaceGeom.x;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_TOP_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = surfaceGeom.y;
                break;
            case MMSALIGNMENT_BOTTOM_CENTER:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            case MMSALIGNMENT_BOTTOM_LEFT:
                x = surfaceGeom.x;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            case MMSALIGNMENT_BOTTOM_RIGHT:
                x = surfaceGeom.x + surfaceGeom.w - width;
                y = surfaceGeom.y + surfaceGeom.h - height;
                break;
            default:
                x = ((surfaceGeom.w - width) / 2) + surfaceGeom.x;
                y = ((surfaceGeom.h - height) / 2) + surfaceGeom.y;
                break;
            }

            // get color
            MMSFBColor color;
            getForeground(&color);
            this->current_fgcolor   = color;
            this->current_fgset     = true;

            if (color.a) {
                // prepare for drawing
                this->surface->setDrawingColorAndFlagsByBrightnessAndOpacity(
                    color,
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP):getShadowColor(MMSPOSITION_TOP),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM):getShadowColor(MMSPOSITION_BOTTOM),
                    (isSelected())?getSelShadowColor(MMSPOSITION_LEFT):getShadowColor(MMSPOSITION_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_RIGHT):getShadowColor(MMSPOSITION_RIGHT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP_LEFT):getShadowColor(MMSPOSITION_TOP_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_TOP_RIGHT):getShadowColor(MMSPOSITION_TOP_RIGHT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_LEFT):getShadowColor(MMSPOSITION_BOTTOM_LEFT),
                    (isSelected())?getSelShadowColor(MMSPOSITION_BOTTOM_RIGHT):getShadowColor(MMSPOSITION_BOTTOM_RIGHT),
                    getBrightness(), getOpacity());

                // draw the text
                this->surface->drawString(this->translated_text, -1, x - this->slide_offset, y);
            }
        }

        // update window surface with an area of surface
        updateWindowSurfaceWithSurface(!*backgroundFilled);
    }

    // unlock
    this->surface->unlock();

    // draw widgets debug frame
    return MMSWidget::drawDebug();
}
Exemplo n.º 12
0
void TextButton::render() {
#ifndef OPENBLOX_NO_GRAPHICS
    if(tex == 0) {
        glGenTextures(1, &tex);
    }
    if(Visible) {
        QRectF drawRect = QRectF(QRect(AbsolutePosition->x, AbsolutePosition->y, AbsoluteSize->x, AbsoluteSize->y));
        ob_type::Color3* bgColor = BackgroundColor3;
        ob_type::Color3* borderColor = BorderColor3;
        float bgTrans = BackgroundTransparency;
        double RotationAtRender = Rotation;
        ob_type::Color3* txtColor = TextColor3;

        double halfX = drawRect.x() + (drawRect.width()/2);
        double halfY = drawRect.y() + (drawRect.height()/2);
        glTranslated(halfX, halfY, 0);
        glRotated(RotationAtRender, 0, 0, 1);
        glTranslated(-halfX, -halfY, 0);

        glColor4d(bgColor->r, bgColor->g, bgColor->b, 1 - bgTrans);

        const GLdouble vertices[] {
            drawRect.x(), drawRect.y() + drawRect.height(), //Bottom Left
            drawRect.x(), drawRect.y(), //Top Left
            drawRect.x() + drawRect.width(), drawRect.y(), //Top Right
            drawRect.x() + drawRect.width(), drawRect.y() + drawRect.height(), //Bottom Right
        };

        glEnableClientState(GL_VERTEX_ARRAY);

        glVertexPointer(2, GL_DOUBLE, 0, vertices);
        glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, quad_indices);

        if(needsRecalc) { //Needs to be done on render thread
            needsRecalc = false;
            prepareText(tex, Font, Text, 0, 0, 0, 0, ob_enum::TextXAlignment::Left, ob_enum::TextYAlignment::Top, {255, 255, 255, 255}, NULL, NULL, &tw, &th);
        } else {
            glBindTexture(GL_TEXTURE_2D, tex);
        }

        int tx = drawRect.x();
        int ty = drawRect.y();

        if(TextXAlignment != ob_enum::TextXAlignment::Left && TextYAlignment != ob_enum::TextYAlignment::Top) {
            if(TextXAlignment == ob_enum::TextXAlignment::Center) {
                tx = drawRect.x() + (drawRect.width() / 2) - (tw / 2);
            }
            if(TextXAlignment == ob_enum::TextXAlignment::Right) {
                tx = drawRect.x() + drawRect.width() - tw;
            }
            if(TextYAlignment == ob_enum::TextYAlignment::Center) {
                ty = drawRect.y() + (drawRect.height() / 2) - (th / 2);
            }
            if(TextYAlignment == ob_enum::TextYAlignment::Bottom) {
                ty = drawRect.y() + drawRect.height() - th;
            }
        }

        if(TextYAlignment == ob_enum::TextYAlignment::Top) {
            ty = ty - 6;
        }

        {
            const GLdouble minX = tx;
            const GLdouble maxX = minX + tw;
            const GLdouble minY = ty;
            const GLdouble maxY = minY + th;

            glColor4d(txtColor->r, txtColor->g, txtColor->b, 1 - TextTransparency);

            const GLdouble vertices[] {
                minX, maxY, //Bottom Left
                minX, minY, //Top Left
                maxX, minY, //Top Right
                maxX, maxY, //Bottom Right
            };

            glEnableClientState(GL_TEXTURE_COORD_ARRAY);

            glVertexPointer(2, GL_DOUBLE, 0, vertices);
            glTexCoordPointer(2, GL_FLOAT, 0, quad_texCoords);

            glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_BYTE, quad_indices);

            glBindTexture(GL_TEXTURE_2D, 0);
            glDisableClientState(GL_TEXTURE_COORD_ARRAY);
        }

        glBindTexture(GL_TEXTURE_2D, 0);

        int bsp = BorderSizePixel;
        if(bsp > 0) {
            const GLdouble line_vertices[] {
                drawRect.x(), drawRect.y() + drawRect.height() + bsp, //Bottom Left
                drawRect.x(), drawRect.y() - bsp, //Top Left
                drawRect.x() + drawRect.width() + bsp, drawRect.y(), //Top Right
                drawRect.x() + drawRect.width(), drawRect.y() + drawRect.height() + bsp, //Bottom Right
                drawRect.x() - bsp, drawRect.y(), //Top Left Second Pass
                drawRect.x() + drawRect.width(), drawRect.y() - bsp, //Top Right Second Pass,
                drawRect.x() + drawRect.width() + bsp, drawRect.y() + drawRect.height(), //Bottom Right Second Pass
                drawRect.x() - bsp, drawRect.y() + drawRect.height()
            };
            glVertexPointer(2, GL_DOUBLE, 0, line_vertices);

            glColor4d(borderColor->r, borderColor->g, borderColor->b, 1 - bgTrans);

            glLineWidth(bsp);

            glDrawElements(GL_LINES, 8, GL_UNSIGNED_BYTE, quad_lines);
        }

        glDisableClientState(GL_VERTEX_ARRAY);

        std::vector<GuiObject*> toRender;
        for(std::vector<Instance*>::size_type i = 0; i != children.size(); i++) {
            Instance* kid = children[i];
            if(kid) {
                if(GuiObject* go = dynamic_cast<GuiObject*>(kid)) {
                    toRender.push_back(go);
                }
            }
        }
        std::sort(toRender.begin(), toRender.end(), [](GuiObject* go1, GuiObject* go2)->bool{
            return go1->getZIndex() < go2->getZIndex();
        });
        for(std::vector<GuiObject*>::size_type i = 0; i != toRender.size(); i++) {
            GuiObject* kid = toRender[i];
            if(kid) {
                kid->render();
            }
        }

        glTranslated(halfX, halfY, 0);
        glRotated(-RotationAtRender, 0, 0, 1);
        glTranslated(-halfX, -halfY, 0);
    }
#endif
}