void InitDirs(const std::string& argv0) { if (g_initialized) return; /* store working dir. some implimentations get the value of initial_path * from the value of current_path the first time initial_path is called, * so it is necessary to call initial_path as soon as possible after * starting the program, so that current_path doesn't have a chance to * change before initial_path is initialized. */ fs::initial_path(); br_init(0); fs::path p = GetUserDir(); if (!exists(p)) { fs::create_directories(p); } p /= "save"; if (!exists(p)) { fs::create_directories(p); } InitBinDir(argv0); g_initialized = true; }
QVariant ItemHandlerPath::GetValue (const QDomElement& item, QVariant value) const { if (value.isNull () || value.toString ().isEmpty ()) { if (item.attribute ("defaultHomePath") == "true") value = QDir::homePath (); else if (item.hasAttribute ("default")) { QString text = item.attribute ("default"); QMap<QString, QString> str2loc; str2loc ["DOCUMENTS"] = QDesktopServices::storageLocation (QDesktopServices::DocumentsLocation); str2loc ["DESKTOP"] = QDesktopServices::storageLocation (QDesktopServices::DesktopLocation); str2loc ["MUSIC"] = QDesktopServices::storageLocation (QDesktopServices::MusicLocation); str2loc ["MOVIES"] = QDesktopServices::storageLocation (QDesktopServices::MoviesLocation); #ifndef Q_OS_LINUX str2loc ["LCDIR"] = GetUserDir ({}).absolutePath (); #else str2loc ["LCDIR"] = Util::GetUserDir ({}).absolutePath (); #endif Q_FOREACH (const QString& key, str2loc.keys ()) if (text.startsWith ("{" + key + "}")) { text.replace (0, key.length () + 2, str2loc [key]); break; } value = text; } }
static void DoInit (HWND hWnd) { STRING szTmp; STRING szDir; int idx; iUserIndex = 0; iUserCount = GetNumberOfUsers(); iButtonIndex = 4; // set to other than 0 - 3 // hide unused radio buttons switch (iUserCount) { case 0: ShowWindow (GetDlgItem(hWnd, IDC_WHO_BUTTON1), SW_HIDE); case 1: ShowWindow (GetDlgItem(hWnd, IDC_WHO_BUTTON2), SW_HIDE); case 2: ShowWindow (GetDlgItem(hWnd, IDC_WHO_BUTTON3), SW_HIDE); case 3: ShowWindow (GetDlgItem(hWnd, IDC_WHO_BUTTON4), SW_HIDE); default: for (idx = 0 ; idx < iUserCount ; idx++) { if ( GetUserNameString (idx, szTmp) ) { SetDlgItemText (hWnd, ButtonIds[idx], szTmp); AstralControlRepaint (hWnd, ButtonIds[idx]); } } break; } ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE); if (iUserCount <= 4) ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE); else ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_SHOW); clr ((LPTR)Control.CurrentUser, sizeof(Control.CurrentUser)); clr ((LPTR)szNewUser, sizeof(STRING)); if (GetUserNameString (iUserIndex, szNewUser)) { if (GetUserDir (szNewUser, szDir)) lstrcpy (Control.CurrentUser, szDir); } if (iUserCount) { SetFocus (GetDlgItem (hWnd, IDC_WHO_BUTTON1)); CheckRadioButton (hWnd, IDC_WHO_BUTTON1, IDC_WHO_NEWBUTTON, IDC_WHO_BUTTON1); fNoUsers = FALSE; } else { SetFocus (GetDlgItem (hWnd, IDOK)); fNoUsers = TRUE; } }
static void UpdateButtons (HWND hWnd, int iUserIndex, int iUserCount) { STRING szUser; STRING szDir; HWND hControl; int idx, iUser; iUser = iUserIndex; // update the button text for (idx = 0 ; idx < 4 ; idx++) { if (GetUserNameString (iUser++, szUser)) { SetDlgItemText (hWnd, ButtonIds[idx], szUser); if ((hControl = GetDlgItem (hWnd, ButtonIds[idx]))) InvalidateRect (hControl, NULL, FALSE); } else break; } // the top button is selected by default, so get a users // directory if one exists until they change it if ( GetUserNameString (iUserIndex, szUser) ) { if ( GetUserDir (szUser, szDir)) lstrcpy (Control.CurrentUser, szDir); } }
YSRESULT YsSpecialPath::GetUserDir(YsWString &wpath) { YsString path; if(YSOK==GetUserDir(path)) { wpath.SetUTF8String(path); return YSOK; } return YSERR; }
const wxFileName mmex::GetLogDir(bool create) { static wxFileName fname; if (!fname.IsOk()) { fname = GetUserDir(create); //FIXME: file not found ERROR //fname.AppendDir("logs"); } return fname; }
const wxString mmex::getPathUser(EUserFile f) { static const wxString files[USER_FILES_MAX] = { getSettingsFileName(), getDirectory() }; wxASSERT(f >= 0 && f < USER_FILES_MAX); wxFileName fname = GetUserDir(true); fname.SetFullName(files[f]); return fname.GetFullPath(); }
NetworkDiskCache::NetworkDiskCache (const QString& subpath, QObject *parent) : QNetworkDiskCache (parent) , CurrentSize_ (-1) , InsertRemoveMutex_ (QMutex::Recursive) , GarbageCollectorWatcher_ (nullptr) { setCacheDirectory (GetUserDir (UserDir::Cache, "network/" + subpath).absolutePath ()); auto timer = new QTimer (this); timer->setInterval (60 * 60 * 1000); connect (timer, SIGNAL (timeout ()), this, SLOT (collectGarbage ())); }
void InitDirs(const std::string& argv0) { if (g_initialized) return; fs::path local_dir = GetUserDir(); if (!exists(local_dir)) fs::create_directories(local_dir); fs::path p(GetSaveDir()); if (!exists(p)) fs::create_directories(p); InitBinDir(argv0); g_initialized = true; }
static void HandleButton (HWND hWnd, int Index) { STRING szDir; HWND hControl; if (fButtonHidden) { ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_HIDE); ShowWindow (GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), SW_SHOW); if ((hControl = GetDlgItem (hWnd, IDC_WHO_NEWBUTTON))) InvalidateRect (hControl, NULL, FALSE); fButtonHidden = FALSE; } clr ((LPTR)szNewUser, sizeof(STRING)); if ( GetUserNameString (iUserIndex + Index, szNewUser) ) { if ( GetUserDir (szNewUser, szDir)) lstrcpy (Control.CurrentUser, szDir); } CheckRadioButton (hWnd, IDC_WHO_BUTTON1, IDC_WHO_NEWBUTTON, ButtonIds[Index]); }
namespace FileSystem { static FileSourceFS dataFilesApp(GetDataDir()); static FileSourceFS dataFilesUser(JoinPath(GetUserDir(), "data")); FileSourceUnion gameDataFiles; FileSourceFS userFiles(GetUserDir()); // note: some functions (GetUserDir(), GetDataDir()) are in FileSystem{Posix,Win32}.cpp std::string JoinPath(const std::string &a, const std::string &b) { if (!b.empty()) { if (b[0] == '/' || a.empty()) return b; else return a + "/" + b; } else return a; } static void normalise_path(std::string &result, const StringRange &path) { StringRange part(path.begin, path.begin); const char *c = path.begin; if ((c != path.end) && (*c == '/')) { result += '/'; ++c; ++part.begin; } const size_t initial_result_length = result.size(); while (true) { if ((*c == '/') || (c == path.end)) { part.end = c; if (part.Empty() || (part == ".")) { // skip this part } else if (part == "..") { // pop the last component if (result.size() <= initial_result_length) throw std::invalid_argument(path.ToString()); size_t pos = result.rfind('/', result.size()-2); ++pos; assert(pos >= initial_result_length); result.erase(pos); } else { // push the new component if (part.end != path.end) { assert(*part.end == '/'); ++part.end; } result.append(part.begin, part.Size()); } part.begin = c+1; } if (c == path.end) { break; } ++c; } } std::string NormalisePath(const std::string &path) { std::string result; result.reserve(path.size()); normalise_path(result, StringRange(path.c_str(), path.size())); return result; } std::string JoinPathBelow(const std::string &base, const std::string &path) { if (base.empty()) return path; if (!path.empty()) { if ((path[0] == '/') && (base != "/")) throw std::invalid_argument(path); else { std::string result(base); result.reserve(result.size() + 1 + path.size()); if (result[result.size()-1] != '/') result += '/'; StringRange rhs(path.c_str(), path.size()); if (path[0] == '/') { assert(base == "/"); ++rhs.begin; } normalise_path(result, rhs); return result; } } else return base; } void Init() { gameDataFiles.AppendSource(&dataFilesUser); gameDataFiles.AppendSource(&dataFilesApp); } void Uninit() { } FileInfo::FileInfo(FileSource *source, const std::string &path, FileType type): m_source(source), m_path(path), m_dirLen(0), m_type(type) { assert((m_path.size() <= 1) || (m_path[m_path.size()-1] != '/')); std::size_t slashpos = m_path.rfind('/'); if (slashpos != std::string::npos) { m_dirLen = slashpos + 1; } else { m_dirLen = 0; } } FileInfo FileSource::MakeFileInfo(const std::string &path, FileInfo::FileType fileType) { return FileInfo(this, path, fileType); } FileSourceUnion::FileSourceUnion(): FileSource(":union:") {} FileSourceUnion::~FileSourceUnion() {} void FileSourceUnion::PrependSource(FileSource *fs) { assert(fs); RemoveSource(fs); m_sources.insert(m_sources.begin(), fs); } void FileSourceUnion::AppendSource(FileSource *fs) { assert(fs); RemoveSource(fs); m_sources.push_back(fs); } void FileSourceUnion::RemoveSource(FileSource *fs) { std::vector<FileSource*>::iterator nend = std::remove(m_sources.begin(), m_sources.end(), fs); m_sources.erase(nend, m_sources.end()); } FileInfo FileSourceUnion::Lookup(const std::string &path) { for (std::vector<FileSource*>::const_iterator it = m_sources.begin(); it != m_sources.end(); ++it) { FileInfo info = (*it)->Lookup(path); if (info.Exists()) { return info; } } return MakeFileInfo(path, FileInfo::FT_NON_EXISTENT); } RefCountedPtr<FileData> FileSourceUnion::ReadFile(const std::string &path) { for (std::vector<FileSource*>::const_iterator it = m_sources.begin(); it != m_sources.end(); ++it) { RefCountedPtr<FileData> data = (*it)->ReadFile(path); if (data) { return data; } } return RefCountedPtr<FileData>(); } // Merge two sets of FileInfo's, by path. // Input vectors must be sorted. Output will be sorted. // Where a path is present in both inputs, directories are selected // in preference to non-directories; otherwise, the FileInfo from the // first vector is selected in preference to the second vector. static void file_union_merge( std::vector<FileInfo>::const_iterator a, std::vector<FileInfo>::const_iterator aend, std::vector<FileInfo>::const_iterator b, std::vector<FileInfo>::const_iterator bend, std::vector<FileInfo> &output) { while ((a != aend) && (b != bend)) { int order = a->GetPath().compare(b->GetPath()); int which = order; if (which == 0) { if (b->IsDir() && !a->IsDir()) { which = 1; } else { which = -1; } } if (which < 0) { output.push_back(*a++); if (order == 0) ++b; } else { output.push_back(*b++); if (order == 0) ++a; } } if (a != aend) { std::copy(a, aend, std::back_inserter(output)); } if (b != bend) { std::copy(b, bend, std::back_inserter(output)); } } bool FileSourceUnion::ReadDirectory(const std::string &path, std::vector<FileInfo> &output) { if (m_sources.empty()) { return false; } if (m_sources.size() == 1) { return m_sources.front()->ReadDirectory(path, output); } bool founddir = false; std::vector<FileInfo> merged; for (std::vector<FileSource*>::const_iterator it = m_sources.begin(); it != m_sources.end(); ++it) { std::vector<FileInfo> nextfiles; if ((*it)->ReadDirectory(path, nextfiles)) { founddir = true; std::vector<FileInfo> prevfiles; prevfiles.swap(merged); // merge order is important // file_union_merge selects from its first input preferentially file_union_merge( prevfiles.begin(), prevfiles.end(), nextfiles.begin(), nextfiles.end(), merged); } } output.reserve(output.size() + merged.size()); std::copy(merged.begin(), merged.end(), std::back_inserter(output)); return founddir; } FileEnumerator::FileEnumerator(FileSource &fs, int flags): m_source(&fs), m_flags(flags) {} FileEnumerator::FileEnumerator(FileSource &fs, const std::string &path, int flags): m_source(&fs), m_flags(flags) { AddSearchRoot(path); } FileEnumerator::~FileEnumerator() {} void FileEnumerator::AddSearchRoot(const std::string &path) { const FileInfo fi = m_source->Lookup(path); if (fi.IsDir()) { QueueDirectoryContents(fi); ExpandDirQueue(); } } void FileEnumerator::Next() { m_queue.pop_front(); ExpandDirQueue(); } void FileEnumerator::ExpandDirQueue() { while (m_queue.empty() && !m_dirQueue.empty()) { const FileInfo &nextDir = m_dirQueue.front(); assert(nextDir.IsDir()); QueueDirectoryContents(nextDir); m_dirQueue.pop_front(); } } void FileEnumerator::QueueDirectoryContents(const FileInfo &info) { assert(info.IsDir()); std::vector<FileInfo> entries; m_source->ReadDirectory(info.GetPath(), entries); for (std::vector<FileInfo>::const_iterator it = entries.begin(); it != entries.end(); ++it) { switch (it->GetType()) { case FileInfo::FT_DIR: if (m_flags & IncludeDirs) { m_queue.push_back(*it); } if (m_flags & Recurse) { m_dirQueue.push_back(*it); } break; case FileInfo::FT_FILE: if (!(m_flags & ExcludeFiles)) { m_queue.push_back(*it); } break; case FileInfo::FT_SPECIAL: if (m_flags & IncludeSpecials) { m_queue.push_back(*it); } break; default: assert(0); break; } } } } // namespace FileSystem
HumanClientApp::HumanClientApp(int width, int height, bool calculate_fps, const std::string& name, int x, int y, bool fullscreen, bool fake_mode_change) : ClientApp(), SDLGUI(width, height, calculate_fps, name, x, y, fullscreen, fake_mode_change), m_fsm(0), m_single_player_game(true), m_game_started(false), m_connected(false), m_auto_turns(0), m_have_window_focus(true) { #ifdef ENABLE_CRASH_BACKTRACE signal(SIGSEGV, SigHandler); #endif #ifdef FREEORION_MACOSX SDL_SetHint(SDL_HINT_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK, "1"); #endif m_fsm = new HumanClientFSM(*this); const std::string HUMAN_CLIENT_LOG_FILENAME((GetUserDir() / "freeorion.log").string()); InitLogger(HUMAN_CLIENT_LOG_FILENAME, "Client"); try { DebugLogger() << "GL Version String: " << GetGLVersionString(); } catch (...) { ErrorLogger() << "Unable to get GL Version String?"; } LogDependencyVersions(); boost::shared_ptr<GG::StyleFactory> style(new CUIStyle()); SetStyleFactory(style); SetMinDragTime(0); m_ui = boost::shared_ptr<ClientUI>(new ClientUI()); if ((GetOptionsDB().Get<bool>("UI.sound.music-enabled"))) Sound::GetSound().PlayMusic(GetOptionsDB().Get<std::string>("UI.sound.bg-music"), -1); Sound::GetSound().SetMusicVolume(GetOptionsDB().Get<int>("UI.sound.music-volume")); Sound::GetSound().SetUISoundsVolume(GetOptionsDB().Get<int>("UI.sound.volume")); EnableFPS(); UpdateFPSLimit(); GG::Connect(GetOptionsDB().OptionChangedSignal("show-fps"), &HumanClientApp::UpdateFPSLimit, this); boost::shared_ptr<GG::BrowseInfoWnd> default_browse_info_wnd( new GG::TextBoxBrowseInfoWnd(GG::X(400), ClientUI::GetFont(), GG::Clr(0, 0, 0, 200), ClientUI::WndOuterBorderColor(), ClientUI::TextColor(), GG::FORMAT_LEFT | GG::FORMAT_WORDBREAK, 1)); GG::Wnd::SetDefaultBrowseInfoWnd(default_browse_info_wnd); boost::shared_ptr<GG::Texture> cursor_texture = m_ui->GetTexture(ClientUI::ArtDir() / "cursors" / "default_cursor.png"); SetCursor(boost::shared_ptr<GG::TextureCursor>(new GG::TextureCursor(cursor_texture, GG::Pt(GG::X(6), GG::Y(3))))); RenderCursor(true); EnableKeyPressRepeat(GetOptionsDB().Get<int>("UI.keypress-repeat-delay"), GetOptionsDB().Get<int>("UI.keypress-repeat-interval")); EnableMouseButtonDownRepeat(GetOptionsDB().Get<int>("UI.mouse-click-repeat-delay"), GetOptionsDB().Get<int>("UI.mouse-click-repeat-interval")); GG::Connect(WindowResizedSignal, &HumanClientApp::HandleWindowResize, this); GG::Connect(FocusChangedSignal, &HumanClientApp::HandleFocusChange, this); GG::Connect(WindowMovedSignal, &HumanClientApp::HandleWindowMove, this); /* TODO: Wire these signals if theyare needed GG::Connect(WindowClosingSignal, &HumanClientApp::HandleWindowClosing, this); GG::Connect(WindowClosedSignal, &HumanClientApp::HandleWindowClose, this); */ SetStringtableDependentOptionDefaults(); SetGLVersionDependentOptionDefaults(); this->SetMouseLRSwapped(GetOptionsDB().Get<bool>("UI.swap-mouse-lr")); std::map<std::string, std::map<int, int> > named_key_maps; parse::keymaps(GetResourceDir() / "keymaps.txt", named_key_maps); if (GetOptionsDB().Get<bool>("verbose-logging")) { DebugLogger() << "Keymaps:"; for (std::map<std::string, std::map<int, int> >::const_iterator km_it = named_key_maps.begin(); km_it != named_key_maps.end(); ++km_it) { DebugLogger() << "Keymap name = \"" << km_it->first << "\""; const std::map<int, int>& key_map = km_it->second; for (std::map<int, int>::const_iterator keys_it = key_map.begin(); keys_it != key_map.end(); ++keys_it) DebugLogger() << " " << char(keys_it->first) << " : " << char(keys_it->second); } } std::map<std::string, std::map<int, int> >::const_iterator km_it = named_key_maps.find("TEST"); if (km_it != named_key_maps.end()) { const std::map<int, int> int_key_map = km_it->second; std::map<GG::Key, GG::Key> key_map; for (std::map<int, int>::const_iterator key_int_it = int_key_map.begin(); key_int_it != int_key_map.end(); ++key_int_it) { key_map[GG::Key(key_int_it->first)] = GG::Key(key_int_it->second); } this->SetKeyMap(key_map); } ConnectKeyboardAcceleratorSignals(); InitAutoTurns(GetOptionsDB().Get<int>("auto-advance-n-turns")); if (fake_mode_change && !FramebuffersAvailable()) { ErrorLogger() << "Requested fake mode changes, but the framebuffer opengl extension is not available. Ignoring."; } m_fsm->initiate(); }
void RenderedTexture::renderTextures() { //Set up RTT texture Ogre::TexturePtr renderTexture; if (renderTexture.isNull()) { renderTexture = Ogre::TextureManager::getSingleton().createManual( getUniqueID("RenderedEntityMaterial"), "EntityRenderer", Ogre::TEX_TYPE_2D, textureSize, textureSize, 0, Ogre::PF_A8R8G8B8, Ogre::TU_RENDERTARGET, 0); } renderTexture->setNumMipmaps(0); //Set up render target Ogre::RenderTexture* renderTarget = renderTexture->getBuffer()->getRenderTarget(); renderTarget->setAutoUpdated(false); //Set up camera Ogre::SceneNode* camNode = sceneMgr->getSceneNode("EntityRenderer::cameraNode"); Ogre::Camera* renderCamera = sceneMgr->createCamera(getUniqueID("EntityRendererCam")); camNode->attachObject(renderCamera); renderCamera->setLodBias(1000.0f); Ogre::Viewport* renderViewport = renderTarget->addViewport(renderCamera); renderViewport->setOverlaysEnabled(false); renderViewport->setClearEveryFrame(true); renderViewport->setShadowsEnabled(false); renderViewport->setBackgroundColour(Ogre::ColourValue(0.0f, 0.0f, 0.0f, 0.0f)); //Set up scene node Ogre::SceneNode* node = sceneMgr->getSceneNode("EntityRenderer::renderNode"); Ogre::SceneNode* oldSceneNode = entity->getParentSceneNode(); if (oldSceneNode) oldSceneNode->detachObject(entity); node->attachObject(entity); node->setPosition(-entityCenter); //Set up camera FOV const Ogre::Real objDist = entityRadius * 100; const Ogre::Real nearDist = objDist - (entityRadius + 1); const Ogre::Real farDist = objDist + (entityRadius + 1); renderCamera->setAspectRatio(1.0f); renderCamera->setFOVy(Ogre::Math::ATan(2.0 * entityRadius / objDist)); renderCamera->setNearClipDistance(nearDist); renderCamera->setFarClipDistance(farDist); //Disable mipmapping (without this, masked textures look bad) Ogre::MaterialManager* mm = Ogre::MaterialManager::getSingletonPtr(); Ogre::FilterOptions oldMinFilter = mm->getDefaultTextureFiltering(Ogre::FT_MIN); Ogre::FilterOptions oldMagFilter = mm->getDefaultTextureFiltering(Ogre::FT_MAG); Ogre::FilterOptions oldMipFilter = mm->getDefaultTextureFiltering(Ogre::FT_MIP); mm->setDefaultTextureFiltering(Ogre::FO_POINT, Ogre::FO_LINEAR,Ogre:: FO_NONE); //Disable fog Ogre::FogMode oldFogMode = sceneMgr->getFogMode(); Ogre::ColourValue oldFogColor = sceneMgr->getFogColour(); Ogre::Real oldFogDensity = sceneMgr->getFogDensity(); Ogre::Real oldFogStart = sceneMgr->getFogStart(); Ogre::Real oldFogEnd = sceneMgr->getFogEnd(); sceneMgr->setFog(Ogre::FOG_NONE); // Get current status of the queue mode Ogre::SceneManager::SpecialCaseRenderQueueMode OldSpecialCaseRenderQueueMode = sceneMgr->getSpecialCaseRenderQueueMode(); //Only render the entity sceneMgr->setSpecialCaseRenderQueueMode(Ogre::SceneManager::SCRQM_INCLUDE); sceneMgr->addSpecialCaseRenderQueue(renderQueueGroup); Ogre::uint8 oldRenderQueueGroup = entity->getRenderQueueGroup(); entity->setRenderQueueGroup(renderQueueGroup); bool oldVisible = entity->getVisible(); entity->setVisible(true); float oldMaxDistance = entity->getRenderingDistance(); entity->setRenderingDistance(0); //Calculate the filename hash used to uniquely identity this render std::string strKey = entityKey; char key[32] = {0}; Ogre::uint32 i = 0; for (std::string::const_iterator it = entityKey.begin(); it != entityKey.end(); ++it) { key[i] ^= *it; i = (i+1) % sizeof(key); } for (i = 0; i < sizeof(key); ++i) key[i] = (key[i] % 26) + 'A'; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( GetUserDir().string(), "FileSystem", "BinFolder"); std::string fileNamePNG = "Rendered." + std::string(key, sizeof(key)) + '.' + Ogre::StringConverter::toString(textureSize) + ".png"; //Attempt to load the pre-render file if allowed bool needsRegen = false; if (!needsRegen) { try{ texture = Ogre::TextureManager::getSingleton().load( fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0); } catch (...) { needsRegen = true; } } if (needsRegen) { //If this has not been pre-rendered, do so now //Position camera camNode->setPosition(0, 0, 0); // TODO camNode->setOrientation(Quaternion(yaw, Vector3::UNIT_Y) * Quaternion(-pitch, Vector3::UNIT_X)); camNode->translate(Ogre::Vector3(0, 0, objDist), Ogre::Node::TS_LOCAL); renderTarget->update(); //Save RTT to file renderTarget->writeContentsToFile((GetUserDir() / fileNamePNG).string()); //Load the render into the appropriate texture view texture = Ogre::TextureManager::getSingleton().load(fileNamePNG, "BinFolder", Ogre::TEX_TYPE_2D, 0); ggTexture = ClientUI::GetTexture(GetUserDir() / fileNamePNG); } entity->setVisible(oldVisible); entity->setRenderQueueGroup(oldRenderQueueGroup); entity->setRenderingDistance(oldMaxDistance); sceneMgr->removeSpecialCaseRenderQueue(renderQueueGroup); // Restore original state sceneMgr->setSpecialCaseRenderQueueMode(OldSpecialCaseRenderQueueMode); //Re-enable mipmapping mm->setDefaultTextureFiltering(oldMinFilter, oldMagFilter, oldMipFilter); //Re-enable fog sceneMgr->setFog(oldFogMode, oldFogColor, oldFogDensity, oldFogStart, oldFogEnd); //Delete camera renderTarget->removeViewport(0); renderCamera->getSceneManager()->destroyCamera(renderCamera); //Delete scene node node->detachAllObjects(); if (oldSceneNode) oldSceneNode->attachObject(entity); //Delete RTT texture assert(!renderTexture.isNull()); std::string texName2(renderTexture->getName()); renderTexture.setNull(); if (Ogre::TextureManager::getSingletonPtr()) Ogre::TextureManager::getSingleton().remove(texName2); }
static BOOL CheckUsername (HWND hWnd) { STRING szTmp; STRING szDir; STRING szGuest; char *src; char *dst; int idx, iErr; if (fButtonHidden) { clr ((LPTR)Control.CurrentUser, sizeof(Control.CurrentUser)); LoadString (hInstAstral, IDS_YOUR_NAME, szTmp, sizeof(szTmp)); clr ((LPTR)szNewUser, sizeof(STRING)); GetDlgItemText (hWnd, IDC_WHO_EDIT, szNewUser, sizeof(szNewUser)); if ( (szNewUser[0] != 0) && (lstrcmp (szNewUser, szTmp))) { // create a directory name by using the first 8 // alnum characters clr ((LPTR)szDir, sizeof(STRING)); src = szNewUser; dst = szDir; idx = 0; while (idx < 8) { if ( isalnum (*src)) { *dst = *src; dst++; src++; idx++; } else { src++; // if two non-alnum char's together, break; if (! isalnum (*src)) break; } } // save this new entry in the INI file SaveUsername (szNewUser, szDir); // create this directory if it doesn't exist lstrcpy (szTmp, Control.WorkPath); lstrcat (szTmp, szDir); if ( (iErr = _mkdir (szTmp)) ) { // no error message, dir could already exist } // save this directory name in the control structure lstrcpy (Control.CurrentUser, szDir); } else { LoadString (hInstAstral, IDS_GUEST, szGuest, sizeof(szGuest)); lstrcpy (szTmp, Control.WorkPath); lstrcat (szTmp, szGuest); _mkdir (szTmp); lstrcpy (Control.CurrentUser, szGuest); SaveUsername (szGuest, szGuest); } } else if (szNewUser[0] != 0) { // make sure the directory exists in case some idiot deletes it if (GetUserDir (szNewUser, szDir)) { lstrcpy (szTmp, Control.WorkPath); lstrcat (szTmp, szDir); _mkdir (szTmp); } return TRUE; } // sign them in as Guest else { LoadString (hInstAstral, IDS_GUEST, szGuest, sizeof(szGuest)); lstrcpy (szTmp, Control.WorkPath); lstrcat (szTmp, szGuest); _mkdir (szTmp); lstrcpy (Control.CurrentUser, szGuest); SaveUsername (szGuest, szGuest); } return TRUE; }
const fs::path GetConfigPath() { static const fs::path p = GetUserDir() / "config.xml"; return p; }
void SequenceViewer::ExportAlignment(eExportType type) { // get filename wxString extension, wildcard; if (type == asFASTA) { extension = ".fsa"; wildcard = "FASTA Files (*.fsa)|*.fsa"; } else if (type == asFASTAa2m) { extension = ".a2m"; wildcard = "A2M FASTA (*.a2m)|*.a2m"; } else if (type == asText) { extension = ".txt"; wildcard = "Text Files (*.txt)|*.txt"; } else if (type == asHTML) { extension = ".html"; wildcard = "HTML Files (*.html)|*.html"; } else if (type == asPSSM) { extension = ".pssm"; wildcard = "PSSM Files (*.pssm)|*.pssm"; } wxString outputFolder = wxString(GetUserDir().c_str(), GetUserDir().size() - 1); // remove trailing / wxString baseName, outputFile; wxFileName::SplitPath(GetWorkingFilename().c_str(), NULL, &baseName, NULL); wxFileDialog dialog(sequenceWindow, "Choose a file for alignment export:", outputFolder, #ifdef __WXGTK__ baseName + extension, #else baseName, #endif wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT); dialog.SetFilterIndex(0); if (dialog.ShowModal() == wxID_OK) outputFile = dialog.GetPath(); if (outputFile.size() > 0) { // create output stream auto_ptr<CNcbiOfstream> ofs(new CNcbiOfstream(WX_TO_STD(outputFile).c_str(), IOS_BASE::out)); if (!(*ofs)) { ERRORMSG("Unable to open output file " << outputFile.c_str()); return; } // map display row order to rows in BlockMultipleAlignment vector < int > rowOrder; const SequenceDisplay *display = GetCurrentDisplay(); for (unsigned int i=0; i<display->rows.size(); ++i) { DisplayRowFromAlignment *alnRow = dynamic_cast<DisplayRowFromAlignment*>(display->rows[i]); if (alnRow) rowOrder.push_back(alnRow->row); } // actually write the alignment if (type == asFASTA || type == asFASTAa2m) { INFOMSG("exporting" << (type == asFASTAa2m ? " A2M " : " ") << "FASTA to " << outputFile.c_str()); DumpFASTA((type == asFASTAa2m), alignmentManager->GetCurrentMultipleAlignment(), rowOrder, sequenceWindow->GetCurrentJustification(), *ofs); } else if (type == asText || type == asHTML) { INFOMSG("exporting " << (type == asText ? "text" : "HTML") << " to " << outputFile.c_str()); DumpText((type == asHTML), alignmentManager->GetCurrentMultipleAlignment(), rowOrder, sequenceWindow->GetCurrentJustification(), *ofs); } else if (type == asPSSM) { static string prevTitle; if (prevTitle.size() == 0) prevTitle = GetWorkingTitle(); string title = WX_TO_STD(wxGetTextFromUser( "Enter a name for this PSSM (to be used by other applications like PSI-BLAST or RPS-BLAST):", "PSSM Title?", prevTitle.c_str(), *viewerWindow).Strip(wxString::both)); if (title.size() > 0) { INFOMSG("exporting PSSM (" << title << ") to " << outputFile.c_str()); alignmentManager->GetCurrentMultipleAlignment()->GetPSSM().OutputPSSM(*ofs, title); prevTitle = title; } } } }
const fs::path GetPersistentConfigPath() { static const fs::path p = GetUserDir() / "persistent_config.xml"; return p; }