void PTrackManager::InitTrack() { // Retrieve the load state from the file manager PTrackLoadState loadState = PFileManager::Get()->GetTrackLoadState(); // If no config is set, then set to the first config in the directory if (!loadState.ConfigName().compare(NO_CONFIG_SET)) { PFileManager* fManager = PFileManager::Get(); std::vector<std::string> configs = fManager->DirectoriesInDirectory(std::string(fManager->GetCurrentDir()) + "tracks\\procedural\\"); loadState.SetConfiguration(configs[0], "tracks/procedural/" + configs[0] + "/"); } pOut("Track manager obtaining pointer to segment factory...\n"); segFactory = PSegFactory::GetInstance(); // Obtain pointer to segment factory pOut("Initializing segment factory...\n"); segFactory->SetChances(45.f, 65.f); // Set neccesary paths std::string modeldir("tracks/procedural/" + loadState.ConfigName() + "/"); std::string texturedir("data/textures"); pOut("Setting Track 3D Description Loader Options...\n"); ssgLoaderOptions* lopts = new ssgLoaderOptions(); lopts->setModelDir(modeldir.c_str()); lopts->setTextureDir(texturedir.c_str()); if (loadState.LoadType() == PLoadType::CONFIG) // Default TORCS Adaptive track initialization - initializes a configuration for a procedural track { pOut("Initialize procedural track configuration...\n"); pOut("Setting track file path and file names...\n"); std::string acname(loadState.ConfigName() + ".ac"); std::string acpath("tracks/procedural/" + loadState.ConfigName() + "/"); std::string configpath(acpath); std::string configname(loadState.ConfigFileName()); // Initialize the procedural track. pOut("Initializing procedural track structure...\n"); track = new PTrack(loadState.Length(), configpath, acpath, configname, acname, lopts); // Point the racemanager to the procedural track pOut("Setting racemanager track to procedural track...\n"); raceManager->track = track->trk; previousSegType = track->GetEnd()->type; // Set track type trackType = PTrackType::PROCEDURAL; } else if (loadState.LoadType() == PLoadType::TRACK) // Initialization if a pre-generated track is to be loaded { // Read in the segments std::vector<PSeg> segs = PFileManager::Get()->ReadTrackSegments(loadState.TrackPath() + loadState.TrackFileName()); // Construct paths and names std::string acname(loadState.TrackName() + ".ac"); std::string acpath("tracks/procedural/" + loadState.ConfigName() + "/previousTracks/" + loadState.TrackName() + "/"); std::string configpath("tracks/procedural/" + loadState.ConfigName() + "/"); std::string configname(loadState.ConfigFileName()); // Obtain track length void* handle = GfParmReadFile((loadState.TrackPath() + loadState.TrackFileName()).c_str(), GFPARM_RMODE_STD); tdble trkLength = GfParmGetNum(handle, P_TRK_SECT_HDR, P_TRK_ATT_LENGTH, (char*)nullptr, 1000); // Initialize the procedural track object track = new PTrack(segs, trkLength, configpath, acpath, configname, acname, lopts); // Add a finish line track->AddFinishLine(); // Point the racemanager to the procedural track raceManager->track = track->trk; // Set the track's name raceManager->track->name = new char[loadState.TrackName().length()]; strcpy((char*)raceManager->track->name, loadState.TrackName().c_str()); strcpy(raceManager->track->internalname, loadState.TrackName().c_str()); // Set track type trackType = PTrackType::PREGENERATED; } // Create a random previous corner type to start with int c = segFactory->CreateRandomCnr(0).type; if (c == TR_LFT) previousCornerType = PCornerType::CTLeft; else previousCornerType = PCornerType::CTRight; }
KDE_EXPORT KCModule *create_dappearance(QWidget *parent, const char* /*name*/) { KConfig *config = new KConfig(configname(), false, false); return new KonqFontOptions(config, "FMSettings", true, parent); }
//------------------------------------------------------------------------ void KfmView::checkLocalProperties (const char *_url) { // Here we read properties. We check if this is a dir with .directory // then if this is the bookmarked url, last if this is on the desktop if (!KRootWidget::pKRootWidget) // No desktop : the window is being restored // by session management. Then use SM values, not local properties. return; // check if this options are enabled: if (!pkfm->isURLPropesEnabled ()) return; int isADir; // Check if this is a dir. If it is writable, write it. isADir = strncmp (_url, "file:", 5); if (!isADir) { if (access(&_url[5], R_OK)==0) // we need if we can read (sven) { QString configname(&_url[5]); configname.append("/.directory"); if (access(configname.data(), F_OK)==0) { KSimpleConfig cfg(configname.data(), true); // be read only gui->loadProperties((KConfig *) &cfg); return; } } } //.directory not readable or not found. See if it is bookmarked KBookmark *bm = gui->getBookmarkManager()->findBookmark(_url); if (bm) { KSimpleConfig cfg(bm->file(), true); //RO gui->loadProperties((KConfig *) &cfg); // will sync on end return; } // .directory not readable or not found and not bookmarked. // See if it is on desktop for (KRootIcon *i = IconList.first(); i; i = IconList.next()) { QString kurl = i->getURL(); KURL::decodeURL(kurl); // Decode kdelnk filename if (kurl.contains(".kdelnk")) { KSimpleConfig cfg(&(kurl.data())[5], true); // RO, #inline, so it's fast cfg.setGroup("KDE Desktop Entry"); if (!strcmp (cfg.readEntry("URL").data(), _url)) { gui->loadProperties((KConfig *) &cfg); // will sync on end return; } } } // Not found or not readable: // Tell gui that there is no URL properties!!!! gui->setHasLocal(false); }
KDE_EXPORT KCModule *create_dbehavior(QWidget *parent, const char* /*name*/) { KConfig *config = new KConfig(configname(), false, false); return new DesktopBehaviorModule(config, parent); }
//---------------------------------------------------------------------------- void KfmView::slotSaveLocalProperties() { int isADir; // Check if this is a dir. If it is writable, write it. const char *_url = manager->getURL(); isADir = strncmp (_url, "file:", 5); if (!isADir) { // No way do find out is it writable; have to check: if (access(&_url[5], W_OK)==0) { QString configname(&_url[5]); configname.append("/.directory"); KSimpleConfig cfg(configname.data()); gui->writeProperties((KConfig *) &cfg); // will sync on end return; } } //Dir not writable or not a file: url. See if it is bookmarked KBookmark *bm = gui->getBookmarkManager()->findBookmark(_url); if (bm) { KSimpleConfig cfg(bm->file()); gui->writeProperties((KConfig *) &cfg); // will sync on end return; } //Dir not writable or not a file: url. See if it is on desktop if (KRootWidget::pKRootWidget) // if there is one. DF. { QString s1, s2, kurl; s1 = _url; if (s1.right( 1 ) == "/") s1.resize(s1.length()); for (KRootIcon *i = IconList.first(); i; i = IconList.next()) { kurl = i->getURL(); KURL::decodeURL(kurl); // Decode kdelnk filename if (kurl.contains(".kdelnk")) { debug ("Got a kdelnk: %s", &(kurl.data())[5]); KSimpleConfig cfg(&(kurl.data())[5], true); //RO, #inline, so it's fast cfg.setGroup("KDE Desktop Entry"); s2 = cfg.readEntry("URL").data(); if (s2.right( 1 ) == "/") s2.resize(s2.length()); if (s1 == s2) { KSimpleConfig wcfg(&(kurl.data())[5]); //rw gui->writeProperties((KConfig *) &wcfg); // will sync on end return; } } } } // Not found or not writable: if (!isADir ) QMessageBox::warning(0, klocale->translate( "KFM Error" ), klocale->translate("Can not save properties because\nthis directory is neither writable nor bookmarked.\n\n Bookmark this location first, or make kdelnk to it on desktop.") ); else QMessageBox::warning(0, klocale->translate( "KFM Error" ), klocale->translate("Can not save properties because\nthis URL is neither bookmarked nor on desktop.\n\n Bookmark this location first, or make kdelnk to it on desktop.")); }