示例#1
0
void CLuaManager::executeScriptFile(const CEGUI::String& filename, const CEGUI::String& resourceGroup)
{
    // load file
    CEGUI::RawDataContainer raw;
    CEGUI::System::getSingleton().getResourceProvider()->loadRawDataContainer(filename,
          raw, resourceGroup.empty() ? d_defaultResourceGroup : resourceGroup);

    // load code into lua
    int loaderr = luaL_loadbuffer(m_luaVM, (char*)raw.getDataPtr(), raw.getSize(), filename.c_str());
    CEGUI::System::getSingleton().getResourceProvider()->unloadRawDataContainer(raw);

    // call it
    if (loaderr==0) { // run the file
        int result = lua_pcall(m_luaVM,0,0,0);
        switch (result) {
            case LUA_ERRRUN:
                CLog::getInstance()->error("Runtime error in %s", filename.c_str());
                break;
            case LUA_ERRMEM:
                CLog::getInstance()->error("Memory alocation error in %s", filename.c_str());
                break;
            case LUA_ERRERR:
                CLog::getInstance()->error("Error handler error in %s", filename.c_str());
                break;
            default:
                break;
        }
    } else {
        CLog::getInstance()->error("Unable to load %s", filename.c_str());
    }
}
示例#2
0
//-------------------------------------------------------------------------------------
bool
NetworkManager::connect(const CEGUI::EventArgs&)
{
  CEGUI::WindowManager *winMgr = CEGUI::WindowManager::getSingletonPtr();
  CEGUI::String Iptmp;
  CEGUI::String PortTmp;
  unsigned int i = 1;
  if (winMgr->isWindowPresent("Connect/ContainerGrp/Ip"))
    {
      Iptmp = winMgr->getWindow("Connect/ContainerGrp/Ip")->getText();
      PortTmp = winMgr->getWindow("Connect/ContainerGrp/Port")->getText();
      this->ip_ = std::string(Iptmp.c_str());
      this->port_ = StringToNumber<const char *, int>(PortTmp.c_str());
      zappy::Convert *c = new zappy::Convert();
      zappy::Network::initInstance(this->ip_ , this->port_, *c);
      zappy::Network &p = zappy::Network::getInstance();
      p.setParameters(this->port_, this->ip_);
      p.connect_();
      if (p.isConnected())
	{
	  Thread<zappy::Network> t(p);
	  t.start();
	  while (p.gettingMap() && i < 5000)
	    usleep(++i);
	  this->GfxMgr_->hide("Connect");
	  this->GfxMgr_->createRealScene();
	}
    }
  return true;
}
示例#3
0
int CLuaManager::executeScriptGlobal(const CEGUI::String& function_name)
{
    int top = lua_gettop(m_luaVM);

    // get the function from lua
    lua_getglobal(m_luaVM, function_name.c_str());

    // is it a function
    if (!lua_isfunction(m_luaVM,-1))
    {
        lua_settop(m_luaVM,top);
        CLog::getInstance()->error("Unable to get Lua global: '%s' as name not represent a global Lua function", function_name.c_str());
        return -1;
    }

    // call it
    int error = lua_pcall(m_luaVM,0,1,0);

    // handle errors
    switch (error) {
        case LUA_ERRRUN:
            lua_settop(m_luaVM,top);
            CLog::getInstance()->error("Runtime error in %s global function", function_name.c_str());
            return -1;
        case LUA_ERRMEM:
            lua_settop(m_luaVM,top);
            CLog::getInstance()->error("Memory alocation error in %s global function", function_name.c_str());
            return -1;
        case LUA_ERRERR:
            lua_settop(m_luaVM,top);
            CLog::getInstance()->error("Error handler error in %s global function", function_name.c_str());
            return -1;
        default:
            break;
    }

    // get return value
    if (!lua_isnumber(m_luaVM,-1))
    {
        // log that return value is invalid. return -1 and move on.
        lua_settop(m_luaVM,top);
        CLog::getInstance()->error("Unable to get Lua global : '%s' return value as it's not a number", function_name.c_str());
        return -1;
    }

    int ret = (int)lua_tonumber(m_luaVM,-1);
    lua_pop(m_luaVM,1);

    // return it
    return ret;
}
示例#4
0
VOID CUIWindowItem::_RegisterControlToScript(CEGUI::Window* pWindow)
{
	//设置UserData,用于回朔调用
	pWindow->setUserData(this);

	//Register Me
	LUA_CONTROL::Window* pTempControl = LUA_CONTROL::Window::CreateControl(pWindow);

	LuaObject objThis = g_pScriptSys->GetLuaState()->BoxPointer(pTempControl);
	objThis.SetMetaTable(*(pTempControl->GetMetaTable()));

	CEGUI::String strTemp = pWindow->getName();
	m_pScriptEnv->GetLuaObject()->SetObject(strTemp.c_str(), objThis);
	
	m_vAllControl.push_back(pTempControl);

	//对ActionButton特殊处理
	if(pWindow->testClassName((CEGUI::utf8*)"FalagardActionButton"))
	{
		CEGUI::IFalagardActionButton* pActionButton = (CEGUI::IFalagardActionButton*)(CEGUI::FalagardActionButton*)pWindow;

		//DrawStarted
		pActionButton->subscribeDragDropStartedEvent(CEGUI::Event::Subscriber(&CUISystem::handleActionDragDropStarted, CUISystem::GetMe()));
		//MouseEnter
		pActionButton->subscribeMouseEnterEvent(CEGUI::Event::Subscriber(&CUISystem::handleActionButtonMouseEnter, CUISystem::GetMe()));
		//MouseLeave
		pActionButton->subscribeMouseLeaveEvent(CEGUI::Event::Subscriber(&CUISystem::handleActionButtonMouseLeave, CUISystem::GetMe()));
		//ParentHidden
		pWindow->subscribeEvent((CEGUI::utf8*)"ParentHidden", CEGUI::Event::Subscriber(&CUISystem::handleActionButtonParentHidden, CUISystem::GetMe()));
	}
	else if(pWindow->testClassName((CEGUI::utf8*)"FalagardMeshWindow"))
	{
		CEGUI::IFalagardMeshWindow* pMeshWindow = (CEGUI::IFalagardMeshWindow*)(CEGUI::FalagardMeshWindow*)pWindow;

		pMeshWindow->subscribeShownEvent(CEGUI::Event::Subscriber(&CUISystem::handleMeshWindowShown, CUISystem::GetMe()));
		pMeshWindow->subscribeHidenEvent(CEGUI::Event::Subscriber(&CUISystem::handleMeshWindowHiden, CUISystem::GetMe()));
	}
	else if(pWindow->testClassName((CEGUI::utf8*)"FalagardComplexWindow"))
	{
		CEGUI::IFalagardComplexWindow* pComplexWindow = (CEGUI::IFalagardComplexWindow*)(CEGUI::FalagardComplexWindow*)pWindow;
		pComplexWindow->subscribInfoItemClickEvent(CEGUI::Event::Subscriber(&CUISystem::handleChatHistoryInfoElementClick, CUISystem::GetMe()));
		pComplexWindow->subscribInfoItemDeleteEvent(CEGUI::Event::Subscriber(&CUISystem::handleElementDelete, CUISystem::GetMe()));
	}
	else if(pWindow->testClassName((CEGUI::utf8*)"FalagardChatHistory"))
	{
		CEGUI::IFalagardChatHistory* pChatHistoryWindow = (CEGUI::IFalagardChatHistory*)(CEGUI::FalagardChatHistory*)pWindow;
		pChatHistoryWindow->subscribInfoItemClickEvent(CEGUI::Event::Subscriber(&CUISystem::handleChatHistoryInfoElementClick, CUISystem::GetMe()));
		pChatHistoryWindow->subscribInfoItemDeleteEvent(CEGUI::Event::Subscriber(&CUISystem::handleElementDelete, CUISystem::GetMe()));
		pChatHistoryWindow->subscribInfoItemMoveInEvent(CEGUI::Event::Subscriber(&CUISystem::handleChatHistoryInfoElementMoveIn, CUISystem::GetMe()));
		pChatHistoryWindow->subscribInfoItemMoveOutEvent(CEGUI::Event::Subscriber(&CUISystem::handleChatHistoryInfoElementMoveOut, CUISystem::GetMe()));
	}

	//Register Child
	for(INT i=0; i<(INT)pWindow->getChildCount(); i++)
	{
		_RegisterControlToScript(pWindow->getChildAtIdx(i));
	}

	return;
}
示例#5
0
void CEGUILuaBindScriptModule::executeScriptFile(const CEGUI::String &filename, const CEGUI::String &resourceGroup)
{
	// load file
	CEGUI::RawDataContainer raw;
	CEGUI::System::getSingleton().getResourceProvider()->loadRawDataContainer(filename,
        raw, resourceGroup.empty() ? d_defaultResourceGroup : resourceGroup);

	lua_State * lua_vm = LuaScript::Instance( ).GetLuaVM( );

	// load code into lua
	int top = lua_gettop( lua_vm );
	int loaderr = luaL_loadbuffer( lua_vm, (char*)raw.getDataPtr(), raw.getSize(), filename.c_str());
	CEGUI::System::getSingleton().getResourceProvider()->unloadRawDataContainer( raw );
	if (loaderr)
	{
		CEGUI::String errMsg = lua_tostring(lua_vm,-1);
		lua_settop(lua_vm,top);
		throw CEGUI::ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
	}

    // call it
	if (lua_pcall(lua_vm,0,0,0))
	{
	    CEGUI::String errMsg = lua_tostring(lua_vm,-1);
		lua_settop(lua_vm,top);
		throw CEGUI::ScriptException("Unable to execute Lua script file: '"+filename+"'\n\n"+errMsg+"\n");
	}

	lua_settop(lua_vm,top); // just in case :P
}
  void SettingComboBox::setValues(const CEGUI::String& value)
  {
    valuesString = value;
    values.clear();

    std::vector<std::string> pairs;
    Tokenize(value.c_str(), pairs, ";");

    std::vector<std::string>::const_iterator it = pairs.begin();
    for (; it != pairs.end(); it++)
    {
      std::vector<std::string> pair;
      Tokenize(*it, pair, ":");

      if (pair.size() != 2)
      {
        printf("E: setValues failed.\n");
        continue;
      }

      std::vector<std::string> vals;
      Tokenize(pair[1], vals, ",");
      values[pair[0]] = vals;
    }

    Update();
  }
