diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2021-06-05 14:58:40 -0500 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2021-06-05 14:58:40 -0500 |
| commit | d27501313cae78b838c1e738ebfaeae4740a23b4 (patch) | |
| tree | 207740d8a42b84a851303b8f2583c523f1624caa /src/aoimage.cpp | |
| parent | a023657348051cbc7c8ea29e3b37f3e2e3fd16d8 (diff) | |
Finish mounting feature
To pull this one off, a new class called VPath was created that denotes
"virtual" paths that can exist anywhere among the list of mount points.
It is functionally identical to QString, except that implicit conversion
between QString and VPath is not allowed. This makes it easy to spot
errors in path resolution at compile time, since get_real_path must be
called to resolve a VPath into an absolute path that can be passed into
a Qt function as a QString.
Other functions, such as the get_*_suffix functions, also return an
absolute path QString for convenience.
As for the rest of the functions that return a VPath, you will need to
call get_real_path yourself.
Finally, a path resolution cache was added to try to avoid blowing
up what is already a massive lookup cost for assets. The cache
is invalidated when the mount path list is changed.
Currently, this cache isn't bounded. Might need to write an LRU cache
if issues arise.
Diffstat (limited to 'src/aoimage.cpp')
| -rw-r--r-- | src/aoimage.cpp | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/aoimage.cpp b/src/aoimage.cpp index e1bd8b8c..fbf8c992 100644 --- a/src/aoimage.cpp +++ b/src/aoimage.cpp @@ -20,21 +20,16 @@ AOImage::AOImage(QWidget *parent, AOApplication *p_ao_app) : QLabel(parent) AOImage::~AOImage() {} -bool AOImage::set_image(QString p_path, QString p_misc) +bool AOImage::set_image(QString p_image, QString p_misc) { - // Check if the user wants animated themes - if (ao_app->get_animated_theme()) - // We want an animated image - p_path = ao_app->get_image(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc); - else - // Grab a static variant of the image - p_path = ao_app->get_image_path(ao_app->get_asset_paths(p_path, ao_app->current_theme, ao_app->get_subtheme(), ao_app->default_theme, p_misc), true); + p_image = ao_app->get_image(p_image, ao_app->current_theme, ao_app->get_subtheme(), + ao_app->default_theme, p_misc, "", "", !ao_app->get_animated_theme()); - if (!file_exists(p_path)) { - qDebug() << "Warning: Image" << p_path << "not found! Can't set!"; + if (!file_exists(p_image)) { + qDebug() << "Warning: Image" << p_image << "not found! Can't set!"; return false; } - path = p_path; + path = p_image; movie->stop(); movie->setFileName(path); if (ao_app->get_animated_theme() && movie->frameCount() > 1) { |
