Beispiel #1
0
void Amor::slotTimeout()
{
    if( mForceHideAmorWidget ) {
        return;
    }

    if( !mTheme.isStatic() ) {
        mPosition += mCurrAnim->movement();
    }

    mAmor->setPixmap( mCurrAnim->frame() );
    mAmor->move( mTargetRect.x() + mPosition - mCurrAnim->hotspot().x(),
                 mTargetRect.y() - mCurrAnim->hotspot().y() + ( !mInDesktopBottom?mConfig.mOffset:0 ) );

    if( !mAmor->isVisible() ) {
        mAmor->show();
        restack();
    }

    if( mCurrAnim == mBaseAnim && mCurrAnim->validFrame() ) {
        // GP: Application tips/messages can be shown in any frame number; amor tips are
        // only displayed on the first frame of mBaseAnim (the old way of doing this).
        if( !mTipsQueue.isEmpty() && !mBubble &&  mConfig.mAppTips ) {
            showBubble();
        }
        else if( KRandom::random()%TIP_FREQUENCY == 1 && mConfig.mTips && !mBubble && !mCurrAnim->frameNum() ) {
            mTipsQueue.enqueue( new QueueItem( QueueItem::Tip, mTips.tip() ) );
            showBubble();
        }
    }

    if( mTheme.isStatic() ) {
        mTimer->setSingleShot( true );
        mTimer->start( ( mState == Normal ) || ( mState == Sleeping ) ? 1000 : 100 );
    }
    else {
        mTimer->setSingleShot( true );
        mTimer->start( mCurrAnim->delay() );
    }

    if( !mCurrAnim->next() ) {
        if( mBubble ) {
            mCurrAnim->reset();
        }
        else {
            selectAnimation( mState );
        }
    }
}
Beispiel #2
0
void Amor::slotBubbleTimeout()
{
    // has the queue item been displayed for long enough?
    QueueItem *first = mTipsQueue.head();

    if( first->time() > BUBBLE_TIME_STEP && mBubble->isVisible() ) {
        first->setTime( first->time() - BUBBLE_TIME_STEP );
        mBubbleTimer->setSingleShot( true );
        mBubbleTimer->start( BUBBLE_TIME_STEP );
        return;
    }

    // do not do anything if the mouse pointer is in the bubble
    if( mBubble->mouseWithin() ) {
        first->setTime( 500 );                  // show this item for another 500ms
        mBubbleTimer->setSingleShot( true );
        mBubbleTimer->start( BUBBLE_TIME_STEP );
        return;
    }

    // are there any other tips pending?
    if( mTipsQueue.count() > 1 ) {
        mTipsQueue.dequeue();
        showBubble();           // shows the next item in the queue
    }
    else {
        hideBubble( true );     // hideBubble calls dequeue() for itself.
    }
}
bool BuildingSprite::init(int index)
{
    if ( !Sprite::init() ) {
        return false;
    }
    
    _isSelected = false;
    _isTouched = false;
    _canTouched = true;
    
    _index = index;
    
    loadData(index);
    
    showUI();
    showUpgradePro();
    showBubble();
    
    addTouch();
    scheduleUpdate();
    
    // 设置名称
    this->setName("BuildingSprite");
    
    return true;
}
Beispiel #4
0
void workshopScene::render(sceneInfo &info)
{
    glMatrixMode( GL_PROJECTION );
    glLoadIdentity();
    glFrustum((-1.f * info.width) / info.height, (1.f * info.width) / info.height, -1.f, 1.f, 1.f, 1000.f);

    glMatrixMode( GL_MODELVIEW );
    glLoadIdentity();

    btQuaternion invrotate = camera.orientation.inverse();
    glRotatef(invrotate.getAngle() * RAD_TO_DEGREES, invrotate.getAxis().getX(), invrotate.getAxis().getY(), invrotate.getAxis().getZ());
    glTranslatef(-camera.position.getX(), -camera.position.getY(), -camera.position.getZ());

    GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat mat_shininess[] = { 50.0 };
    GLfloat light_position[] = { 1.2, 1.1, 1.0, 0.0 };
    glShadeModel (GL_SMOOTH);

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);

    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_DEPTH_TEST);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_COLOR_MATERIAL);
    glColor3f(1.f, 1.f, 1.f);

    glEnable(GL_CULL_FACE);

    gWorld->render();

    if (axisHasFirst)
    {
        glColor3f(1, 0, 0);
        btTransform trans = ((btRigidBody*)(axisResult.m_collisionObject))->getCenterOfMassTransform();
        btVector3 start = trans * axisFirstPivot;
        btVector3 end = trans * (axisFirstPivot + axisFirstNormal * 0.5);
        glBegin(GL_LINES);
        glVertex3f(start.getX(), start.getY(), start.getZ());
        glVertex3f(end.getX(), end.getY(), end.getZ());
        glEnd();

    }

    glPushAttrib(GL_ENABLE_BIT);

    glDisable(GL_CULL_FACE);
    glDisable(GL_LIGHTING);
    glDisable(GL_DEPTH_TEST);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0.f, info.width, info.height, 0.f, -1.f, 1.f);

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnable(GL_TEXTURE_2D);

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

    glColor3f(1.f, 1.f, 1.f);

    panel.draw(0, UI_SIZE + 16, info.height, 0);

    glPushAttrib(GL_SCISSOR_BIT);
    glEnable(GL_SCISSOR_TEST);
    glScissor(8, 8, UI_SIZE, info.height - 16);
    for (unsigned int i = 0; i < thumbnails.size(); i++)
    {
        int basex = 8;
        int basey = 8 + (UI_SIZE + 8) * i;
        if (i == selectedItem)
            glColor3f(1.f, 1.f, 0.5f);
        else
            glColor3f(1.f, 1.f, 1.f);

        button.draw(basex, basex + UI_SIZE, basey + UI_SIZE, basey);
        glBindTexture(GL_TEXTURE_2D, thumbnails[i]);
        texturedQuad(basex + 8, basex + (UI_SIZE - 8), basey + (UI_SIZE - 8), basey + 8);
    }
    glPopAttrib();
    panel.draw(UI_SIZE + 16, info.width, info.height, info.height - UI_SMALL - 16);
    glColor3f(1.f, 1.f, 1.f);
    for (unsigned int i = 0; i < tooltextures.size(); i++)
    {
        int basex = UI_SIZE + 16 + 8 + (UI_SMALL + 8) * i;
        int basey = info.height - 8 - UI_SMALL;
        if (i == selectedTool)
            glColor3f(1.f, 1.f, 0.5f);
        else
            glColor3f(1.f, 1.f, 1.f);
        button.draw(basex, basex + UI_SMALL, basey + UI_SMALL, basey);
        glBindTexture(GL_TEXTURE_2D, tooltextures[i]);
        texturedQuad(basex + 8, basex + UI_SMALL - 8, basey + UI_SMALL - 8, basey + 8);
    }
    glColor3f(1.f, 1.f, 1.f);
    if (info.captureMouse)
    {
        if (mousevelx * mousevelx + mousevely * mousevely < 1.f)
            glColor3f(1, 0, 0);
        glBindTexture(GL_TEXTURE_2D, cursor);
        texturedQuad(cursorx, cursorx + 20, cursory + 20, cursory);
        glBindTexture(GL_TEXTURE_2D, 0);
        glBegin(GL_LINES);
        glVertex2f(cursorx, cursory);
        glVertex2f(cursorx + mousevelx, cursory + mousevely);
        glEnd();

    }

    if (mousevelx * mousevelx + mousevely * mousevely < 1.f && mouseRayCallback.hasHit())
        showBubble(cursorx, cursory, gWorld->findObj((btRigidBody*)mouseRayCallback.m_collisionObject)->tag);


    /*glBindTexture(GL_TEXTURE_2D, font);
    info.keybuffer.push_back(0);
    print(100, 100, &info.keybuffer[0]);
    glBindTexture(GL_TEXTURE_2D, stbfont);
    texturedQuad(100, 200, 500, 400);
    stbprint(100, 300, &info.keybuffer[0]);
    info.keybuffer.erase(info.keybuffer.end() - 1);*/

    glPopAttrib();
}