bool OnPlayerShopBuyNumChange(const CEGUI::EventArgs& e)
{
	CEGUI::Window* wnd = WEArgs(e).window;
	if(!wnd) return false;

	CEGUI::String buyNum = wnd->getText();
	char str[32] = "";

	CEGUI::Window* goodsWnd = wnd->getParent();
	if (goodsWnd)
	{	
		CGoods* goods = static_cast<CGoods*>(goodsWnd->getUserData());
		if (!goods) return false;

		PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods);
		if (pGoodsItem!=NULL)
		{
			ulong num = atoi(buyNum.c_str());

			if (num>=pGoodsItem->groupNum)
			{
				sprintf(str,"%d",pGoodsItem->groupNum);
			}
			else if (num<=0)
			{
				sprintf(str,"%d",0);
			}
				sprintf(str,"%d",num);
			wnd->setText(ToCEGUIString(str));
			pGoodsItem->readyTradeNum = num;	
		}
	}
	return true;
}
示例#8
0
VOID CUIIconsManager::Initial(VOID)
{
	CEGUI::ImagesetManager&	 theImagesetMng = CEGUI::ImagesetManager::getSingleton();

	//遍历所有的Imageset
	CEGUI::ImagesetManager::ImagesetIterator it = theImagesetMng.getIterator();

	for(it.toStart(); !it.isAtEnd(); it++)
	{
		const CEGUI::String strName = it.getCurrentKey();
		const CEGUI::Imageset* pImageset = it.getCurrentValue();
		const CEGUI::String& strTextureName = pImageset->getTextureFilename();

		if(strTextureName.substr(0, 5) == CEGUI::String("Icons"))
		{
			//遍历Imageset中所有Image
			CEGUI::Imageset::ImageIterator itImage = pImageset->getIterator();
			for(itImage.toStart(); !itImage.isAtEnd(); itImage++)
			{
				const CEGUI::String strImageName = itImage.getCurrentKey();
				const CEGUI::Image* pImage = &(itImage.getCurrentValue());

				m_mapAllIcons.insert(std::make_pair(strImageName.c_str(), pImageset));
			}
		}
	}
}
示例#9
0
void SampleDataModule::getSampleInstanceFromDLL()
{
//    assert(false && "This doesn't work in emscripten");
/*    CEGUI::DynamicModule* sampleModule = new CEGUI::DynamicModule(d_name);
    getSampleInstance functionPointerGetSample = (getSampleInstance)sampleModule->getSymbolAddress(CEGUI::String(GetSampleInstanceFuncName));

    if(functionPointerGetSample == 0)
    {
        CEGUI::String errorMessage = "The sample creation function is not defined in the dynamic library of " + d_name;
        CEGUI_THROW(CEGUI::InvalidRequestException(errorMessage.c_str()));
    }

    d_sample =  &(functionPointerGetSample());*/

	SAMPLE_CASE( HelloWorldDemo );
	SAMPLE_CASE( LookNFeelOverviewDemo );
	SAMPLE_CASE( GameMenuDemo );
	SAMPLE_CASE( HUDDemo );
	SAMPLE_CASE( DragDropDemo );
	SAMPLE_CASE( InventoryDemo );
	SAMPLE_CASE( EffectsDemo );
	SAMPLE_CASE( FontDemo );
	SAMPLE_CASE( Demo6 );
	SAMPLE_CASE( EditboxValidationDemo );
	SAMPLE_CASE( Minesweeper );
	SAMPLE_CASE( ScrollablePaneDemo );
	SAMPLE_CASE( TabControlDemo );
	SAMPLE_CASE( WidgetDemo );
	SAMPLE_CASE( TextDemo );
	SAMPLE_CASE( TreeDemo );

        CEGUI::String errorMessage = "Could not find sample " + d_name;
        CEGUI_THROW(CEGUI::InvalidRequestException(errorMessage.c_str()));
} 
bool OnPlayerShopShowGoodsInfo(const CEGUI::EventArgs& e)
{
	CEGUI::Window* wnd = WEArgs(e).window;
	if(!wnd) return false;

	CGoods* goods = static_cast<CGoods*>(wnd->getUserData());
	if (!goods) return false;

	CEGUI::DefaultWindow* iconWnd = WDefaultWindow(GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Icon"));
	CEGUI::Window* nameWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Name");
	CEGUI::Window* oneGroupNumWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/OneGroupNum");
	CEGUI::Window* priceWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/Price");
	CEGUI::Window* averagePriceWnd = GetWndMgr().getWindow("PlayerShop/backgrond/GoodsInfo/AveragePrice");
	if (!iconWnd || !nameWnd || !oneGroupNumWnd || !priceWnd || !averagePriceWnd)
		return false;

	char tempText[256];
	char strImageFilePath[128] = "";
	char strImageFileName[128] = "";

	PlayerShop::tagGoodsItem* pGoodsItem = GetPlayerShop().FindtagGoods(goods);
	if (pGoodsItem!=NULL)
	{
		// 物品名字
		DWORD dwNameSize = (DWORD)strlen(pGoodsItem->strGoodsName.c_str());
		if (dwNameSize>20)
		{
			_snprintf(tempText,21,"%s", pGoodsItem->strGoodsName.c_str());
			sprintf((tempText+20),"...");
		}else
			sprintf(tempText,"%s", pGoodsItem->strGoodsName.c_str());
		nameWnd->setText(ToCEGUIString(tempText));

		// 物品图片
		const char *strIconPath = GetGame()->GetPicList()->GetPicFilePathName(CPicList::PT_GOODS_ICON, pGoodsItem->goodsIconId);
		GetFilePath(strIconPath,strImageFilePath);
		GetFileName(strIconPath,strImageFileName);
		CEGUI::String strImagesetName = "GoodIcon/";
		strImagesetName += strImageFileName;
		SetBackGroundImage(iconWnd,strImagesetName.c_str(),strImageFilePath,strImageFileName);

		// 物品单组个数
		sprintf(tempText,"%d",pGoodsItem->oneGroupNum);
		oneGroupNumWnd->setText(ToCEGUIString(tempText));

		// 物品售价
		sprintf(tempText,"%d", pGoodsItem->price);
		priceWnd->setText(ToCEGUIString(tempText));

		// 物品单个均价
		char strGoodsPrice[64] = "",strNumLen[64] = "";
		sprintf(strNumLen,"%d",pGoodsItem->price/pGoodsItem->oneGroupNum);
		float fPrice = static_cast<float>(pGoodsItem->price)/static_cast<float>(pGoodsItem->oneGroupNum);
		sprintf(strGoodsPrice,"%*.2f",(int)strlen(strNumLen)+2,fPrice);
		averagePriceWnd->setText(ToCEGUIString(strGoodsPrice));
	}

	return true;
}
示例#11
0
float GameState::ParseText(CEGUI::String ToParse)
{
	
	float returnval = std::stof(ToParse.c_str());;

	
	return returnval;
}
示例#12
0
void CEGUILuaBindScriptModule::executeString(const CEGUI::String &str)
{
	lua_State * d_state = LuaScript::Instance( ).GetLuaVM( );

	int top = lua_gettop(d_state);

    // load code into lua and call it
    int error =	luaL_loadbuffer(d_state, str.c_str(), str.length(), str.c_str()) || lua_pcall(d_state,0,0,0);

    // handle errors
    if (error)
    {
		CEGUI::String errMsg = lua_tostring(d_state,-1);
        lua_settop(d_state,top);
		throw CEGUI::ScriptException("Unable to execute Lua script string: '"+str+"'\n\n"+errMsg+"\n");
    }
}
示例#13
0
void cOverworld :: elementEnd( const CEGUI::String &element )
{
	if( element == "property" || element == "Property" )
	{
		return;
	}

	if( element == "information" )
	{
		m_engine_version = m_xml_attributes.getValueAsInteger( "engine_version" );
		m_last_saved = string_to_int64( m_xml_attributes.getValueAsString( "save_time" ).c_str() );
	}
	else if( element == "settings" )
	{
		// Author
		//author = m_xml_attributes.getValueAsString( "author" ).c_str();
		// Version
		//version = m_xml_attributes.getValueAsString( "version" ).c_str();
		// Music
		m_musicfile = xml_string_to_string( m_xml_attributes.getValueAsString( "music" ).c_str() );
		// Camera Limits
		//pOverworld_Manager->camera->Set_Limits( GL_rect( static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_x" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_y" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_w" )), static_cast<float>(m_xml_attributes.getValueAsInteger( "cam_limit_h" )) ) );
	}
	else if( element == "player" )
	{
		// Start Waypoint
		m_player_start_waypoint = m_xml_attributes.getValueAsInteger( "waypoint" );
		// Moving State
		m_player_moving_state = static_cast<Moving_state>(m_xml_attributes.getValueAsInteger( "moving_state" ));
	}
	else if( element == "background" )
	{
		m_background_color = Color( static_cast<Uint8>(m_xml_attributes.getValueAsInteger( "color_red" )), m_xml_attributes.getValueAsInteger( "color_green" ), m_xml_attributes.getValueAsInteger( "color_blue" ) );
	}
	else
	{
		// get World object
		cSprite *object = Create_World_Object_From_XML( element, m_xml_attributes, m_engine_version, m_sprite_manager, this );
		
		// valid
		if( object )
		{
			m_sprite_manager->Add( object );
		}
		else if( element == "overworld" )
		{
			// ignore
		}
		else if( element.length() )
		{
			printf( "Warning : Overworld Unknown element : %s\n", element.c_str() );
		}
	}

	// clear
	m_xml_attributes = CEGUI::XMLAttributes();
}
示例#14
0
void CUIEditorView::deleteSelectedWindow(void)
{
	if(m_pSelectedWindow)
	{
		CEGUI::String szDelName = m_pSelectedWindow->getName();
		g_DataPool.OnDeleteWindow(szDelName.c_str());
		setWindowSelected("");
		CEGUI::WindowManager::getSingleton().destroyWindow(szDelName);
	}
}
int FalconScriptingModule::executeScriptGlobal(const CEGUI::String& function_name)
{
    Falcon::Item* func = d_vm->findGlobalItem(Falcon::String(function_name.c_str()));
    if(func != NULL && func->isCallable()) {
        d_vm->callItem(*func, 0);
        d_vm->reset();
        Falcon::Item& ret = d_vm->regA();
        return ret.forceInteger();
    }
    return 0;
}
示例#16
0
void CGUIElement_Impl::FillProperties ( void )
{
	CEGUI::Window::PropertyIterator itPropertySet = ((CEGUI::PropertySet*)m_pWindow)->getIterator ();
	while ( !itPropertySet.isAtEnd () ) {
		CEGUI::String strKey = itPropertySet.getCurrentKey ();
		CEGUI::String strValue = m_pWindow->getProperty ( strKey );

		const char *szKey = strKey.c_str ();
		const char *szValue = strValue.c_str ();

		CGUIProperty* pProperty = new CGUIProperty;
		pProperty->szKey = new char[strlen ( szKey ) + 1];
		pProperty->szValue = new char[strlen ( szValue ) + 1];

		strcpy ( pProperty->szKey, szKey );
		strcpy ( pProperty->szValue, szValue );

		m_Properties.push_back ( pProperty );
		itPropertySet++;
	}
}
bool FalconScriptingModule::executeScriptedEventHandler(const CEGUI::String& handler_name, const CEGUI::EventArgs& e)
{
    Falcon::Item* func = d_vm->findGlobalItem(Falcon::String(handler_name.c_str()));
    if(func != NULL && func->isCallable()) {
        d_vm->pushParam(3);
        d_vm->callItem(*func, 1);
        d_vm->reset();
        Falcon::Item& ret = d_vm->regA();
        return ret.isBoolean() ? ret.asBoolean() : true;
    }
    return false;
}
示例#18
0
bool CLuaManager::executeScriptedEventHandler(const CEGUI::String& handler_name, const CEGUI::EventArgs& e)
{

    // TODO search dots in handler name
    int top = lua_gettop(m_luaVM);
    lua_getglobal(m_luaVM, handler_name.c_str());

    // is it a function
    if (!lua_isfunction(m_luaVM,-1))
    {
        lua_settop(m_luaVM,top);
        CLog::getInstance()->error("Unable to get Lua event handler: '%s' as name not represent a global Lua function", handler_name.c_str());
        return true;
    }

    // TODO push CEGUI::EventArgs as the first parameter
    //tolua_pushusertype(d_state,(void*)&e,"const CEGUI::EventArgs");
    //lua_pushnil(m_luaVM);

    // call it
    //int error = lua_pcall(m_luaVM,1,0,0);
    int error = lua_pcall(m_luaVM,0,0,0);

    // handle errors
    switch (error) {
        case LUA_ERRRUN:
            CLog::getInstance()->error("Runtime error in %s event handler", handler_name.c_str());
            break;
        case LUA_ERRMEM:
            CLog::getInstance()->error("Memory alocation error in %s event handler", handler_name.c_str());
            break;
        case LUA_ERRERR:
            CLog::getInstance()->error("Error handler error in %s event handler", handler_name.c_str());
            break;
        default:
            break;
    }

    return true;
}
示例#19
0
void CLuaManager::executeString(const CEGUI::String& str)
{
    int top = lua_gettop(m_luaVM);

    // load code into lua
    int loaderror =	luaL_loadbuffer(m_luaVM, str.c_str(), str.length(), str.c_str());
    if(loaderror == 0) {
        int error = lua_pcall(m_luaVM,0,0,0);

        // handle errors
        switch (error) {
            case LUA_ERRRUN:
                CLog::getInstance()->error("Runtime error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            case LUA_ERRMEM:
                CLog::getInstance()->error("Memory alocation error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            case LUA_ERRERR:
                CLog::getInstance()->error("Error handler error in string: %s", str.c_str());
                lua_settop(m_luaVM,top);
                break;
            default:
                break;
        }
    } else {
        CLog::getInstance()->error("Unable to load string: %s", str.c_str());
        lua_settop(m_luaVM,top);
    }

}
void FalconScriptingModule::executeScriptFile(const CEGUI::String& filename, const CEGUI::String& resourceGroup)
{
    try {
        Falcon::Runtime rt(d_ml);
        rt.loadFile(filename.c_str());
        d_vm->link(&rt);
    } catch(Falcon::Error* err) {
        Falcon::AutoCString edesc(err->toString());
        std::cerr << edesc.c_str() << std::endl;
        err->decref();
        return;
    }
}
示例#21
0
void SampleDataModule::getSampleInstanceFromDLL()
{
    CEGUI::DynamicModule* sampleModule = new CEGUI::DynamicModule(d_name);
    getSampleInstance functionPointerGetSample = (getSampleInstance)sampleModule->getSymbolAddress(CEGUI::String(GetSampleInstanceFuncName));

    if(functionPointerGetSample == 0)
    {
        CEGUI::String errorMessage = "The sample creation function is not defined in the dynamic library of " + d_name;
        CEGUI_THROW(CEGUI::InvalidRequestException(errorMessage.c_str()));
    }

    d_sample =  &(functionPointerGetSample());
}
示例#22
0
std::string CGUIElement_Impl::GetProperty ( const char *szProperty )
{
    CEGUI::String strValue;
	try
    {
		// Return the string. std::string will copy it
		strValue = m_pWindow->getProperty ( CEGUI::String ( szProperty ) );
	}
    catch ( CEGUI::Exception e )
    {}

    return strValue.c_str ();
}
示例#23
0
void CEGUILogger::logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level)
{
	//just reroute to the Ember logging service
	static std::string cegui("(CEGUI) ");
	if (d_level >= level) {
		switch (level) {
			case CEGUI::Insane:
				Log::slog("CEGUI", Log::VERBOSE) << cegui << message.c_str() << Log::END_MESSAGE;
				break;
			case CEGUI::Informative:
				Log::slog("CEGUI", Log::VERBOSE) << cegui << message.c_str() << Log::END_MESSAGE;
				break;
			case CEGUI::Standard:
				Log::slog("CEGUI", Log::INFO) << cegui << message.c_str() << Log::END_MESSAGE;
				break;
			case CEGUI::Warnings:
				Log::slog("CEGUI", Log::WARNING) << cegui << message.c_str() << Log::END_MESSAGE;
				break;
			case CEGUI::Errors:
				Log::slog("CEGUI", Log::FAILURE) << cegui << message.c_str() << Log::END_MESSAGE;
				break;
		}
	}
}
示例#24
0
bool CUIWindowItem::callbackProperty(CEGUI::Window* window, CEGUI::String& propname, CEGUI::String& propvalue, void* userdata)
{
	if(propname == (CEGUI::utf8*)"Text" && !propvalue.empty())
	{
		//字符串转化
		CEGUI::String32 strUtf32;

		STRING strMbcs;
		CUIStringSystem::utf8_to_mbcs(STRING(propvalue.c_str()), strMbcs);
		CUIStringSystem::GetMe()->ParserString_Runtime(strMbcs, strUtf32);
		propvalue = strUtf32.c_str();
	}

	return true;
}
示例#25
0
std::string CGUIElement_Impl::GetFont ( void )
{
	try
	{
		const CEGUI::Font *pFont = m_pWindow->getFont ();
		if ( pFont )
		{
			// Return the contname. std::string will copy it.
			CEGUI::String strFontName = pFont->getName ();
			return strFontName.c_str ();
		}
	}
	catch ( CEGUI::Exception e ) {}

	return "";
}
示例#26
0
	virtual void 	loadRawDataContainer (const CEGUI::String &filename,
		CEGUI::RawDataContainer &output, const CEGUI::String &resourceGroup)
	{

		ZFile file;
		if (file.Open(filename.c_str()))
		{
			int fn = file.GetSize();
			char *ptr = new char [fn+1];
			file.Read(ptr, fn);
			ptr[fn] = 0;
			output.setData((CEGUI::uint8*)ptr);
			output.setSize(fn);
		}

	}
void CNebula2Logger::logEvent(const CEGUI::String& message, CEGUI::LoggingLevel level)
{
	if (Enable && level <= getLoggingLevel())
		switch (level) 
		{
			case CEGUI::Errors:
				//nKernelServer::Instance()->Error("%s\n", message.c_str()); ///!!! TODO
				//break;
			case CEGUI::Standard:
			case CEGUI::Informative:
			case CEGUI::Insane:
				n_printf("%s\n", message.c_str());
				break;
			default:
				n_error("Unknown CEGUI logging level\n");
        }
}
示例#28
0
void GameConsoleWindow::ParseText(CEGUI::String inMsg)
{
	// I personally like working with std::string. So i'm going to convert it here.
    std::string inString = inMsg.c_str();
 
	if (inString.length() >= 1) // Be sure we got a string longer than 0
	{
		if (inString.at(0) == '/') // Check if the first letter is a 'command'
		{
			std::string::size_type commandEnd = inString.find(" ", 1);
			std::string command = inString.substr(1, commandEnd - 1);
			std::string commandArgs = inString.substr(commandEnd + 1, inString.length() - (commandEnd + 1));
			//convert command to lower case
			for(std::string::size_type i=0; i < command.length(); i++)
			{
				command[i] = tolower(command[i]);
			}
 
			// Begin processing
			
			if (command == "say")
			{
				std::string outString = "You:" + inString; // Append our 'name' to the message we'll display in the list
                OutputText(outString);
			}
			else if (command == "quit")
			{
				// do a /quit 
			}
			else if (command == "help")
			{
				// do a /help
			}
			else
			{
				std::string outString = "<" + inString + "> is an invalid command.";
				(this)->OutputText(outString,CEGUI::Colour(1.0f,0.0f,0.0f)); // With red ANGRY colors!
			}
		} // End if
		else
		{
			(this)->OutputText(inString); // no commands, just output what they wrote
		}
	}
}
示例#29
0
bool OnUpdateLatestBuy(const CEGUI::EventArgs& e)
{
    CEGUI::Window* wnd = WEArgs(e).window;
    //先把图片清掉 ,默认为十个条目
    char name[256] = "";
    for(uint i = 0 ; i < 10 ; ++i)
    {
        sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i);
        CEGUI::Window* temp = wnd->getChild(name);
        if(temp)
        {
            temp->setProperty("Image","");
            OutputDebugStr(temp->getName().c_str());
            OutputDebugStr("\n");
        }
    }

    //由索引关联商城类型
    SCGData::eSCType eCityType = GetShopCityTypeByTabContentSelIndex();
    SCGData* dt = GetInst(ShopCityMsgMgr).GetShopCityGoodsData();
    SCGData::MapSBT10& personal = dt->GetSelfBuyTop10();
    SCGData::VecGDPTA perDTA = personal[eCityType];

    size_t count = perDTA.size();
    for(size_t i = 0 ; i < count ; ++i)
    {
        char name[256] = "";
        sprintf(name,SHOPCITY_LATESTBUY_ITME_NAME_D,i);
        CEGUI::Window* temp = wnd->getChild(name);
        if(temp)
        {
            CGoodsList::tagGoods2* tg2 = CGoodsList::GetProperty(perDTA[i].index);
            if(tg2)
            {
                char imagesetname[256];
                sprintf(imagesetname,GOODS_PREFIXID,tg2->BaseProperty.dwIconId);
                CEGUI::String imagename = CEGUI::PropertyHelper::intToString(tg2->BaseProperty.dwIconId)+".jpg";
                SetBackGroundImage(WGUISheet(temp),imagesetname,GOODS_ICON_PATH,imagename.c_str());
            }
        }
    }
    return true;
}
示例#30
0
int CEGUILuaBindScriptModule::executeScriptGlobal(const CEGUI::String &function_name)
{
	lua_State * d_state = LuaScript::Instance( ).GetLuaVM( );

	int top = lua_gettop(d_state);

    // get the function from lua
    lua_getglobal(d_state, function_name.c_str());

    // is it a function
    if (!lua_isfunction(d_state,-1))
    {
        lua_settop(d_state,top);
		throw CEGUI::ScriptException("Unable to get Lua global: '"+function_name+"' as name not represent a global Lua function" );
    }

    // call it
    int error = lua_pcall(d_state,0,1,0);

    // handle errors
    if (error)
    {
		CEGUI::String errMsg = lua_tostring(d_state,-1);
        lua_pop(d_state,1);
		throw CEGUI::ScriptException("Unable to evaluate Lua global: '"+function_name+"\n\n"+errMsg+"\n");
    }

    // get return value
    if (!lua_isnumber(d_state,-1))
    {
        // log that return value is invalid. return -1 and move on.
        lua_settop(d_state,top);
		CEGUI::ScriptException("Unable to get Lua global : '"+function_name+"' return value as it's not a number" );
        return -1;
    }

    int ret = (int)lua_tonumber(d_state,-1);
    lua_pop(d_state,1);

    // return it
    return ret;
}