void ConfigurationBatchDialog::OnRemoveSource( wxCommandEvent& event )
{
    int index = m_lSources->GetSelection();
    if (index < 0) return;

    RemoveSource(m_lSources->GetString(index));

    m_lSources->Delete(index);
    m_lDestinations->Delete(index);
}
Exemple #2
0
void AudioHandlerAl::StopSound(int sound_id, bool wait_finish)
{
  assert(sound_id >= 0 && sound_id < sources_.size());
  
  if (wait_finish)
  {
    alSourcei(sources_[sound_id].source, AL_LOOPING, AL_FALSE);
    return;
  }
  
  RemoveSource(sound_id);
}
Exemple #3
0
/////////////////////////////////////////////////////////////////////////////////////////
// DefaultUnfoundedCheck - source pointer propagation
/////////////////////////////////////////////////////////////////////////////////////////
// propagates recently set source pointers within one strong component.
void DefaultUnfoundedCheck::propagateSource(bool forceTodo) {
    for (LitVec::size_type i = 0; i < sourceQ_.size(); ++i) {
        NodeId atom = sourceQ_[i];
        if (atoms_[atom].hasSource()) {
            // propagate a newly added source-pointer
            graph_->visitAtomSuccessors(atom, AddSource(this));
        }
        else {
            graph_->visitAtomSuccessors(atom, RemoveSource(this, forceTodo));
        }
    }
    sourceQ_.clear();
}
Exemple #4
0
void AudioHandlerAl::StopAllSounds(bool wait_finish)
{
  for (int i = 0; i < sources_.size(); ++i)
  {
    if (bgm_source_ref_ != -1 && i == bgm_source_ref_)
      continue;
    
    if (wait_finish)
      alSourcei(sources_[i].source, AL_LOOPING, AL_FALSE);
    else
      RemoveSource(i);
  }
}
DWORD CDissolveDialog::ActionEvent(CMouse* mouse)
{
	const DWORD windowEvent = cTabDialog::ActionEvent(
		mouse);

	if(FALSE == (WE_LBTNCLICK & windowEvent))
	{
		return windowEvent;
	}

	const POINT point = {
		mouse->GetMouseX(),
		mouse->GetMouseY()
	};
	CItem* const item = GetSourceItem(
		point);

	if(0 == item)
	{
		return windowEvent;
	}
	else if(item->IsLocked())
	{
		FakeMoveIcon(
			0,
			0,
			0);
	}

	CItem* const inventoryItem = ITEMMGR->GetItem(
		item->GetDBIdx());

	if(inventoryItem)
	{
		inventoryItem->SetLock(
			FALSE);
	}

	RemoveSource(
		item->GetItemBaseInfo(),
		POSTYPE(item->GetData()));
	RemoveResult(
		item->GetItemBaseInfo());
	Clear(
		*item);

	return windowEvent;
}
Exemple #6
0
void tGauge::RemoveSource( const tDataId& dataId )
{
    int index = -1;
    for( int i = 0; i < m_Indicators.size(); i++ )
    {
        if( m_Indicators.at( i ).dataId == dataId )
        {
            index = i;
            break;
        }
    }

    if( index != -1 )
    {
        RemoveSource( index );
    }
}
//-----------------------------------------------------------------------------
//!
//-----------------------------------------------------------------------------
void tSuzukiRepowerEnginePanel::CreateActions()
{
    m_pSpacerAct = new tAction( this );

    m_pEditAct = new tAction( tr( "Edit" ) + "...", this );
    m_pEditAct->SetAbbreviation( tr( "Edit", "[abbrev] for Edit" ) );
    Connect( m_pEditAct, SIGNAL( triggered() ), this, SLOT( EnterEditMode() ) );

    m_pSaveAct = new tAction( tr( "Save", "[button]" ), this );
    m_pSaveAct->SetAbbreviation( tr( "Save", "[abbrev] for Save" ) );
    Connect( m_pSaveAct, SIGNAL( triggered() ), this, SLOT( EditSave() ) );

    m_pCancelAct = new tAction( tr( "Cancel", "[button]" ), this );
    m_pCancelAct->SetAbbreviation( tr( "Cancel", "[abbrev] for Cancel" ) );
    m_pCancelAct->SetAppearance( Action::DestructiveAppearance );
    Connect( m_pCancelAct, SIGNAL( triggered() ), this, SLOT( EditCancel() ), Qt::QueuedConnection );

    m_pChangeGaugeRangeAct = new tAction( tr( "Configure limits", "[button]" ) + "..." );
    m_pChangeGaugeRangeAct->SetAbbreviation( tr( "Config. limits", "[abbrev] for Configure limits" ) );
    Connect( m_pChangeGaugeRangeAct, SIGNAL( triggered() ), this, SLOT( ConfigureGaugeLimits() ) );

    m_pSelectDataAct = new tAction( tr( "Select info" ) + "..." );
    m_pSelectDataAct->SetAbbreviation( tr( "Select info", "[abbrev] for Select information" ) );
    Connect( m_pSelectDataAct, SIGNAL( triggered() ), this, SLOT( SelectInfo() ) );

    m_pAddSourceAct = new tAction( tr( "Add" ) );
    m_pAddSourceAct->SetAbbreviation( tr( "Add", "[abbrev] for Add" ) );
    m_pRemoveSourceAct = new tAction( tr( "Remove" ) );
    m_pRemoveSourceAct->SetAbbreviation( tr( "Remove", "[abbrev] for Remove" ) );
    m_pAutoAct = new tAction( tr( "Auto" ), this );
    m_pAutoAct->SetAbbreviation( tr( "Auto", "[abbrev] for Auto" ) );
    m_pAutoAct->setCheckable( true );

    m_pSourceMenuAct = new tAction( tr("Sources"), tr( "Sources", "[abbrev] for Sources" ), this );
    m_pSourceMenuAct->AppendSubAction( m_pAddSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pRemoveSourceAct );
    m_pSourceMenuAct->AppendSubAction( m_pAutoAct );
    Connect( m_pAddSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( AddSource() ) );
    Connect( m_pRemoveSourceAct, SIGNAL( triggered() ), m_pPageWidget, SLOT( RemoveSource() ), Qt::QueuedConnection );
    Connect( m_pAutoAct, SIGNAL( toggled( bool ) ), m_pPageWidget, SLOT( SetAutoConfigureSources( bool ) ) );
}
Exemple #8
0
void csSndSysRendererOpenAL::Update()
{
  // Listener is created on open, but EventHandler is setup at init,
  // so, in some cases we can get here without the listener having been
  // created yet.
  if (!m_Listener)
    return;
  // Get exclusive access to the OpenAL context.
  ScopedRendererLock lock (*this);

  // Make sure the context, not really necessary as we requested a async
  // context, but documentation recommends it, in case async contexts are not
  // supported.
  //alcProcessContext (m_Context);

  // Update the listeners state.
  bool ExternalUpdates = m_Listener->Update();

  // Update the sources
  size_t iMax = m_Sources.GetSize();
  for (size_t i=0;i<iMax;i++)
  {
    m_Sources[i]->PerformUpdate( ExternalUpdates );
	if (m_Sources[i]->GetStream()->GetPauseState() == CS_SNDSYS_STREAM_PAUSED &&
        m_Sources[i]->GetStream()->GetAutoUnregisterRequested() == true) // sound has finished and is not looping
	{
	  RemoveStream(m_Sources[i]->GetStream());
	  RemoveSource(m_Sources[i]);
	  i--;    // changing the vector in mid-loop means we back up here
	  iMax--; // array is also one shorter now
	}
  }
  // Check for any errors
  ALCenum err = alcGetError (m_Device);
  if (err != ALC_NO_ERROR)
  {
    Report (CS_REPORTER_SEVERITY_ERROR, "An OpenAL error occured: %s", alcGetString (m_Device, err));
    CS_ASSERT (err == ALC_NO_ERROR);
  }

}
Exemple #9
0
static void ContextCallback(pa_context *ctx, pa_subscription_event_type_t type,
                            uint32_t idx, void *userdata)
{
    services_discovery_t *sd = userdata;
    pa_operation *op;

    assert ((type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK)
                                              == PA_SUBSCRIPTION_EVENT_SOURCE);
    switch (type & PA_SUBSCRIPTION_EVENT_TYPE_MASK)
    {
      case PA_SUBSCRIPTION_EVENT_NEW:
      case PA_SUBSCRIPTION_EVENT_CHANGE:
        op = pa_context_get_source_info_by_index(ctx, idx, SourceCallback, sd);
        if (likely(op != NULL))
            pa_operation_unref(op);
        break;

      case PA_SUBSCRIPTION_EVENT_REMOVE:
        RemoveSource (sd, idx);
        break;
    }
}
Exemple #10
0
void
jsd_DestroyAllSources( JSDContext* jsdc )
{
    JSDSourceText *jsdsrc;
    JSDSourceText *next;

    for (jsdsrc = (JSDSourceText*)jsd_source_list.next;
         jsdsrc != (JSDSourceText*)&jsd_source_list;
         jsdsrc = next) 
    {
        next = (JSDSourceText*)jsdsrc->links.next;
        RemoveSource( jsdc, jsdsrc );
    }

    for (jsdsrc = (JSDSourceText*)jsd_removed_source_list.next;
         jsdsrc != (JSDSourceText*)&jsd_removed_source_list;
         jsdsrc = next) 
    {
        next = (JSDSourceText*)jsdsrc->links.next;
        RemoveSourceFromRemovedList( jsdc, jsdsrc );
    }

}
Exemple #11
0
void AudioHandlerAl::UnloadSound(const std::string& resource)
{
  // remove all referenced source first
  
  std::map<std::string, int>::iterator itor = buffer_resource_map_.find(resource);
  if (itor != buffer_resource_map_.end())
  {
    int buffer_ref = itor->second;
    size_t source_num = sources_.size();
    for (int i = 0; i < source_num; ++i)
    {
      if (sources_[i].buffer_ref == buffer_ref)
        RemoveSource(i);
    }
  }
  
  // if still exist
  
  itor = buffer_resource_map_.find(resource);
  if (itor != buffer_resource_map_.end())
  {
    RemoveBuffer(itor->second);
  }
}
Exemple #12
0
void FileSourceUnion::AppendSource(FileSource *fs)
{
    assert(fs);
    RemoveSource(fs);
    m_sources.push_back(fs);
}
Exemple #13
0
void FileSourceUnion::PrependSource(FileSource *fs)
{
    assert(fs);
    RemoveSource(fs);
    m_sources.insert(m_sources.begin(), fs);
}
BOOL CDissolveDialog::FakeMoveIcon(LONG x, LONG y, cIcon* movedIcon)
{
	// 완료된 결과가 있을 경우 초기화시킨다
	{
		CItem* const item = (CItem*)mSourceDialog->GetIconForIdx(
			0);

		if(item->IsLocked())
		{
			Clear();
		}
	}

	CItem* const movedItem = (CItem*)movedIcon;

	if(0 == movedItem)
	{
		return FALSE;
	}
	else if(WT_ITEM != movedItem->GetType())
	{
		return FALSE;
	}
	else if(movedItem->IsLocked())
	{
		return FALSE;
	}
	else if(FALSE == ITEMMGR->IsEqualTableIdxForPos(eItemTable_Inventory, movedItem->GetPosition()))
	{
		CHATMGR->AddMsg(
			CTC_SYSMSG,
			CHATMGR->GetChatMsg(787));
		return FALSE;
	}

	// 기존 아이템이 위치한 장소에 놓았을 경우 교체한다
	const POINT point = {x, y};
	CItem* const item = GetSourceItem(
		point);

	if(0 == item)
	{
		return FALSE;
	}
	else if(0 < item->GetItemIdx())
	{
		RemoveSource(
			item->GetItemBaseInfo(),
			POSTYPE(item->GetData()));
		RemoveResult(
			item->GetItemBaseInfo());
		Clear(
			*item);
	}

	const Error error = IsEnableUpdate(movedItem->GetItemBaseInfo());

	if(ErrorNone != error)
	{
		PutError(
			error,
			movedItem->GetItemIdx());
		return FALSE;
	}

	AddSource(
		movedItem->GetItemBaseInfo(),
		POSTYPE(item->GetData()));
	AddResult(
		movedItem->GetItemBaseInfo());

	mSubmitButton->SetActive(
		TRUE);
	return FALSE;
}
CDissolveDialog::Error CDissolveDialog::Submit()
{
	CInventoryExDialog* const inventoryDialog = (CInventoryExDialog*)WINDOWMGR->GetWindowForID(
		IN_INVENTORYDLG);

	if(0 == inventoryDialog)
	{
		return ErrorIsNoInventory;
	}

	MSG_ITEM_DISSOLVE_SYN message;
	ZeroMemory(
		&message,
		sizeof(message));
	message.Category = MP_ITEM;
	message.Protocol = MP_ITEM_DISSOLVE_SYN;
	message.dwObjectID = gHeroID;

	typedef std::set< POSTYPE > ReservedPositionContainer;
	ReservedPositionContainer reservedPositionContainer;

	// 재료 취합
	for(WORD cellIndex = 0; mSourceDialog->GetCellNum() > cellIndex; ++cellIndex)
	{
		CItem* const sourceItem = (CItem*)mSourceDialog->GetIconForIdx(
			cellIndex);
		CItem* const inventoryItem = ITEMMGR->GetItem(
			sourceItem->GetDBIdx());

		if(0 == inventoryItem)
		{
			continue;
		}
		else if(ITEMMGR->IsDupItem(inventoryItem->GetItemIdx()))
		{
			if(sourceItem->GetDurability() != inventoryItem->GetDurability())
			{
				const ITEMBASE sourceItemBase = inventoryItem->GetItemBaseInfo();

				RemoveSource(
					sourceItemBase,
					cellIndex);
				RemoveResult(
					sourceItemBase);
				return ErrorInInvalidSource;
			}
		}

		MSG_ITEM_DISSOLVE_SYN::Item item;
		ZeroMemory(
			&item,
			sizeof(item));
		item.mType = MSG_ITEM_DISSOLVE_SYN::Item::TypeSource;
		item.mIndex = inventoryItem->GetItemIdx();
		item.mDbIndex = inventoryItem->GetDBIdx();
		item.mQuantity = (ITEMMGR->IsDupItem(inventoryItem->GetItemIdx()) ? inventoryItem->GetDurability() : 1);
		item.mPosition = inventoryItem->GetPosition();

		if(FALSE == message.Add(item))
		{
			return ErrorInsufficientInventory;
		}

		reservedPositionContainer.insert(
			inventoryItem->GetPosition());
	}

	ResultContainer resultContainer;

	// 결과 취합
	for(BYTE tabIndex = 0; tabIndex < GetTabNum(); ++tabIndex)
	{
		cPushupButton* const button = GetTabBtn(
			tabIndex);

		if(FALSE == button->IsActive())
		{
			break;
		}

		cIconGridDialog* const iconGridDialog = (cIconGridDialog*)GetTabSheet(
			tabIndex);

		for(WORD cellIndex = 0; iconGridDialog->GetCellNum() > cellIndex; ++cellIndex)
		{
			CItem* const item = (CItem*)iconGridDialog->GetIconForIdx(
				cellIndex);

			if(0 == item->GetItemIdx())
			{
				break;
			}

			resultContainer[item->GetItemIdx()] += item->GetDurability();
		}
	}

	// 랜덤 결과 취합
	for(WORD cellIndex = 0; mRandomResultDialog->GetCellNum() > cellIndex; ++cellIndex)
	{
		CItem* const item = (CItem*)mRandomResultDialog->GetIconForIdx(
			cellIndex);

		if(0 == item->GetItemIdx())
		{
			break;
		}

		resultContainer[item->GetItemIdx()] += item->GetDurability();
	}

	// 중첩 처리 가능한 경우 최대한 시도한다
	for(ResultContainer::iterator iterator = resultContainer.begin();
		resultContainer.end() != iterator;
		++iterator)
	{
		const ItemIndex resultItemIndex = iterator->first;
		ItemQuantity& resultItemQuantity = iterator->second;

		if(FALSE == ITEMMGR->IsDupItem(resultItemIndex))
		{
			continue;
		}
		else if(0 >= resultItemQuantity)
		{
			continue;
		}

		for(POSTYPE inventoryCellIndex = TP_INVENTORY_START;
			inventoryCellIndex < TP_INVENTORY_END + TABCELL_INVENTORY_NUM * HERO->Get_HeroExtendedInvenCount();
			++inventoryCellIndex)
		{
			if(0 >= resultItemQuantity)
			{
				break;
			}
			else if(reservedPositionContainer.end() != reservedPositionContainer.find(inventoryCellIndex))
			{
				continue;
			}

			CItem* const item = inventoryDialog->GetItemForPos(
				inventoryCellIndex);
			const ITEM_INFO* const itemInfo = ITEMMGR->GetItemInfo(
				item ? item->GetItemIdx() : 0);

			if(0 == itemInfo)
			{
				continue;
			}
			else if(itemInfo->ItemIdx != resultItemIndex)
			{
				continue;
			}
			else if(itemInfo->Stack <= item->GetDurability())
			{
				continue;
			}
			else if(itemInfo->wSeal != item->GetItemBaseInfo().nSealed)
			{
				continue;
			}

			MSG_ITEM_DISSOLVE_SYN::Item resultItem;
			ZeroMemory(
				&resultItem,
				sizeof(resultItem));
			resultItem.mType = MSG_ITEM_DISSOLVE_SYN::Item::TypeResult;
			resultItem.mPosition = item->GetPosition();
			resultItem.mIndex = item->GetItemIdx();
			resultItem.mDbIndex = item->GetDBIdx();
			resultItem.mQuantity = min(
				itemInfo->Stack - item->GetDurability(),
				DURTYPE(resultItemQuantity));

			if(FALSE == message.Add(resultItem))
			{
				return ErrorInsufficientInventory;
			}

			resultItemQuantity -= resultItem.mQuantity;
		}
	}

	// 결과를 인벤토리 빈 칸에 채워나간다
	for(POSTYPE inventoryCellIndex = TP_INVENTORY_START;
		inventoryCellIndex < TP_INVENTORY_END + TABCELL_INVENTORY_NUM * HERO->Get_HeroExtendedInvenCount();)
	{
		if(resultContainer.empty())
		{
			break;
		}

		const ResultContainer::iterator resultIterator = resultContainer.begin();
		const ItemIndex resultItemIndex = resultIterator->first;
		ItemQuantity& resultItemQuantity = resultIterator->second;

		if(0 >= resultItemQuantity)
		{
			resultContainer.erase(
				resultIterator);
			continue;
		}

		CItem* const item = inventoryDialog->GetItemForPos(
			inventoryCellIndex);

		if(0 < item)
		{
			// 재료가 위치한 슬롯은 사용 가능하므로 검사한다
			if(reservedPositionContainer.end() == reservedPositionContainer.find(item->GetPosition()))
			{
				++inventoryCellIndex;
				continue;
			}
		}

		const ITEM_INFO* const itemInfo = ITEMMGR->GetItemInfo(
			resultItemIndex);

		if(0 == itemInfo)
		{
			++inventoryCellIndex;
			continue;
		}

		MSG_ITEM_DISSOLVE_SYN::Item resultItem;
		ZeroMemory(
			&resultItem,
			sizeof(resultItem));
		resultItem.mType = MSG_ITEM_DISSOLVE_SYN::Item::TypeResult;
		resultItem.mPosition = inventoryCellIndex;
		resultItem.mIndex = resultItemIndex;
		resultItem.mQuantity = min(
			itemInfo->Stack ? itemInfo->Stack : 1,
			resultItemQuantity);

		if(FALSE == message.Add(resultItem))
		{
			return ErrorInsufficientInventory;
		}

        resultItemQuantity -= resultItem.mQuantity;
		++inventoryCellIndex;
	}

	NETWORK->Send(
		&message,
		message.GetSize());
	return ErrorNone;
}
Exemple #16
0
int AudioHandlerAl::AddSource(int buffer_ref, bool is_loop, float volume, float pitch)
{
  assert(buffer_ref >= 0 && buffer_ref < buffers_.size());

  ALenum error = AL_NO_ERROR;
  
  AudioSourceInfo source_info;
  source_info.buffer_ref = buffer_ref;
  
  // Create some OpenAL Source Objects
  alGenSources(1, &source_info.source);
  if ((error = alGetError()) != AL_NO_ERROR) 
  {
    fprintf(stderr, "Error(%x) generating source\n", error);
    return -1;
  }
  
  // Turn Looping ON
  alSourcei(source_info.source, AL_LOOPING, is_loop ? AL_TRUE : AL_FALSE);
  
  // Set Source Position
  float sourcePosAL[] = {0, 0, 0};
  alSourcefv(source_info.source, AL_POSITION, sourcePosAL);
  
  // Set Source Reference Distance
  alSourcef(source_info.source, AL_REFERENCE_DISTANCE, 50.0f);
  
  // Attach OpenAL Buffer to OpenAL Source
  alSourcei(source_info.source, AL_BUFFER, buffers_[buffer_ref].buffer);
  
  // Set Volume
  source_info.volume = volume;
  alSourcef(source_info.source, AL_GAIN, global_sound_volume_ * volume);
  
  // Set Pitch
  alSourcef(source_info.source, AL_PITCH, pitch);
  
  if ((error = alGetError()) != AL_NO_ERROR)
  {
    fprintf(stderr, "Error(%x) setup source\n", error);
    return -1;
  }
  
  // play
  alSourcePlay(source_info.source);
  if ((error = alGetError()) != AL_NO_ERROR)
  {
    fprintf(stderr, "Error(%x) starting source\n", error);
    return -1;
  }
  
  ++buffers_[buffer_ref].reference_count;
  
#ifdef AUDIO_LOG
  fprintf(stdout, "AddSource add ref count of buffer %d: %d\n", buffer_ref, buffers_[buffer_ref].reference_count);
#endif
  
  int i = 0;
  ALint play;
  bool can_insert;
  for (; i < sources_.size(); ++i)
  {
    can_insert = false;
    if (sources_[i].buffer_ref == -1)
    {
      can_insert = true;
    }
    else
    {
      alGetSourcei(sources_[i].source, AL_SOURCE_STATE, &play);
      if (play != AL_PLAYING)
      {
        RemoveSource(i);
        can_insert = true;
      }
    }
    
    if (can_insert)
    {
      sources_[i] = source_info;
      
#ifdef AUDIO_LOG
      fprintf(stdout, "AddSource replace source %d\n", i);
#endif
      
      break;
    }
  }
  
  if (i == sources_.size())
  {
    sources_.push_back(source_info);
    
#ifdef AUDIO_LOG
    fprintf(stdout, "AddSource push back source %d\n", i);
#endif
  }
  
  return i;
}