Пример #1
0
//=====================================================================================
//  Window for WIND
//=====================================================================================
CFuiWind::CFuiWind(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char erm[128];
  sprintf(erm,"Incorrect TEMPLATE file: %",filename);
  //---Locate components ------------------------------------
  layW = (CFuiList*)  GetComponent('layr');
  if (0 == layW) gtfo(erm);
  errW = (CFuiLabel*) GetComponent('eror');
  if (0 == layW) gtfo(erm);
  popW = (CFuiPopupMenu*) GetComponent('popm');
  if (0 == popW) gtfo(erm);
  skyW = (CFuiTextField*) GetComponent('ceil');
  if (0 == skyW) gtfo(erm);
  //-- Init menu -------------------------------------------
  popW->CreatePage(&cMEN,coverMENU);
  layer = globals->wtm->GetCloudLayer();
  popW->SetButtonText((char*)cMEN.aText[layer]);
  //-- Init cloud ceil -------------------------------------
  ceil = globals->wtm->GetCloudCeil();
  ChangeCeil(0);
  //-- Init list box ---------------------------------------
  U_INT type = LIST_HAS_TITLE + LIST_NOHSCROLL;
  windBOX.SetParameters(this,'layr',type);
  windBOX.Display();
  Select();
}
Пример #2
0
// Splits the calling object into its components.
global func Split2Components()
{
	// Safety: can only be called from object context.
	if (!this || GetType(this) != C4V_C4Object)
		return FatalError(Format("Split2Components must be called from object context and not from %v", this));

	// Transfer all contents to container.
	var ctr = Contained();
	while (Contents())
		if (!ctr || !Contents()->Enter(ctr))
			Contents()->Exit();
			
	// Split components.
	for (var i = 0, compid; compid = GetComponent(nil, i); ++i)
		for (var j = 0; j < GetComponent(compid); ++j)
		{
			var comp = CreateObjectAbove(compid, nil, nil, GetOwner());
			if (OnFire()) comp->Incinerate();
			if (!ctr || !comp->Enter(ctr))
			{
				comp->SetR(Random(360));
				comp->SetXDir(Random(3) - 1);
				comp->SetYDir(Random(3) - 1);
				comp->SetRDir(Random(3) - 1);
			}
		}
	return RemoveObject();
}
Пример #3
0
//=====================================================================================
//=====================================================================================
//  Weather overview
//=====================================================================================
CFuiWeatherView::CFuiWeatherView(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ char *erm = "Invalid template %s";
  //---Get window components -------------------------------
  datW  = (CFuiLabel*)GetComponent('date');
  if (0 == datW)  gtfo(erm,filename);
  timW  = (CFuiLabel*)GetComponent('time');
  if (0 == datW)  gtfo(erm,filename);
  utcW  = (CFuiLabel*)GetComponent('utc_');
  if (0 == utcW)  gtfo(erm,filename);
  disW  = (CFuiLabel*)GetComponent('dist');
  if (0 == disW)  gtfo(erm,filename);
  locW  = (CFuiLabel*)GetComponent('loca');
  if (0 == locW)  gtfo(erm,filename);
  winW  = (CFuiLabel*)GetComponent('wind');
  if (0 == winW)  gtfo(erm,filename);
  altW  = (CFuiLabel*)GetComponent('alti');
  if (0 == altW)  gtfo(erm,filename);
  tmpW  = (CFuiLabel*)GetComponent('temp');
  if (0 == tmpW)  gtfo(erm,filename);
  barW  = (CFuiLabel*)GetComponent('baro');
  if (0 == barW)  gtfo(erm,filename);
  cldW  = (CFuiLabel*)GetComponent('clod');
  if (0 == cldW)  gtfo(erm,filename);
  //---------------------------------------------------------
  Apt   = 0;
  Req.SetWindow(this);
}
Пример #4
0
/////////////////////////////
//	DeSerialize
//	 -Translate the data in the buffer into relevant data for this object
void Player::DeSerialize(char * _buffer)
{
	Transform * playerT = (Transform*)GetComponent(C_TRANSFORM);
	InputController * playerI = (InputController*)GetComponent(C_INPUT);

	// Read ID
	unsigned int id = 0;
	memcpy(&id, &_buffer[0], sizeof(id));
	m_uiID = id;

	// Read X
	int x = 0;
	memcpy(&x, &_buffer[4], sizeof(x));
	playerT->SetX(x);

	// Read Y
	int y = 0;
	memcpy(&y, &_buffer[8], sizeof(y));
	playerT->SetY(y);

	// Read input controller's ID
	unsigned int inputID = 0;// playerI->GetID();
	memcpy(&inputID, &_buffer[12], sizeof(inputID));
	playerI->SetID(inputID);

	m_pGame->SetRefresh(true);
}
Пример #5
0
std::unique_ptr<Entity> EntityFactory::CreateFlyingEnemy(int x, int y, Entity *target)
{
  
  auto e = BaseEnemy(x, y);
  e->AddComponent(ComponentType::AI, std::unique_ptr<FlyingAiComponent>(new FlyingAiComponent(target)));

  auto g = static_cast<GraphicsComponent *>(e->GetComponent(ComponentType::GRAPHICS));
  auto c = static_cast<CollisionComponent *>(e->GetComponent(ComponentType::COLLISION));
  g->AddFrame(0, 200028, 5);
  g->AddFrame(0, 200032, 5);

  c->AddHitbox(0,0,70,35, HitboxType::SOLID);
  c->AddHitbox(0,0,70,35, HitboxType::TRIGGER);

  std::unique_ptr<SoundComponent> sound(new SoundComponent());
  sound->AddSoundEffect(SoundEffectType::DEATH, SOUND_MONSTER_DEATH);

  e->AddComponent(ComponentType::SOUND, std::move(sound));
  

  auto spawnHealthPickupOnDeathScript = Compiler::Compile("data/scripts/SpawnHealthPickupOnDeathScript.txt");
  RegisterNativeBindings(spawnHealthPickupOnDeathScript);

  e->AddVmScript(std::move(spawnHealthPickupOnDeathScript));
  

  return e;
}
Пример #6
0
/////////////////////////////
//	Update
//	 -Main loop
void Player::Update()
{
	Transform * playerT = (Transform*)GetComponent(C_TRANSFORM);

	InputController * input = (InputController*)GetComponent(C_INPUT);
	bool changedInput = false;
	if (input->GetKeyDown('W'))
	{
		playerT->SetY(playerT->GetY() - 1);
		changedInput = true;
	}
	if (input->GetKeyDown('A'))
	{
		playerT->SetX(playerT->GetX() - 1);
		changedInput = true;
	}
	if (input->GetKeyDown('S'))
	{
		playerT->SetY(playerT->GetY() + 1);
		changedInput = true;
	}
	if (input->GetKeyDown('D'))
	{
		playerT->SetX(playerT->GetX() + 1);
		changedInput = true;
	}

	if (changedInput)
	{
		NetworkView * nwView = (NetworkView*)GetComponent(C_NETWORK);
		nwView->UpdatePositionMessage(playerT->GetX(), playerT->GetY());
	}

	UpdateComponents();
}
Пример #7
0
/**
**  Draw formatted text with variable value.
**
**  @param unit         unit with variable to show.
**  @param defaultfont  default font if no specific font in extra data.
**
**  @note text is limited to 256 chars. (enough?)
**  @note text must have exactly 2 %d.
**  @bug if text format is incorrect.
*/
void CContentTypeFormattedText2::Draw(const CUnit *unit, CFont *defaultfont) const
{
	CFont *font;
	char buf[256];
	UStrInt usi1, usi2;

	Assert(unit);
	font = this->Font ? this->Font : defaultfont;
	Assert(font);

	usi1 = GetComponent(unit, this->Index1, this->Component1, 0);
	usi2 = GetComponent(unit, this->Index2, this->Component2, 0);
	if (usi1.type == USTRINT_STR) {
		if (usi2.type == USTRINT_STR) {
			sprintf(buf, this->Format, usi1.s, usi2.s);
		} else {
			sprintf(buf, this->Format, usi1.s, usi2.i);
		}
	} else {
		if (usi2.type == USTRINT_STR) {
			sprintf(buf, this->Format, usi1.i, usi2.s);
		} else {
			sprintf(buf, this->Format, usi1.i, usi2.i);
		}
	}
	if (this->Centered) {
		VideoDrawTextCentered(this->PosX, this->PosY, font, buf);
	} else {
		VideoDrawText(this->PosX, this->PosY, font, buf);
	}
}
Пример #8
0
TimeRep :: TimeRep( const string & s )  : mSecs( 0 ) {
	vector <string> tmp;
	ALib::Split( s, ':', tmp );
	if ( tmp.size() != 3 ) {
		throw Exception( "Invalid time format: " + s );
	}
	int hrs = GetComponent( tmp[0], 24 );
	int mins = GetComponent( tmp[1], 60 );
	int secs = GetComponent( tmp[2], 60 );
	mSecs = hrs * 60 * 60 + mins * 60 + secs;
}
Пример #9
0
bool OMXClock::Step(int steps, bool lock)
{
	if (!GetComponent())
		return false;

	if (lock)
		Lock();

	OMX_ERRORTYPE omxErr = OMX_ErrorNone;
	OMX_PARAM_U32TYPE param;
	OMX_INIT_STRUCTURE(param);

	param.nPortIndex = OMX_ALL;
	param.nU32 = steps;

	omxErr = SetConfig(OMX_IndexConfigSingleStep, &param);
	if (omxErr != OMX_ErrorNone)
	{
		if (lock)
			Unlock();

		return false;
	}

	m_lastMediaTime = 0.0f;
	if (lock)
		Unlock();

	return true;
}
Пример #10
0
bool OMXClock::Start(bool lock)
{
	if (!GetComponent())
		return false;

	if (lock)
		Lock();

	OMX_ERRORTYPE omxErr = OMX_ErrorNone;
	OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
	OMX_INIT_STRUCTURE(clock);

	clock.eState = OMX_TIME_ClockStateRunning;

	omxErr = SetConfig(OMX_IndexConfigTimeClockState, &clock);
	if (omxErr != OMX_ErrorNone)
	{
		if (lock)
			Unlock();

		return false;
	}

	m_eState = clock.eState;

	m_lastMediaTime = 0.0f;

	if (lock)
		Unlock();

	return true;
}
Пример #11
0
bool OMXClock::Stop(bool lock)
{
	if (!GetComponent())
		return false;

	if (lock)
		Lock();

	OMX_ERRORTYPE omxErr = OMX_ErrorNone;
	OMX_TIME_CONFIG_CLOCKSTATETYPE clock;
	OMX_INIT_STRUCTURE(clock);

	clock.eState = OMX_TIME_ClockStateStopped;
	clock.nOffset = ToOMXTime(-1000LL * OMX_PRE_ROLL);

	omxErr = SetConfig(OMX_IndexConfigTimeClockState, &clock);
	if (omxErr != OMX_ErrorNone)
	{
		if (lock)
			Unlock();

		return false;
	}

	m_eState = clock.eState;

	m_lastMediaTime = 0.0f;

	if (lock)
		Unlock();

	return true;
}
Пример #12
0
   bool MapSystem::OnEntityChangedUniqueId(EntityId id, const std::string& oldUniqueId, const std::string& newUniqueId)
   {
      if(oldUniqueId == newUniqueId)
      {
         return true;
      }

      typedef std::map<std::string, EntityId> UIMap;
      MapComponent* comp = GetComponent(id);
      assert(comp != NULL);

      UIMap::iterator j = mEntitiesByUniqueId.find(newUniqueId);
      if(j != mEntitiesByUniqueId.end())
      {
         return false;
      }  

      UIMap::iterator i = mEntitiesByUniqueId.find(oldUniqueId);
      if(i != mEntitiesByUniqueId.end())
      {
         mEntitiesByUniqueId.erase(i);
      }

      mEntitiesByUniqueId[newUniqueId] = id;


      EntityNameUpdatedMessage msg;
      msg.SetAboutEntityId(id);
      msg.SetEntityName(comp->GetEntityName());
      msg.SetUniqueId(newUniqueId);
      GetEntityManager().EmitMessage(msg);
      return true;
   }
