瀏覽代碼

remove resume & move save to seperate function

Laserlicht 1 周之前
父節點
當前提交
70e75938ba
共有 4 個文件被更改,包括 11 次插入13 次删除
  1. 2 2
      client/GameEngineUser.h
  2. 5 3
      client/GameInstance.cpp
  3. 3 1
      client/GameInstance.h
  4. 1 7
      client/eventsSDL/InputHandler.cpp

+ 2 - 2
client/GameEngineUser.h

@@ -23,8 +23,8 @@ public:
 	/// Called when app shutdown has been requested in any way - exit button, Alt-F4, etc
 	/// Called when app shutdown has been requested in any way - exit button, Alt-F4, etc
 	virtual void onShutdownRequested(bool askForConfirmation) = 0;
 	virtual void onShutdownRequested(bool askForConfirmation) = 0;
 
 
-	/// Called when mobile app pauses or resumes
-	virtual void onAppPaused(bool resume) = 0;
+	/// Called when mobile app pauses
+	virtual void onAppPaused() = 0;
 
 
 	/// Returns true if all input events should be captured and ignored
 	/// Returns true if all input events should be captured and ignored
 	virtual bool capturedAllEvents() = 0;
 	virtual bool capturedAllEvents() = 0;

+ 5 - 3
client/GameInstance.cpp

@@ -114,11 +114,13 @@ void GameInstance::onShutdownRequested(bool ask)
 	}
 	}
 }
 }
 
 
-void GameInstance::onAppPaused(bool resume)
+void GameInstance::onAppPaused()
 {
 {
-	if(resume)
-		return;
+	pauseAutoSave();
+}
 
 
+void GameInstance::pauseAutoSave()
+{
 	const std::string autoSaveName = "Saves/PauseAutosave";
 	const std::string autoSaveName = "Saves/PauseAutosave";
 
 
 	logGlobal->info("Received pause save game request");
 	logGlobal->info("Received pause save game request");

+ 3 - 1
client/GameInstance.h

@@ -37,6 +37,8 @@ class GameInstance final : boost::noncopyable, public IGameEngineUser
 	std::shared_ptr<CMainMenu> mainMenuInstance;
 	std::shared_ptr<CMainMenu> mainMenuInstance;
 	CPlayerInterface * interfaceInstance;
 	CPlayerInterface * interfaceInstance;
 
 
+	void pauseAutoSave();
+
 public:
 public:
 	GameInstance();
 	GameInstance();
 	~GameInstance();
 	~GameInstance();
@@ -55,7 +57,7 @@ public:
 	void onUpdate() final;
 	void onUpdate() final;
 	bool capturedAllEvents() final;
 	bool capturedAllEvents() final;
 	void onShutdownRequested(bool askForConfirmation) final;
 	void onShutdownRequested(bool askForConfirmation) final;
-	void onAppPaused(bool resume) final;
+	void onAppPaused() final;
 };
 };
 
 
 extern std::unique_ptr<GameInstance> GAME;
 extern std::unique_ptr<GameInstance> GAME;

+ 1 - 7
client/eventsSDL/InputHandler.cpp

@@ -220,13 +220,7 @@ void InputHandler::preprocessEvent(const SDL_Event & ev)
 	else if(ev.type == SDL_APP_WILLENTERBACKGROUND)
 	else if(ev.type == SDL_APP_WILLENTERBACKGROUND)
 	{
 	{
 		std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
 		std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
-		ENGINE->user().onAppPaused(false);
-		return;
-	}
-	else if(ev.type == SDL_APP_WILLENTERFOREGROUND)
-	{
-		std::scoped_lock interfaceLock(ENGINE->interfaceMutex);
-		ENGINE->user().onAppPaused(true);
+		ENGINE->user().onAppPaused();
 		return;
 		return;
 	}
 	}
 	else if(ev.type == SDL_KEYDOWN)
 	else if(ev.type == SDL_KEYDOWN)