diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..eeff796 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,93 @@ +{ + "files.associations": { + "*.wsgi": "python", + "*.s": "nasm", + "*.cog": "cpp", + "algorithm": "cpp", + "cmath": "cpp", + "any": "cpp", + "array": "cpp", + "atomic": "cpp", + "hash_map": "cpp", + "strstream": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "bitset": "cpp", + "cctype": "cpp", + "cfenv": "cpp", + "charconv": "cpp", + "chrono": "cpp", + "clocale": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "coroutine": "cpp", + "csetjmp": "cpp", + "csignal": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cstring": "cpp", + "ctime": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "forward_list": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "exception": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "optional": "cpp", + "random": "cpp", + "ratio": "cpp", + "regex": "cpp", + "source_location": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "format": "cpp", + "fstream": "cpp", + "future": "cpp", + "initializer_list": "cpp", + "iomanip": "cpp", + "iosfwd": "cpp", + "iostream": "cpp", + "istream": "cpp", + "limits": "cpp", + "mutex": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "ranges": "cpp", + "semaphore": "cpp", + "shared_mutex": "cpp", + "span": "cpp", + "sstream": "cpp", + "stdexcept": "cpp", + "stdfloat": "cpp", + "stop_token": "cpp", + "streambuf": "cpp", + "text_encoding": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "typeindex": "cpp", + "typeinfo": "cpp", + "valarray": "cpp", + "variant": "cpp" + } +} \ No newline at end of file diff --git a/src/bottles/activate.cpp b/src/bottles/activate.cpp index ccfbe31..193ec0a 100644 --- a/src/bottles/activate.cpp +++ b/src/bottles/activate.cpp @@ -21,7 +21,7 @@ void cellar::bottles::switch_active_bottle(int argc, vector argv) { string homepath = getenv("HOME"); string bottlepath = homepath + "/.wine"; - string targetpath = homepath + "/.local/share/cellar/bottles/" + argv[1]; + string targetpath = cellar::bottles::resolve_bottle(argv[1]); file_status targetstatus = symlink_status(targetpath); if (!exists(targetstatus)) { diff --git a/src/bottles/bottles.cpp b/src/bottles/bottles.cpp index 4265583..4e80381 100644 --- a/src/bottles/bottles.cpp +++ b/src/bottles/bottles.cpp @@ -85,13 +85,20 @@ string cellar::bottles::resolve_bottle(string bottlechoice) { if (bottlechoice.substr(0,1) == "/" || bottlechoice.substr(0,1) == ".") { // absolute or relative path result = 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")); // or at least you'll think to use verbose mode to make sure it's loading the right directory output::warning("your shell didn't expand your given path properly, doing a naive replacement", true); result = bottlechoice; +#ifdef ENABLE_STEAM + } else if (bottlechoice.substr(0,6) == "steam:") { // steam bottles + string str_appid = bottlechoice.substr(6); + unsigned long uint_appid = std::stoul(str_appid); + auto steambottle = cellar::steam::app_bottle(uint_appid); + result = steambottle.path; +#endif } else { string homepath = getenv("HOME"); string fullbottlepath = homepath + "/.local/share/cellar/bottles" + bottlechoice; diff --git a/src/steam/bottles.cpp b/src/steam/bottles.cpp index 5dc5747..01b5e9c 100644 --- a/src/steam/bottles.cpp +++ b/src/steam/bottles.cpp @@ -38,13 +38,24 @@ std::map cellar::steam::get_app_bottles() } } - auto curbottle = cellar::bottles::Bottle(pth_appid.string()); - curbottle.set_config("description", str_gamename); + auto curbottle = cellar::bottles::Bottle((pth_appid / "pfx").string()); + curbottle.set_config("name", str_gamename); curbottle.save_config(); - result[std::string("proton-" + pth_appid.filename().string())] = curbottle; + result[std::string("steam:" + pth_appid.filename().string())] = curbottle; } } } return result; +} + +cellar::bottles::Bottle cellar::steam::app_bottle(unsigned appid) { + string str_appid = std::to_string(appid); + string str_prefix = std::string("steam:") + str_appid; + auto steambottles = get_app_bottles(); + if (steambottles.find(str_prefix) == steambottles.end()) { + throw std::range_error("steam is not currently managing a valid prefix for " + std::to_string(appid)); + } + + return steambottles.at(str_prefix); } \ No newline at end of file