Example #1
0
void ARX_SPEECH_Check()
{
	bool bClear = false;
	long exist = 0;

	for(size_t i = 0; i < MAX_SPEECH; i++) {
		if(speech[i].timecreation == 0)
			continue;

		if(float(arxtime) > speech[i].timecreation + speech[i].duration) {
			ARX_SPEECH_MoveUp();
			i--;
		} else {
			exist++;
		}

		bClear = true;
	}

	if(bClear && pTextManage) {
		pTextManage->Clear();
	}

	if(exist)
		ARX_SPEECH_Render();
}
Example #2
0
void ARX_SPEECH_Check()
{
    bool bClear = false;
    long exist = 0;

    for(size_t i = 0; i < MAX_SPEECH; i++) {
        if(speech[i].timecreation == ArxInstant_ZERO)
            continue;

        ArxDuration elapsed = arxtime.now() - speech[i].timecreation;
        if(elapsed > speech[i].duration) {
            ARX_SPEECH_MoveUp();
            i--;
        } else {
            exist++;
        }

        bClear = true;
    }

    if(bClear && pTextManage) {
        pTextManage->Clear();
    }

    if(exist)
        ARX_SPEECH_Render();
}
Example #3
0
void ARX_SPEECH_Add(const std::string & text) {

    if(text.empty())
        return;

    ArxInstant now = arxtime.now();
    if(now == ArxInstant_ZERO) {
        now = ArxInstantMs(1);
    }

    if(speech[MAX_SPEECH - 1].timecreation != ArxInstant_ZERO) {
        ARX_SPEECH_MoveUp();
    }

    for(size_t i = 0; i < MAX_SPEECH; i++) {

        if(speech[i].timecreation != ArxInstant_ZERO)
            continue;

        // Sets creation time
        speech[i].timecreation = now;
        speech[i].duration = ArxDurationMs(2000 + text.length() * 60);
        speech[i].text = text;
        return;
    }

    LogInfo << "Failed to add speech: " << text;
}
Example #4
0
static void ARX_SPEECH_Render() {
	
	long igrec = 14;
	
	Vec2i sSize = hFontInBook->getTextSize("p");
	sSize.y *= 3;
	
	int iEnd = igrec + sSize.y;
	
	for(size_t i = 0; i < MAX_SPEECH; i++) {
		
		if(speech[i].timecreation == 0 || speech[i].text.empty()) {
			continue;
		}
		
		Rectf rect(
			Vec2f(120 * g_sizeRatio.x - 16 * minSizeRatio(), igrec),
			16 * minSizeRatio(),
			16 * minSizeRatio()
		);
		
		GRenderer->SetRenderState(Renderer::AlphaBlending, true);
		GRenderer->SetBlendFunc(Renderer::BlendSrcAlpha, Renderer::BlendInvSrcAlpha);
		
		EERIEDrawBitmap(rect, .00001f, arx_logo_tc, Color::white);
		
		igrec += ARX_UNICODE_DrawTextInRect(hFontInBook, Vec2f(120.f * g_sizeRatio.x, igrec), 500 * g_sizeRatio.x,
		                           ' ' + speech[i].text, Color::white, NULL);
		
		if(igrec > iEnd && !isLastSpeech(i)) {
			ARX_SPEECH_MoveUp();
			break;
		}
	}

	GRenderer->SetRenderState(Renderer::AlphaBlending, false);
}
Example #5
0
long ARX_SPEECH_Add(const std::string & text, long duration) {
	
	if(text.empty())
		return -1;
	
	unsigned long tim = (unsigned long)(arxtime);
	if(tim == 0) {
		tim = 1;
	}
	
	if(speech[MAX_SPEECH - 1].timecreation != 0) {
		ARX_SPEECH_MoveUp();
	}
	
	for(size_t i = 0; i < MAX_SPEECH; i++) {

		if(speech[i].timecreation != 0)
			continue;
		
		// Sets creation time
		speech[i].timecreation = tim;
		
		// Sets/computes speech duration
		if(duration == -1) {
			speech[i].duration = 2000 + text.length() * 60;
		} else {
			speech[i].duration = duration;
		}
		
		speech[i].text = text;
		
		// Successfull allocation
		return speech[i].duration;
	}
	
	return -1;
}