Ejemplo n.º 1
0
Dialog* Dialog::createDialogByScript( const char* dialogName )
{
	char tempBuf[256];
	Tcl_Interp* interp = GetScriptManager().getInterp();
	
	StringCchPrintfA( tempBuf, 256, "%s::region", dialogName );
	TileRegion region;
	GetScriptManager().readRect( tempBuf, region );

	StringCchPrintfA( tempBuf, 256, "%s::dialog", dialogName );
	Tcl_Obj* dialogObj = GetScriptManager().getObject( tempBuf );
	int dialogTokenCount;
	Tcl_ListObjLength( interp, dialogObj, &dialogTokenCount );
	UINT speakCount = dialogTokenCount / 2;
	Dialog::Speak* speakArray = new Dialog::Speak[ speakCount ];
	UINT i;
	for ( i = 0; i < speakCount; ++i )
	{
		Tcl_Obj* elem;
		int length;
		Tcl_ListObjIndex( interp, dialogObj, i*2 + 0, &elem );
		speakArray[ i ].name = Tcl_GetStringFromObj( elem, &length );
		Tcl_ListObjIndex( interp, dialogObj, i*2 + 1, &elem );
		speakArray[ i ].content = Tcl_GetStringFromObj( elem, &length );
	}

	StringCchPrintfA( tempBuf, 256, "%s::oneTime", dialogName );
	int oneTime = GetScriptManager().readInt( tempBuf );

	return new Dialog( speakArray, speakCount, &region, oneTime?true:false, dialogName );
}
Ejemplo n.º 2
0
HRESULT World::init()
{
    HRESULT hr = S_OK;
    if ( GetG().m_videoMan->GetDev() )
        loadWorldModel();

    char command[128];
    StringCchPrintfA( command, 128, "%s::init 0x%p", m_worldName.c_str(), this );
    GetScriptManager().execute( command );

    if ( !m_sound )
    {
        m_sound = new Sound;
        m_sound->init();
    }
    else
        throw std::runtime_error( "Sound should not be init twice or more" );



    // 'enter' function implemented in the script file defines which characters are exist in this world
    char scriptCommand[128];
    StringCchPrintfA( scriptCommand, 128, "%s::enter", m_worldName.c_str() );
    GetScriptManager().execute( scriptCommand );

    // Hero and enemies are defined afterwards

    // CAUTION To be set by RakNet ReplicaManager
    assert( m_heroUnit );

    m_curDialog = 0;
    return hr;
}
Ejemplo n.º 3
0
void EvaChatWindowManager::slotReceivedMessage(unsigned int sender, bool isNormal, TQString message, TQDateTime time, const char size, 
		const bool u, const bool i, const bool b, 
		const char blue, const char green, const char red)
{	
	// notify script
	GetScriptManager()->notifyMessage( false, sender, time, message);
	
	EvaChatWindow *win = getWindow(sender);
	if(win && win->isVisible()){
		win->slotReceivedMessage(sender, isNormal, message, time, size, u, i, b, blue, green, red);
		win->showMessages();
		if(!win->isActiveWindow()){
			KWin::demandAttention(win->winId(), true);
		}
		return;
	}
	
	Message *msg = new Message;
	msg->sender = sender;
	msg->isNormal = isNormal;
	msg->message = message;
	msg->time = time;
	msg->size = size;
	msg->u = u;
	msg->i = i;
	msg->b = b;
	msg->blue = blue;
	msg->green = green;
	msg->red = red;
	
	messageQueue.append(msg);
}
Ejemplo n.º 4
0
Unit* EpCreateHero( Tcl_Obj* tilePos )
{
	int tileX = 0, tileY = 0;
	GetScriptManager().readTwoIntObj( tilePos, tileX, tileY );

	return Hero::createHero( 0, tileX, tileY, 0 );

} SCRIPT_CALLABLE_PV_OBJ( EpCreateHero )
Ejemplo n.º 5
0
void ScriptAction::activate()
{
	Action::activate();

	GetScriptManager().execute( m_scriptCommand.c_str() );

	// ScriptAction is 'very' instantaneous, so deactivate() is called
	// immediately after activate().
	deactivate();
}
Ejemplo n.º 6
0
Skill* Skill::createSkillByScript( const char* skillNsName )
{
	char tempBuf[256];
	StringCchPrintfA( tempBuf, 256, "%s::name", skillNsName );
	const char* skillName = GetScriptManager().readString( tempBuf );
	StringCchPrintfA( tempBuf, 256, "%s::description", skillNsName );
	const char* skillDescription = GetScriptManager().readString( tempBuf );
	StringCchPrintfA( tempBuf, 256, "%s::csEssentials", skillNsName );
	int csEssentials = GetScriptManager().readInt( tempBuf );

	Skill* ret = new Skill( skillName, skillDescription, csEssentials );

	StringCchPrintfA( tempBuf, 256, "%s::registerSkillObjects", skillNsName );
	Tcl_Obj* skillObjects = GetScriptManager().execute( tempBuf );

	int skillObjectsCount = 0;
	Tcl_Interp* interp = GetScriptManager().getInterp();
	Tcl_ListObjLength( interp, skillObjects, &skillObjectsCount );
	
	int i;
	for ( i = 0; i < skillObjectsCount; ++i )
	{
		Tcl_Obj* elem;
		long soPtrVal = 0;
		SkillObject* so = 0;
		Tcl_ListObjIndex( interp, skillObjects, i, &elem );
		Tcl_GetLongFromObj( interp, elem, &soPtrVal );
		so = reinterpret_cast<SkillObject*>( soPtrVal );
		if ( so->getType() == UT_SKILLOBJECT )
			ret->addSkillObject( so );
		else
			throw std::runtime_error( "Serious error on script file." );
	}

	return ret;
}
Ejemplo n.º 7
0
UINT World::preloadDialogs()
{
    char scriptCommand[512];
    ConstCharList dialogNameList;
    StringCchPrintfA( scriptCommand, 512, "%s::dialogNameList", m_worldName );
    GetScriptManager().readCharPtrList( scriptCommand, dialogNameList );

    ConstCharList::iterator itDlg = dialogNameList.begin();
    for ( ; itDlg != dialogNameList.end(); ++itDlg )
    {
        StringCchPrintfA( scriptCommand, 512, "%s::%s", m_worldName, *itDlg );
        Dialog* newDlg = Dialog::createDialogByScript( scriptCommand );
        newDlg->init();
        addDialog( newDlg );
    }

    return dialogNameList.size();
}
Ejemplo n.º 8
0
void EvaChatWindowManager::slotReceivedQunMessage( unsigned int qunID, unsigned int senderQQ, TQString message, TQDateTime time, const char size, 
						const bool u, const bool i, const bool b, 
						const char blue, const char green, const char red )
{
	// notify script
	int extId = EvaMain::user->getQunList()->getQunExtID(qunID);
	
	GetScriptManager()->notifyMessage( true, extId, time, message);
	EvaQunChatWindow *win = getQunWindow(qunID);
	if(win && win->isVisible()){
		win->slotReceivedMessage(qunID, senderQQ, message, time, size, u, i, b, blue, green, red);
		win->showMessages();
		if(!win->isActiveWindow()){
			KWin::demandAttention(win->winId(), true);
		}
		return;
	}
	
	QunMessage *msg = new QunMessage;
	msg->qunID = qunID;
	msg->sender = senderQQ;
	msg->message = message;
	msg->time = time;
	msg->size = size;
	msg->u = u;
	msg->i = i;
	msg->b = b;
	msg->blue = blue;
	msg->green = green;
	msg->red = red;
	
	qunMessageQueue.append(msg);
	
	EvaHtmlParser parser;
	TQString cachesPath = EvaMain::user->getSetting()->getPictureCacheDir();
	parser.setAbsImagePath(EvaMain::images->getSmileyPath(), cachesPath);
	std::list<CustomizedPic> picList = parser.convertToHtml(message, true, true);
	if(picList.size()){
		EvaAskForCustomizedPicEvent *event = new EvaAskForCustomizedPicEvent();
		event->setPicList(picList);
		event->setQunID(qunID);
		TQApplication::postEvent((TQObject *)EvaMain::picManager, event);
	}
}