Add correct paths for 'data' and 'cache' directories
This commit is contained in:
parent
b0e32b6717
commit
828de30570
5 changed files with 19 additions and 11 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -4,3 +4,6 @@
|
|||
[submodule "external/rei-json"]
|
||||
path = external/rei-json
|
||||
url = https://codeberg.org/vyn/rei-json.git
|
||||
[submodule "external/evalyte-cpp-common"]
|
||||
path = external/evalyte-cpp-common
|
||||
url = https://codeberg.org/vyn/evalyte-cpp-common.git
|
||||
|
|
|
@ -30,8 +30,11 @@ slint_target_sources(
|
|||
LIBRARY_PATHS selenite=${CMAKE_CURRENT_SOURCE_DIR}/external/selenite/components/index.slint
|
||||
)
|
||||
|
||||
add_subdirectory(external/rei-json)
|
||||
add_subdirectory(external/evalyte-cpp-common)
|
||||
target_include_directories(lali PRIVATE "external/evalyte-cpp-common/include")
|
||||
target_link_libraries(lali PRIVATE evalyte-cpp-common)
|
||||
|
||||
add_subdirectory(external/rei-json)
|
||||
target_include_directories(lali PRIVATE "external/rei-json/include")
|
||||
target_link_libraries(lali PRIVATE rei-json)
|
||||
|
||||
|
|
1
external/evalyte-cpp-common
vendored
Submodule
1
external/evalyte-cpp-common
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 20e766badc8f400ac7db8487486b5e8990cefbbe
|
1
run-release.sh
Normal file
1
run-release.sh
Normal file
|
@ -0,0 +1 @@
|
|||
cmake -DCMAKE_BUILD_TYPE=Release -S . -B ./build -G Ninja && cd build && ninja && cd - && build/lali
|
|
@ -3,6 +3,7 @@
|
|||
#include <mutex>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "rei-json/Field.h"
|
||||
#include "rei-json/Object.h"
|
||||
#include "ui.h"
|
||||
|
@ -85,11 +86,12 @@ public:
|
|||
}
|
||||
|
||||
void loadDataFromDisk() {
|
||||
std::filesystem::create_directories("./imgs");
|
||||
evalyte::createRequiredDirectories("lali");
|
||||
std::filesystem::create_directories(imageDirectory);
|
||||
|
||||
std::ifstream file("./save.json");
|
||||
std::ifstream file(saveFilePath);
|
||||
if (!file.is_open()) {
|
||||
std::println(std::cerr, "can't open file");
|
||||
std::println(std::cerr, "can't open file {}", saveFilePath);
|
||||
json = rei::json::JsonObject{};
|
||||
json.set("version", 1);
|
||||
json.addArray("lists", rei::json::JsonArray{});
|
||||
|
@ -107,11 +109,6 @@ public:
|
|||
ui->global<ui::State>().set_lists(listsSlint);
|
||||
|
||||
animesSlint = std::make_shared<slint::VectorModel<ui::Anime>>();
|
||||
ui->global<ui::State>().set_current_list({
|
||||
.index = 0,
|
||||
.name = "ok",
|
||||
.animes = animesSlint
|
||||
});
|
||||
|
||||
auto& lists = json.getArray("lists");
|
||||
|
||||
|
@ -285,7 +282,7 @@ public:
|
|||
|
||||
slint::Image getAnimeImage(int animeId, std::string imageUrl) {
|
||||
//std::println("Get image for anime {}", animeId);
|
||||
std::string imagePath = "./imgs/" + std::to_string(animeId);
|
||||
std::string imagePath = imageDirectory + "/" + std::to_string(animeId);
|
||||
|
||||
if (imageUrl.ends_with(".jpg") || imageUrl.ends_with(".jpeg")) {
|
||||
imagePath += ".jpg";
|
||||
|
@ -328,7 +325,7 @@ public:
|
|||
}
|
||||
|
||||
void save() {
|
||||
std::ofstream save("./save.json");
|
||||
std::ofstream save(saveFilePath);
|
||||
if (!save.is_open()) {
|
||||
throw std::runtime_error("Can't save data");
|
||||
}
|
||||
|
@ -348,4 +345,7 @@ private:
|
|||
std::mutex continueAnimeLock[THREAD_COUNT];
|
||||
bool shouldStopLoadingImages[THREAD_COUNT] = {false};
|
||||
std::thread thread_object[THREAD_COUNT];
|
||||
|
||||
const std::string imageDirectory = evalyte::cacheDirectoryPath("lali") + "/images";
|
||||
const std::string saveFilePath = evalyte::dataDirectoryPath("lali") + "/save.json";
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue