Пример #1
0
/* Creating of the options from the script. */
bool DIALOGUE::CreateOptions(){

	// atributes
	std::wstring text;
	Gdiplus::GraphicsPath path;
	// caused changes which will be paired with the options
	std::string state_name;
	std::vector<state_changes> changes; 

	if(!script.FindElem(L"OPTIONS")){
		TermLog("Options tag not found in the Dialogue scene, script.xml file is probably damaged.");
		return false;
	}
	script.IntoElem();

	// Going through the options
	if(!script.FindElem(L"OPTION")){
		script.OutOfElem();
		TermLog("No option to choose found in the dialogue scene.");
		return false;
	}
	else do {
		text = script.GetAttrib(L"text");
		
		line_top -= line_height; // Put the line above the previous
		stat = path.AddString(text.c_str(), -1, fontFamily, Gdiplus::FontStyleBold, text_size, Gdiplus::PointF(0, Gdiplus::REAL(line_top)), &strformat);
			if (stat != 0) StatusLog("GraphicPath.AddString()", stat, false);

		script.IntoElem();

		if(!CheckTests()){
			script.OutOfElem();
			continue;
		}


		// creates the map of state changes
		while(script.FindElem(L"STATECHANGE")){
			state_changes current_changes;
			current_changes.name = wstring2string(script.GetData());
			current_changes.value = atoi((wstring2string(script.GetAttrib(L"value"))).c_str());
			current_changes.replace = atoi((wstring2string(script.GetAttrib(L"replace"))).c_str())  != 0 ? true : false;
			changes.push_back(current_changes);
		}
		
		script.OutOfElem(); // Jumps out of the object

		options.push_back(OPTION(text, &path, changes));
		changes.clear();
		StatusLog("GraphicPath.Reset()", path.Reset(), false);

	} while(script.FindElem(L"OPTION"));

	script.OutOfElem();
	return true;
}
Пример #2
0
 void strutil::toString(const StringBuffer& buffer, std::string& body, CharactorType type) {
   switch(buffer.type) {
   case Utf16:
     switch(type) {
     case Utf8: // utf16 -> utf8
       wstring2utf8(wstring(reinterpret_cast<const wchar_t*>(buffer.buffer)), body);
       return;
     case ShiftJis: // utf16 -> sjis
       wstring2string(wstring(reinterpret_cast<const wchar_t*>(buffer.buffer)), body);
       return;
     default:
       throw InvalidCharactorType(); // wstringにUTF-16以外を入れようとしたらエラー
     }
   case Utf8: 
     switch(type) {
     case Utf8: // utf8 -> utf8
       body = reinterpret_cast<const char*>(buffer.buffer);
       return;
       return;
     case ShiftJis: // utf8 -> sjis
       {
         wstring ws;
         utf8towstring(reinterpret_cast<const unsigned char*>(buffer.buffer), strlen(reinterpret_cast<const char*>(buffer.buffer)), ws);
         wstring2string(ws, body);
       }
     default:
       throw InvalidCharactorType(); // wstringにUTF-16以外を入れようとしたらエラー
     }
   case ShiftJis:
     switch(type) {
     case Utf8: // sjis -> utf8
       {
         wstring ws;
         char2wstring(reinterpret_cast<const char*>(buffer.buffer), ws);
         wstring2utf8(ws, body);
         return;
         return;
       }
     case ShiftJis: // sjis -> sjis
       body = reinterpret_cast<const char*>(buffer.buffer);
       return;
     default:
       throw InvalidCharactorType(); // wstringにUTF-16以外を入れようとしたらエラー
     }
   default:
     throw InvalidCharactorType(); //
   }
 }
