//--------------------------------------------------------------
void testApp::setup(){
  loadFromXML();
  ofEnableAlphaBlending();
  Tweenzor::init();
  //ofBackground(255, 0, 0);
  _receiver.setup(PORT);

  // loops
  _bgLoop.loadMovie("animations/backgroundlogo_dashboard.mov");
  _bgLoop.setLoopState(OF_LOOP_NORMAL);
  _bgLoop.play();

  #ifdef TARGET_LINUX
    _logoLoop.setPixelFormat(OF_PIXELS_BGRA);
  #endif
  _logoLoop.loadMovie("animations/mots/logoballroom_anime.mov");
  _logoLoop.setLoopState(OF_LOOP_NORMAL);
  _logoLoop.play();

  // load digits
  _digits.resize(10);
  for (unsigned int i = 0; i < 10; i++){
    ofImage *image = new ofImage();
    image->loadImage("graphics/numbers_PNG/" + ofToString(i) + ".png");
    _digits[i] = image;
  }
}
示例#2
0
	bool Phy2dWorld::loadFromXMLFile(const char* xmlFile)
	{
		TiXmlDocument doc(xmlFile);
		if (!doc.LoadFile()) 
			return false;

		TiXmlHandle hDoc(&doc);
		
		TiXmlElement* pDocRoot = hDoc.FirstChildElement().Element();
		// should always have a valid root but handle gracefully if it does
		if (!pDocRoot) 
			return false;	

		stringc docRootName=pDocRoot->Value();
		if(docRootName != "FLTResXML")
			return false;

		TiXmlHandle hDocRoot(pDocRoot);
		TiXmlElement* pXMLNodePhy2DWorld = hDocRoot.FirstChild("Phy2DWorld").Element();

		if(pXMLNodePhy2DWorld==0)
			return false;

		bool bLoaded = loadFromXML(pXMLNodePhy2DWorld);

		if(bLoaded)
		{
			m_xmlFileName = xmlFile;			
		}

		return bLoaded;	
	}	
示例#3
0
bool KDReports::Report::loadFromXML( QIODevice* iodevice, ErrorDetails* details )
{
    QDomDocument doc;
    // Read document from the QIODevice, check for errors

    // We need to be able to see the space in <text> </text>, this is why
    // we activate the "report-whitespace-only-CharData" feature.
    // Unfortunately this leads to lots of whitespace text nodes in between real
    // elements in the rest of the document, watch out for that.
    if (iodevice->isOpen())
        iodevice->reset(); //need to do that to allow consecutive calls of loadFromXML()
    QXmlInputSource source( iodevice );
    QXmlSimpleReader reader;
    reader.setFeature( QLatin1String( "http://xml.org/sax/features/namespaces" ), false );
    reader.setFeature( QLatin1String( "http://xml.org/sax/features/namespace-prefixes" ), true );
    reader.setFeature( QLatin1String( "http://trolltech.com/xml/features/report-whitespace-only-CharData" ), true );

    QString errorMsg;
    int errorLine = 0, errorColumn = 0;
    bool ret = doc.setContent( &source, &reader, &errorMsg, &errorLine, &errorColumn );
    if( !ret ) {
        if ( details ) {
            details->setLine( errorLine );
            details->setColumn( errorColumn );
            details->setDriverMessage( errorMsg );
        }
        else
            qWarning( "Malformed XML read in KDReports::Report::loadFromXML(): error message = %s, error line = %d, error column = %d", qPrintable( errorMsg ), errorLine, errorColumn );
        return false;
    }
    return loadFromXML( doc, details );
}
示例#4
0
Character::Character(Sound* sonido,RosalilaGraphics* painter,Receiver* receiver,std::string name)
{
    //Setting up the other variables
    this->name=name;
    this->directory="";
    this->sonido=sonido;
    this->painter=painter;
    this->receiver=receiver;
    this->active_patterns=new std::list<Pattern*>;
    this->x=500;
    this->y=500;
    this->shooting=true;
    this->orientation="idle";
    this->current_type="1";
    this->visible=true;

    //Sprites animation
    this->animation_iteration=0;
    this->current_sprite=0;

    this->life_bar_x=0;
    this->life_bar_y=0;

    this->iteration=0;

    loadFromXML();
}
示例#5
0
Automata::Automata(std::string archivo,std::string archivo_default)
{
    estado_actual="S";
    estados["S"]=new Estado(vector<Transicion*>());
    loadFromXML(archivo,archivo_default);
    transicion_a_recompenzar=NULL;
    wait=0;
}
Card::Card(std::string cardFilename)
{
    filename = std::string(cardFilename);

    // Load the card xml data
    XMLElement *cardData = XMLManager::instance()->parse(cardFilename);
    loadFromXML(cardData);
    delete cardData;
}
示例#7
0
bool Proyecto::load(QString &filename)
{
    if (filename.endsWith(".xml", Qt::CaseInsensitive))
        return loadFromXML(filename);
    else if (filename.endsWith(".pr", Qt::CaseInsensitive))
        return loadFromStream(filename);
    else
        return false;
}
示例#8
0
const Material& MaterialLoader::getMaterial(const std::string &name) {
  auto it = materialCache.find(name);
  if (it != materialCache.end()) {
    return it->second;
  }
  std::string path = /*Environment::getDataDir() + "/textures/" +*/ name;
  Material m = loadFromXML(path);
  auto inserted = materialCache.insert(std::pair<std::string, Material>(m.name, m));
  // Return reference to newly inserted Material
  return inserted.first->second;
}
示例#9
0
void QtTranslationManager::loadTranslationLanguage(const QString & xml) {

	if(xml==""){//VOXOX - CJC - 2010.01.28 Load the file locally. 
	
		Config & config = ConfigManager::getInstance().getCurrentConfig();
		QString resource = QString::fromStdString(config.getResourcesDir());
		resource = resource.replace("\\","/");
		loadFromFile(resource + QString("chat/translation/translations.xml"));

	}else{
		loadFromXML(xml);
	}
}
示例#10
0
Settings Settings::loadFromXML(const std::string& filename,
                               const std::string& accountName)
{
    ofxXmlSettings XML;

    if(XML.loadFile(filename))
    {
        XML.pushTag("accounts");
        return loadFromXML(XML,accountName);
    }
    else
    {
        ofLogError("Settings::loadFromXML") << "Unable to load XML from " << filename << XML.doc.ErrorDesc() << ".  Loading defaults.";
        return Settings();
    }
}
Character::Character(Sound* sonido,RosalilaGraphics* painter,Receiver* receiver,std::string name,int sound_channel_base)
{
    //Setting up the other variables
    this->name=name;
    this->directory="";
    this->sonido=sonido;
    this->painter=painter;
    this->receiver=receiver;
    this->active_patterns=new std::list<Pattern*>;
    this->x=500;
    this->y=500;
    this->shooting=true;
    this->orientation="idle";
    this->current_type="1";
    this->visible=true;

    //Sprites animation
    this->animation_iteration=0;
    this->current_sprite=0;

    this->life_bar_x=0;
    this->life_bar_y=0;

    this->iteration=0;

    //Color effect
    current_color_effect_r=255;
    current_color_effect_g=255;
    current_color_effect_b=255;
    current_color_effect_a=255;

    //Shake
    current_screen_shake_x=0;
    current_screen_shake_y=0;
    shake_time=0;
    shake_magnitude=0;

    this->sound_channel_base=sound_channel_base;

    //Flat Shadow
    flat_shadow_texture = NULL;

    loadFromXML();
}
示例#12
0
Enemy::Enemy(Sound* sonido,RosalilaGraphics* painter,Receiver* receiver,std::string name,Player*player)
{
    //Setting up the other variables
    this->name=name;
    this->directory="stages/"+name+"/Enemy/";
    this->sonido=sonido;
    this->painter=painter;
    this->receiver=receiver;
    this->player=player;
    this->active_patterns=new std::list<Pattern*>;
    this->shooting=true;
    this->orientation="idle";
    this->current_type="";
    this->visible=true;

    //Enemy variables
    this->angle=180;
    this->velocity=0;
    this->angle_change=0;


    //Sprites animation
    this->animation_velocity=4;
    this->animation_iteration=0;
    this->current_sprite=0;

    this->iteration=0;

    this->score_upload_message="";
    bool flag_begin_upload=false;

    loadFromXML();

    loadModifiersFromXML();
    life_bar=painter->getTexture(assets_directory+directory+"life_bar.png");
}
Card::Card(XMLElement *cardData)
{
    filename = "";

    loadFromXML(cardData);
}
示例#14
0
void Player::loadPlayerFromXML()
{
    loadFromXML();

    //Loading file
    std::string main_path=assets_directory+directory+"main.xml";
    TiXmlDocument doc_t(main_path.c_str());
    doc_t.LoadFile();
    TiXmlDocument *doc;
    doc=&doc_t;
    TiXmlNode *main_file=doc->FirstChild("MainFile");

    this->current_slow=0;
    this->max_slow=-1;
    TiXmlElement *attributes=main_file->FirstChild("Attributes")->ToElement();
    if(attributes->Attribute("slow")!=NULL)
    {
        this->current_slow=atoi(attributes->Attribute("slow"));
        this->max_slow=atoi(attributes->Attribute("slow"));
    }

    this->slow_decrement=3;
    if(attributes->Attribute("slow_decrement")!=NULL)
    {
        this->slow_decrement=atoi(attributes->Attribute("slow_decrement"));
    }

    this->slow_increment=1;
    if(attributes->Attribute("slow_increment")!=NULL)
    {
        this->slow_increment=atoi(attributes->Attribute("slow_increment"));
    }

    this->slow_cooldown_increment=2;
    if(attributes->Attribute("slow_cooldown_increment")!=NULL)
    {
        this->slow_cooldown_increment=atoi(attributes->Attribute("slow_cooldown_increment"));
    }

    this->slow_bar_x=0;
    this->slow_bar_y=0;
    this->slow_bar_rect_offset_x=0;
    this->slow_bar_rect_offset_y=0;
    this->slow_bar_rect_height=0;
    this->slow_bar_rect_width=0;
    this->slow_bar_color.red=0;
    this->slow_bar_color.green=0;
    this->slow_bar_color.blue=0;
    this->slow_bar_color.alpha=255;
    this->slow_bar_cooldown_color.red=0;
    this->slow_bar_cooldown_color.green=0;
    this->slow_bar_cooldown_color.blue=0;
    this->slow_bar_cooldown_color.alpha=128;

    if(main_file->FirstChild("SlowBar")!=NULL)
    {
        TiXmlElement *slow_bar=main_file->FirstChild("SlowBar")->ToElement();
        if(slow_bar->Attribute("x")!=NULL)
            this->slow_bar_x=atoi(slow_bar->Attribute("x"));
        if(slow_bar->Attribute("y")!=NULL)

            this->slow_bar_y=atoi(slow_bar->Attribute("y"));
        if(slow_bar->Attribute("color_r")!=NULL)
            this->slow_bar_color.red=atoi(slow_bar->Attribute("color_r"));
        if(slow_bar->Attribute("color_g")!=NULL)
            this->slow_bar_color.green=atoi(slow_bar->Attribute("color_g"));
        if(slow_bar->Attribute("color_b")!=NULL)
            this->slow_bar_color.blue=atoi(slow_bar->Attribute("color_b"));
        if(slow_bar->Attribute("color_a")!=NULL)
            this->slow_bar_color.alpha=atoi(slow_bar->Attribute("color_a"));

        if(slow_bar->Attribute("cooldown_color_r")!=NULL)
            this->slow_bar_cooldown_color.red=atoi(slow_bar->Attribute("cooldown_color_r"));
        if(slow_bar->Attribute("cooldown_color_g")!=NULL)
            this->slow_bar_cooldown_color.green=atoi(slow_bar->Attribute("cooldown_color_g"));
        if(slow_bar->Attribute("cooldown_color_b")!=NULL)
            this->slow_bar_cooldown_color.blue=atoi(slow_bar->Attribute("cooldown_color_b"));
        if(slow_bar->Attribute("cooldown_color_a")!=NULL)
            this->slow_bar_cooldown_color.alpha=atoi(slow_bar->Attribute("cooldown_color_a"));

        if(slow_bar->Attribute("rect_offset_x")!=NULL)
            this->slow_bar_rect_offset_x=atoi(slow_bar->Attribute("rect_offset_x"));
        if(slow_bar->Attribute("rect_offset_y")!=NULL)
            this->slow_bar_rect_offset_y=atoi(slow_bar->Attribute("rect_offset_y"));
        if(slow_bar->Attribute("rect_height")!=NULL)
            this->slow_bar_rect_height=atoi(slow_bar->Attribute("rect_height"));
        if(slow_bar->Attribute("rect_width")!=NULL)
            this->slow_bar_rect_width=atoi(slow_bar->Attribute("rect_width"));
    }
}
示例#15
0
SandwichData::SandwichData( tinyxml2::XMLElement* xmlElement, m2g::GraphicsLibrary& graphicsLibrary )
{
    loadFromXML( xmlElement, graphicsLibrary );
}
示例#16
0
void ofxRemoteUIServer::updateServer(float dt){

	timeCounter += dt;
	broadcastTime += dt;
	timeSinceLastReply  += dt;

	if(readyToSend){
		if (timeCounter > updateInterval){
			timeCounter = 0.0f;
			//vector<string> changes = scanForUpdatedParamsAndSync(); //sends changed params to client
			//cout << "ofxRemoteUIServer: sent " << ofToString(changes.size()) << " updates to client" << endl;
			//sendUpdateForParamsInList(changes);
		}
	}

	//let everyone know I exist and which is my port, every now and then
	if(broadcastTime > OFXREMOTEUI_BORADCAST_INTERVAL){
		if(doBroadcast){
			broadcastTime = 0.0f;
			if (computerName.size() == 0){
				#ifdef OF_AVAILABLE
					Poco::Environment e;
					computerName = e.nodeName();

					char pathbuf[2048];
					uint32_t  bufsize = sizeof(pathbuf);
					#ifdef TARGET_OSX
						_NSGetExecutablePath(pathbuf, &bufsize);
						Poco::Path p = Poco::Path(pathbuf);
						binaryName = p[p.depth()];
					#endif
					#ifdef TARGET_WIN32						
						GetModuleFileNameA( NULL, pathbuf, bufsize ); //no iea why, but GetModuleFileName() is not defined?
						Poco::Path p = Poco::Path(pathbuf);
						binaryName = p[p.depth()];
					#endif
				#endif
			}
			ofxOscMessage m;
			m.addIntArg(port); //0
			m.addStringArg(computerName); //1
			m.addStringArg(binaryName);	//2
			broadcastSender.sendMessage(m);
		}
	}

	while( oscReceiver.hasWaitingMessages() ){// check for waiting messages from client

		ofxOscMessage m;
		oscReceiver.getNextMessage(&m);
		if (!readyToSend){ // if not connected, connect to our friend so we can talk back
			connect(m.getRemoteIp(), port + 1);
		}

		DecodedMessage dm = decode(m);
		RemoteUIServerCallBackArg cbArg; // to notify our "delegate"
		cbArg.host = m.getRemoteIp();
		switch (dm.action) {

			case HELO_ACTION: //if client says hi, say hi back
				sendHELLO();
				if(callBack != NULL){
					cbArg.action = CLIENT_CONNECTED;
					callBack(cbArg);
				}
				if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says HELLO!"  << endl;
				onScreenNotifications.addNotification("CONNECTED (" + cbArg.host +  ")!");
				break;

			case REQUEST_ACTION:{ //send all params to client
				if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends REQU!"  << endl;
				vector<string>paramsList = getAllParamNamesList();
				syncAllParamsToPointers();
				sendUpdateForParamsInList(paramsList);
				sendREQU(true); //once all send, confirm to close the REQU
			}
				break;

			case SEND_PARAM_ACTION:{ //client is sending us an updated val
				if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " sends SEND!"  << endl;
				updateParamFromDecodedMessage(m, dm);
				if(callBack != NULL){
					cbArg.action = CLIENT_UPDATED_PARAM;
					cbArg.paramName = dm.paramName;
					cbArg.param = params[dm.paramName];  //copy the updated param to the callbakc arg
					callBack(cbArg);
				}
			}
				break;

			case CIAO_ACTION:{
				if(verbose_) cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says CIAO!" << endl;
				sendCIAO();
				onScreenNotifications.addNotification("DISCONNECTED (" + cbArg.host +  ")!");
				if(callBack != NULL){
					cbArg.action = CLIENT_DISCONNECTED;
					callBack(cbArg);
				}
				clearOscReceiverMsgQueue();
				readyToSend = false;
			}break;

			case TEST_ACTION: // we got a request from client, lets bounce back asap.
				sendTEST();
				//if(verbose)cout << "ofxRemoteUIServer: " << m.getRemoteIp() << " says TEST!" << endl;
				break;

			case PRESET_LIST_ACTION: //client wants us to send a list of all available presets
				presetNames = getAvailablePresets();
				if (presetNames.size() == 0){
					presetNames.push_back(OFXREMOTEUI_NO_PRESETS);
				}
				sendPREL(presetNames);
				break;

			case SET_PRESET_ACTION:{ // client wants to set a preset
				//presetNames = getAvailablePresets();
				string presetName = m.getArgAsString(0);
				vector<string> missingParams = loadFromXML(string(OFXREMOTEUI_PRESET_DIR) + "/" + presetName + ".xml");
				if(verbose_) cout << "ofxRemoteUIServer: setting preset: " << presetName << endl;
				sendSETP(presetName);
				sendMISP(missingParams);
				if(callBack != NULL){
					cbArg.action = CLIENT_DID_SET_PRESET;
					cbArg.msg = presetName;
					callBack(cbArg);
				}
				onScreenNotifications.addNotification("SET PRESET to '" + string(OFXREMOTEUI_PRESET_DIR) + "/" + presetName + ".xml'");
			}break;

			case SAVE_PRESET_ACTION:{ //client wants to save current xml as a new preset
				string presetName = m.getArgAsString(0);
				if(verbose_) cout << "ofxRemoteUIServer: saving NEW preset: " << presetName << endl;
				saveToXML(string(OFXREMOTEUI_PRESET_DIR) + "/" + presetName + ".xml");
				sendSAVP(presetName);
				onScreenNotifications.addNotification("SAVED PRESET to '" + string(OFXREMOTEUI_PRESET_DIR) + "/" + presetName + ".xml'");
				if(callBack != NULL){
					cbArg.action = CLIENT_SAVED_PRESET;
					cbArg.msg = presetName;
					callBack(cbArg);
				}
			}break;

			case DELETE_PRESET_ACTION:{
				string presetName = m.getArgAsString(0);
				if(verbose_) cout << "ofxRemoteUIServer: DELETE preset: " << presetName << endl;
				deletePreset(presetName);
				sendDELP(presetName);
				onScreenNotifications.addNotification("DELETED PRESET '" + string(OFXREMOTEUI_PRESET_DIR) + "/" + presetName + ".xml'");
				if(callBack != NULL){
					cbArg.action = CLIENT_DELETED_PRESET;
					cbArg.msg = presetName;
					callBack(cbArg);
				}
			}break;

			case SAVE_CURRENT_STATE_ACTION:{
				if(verbose_) cout << "ofxRemoteUIServer: SAVE CURRENT PARAMS TO DEFAULT XML: " << endl;
				saveToXML(OFXREMOTEUI_SETTINGS_FILENAME);
				onScreenNotifications.addNotification("SAVED CONFIG to default XML");
				sendSAVE(true);
				if(callBack != NULL){
					cbArg.action = CLIENT_SAVED_STATE;
					callBack(cbArg);
				}
			}break;

			case RESET_TO_XML_ACTION:{
				if(verbose_) cout << "ofxRemoteUIServer: RESET TO XML: " << endl;
				restoreAllParamsToInitialXML();
				sendRESX(true);
				onScreenNotifications.addNotification("RESET CONFIG TO SERVER-LAUNCH XML values");
				if(callBack != NULL){
					cbArg.action = CLIENT_DID_RESET_TO_XML;
					callBack(cbArg);
				}
			}break;

			case RESET_TO_DEFAULTS_ACTION:{
				if(verbose_) cout << "ofxRemoteUIServer: RESET TO DEFAULTS: " << endl;
				restoreAllParamsToDefaultValues();
				sendRESD(true);
				onScreenNotifications.addNotification("RESET CONFIG TO DEFAULTS (source defined values)");
				if(callBack != NULL){
					cbArg.action = CLIENT_DID_RESET_TO_DEFAULTS;
					callBack(cbArg);
				}
			}break;

			default: cout << "ofxRemoteUIServer::update >> ERR!" <<endl; break;
		}
	}
}