From 0133207b2e9b6f7f2a5d90738e824435eeb08303 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Sat, 25 Jun 2011 19:43:43 +0300 Subject: [PATCH] [ios] Platform compilation fixes --- iphone/Maps/Classes/EAGLView.mm | 4 +- iphone/Maps/Platform/IPhonePlatform.hpp | 25 +--- iphone/Maps/Platform/IPhonePlatform.mm | 157 +++++++----------------- 3 files changed, 49 insertions(+), 137 deletions(-) diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm index 0b54e172da..d246bf9c35 100644 --- a/iphone/Maps/Classes/EAGLView.mm +++ b/iphone/Maps/Classes/EAGLView.mm @@ -109,7 +109,9 @@ !yg::gl::g_isBufferObjectsSupported, !GetPlatform().IsMultiSampled())); - resourceManager->addFonts(GetPlatform().GetFontNames()); + Platform::FilesList fonts; + GetPlatform().GetFontNames(fonts); + resourceManager->addFonts(fonts); DrawerYG::params_t p; p.m_resourceManager = resourceManager; diff --git a/iphone/Maps/Platform/IPhonePlatform.hpp b/iphone/Maps/Platform/IPhonePlatform.hpp index b33a83d606..defb0a6d22 100644 --- a/iphone/Maps/Platform/IPhonePlatform.hpp +++ b/iphone/Maps/Platform/IPhonePlatform.hpp @@ -2,38 +2,23 @@ #include "../../platform/platform.hpp" -class IPhonePlatform : public Platform +class IPhonePlatform : public BasePlatformImpl { public: IPhonePlatform(); virtual ~IPhonePlatform(); - virtual string WritableDir() const; - virtual string ResourcesDir() const; - virtual string ReadPathForFile(char const * file) const; - virtual int GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) const; - virtual bool GetFileSize(string const & file, uint64_t & size) const; + virtual void GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) const; virtual bool RenameFileX(string const & original, string const & newName) const; virtual int CpuCores() const; virtual double VisualScale() const; - virtual string const SkinName() const; - virtual bool IsMultiSampled() const; - virtual bool DoPeriodicalUpdate() const; - virtual double PeriodicalUpdateInterval() const; - virtual vector GetFontNames() const; - virtual bool IsBenchmarking() const; - virtual bool IsVisualLog() const; - virtual string const DeviceID() const; - virtual unsigned ScaleEtalonSize() const; + virtual string SkinName() const; + virtual string DeviceID() const; + virtual int ScaleEtalonSize() const; private: string m_deviceID; string m_skinName; double m_visualScale; - bool m_isMultiSampled; - bool m_doPeriodicalUpdate; - double m_periodicalUpdateInterval; - string m_resourcesPath; - string m_writablePath; unsigned m_scaleEtalonSize; }; diff --git a/iphone/Maps/Platform/IPhonePlatform.mm b/iphone/Maps/Platform/IPhonePlatform.mm index a90b931e87..281d8c8725 100644 --- a/iphone/Maps/Platform/IPhonePlatform.mm +++ b/iphone/Maps/Platform/IPhonePlatform.mm @@ -18,50 +18,47 @@ IPhonePlatform::IPhonePlatform() NSBundle * bundle = [NSBundle mainBundle]; NSString * path = [bundle resourcePath]; - m_resourcesPath = [path UTF8String]; - m_resourcesPath += '/'; + m_resourcesDir = [path UTF8String]; + m_resourcesDir += '/'; NSArray * dirPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString * docsDir = [dirPaths objectAtIndex:0]; - m_writablePath = [docsDir UTF8String]; - m_writablePath += '/'; + m_writableDir = [docsDir UTF8String]; + m_writableDir += '/'; - /// Hardcoding screen resolution depending on the device we are running. + /// Hardcoding screen resolution depending on the device we are running. m_visualScale = 1.0; - m_skinName = "basic.skn"; - m_isMultiSampled = false; - m_doPeriodicalUpdate = true; - m_periodicalUpdateInterval = 0.3; + m_skinName = "basic.skn"; - /// Calculating resolution - UIDevice * device = [UIDevice currentDevice]; + /// Calculating resolution + UIDevice * device = [UIDevice currentDevice]; - NSRange range = [device.name rangeOfString:@"iPad"]; - if (range.location != NSNotFound) - { + NSRange range = [device.name rangeOfString:@"iPad"]; + if (range.location != NSNotFound) + { m_deviceID = "iPad"; m_visualScale = 1.3; } - else { - range = [device.name rangeOfString:@"iPod"]; - float ver = [device.systemVersion floatValue]; - if (ver >= 3.1999) - { - m_deviceID = "iPod"; - UIScreen * mainScr = [UIScreen mainScreen]; - if (mainScr.currentMode.size.width == 640) - { - m_deviceID = "iPod"; - m_visualScale = 2.0; - m_isMultiSampled = false; - m_skinName = "basic_highres.skn"; - } - } - } + else + { + range = [device.name rangeOfString:@"iPod"]; + float ver = [device.systemVersion floatValue]; + if (ver >= 3.1999) + { + m_deviceID = "iPod"; + UIScreen * mainScr = [UIScreen mainScreen]; + if (mainScr.currentMode.size.width == 640) + { + m_deviceID = "iPod"; + m_visualScale = 2.0; + m_skinName = "basic_highres.skn"; + } + } + } - m_scaleEtalonSize = (256 * 1.5) * m_visualScale; + m_scaleEtalonSize = (256 * 1.5) * m_visualScale; - NSLog(@"Device Name : %@, SystemName : %@, SystemVersion : %@", device.name, device.systemName, device.systemVersion); + NSLog(@"Device Name : %@, SystemName : %@, SystemVersion : %@", device.name, device.systemName, device.systemVersion); [pool release]; } @@ -70,37 +67,13 @@ IPhonePlatform::~IPhonePlatform() { } -string IPhonePlatform::ReadPathForFile(char const * file) const -{ - string path = m_writablePath + file; - if (!IsFileExists(path)) - { - path = m_resourcesPath + file; - if (!IsFileExists(path)) - { - MYTHROW( FileAbsentException, ("File can't be read") ); - } - } - return path; -} - -string IPhonePlatform::ResourcesDir() const -{ - return m_resourcesPath; -} - -string IPhonePlatform::WritableDir() const -{ - return m_writablePath; -} - -int IPhonePlatform::GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) const +void IPhonePlatform::GetFilesInDir(string const & directory, string const & mask, FilesList & outFiles) const { DIR * dir; struct dirent * entry; if ((dir = opendir(directory.c_str())) == NULL) - return 0; + return; // TODO: take wildcards into account... string mask_fixed = mask; @@ -115,31 +88,19 @@ int IPhonePlatform::GetFilesInDir(string const & directory, string const & mask, size_t index = fname.rfind(mask_fixed); if (index != string::npos && index == fname.size() - mask_fixed.size()) { - // TODO: By some strange reason under simulator stat returns -1, may be because of symbolic links?.. -// struct stat fileStatus; -// if (stat(string(directory + fname).c_str(), &fileStatus) == 0 -// && !(fileStatus.st_mode & S_IFDIR)) -// { + // TODO: By some strange reason under simulator stat returns -1, + // may be because of symbolic links?.. + //struct stat fileStatus; + //if (stat(string(directory + fname).c_str(), &fileStatus) == 0 && + // !(fileStatus.st_mode & S_IFDIR)) + //{ outFiles.push_back(fname); -// } + //} } } } while (entry != NULL); closedir(dir); - - return outFiles.size(); -} - -bool IPhonePlatform::GetFileSize(string const & file, uint64_t & size) const -{ - struct stat fileStatus; - if (stat(file.c_str(), &fileStatus) == 0) - { - size = fileStatus.st_size; - return true; - } - return false; } bool IPhonePlatform::RenameFileX(string const & original, string const & newName) const @@ -155,7 +116,7 @@ int IPhonePlatform::CpuCores() const return 1; } -string const IPhonePlatform::SkinName() const +string IPhonePlatform::SkinName() const { return m_skinName; } @@ -165,48 +126,12 @@ double IPhonePlatform::VisualScale() const return m_visualScale; } -bool IPhonePlatform::IsMultiSampled() const -{ - return m_isMultiSampled; -} - -bool IPhonePlatform::DoPeriodicalUpdate() const -{ - return m_doPeriodicalUpdate; -} - -double IPhonePlatform::PeriodicalUpdateInterval() const -{ - return m_periodicalUpdateInterval; -} - -vector IPhonePlatform::GetFontNames() const -{ - vector res; - string fontFolder = m_resourcesPath; - GetFilesInDir(fontFolder, ".ttf", res); - for (size_t i = 0; i < res.size(); ++i) - res[i] = fontFolder + res[i]; - - return res; -} - -bool IPhonePlatform::IsBenchmarking() const -{ - return false; -} - -bool IPhonePlatform::IsVisualLog() const -{ - return false; -} - -unsigned IPhonePlatform::ScaleEtalonSize() const +int IPhonePlatform::ScaleEtalonSize() const { return m_scaleEtalonSize; } -string const IPhonePlatform::DeviceID() const +string IPhonePlatform::DeviceID() const { return m_deviceID; }