Пример #3
0
std::string getCellMLMetadataAsRDFXMLString(const char* mbrurl)
{
    std::string s;

    // Get the URL from which to load the model
    if (!mbrurl) return(s);
    std::wstring URL = string2wstring(mbrurl);

    RETURN_INTO_OBJREF(cb, iface::cellml_api::CellMLBootstrap, CreateCellMLBootstrap());
    RETURN_INTO_OBJREF(ml, iface::cellml_api::ModelLoader, cb->modelLoader());
    // Try and load the CellML model from the URL
    try
    {
        RETURN_INTO_OBJREF(model, iface::cellml_api::Model, ml->loadFromURL(URL.c_str()));
        RETURN_INTO_OBJREF(rr, iface::cellml_api::RDFRepresentation,
                           model->getRDFRepresentation(L"http://www.cellml.org/RDFXML/string"));
        if (rr)
        {
            DECLARE_QUERY_INTERFACE(rrs,rr,cellml_api::RDFXMLStringRepresentation);
            std::wstring rdf = rrs->serialisedData();
            s = wstring2string(rdf.c_str());
        }
    }
    catch (...)
    {
        std::cerr << "getCellMLMetadataAsRDFXMLString: Error loading model URL: " << mbrurl << std::endl;
        return(s);
    }
    return(s);
}
Пример #4
0
void ofxBerkelium::onScriptAlert(Berkelium::Window *win, Berkelium::WideString message,
						   Berkelium::WideString defaultValue, Berkelium::URLString url,
						   int flags, bool &success, Berkelium::WideString &value) {
	status = wstring2string( message.data() );
	if(listener) listener->onScriptAlert(message.data(), defaultValue.data(), url.data(),
										 flags, success, value.data());
}
Пример #5
0
void cParty::talkToAll( std::wstring& s, COLOR color )
{
	std::string m;
	wstring2string( s, m );
	
	std::vector<P_PARTY_MEMBER>::iterator iter( members.begin() ), end( members.end() );
	for ( ; iter!=end; ++iter ) {
		pChar pc = cSerializable::findCharBySerial( (*iter)->serial );
		if( pc ) {
			pClient ps = pc->getClient();
			if(ps)
				ps->sysmessage( color, (char*)m.c_str() );
		}
	}
}
Пример #6
0
std::string  get_exe_dir(std::string argv0)
{
	std::vector<char> Filename;
	Filename.resize(_MAX_FNAME);

	GetModuleFileName(NULL, &Filename[0], _MAX_FNAME);

	CLSID clsid;
	CLSIDFromProgID(CComBSTR("Scripting.FileSystemObject"), &clsid);
	void *p;
	CoCreateInstance(clsid, 0, CLSCTX_INPROC_SERVER, __uuidof(IDispatch), &p);
	CComPtr<IDispatch> disp(static_cast<IDispatch*>(p));
	CComDispatchDriver dd(disp);
	CComVariant arg(Filename.data());
	CComVariant ret("");
	dd.Invoke1(CComBSTR("GetParentFolderName"), &arg, &ret);
	return wstring2string(ret.bstrVal);
}
Пример #7
0
AVSINLINE const CStringA Encoding::unicode2ansi  (const CStringW &sLine)
{
	return wstring2string( sLine, CP_ACP );
}
Пример #8
0
AVSINLINE const CStringA Encoding::utf82ansi     (const CStringA &sLine)
{
	return wstring2string( string2wstring( sLine, CP_UTF8 ), CP_ACP );
}
void CSisCertificateChain::LoadText (const std::wstring& aName)
{
    char *fName = NULL;
    std::ifstream certFile;
    std::string line;
    std::string buffer;

    certFile.rdbuf()->open(wstring2string (aName).c_str (), std::ios::in);

    if (!certFile.is_open())
    {
        if((fName = Copy2TmpFile(aName.c_str(), CERTFILE)) != NULL)
        {
            certFile.rdbuf()->open(fName, std::ios::in);
        }
    }

    //check if file is successfully opened.
    if(certFile.is_open())
    {
        //reads the file (pem certificate) into the buffer ignoring empty lines.
        while(!certFile.eof())
        {
            getline(certFile,line);
            //ignore blank lines.
            if(line.length())
            {
                buffer.append(line);
                buffer.append("\n");
            }
        }

        certFile.rdbuf()->close();
    }

    else
    {
        CSISException::ThrowIf (1, CSISException::EFileProblem, std::wstring (L"cannot open ") + aName);
    }

    if(fName != NULL)
    {
        DeleteFileA(fName);
        delete fName;
    }

    X509* x509 = NULL;
    BIO* mem = NULL;

    try
    {
        ERR_clear_error();
        //creates a memory BIO and writes the buffer data into it.
        mem = BIO_new(BIO_s_mem());
        BIO_puts(mem , buffer.c_str());
        while(PEM_read_bio_X509 (mem , &x509 ,0 ,NULL) != NULL)
        {
            X509ToBlobAppend (const_cast<CSISBlob&>(iSisCertChain.CertificateData()), x509);
            X509_free (x509);
            x509 = NULL;
        }
        BIO_free(mem);
        mem = NULL;
        if(iSisCertChain.CertificateData().Size() == 0)
            throw 0;
    }

    catch (...)
    {

        if (certFile.rdbuf()->is_open())
        {
            certFile.rdbuf()->close();
        }

        if (x509)
        {
            X509_free (x509);
        }

        if(mem)
        {
            BIO_free(mem);
        }

        iSisCertChain.CertificateData().Dispose ();
        throw CSISException (CSISException::ECrypto, std::wstring (L"Cannot read ") + aName);
    }

}
Пример #10
0
void ofxBerkelium::onTooltipChanged(Berkelium::Window *win, Berkelium::WideString text) {
	status = wstring2string( text.data() );
	if(listener) listener->onTooltipChanged(text.data());
}
Пример #11
0
void ofxBerkelium::onTitleChanged(Berkelium::Window *win, Berkelium::WideString _title) {
	title = wstring2string( _title.data() );
	if(listener) listener->onTitleChanged(_title.data());
}
Пример #12
0
STDMETHODIMP OPCItemIO::WriteVQT(
	/* [in] */ DWORD dwCount,
	/* [size_is][in] */ LPCWSTR *pszItemIDs,
	/* [size_is][in] */ OPCITEMVQT *pItemVQT,
	/* [size_is][size_is][out] */ HRESULT **ppErrors )
{
	boost::mutex::scoped_lock guard( scopeGuard );

	if( pszItemIDs == NULL || pItemVQT == NULL || ppErrors == NULL )
		return E_INVALIDARG;

	*ppErrors = NULL;

	if( dwCount == 0 )
		return E_INVALIDARG;

	*ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount );
	os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount );

	HRESULT res = S_OK;
	address_space::Tag *item = NULL;
	String itemID;
	for( DWORD i = 0; i < dwCount; ++i )
	{
		try
		{
			#if( FRL_CHARACTER == FRL_CHARACTER_UNICODE )
				if( pszItemIDs[i] )
					itemID = pszItemIDs[i];
			#else
				if( pszItemIDs[i] )
					itemID = wstring2string( pszItemIDs[i] );
			#endif
			item = opcAddressSpace::getInstance().getLeaf( itemID );
		}
		catch( frl::Exception& )
		{
			(*ppErrors)[i] = OPC_E_INVALIDITEMID;
			res = S_FALSE;
			continue;
		}

		if( ! item->isWritable() )
		{
			res = S_FALSE;
			(*ppErrors)[i] = OPC_E_BADRIGHTS;
			continue;
		}

		if( pItemVQT[i].vDataValue.vt == VT_EMPTY )
		{
			res = S_FALSE;
			(*ppErrors)[i] = OPC_E_BADTYPE;
			continue;	
		}

		VARIANT tmp;
		::VariantInit( &tmp );
		os::win32::com::Variant::variantCopy( &tmp, &pItemVQT[i].vDataValue );
		(*ppErrors)[i] = ::VariantChangeType( &tmp, &tmp, 0, item->getCanonicalDataType() );
		if( FAILED( (*ppErrors)[i] ) )
		{
			res = S_FALSE;
			continue;
		}
		item->writeFromOPCClient( tmp );

		if( pItemVQT[i].bQualitySpecified )
		{
			item->setQuality( pItemVQT[i].wQuality );
		}

		if( pItemVQT[i].bTimeStampSpecified )
		{
			item->setTimeStamp( pItemVQT[i].ftTimeStamp );
		}
	}
	return res;
}
Пример #13
0
AVSINLINE const CStringA Encoding::unicode2utf8  (const CStringW &sLine)
{
	return wstring2string( sLine, CP_UTF8 );
}
Пример #14
0
bool CParameter::CommandLine (int argc, _TCHAR* argv[])

