Example #1
0
void Component::contextMenuEvent(QContextMenuEvent *event) {
	QMenu menu(this);
	if(getComponentType()!=2) // if is not a collector
		menu.addAction(wireAct);
    if(getComponentType()==7) // if is a diver
        menu.addAction(dividerAct);
	if(outComponentList.isEmpty() && inComponentList.isEmpty())
		deleteWireAct->setEnabled(false);
	else
		deleteWireAct->setEnabled(true);
	menu.addAction(deleteWireAct);
	menu.addSeparator();
	menu.addAction(deleteAct);
	menu.exec(event->globalPos());
}
Example #2
0
bool ComponentTypesFile::anyComponentsDefined() const
    {
    auto const &names = getComponentNames();
    return std::any_of(names.begin(), names.end(),
            [=](std::string const &name)
            {return(getComponentType(name) != CT_Unknown);} );
    }
Example #3
0
void ComponentTypesFile::setComponentType(OovStringRef const compName,
    OovStringRef const typeName)
    {
    eCompTypes newType = getComponentTypeFromTypeName(typeName);
    if(newType != CT_Unknown && newType != getComponentType(compName))
        {
        coerceParentComponents(compName);
        coerceChildComponents(compName);
        }
    setComponentType(compName, getComponentTypeFromTypeName(typeName));
    }
Example #4
0
OovStringVec ComponentTypesFile::getComponentNames(bool definedComponentsOnly) const
    {
    OovStringVec compNames = CompoundValueRef::parseString(
            mCompTypesFile.getValue("Components"));
    if(definedComponentsOnly)
        {
        compNames.erase(std::remove_if(compNames.begin(), compNames.end(),
            [this](OovString &name)
            { return(getComponentType(name) == CT_Unknown); }), compNames.end());
        }
    return compNames;
    }
Example #5
0
OovStringVec ComponentTypesFile::getComponentNamesByType(eCompTypes cft) const
    {
    OovStringVec allCompNames = CompoundValueRef::parseString(
        mCompTypesFile.getValue("Components"));
    OovStringVec filteredNames;
    for(auto const &compName : allCompNames)
        {
        if(getComponentType(compName) == cft)
            {
            filteredNames.push_back(compName);
            }
        }
    return filteredNames;
    }