Пример #13
0
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 void GridLayout::SetNumCols(u32 in_numCols)
 {
     CS_ASSERT(in_numCols > 0, "Cannot create a grid with 0 columns");
     m_numCols = in_numCols;
     
     GetComponent()->OnLayoutChanged();
 }
Пример #14
0
 //------------------------------------------------------------------------------
 //------------------------------------------------------------------------------
 void GridLayout::SetNumRows(u32 in_numRos)
 {
     CS_ASSERT(in_numRos > 0, "Cannot create a grid with 0 rows");
     m_numRows = in_numRos;
     
     GetComponent()->OnLayoutChanged();
 }
Пример #15
0
bool OMXClock::StateExecute(bool lock)
{
	if (!GetComponent())
		return false;

	if (lock)
		Lock();

	OMX_ERRORTYPE omxErr = OMX_ErrorNone;

	if (GetState() != OMX_StateExecuting)
	{
		StateIdle(false);

		omxErr = SetStateForComponent(OMX_StateExecuting);
		if (omxErr != OMX_ErrorNone)
		{
			if (lock)
				Unlock();

			return false;
		}
	}

	m_lastMediaTime = 0.0f;
	if (lock)
		Unlock();

	return true;
}
Пример #16
0
double OMXClock::ClockAdjustment(bool lock)
{
	if (!GetComponent())
		return 0.0;

	if (lock)
		Lock();

	OMX_ERRORTYPE omxErr = OMX_ErrorNone;
	double pts = 0.0;

	OMX_TIME_CONFIG_TIMESTAMPTYPE timestamp;
	OMX_INIT_STRUCTURE(timestamp);
	timestamp.nPortIndex = GetInputPort();

	omxErr = GetConfig(OMX_IndexConfigClockAdjustment, &timestamp);
	if (omxErr != OMX_ErrorNone)
	{

		if (lock)
			Unlock();

		return 0.0;
	}

	pts = (double)FromOMXTime(timestamp.nTimestamp);

	if (lock)
		Unlock();

	return pts;
}
Пример #17
0
/**
**  Draw formatted text with variable value.
**
**  @param unit         unit with variable to show.
**  @param defaultfont  default font if no specific font in extra data.
**
**  @note text is limited to 256 chars. (enough?)
**  @note text must have exactly 1 %d.
**  @bug if text format is incorrect.
*/
/* virtual */ void CContentTypeFormattedText::Draw(const CUnit &unit, CFont *defaultfont) const
{
	char buf[256];
	UStrInt usi1;

	CFont &font = this->Font ? *this->Font : *defaultfont;
	Assert(&font);

	//Wyrmgus start
//	CLabel label(font);
	CLabel label(font, this->TextColor, this->HighlightColor);
	//Wyrmgus end

	Assert((unsigned int) this->Index < UnitTypeVar.GetNumberVariable());
	usi1 = GetComponent(unit, this->Index, this->Component, 0);
	if (usi1.type == USTRINT_STR) {
		snprintf(buf, sizeof(buf), this->Format.c_str(), _(usi1.s));
	} else {
		snprintf(buf, sizeof(buf), this->Format.c_str(), usi1.i);
	}

	char *pos;
	if ((pos = strstr(buf, "~|")) != NULL) {
		std::string buf2(buf);
		label.Draw(this->Pos.x - font.getWidth(buf2.substr(0, pos - buf)), this->Pos.y, buf);
	} else if (this->Centered) {
		label.DrawCentered(this->Pos.x, this->Pos.y, buf);
	} else {
		label.Draw(this->Pos.x, this->Pos.y, buf);
	}
}
Пример #18
0
static PyObject * BackSubCoreDP_light_update(BackSubCoreDP * self, PyObject * args)
{
 // Extract the 3 parameters...
 float mult[3];
 if (!PyArg_ParseTuple(args, "fff", &mult[0], &mult[1], &mult[2])) return NULL;

 // Iterate every single component and update the effective mean, taking the offset into account...
  int y,x,c,col;
  for (y=0;y<self->height;y++)
  {
   for (x=0;x<self->width;x++)
   {
    for (c=0;c<self->component_cap;c++)
    {
     Component * com = GetComponent(self,y,x,c);
     for (col=0;col<3;col++)
     {
      float est = (com->mu[col] + self->prior_mu[col]) * mult[col];
      if (est>1.0) est = 1.0; // No point in exceding the dynamic range - this seems to happen to skys a lot due to them being oversaturated.
      com->mu[col] = est - self->prior_mu[col];
     }
    }
   }
  }

 Py_INCREF(Py_None);
 return Py_None;
}
Пример #19
0
void plResponderCmdAnim::CreateWait(plMaxNode* node, plErrorMsg* pErrMsg, IParamBlock2 *pb, ResponderWaitInfo& waitInfo)
{
    plAnimCmdMsg *animMsg = plAnimCmdMsg::ConvertNoRef(waitInfo.msg);
    if (animMsg)
        animMsg->SetCmd(plAnimCmdMsg::kAddCallbacks);

    plSoundMsg *soundMsg = plSoundMsg::ConvertNoRef(waitInfo.msg);
    if (soundMsg)
        soundMsg->SetCmd(plSoundMsg::kAddCallbacks);

    plEventCallbackMsg *eventMsg = new plEventCallbackMsg;
    eventMsg->AddReceiver(waitInfo.receiver);
    eventMsg->fRepeats = 0;
    eventMsg->fUser = waitInfo.callbackUser;

    if (!waitInfo.point.IsNull())
    {
        // FIXME COLIN - Error checking here?
        plAnimComponent *animComp = (plAnimComponent*)GetComponent(pb);
        plString animName = animComp->GetAnimName();

        plNotetrackAnim notetrackAnim(animComp, nil);
        plAnimInfo info = notetrackAnim.GetAnimInfo(animName);

        eventMsg->fEvent = kTime;
        eventMsg->fEventTime = info.GetMarkerTime(waitInfo.point);
    }
    else
        eventMsg->fEvent = kStop;

    plMessageWithCallbacks *callbackMsg = plMessageWithCallbacks::ConvertNoRef(waitInfo.msg);
    callbackMsg->AddCallback(eventMsg);
    // AddCallback adds it's own ref, so remove ours (the default of 1)
    hsRefCnt_SafeUnRef(eventMsg);
}
Пример #20
0
static PyObject * BackSubCoreDP_background(BackSubCoreDP * self, PyObject * args)
{
 // Get the output numpy array...
  PyArrayObject * image;
  if (!PyArg_ParseTuple(args, "O!", &PyArray_Type, &image)) return NULL;

 // Iterate the pixels and write the mode into each...
  int y,x,c,i;
  for (y=0;y<self->height;y++)
  {
   for (x=0;x<self->width;x++)
   {
    float * rgb = (float*)(image->data + y*image->strides[0] + x*image->strides[1]);

    float best = 0.0;
    for (c=0;c<self->component_cap;c++)
    {
     Component * com = GetComponent(self,y,x,c);
     if (com->count>best)
     {
      best = com->count;
      for (i=0;i<3;i++) rgb[i] = self->prior_mu[i] + com->mu[i];
     }
    }

    if (best<1e-3)
    {
     for (i=0;i<3;i++) rgb[i] = self->prior_mu[i];
    }
   }
  }

 Py_INCREF(Py_None);
 return Py_None;
}
Пример #21
0
    ComponentPtr Entity::GetOrCreateComponent(uint type_hash, const QString &name, AttributeChange::Type change)
    {
        ComponentPtr new_comp = GetComponent(type_hash, name);
        if (new_comp)
            return new_comp;

        return CreateComponent(type_hash, name, change);
    }
