cellar list now includes proton bottles
This commit is contained in:
parent
3fc9c88230
commit
b32259c56d
@ -1,9 +1,11 @@
|
||||
#pragma once
|
||||
#include <map>
|
||||
|
||||
#include "bottles.hpp"
|
||||
|
||||
namespace cellar {
|
||||
namespace steam {
|
||||
extern cellar::bottles::Bottle app_bottle(unsigned appid);
|
||||
extern std::map<std::string, cellar::bottles::Bottle> get_app_bottles();
|
||||
}
|
||||
}
|
@ -9,9 +9,13 @@
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "cmake.hpp"
|
||||
#include "internal/bottles.hpp"
|
||||
#include "fs.hpp"
|
||||
#include "output.hpp"
|
||||
#ifdef ENABLE_STEAM
|
||||
#include "steam.hpp"
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace cellar;
|
||||
@ -66,6 +70,13 @@ map<string, Bottle> cellar::bottles::get_bottles() {
|
||||
result[item] = output;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_STEAM
|
||||
map<string, Bottle> bottles_proton = cellar::steam::get_app_bottles();
|
||||
for (auto item : bottles_proton) {
|
||||
result.insert_or_assign(item.first, item.second);
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ void cellar::bottles::create_bottle(int argc, vector<string> argv) {
|
||||
if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path
|
||||
fullbottlepath = bottlechoice;
|
||||
} else if (bottlechoice.substr(0,1) == "~") { // "absolute" path in home directory, not expanded by the shell for some reason (i've seen some shit)
|
||||
// this is a naive replacement and will fail if the user tries something like ~nick/.wine
|
||||
// this is a naive replacement and will fail if the user tries something like ~nicole/.wine
|
||||
// i'm figuring at that point if you're doing that, you'll also recognize if your shell
|
||||
// isn't actually expanding your path...
|
||||
bottlechoice.replace(0,1,getenv("HOME"));
|
||||
|
50
src/steam/bottles.cpp
Normal file
50
src/steam/bottles.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
#include "vdf_parser.hpp"
|
||||
|
||||
#include "bottles.hpp"
|
||||
#include "steam.hpp"
|
||||
#include "internal/steam.hpp"
|
||||
|
||||
using namespace tyti; //vdf
|
||||
|
||||
std::map<std::string, cellar::bottles::Bottle> cellar::steam::get_app_bottles() {
|
||||
std::map<std::string, cellar::bottles::Bottle> result;
|
||||
|
||||
for (std::string str_path_library : cellar::steam::find_steam_libraries()) {
|
||||
std::filesystem::path pth_library(str_path_library);
|
||||
std::filesystem::path pth_steam_cellar = pth_library / "steamapps/compatdata";
|
||||
|
||||
for (auto const& itm_appid : std::filesystem::directory_iterator(pth_steam_cellar)) {
|
||||
auto pth_appid = itm_appid.path();
|
||||
if (std::filesystem::is_directory(pth_appid / "pfx") && ! std::filesystem::is_empty(pth_appid / "pfx")) {
|
||||
std::string str_appid = pth_appid.filename().string(); // should become, e.g. 1124300
|
||||
auto pth_appmanifest = pth_library / ("steamapps/appmanifest_" + str_appid + ".acf");
|
||||
if (! std::filesystem::exists(pth_appmanifest) ) { continue; }
|
||||
std::string str_gamename = "";
|
||||
|
||||
std::ifstream fd_appmanifest(pth_appmanifest);
|
||||
auto hnd_appmanifest = vdf::read(fd_appmanifest);
|
||||
for (auto hnd_appmanifest_def : hnd_appmanifest.attribs) {
|
||||
std::string str_index = hnd_appmanifest_def.first;
|
||||
std::string str_value = hnd_appmanifest_def.second;
|
||||
|
||||
if (str_index == "name") {
|
||||
str_gamename = str_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
auto curbottle = cellar::bottles::Bottle(pth_appid.string());
|
||||
curbottle.set_config("description", str_gamename);
|
||||
curbottle.save_config();
|
||||
result[std::string("proton-" + pth_appid.filename().string())] = curbottle;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user