Exemplo n.º 1
0
bool BarkGump::NextText()
{
	TextWidget *widget = p_dynamic_cast<TextWidget*>(getGump(textwidget));
	assert(widget);
	if (widget->setupNextText()) {
		// This is just a hack
		Pentagram::Rect d;
		widget->GetDims(d);
		if (speechlength && totaltextheight) {
			counter = (d.h * speechlength) / totaltextheight;
		} else {
			counter = d.h * textdelay;
		}
		dims.h = d.h;
		dims.w = d.w;
		return true;
	}

	return false;
}
Exemplo n.º 2
0
void BarkGump::InitGump(Gump* newparent, bool take_focus)
{
	// OK, this is a bit of a hack, but it's how it has to be
	int	fontnum;
	if (owner == 1) fontnum = 6;
	else if (owner > 256) fontnum = 8;
	else switch (owner%3) {
		case 1:
			fontnum = 5;
			break;
			
		case 2:
			fontnum = 7;
			break;

		default:
			fontnum = 0;
			break;
	}

	// This is a hack. We init the gump twice...
	ItemRelativeGump::InitGump(newparent, take_focus);

	// Create the TextWidget
	TextWidget *widget = new TextWidget(0,0,barked,true,fontnum,194,55);
	widget->InitGump(this);

	textwidget = widget->getObjId();

	// see if we need to play speech
	AudioProcess *ap = AudioProcess::get_instance();
	speechlength = 0;
	if (speechshapenum && ap) {
		if (ap->playSpeech(barked, speechshapenum, owner)) {
			speechlength = ap->getSpeechLength(barked, speechshapenum) / 33;
			if (speechlength == 0) speechlength = 1;

			// We're playing speech, so need to sync the text with the speech.
			// First we count the total height of all text blocks.
			Pentagram::Rect d;
			widget->GetDims(d);
			totaltextheight = d.h;
			while (widget->setupNextText()) {
				widget->GetDims(d);
				totaltextheight += d.h;
			}
			widget->rewind();
		}
	}

	// This is just a hack
	Pentagram::Rect d;
	widget->GetDims(d);
	if (speechlength && totaltextheight) {
		counter = (d.h * speechlength) / totaltextheight;
	} else {
		counter = d.h * textdelay;
	}
	dims.h = d.h;
	dims.w = d.w;

	// Wait with ItemRelativeGump initialization until we calculated our size.
	ItemRelativeGump::InitGump(newparent, take_focus);
}