Ejemplo n.º 1
0
void ChessSelectionWidget::okPushButtonClicked()
{
    if(isOK())
    {
        ChessType type = AIType;
        QString stype(tr("ai"));
        if(serverRadioButton->isChecked())
        {
            type = ServerType;
            stype = tr("server");
        }
        else if(clientRadioButton->isChecked())
        {
            type = ClientType;
            stype = tr("client");
        }
        else if(replayRadioButton->isChecked())
        {
            type = ReplayType;
            stype = tr("replay");
        }
        ChessColor color = RedColor;
        QString scolor("red");
        if(ClientType == type)
        {
            color = BlackColor;
            scolor = tr("black");
        }
        Chess_Info(tr("your selection: type=%1 color=%2 ip=%3 port=%4")
                   .arg(stype)
                   .arg(scolor)
                   .arg(ipLineEdit->text())
                   .arg(portSpinBox->value()));
        ChessInformation *ci = ChessInformation::instance();
        ci->init(type, color, ipLineEdit->text(), portSpinBox->value());
        Chess *chess = Chess::instance();
        chess->setAttribute(Qt::WA_DeleteOnClose);  //窗口关闭时自动删除
        this->hide();
        chess->show();
    }
    else
    {
        Chess_Warning(tr("error input, please check!"));
        QMessageBox::warning(this, tr("ERROR INPUT"), tr("ERROR INPUT, PLEASE CHECK!"));
    }
}
Ejemplo n.º 2
0
EnergyBarNode::EnergyBarNode(scene::ISceneNode* parent, 
			  scene::ISceneManager* mgr, 
			  s32 id, 
			  float width, 
			  float height,
			  video::SColor startColor,
			  video::SColor endColor,
			  video::SColor frameColor,
			  int type
			  ) :  
	  Base2dNode(parent, mgr, id),
	  mEnergyValue(1.0f),
	  mEnergyNeedsUpdate(true),
	  mStartColor(startColor),
	  mEndColor(endColor),
	  mFrameColor(frameColor),
	  mHeight(height),
	  mWidth(width),
	  mType(type)
{
	float textSize=512.0f;
	float tx =  0.0f/ textSize;
	float ty =  0.0f / textSize;
	float tx2 =  76.0f / textSize;
	float ty2 =  160.0f/ textSize;

	if(type == 0)
	{
		tx =  0.0f/ textSize;
		ty =  0.0f / textSize;
		tx2 =  76.0f / textSize;
		ty2 =  160.0f/ textSize;
		frameUV1.set(tx, ty);
		frameUV2.set(tx2, ty2);
		tx =  78.0f/ textSize;
		ty =  0.0f / textSize;
		tx2 =  118.0f / textSize;
		ty2 =  160.0f/ textSize;	
		barUV1.set(tx, ty);
		barUV2.set(tx2, ty2);
		mXFactor=0.0f;
		mYFactor=0.0f;
		mXFactor2=0.0f;
		mYFactor2=12.0f / textSize;

		mXFactor2=9.0f / textSize;	
		mXFactor = mYFactor2/(ty2-ty);
		mXFactor = mXFactor * width;
		mYFactor = mXFactor2/(tx2-tx);
		mYFactor = mYFactor * height;
	}
	else
	{
		tx =  128.0f/ textSize;
		ty =  0.0f / textSize;
		tx2 = 511.0f / textSize;
		ty2 =  76.0f/ textSize;
		frameUV1.set(tx, ty);
		frameUV2.set(tx2, ty2);
		tx =  128.0f/ textSize;
		ty =  78.0f / textSize;
		tx2 =  511.0f / textSize;
		ty2 =  118.0f/ textSize;	
		barUV1.set(tx, ty);
		barUV2.set(tx2, ty2);
		mXFactor=0.0f;
		mYFactor=0.0f;
		mXFactor2=0.0f;
		mYFactor2=12.0f / textSize;
		mXFactor2=9.0f / textSize;	

		mXFactor = mYFactor2/(tx2-tx);
		mXFactor = mXFactor * width;

		mYFactor = mXFactor2/(ty2-ty);
		mYFactor = mYFactor * height;
	
	}



	irr::video::SColor scolor(255,255,255,255);

	mMaterial.Wireframe = false;
	mMaterial.Lighting = false;
	mMaterial.AmbientColor = scolor;
	mMaterial.DiffuseColor = scolor;
	mMaterial.EmissiveColor  = scolor;
	mMaterial.MaterialType = EMT_TRANSPARENT_ALPHA_CHANNEL;


	//internal frame
	/*
	vertices[0] = video::S3DVertex(-width/2, height/2,0.01f,0,0,0, mFrameColor,0,0);
	vertices[1] = video::S3DVertex( width/2, height/2,0.01f,0,0,0, mFrameColor,0,1);
	vertices[2] = video::S3DVertex(-width/2,-height/2,0.01f,0,0,0, mFrameColor,1,0);
	vertices[3] = video::S3DVertex( width/2,-height/2,0.01f,0,0,0, mFrameColor,1,1);
	*/

	vertices[0] = video::S3DVertex(-width/2, height/2, 0.001f,0,0,0, mFrameColor,0,0);
	vertices[1] = video::S3DVertex( width/2, height/2, 0.001f,0,0,0, mFrameColor,0,1);
	vertices[2] = video::S3DVertex(-width/2,-height/2, 0.001f,0,0,0, mFrameColor,1,0);
	vertices[3] = video::S3DVertex( width/2,-height/2, 0.001f,0,0,0, mFrameColor,1,1);	
	/*
	vertices[4] =  video::S3DVertex((-width/2)+mXFactor,( height/2)-mYFactor,  0.01f,0,0,0, mFrameColor,0,0);
	vertices[5] =  video::S3DVertex(( width/2)-mXFactor,( height/2)-mYFactor,  0.01f,0,0,0, mFrameColor,  0,1);	
	vertices[6] = video::S3DVertex((-width/2) +mXFactor,(-height/2)+mYFactor,   0.01f,0,0,0, mFrameColor,1,0);
	vertices[7] = video::S3DVertex(( width/2) -mXFactor,(-height/2)+mYFactor,   0.01f,0,0,0, mFrameColor,  1,1);
	*/
	//bar 
	vertices[4] = video::S3DVertex((-width/2),         ( height/2)-mYFactor,0,0,0,0, mStartColor,0,0);
	vertices[5] = video::S3DVertex((-width/2)+mXFactor,( height/2)-mYFactor,0,0,0,0, mEndColor,  0,1);	
	vertices[6] = video::S3DVertex((-width/2),         (-height/2)+mYFactor,0,0,0,0, mStartColor,1,0);
	vertices[7] = video::S3DVertex((-width/2)+mXFactor,(-height/2)+mYFactor,-0,0,0,0,mEndColor,  1,1);

	


	u16 tmpindices[]= { 0,1,2, 
						1,3,2,  

						4,5,6, 
						5,7,6, 

						8,9,10, 
						9,11,10
						};

	for (s32 i=0; i<18; ++i)
	{
		indices[i]= tmpindices[i];
	}

	mBox.reset(vertices[0].Pos);
	for (s32 i=0; i<12; i++)
	{
		mBox.addInternalPoint(vertices[i].Pos);
	}


}
Ejemplo n.º 3
0
void cfprintf(FILE *f, const char *fo, ...)
{
    char *in = new char[MAX_STRLEN];
    char *out = new char[MAX_STRLEN];
    int ao = 0;

    memset(in, 0, MAX_STRLEN);
    memset(out, 0, MAX_STRLEN);

    va_list args;
    va_start(args, fo);
    vsprintf(in, fo, args);
    va_end(args);

    for (char *at = in; *at != '\0'; at++) {
        if (*at == '^') {
            at++;

            #ifdef __linux__

            switch (*at) {
                case '0':
                    ao += ccolor(&out[ao]);
                    break;

                case 'd':
                    ao += scolor(&out[ao], DIM, BLACK);
                    break;

                case 'r':
                    ao += scolor(&out[ao], DIM, RED);
                    break;

                case 'g':
                    ao += scolor(&out[ao], DIM, GREEN);
                    break;

                case 'b':
                    ao += scolor(&out[ao], DIM, BLUE);
                    break;

                case 'y':
                    ao += scolor(&out[ao], DIM, YELLOW);
                    break;

                case 'm':
                    ao += scolor(&out[ao], DIM, MAGENTA);
                    break;

                case 'c':
                    ao += scolor(&out[ao], DIM, CYAN);
                    break;

                case 'w':
                    ao += scolor(&out[ao], DIM, WHITE);
                    break;
            }

            #endif
        } else {
            out[ao++] = *at;
        }
    }

    fprintf(f, "%s", out);
    delete [] in;
    delete [] out;
}