Beispiel #1
0
/*F AddStructureNext(currentstructure,element)
**
**  DESCRIPTION
**    currentstructure: The current structure to add to
**    element: The structural element to add
**
**  REMARKS
**
**   This connects the current structure with the structural element
**   to form a new currentstructure
**
**
**  REFERENCES
**
**  SEE ALSO
**
**  HEADERFILE
**
*/
static void AddStructureNext(CurrentStructure *currentstructure,
			 FullStructuralElement *element){
  INT currentattach, structureattach,replacepoint,replacepointC;
  CombinedGraph *combined,*newcombined;
  AttachmentRemoved *currentR,*elementR;
  CurrentStructure *elementcurrent;
  INT a1,a2,offset;
  Neighbor *n1,*n2;

  currentattach = PickPoint(currentstructure->Attachments->NumberOfPoints);
  structureattach = PickPoint(element->Connections->NumberOfPoints);

  elementcurrent = AllocateCurrentStructure;
  CreateCurrentStructure(elementcurrent,currentstructure->ID,currentstructure->Name,
			 0,element->MoleculeGraph,element->Connections);
  
  /*
  PrintPrettyGraph("current: ",stdout,currentstructure->Structure);
  PrintPrettyDataSubSet(stdout,"Attachments: ",currentstructure->Attachments);
  PrintPrettyGraph("element: ",stdout,element->MoleculeGraph);
  PrintPrettyDataSubSet(stdout,"Attachments: ",elementcurrent->Attachments);
  */
  replacepoint = *(elementcurrent->Attachments->Points + structureattach);
  replacepointC = *(currentstructure->Attachments->Points + currentattach);
  printf("Remove: Element (%d,%d,%d),  Current(%d,%d,%d)\n",
	 replacepoint,structureattach,element->Connections->NumberOfPoints,
	 replacepointC,currentattach,currentstructure->Attachments->NumberOfPoints);
  currentR = RemoveAttachment(currentstructure,currentattach);
  elementR = RemoveAttachment(elementcurrent,structureattach);
  /*  PrintPrettyGraph("currentR: ",stdout,currentR->Structure);
  PrintPrettyGraph("elementR: ",stdout,elementR->Structure);
  */
  offset = currentR->Structure->NumberOfNodes;
  combined = AllocateCombinedGraph;
  CreateCombinedGraph(combined,currentstructure->ID,currentstructure->Name,
		      currentR->Structure,
		      1,0);
  *(combined->Begins) = 0;

  newcombined = AddGraphToCombined(elementR->Structure,combined);

  a1 = currentR->Attachment;
  a2 = elementR->Attachment + offset;
  n1 = newcombined->Combined->Neighbors + a1;
  n2 = newcombined->Combined->Neighbors + a2;
  AddElementToNeighbor(a1,n2);
  AddElementToNeighbor(a2,n1);
  FreeGraph(currentstructure->Structure);
  CopyFullGraph(currentstructure->Structure,newcombined->Combined);

  /*
  PrintPrettyGraph("newcombined with bond: ",stdout,currentstructure->Structure);
  */
  offset = *(newcombined->Begins +1);
  AdjustAttachmentPointsOfNewElement(offset,replacepoint,replacepointC,elementcurrent,currentstructure);  
}
Beispiel #2
0
void ToggleAttachment( GUI_BUTTON *btn, INT32 reason )
{
	if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
	{
		INT32 i;
		UINT16 usAttachment;
		OBJECTTYPE temp;
		for( i = 0; i < NUM_ATTACHMENT_BUTTONS; i++ )
		{	//Loop through and find the button that was just modified
			switch( i )
			{
				case 0: usAttachment = SILENCER;				break;
				case 1: usAttachment = SNIPERSCOPE;			break;
				case 2: usAttachment = LASERSCOPE;			break;
				case 3:	usAttachment = BIPOD;						break;
				case 4: usAttachment = DUCKBILL;				break;
				case 5: usAttachment = UNDER_GLAUNCHER;	break;
			}
			if( guiAttachmentButton[ i ] != -1 && btn == ButtonList[ guiAttachmentButton[ i ] ] )
			{	//Found it, now check the state of the button.
				if( !gfAttachment[ i ] )
				{
					gfAttachment[ i ] = TRUE;
					btn->uiFlags |= BUTTON_CLICKED_ON;
					CreateItem( usAttachment, gpItem->bGunStatus, &temp );
					AttachObject( NULL, gpItem, &temp );
				}
				else
				{ //Button is out, so remove the attachment
					INT8 slot;
					gfAttachment[ i ] = FALSE;
					btn->uiFlags &= ~BUTTON_CLICKED_ON;
					slot = FindAttachment( gpItem, usAttachment );
					if( slot != -1 )
						RemoveAttachment( gpItem, slot, &temp );
				}
			}
		}
		ReEvaluateAttachmentStatii();
	}
}
Beispiel #3
0
void ToggleCeramicPlates( GUI_BUTTON *btn, INT32 reason )
{
	if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
	{
		OBJECTTYPE temp;
		gfCeramicPlates ^= TRUE;
		if( gfCeramicPlates )
		{
			btn->uiFlags |= BUTTON_CLICKED_ON;
			CreateItem( CERAMIC_PLATES, gpItem->bStatus[0], &temp );
			AttachObject( NULL, gpItem, &temp );
		}
		else
		{
			INT8 slot;
			btn->uiFlags &= ~BUTTON_CLICKED_ON;
			slot = FindAttachment( gpItem, CERAMIC_PLATES );
			if( slot != -1 )
				RemoveAttachment( gpItem, slot, &temp );
		}
	}
}
Beispiel #4
0
void ToggleDetonator( GUI_BUTTON *btn, INT32 reason )
{
	if( reason & MSYS_CALLBACK_REASON_LBUTTON_UP )
	{
		OBJECTTYPE temp;
		if( !gfDetonator )
		{
			gfDetonator = TRUE;
			btn->uiFlags |= BUTTON_CLICKED_ON;
			CreateItem( DETONATOR, gpItem->bStatus[0], &temp );
			AttachObject( NULL, gpItem, &temp );
		}
		else
		{ //Button is out, so remove the attachment
			INT8 slot;
			gfDetonator = FALSE;
			btn->uiFlags &= ~BUTTON_CLICKED_ON;
			slot = FindAttachment( gpItem, DETONATOR );
			if( slot != -1 )
				RemoveAttachment( gpItem, slot, &temp );
		}
	}
}
Beispiel #5
0
void AvatarEditor::RebuildEditView()
{
    if (!avatar_widget_)
        return;

    // Activate/deactivate export button based on whether export currently supported
    QPushButton *button = avatar_widget_->findChild<QPushButton *>("but_export");
    if (button)
        button->setEnabled(rexlogicmodule_->GetAvatarHandler()->AvatarExportSupported());

    QWidget* mat_panel = avatar_widget_->findChild<QWidget *>("panel_materials");
    QWidget* attachment_panel = avatar_widget_->findChild<QWidget *>("panel_attachments");
    if (!mat_panel || !attachment_panel)
        return;

    Scene::EntityPtr entity = rexlogicmodule_->GetAvatarHandler()->GetUserAvatar();
    if (!entity)
        return;
    EC_AvatarAppearance* appearance = entity->GetComponent<EC_AvatarAppearance>().get();
    if (!appearance)
        return;

    int width = 308-10;
    int tab_width = 302-10;
    int itemheight = 20;

    // Materials
    ClearPanel(mat_panel);
    const AvatarMaterialVector& materials = appearance->GetMaterials();
    mat_panel->resize(width, itemheight * (materials.size() + 1));

    for (uint y = 0; y < materials.size(); ++y)
    {
        QPushButton* button = new QPushButton("Change", mat_panel);
        button->setObjectName(QString::fromStdString(ToString<int>(y))); // Material index
        button->resize(50, 20);
        button->move(width - 50, y*itemheight);
        button->show();

        QObject::connect(button, SIGNAL(clicked()), this, SLOT(ChangeTexture()));
        // If there's a texture name, use it, because it is probably more understandable than material name
        std::string texname = materials[y].asset_.name_;
        if (materials[y].textures_.size())
            texname = materials[y].textures_[0].name_;

        QLabel* label = new QLabel(QString::fromStdString(texname), mat_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Attachments
    ClearPanel(attachment_panel);
    const AvatarAttachmentVector& attachments = appearance->GetAttachments();
    attachment_panel->resize(width, itemheight * (attachments.size() + 1));

    for (uint y = 0; y < attachments.size(); ++y)
    {
        QPushButton* button = new QPushButton("Remove", attachment_panel);
        button->setObjectName(QString::fromStdString(ToString<int>(y))); // Attachment index
        button->resize(50, 20);
        button->move(width - 50, y*itemheight);
        button->show();

        QObject::connect(button, SIGNAL(clicked()), this, SLOT(RemoveAttachment()));

        std::string attachment_name = attachments[y].name_;
        // Strip away .xml from the attachment name for slightly nicer display
        std::size_t pos = attachment_name.find(".xml");
        if (pos != std::string::npos)
            attachment_name = attachment_name.substr(0, pos);

        QLabel* label = new QLabel(QString::fromStdString(attachment_name), attachment_panel);
        label->resize(200,20);
        label->move(0, y*itemheight);
        label->show();
    }

    // Modifiers
    QTabWidget* tabs = avatar_widget_->findChild<QTabWidget *>("tab_appearance");
    if (!tabs)
        return;
    for (;;)
    {
        QWidget* tab = tabs->widget(0);
        if (!tab)
            break;
        tabs->removeTab(0);
        delete tab;
    }

    const MasterModifierVector& master_modifiers = appearance->GetMasterModifiers();
    // If no master modifiers, show the individual morph/bone controls
    if (!master_modifiers.size())
    {
        QWidget* morph_panel = GetOrCreateTabScrollArea(tabs, "Morphs");
        QWidget* bone_panel = GetOrCreateTabScrollArea(tabs, "Bones");
        if (!morph_panel || !bone_panel)
            return;

        const BoneModifierSetVector& bone_modifiers = appearance->GetBoneModifiers();
        const MorphModifierVector& morph_modifiers = appearance->GetMorphModifiers();
        morph_panel->resize(tab_width, itemheight * (morph_modifiers.size() + 1));
        bone_panel->resize(tab_width, itemheight * (bone_modifiers.size() + 1));

        for (uint i = 0; i < bone_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, bone_panel);
            slider->setObjectName(QString::fromStdString(bone_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(bone_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(BoneModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(bone_modifiers[i].name_), bone_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }

        for (uint i = 0; i < morph_modifiers.size(); ++i)
        {
            QScrollBar* slider = new QScrollBar(Qt::Horizontal, morph_panel);
            slider->setObjectName(QString::fromStdString(morph_modifiers[i].name_));
            slider->setMinimum(0);
            slider->setMaximum(100);
            slider->setPageStep(10);
            slider->setValue(morph_modifiers[i].value_ * 100.0f);
            slider->resize(150, 20);
            slider->move(tab_width - 150, i * itemheight);
            slider->show();

            QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MorphModifierValueChanged(int)));

            QLabel* label = new QLabel(QString::fromStdString(morph_modifiers[i].name_), morph_panel);
            label->resize(100,20);
            label->move(0, i * itemheight);
            label->show();
        }
    }