mirror of
https://github.com/vcmi/vcmi.git
synced 2025-01-02 00:10:22 +02:00
show loading indicator when starting local server
single player or hosting a multiplayer game
This commit is contained in:
parent
2af7c29163
commit
3ab21d8491
@ -441,7 +441,6 @@ int main(int argc, char * argv[])
|
||||
|
||||
|
||||
#ifndef VCMI_NO_THREADED_LOAD
|
||||
// todo ios
|
||||
#ifdef VCMI_ANDROID // android loads the data quite slowly so we display native progressbar to prevent having only black screen for few seconds
|
||||
{
|
||||
CAndroidVMHelper vmHelper;
|
||||
@ -1322,7 +1321,6 @@ static void handleEvent(SDL_Event & ev)
|
||||
{
|
||||
if((ev.type==SDL_QUIT) ||(ev.type == SDL_KEYDOWN && ev.key.keysym.sym==SDLK_F4 && (ev.key.keysym.mod & KMOD_ALT)))
|
||||
{
|
||||
// todo ios
|
||||
#ifdef VCMI_ANDROID
|
||||
handleQuit(false);
|
||||
#else
|
||||
|
@ -151,11 +151,13 @@ if(APPLE_IOS)
|
||||
ios/GameChatKeyboardHanlder.m
|
||||
ios/main.m
|
||||
ios/startSDL.mm
|
||||
ios/utils.mm
|
||||
)
|
||||
set(client_HEADERS ${client_HEADERS}
|
||||
CFocusableHelper.h
|
||||
ios/GameChatKeyboardHanlder.h
|
||||
ios/startSDL.h
|
||||
ios/utils.h
|
||||
)
|
||||
endif()
|
||||
|
||||
|
@ -364,7 +364,6 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details, bool verbose)
|
||||
for(int i = 1; i < 32; i += 2 * speed)
|
||||
{
|
||||
movementPxStep(details, i, hp, hero);
|
||||
// todo ios
|
||||
#ifndef VCMI_ANDROID
|
||||
// currently android doesn't seem to be able to handle all these full redraws here, so let's disable it so at least it looks less choppy;
|
||||
// most likely this is connected with the way that this manual animation+framerate handling is solved
|
||||
|
@ -24,8 +24,10 @@
|
||||
#ifdef VCMI_ANDROID
|
||||
#include "../lib/CAndroidVMHelper.h"
|
||||
#elif defined(VCMI_IOS)
|
||||
#include "ios/utils.h"
|
||||
#include "../server/CVCMIServer.h"
|
||||
// todo ios
|
||||
|
||||
#include <dispatch/dispatch.h>
|
||||
#else
|
||||
#include "../lib/Interprocess.h"
|
||||
#endif
|
||||
@ -185,8 +187,6 @@ void CServerHandler::startLocalServerAndConnect()
|
||||
envHelper.callStaticVoidMethod(CAndroidVMHelper::NATIVE_METHODS_DEFAULT_CLASS, "startServer", true);
|
||||
}
|
||||
#elif defined(VCMI_IOS)
|
||||
// todo ios: hide keyboard
|
||||
logNetwork->info("[ios] create server thread");
|
||||
boost::condition_variable cond;
|
||||
threadRunLocalServer = std::make_shared<boost::thread>([&cond, this] {
|
||||
setThreadName("CVCMIServer");
|
||||
@ -196,7 +196,6 @@ void CServerHandler::startLocalServerAndConnect()
|
||||
CSH->campaignServerRestartLock.setn(false);
|
||||
});
|
||||
threadRunLocalServer->detach();
|
||||
logNetwork->info("[ios] detach server thread");
|
||||
#else
|
||||
threadRunLocalServer = std::make_shared<boost::thread>(&CServerHandler::threadRunServer, this); //runs server executable;
|
||||
#endif
|
||||
@ -214,13 +213,20 @@ void CServerHandler::startLocalServerAndConnect()
|
||||
logNetwork->info("waiting for server finished...");
|
||||
androidTestServerReadyFlag = false;
|
||||
#elif defined(VCMI_IOS)
|
||||
// todo ios
|
||||
{
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
iOS_utils::showLoadingIndicator();
|
||||
});
|
||||
|
||||
boost::mutex m;
|
||||
boost::unique_lock<boost::mutex> lock{m};
|
||||
logNetwork->info("waiting for server");
|
||||
cond.wait(lock);
|
||||
logNetwork->info("server is ready");
|
||||
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
iOS_utils::hideLoadingIndicator();
|
||||
});
|
||||
}
|
||||
#else
|
||||
if(shm)
|
||||
|
@ -21,7 +21,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef VCMI_IOS
|
||||
#include "iOS_utils.h"
|
||||
#include "ios/utils.h"
|
||||
#endif
|
||||
|
||||
const SDL_Color Colors::YELLOW = { 229, 215, 123, 0 };
|
||||
|
18
client/ios/utils.h
Normal file
18
client/ios/utils.h
Normal file
@ -0,0 +1,18 @@
|
||||
/*
|
||||
* utils.h, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
namespace iOS_utils
|
||||
{
|
||||
double screenScale();
|
||||
|
||||
void showLoadingIndicator();
|
||||
void hideLoadingIndicator();
|
||||
}
|
46
client/ios/utils.mm
Normal file
46
client/ios/utils.mm
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* utils.mm, part of VCMI engine
|
||||
*
|
||||
* Authors: listed in file AUTHORS in main folder
|
||||
*
|
||||
* License: GNU General Public License v2.0 or later
|
||||
* Full text of license available in license.txt file, in main folder
|
||||
*
|
||||
*/
|
||||
|
||||
#include "utils.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
UIActivityIndicatorView *indicator;
|
||||
}
|
||||
|
||||
namespace iOS_utils
|
||||
{
|
||||
double screenScale()
|
||||
{
|
||||
return UIScreen.mainScreen.nativeScale;
|
||||
}
|
||||
|
||||
void showLoadingIndicator()
|
||||
{
|
||||
NSCAssert(!indicator, @"activity indicator must be hidden before attempting to show it again");
|
||||
indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
|
||||
[indicator startAnimating];
|
||||
|
||||
auto mainView = UIApplication.sharedApplication.keyWindow.rootViewController.view;
|
||||
mainView.userInteractionEnabled = NO;
|
||||
[mainView addSubview:indicator];
|
||||
indicator.center = {CGRectGetMidX(mainView.bounds), CGRectGetMidY(mainView.bounds)};
|
||||
}
|
||||
|
||||
void hideLoadingIndicator()
|
||||
{
|
||||
indicator.superview.userInteractionEnabled = YES;
|
||||
[indicator stopAnimating];
|
||||
[indicator removeFromSuperview];
|
||||
indicator = nil;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ add_library(iOS_utils SHARED
|
||||
)
|
||||
target_link_libraries(iOS_utils PRIVATE
|
||||
"-framework Foundation"
|
||||
"-framework UIKit"
|
||||
)
|
||||
target_include_directories(iOS_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
|
@ -25,7 +25,5 @@ const char *bundlePath();
|
||||
const char *frameworksPath();
|
||||
|
||||
const char *bundleIdentifier();
|
||||
|
||||
double screenScale();
|
||||
}
|
||||
#pragma GCC visibility pop
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "iOS_utils.h"
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
namespace
|
||||
{
|
||||
@ -47,6 +46,4 @@ const char *bundlePath() { return NSBundle.mainBundle.bundlePath.fileSystemRepre
|
||||
const char *frameworksPath() { return NSBundle.mainBundle.privateFrameworksPath.fileSystemRepresentation; }
|
||||
|
||||
const char *bundleIdentifier() { return NSBundle.mainBundle.bundleIdentifier.UTF8String; }
|
||||
|
||||
double screenScale() { return UIScreen.mainScreen.nativeScale; }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user