Ejemplo n.º 1
0
EditText::EditText(SObject* obj)
{
	SParser parser;
	parser.Attach(obj->character->data, 0);     

	m_flags = parser.GetWord();

	if ( m_flags & seditTextFlagsHasFont )
	{
		parser.SkipBytes(4);
	}

	if ( m_flags & seditTextFlagsHasTextColor )
	{
		parser.GetColor(true);
	}

	if ( m_flags & seditTextFlagsHasMaxLength )
	{
		m_maxLength = parser.GetWord();
	}
	else
	{
		m_maxLength = 0;
	}

	if ( m_flags & seditTextFlagsHasLayout )
	{
		m_align = parser.GetByte();
		parser.SkipBytes(8);
	}
	else
	{
		m_align = stextAlignLeft;
	}

	m_variable = parser.GetStringP();

	if ( m_flags & seditTextFlagsHasText )
	{
		m_initialText = parser.GetStringP();
	}
	else
	{
		m_initialText = NULL;
	}

	m_obj             = obj;
	m_character       = obj->character;
	m_clickTime       = 0;
	m_selecting       = FALSE;
	m_buffer          = new U16[1];
	m_buffer[0]       = '\0';
	m_length          = 0;
	m_selectionStart  = 0;
	m_selectionEnd    = 0;
	m_hscroll         = 0;
	m_vscroll         = 0;
	m_mouseIsDown     = FALSE;
	m_doFindCursor    = FALSE;
	m_mousePosition.x = 0;
	m_mousePosition.y = 0;
	m_lineX           = NULL;
	m_drawn           = FALSE;
	m_lineStarts      = NULL;
	m_numLines        = 0;
	m_atLineEnd       = FALSE;
	m_heldLeadByte    = -1;
	devCharWidths     = NULL;
	devLineSpacing    = 0;
	devAscent         = 0;

	RectSetEmpty(&devBounds);
}
Ejemplo n.º 2
0
void DisplayList::DoButtonAction(SObject* target, int transition)
{
	SCharacter* ch = target->character;
	FLASHASSERT(ch->type == buttonChar);

	if ( ch->tagCode == stagDefineButton2 ) {
		// Handle the new style button
		SParser parser;
		parser.Attach(ch->data, 0);
		BOOL first = true;
		for (;;) {
			S32 link = parser.pos;
			int offset = parser.GetWord();
			if ( !first ) {
				int code = parser.GetWord();
				if ( code & (1<<transition) ) {
					PushAction(parser.script+parser.pos, target->thread);
				}
			}
			if ( !offset ) break;
			parser.pos = link + offset;
			first = false;
		}

	} else {
		// Handle the old style button
		if ( transition == bsOverDownToOverUp ) {
			// Do the button action on the mouse up in
			SParser parser;
			parser.Attach(ch->data, 0);

			// Skip over the child data
			for (;;) {
				U8 stateFlags = parser.GetByte();
				if ( !stateFlags ) break;
				MATRIX m;
				parser.SkipBytes(4);//GetWord();
				//parser.GetWord();
				parser.GetMatrix(&m);
			}

			// Handle the action
			PushAction(parser.script+parser.pos, target->thread);
		}
	}

#ifdef SOUND
	{// Play the sound
		int state = 0;
		switch ( transition ) {
			case bsIdleToOverDown:
			case bsIdleToOverUp:
				state = sbtnOverState;
				break;

			case bsOverUpToOverDown:
				state = sbtnDownState;
				break;

			case bsOverDownToOverUp:
				state = sbtnHitTestState;
				break;

			case bsOverUpToIdle:
			case bsOutDownToIdle:
			case bsOverDownToIdle:
				state = sbtnUpState;
				break;
		}

		if ( state && ch->button.soundData ) {
			SParser parser;
			parser.Attach(ch->button.soundData, 0);

			// Skip the sounds
			for ( int i = 1; i < state; i <<= 1 ) {
				U16 tag = parser.GetWord();
				if ( tag )
					parser.GetSoundInfo(0);// skip the data
			}

			// Get the sound we want
			U16 tag = parser.GetWord();
			if ( tag ) {
				SCharacter* sound = ch->player->FindCharacter(tag);
				if ( !sound || sound->type != soundChar ) return;

				CSoundChannel* channel = new CSoundChannel();
				if ( channel ) {
					channel->AddRef();
					channel->sound = &sound->sound;
					channel->tag = (U32)this;
					parser.GetSoundInfo(channel);	// set up envelope, inPoint, loops, etc...

					theSoundMix->AddSound(channel);
					channel->Release();
				}
			}
		}
	}
#endif
}