Ejemplo n.º 1
0
void C3SliderButtonActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie )
{

	if ( action != (uint32)AUI_BUTTON_ACTION_PRESS ) return;

	aui_Ranger *ranger = (aui_Ranger *)cookie;
	aui_Button *button = (aui_Button *)control;

	sint32		sound = -1;

	if ( button == ranger->GetIncrementXButton() ) {
		ranger->IncrementUpX();
		sound = GAMESOUNDS_SLIDERUP;
	} else if ( button == ranger->GetIncrementYButton() ) {
 		ranger->IncrementUpY();
		sound = GAMESOUNDS_SLIDERUP;
	} else if ( button == ranger->GetDecrementXButton() ) {
		ranger->IncrementDownX();
		sound = GAMESOUNDS_SLIDERDOWN;
	} else {
		ranger->IncrementDownY();
		sound = GAMESOUNDS_SLIDERDOWN;
	}

	if (sound != -1)
	if (g_soundManager) {
		g_soundManager->AddSound(SOUNDTYPE_SFX, 0,
				gamesounds_GetGameSoundID(sound), 0, 0);
	}
}
Ejemplo n.º 2
0
void C3SliderThumbActionCallback( aui_Control *control, uint32 action, uint32 data, void *cookie )
{

	aui_Ranger *ranger = (aui_Ranger *)cookie;

	sint32		sound = -1;
	static aui_Ranger *oldRanger = 0;
	static sint32 val = 0;

	if (oldRanger != ranger) {
		oldRanger = ranger;
		val = 0;
	}

	switch ( action )
	{
	case AUI_THUMB_ACTION_DRAG:
		ranger->ThumbMoved();

		if (val != ranger->GetValueX()) {
			sound = GAMESOUNDS_SLIDERUP;
			val = ranger->GetValueX();
		}

		break;

	case AUI_THUMB_ACTION_DROP:
		ranger->ThumbMoved( TRUE );
		sound = GAMESOUNDS_SLIDERDOWN;
		if(ranger->GetActionFunc()) {
			ranger->GetActionFunc()(ranger, AUI_RANGER_ACTION_RELEASE, 0, ranger->GetCookie());
		}
		break;
	}

	if (sound != -1)
		if (g_soundManager) {
			g_soundManager->AddSound(SOUNDTYPE_SFX, 0,
					gamesounds_GetGameSoundID(sound), 0, 0);
		}
}
Ejemplo n.º 3
0
void aui_Button::MouseLGrabInside( aui_MouseEvent *mouseData )
{
	if (IsDisabled()) {
		if (g_soundManager) {
			g_soundManager->AddSound(SOUNDTYPE_SFX, 0,
					gamesounds_GetGameSoundID(GAMESOUNDS_GENERALFAIL), 0, 0);
		}
		return;
	}

	if ( !GetWhichSeesMouse() || GetWhichSeesMouse() == this )
	{
		SetWhichSeesMouse( this );

		PlaySound( AUI_SOUNDBASE_SOUND_ENGAGE );

		HideTipWindow();

		SetMouseOwnership();
		SetKeyboardFocus();

		m_mouseCode = AUI_ERRCODE_HANDLEDEXCLUSIVE;

		m_attributes |= k_CONTROL_ATTRIBUTE_DOWN;
		m_attributes |= k_CONTROL_ATTRIBUTE_ACTIVE;
		m_draw |= m_drawMask & k_AUI_REGION_DRAWFLAG_MOUSELGRABINSIDE;

		m_isRepeating = TRUE;
		m_repeatCount = 0;
		m_startWaitTime = mouseData->time;
		if ( m_ActionFunc )
			m_ActionFunc( this, AUI_BUTTON_ACTION_PRESS, 0, m_cookie );
		else if ( m_action )
			m_action->Execute( this, AUI_BUTTON_ACTION_PRESS, 0 );
	}
	else
		MouseLGrabOutside( mouseData );
}
Ejemplo n.º 4
0
void ChatBox::AddLine(sint32 playerNum, MBCHAR *text)
{
	COLOR		color = g_colorSet->ComputePlayerColor(playerNum);
	COLORREF	colorRef = g_colorSet->GetColorRef(color);

	MBCHAR			coloredText[_MAX_PATH];

	m_chatWindow->ColorizeString(coloredText, text, colorRef);

	strcat(coloredText, "\n");

	m_chatWindow->GetTextBox()->AppendHyperText(coloredText);

	aui_Ranger *ranger = m_chatWindow->GetTextBox()->GetRanger();
	ranger->SetValue(ranger->GetValueX(), ranger->GetMaximumY());

	if (g_c3ui->GetWindow(m_chatWindow->Id()) == NULL) {
		g_soundManager->AddSound(SOUNDTYPE_SFX, (uint32)0,
									gamesounds_GetGameSoundID(GAMESOUNDS_CHAT_MESSAGE),
									0,
									0);
	}
}
Ejemplo n.º 5
0
void SoundManager::ProcessRedbook()
{
	if (!g_theProfileDB->IsUseRedbookAudio()) return;

	if (!m_musicEnabled) return;

	if (GetTickCount() > m_timeToCheckCD) {
#if defined(USE_SDL)
        CDstatus status;
        if (m_cdrom) {
            status = SDL_CDStatus(m_cdrom);
#else
        U32 status;
		if (m_redbook) {
			status = AIL_redbook_status(m_redbook);
#endif
			switch (status) {
#if !defined(USE_SDL)
			case REDBOOK_ERROR:
#else
            case CD_TRAYEMPTY:
                break;
            case CD_ERROR:
#endif
				break;
#if !defined(USE_SDL)
			case REDBOOK_PLAYING:
#else
            case CD_PLAYING:
#endif
				break;
#if !defined(USE_SDL)
			case REDBOOK_PAUSED:
#else
            case CD_PAUSED:
#endif
				break;
#if !defined(USE_SDL)
			case REDBOOK_STOPPED:
#else
            case CD_STOPPED:
#endif			
				if (m_curTrack != -1) 
					PickNextTrack();
				
				if (m_curTrack != -1 && !m_stopRedbookTemporarily) 
					StartMusic(m_curTrack);
				break;
			}
		}

		m_timeToCheckCD = GetTickCount() + k_CHECK_CD_PERIOD;
	}
}

void SoundManager::Process(const uint32 &target_milliseconds,
                           uint32 &used_milliseconds)
{
	CivSound						*sound;

    sint32 start_time_ms = GetTickCount(); 

    if ((m_noSound) ||(m_usePlaySound)) { 
        used_milliseconds = GetTickCount() - start_time_ms; 
        return;
    }

	
	if (m_sfxSounds->GetCount() > 0) {
		m_soundWalker->SetList(m_sfxSounds);
		while (m_soundWalker->IsValid()) {
			sound = m_soundWalker->GetObj();
			Assert(sound);
			if (!sound) continue;
			
			if (sound->IsPlaying()) {
#if !defined(USE_SDL)
				if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) {
#else
                if (!Mix_Playing(sound->GetChannel())) {
#endif
					m_soundWalker->Remove();

					delete sound;
				} else {
					m_soundWalker->Next();
				}
			}
		}
	}

	if (m_voiceSounds->GetCount() > 0) {
		
		m_soundWalker->SetList(m_voiceSounds);
		while (m_soundWalker->IsValid()) {
			sound = m_soundWalker->GetObj();
			Assert(sound);
			if (!sound) continue;
			
			if (sound->IsPlaying()) {
#if !defined(USE_SDL)
				if (AIL_quick_status(sound->GetHAudio()) == QSTAT_DONE) {
#else
                if ((-1 == sound->GetChannel()) ||
                    (!Mix_Playing(sound->GetChannel()))) {
#endif
					m_soundWalker->Remove();
					delete sound;
				} else {
					m_soundWalker->Next();
				}
			}
		}
	}

	ProcessRedbook();

    used_milliseconds = GetTickCount() - start_time_ms; 
}


bool FindSoundinList(PointerList<CivSound> * sndList, sint32 soundID)
{
    for 
    (
	    PointerList<CivSound>::Walker walk(sndList);
	    walk.IsValid();
        walk.Next()
    ) 
    {
		if (walk.GetObj()->GetSoundID() == soundID)
		{
			return true;
		}
	}

	return false;
}

void
SoundManager::AddGameSound(const GAMESOUNDS &sound)
{
	sint32 id = gamesounds_GetGameSoundID(sound);
	AddSound(SOUNDTYPE_SFX, 0, id, 0, 0);
}