summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-11-07 16:32:18 +0300
committerAndrei Karas <akaras@inbox.ru>2013-11-07 18:56:07 +0300
commit64535f9763c432bbb46be2769560bfd6a2202d72 (patch)
tree08221a911005ad417cbdc339b02a416b757122a5 /src/client.cpp
parentcf77bdc4baa273d8750175411cb59af3ca3c07ac (diff)
downloadmanaplus-64535f9763c432bbb46be2769560bfd6a2202d72.tar.gz
manaplus-64535f9763c432bbb46be2769560bfd6a2202d72.tar.bz2
manaplus-64535f9763c432bbb46be2769560bfd6a2202d72.tar.xz
manaplus-64535f9763c432bbb46be2769560bfd6a2202d72.zip
add progress bar while loading in SDL2 in Android.
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 461ce03c8..bcaba2a40 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -152,6 +152,12 @@
#define _nacl_dir std::string("/persistent/manaplus")
#endif
+#ifdef ANDROID
+#ifdef USE_SDL2
+int loadingProgressCounter = 1;
+#endif
+#endif
+
std::string errorMessage;
ErrorListener errorListener;
LoginData loginData;
@@ -309,7 +315,6 @@ void Client::gameInit()
"Exiting.", mLocalDataDir.c_str()));
}
- extractDataDir();
initLang();
chatLogger = new ChatLogger;
@@ -348,6 +353,8 @@ void Client::gameInit()
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
+ initGraphics();
+ extractDataDir();
mountDataDir();
if (mOptions.dataPath.empty()
@@ -373,7 +380,6 @@ void Client::gameInit()
resman->addToSearchPath(mLocalDataDir, false);
TranslationManager::loadCurrentLang();
- initGraphics();
initTitle();
Theme::selectSkin();
@@ -580,10 +586,33 @@ void Client::initTitle()
setIcon();
}
+#ifdef ANDROID
+#ifdef USE_SDL2
+static void updateProgress(int cnt)
+{
+ const int progress = cnt + loadingProgressCounter;
+ const int h = mainGraphics->mHeight;
+ mainGraphics->setColor(gcn::Color(255, 255, 255));
+ const int maxSize = mainGraphics->mWidth - 100;
+ const int width = maxSize * progress / 450;
+ mainGraphics->fillRectangle(gcn::Rectangle(50, h - 100, width, 50));
+ mainGraphics->updateScreen();
+}
+
+static void setProgress(const int val)
+{
+ loadingProgressCounter = val;
+ updateProgress(loadingProgressCounter);
+}
+#endif
+#endif
+
void Client::extractDataDir()
{
#ifdef ANDROID
#ifdef USE_SDL2
+ Files::setCopyCallBack(&updateProgress);
+ setProgress(0);
extractAssets();
const std::string zipName = std::string(getenv(
@@ -2965,6 +2994,7 @@ void Client::extractAssets()
logger->log("asset size: %d", size2);
fwrite(buf, 1, size2, file);
SDL_RWclose(rw);
+ setProgress(loadingProgressCounter + 1);
}
else
{
@@ -2983,6 +3013,7 @@ void Client::extractAssets()
int size2 = SDL_RWread(rw, buf, 1, size);
fwrite(buf, 1, size2, file2);
SDL_RWclose(rw);
+ setProgress(loadingProgressCounter + 1);
}
fclose(file2);