## Summary I love the new screenshot feature but I can tell that soon I'm gonna have a folder full of screenshots and not know what's what. It would be great if the folder could self organize. When a screenshot is taken while reading, the filename would now include the book title, chapter (EPUB), page number, and progress percentage. Example: My-Great-Book_ch3_p5_42pct_12345.bmp * **What is the goal of this PR?** (e.g., Implements the new feature for file uploading.) * **What changes are included?** ## Additional Context * Non-reader screens keep the existing screenshot-<millis>.bmp naming. --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**< YES >**_ I reviewed all the changes but I don't have any experience with this project so this is my best guess
64 lines
2.0 KiB
C++
64 lines
2.0 KiB
C++
#pragma once
|
|
#include <Logging.h>
|
|
|
|
#include <cassert>
|
|
#include <memory>
|
|
#include <string>
|
|
#include <utility>
|
|
|
|
#include "ActivityManager.h" // for using the ActivityManager singleton
|
|
#include "ActivityResult.h"
|
|
#include "GfxRenderer.h"
|
|
#include "MappedInputManager.h"
|
|
#include "RenderLock.h"
|
|
#include "util/ScreenshotInfo.h"
|
|
|
|
class Activity {
|
|
friend class ActivityManager;
|
|
|
|
protected:
|
|
std::string name;
|
|
GfxRenderer& renderer;
|
|
MappedInputManager& mappedInput;
|
|
|
|
ActivityResultHandler resultHandler;
|
|
ActivityResult result;
|
|
|
|
public:
|
|
explicit Activity(std::string name, GfxRenderer& renderer, MappedInputManager& mappedInput)
|
|
: name(std::move(name)), renderer(renderer), mappedInput(mappedInput) {}
|
|
virtual ~Activity() = default;
|
|
virtual void onEnter();
|
|
virtual void onExit();
|
|
virtual void loop() {}
|
|
|
|
virtual void render(RenderLock&&) {}
|
|
|
|
// If immediate is true, the update will be triggered immediately.
|
|
// Otherwise, it will be deferred until the end of the current loop iteration.
|
|
virtual void requestUpdate(bool immediate = false);
|
|
|
|
// Request an immediate render and block until it completes.
|
|
virtual void requestUpdateAndWait();
|
|
|
|
virtual bool skipLoopDelay() { return false; }
|
|
virtual bool preventAutoSleep() { return false; }
|
|
virtual bool isReaderActivity() const { return false; }
|
|
virtual ScreenshotInfo getScreenshotInfo() const { return {}; }
|
|
|
|
// Start a new activity without destroying the current one
|
|
// Note: requestUpdate() will be invoked automatically once resultHandler finishes
|
|
void startActivityForResult(std::unique_ptr<Activity>&& activity, ActivityResultHandler resultHandler);
|
|
|
|
// Set the result to be passed back to the previous activity when this activity finishes
|
|
void setResult(ActivityResult&& result);
|
|
|
|
// Finish this activity and return to the previous one on the stack (if any)
|
|
void finish();
|
|
|
|
// Convenience method to facilitate API transition to ActivityManager
|
|
// TODO: remove this in near future
|
|
void onGoHome();
|
|
void onSelectBook(const std::string& path);
|
|
};
|