Skip to content
Snippets Groups Projects
Commit 5c7ecdb7 authored by sapier's avatar sapier Committed by PilzAdam
Browse files

Add support for modstore screenshots

Add error output on invalid mmdb entries
parent 80a2acaa
No related branches found
No related tags found
No related merge requests found
...@@ -216,10 +216,12 @@ function modstore.getmodlist(list) ...@@ -216,10 +216,12 @@ function modstore.getmodlist(list)
if details.screenshot_url ~= nil and if details.screenshot_url ~= nil and
details.screenshot_url ~= "" then details.screenshot_url ~= "" then
if list.data[i].texturename == nil then if list.data[i].texturename == nil then
print("downloading screenshot: " .. details.screenshot_url) local fullurl = engine.setting_get("modstore_download_url") ..
details.screenshot_url
print("downloading screenshot: " .. fullurl)
local filename = os.tempfolder() local filename = os.tempfolder()
if engine.download_file(details.screenshot_url,filename) then if engine.download_file(fullurl,filename) then
list.data[i].texturename = filename list.data[i].texturename = filename
end end
end end
...@@ -238,7 +240,7 @@ function modstore.getmodlist(list) ...@@ -238,7 +240,7 @@ function modstore.getmodlist(list)
--description --description
local descriptiony = screenshot_ypos + 0.5 local descriptiony = screenshot_ypos + 0.5
retval = retval .. "textarea[3," .. descriptiony .. ";6.5,1.6;;" .. retval = retval .. "textarea[3," .. descriptiony .. ";6.5,1.55;;" ..
fs_escape_string(details.description) .. ";]" fs_escape_string(details.description) .. ";]"
--rating --rating
local ratingy = screenshot_ypos + 0.6 local ratingy = screenshot_ypos + 0.6
......
...@@ -111,6 +111,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { ...@@ -111,6 +111,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) {
} }
} }
else { else {
errorstream << "readModStoreList: missing id" << std::endl;
toadd.valid = false; toadd.valid = false;
} }
...@@ -119,6 +120,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { ...@@ -119,6 +120,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) {
toadd.title = modlist[i]["title"].asString(); toadd.title = modlist[i]["title"].asString();
} }
else { else {
errorstream << "readModStoreList: missing title" << std::endl;
toadd.valid = false; toadd.valid = false;
} }
...@@ -127,6 +129,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) { ...@@ -127,6 +129,7 @@ std::vector<ModStoreMod> readModStoreList(Json::Value& modlist) {
toadd.basename = modlist[i]["basename"].asString(); toadd.basename = modlist[i]["basename"].asString();
} }
else { else {
errorstream << "readModStoreList: missing basename" << std::endl;
toadd.valid = false; toadd.valid = false;
} }
...@@ -166,6 +169,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -166,6 +169,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing version_set id" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -179,6 +183,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -179,6 +183,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
toadd.file = details["version_set"][i]["file"].asString(); toadd.file = details["version_set"][i]["file"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing version_set file" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -196,6 +201,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -196,6 +201,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
if (retval.versions.size() < 1) { if (retval.versions.size() < 1) {
errorstream << "readModStoreModDetails: not a single version specified!" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -215,12 +221,14 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -215,12 +221,14 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing categories id" << std::endl;
retval.valid = false; retval.valid = false;
} }
if (details["categories"][i]["title"].asString().size()) { if (details["categories"][i]["title"].asString().size()) {
toadd.name = details["categories"][i]["title"].asString(); toadd.name = details["categories"][i]["title"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing categories title" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -245,10 +253,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -245,10 +253,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
retval.author.id = numbervalue; retval.author.id = numbervalue;
} }
else { else {
errorstream << "readModStoreModDetails: missing author id (convert)" << std::endl;
retval.valid = false; retval.valid = false;
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing author id" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -256,10 +266,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -256,10 +266,12 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
retval.author.username = details["author"]["username"].asString(); retval.author.username = details["author"]["username"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing author username" << std::endl;
retval.valid = false; retval.valid = false;
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing author" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -276,6 +288,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -276,6 +288,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing license id" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -283,6 +296,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -283,6 +296,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
retval.license.shortinfo = details["license"]["short"].asString(); retval.license.shortinfo = details["license"]["short"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing license short" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -292,6 +306,39 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -292,6 +306,39 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
//titlepic
if (details["titlepic"].isObject()) {
if (details["titlepic"]["id"].asString().size()) {
const char* id_raw = details["titlepic"]["id"].asString().c_str();
char* endptr = 0;
int numbervalue = strtol(id_raw,&endptr,10);
if ((*id_raw != 0) && (*endptr == 0)) {
retval.titlepic.id = numbervalue;
}
}
if (details["titlepic"]["file"].asString().size()) {
retval.titlepic.file = details["titlepic"]["file"].asString();
}
if (details["titlepic"]["desc"].asString().size()) {
retval.titlepic.description = details["titlepic"]["desc"].asString();
}
if (details["titlepic"]["mod"].asString().size()) {
const char* mod_raw = details["titlepic"]["mod"].asString().c_str();
char* endptr = 0;
int numbervalue = strtol(mod_raw,&endptr,10);
if ((*mod_raw != 0) && (*endptr == 0)) {
retval.titlepic.mod = numbervalue;
}
}
}
//id //id
if (details["id"].asString().size()) { if (details["id"].asString().size()) {
...@@ -304,6 +351,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -304,6 +351,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
} }
} }
else { else {
errorstream << "readModStoreModDetails: missing id" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -312,6 +360,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -312,6 +360,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
retval.title = details["title"].asString(); retval.title = details["title"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing title" << std::endl;
retval.valid = false; retval.valid = false;
} }
...@@ -320,6 +369,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) { ...@@ -320,6 +369,7 @@ ModStoreModDetails readModStoreModDetails(Json::Value& details) {
retval.basename = details["basename"].asString(); retval.basename = details["basename"].asString();
} }
else { else {
errorstream << "readModStoreModDetails: missing basename" << std::endl;
retval.valid = false; retval.valid = false;
} }
......
...@@ -430,6 +430,10 @@ int guiLuaApi::l_get_modstore_details(lua_State *L) ...@@ -430,6 +430,10 @@ int guiLuaApi::l_get_modstore_details(lua_State *L)
lua_pushstring(L,current_mod.versions[0].file.c_str()); lua_pushstring(L,current_mod.versions[0].file.c_str());
lua_settable(L, top); lua_settable(L, top);
lua_pushstring(L,"screenshot_url");
lua_pushstring(L,current_mod.titlepic.file.c_str());
lua_settable(L, top);
lua_pushstring(L,"license"); lua_pushstring(L,"license");
lua_pushstring(L,current_mod.license.shortinfo.c_str()); lua_pushstring(L,current_mod.license.shortinfo.c_str());
lua_settable(L, top); lua_settable(L, top);
......
...@@ -202,11 +202,19 @@ struct ModStoreVersionEntry { ...@@ -202,11 +202,19 @@ struct ModStoreVersionEntry {
int mtversion; int mtversion;
}; };
struct ModStoreTitlePic {
int id;
std::string file;
std::string description;
int mod;
};
struct ModStoreModDetails { struct ModStoreModDetails {
/* version_set?? */ /* version_set?? */
std::vector<ModStoreCategoryInfo> categories; std::vector<ModStoreCategoryInfo> categories;
ModAuthorInfo author; ModAuthorInfo author;
ModLicenseInfo license; ModLicenseInfo license;
ModStoreTitlePic titlepic;
int id; int id;
std::string title; std::string title;
std::string basename; std::string basename;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment