void UIButton::press() { applyEvent("Press"); if (_listenerObject) { _listenerObject->listen(_listenerParamObject, _listenerParamDWORD); } if (_parentNotify && _parent) { _parent->applyEvent(getName()); } _oneTimePress = false; }
bool BaseObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); setSoundEvent(nullptr); } } if (_sFX) { updateOneSound(_sFX); } return STATUS_OK; }
////////////////////////////////////////////////////////////////////////// // IWmeObject ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::sendEvent(const char *eventName) { return DID_SUCCEED(applyEvent(eventName)); }
////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "DEBUG_CrashMe") == 0) { stack->correctParams(0); byte *p = 0; *p = 10; stack->pushNULL(); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // ApplyEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ApplyEvent") == 0) { stack->correctParams(1); ScValue *val = stack->pop(); bool ret; ret = applyEvent(val->getString()); if (DID_SUCCEED(ret)) { stack->pushBool(true); } else { stack->pushBool(false); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // CanHandleEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleEvent") == 0) { stack->correctParams(1); stack->pushBool(canHandleEvent(stack->pop()->getString())); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // CanHandleMethod ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CanHandleMethod") == 0) { stack->correctParams(1); stack->pushBool(canHandleMethod(stack->pop()->getString())); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // AttachScript ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AttachScript") == 0) { stack->correctParams(1); stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // DetachScript ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DetachScript") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); bool killThreads = stack->pop()->getBool(false); bool ret = false; for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { _scripts[i]->finish(killThreads); ret = true; break; } } stack->pushBool(ret); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // IsScriptRunning ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsScriptRunning") == 0) { stack->correctParams(1); const char *filename = stack->pop()->getString(); bool ret = false; for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; } } stack->pushBool(ret); return STATUS_OK; } else { return BaseScriptable::scCallMethod(script, stack, thisStack, name); } }
bool StaticMidiBufferNode::pushData(PushPacket &input, NCID this_id, NCID other_id) { bool pushed = false; //Check connector if(this_id == INPUTS.MIDI_ID) //Midi Packet { if(recording) //Only if recording { MidiPushPacket *midi_input = dynamic_cast<MidiPushPacket*>(&input); //MidiEventPushPacket *midi_event = dynamic_cast<MidiEventPushPacket*>(&input); if(midi_input) { //const double chunk_time = (double)AUDIO_CHUNK_SIZE/(double)sampleRate, // chunk_time_inv = 1.0/chunk_time; //Get range of pushed data //TimeRange tr = midi_input->range;//midi_input->range.end, midi_input->range.end + midi_input->range.length()); //ChunkRange cr((c_time)std::round(tr.start*chunk_time_inv), (c_time)std::round(tr.end*chunk_time_inv)); //Adjust track length //TODO: Make option for stopping recording if it goes out of range //if(cr.end > length) // setLength(cr.end); MidiEvent e = midi_input->event; //Convert time from global to local time //e.time = globalCursor.convertToLocal(e.time); //Record data applyEvent(midi_input->event); //Make forward nodes dirty //pushed = connectors[OUTPUTS.MIDI_ID]->setDirty(cr); pushed = true;//(unfinishedNotes.size() > 0); //Propogate push //connectors[OUTPUTS.MIDI_ID]->pushData(*midi_input); } /* else if(midi_event) { const double chunk_time = (double)AUDIO_CHUNK_SIZE/(double)sampleRate, chunk_time_inv = 1.0/chunk_time; TimeRange range = pCursor->getTimeRange(); //Get range of pushed data TimeRange tr(midi_event->e.time - 1.0, midi_event->e.time + 1.0);//midi_input->range.end, midi_input->range.end + midi_input->range.length()); ChunkRange cr((c_time)std::round(tr.start*chunk_time_inv), (c_time)std::round(tr.end*chunk_time_inv)); applyEvents({midi_event->e}, tr, cr); pushed = true; //Propogate push connectors[OUTPUTS.MIDI_ID]->pushData(*midi_event); } */ } //Only accept pushed audio data if this track is recording } return pushed; }
bool ConfigXML::createConfigFile() { bool hasGlobal = false, hasFrontend = false, hasAdmin = false; QDomDocument document; configXMLDoc = &document; QDomProcessingInstruction xmldecl = document.createProcessingInstruction("xml", "version=\"1.0\""); document.appendChild(xmldecl); // config element QDomElement config = document.createElement("config"); document.appendChild(config); // MODULES & VERSION ///////////////////////////////////////// // modules section QDomElement modules = document.createElement("modules"); config.appendChild(modules); // module name QDomElement module = document.createElement(CnMn); modules.appendChild(module); // version QDomElement version = document.createElement("version"); version.appendChild(document.createTextNode(moduleConf->getModuleVersion())); module.appendChild(version); // MODULES & VERSION END ///////////////////////////////////////// // init global, frontend, admin sections QDomElement global = document.createElement("global"); QDomElement frontend = document.createElement("frontend"); QDomElement admin = document.createElement("admin"); // blocks | models | helpers if (moduleConf->getHasBlock() || moduleConf->getHasHelper() || moduleConf->getHasModel() || moduleConf->getHasScript() ) { hasGlobal = true; // init blocks, helpers, models sections QDomElement blocks = document.createElement("blocks"); QDomElement helpers = document.createElement("helpers"); QDomElement models = document.createElement("models"); if (moduleConf->getHasBlock()) { // block module QDomElement blockModule = document.createElement( moduleConf->getModuleName().toLower() ); blocks.appendChild(blockModule); // class QDomElement blockClass = document.createElement("class"); blockClass.appendChild(document.createTextNode(CnMn + "_Block")); blockModule.appendChild(blockClass); // blocks section global.appendChild(blocks); } if (moduleConf->getHasHelper()) { // helpers module QDomElement helperModule = document.createElement (moduleConf->getModuleName().toLower() ); helpers.appendChild(helperModule); // class QDomElement helperClass = document.createElement("class"); helperClass.appendChild(document.createTextNode(CnMn + "_Helper")); helperModule.appendChild(helperClass); // helpers section global.appendChild(helpers); } if (moduleConf->getHasModel()) { // block module QDomElement modelModule = document.createElement(moduleConf->getModuleName().toLower()); models.appendChild(modelModule); // class QDomElement modelClass = document.createElement("class"); modelClass.appendChild(document.createTextNode(CnMn + "_Model")); modelModule.appendChild(modelClass); // models section global.appendChild(models); } // apply selected rewrites for (int i = 0; i < rewrites.size(); i++) { hasGlobal = true; Rewrite r = rewrites.at(i); if (r.getType() == "Block") { applyRewrite(r, blocks); } if (r.getType() == "Helper") { applyRewrite(r, helpers); } if (r.getType() == "Model") { applyRewrite(r, models); } r.createFile(); } //////////////////// EVENTS /////////////////// // apply selected events QDomElement globalEvents = document.createElement("events"); QDomElement frontendEvents = document.createElement("events"); QDomElement adminEvents = document.createElement("events"); for (int i = 0; i < events.size(); i++) { Event e = events.at(i); if (e.getArea() == "global") { hasGlobal = true; applyEvent(e, globalEvents); } if (e.getArea() == "frontend") { hasFrontend = true; applyEvent(e, frontendEvents); } if (e.getArea() == "admin") { hasAdmin = true; applyEvent(e, adminEvents); } e.createFile(); } if (globalEvents.childNodes().size() > 0) { global.appendChild(globalEvents); } if (frontendEvents.childNodes().size() > 0) { frontend.appendChild(frontendEvents); } if (adminEvents.childNodes().size() > 0) { admin.appendChild(adminEvents); } //////////////////// EVENTS END /////////////////// if (moduleConf->getHasScript()) { hasGlobal = true; // resources section QDomElement resourcesElem = document.createElement("resources"); // resources setup module QDomElement moduleToSetup = document.createElement(moduleConf->getSetupDirName()); resourcesElem.appendChild(moduleToSetup); // setup section QDomElement setupElem = document.createElement("setup"); moduleToSetup.appendChild(setupElem); QDomElement moduleElem = document.createElement("module"); moduleElem.appendChild(document.createTextNode(CnMn)); setupElem.appendChild(moduleElem); global.appendChild(resourcesElem); } } if (moduleConf->getHasController() || moduleConf->getHasAdminController() ) { // frontend router if (moduleConf->getHasController()) { hasFrontend = true; // routers QDomElement routers = document.createElement("routers"); // router module QDomElement routerModule1 = document.createElement( moduleConf->getModuleName().toLower() ); QDomElement use = document.createElement("use"); use.appendChild(document.createTextNode("standard")); routerModule1.appendChild(use); routerModule1.appendChild(createRouterArgs(document)); routers.appendChild(routerModule1); frontend.appendChild(routers); } // admin router if (moduleConf->getHasAdminController()) { hasAdmin = true; // routers QDomElement routers = document.createElement("routers"); // router module QDomElement routerModule2 = document.createElement( moduleConf->getModuleName().toLower() ); QDomElement use = document.createElement("use"); use.appendChild(document.createTextNode("admin")); routerModule2.appendChild(use); routerModule2.appendChild(createRouterArgs(document)); routers.appendChild(routerModule2); admin.appendChild(routers); } } // add sections and write to file if (hasGlobal) { config.appendChild(global); } if (hasFrontend) { config.appendChild(frontend); } if (hasAdmin) { config.appendChild(admin); } return writeXML(getConfigFilePath(), document); }