| 8 | { |
| 9 | public: |
| 10 | static void Render() |
| 11 | { |
| 12 | static bool bOnOpen = true; |
| 13 | static bool bSortOnOpen = false; |
| 14 | |
| 15 | if (ImGui::BeginTabItem("Skins")) |
| 16 | { |
| 17 | ImGui::Text("Sort by: "); |
| 18 | ImGui::SameLine(); |
| 19 | |
| 20 | static int iSort = 0; |
| 21 | static int iLastSort = -1; |
| 22 | ImGui::RadioButton("Alphabetically", &iSort, 0); |
| 23 | ImGui::SameLine(); |
| 24 | ImGui::RadioButton("Purchase date", &iSort, 1); |
| 25 | ImGui::SameLine(); |
| 26 | ImGui::RadioButton("ID", &iSort, 2); |
| 27 | |
| 28 | if (bOnOpen) |
| 29 | { |
| 30 | bOnOpen = false; |
| 31 | bSortOnOpen = true; |
| 32 | ownedSkins.clear(); |
| 33 | |
| 34 | static Json::Value root; |
| 35 | static Json::CharReaderBuilder builder; |
| 36 | static const std::unique_ptr<Json::CharReader> reader(builder.newCharReader()); |
| 37 | static JSONCPP_STRING err; |
| 38 | |
| 39 | std::string getSkins = LCU::Request("GET", "https://127.0.0.1/lol-inventory/v2/inventory/CHAMPION_SKIN"); |
| 40 | |
| 41 | if (reader->parse(getSkins.c_str(), getSkins.c_str() + static_cast<int>(getSkins.length()), &root, &err)) |
| 42 | { |
| 43 | if (root.isArray()) |
| 44 | { |
| 45 | for (auto& i : root) |
| 46 | { |
| 47 | Skin skin; |
| 48 | |
| 49 | skin.inventoryType = i["inventoryType"].asString(); |
| 50 | skin.itemId = i["itemId"].asInt(); |
| 51 | skin.ownershipType = i["ownershipType"].asString(); |
| 52 | skin.isVintage = i["payload"]["isVintage"].asBool(); |
| 53 | |
| 54 | std::string purchase = i["purchaseDate"].asString(); |
| 55 | if (purchase.find('-') == std::string::npos && purchase.find(':') == std::string::npos) |
| 56 | { |
| 57 | sscanf_s(purchase.c_str(), "%04d%02d%02dT%02d%02d%02d", |
| 58 | &skin.purchaseDate.tm_year, &skin.purchaseDate.tm_mon, &skin.purchaseDate.tm_mday, |
| 59 | &skin.purchaseDate.tm_hour, &skin.purchaseDate.tm_min, &skin.purchaseDate.tm_sec); |
| 60 | } |
| 61 | else |
| 62 | { |
| 63 | sscanf_s(purchase.c_str(), "%04d-%02d-%02dT%02d:%02d:%02d", |
| 64 | &skin.purchaseDate.tm_year, &skin.purchaseDate.tm_mon, &skin.purchaseDate.tm_mday, |
| 65 | &skin.purchaseDate.tm_hour, &skin.purchaseDate.tm_min, &skin.purchaseDate.tm_sec); |
| 66 | } |
| 67 | skin.purchaseDate.tm_year -= 1901; |