Exemple #1
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 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());
    }
}
void
VfsResourceProvider::loadRawDataContainer( const CEGUI::String& filename      , 
                                           CEGUI::RawDataContainer& output    , 
                                           const CEGUI::String& resourceGroup )
{GUCEF_TRACE;
    
    // everything in CEGUI works based on resource groups
    // make sure we dont use an empty one
    const CEGUI::String* rscGroup = &resourceGroup;
    if ( resourceGroup.empty() )
    {
        rscGroup = &m_defaultResourceGroup;
    }

    CORE::CString filePath;
    CORE::CString fileName = filename;
    TCEStringMap::iterator i = m_groupMap.find( *rscGroup );
    if ( i != m_groupMap.end() )
    {
        filePath = (*i).second;
    }

    filePath = CORE::CombinePath( filePath, fileName );

    VFS::CVFS& vfs = VFS::CVfsGlobal::Instance()->GetVfs();

    VFS::CVFS::CVFSHandlePtr file = vfs.GetFile( filePath, "rb", false );
    if ( !file.IsNULL() )
    {
        CORE::CIOAccess* fileAccess = file->GetAccess();
        if ( NULL != fileAccess )
        {
            CORE::CDynamicBuffer memBuffer( *fileAccess );
             
            void* buffer = NULL;
            UInt32 dataSize = 0; 
            memBuffer.RelinquishDataOwnership( buffer, dataSize );

            output.setData( (CEGUI::uint8*) buffer );
            output.setSize( dataSize );

            DataContainerInfoPtr info = new TDataContainerInfo;
            info->fileHandle = file;
            info->requestFilename = fileName;
            info->requestresourceGroup = resourceGroup;
            info->ceContainer = output;

            m_containerMap[ buffer ] = info;
        }
        else
        {
            GUCEF_ERROR_LOG( CORE::LOGLEVEL_NORMAL, "VfsResourceProvider:loadRawDataContainer: Unable to load resource from path: " + filePath );
        } 
    }
}
Exemple #4
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;
}
Exemple #5
0
//-----------------------------------------------------------------------
wxString EditorDocument::getDefaultResourceGroupRelativePath( const wxString& filename ) const
{
    wxString resourcePath( wxT( "./" ) );
    wxFileName filespec( filename );

    CEGUI::DefaultResourceProvider* rp =
        static_cast<CEGUI::DefaultResourceProvider*>(
            CEGUI::System::getSingleton().getResourceProvider() );

    CEGUI::String defResGrp = rp->getDefaultResourceGroup();

    if ( !defResGrp.empty() )
        resourcePath = CEGUIHelper::ToWXString(
            rp->getResourceGroupDirectory( defResGrp ) );

    filespec.MakeRelativeTo( resourcePath );
    return filespec.GetFullPath();
}
Exemple #6
0
VOID CUIWindowItem::_TransWindowText(CEGUI::Window* pWindow)
{
	CEGUI::String str = pWindow->getTextOriginal();
	if(!str.empty())
	{
		STRING strMBCS_ToTrans;
		CUIStringSystem::utf8_to_mbcs(str.c_str(), strMBCS_ToTrans);

		// 经过special转化的string,已经是utf32格式。
		CEGUI::String strMBCS_Transed_Done;

		CUIStringSystem::GetMe()->ParserString_Runtime(strMBCS_ToTrans, strMBCS_Transed_Done);

		pWindow->setText(strMBCS_Transed_Done);
	}
	//Register Child
	for(INT i=0; i<(INT)pWindow->getChildCount(); i++)
	{
		_TransWindowText(pWindow->getChildAtIdx(i));
	}
}
Exemple #7
0
bool Dan::textAccepted(const CEGUI::EventArgs&) 
{
	CEGUI::String text = CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText();
	
	std::cout<<CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText()<<std::endl;
	std::cout<<CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText().size()<<std::endl;
	if(text.empty())
		return true;
	if(text.size() != 9)
	{
		_time = 1.0f;
		CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/W")->setProperty("Image","set:UI4 image:w1");
		
	}else
	{	
		if(_callback)
			_callback->uploadPassword(Ogre::StringConverter::parseInt(text.c_str()));
	}
	CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->setText("");
	return true;
}
const CEGUI::String&
ImageCodecAdapter::getSupportedFormat() const
{GUCEF_TRACE;

    IMAGE::CImageCodecRegistry& codecRegistry = IMAGE::CImageGlobal::Instance()->GetImageCodecRegistry();
    
    IMAGE::CImageCodecRegistry::TStringList codecList;
    codecRegistry.GetList( codecList );
    
    static CEGUI::String formatStr;

    formatStr.clear();
    IMAGE::CImageCodecRegistry::TStringList::iterator i = codecList.begin();
    while ( i != codecList.end() )
    {
        if ( !formatStr.empty() )
            formatStr += " ";
        formatStr += (*i).STL_String();
        ++i;
    }
    return formatStr;
}
Exemple #9
0
bool Dan::textAccepted(const CEGUI::EventArgs&) 
{
	if(!check())
		return false;
	
	CodingFormatInterface * format = _coding->queryInterface<CodingFormatInterface>();
	CEGUI::String text = CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->getText();

	if(text.empty())
		return true;
	if(text.size() <= 9)
	{
		this->warning(L"输入未满9位");

	}else
	{	
		format->clear();
		LockInterface * lock = _dataServer->queryInterface<LockInterface>();
		DataServerInterface * data = _dataServer->queryInterface<DataServerInterface>();

		std::string code = lock->getLockCode2();
		format->decode10(code, 60);
		unsigned int oCheck = format->getCheck8(60);


		if(data->loadCodingData())
		{

			CodingFormatInterface * lockData = _dataServer->queryInterface<CodingFormatInterface>();
			unsigned int oId = lockData->getLockID();
			if(format->decode10(std::string(text.c_str()),28))
			{
				if(format->getBackCheck() != oCheck ||format->getBackID() != (oId%128))
				{
					warning(L"开机码和报账码不匹配,请重新报账");
				}else
				{
					lockData->setLockLeavings(format->getBackLeavingsIndex());
					data->saveCodingData();
					unsigned int index = format->getBackLeavingsIndex();
					unsigned int profits = format->index2Profits(index);
					unsigned int levings = data->getLevingsProfits();

					data->setLevingsProfits(levings + profits);
					data->cleanCostBackTimeCode2();
					data->save();
					if(check())
					{
						warning(L"报账成功");
					}
				}

			}
			else
			{
				warning(L"无效开机码");
			}
		}else
			{
				warning(L"内部数据错误,请联系开发商!");
			}
	
	}
	CEGUI::WindowManager::getSingleton().getWindow("Dan/Bg/Text/Putin")->setText("");
	return true;
}