void
Box2DColliderEntity::update(TIME d)
{
    if (!m_init) {
        Game::SharedSizeComponent l_size_component =
            getComponentType(Game::SizeComponent::Type()).staticCast<Game::SizeComponent>();
        if (!l_size_component) {
            MMERROR1("Collider entity requires a size component to be present");
            return;
        }

        Game::SharedBox2DComponent l_box2d_component =
            new Game::Box2DComponent("box2d", *this);
        l_box2d_component->bodyType() = b2_staticBody;
        l_box2d_component->size() = l_size_component->size();
        pushComponent(l_box2d_component.staticCast<Game::IComponent>());
        m_init = true;
    }

    Game::EntityBase::update(d);
}
Example #7
0
void CStation::initialize()
{
	// Add station anew to simulation, if connected
	// (This is needed since by removing a component, a clean up is performed by 
	// simulation DLL, which is also performed by the reset at the end of initialization. 
	// Thus, the reset function is used by both simulation and editor, but in general, 
	// a clean up can only be performed by simulation (or must not cause deletions). 
	// This is because a clean up deletes the values created during simulation. Because 
	// initialization uses the reset function to (re)set all values, it must be ensured 
	// that the component is in a state were the clean up performed by the reset causes 
	// no delete operateions of values created during simulation.)
	TfpAddStationToSimulation fpAddStationToSimulation = getStationType().getAddStationToSimulation();
	TfpRemoveStationFromSimulation fpRemoveStationFromSimulation = getStationType().getRemoveStationFromSimulation();
	if( (fpAddStationToSimulation != NULL) && (fpRemoveStationFromSimulation != NULL) )
	{
		(*fpRemoveStationFromSimulation)( this );
		(*fpAddStationToSimulation)( this );
	}

	// Initialize the component's (edge dependent) general attribute values
	CComponent::initialize();

	// Initialize the stations's time counters
	times.clear();
	list<CEdgeConnector*>::const_iterator itEdgeConnector;
	for( itEdgeConnector = getComponentType().getEdgeConnectors().begin(); itEdgeConnector != getComponentType().getEdgeConnectors().end(); itEdgeConnector++ )
    {
		// Check if the linked connector is connected as well (this is important since when an edge is 
		// deleted, its connectors are deleted serialized while the edge remains in a semi-destructed 
		// state where polymorphism is no longer supported and the method would not recognize the edge type!)
		if( &((*itEdgeConnector)->getLinkedConnector().getComponentType()) != NULL )
			MInitEdgeDependentStationValues( *this )°(const_cast<CEdge*>(&((*itEdgeConnector)->getEdge())))();
	}

	// Reset all station's values to start values for simulation
	reset();
}
Example #8
0
QString TraceModelImpl::getComponentName(int component, bool full) const
{
    Q_ASSERT(component >= 0 && component < components_.size());

    if (!full)
    {
        return components_.item(component);
    }

    QString fullname = components_.item(component).trimmed();
    for(;;)
    {
        QString splitter = "::";
        if (getComponentType(component) == ComponentType::INTERFACE) splitter = ":";

        component = components_.itemParent(component);
        if (component == Selection::ROOT) break;
        if (component == getParentComponent()) break;

        fullname = components_.item(component).trimmed() + splitter + fullname;
    }

    return fullname;
}
void
PlayerEntity::update(float d)
{
	if (!m_init) {
		Game::SharedSizeComponent l_size_component =
		    getComponentType(Game::SizeComponent::Type()).staticCast<Game::SizeComponent>();
		if (!l_size_component) {
			MMERROR("Player entity requires a size component to be present");
			return;
		}

		m_animation_component =
		    new Game::AnimationComponent("animation", *this);

		m_animation_component->pushFrame("stand-left",  115, 12);
		m_animation_component->pushFrame("stand-left",  116, 4);
		m_animation_component->pushFrame("stand-right", 111, 12);
		m_animation_component->pushFrame("stand-right", 112, 4);

		m_animation_component->pushFrame("walk-left", 117, 1);
		m_animation_component->pushFrame("walk-left", 118, 1);
		m_animation_component->setFrameRate("walk-left", 16);
		m_animation_component->pushFrame("walk-right", 113, 1);
		m_animation_component->pushFrame("walk-right", 114, 1);
		m_animation_component->setFrameRate("walk-right", 16);

		m_animation_component->pushFrame("jump-left", 118, 1);
		m_animation_component->setFrameRate("jump-left", 1);
		m_animation_component->pushFrame("jump-right", 113, 1);
		m_animation_component->setFrameRate("jump-right", 1);

		m_animation_component->pushFrame("dying", 126, 1);
		m_animation_component->pushFrame("dying", 127, 1);

		pushComponent(m_animation_component.staticCast<Game::IComponent>());

		/* movement component */
		m_movement_component =
		    new Game::MovementComponent("movement", *this);
		pushComponent(m_movement_component.staticCast<Game::IComponent>());

		/* collider component */
		m_collider_component =
		    new ActorColliderComponent("collider", *this);
		pushComponent(m_collider_component.staticCast<Game::IComponent>());

		/* input component */
		m_input_component = new InputComponent("input", *this);
		pushComponent(m_input_component.staticCast<Game::IComponent>());

		m_direction = -1;

		m_init = true;
	}

	/*
	 * XXX(gamaral): Most of this needs to be moved elsewhere.
	 */
	else if (m_input_component->isEnabled()) {
		/* make camera follow player */
		Game::SharedPositionComponent l_pos_component =
		    getComponentType(Game::PositionComponent::Type()).staticCast<Game::PositionComponent>();
		if (l_pos_component) {
			Math::Point2 l_pos = l_pos_component->position();
			const Math::Size2f &l_zoom = Graphics::Camera::Zoom();

			if (m_input_component->inMotion()) {
				const float l_lratio = m_input_component->linearRatio();
				m_animation_component->setPlaybackRatio(l_lratio < 0 ? -l_lratio : l_lratio);
			}
			else m_animation_component->setPlaybackRatio(1.f);

			void setFrameRate(const Core::Identifier &animation, float fps);
			/* camara snap - calculate using map */

			float l_limit;
			Game::SharedTilemapSceneLayer l_platform_layer =
			    Game::Engine::Instance()->sceneManager()->activeScene()->getLayer("platform").staticCast<Game::TilemapSceneLayer>();
			const Math::Size2f &l_hrsize = l_platform_layer->virtualHalfSize();

			l_limit = l_hrsize.width - (Graphics::Viewport::Size().width / (2.f * l_zoom.width));
			if (l_pos.x < -l_limit) l_pos.x = -l_limit;
			else if (l_pos.x > l_limit) l_pos.x = l_limit;
			l_limit = l_hrsize.height - (Graphics::Viewport::Size().height / (2.f * l_zoom.height));
			if (l_pos.y < -l_limit) l_pos.y = -l_limit;
			else if (l_pos.y > l_limit) l_pos.y = l_limit;

			Graphics::Camera::SetPosition(l_pos);

			/* translate background layers (parallax) */

			Game::SharedTilemapSceneLayer l_clouds =
			    Game::Engine::Instance()->sceneManager()->activeScene()->
			        getLayer("clouds").staticCast<Game::TilemapSceneLayer>();
			if (l_clouds) {
				if ((m_moving_sky += 8.f * d) > l_clouds->virtualSize().area())
					m_moving_sky = 8.f * d;
				l_clouds->setTranslation(Math::Vector2(m_moving_sky + (l_pos.x * .15f), m_moving_sky));
			}

			Game::SharedTilemapSceneLayer l_cloudbg =
			    Game::Engine::Instance()->sceneManager()->activeScene()->
			        getLayer("cloudbg").staticCast<Game::TilemapSceneLayer>();
			if (l_cloudbg) {
				if ((m_moving_sky_bg += 2.f * d) > l_cloudbg->virtualSize().area())
					m_moving_sky_bg = 2.f * d;
				l_cloudbg->setTranslation(Math::Vector2(m_moving_sky_bg + (l_pos.x * .05f), m_moving_sky_bg));
			}

		}

		/* update animation */
		switch(m_input_component->direction()) {

		case InputComponent::ICDLeft:
			if (m_direction == InputComponent::ICDLeft
			 && m_in_motion == m_input_component->inMotion()
			 && m_on_platform == m_collider_component->onPlatform())
				break;

			m_direction = InputComponent::ICDLeft;
			m_in_motion = m_input_component->inMotion();
			m_on_platform = m_collider_component->onPlatform();

			if (m_on_platform) {
				if (m_in_motion)
					m_animation_component->play("walk-left", true);
				else
					m_animation_component->play("stand-left", true);
			} else m_animation_component->play("jump-left", true);
			break;

		case InputComponent::ICDRight:
			if (m_direction == InputComponent::ICDRight
			 && m_in_motion == m_input_component->inMotion()
			 && m_on_platform == m_collider_component->onPlatform())
				break;

			m_direction = InputComponent::ICDRight;
			m_in_motion = m_input_component->inMotion();
			m_on_platform = m_collider_component->onPlatform();

			if (m_on_platform) {
				if (m_in_motion)
					m_animation_component->play("walk-right", true);
				else
					m_animation_component->play("stand-right", true);
			} else m_animation_component->play("jump-right", true);
			break;

		default: break;
		}
	}

	Game::EntityBase::update(d);
}
void add(const char* component_type, IPropertyDescriptor* descriptor)
{
	getDescriptors(getComponentType(component_type)).push(descriptor);
}
const IPropertyDescriptor* getDescriptor(const char* component_type, const char* property_name)
{
	return getDescriptor(getComponentType(component_type), crc32(property_name));
}
Example #12
0
/**************************************************************************
* 				MIX_GetLineInfo			[internal]
*/
static DWORD MIX_GetLineInfo(WORD wDevID, LPMIXERLINEW lpMl, DWORD_PTR fdwInfo)
{
    int i;
    DWORD ret = MMSYSERR_ERROR;
    MixerLine *line = NULL;

    TRACE("%04X, %p, %08lx\n", wDevID, lpMl, fdwInfo);

    if (lpMl == NULL) {
        WARN("invalid parameter: lpMl = NULL\n");
	return MMSYSERR_INVALPARAM;
    }

    if (lpMl->cbStruct != sizeof(*lpMl)) {
        WARN("invalid parameter: lpMl->cbStruct\n");
	return MMSYSERR_INVALPARAM;
    }

    if (wDevID >= numMixers) {
        WARN("bad device ID: %04X\n", wDevID);
        return MMSYSERR_BADDEVICEID;
    }

    /* FIXME: set all the variables correctly... the lines below
        * are very wrong...
        */
    lpMl->dwUser = 0;

    switch (fdwInfo & MIXER_GETLINEINFOF_QUERYMASK)
    {
        case MIXER_GETLINEINFOF_DESTINATION:
            TRACE("MIXER_GETLINEINFOF_DESTINATION %d\n", lpMl->dwDestination);
            if ( (lpMl->dwDestination >= 0) && (lpMl->dwDestination < mixer.caps.cDestinations) )
            {
                lpMl->dwLineID = lpMl->dwDestination;
                line = &mixer.lines[lpMl->dwDestination];
            }
            else ret = MIXERR_INVALLINE;
            break;
        case MIXER_GETLINEINFOF_COMPONENTTYPE:
            TRACE("MIXER_GETLINEINFOF_COMPONENTTYPE %s\n", getComponentType(lpMl->dwComponentType));
            for (i = 0; i < mixer.caps.cDestinations; i++)
            {
                if (mixer.lines[i].componentType == lpMl->dwComponentType)
                {
                    lpMl->dwDestination = lpMl->dwLineID = i;
                    line = &mixer.lines[i];
                    break;
                }
            }
            if (line == NULL)
            {
                WARN("can't find component type %s\n", getComponentType(lpMl->dwComponentType));
                ret = MIXERR_INVALVALUE;
            }
            break;
        case MIXER_GETLINEINFOF_SOURCE:
            FIXME("MIXER_GETLINEINFOF_SOURCE %d dst=%d\n", lpMl->dwSource, lpMl->dwDestination);
            break;
        case MIXER_GETLINEINFOF_LINEID:
            TRACE("MIXER_GETLINEINFOF_LINEID %d\n", lpMl->dwLineID);
            if ( (lpMl->dwLineID >= 0) && (lpMl->dwLineID < mixer.caps.cDestinations) )
            {
                lpMl->dwDestination = lpMl->dwLineID;
                line = &mixer.lines[lpMl->dwLineID];
            }
            else ret = MIXERR_INVALLINE;
            break;
        case MIXER_GETLINEINFOF_TARGETTYPE:
            FIXME("MIXER_GETLINEINFOF_TARGETTYPE (%s)\n", getTargetType(lpMl->Target.dwType));
            switch (lpMl->Target.dwType) {
                case MIXERLINE_TARGETTYPE_UNDEFINED:
                case MIXERLINE_TARGETTYPE_WAVEOUT:
                case MIXERLINE_TARGETTYPE_WAVEIN:
                case MIXERLINE_TARGETTYPE_MIDIOUT:
                case MIXERLINE_TARGETTYPE_MIDIIN:
                case MIXERLINE_TARGETTYPE_AUX:
                default:
                    FIXME("Unhandled target type (%s)\n",
                          getTargetType(lpMl->Target.dwType));
                    return MMSYSERR_INVALPARAM;
            }
                break;
        default:
            WARN("Unknown flag (%08lx)\n", fdwInfo & MIXER_GETLINEINFOF_QUERYMASK);
            break;
    }

    if (line)
    {
        lpMl->dwComponentType = line->componentType;
        lpMl->cChannels = line->numChannels;
        lpMl->cControls = ControlsPerLine;

        /* FIXME check there with CoreAudio */
        lpMl->cConnections = 1;
        lpMl->fdwLine = MIXERLINE_LINEF_ACTIVE;

        MultiByteToWideChar(CP_ACP, 0, line->name, -1, lpMl->szShortName, sizeof(lpMl->szShortName) / sizeof(WCHAR));
        MultiByteToWideChar(CP_ACP, 0, line->name, -1, lpMl->szName, sizeof(lpMl->szName) / sizeof(WCHAR));

        if ( IsInput(line->direction) )
            lpMl->Target.dwType = MIXERLINE_TARGETTYPE_WAVEIN;
        else
            lpMl->Target.dwType = MIXERLINE_TARGETTYPE_WAVEOUT;

        lpMl->Target.dwDeviceID = line->deviceID;
        lpMl->Target.wMid = mixer.caps.wMid;
        lpMl->Target.wPid = mixer.caps.wPid;
        lpMl->Target.vDriverVersion = mixer.caps.vDriverVersion;

        MultiByteToWideChar(CP_ACP, 0, WINE_MIXER_NAME, -1, lpMl->Target.szPname, sizeof(lpMl->Target.szPname) / sizeof(WCHAR));
        ret = MMSYSERR_NOERROR;
    }
    return ret;
}
Example #13
0
const CStationType& CStation::getStationType() const
{
	return( static_cast<const CStationType&>( getComponentType() ) );
}
void printMixerLine(MIXERLINE* mixerLine) {
    TRACE2("MIXERLINE destination=%d, source=%d, ", mixerLine->dwDestination, mixerLine->dwSource);
    TRACE3("channels=%d, connections=%d, controls=%d, ", mixerLine->cChannels, mixerLine->cConnections, mixerLine->cControls);
    TRACE3("\"%s\", fdwLine=%s, componentType=%s\n", mixerLine->szName,  getLineFlags(mixerLine->fdwLine), getComponentType(mixerLine->dwComponentType));
}