{
	bool help = argc == 1;
	bool ssl = false;
	unsigned char stage = 0;
	bool bien = argc > 1;
	bool multi = false;

	iSign = true;

	for (int index = 1; index < argc; index++)
		{
 			// WINDOWS ENVIRONMENT : If the underlying platform is WINDOWS then, 
 			// cope up with multiple arguments following the '-' or '/'. 
 			//
 			// LINUX ENVIRONMENT : If the underlying platform is LINUX then, cope 
 			// up with multiple arguments following only the '-'. This restriction 
 			// of not dealing with arguments following '/' is due to the fact that, 
 			// the absolute paths in case of LINUX start with a '/'. So, this could 
 			// be mistaken as an option if we treat anything prefixed by a '/' as 
 			// an option. Hence, this facility is being removed once for all and 
 			// only '-' can(should) be used for specifying an option.
		    if (	   (argv [index][0] == '-')   
#ifndef __LINUX__			
				    || (argv [index][0] == '/')
#endif
			   )
			{
 			int wCharacter = 1;
 			while (argv[index][wCharacter] !='\0')
				{
				switch (argv [index][wCharacter])
					{
				case 'a' :
				case 'A' :
#ifdef _DEBUG
					iDump = true;
#endif
					break;
#ifdef GENERATE_ERRORS
				case 'b' :
				case 'B' :
					{
					for (int offset = wCharacter+1; argv [index] [offset]; offset++)
						{
						switch(argv [index] [offset])
							{
						case 'a' :
						case 'A' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugArrayCount);
							break;
						case 'b' :
						case 'B' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugInsaneBlob);
							break;
						case 'c' :
						case 'C' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugCRCError);
							break;
						case 'e' :
						case 'E' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugBigEndian);
							break;
		
						case 'f' :
						case 'F' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugDuffFieldType);
							break;
						case 'h' :
						case 'H' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugHashError);
							break;
						case 'l' :
						case 'L' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugInvalidLength);
							break;
						case 'm' :
						case 'M' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugMissingField);
							break;
						case 'n' :
						case 'N' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugNegativeLength);
							break;
						case 's' :
						case 'S' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugInsaneString);
							break;
						case 't' :
						case 'T' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBug32As64);
							break;
						case 'u' :
						case 'U' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugUnexpectedField);
							break;
						case 'v' :
						case 'V' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugInvalidValues);
							break;
						case 'x' :
						case 'X' :
							CSISFieldRoot::SetBug (CSISFieldRoot::EBugUnknownField);
							break;
							}
						wCharacter++;
						}
				}
				break;
