Example #1
0
void Subtitles::setTextByID(unsigned long id) {
	if (id == static_cast<unsigned long>(-1) && visible_timer.isEnd()) {
		current_id = -1;
		current_text = "";

		if (background) {
			delete background;
			background = NULL;
		}

		return;
	}

	for (size_t i = 0; i < filename.size(); ++i) {
		if (filename[i] == id) {
			current_id = id;
			current_text = text[i];
			updateLabelAndBackground();

			// 1 second per 10 letters
			visible_timer.setDuration(static_cast<int>(current_text.length()) * (settings->max_frames_per_sec / 10));

			return;
		}
	}
}
Example #2
0
void Subtitles::setTextByID(unsigned long id) {
	if (id == static_cast<unsigned long>(-1) && visible_ticks == 0) {
		current_id = -1;
		current_text = "";

		if (background) {
			delete background;
			background = NULL;
		}

		return;
	}

	for (size_t i = 0; i < filename.size(); ++i) {
		if (filename[i] == id) {
			current_id = id;
			current_text = text[i];
			updateLabelAndBackground();

			// 1 second per 10 letters
			// TODO is this too short?
			visible_ticks = static_cast<int>(current_text.length()) * (MAX_FRAMES_PER_SEC/10);

			return;
		}
	}
}
Example #3
0
void Subtitles::logic(unsigned long id) {
	setTextByID(id);

	visible_timer.tick();

	if (current_text.empty()) {
		visible = false;
		return;
	}
	else {
		visible = true;
	}

	updateLabelAndBackground();
}
Example #4
0
void Subtitles::logic(unsigned long id) {
	if (!SUBTITLES)
		return;

	setTextByID(id);

	if (visible_ticks > 0)
		visible_ticks--;

	if (current_text.empty()) {
		visible = false;
		return;
	}
	else {
		visible = true;
	}

	updateLabelAndBackground();
}