Exemple #1
0
void Unit::Render()
{
    if (m_IsDeath)
        return;

    auto render = GetComponent<CmdRenderComponent>();
    if (render == nullptr)
        return;

    render->SetCoord(Coord(m_Pos));
    DirectionShow();

    if (m_HitRenderFlag)
    {
        m_HitRenderFlag = false;
        auto orgBGColor = render->GetBGColor();
        render->SetBGColor(Color::MAGENTA);
        GameObject::Render();
        render->SetBGColor(orgBGColor);
    }
    else
    {
        GameObject::Render();
    }
}
Exemple #2
0
void lamnoi2(int y)
{
	CauHinhMenu();
	SetBGColor(XAM_SANG);
	textcolor(FOREGROUND_RED|FOREGROUND_INTENSITY);
	switch (y)
	{
	case 7:printxy(30,7,"10 x 10 - 20 Bom");break;
	case 8:printxy(30,8,"16 x 16 - 40 Bom");break;
	case 9:printxy(30,9,"20 x 20 - 200 Bom");break;
	case 10:printxy(30,10,"Nhap vao");break;
	}
	textcolor(TRANG);
	SetBGColor(DEN);
}
Exemple #3
0
void lamnoi1(int y)
{
	MainMenu();
	SetBGColor(XAM_SANG);
	textcolor(FOREGROUND_RED|FOREGROUND_INTENSITY);
	switch (y)
	{
	case 6:printxy(33,6,"Van moi");break;
	case 7:printxy(33,7,"Choi tiep");break;
	case 8:printxy(33,8,"Xem diem");break;
	case 9:printxy(33,9,"xem luat choi");break;
	case 10:printxy(33,10,"Thoat");break;
	}
	textcolor(TRANG);
	SetBGColor(DEN);
}
Exemple #4
0
void Unit::Death()
{
    m_IsDeath = true;
    auto corpse = std::make_shared<Dummy>();
    auto render = corpse->GetComponent<CmdRenderComponent>();
    if (render != nullptr)
    {
        render->SetCoord(Coord(m_Pos));
        render->SetShape(GetComponent<CmdRenderComponent>()->GetShape());
        render->SetColor(Color::BLACK);
        render->SetBGColor(Color::RED);
        GameManager::GetInstance().GetGame<Game>().AddOnlyRender(corpse, 1.f);
    }
}
CGameFlyControl::CGameFlyControl(void)
{
	rectWall.left=10;
	rectWall.top=10;
	rectWall.right=430;
	rectWall.bottom=340;
	birdBody= new CBirdBody(50,150,30,30,rectWall);
	birdBody->SetBirdSpeed(5);
	nHardLevel=2;
	gunControl=new CGunControl(24,8,2,10,10,rectWall);
	bLButtonDown=FALSE;
	bIsAddStat=TRUE;
	SetBGColor(RGB(0,255,255),RGB(255,0,10));
}
Exemple #6
0
int COGLWin::LoadScript()
{
	char pcText[BUFSIZE+1];
	int iRead, iLines;
	cStr csText;
	FILE *pFile;


  	if (!(pFile = fopen(m_csScriptFilename, "r")))
	{
		return -2;
	}
	

	while(!feof(pFile))
	{
		iRead = (int) fread(pcText, 1, BUFSIZE, pFile);
		pcText[iRead] = 0;
		csText << pcText;
	}

	fclose(pFile);

	ResetTransformVars();

	CCodeVar& rVarCol = m_Parse.GetVar("_BGColor");
	if (rVarCol.Type() != PDT_NOTYPE)
	{
		rVarCol = Black;
		SetBGColor(Black);
	}

	CCodeVar& rVarFBS = m_Parse.GetVar("_FrameBoxSize");
	if (rVarFBS.Type() != PDT_NOTYPE)
	{
		rVarFBS = TCVScalar(3);
	}

	m_Parse.Reset();
	iLines = m_Parse.InsertText(csText);

	if (iLines < 0)
	{
		return -3;
	}
	
	return iLines;
}
Exemple #7
0
void kGUIText::SetRichBGColor(unsigned int si,unsigned int ei,kGUIColor color)
{
	unsigned int i;
	unsigned int l=GetLen();
	RICHINFO_DEF *ri;

	for(i=si;i<ei;++i)
	{
		if(i==l)
			SetBGColor(color);
		else
		{
			ri=GetRichInfoPtr(i);
			ri->bgcolor=color;
		}
	}
	StringChanged();
}
void C3dView::SetBGColor ( float r, float g, float b)
{
	trColor clr = {r,g,b};
	SetBGColor(clr);
}
WymsingTxt::WymsingTxt( QRectF recter , QColor sfondo , QColor margincolor , qreal borders , int rotate , QTextDocument *item , TypImageContainer block ,  QGraphicsItem  * parent )
{
	setupUi( this );
    Qfontlist->setFontFilters( QFontComboBox::ScalableFonts );
    
    
    stackedWidget->hide();
    
    QStringList palign;
    palign << "[1] AlignLeft" << "[2] AlignRight" << "[4] AlignHCenter";
    alignetable->clear();
    alignetable->addItems(palign);
    
    
    if (QGraphicsTextItem *image = qgraphicsitem_cast<QGraphicsTextItem *>(parent)) {
    ////////qDebug() << "### trovato " << image->boundingRect();
    
        connect(XxAxys, SIGNAL(valueChanged(int)), this, SLOT(RotateFloat(int)));
        
        wtxt->setDocument ( image->document() );
        wtxt->document()->adjustSize();
        
        DocFrameFormings =  wtxt->document()->rootFrame()->frameFormat();
        DocFrameFormings.setBackground(sfondo);
        DocFrameFormings.setWidth( image->boundingRect().width() );
        wtxt->document()->rootFrame()->setFrameFormat ( DocFrameFormings ); 
        wtxt->document()->setUseDesignMetrics (true );
       
        
        
      /////tablegr->hide();    /* propryetys setter */
      /////imagegr->hide();   /* propryetys setter */
      wtxt->AppendImageBlocks(block);
      CatchPixmapCurrent("");
        
        QPointF globalpos = image->pos();
        XXset->setValue(globalpos.x());
        YYset->setValue(globalpos.y());
        
        connect(XXset, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
        connect(YYset, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));

    destimage = image;
    /////wtxt->setEnabled(true);
    loadetConnection = false;
    workfont = item->defaultFont();
    ////////qDebug() << "### textWidth   " << item->textWidth();
    tdoc = item->clone();
    QTextFrame  *Tframe = tdoc->rootFrame();
    rootformat = Tframe->frameFormat();
    pnord->setValue(rootformat.topMargin());
    psud->setValue(rootformat.bottomMargin());
    pwest->setValue(rootformat.leftMargin());
    post->setValue(rootformat.rightMargin());
    
    connect(pnord, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
    connect(psud, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
    connect(pwest, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
    connect(post, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
    LoadButtonControll();
    InitValue = recter;
    
    
   
    
    
    
    BorderDicks = borders;
    BGColor = sfondo;
    AlphaColor = sfondo.alpha();
    MarginColor = margincolor;
    
     QPixmap pixbg(22, 22);
     pixbg.fill(sfondo);
    
     QPixmap pixma(22, 22);
     pixma.fill(margincolor);
    
      Mabg->setIcon(pixma);
      Cobg->setIcon(pixbg);
      MarginSize->setValue ( borders );
    
      BoxAltezza->setValue ( recter.height() );
      BoxLarghezza->setValue ( recter.width() );
    
      ///////Vol_Rotate->setValue ( rotate );
      connect(BoxAltezza, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
      connect(BoxLarghezza, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
      connect(MarginSize, SIGNAL(valueChanged(double)), this, SLOT(UpdateVars()));
      
      connect(Mabg, SIGNAL(clicked()), this,  SLOT(SetMarginColor()));
      connect(Cobg, SIGNAL(clicked()), this,  SLOT(SetBGColor()));
      connect(CurrentImagePlay, SIGNAL(clicked()), this,  SLOT(ImageToClipbord()));
      connect(SaveToPath, SIGNAL(clicked()), this,  SLOT(SaveCurrentImageStream()));
      
      
      connect(Vol_21, SIGNAL(clicked()), wtxt, SLOT(InsertImageonCursor()));
      
      
      connect(pushButton, SIGNAL(clicked()), this, SLOT(SaveNewFormat()));
      connect(EditableOr, SIGNAL(toggled(bool)), wtxt, SLOT(Editablemodus(bool)));
      connect(wtxt, SIGNAL(SaveStreamer()), this, SLOT(SaveNewFormat()));
      connect(wtxt, SIGNAL(DDclick()), this, SLOT(TableImageSetup()));
      
      connect(tabiborder, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));
      connect(imghi, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentImage()));
      connect(imgwi, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentImage()));
   
      
      
      connect(tabiwi, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));
      connect(tabipadding, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));
      connect(tabiborder, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));
      connect(tabispacing, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));
      
      connect(alignetable, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(UpdateCurrentTable()));
      
      connect(Vol_6, SIGNAL(clicked(bool)), wtxt, SLOT(MakeHrefLink()));
      connect(Vol_22, SIGNAL(clicked()), this, SLOT(CurrentParamMargin()));
      
    
    
      
///////////connect(tabiborder, SIGNAL(valueChanged(int)), this, SLOT(UpdateCurrentTable()));

      //////////FontChanged(workfont);
      
  }
