Jazz2/Editor/Shell/ProgressDialog.h file

Namespaces

namespace Jazz2
Root namespace of Jazz² Resurrection.
namespace Jazz2::Editor

Functions

void RunWithProgress(IEditorContext& session, StringView title, Function<void(JobProgress&)>&& work, Function<void(bool)>&& onDone)
Runs work off the user interface and shows how far it is in a window that can stop it.
auto IsPathInside(StringView path, StringView root) -> bool
Returns true if path is root itself or a file or directory inside it.
auto IsLevelOpenElsewhere(StringView levelPath, StringView ownPath) -> bool
Returns true if a level other than ownPath seems to be open in another editor.

Function documentation

void RunWithProgress(IEditorContext& session, StringView title, Function<void(JobProgress&)>&& work, Function<void(bool)>&& onDone)

Runs work off the user interface and shows how far it is in a window that can stop it.

The work runs on a thread of its own where the platform has threads, see BackgroundJob, it must not touch the document, the session or anything else the user interface uses, only what it was given. onDone runs on the main thread afterwards, with whether the work was stopped, the results are taken there. Without threads, the work runs right away and the window isn't shown at all. If the session goes away meanwhile, the work is stopped and waited for, onDone isn't called then.

bool IsPathInside(StringView path, StringView root)

Returns true if path is root itself or a file or directory inside it.

Paths are compared in lowercase and with / between directories, as the editor compares them elsewhere, and only whole names count, Episodes-old/x.j2l isn't inside Episodes. It only compares the text, it can run on any thread.

bool IsLevelOpenElsewhere(StringView levelPath, StringView ownPath)

Returns true if a level other than ownPath seems to be open in another editor.

An editor keeps <level>.lock next to the level and writes it again every half a minute, a lock older than that was left behind. A level changed here while it's open there would be written over by saving it there. It only reads the file system, it can run on any thread.