Esempio n. 1
0
bool BarkGump::loadData(IDataSource* ids, uint32 version)
{
	if (!ItemRelativeGump::loadData(ids, version)) return false;

	counter = static_cast<sint32>(ids->read4());
	textwidget = ids->read2();
	speechshapenum = ids->read4();
	speechlength = ids->read4();
	totaltextheight = ids->read4();

	uint32 slen = ids->read4();
	if (slen > 0) {
		char* buf = new char[slen+1];
		ids->read(buf, slen);
		buf[slen] = 0;
		barked = buf;
		delete[] buf;
	} else {
		barked = "";
	}


	TextWidget *widget = p_dynamic_cast<TextWidget*>(getGump(textwidget));

	SettingManager::get_instance()->get("textdelay", textdelay);

	// This is just a hack
	Pentagram::Rect d;
	widget->GetDims(d);
	counter = d.h * textdelay;
	dims.h = d.h;
	dims.w = d.w;

	return true;
}
Esempio n. 2
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;
}
Esempio n. 3
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);
}