void HtmlTabCtrl::onInit() { ControlBase::onInit(); getControls()->add(m_pages); getControls()->add(m_view); }
ofxGuiElement * ofxGuiContainer::getControl(std::size_t num) { if(num < getControls().size()) { return dynamic_cast <ofxGuiElement *>(getControls().at(num)); } else { return nullptr; } }
void ofxGuiContainer::clear() { parameters.clear(); while(getControls().size() > 0) { if(!removeChild(getControls().at(0))) { ofLogError("Element::clear") << "Could not remove child"; return; } } active_toggle_index = -1; }
/** This function is called each timestep, and it collects most of the * statistics for this kart. * \param dt Time step size. */ void KartWithStats::update(int ticks) { Kart::update(ticks); if(getSpeed()>m_top_speed ) m_top_speed = getSpeed(); float dt = stk_config->ticks2Time(ticks); if(getControls().getSkidControl()) m_skidding_time += dt; if(getControls().getBrake() ) m_brake_count ++; LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld()); if(world && !world->isOnRoad(getWorldKartId())) m_off_track_count ++; } // update
bool ofxGuiContainer::setActiveToggle(int index) { if(index >= 0 && index < (int)getControls().size()) { if(ofxGuiToggle* toggle = dynamic_cast<ofxGuiToggle*>(getControls().at(index))) { return setActiveToggle(toggle); } else { ofLogError("ofxGuiContainer", "cannot activate control " + ofToString(index) + " because it's no ofxToggle."); return false; } } return false; }
/** This function is called each timestep, and it collects most of the * statistics for this kart. * \param dt Time step size. */ void KartWithStats::update(float dt) { Kart::update(dt); if(getSpeed()>m_top_speed) m_top_speed = getSpeed(); if(getControls().m_skid) m_skidding_time += dt; if(getControls().m_brake) m_brake_count ++; LinearWorld *world = dynamic_cast<LinearWorld*>(World::getWorld()); if(world && !world->isOnRoad(getWorldKartId())) m_off_track_count ++; } // update
void ofxGuiContainer::deactivateAllOtherToggles(ofxGuiToggle *toggle) { if(exclusiveToggles) { int active_index = -1; for(int i = 0; i < (int)getControls().size(); i++) { if(ofxGuiToggle* t = dynamic_cast<ofxGuiToggle*>(getControls()[i])) { active_index++; if(t != toggle) { *t = false; } else { active_toggle_index.set(active_index); } } } } }
void PPContainer::adjustContainerSize() { PPSimpleVector<PPControl>& controls = getControls(); pp_int32 x1 = parentScreen->getWidth(); pp_int32 y1 = parentScreen->getHeight(); pp_int32 x2 = 0; pp_int32 y2 = 0; for (pp_int32 i = 0; i < controls.size(); i++) { PPControl* control = controls.get(i); PPPoint p = control->getLocation(); if (p.x < x1) x1 = p.x; if (p.y < y1) y1 = p.y; p.x+=control->getSize().width; p.y+=control->getSize().height; if (p.x > x2) x2 = p.x; if (p.y > y2) y2 = p.y; } setLocation(PPPoint(x1, y1)); setSize(PPSize(x2-x1, y2-y1)); }
void SearchEditor::onLoad() { EditorBase::onLoad(); String path = utils::makeFilePath(utils::makeFolderPath(g_componentsPath, _S("search")), _S("search_editor.xsl")); shared_ptr<XMLStylesheet> stylesheet(OS_NEW XMLStylesheet()); // Inizializza le funzioni del template getPage()->initStylesheet(stylesheet); // Carica l'xsl if(stylesheet->parseFile(path)) { // URGENT devo per forza creare un documento? // Se il secondo parametro della XSLControl nullptr non crea il controllo, // e non posso passare una "getDocument()" perch se una nuova istanza nullptr pure lui... shared_ptr<XMLDocument> document(OS_NEW XMLDocument()); shared_ptr<XMLNode> root = document->create(OS_MODULES_SEARCH_ROOT); shared_ptr<HtmlXSLControl> templ(OS_NEW HtmlXSLControl(stylesheet, document)); templ->addChildParam(m_globalParams); templ->addChildParam(m_showParams); templ->addChildParam(m_directRun); templ->addChildParam(m_allowRss); templ->addChildParam(m_rssDescription); templ->addChildParam(m_rssBody); getControls()->add(templ); } }
void QuickKeysMenu::dismiss() { std::vector<HUDuiControl*>& controls = getControls(); int i; for (i=1; i < 11; i++) { HUDuiTypeIn *entry = static_cast<HUDuiTypeIn*>(controls[firstKeyControl + i - 1]); std::string keyValue = entry->getString(); std::string keyName = string_util::format("quickMessage%d", i); if (keyValue.empty() && BZDB.isSet(keyName)) BZDB.unset(keyName); else if (!keyValue.empty()) BZDB.set(keyName, keyValue); } for (i=1; i < 11; i++) { HUDuiTypeIn *entry = static_cast<HUDuiTypeIn*>(controls[firstKeyControl + i + 9]); std::string keyValue = entry->getString(); std::string keyName = string_util::format("quickTeamMessage%d", i); if (keyValue.empty() && BZDB.isSet(keyName)) BZDB.unset(keyName); else if (!keyValue.empty()) BZDB.set(keyName, keyValue); } }
void PPContainer::move(const PPPoint& offset) { PPPoint p = getLocation(); p.x+=offset.x; p.y+=offset.y; location = p; backgroundButton->setLocation(p); PPSimpleVector<PPControl>& controls = getControls(); for (pp_int32 i = 0; i < controls.size(); i++) { PPControl* control = controls.get(i); if (!control->isContainer()) { p = control->getLocation(); p.x+=offset.x; p.y+=offset.y; control->setLocation(p); } else static_cast<PPContainer*>(control)->move(offset); } }
QuickKeysMenu::QuickKeysMenu() { // add controls std::vector<HUDuiControl*>& controls = getControls(); controls.push_back(createLabel("Define Quick Keys")); controls.push_back(createLabel("Notice: depending on platform not all keys might work")); controls.push_back(createLabel("Send to All")); controls.push_back(createLabel("Send to Team")); firstKeyControl = controls.size(); int i; for (i=1; i < 11; i++) { std::string keyLabel = string_util::format("Alt-F%d", i); controls.push_back(createInput(keyLabel)); } for (i=1; i < 11; i++) { std::string keyLabel = string_util::format("Ctrl-F%d", i); controls.push_back(createInput(keyLabel)); } initNavigation(controls, firstKeyControl, controls.size()-1); }
void IdePickerNumber::onLoad() { m_input->setSize(19); m_input->setMaxLength(19); m_input->getAttributes()->set(_S("data-os-otype"), _S("number")); m_input->getAttributes()->set(_S("data-os-min"), conversions::to_utf16(m_valueMin)); m_input->getAttributes()->set(_S("data-os-max"), conversions::to_utf16(m_valueMax)); getControls()->add(m_input); }
ofxGuiElement* ofxGuiContainer::getControl(const std::string& name) { for(auto & e: getControls()) { if(e) { if(e->getName() == name) { return e; } } } return nullptr; }
void IdeVoteEditor::onInit() { ControlBase::onInit(); m_values->setID(_S("values")); m_values->addOption(getPage()->getText(_S("vote_editor.votes.null")), _S("")); for(uint32 i = OS_PORTAL_OBJECT_VOTE_MIN; i <= OS_PORTAL_OBJECT_VOTE_MAX; i+=2) { String value = conversions::to_utf16<uint32>(i); m_values->addOption(getPage()->getText(_S("vote_editor.votes.") + value), value); } m_update->setCaption(getPage()->getText(_S("vote_editor.vote.caption"))); m_update->setID(_S("update")); getControls()->add(m_values); getControls()->add(m_update); }
void ofxGuiContainer::setOneToggleActive() { if(active_toggle_index == -1) { for(auto &e : getControls()) { if(ofxGuiToggle* t = dynamic_cast<ofxGuiToggle*>(e)) { setActiveToggle(t); return; } } } }
void HtmlTab::addPage(shared_ptr<IHtmlControl> page, const String &title) { if(page == nullptr) return; if(page->hasCss() == false) page->setCss(OS_CSS_TAB_PAGE); page->getAttributes()->set(_S("pageTitle"), title); getControls()->add(page); }
int ofxGuiContainer::getControlIndex(const std::string& name) { for(int i = 0; i < (int)getControls().size(); i++) { ofxGuiElement *e = getControl(i); if(e) { if(e->getName() == name) { return i; } } } return -1; }
int sfw::menuChoice(int opts, bool isVertical) { opts -= 1; if (isVertical) { /********************************************************\ * This isn't one switch becasue that would allow the * * "sideways" keys to function in vertical menus, which * * I find undesireable. * \*******************************************************/ switch (getControls()) { case 0: sel--; break; case 1: sel++; break; } } else if (!isVertical) { switch (getControls()) { case 2: sel--; break; case 3: sel++; break; } } if (sel > opts) { sel = 0; } else if (sel < 0) { sel = opts; } resetKeys(); return sel; }
void ExtensionsInvalidModule::onLoad() { ViewerBase::onLoad(); /* shared_ptr<HtmlImage> img(OS_NEW HtmlImage(getPage()->getSkin()->getImageUrl(_S("invalid_module.png")))); setCss(_S("os_modules_invalid")); img->getAttributes()->set(_S("data-os-tooltip"), getPage()->getText(_S("system.invalid_module")) + _S(": ") + m_module.toUTF16()); getControls()->add(img); */ setCss(_S("os_modules_invalid")); getControls()->add(shared_ptr<HtmlText>(OS_NEW HtmlText(getPage()->getText(_S("system.invalid_module"))))); }
int ofxGuiContainer::getControlIndex(ofxGuiElement* element) { for(int i = 0; i < (int)getControls().size(); i++) { ofxGuiElement *e = getControl(i); if(e) { if(e == element) { return i; } } } return -1; }
void JobDetail::onLoad() { PageBase::onLoad(); // Ottiene l'id dell'utente richiesto int id = conversions::from_utf16<uint32>(getUrlID()); shared_ptr<XMLDocument> document(OS_NEW XMLDocument()); shared_ptr<XMLExporter> exporter(OS_NEW XMLExporter(document->create(_S("job")))); // VERYURGENT: abolire il ciclo for Engine::BackgroundJobs::const_iterator i; shared_ptr<Engine::BackgroundJobs> jobs = Engine::instance()->getBackgroundJobs(); if(jobs != nullptr) { for(i = jobs->begin(); i != jobs->end(); ++i) { shared_ptr<IBackgroundJob> job = *i; if(job->getID() == id) { Jobs::exportJob(exporter, job, false); } } } jobs = Engine::instance()->getLastCompletedBackgroundJobs(); if(jobs != nullptr) { for(i = jobs->begin(); i != jobs->end(); ++i) { shared_ptr<IBackgroundJob> job = *i; if(job->getID() == id) { Jobs::exportJob(exporter, job, true); } } } String path = getSkin()->getTemplatePath(_S("job_detail.xsl")); shared_ptr<HtmlXSLControl> pageTemplate(OS_NEW HtmlXSLControl(loadStylesheet(path), document)); // Carica il template di riferimento getControls()->add(pageTemplate); }
void IdePickerDateTime::onLoad() { m_input->setSize(19); m_input->setMaxLength(19); getControls()->add(m_input); /* shared_ptr<HtmlImage> img(OS_NEW HtmlImage(getPage()->getSkin()->getImageUrl(_S("small/warning.gif")))); img->getAttributes()->set(_S("data-os-tooltip"),_S("Syntax:\r\nyyyy-mm-ddThh24:mi:ss")); getControls()->add(img); */ m_input->getAttributes()->set(_S("data-os-otype"), _S("datetime")); m_input->getAttributes()->set(_S("data-os-showtime"), conversions::to_utf16(m_showTime)); }
/** Actually rewind to the specified state. */ void KartRewinder::rewindToState(BareNetworkString *buffer) { // 1) Physics values: transform and velocities // ------------------------------------------- btTransform t; t.setOrigin(buffer->getVec3()); t.setRotation(buffer->getQuat()); btRigidBody *body = getBody(); body->setLinearVelocity(buffer->getVec3()); body->setAngularVelocity(buffer->getVec3()); // This function also reads the velocity, so it must be called // after the velocities are set body->proceedToTransform(t); // Update kart transform in case that there are access to its value // before Moveable::update() is called (which updates the transform) setTrans(t); m_has_started = buffer->getUInt8()!=0; // necessary for startup speed boost m_vehicle->setMinSpeed(buffer->getFloat()); float time_rot = buffer->getFloat(); // Set timed rotation divides by time_rot m_vehicle->setTimedRotation(time_rot, time_rot*buffer->getVec3()); // 2) Steering and other controls // ------------------------------ getControls().rewindTo(buffer); getController()->rewindTo(buffer); // 3) Attachment // ------------- getAttachment()->rewindTo(buffer); // 4) Powerup // ---------- getPowerup()->rewindTo(buffer); // 5) Max speed info // ------------------ m_max_speed->rewindTo(buffer); m_max_speed->update(0); // 6) Skidding // ----------- m_skidding->rewindTo(buffer); return; } // rewindToState
bool oCourse::Write(xmlparser &xml) { if (Removed) return true; xml.startTag("Course"); xml.write("Id", Id); xml.write("Updated", Modified.getStamp()); xml.write("Name", Name); xml.write("Length", Length); xml.write("Controls", getControls()); xml.write("Legs", getLegLengths()); getDI().write(xml); xml.endTag(); return true; }
void CommentableObjectViewer::_createLastPosts() { // Calcola il numero di posts totali uint32 total_posts = getEntity()->getChildsCount(getDatabase(), portalObjectTypePost); // Calcola il numero di risposte da visualizzare uint32 posts_count = utils::min<uint32>(total_posts, getSkin()->getPagerItems()); // Carica i posts shared_ptr<EntitiesEntities> posts = getEntity()->getChilds(getDatabase(), portalObjectTypePost, RangeUint32(total_posts - posts_count, posts_count)); if(posts->empty() == false) { shared_ptr<PostViewer> posts_viewer(OS_NEW PostViewer()); getControls()->add(posts_viewer); // Scorre gli ultimi posts dal pi recente for(EntitiesEntities::reverse_iterator i = posts->rbegin(); i != posts->rend(); ++i) { posts_viewer->addPost(posts->get(getDatabase(), *i)); } } }
/** Saves all state information for a kart in a memory buffer. The memory * is allocated here and the address returned. It will then be managed * by the RewindManager. The size is used to keep track of memory usage * for rewinding. * \param[out] buffer Address of the memory buffer. * \returns Size of allocated memory, or -1 in case of an error. */ BareNetworkString* KartRewinder::saveState() const { const int MEMSIZE = 17*sizeof(float) + 9+3; BareNetworkString *buffer = new BareNetworkString(MEMSIZE); const btRigidBody *body = getBody(); // 1) Physics values: transform and velocities // ------------------------------------------- const btTransform &t = body->getWorldTransform(); buffer->add(t.getOrigin()); btQuaternion q = t.getRotation(); buffer->add(q); buffer->add(body->getLinearVelocity()); buffer->add(body->getAngularVelocity()); buffer->addUInt8(m_has_started); // necessary for startup speed boost buffer->addFloat(m_vehicle->getMinSpeed()); buffer->addFloat(m_vehicle->getTimedRotationTime()); buffer->add(m_vehicle->getTimedRotation()); // 2) Steering and other player controls // ------------------------------------- getControls().saveState(buffer); getController()->saveState(buffer); // 3) Attachment // ------------- getAttachment()->saveState(buffer); // 4) Powerup // ---------- getPowerup()->saveState(buffer); // 5) Max speed info // ------------------ m_max_speed->saveState(buffer); // 6) Skidding // ----------- m_skidding->saveState(buffer); return buffer; } // saveState
void QuickKeysMenu::show() { std::vector<HUDuiControl*>& controls = getControls(); int i; for (i=1; i < 11; i++) { HUDuiTypeIn *entry = static_cast<HUDuiTypeIn*>(controls[firstKeyControl + i - 1]); std::string keyName = string_util::format("quickMessage%d", i); std::string keyValue = BZDB.get(keyName); entry->setString(keyValue); } for (i=1; i < 11; i++) { HUDuiTypeIn *entry = static_cast<HUDuiTypeIn*>(controls[firstKeyControl + i + 9]); std::string keyName = string_util::format("quickTeamMessage%d", i); std::string keyValue = BZDB.get(keyName); entry->setString(keyValue); } }
void XsltTransformViewer::onLoad() { ViewerBase::onLoad(); shared_ptr<XMLNode> root = getModuleDocument()->getRoot(); if(root != nullptr) { String xmlStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XML); String xslStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XSL); String xsdStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XSD); shared_ptr<XMLDocument> document; if(xsdStr.empty()) { document.reset(OS_NEW XMLDocument()); } else { shared_ptr<XMLSchema> xsd(OS_NEW XMLSchema()); xsd->parseString(xsdStr); document.reset(OS_NEW XMLDocument(xsd)); } if(document->parseString(xmlStr)) { shared_ptr<XMLStylesheet> transformer(OS_NEW XMLStylesheet()); // Inizializza le funzioni del template getPage()->initStylesheet(transformer); if(transformer->parseString(xslStr)) { String output; if(transformer->applyToString(document, output)) { getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(getPage()->parseOml(output, true, false, false, omlRenderModeOsiris, getInstance().getString())))); } } } } }
void InputMenu::resize(int width, int height) { HUDDialog::resize(width, height); int i; // use a big font for title, smaller font for the rest const float titleFontSize = (float)height / 15.0f; const float fontSize = (float)height / 45.0f; FontManager &fm = FontManager::instance(); // reposition title std::vector<HUDuiControl*>& list = getControls(); HUDuiLabel* title = (HUDuiLabel*)list[0]; title->setFontSize(titleFontSize); const float titleWidth = fm.getStrLength(MainMenu::getFontFace(), titleFontSize, title->getString()); const float titleHeight = fm.getStrHeight(MainMenu::getFontFace(), titleFontSize, " "); float x = 0.5f * ((float)width - titleWidth); float y = (float)height - titleHeight; title->setPosition(x, y); // reposition options x = 0.5f * ((float)width + 0.5f * titleWidth); y -= 0.6f * titleHeight; const float h = fm.getStrHeight(MainMenu::getFontFace(), fontSize, " "); const int count = list.size(); for (i = 1; i < count; i++) { list[i]->setFontSize(fontSize); list[i]->setPosition(x, y); y -= 1.0f * h; } // load current settings std::vector<std::string> *options = &forceInput->getList(); for (i = 0; i < (int)options->size(); i++) { std::string currentOption = (*options)[i]; if (BZDB.get("forceInputDevice") == currentOption) forceInput->setIndex(i); } if (BZDB.isTrue("allowInputChange")) forceInput->setIndex(0); }