Пример #22
0
    ComponentPtr Entity::GetOrCreateComponent(const QString &type_name, const QString &name, AttributeChange::Type change, bool syncEnabled)
    {
        ComponentPtr new_comp = GetComponent(type_name, name);
        if (new_comp)
            return new_comp;

        return CreateComponent(type_name, name, change, syncEnabled);
    }
Пример #23
0
Component* Node::GetOrCreateComponent(ShortStringHash type, CreateMode mode)
{
    Component* oldComponent = GetComponent(type);
    if (oldComponent)
        return oldComponent;
    else
        return CreateComponent(type, mode);
}
Пример #24
0
	void Bullet::BulletDeath(WorldState & worldState)
	{
		//MarkForDestroy(worldState);

		UNREFERENCED_PARAMETER(worldState);
		mIsDead = true;
		GetComponent(CircleColliderComponent::TypeName())->AssertiveAs<CircleColliderComponent>()->SetEnabled(false);
	}
Пример #25
0
//=========================================================================================
//  AIRCRAFT SELECTION WINDOW
//  Display a list of available aircraftt with icon and make according to the popup filter
//  NOTE:  Due to the flag ok in the VehicleSelect.win, the button id is renamed okok
//=========================================================================================
CFuiSetAir::CFuiSetAir(Tag idn, const char *filename)
:CFuiWindow(idn,filename,0,0,0)
{ fSlot.FixeIt();
  airBOX.SetParameters(this,'crft',0,64);
  selPOP = (CFuiPopupMenu*)GetComponent('type');
  if (0 == selPOP)  gtfo("Wrong file VehicleSelect.win");
  selBTN = (CFuiButton*)   GetComponent('okok');
  if (0 == selBTN)  gtfo("Wrong file VehicleSelect.win");
  //---Create associated mask (change size when adding new type) ---------------
  mask[0]       = 0x00FF;
  mask[1]       = 0x01;
  mask[2]       = 0x02;
  mask[3]       = 0x04;
  mask[4]       = 0x08;
  mask[5]       = 0x10;
  EditSelPopup();
}
Пример #26
0
public func Initialize()
{
  // Erst alle Komponenten löschen
  var i, id;
  while(id = GetComponent(0, i++, 0, GetID()) )
    SetComponent(id, 0, this() );
  SetComponent(ILOA, 3, this() );
}
Пример #27
0
 void Entity::RemoveComponentRaw(QObject* comp)
 {
     IComponent* compPtr = dynamic_cast<IComponent*>(comp);
     if (compPtr)
     {
         ComponentPtr ptr = GetComponent(compPtr->TypeName(), compPtr->Name()); //the shared_ptr to this component
         RemoveComponent(ptr);
     }
 }