#endif // GENERATE_ERRORS
				case 'c' :
				case 'C' :
					{
					switch (argv [index][wCharacter+1])
						{
					case 'd' :
					case 'D' :
						if (iAlgorithm != CSISSignatureAlgorithm::EAlgNone)
							{
							multi = true;
							break;
							}
						iAlgorithm = CSISSignatureAlgorithm::EAlgDSA;
						break;
					case 'r' :
					case 'R' :
						if (iAlgorithm != CSISSignatureAlgorithm::EAlgNone)
							{
							multi = true;
							break;
							}
						iAlgorithm = CSISSignatureAlgorithm::EAlgRSA;
						break;
						}
					wCharacter++;
					}
					break;
				case 'h' :
				case 'H' :
				case '?' :
					help = true;
					break;
				case 'i' :
				case 'I' :
					ssl = true;
					break;
				case 'o' :
				case 'O' :
					iReport = true;
					iSign = false;
					break;
				//EC023 additional prarameter added to extract the certificate 
				case 'p' :
				case 'P' :
					iExtractCert = true;
					iSign = false;
					break;
#ifdef GENERATE_ERRORS
				case 'q' :
				case 'Q' :
					CSISFieldRoot::SetBugStart (atoi(wstring2string (&argv [index] [wCharacter+1]).c_str ()));
					wCharacter++;
					break;
				case 'r' :
				case 'R' :
					CSISFieldRoot::SetBugRepeat (atoi (wstring2string (&argv [index] [wCharacter+1]).c_str ()));
					wCharacter++;
					break;
