示例#1
0
文件: chat.c 项目: Aitchwing/OpenRCT2
void chat_history_add(const char *src)
{
	int index = _chatHistoryIndex % CHAT_HISTORY_SIZE;
	memset(_chatHistory[index], 0, CHAT_INPUT_SIZE);
	memcpy(_chatHistory[index], src, min(strlen(src), CHAT_INPUT_SIZE - 1));
	_chatHistoryTime[index] = SDL_GetTicks();
	_chatHistoryIndex++;
	Mixer_Play_Effect(SOUND_NEWS_ITEM, 0, SDL_MIX_MAXVOLUME, 0, 1.5f, true);
}
示例#2
0
void chat_history_add(const char* src)
{
    size_t bufferSize = strlen(src) + 64;
    utf8* buffer = (utf8*)calloc(1, bufferSize);

    // Find the start of the text (after format codes)
    const char* ch = src;
    const char* nextCh;
    uint32_t codepoint;
    while ((codepoint = utf8_get_next(ch, &nextCh)) != 0)
    {
        if (!utf8_is_format_code(codepoint))
        {
            break;
        }
        ch = nextCh;
    }
    const char* srcText = ch;

    // Copy format codes to buffer
    std::memcpy(buffer, src, std::min(bufferSize, (size_t)(srcText - src)));

    // Prepend a timestamp
    time_t timer;
    time(&timer);
    struct tm* tmInfo = localtime(&timer);

    strcatftime(buffer, bufferSize, "[%H:%M] ", tmInfo);
    safe_strcat(buffer, srcText, bufferSize);

    // Add to history list
    int32_t index = _chatHistoryIndex % CHAT_HISTORY_SIZE;
    std::fill_n(_chatHistory[index], CHAT_INPUT_SIZE, 0x00);
    std::memcpy(_chatHistory[index], buffer, std::min<size_t>(strlen(buffer), CHAT_INPUT_SIZE - 1));
    _chatHistoryTime[index] = platform_get_ticks();
    _chatHistoryIndex++;

    // Log to file (src only as logging does its own timestamp)
    network_append_chat_log(src);

    free(buffer);

    Mixer_Play_Effect(SOUND_NEWS_ITEM, 0, MIXER_VOLUME_MAX, 0.5f, 1.5f, true);
}
示例#3
0
文件: intro.c 项目: YJSoft/OpenRCT2
// rct2: 0x0068E966
void intro_update()
{
	screen_intro_process_mouse_input();
	screen_intro_process_keyboard_input();

	switch (gIntroState) {
	case INTRO_STATE_DISCLAIMER_1:
	case INTRO_STATE_DISCLAIMER_2:
		// Originally used for the disclaimer text
		gIntroState = INTRO_STATE_PUBLISHER_BEGIN;
	case INTRO_STATE_PUBLISHER_BEGIN:
		load_palette();

		// Set the Y for the Infogrammes logo
		_introStateCounter = -580;

		// Play the chain lift sound
		_soundChannel = Mixer_Play_Effect(SOUND_LIFT_7, MIXER_LOOP_INFINITE, SDL_MIX_MAXVOLUME, 0.5f, 1, true);
		_chainLiftFinished = false;
		gIntroState++;
		break;
	case INTRO_STATE_PUBLISHER_SCROLL:
		// Move the Infogrammes logo down
		_introStateCounter += 5;

		// Check if logo is off the screen...ish
		if (_introStateCounter > gScreenHeight - 120) {
			_introStateCounter = -116;
			gIntroState++;
		}

		break;
	case INTRO_STATE_DEVELOPER_BEGIN:
		_introStateCounter += 5;

		// Set the Y for the Chris Sawyer logo
		_introStateCounter = -116;

		gIntroState++;
		break;
	case INTRO_STATE_DEVELOPER_SCROLL:
		_introStateCounter += 5;

		// Check if logo is almost scrolled to the bottom
		if (!_chainLiftFinished && _introStateCounter >= gScreenHeight + 40 - 421) {
			_chainLiftFinished = true;

			// Stop the chain lift sound
			if (_soundChannel != NULL) {
				Mixer_Stop_Channel(_soundChannel);
				_soundChannel = NULL;
			}

			// Play the track friction sound
			_soundChannel = Mixer_Play_Effect(SOUND_TRACK_FRICTION_3, MIXER_LOOP_INFINITE, SDL_MIX_MAXVOLUME, 0.25f, 0.75, true);
		}

		// Check if logo is off the screen...ish
		if (_introStateCounter >= gScreenHeight + 40) {
			// Stop the track friction sound
			if (_soundChannel != NULL) {
				Mixer_Stop_Channel(_soundChannel);
				_soundChannel = NULL;
			}

			// Play long peep scream sound
			_soundChannel = Mixer_Play_Effect(SOUND_SCREAM_1, MIXER_LOOP_NONE, SDL_MIX_MAXVOLUME, 0.5f, 1, true);

			gIntroState++;
			_introStateCounter = 0;
		}
		break;
	case INTRO_STATE_LOGO_FADE_IN:
		// Fade in, add 4 / 256 to fading
		_introStateCounter += 0x400;
		if (_introStateCounter > 0xFF00) {
			gIntroState++;
			_introStateCounter = 0;
		}
		break;
	case INTRO_STATE_LOGO_WAIT:
		// Wait 80 game ticks
		_introStateCounter++;
		if (_introStateCounter >= 80) {
			// Set fading to 256
			_introStateCounter = 0xFF00;

			gIntroState++;
		}
		break;
	case INTRO_STATE_LOGO_FADE_OUT:
		// Fade out, subtract 4 / 256 from fading
		_introStateCounter -= 0x400;
		if (_introStateCounter < 0) {
			gIntroState = INTRO_STATE_CLEAR;
		}
		break;
	case INTRO_STATE_CLEAR:
		// Stop any playing sound
		if (_soundChannel != NULL) {
			Mixer_Stop_Channel(_soundChannel);
			_soundChannel = NULL;
		}

		// Move to next part
		gIntroState++;
		_introStateCounter = 0;
		break;
	case INTRO_STATE_FINISH:
		gIntroState = INTRO_STATE_NONE;
		load_palette();
		gfx_invalidate_screen();
		audio_start_title_music();
		break;
	}
}