Exemple #10
0
int COGLWin::SetScript(const char *pcScript, bool bResetEnv, bool bReparseLatex)
{
	CCodeVar Var;

	//printf("Enter SetScript.\n");

	// Only execute checks on change of global variables
	// in idle loop after the next display operation.
	m_bWaitWithIdleForNextDisplay = true;

	SetTitle();

	if (bReparseLatex)
	{
		m_Parse.OverrideSetRenderLatex(false);
		m_Parse.SetRenderLatex(true);
		m_Parse.OverrideSetRenderLatex(true);
	}

	if (bResetEnv)
	{
		// Switch off animation
		SetAnimCode(false);
		COGLWinFLTK::StopAnimation();

		SetExecModeVar(EXEC_MODE_NEW);
		AddExecModeVar(EXEC_MODE_CHANGE);

		ResetTransformVars();
		ResetLights();

		m_ToolBox.ResetToolInUseFlags();
		m_ToolBox.PruneToolMap();

		if (!m_bKeepBGColor)
		{
			CCodeVar& rVarCol = m_Parse.GetVar("_BGColor");
			if (rVarCol.Type() != PDT_NOTYPE)
			{
				rVarCol = Black;
				SetBGColor(Black);
			}
		}
		else
		{
			m_bKeepBGColor = false;
		}

		CCodeVar& rVarFBS = m_Parse.GetVar("_FrameBoxSize");
		if (rVarFBS.Type() != PDT_NOTYPE)
		{
			rVarFBS = TCVScalar(3);
		}

		CCodeVar& rVar2dV = m_Parse.GetVar("_2dView");
		if (rVar2dV.Type() != PDT_NOTYPE)
		{
			rVar2dV = 0;		
		}
		Enable2dView(false);

		/// Reset visualization mode to OPNS for all spaces.
		m_Filter.SetMode(MODE_OPNS);

		// Reset Code Base
		m_Parse.ResetCodeBase();
	}
	else
	{
		SetExecModeVar(EXEC_MODE_CHANGE);
	}
	
	m_Parse.CollectGarbage();
	m_Parse.Reset();
	m_Parse.GetCodeBase().ResetInfoVars();

	SetInfoText("Use <code>SetInfoText([string])</code> to put some text here. "
				"The text may include some 'simple' HTML tags.");
	SetInfoWidth(0);

	bool bShowOutput = true;

	if (m_bInFullScreenMode || m_bVizOnlyMode)
	{
		bShowOutput = false;
	}

	if (m_pOutput && bShowOutput)
	{
		m_pOutput->SetText("<body size=\"16\"><b>Parsing code...</b></body>");
		m_pOutput->show();
	}

	int iLines = m_Parse.InsertText(pcScript);

	if (m_pOutput && bShowOutput)
	{
		m_pOutput->SetText("<body size=\"14\">Parsing code...<b>finished</b>.<br>Running code after change. <b>Please wait...</b></body>");
		m_pOutput->show();
	}

	if (!m_bInFullScreenMode)
	{
		if (m_bPresentationAction || m_bParseFromOGLWin || m_bVizOnlyMode)
		{
			ShowWindow();
		}
		else
			m_pEditor->show();
	}
	m_bPresentationAction = false;
	m_bParseFromOGLWin = false;

	if (iLines >= 0)
	{
		//printf("Parsed %d lines.\n", iLines);
		m_bCheckForAnimate = true;
		m_bCodeChanged = true;
		m_bCodeChangedForAnim = true;
		//glutSetWindow(m_iHWin);

		//m_pWindow->show();

		m_bCheckToolBoxSize = true;

		// When visualization window is iconized, the script is not executed
		// because of a glutPostRedisplay(). So we have to call Display explicitly.
		if (!m_pWindow->visible())
		{
			Display();
		}

//		if (!m_bIsAnimated)
//			glutPostRedisplay();
	}
	else
	{
		ClearError();
		m_sError = "<b>Parse Errors:</b><p>";
		m_sError += m_Parse.PrintParseErrors().Str();
		m_sError += "</p>";

		m_bHasError = true;

		if (m_pOutput && !m_bVizOnlyMode)
		{
			m_pOutput->SetText(m_sError.c_str());
			m_pOutput->show();
		}
		
		if (m_pEditor && !m_bVizOnlyMode)
		{
			cStr csFilename, csPath;
			int iLine, iPos, iInputPos;

			if (iLines == -1)
				m_Parse.GetParseErrorPos(iLine, iPos, iInputPos, csFilename);
			else
			{
				csFilename = m_Parse.GetErrorFilename().c_str();
				csPath = m_Parse.GetErrorPath().c_str();

				if (csFilename.Len() == 0)
				{
					csFilename = m_sScriptPath.c_str();
					csFilename << m_sScriptName.c_str() << ".clu";
				}

				char *pcName = csFilename.Str();
				if (!strchr(pcName, ':') &&
					!strchr(pcName, '/') &&
					!strchr(pcName, '\\'))
				{
					csFilename = csPath + csFilename;
					csFilename |= ('.' < csFilename) - csFilename.Len() - 1;
				}
				iInputPos = -iLines - 2;
			}

			m_pEditor->HighlightLinePos(csFilename.Str(), iInputPos);
			m_pEditor->show();
		}

		//ClearError();

		m_Parse.ClearError();

		SetAnimCode(false);
/*
		m_bCodeChanged = true;
		glutSetWindow(m_iHWin);

		if (!m_bIsAnimated)
			glutPostRedisplay();
*/
	}


	if (!m_bIsAnimated)
		glutPostRedisplay();

//	CheckToolBoxSize();

//	if (iLines >= 0 && !m_bIsAnimated)
//		glutPostRedisplay();

	return iLines;
}
Exemple #11
0
void COGLWin::Display()
{
	//printf("Display\n");
	if (m_bInDisplay)
		return;

	m_bInDisplay = true;

	bool bRedisplay = false;
	//printf("Enter Display\n");

	// Always call this function before drawing

	// Now we display, so we can allow idle loop to check script.
	m_bWaitWithIdleForNextDisplay = false;

	// Reset Perspective Angle to standard
	SetPerspectiveAngle(70);

	BeginDraw();

	// Save Frame Transform 
	float fFrameAngle = m_fFrameAngle;
	STransform Trans = m_mTransform[0];
	bool bRedraw = false;
	bool bEnable2dView = false;
	bool b2dViewChanged = false;
	int iActRTMode = GetActRTMode();

	if (iActRTMode && m_mTransform[iActRTMode].iFlags)
		AddExecModeVar(EXEC_MODE_USER);

	if (m_bCodeChanged)
	{
		bRedraw = true;
		m_bCodeChanged = false;
	}
	else
	{
		for(int i=1;i<=9;i++)
		{
			if (m_mTransform[i].iFlags)
			{
				bRedraw = true;
				break;
			}
		}
		
		if (m_iExecMode & EXEC_MODE_TOOL ||
			m_iExecMode & EXEC_MODE_LINK ||
			m_iExecMode & EXEC_MODE_KEYUP ||
			m_iExecMode & EXEC_MODE_KEYDOWN)
			//||
			//m_iExecMode & EXEC_MODE_RESHAPE)
		{
			bRedraw = true;
			m_bCheckForAnimate = true;
		}

//		if (!m_mTransform[0].iFlags)
//			bRedraw = true;	
	}

	if (HasError() && !bRedraw)
	{
		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);

		EndDraw();
		//SetExecModeVar(EXEC_MODE_NONE);
		m_bInDisplay = false;
		return;
	}

	glEnable(GL_ALPHA_TEST);
	glAlphaFunc(GL_GEQUAL, 1.0f);

	// Check whether only space has been transformed
	if (bRedraw)
	{		
		CCodeVar Var;

		// Start drawing into display list
		m_dlSpace.BeginDraw(true);
		
		// Draw Frame Box (optional)
		// DrawBox(3.0);
		
		// Draw you own stuff
		Draw();
	
		// End drawing into display list
		m_dlSpace.EndDraw();

		if (!HasError())
		{
			// Check whether Frame Box is to be drawn and in what size
			if (m_Parse.GetVar("_FrameBoxSize", Var))
			{	
				TCVScalar dVal;
				if (Var.CastToScalar(dVal))
					m_dFrameBoxSize = dVal;
			}
			else m_dFrameBoxSize = 3.0;

			// Set Background Color
			if (m_Parse.GetVar("_BGColor", Var))
			{	
				if (Var.Type() == PDT_COLOR)
				{
					COGLColor colBG = *((COGLColor *) Var.Val());
					if (!(colBG == GetBGColor()))
						bRedisplay = true;
//						m_bBGColChanged = true;

					SetBGColor(colBG);
				}
			}
			//else SetBGColor(Black);

			if (!m_b2dView && ScriptIs2d())
			{
				//printf("Switch to 2d view.\n");

				bEnable2dView = true;
				b2dViewChanged = true;
				//m_bCodeChanged = true;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}
			else if (m_b2dView && !ScriptIs2d())
			{	
				//printf("Switch to 3d view.\n");

				bEnable2dView = false;
				b2dViewChanged = true;
				//m_bCodeChanged = true;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (m_bBGColChanged)
			{
				//printf("BGCol. changed.\n");

				//m_bBGColChanged = false;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (m_bFrameTransChanged)
			{
				m_bFrameTransChanged = false;
				//SetExecModeVar(EXEC_MODE_AGAIN);

				bRedisplay = true;
			}

			if (bRedisplay)
			{
				//printf("Redisplay\n");
				// End Draw without swapping buffers
				CCLUDrawBase::EndDraw();

				if (b2dViewChanged)
					Enable2dView(bEnable2dView);

				// Now begin drawing again
				BeginDraw();
				fFrameAngle = m_fFrameAngle;
				Trans = m_mTransform[0];

				glEnable(GL_ALPHA_TEST);
				glAlphaFunc(GL_GEQUAL, 1.0f);
				m_dlSpace.Apply();
			}

		}

		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);
	}
	else
	{
		// Apply display list
		m_dlSpace.Apply();

		// Draw Frame Box (optional)
		if (m_dFrameBoxSize > 0.0 && !m_b2dView)
			DrawBox((float)m_dFrameBoxSize);
	}


	if (!HasError())
	{
		// Get ModelView Identity Matrix back
		glPopMatrix(); 
		// Save it again
		glPushMatrix();
		// Set initial origin again
		glTranslatef(Trans.pfTrans[0], Trans.pfTrans[1], Trans.pfTrans[2]);

		if (m_bUseLocalRot)
		{
			glRotatef(Trans.pfRot[2], 1, 0, 0);
			glRotatef(Trans.pfRot[0], 0, 1, 0);
			glRotatef(Trans.pfRot[1], 0, 0, 1);
		}
		else
		{
			glRotatef(fFrameAngle, Trans.pfRot[0], Trans.pfRot[1], Trans.pfRot[2]);
		}

		glEnable(GL_BLEND);
		glAlphaFunc(GL_LESS, 1.0f);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glDepthMask(GL_FALSE);

		m_dlSpace.Apply();
		
		glDepthMask(GL_TRUE);
		glDisable(GL_BLEND);
	}
	glDisable(GL_ALPHA_TEST);
	//m_Filter << m_E3Base.vI;

	// Always call this function after drawing
	EndDraw();
	

	//CheckToolBoxSize();
	m_bCheckToolBoxSize = true;
	
	//SetExecModeVar(EXEC_MODE_NONE);
	m_bInDisplay = false;
}