Пример #28
0
Component* Entity::GetComponent(std::string _type)
{
    for(int i=0; i<(int)CV.size(); i++)
    {
        if(CV[i]->GetType() == _type)
            return GetComponent(i);
    }
    return NULL;
}
void UAbilityTask_WaitOverlap::Activate()
{
	UPrimitiveComponent* PrimComponent = GetComponent();
	if (PrimComponent)
	{
		PrimComponent->OnComponentBeginOverlap.AddDynamic(this, &UAbilityTask_WaitOverlap::OnOverlapCallback);
		PrimComponent->OnComponentHit.AddDynamic(this, &UAbilityTask_WaitOverlap::OnHitCallback);
	}
}
Пример #30
0
//--------------------------------------------------------------------------------------------------
void ayy_AddExeContent
(
    const char* contentName
)
//--------------------------------------------------------------------------------------------------
{
    try
    {
        const char* contentType;

        if (legato::IsCSource(contentName))
        {
            contentType = "C source code";

            // Add the source code file to the default component.
            ExePtr->AddCSourceFile(contentName);
        }
        else if (legato::IsLibrary(contentName))
        {
            contentType = "library";

            // Add the library file to the list of libraries to be linked with the default
            // component.
            ExePtr->AddLibrary(contentName);
        }
        else if (legato::IsComponent(contentName, BuildParamsPtr->ComponentDirs()))
        {
            contentType = "component";

            // Find the component and add it to the executable's list of component instances.
            // NOTE: For now, we only support one instance of a component per executable.
            ExePtr->AddComponentInstance(GetComponent(contentName));
        }
        else
        {
            contentType = "** unknown **";

            std::string msg = "Executable '";
            msg += ExePtr->OutputPath();
            msg += "': Unable to identify content item '";
            msg += contentName;
            msg += "'.";

            throw legato::Exception(msg);
        }

        if (ayy_IsVerbose)
        {
            std::cout << "    Added '" << contentName << "' (" << contentType << ")"
                      << " to executable '" << ExePtr->OutputPath() << "'." << std::endl;
        }
    }
    catch (legato::Exception e)
    {
        ayy_error(e.what());
    }
}