#endif // GENERATE_ERRORS
				case 's' :
				case 'S' :
					iSign = true;
					break;
				case 'u' :
				case 'U' :
					iUnsign = true;
					iSign = false;
					break;
				case 'v' :
				case 'V' :
					iVerbose = true;
					break;
				case 'x' :
				case 'X' :
					{
					for (int offset = wCharacter+1; argv [index][offset]; offset++)
						{
						switch(argv[index][offset])
							{
						case 'c' :
						case 'C' :
							CSISFieldRoot::SetDebugOption (CSISFieldRoot::EDbgControllerChecksum);
							break;
						case 'd' :
						case 'D' :
							CSISFieldRoot::SetDebugOption (CSISFieldRoot::EDbgDataChecksum);
							break;
						case 'w' :
						case 'W' :
							CSISFieldRoot::SetDebugOption (CSISFieldRoot::EDbgCompress);
							break;
						case 'x' :
						case 'X' :
							CSISFieldRoot::SetDebugOption (CSISFieldRoot::EDbgNoCompress);
							break;
							}
						wCharacter++;
						}
					}
					break;
		
				default :
					std::cout << "Unknown switch " << argv [index];
					bien = false;
					break;
					}
				wCharacter++;
				}
			}
		else 
			{
			switch (stage)
				{
			case 0 :
				iSISFileName = argv [index];
				break;
			case 1 :
				iOutput = argv [index];
				break;
			case 2 :
				iCertificate = argv [index];
				break;
			case 3 :
				iKey = argv [index];
				break;
			case 4 :
				iPassPhrase = argv [index];
				break;
			default :
				if (bien)
					{
					std::cout << "Unexpected arguments from  "; //<< std::string (argv [index]) << "." << std::endl;
					HANDLE	hndl;
					DWORD bytesWritten;
					//Get command prompt handle
					hndl = GetStdHandle(STD_OUTPUT_HANDLE);
					WriteConsole(hndl, argv [index], wcslen(argv [index]), &bytesWritten, 0);
					std::cout << "." << std::endl;
					bien = false;
					}
				break;
				}
			stage++;
			}
		}

	if (bien && ! iSign && ! iUnsign && ! iReport && !iExtractCert)
		{
		std::cout << "Nothing to do." << std::endl;
		bien = false;
		}

	if (bien && multi)
		{
		std::cout << "More than one signing algorithm specified." << std::endl;
		bien = false;
		}

	if (bien)
		{
		if (iSign && iUnsign)
			{
			std::cout << "Can't sign and unsign in single operation." << std::endl; 
			bien = false;
			}
		else
			if (iSign || iUnsign || iReport || iExtractCert)
			{
			if (iSISFileName.empty ()) 
				{
				std::cout << "Please name the input file." << std::endl; 
				bien = false;
				}
			else
					if ((! iReport && iOutput.empty ())&& (! iExtractCert && iOutput.empty())) 
				{
				std::cout << "Please name the output file." << std::endl; 
				bien = false;
				}
			}
		}

	if (iVerbose)
		{
		ShowBanner ();
		}

	if (bien && ! iSign && ! iCertificate.empty ())
		{
		std::cout << "A certificate is only used for signing a sis file." << std::endl;
		bien = false;
		}

	if (! bien && ! help)
		{
		std::cout << "Type \"" << "signsis" << " -?\" for command line options." << std::endl;
		}

	if (ssl)
		{
		for (int index = 0; index < (sizeof(openSSLLicenseString)/sizeof(openSSLLicenseString[0])); index++)
			std::cout << openSSLLicenseString [index] << std::endl;
		std::cout << std::endl;
		bien = false;
		}

	if (help)
		{
		std::cout << "Usage: SignSIS [-?] [-c...] [-i] [-o[-p]] [-s] [-u] [-v] input [output [certificate key [passphrase] ] ]" << std::endl << std::endl;
		std::cout << "-? or -h      Output this information" << std::endl;
		std::cout << "-c...         Sign using specific algorithm: -cd for DSA, -cr for RSA" << std::endl;
		std::cout << "-i            Output licence information" << std::endl;
		std::cout << "-o            Report on content of sis file (after any other operation)" << std::endl;
		std::cout << "-p            Extracts the certificates present (This option has to be given along with -o option)"<< std::endl;
		std::cout << "-s            Sign SIS file (requires sis file, certificate, key and passphrase)" << std::endl;
		std::cout << "-u            Remove most recent signature from SIS file" << std::endl;
		std::cout << "-v            Verbose output" << std::endl;
		std::cout << "input         The SIS file to be sign, unsigned or investigated" << std::endl;
		std::cout << "output        The SIS file generated by signing or unsigned" << std::endl;
		std::cout << "certificate   The certificate file used for signing" << std::endl;
		std::cout << "key           The certificate's private key file" << std::endl << std::endl;
		std::cout << "passphrase    The certificate's private key file's passphrase" << std::endl << std::endl;
		std::cout << "You can sign or unsign a file in a single operation." << std::endl;
		std::cout << "You can generate SIS files using MakeSIS v5." << std::endl << std::endl;
		bien = false;
		}

	return bien;
}
Пример #15
0
//--------------------------------------------------------------
void testApp::onTitleChanged(wstring title){
	wcout << "*** onTitleChanged " << title << endl;
	ofSetWindowTitle(wstring2string(title));
	log.push_back("*** onTitleChanged ");
}
Пример #16
0
//--------------------------------------------------------------
void testApp::onConsoleMessage(wstring message, wstring sourceId, int line_no){
	wcout << "*** onConsoleMessage " << message << " from " << sourceId << " line " << line_no << endl;
	log.push_back("*** onConsoleMessage " + wstring2string(message));
}
Пример #17
0
/* Function creates objects from script - first it take names and than it creates path for a region and afterwards the map of state changes. */
bool INTERACTIVE::CreateObjects() {
	// attributes
	std::wstring name;
	std::wstring caption;
	std::string sound_path;
	std::string caption_sound_path;
	bool finish_scene;

	// object's space
	Gdiplus::GraphicsPath boundaries;
	int verticle_count;
	Gdiplus::Point * verticles;
	int x, y;

	// caused changes
	std::string state_name;
	std::vector<state_changes> changes; 

	// control
	bool verticles_OK = true;

	// Tag is not necessary for the editor
	if(!script.FindElem(L"OBJECTS"))
		return true;
	script.IntoElem();

	// Tag is not necessary for the editor
	if(!script.FindElem(L"OBJECT")){
		script.OutOfElem();
		return true;
	}
	else do {
		// atributes reading
		name = script.GetAttrib(L"name");
		caption = script.GetAttrib(L"caption");
		sound_path = wstring2string(script.GetAttrib(L"sound_source"));
		caption_sound_path = wstring2string(script.GetAttrib(L"caption_sound")); 
		verticle_count = atoi((wstring2string(script.GetAttrib(L"v_count"))).c_str());
		if(verticle_count < 3){
			Log("Verticle count in one of the objects is too low");
			verticles_OK = false;
		} 
		finish_scene = (atoi((wstring2string(script.GetAttrib(L"finish_scene"))).c_str())) != 0 ? true : false;
		
		script.IntoElem(); // Jumps into the object

		if(!CheckTests()){
			script.OutOfElem();
			continue;
		}

		// creates verticles for the object polygon
		verticles = new Gdiplus::Point [verticle_count];
		for(int i = 0; i < verticle_count; i++){
			if(!script.FindElem(L"VERTEX")){
				Log("There is not responding count of vertices in one object in script.");
				verticles_OK = false;
			}
			x = atoi((wstring2string(script.GetAttrib(L"x"))).c_str()); 
			y = atoi((wstring2string(script.GetAttrib(L"y"))).c_str()); 
			verticles[i] = Gdiplus::Point(x, y);
			
		}
		if(!verticles_OK){
			delete [] verticles;
			script.OutOfElem();
			continue;
		}
		else{
			boundaries.AddPolygon(verticles, verticle_count);
			delete [] verticles;
		}

		// creates the vector of state changes
		while(script.FindElem(L"STATECHANGE")){
			state_changes current_changes;
			current_changes.name = wstring2string(script.GetData());
			current_changes.value = atoi((wstring2string(script.GetAttrib(L"value"))).c_str());
			current_changes.replace = atoi((wstring2string(script.GetAttrib(L"replace"))).c_str())  != 0 ? true : false;
			changes.push_back(current_changes);
		}
		
		script.OutOfElem(); // Jumps out of the object

		objects.push_back(SCENE_OBJECT(&boundaries, name, caption, sound_path, caption_sound_path, changes, finish_scene));
		boundaries.Reset();
		changes.clear();

	} while(script.FindElem(L"OBJECT"));

	script.OutOfElem();
	return true;
}
Пример #18
0
void MapEditor2D::SaveToTextFile (const char *fn) {
	objectId = 0;
	FILE *F = fopen (fn, "w+");
	string ws = "                   ";

	fputs ("Room\n", F);
	fputs (string("    Size : "+IntToStr (RoomSize.x)+", "+IntToStr (RoomSize.y)+";\n").c_str(), F);
	fputs ("end;\n\n", F);

	// Cameras
	for (int i = 0; i < Cameras.size(); i++) {
		fputs ("Camera\n", F);
		fputs (string("    Id : "+IntToStr(i)+";\n").c_str(), F);
		fputs (string("    Name : \""+wstring2string(Cameras[i]->Name)+"\";\n").c_str(), F);
		fputs (string("    Position : "+IntToStr (Cameras[i]->Position.x)+", "+IntToStr (Cameras[i]->Position.y)+";\n").c_str(), F);
		fputs (string("    Size : "+IntToStr (Cameras[i]->Size.x)+", "+IntToStr (Cameras[i]->Size.y)+";\n").c_str(), F);
		fputs ("end;\n\n", F);
	}

	// Layers
	for (int i = 0; i < Layers.size(); i++) {
		string bVisible = Layers[i]->Visible ? "True" : "False";
		fputs ("Layer\n", F);
		fputs (string("    Id : "+IntToStr(i)+";\n").c_str(), F);
		fputs (string("    Name : \""+Layers[i]->Name+"\";\n").c_str(), F);
		fputs (string("    Visible : "+bVisible+";\n").c_str(), F);
		fputs ("end;\n\n", F);

		for (int j = 0; j < Layers[i]->Objects.size(); j++) {
			Layers[i]->Objects[j]->Id = j;
			Layers[i]->Objects[j]->LayerId = i;
		}
	}

	// Objects
	for (int i = 0; i < Layers.size(); i++) {
		for (int j = 0; j < Layers[i]->Objects.size(); j++) {
			BaseGameObject *Obj = Layers[i]->Objects[j];
			string Type = "";

			if (dynamic_cast<PolygonObject*>(Obj)) Type = "Polygon";
			else if (dynamic_cast<PointObject*>(Obj)) Type = "Point";
			else if (dynamic_cast<LightObject*>(Obj)) Type = "Light";
			else Type = "Sprite";

			fputs (string("Object ("+Type+")\n").c_str(), F);
			fputs (string("    Id : "      +IntToStr(j)+";\n").c_str(), F);
			fputs (string("    Layer : "   +IntToStr(i)+";\n").c_str(), F);
			fputs (string("    Class : \"" +Obj->GameClass+";\"\n").c_str(), F);
			fputs (string("    Position : "+FloatToStr(Obj->Position.x)+", "+FloatToStr(Obj->Position.y)+";\n").c_str(), F);
			fputs (string("    Size : "    +FloatToStr(Obj->Size.x)+", "+FloatToStr(Obj->Size.y)+";\n").c_str(), F);
			fputs (string("    Rotation : "+FloatToStr(Obj->Rotation)+";\n").c_str(), F);

			if (dynamic_cast<PolygonObject*>(Obj))    WritePolygonObjectData ((PolygonObject*) Obj, F);
			else if (dynamic_cast<PointObject*>(Obj)) WritePointObjectData   (  (PointObject*) Obj, F);
			else if (dynamic_cast<LightObject*>(Obj)) WriteLightObjectData   (  (LightObject*) Obj, F);
			else WriteSpriteObjectData (Obj, F);
			//
			WriteMaterialData (Obj, F);
			WritePolygonsData (Obj, F);
			WriteLabelsData   (Obj, F);

			fputs ("end;\n\n", F);
			/*if (dynamic_cast<PolygonObject*>(Obj)) {

			} else {
				
				
				fputs ("end;\n\n", F);
			}*/
		}
	}

	fclose (F);
}
Пример #19
0
void ofxBerkelium::onConsoleMessage(Berkelium::Window *win, Berkelium::WideString message,
							  Berkelium::WideString sourceId, int line_no) {
	status = wstring2string(message.data());
	if(listener) listener->onConsoleMessage(message.data(), sourceId.data(), line_no);
}
Пример #20
0
STDMETHODIMP OPCItemIO::Read(
	/* [in] */ DWORD dwCount,
	/* [size_is][in] */ LPCWSTR *pszItemIDs,
	/* [size_is][in] */ DWORD *pdwMaxAge,
	/* [size_is][size_is][out] */ VARIANT **ppvValues,
	/* [size_is][size_is][out] */ WORD **ppwQualities,
	/* [size_is][size_is][out] */ FILETIME **ppftTimeStamps,
	/* [size_is][size_is][out] */ HRESULT **ppErrors )
{
	boost::mutex::scoped_lock guard( scopeGuard );

	if( pszItemIDs == NULL || pdwMaxAge == NULL ||
		ppvValues == NULL || ppwQualities == NULL ||
		ppftTimeStamps == NULL || ppErrors == NULL )
	{
		return E_INVALIDARG;
	}

	*ppvValues = NULL;
	*ppwQualities = NULL;
	*ppftTimeStamps = NULL;
	*ppErrors = NULL;

	if( dwCount == 0 )
		return E_INVALIDARG;

	*ppvValues = os::win32::com::allocMemory< VARIANT >( dwCount );
	*ppwQualities = os::win32::com::allocMemory< WORD >( dwCount );
	*ppftTimeStamps = os::win32::com::allocMemory< FILETIME >( dwCount );
	*ppErrors = os::win32::com::allocMemory< HRESULT >( dwCount );

	os::win32::com::zeroMemory< VARIANT >( *ppvValues, dwCount );
	os::win32::com::zeroMemory< WORD >( *ppwQualities, dwCount );
	os::win32::com::zeroMemory< FILETIME >( *ppftTimeStamps, dwCount );
	os::win32::com::zeroMemory< HRESULT >( *ppErrors, dwCount );

	HRESULT res = S_OK;
	address_space::Tag *item = NULL;
	String itemID;
	for( DWORD i = 0; i < dwCount; ++i )
	{
		try
		{
			#if( FRL_CHARACTER == FRL_CHARACTER_UNICODE )
				if( pszItemIDs[i] )
					itemID = pszItemIDs[i];
			#else
				if( pszItemIDs[i] )
					itemID = wstring2string( pszItemIDs[i] );
			#endif
			item = opcAddressSpace::getInstance().getLeaf( itemID );
		}
		catch( frl::Exception& )
		{
			(*ppErrors)[i] = OPC_E_INVALIDITEMID;
			res = S_FALSE;
			continue;
		}

		if( ! ( item->isReadable() ) )
		{
			res = S_FALSE;
			(*ppErrors)[i] = OPC_E_BADRIGHTS;
			continue;
		}

		(*ppErrors)[i] = os::win32::com::Variant::variantCopy( (*ppvValues)[i], item->read() );
		if( FAILED( (*ppErrors)[i] ) )
		{
			res = S_FALSE;
			continue;
		}
		(*ppwQualities)[i] = item->getQuality();
		(*ppftTimeStamps)[i] = item->getTimeStamp();
	}
	return res;
}