1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Add updating to online content browser

This commit is contained in:
rubenwardy 2018-05-16 21:52:12 +01:00 committed by GitHub
parent 45e48295d2
commit 3eb363f813
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 196 additions and 107 deletions

View file

@ -98,6 +98,9 @@ void parseContentInfo(ContentSpec &spec)
if (conf.exists("author"))
spec.author = conf.get("author");
if (conf.exists("release"))
spec.release = conf.getS32("release");
}
if (spec.desc.empty()) {

View file

@ -20,11 +20,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#include "config.h"
#include "convert_json.h"
#include "irrlichttypes.h"
struct ContentSpec
{
std::string type;
std::string author;
u32 release = 0;
std::string name;
std::string desc;
std::string path;

View file

@ -56,6 +56,9 @@ void parseModContents(ModSpec &spec)
if (info.exists("author"))
spec.author = info.get("author");
if (info.exists("release"))
spec.release = info.getS32("release");
spec.depends.clear();
spec.optdepends.clear();
spec.is_modpack = false;

View file

@ -39,6 +39,7 @@ struct ModSpec
std::string author;
std::string path;
std::string desc;
int release = 0;
// if normal mod:
std::unordered_set<std::string> depends;

View file

@ -49,6 +49,7 @@ std::vector<Package> getPackagesFromURL(const std::string &url)
package.type = json[i]["type"].asString();
package.shortDesc = json[i]["shortDesc"].asString();
package.url = json[i]["url"].asString();
package.release = json[i]["release"].asInt();
Json::Value jScreenshots = json[i]["screenshots"];
for (unsigned int j = 0; j < jScreenshots.size(); ++j) {

View file

@ -20,6 +20,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#pragma once
#include "config.h"
#include "convert_json.h"
#include "irrlichttypes.h"
struct Package
{
@ -30,12 +31,13 @@ struct Package
std::string shortDesc;
std::string url; // download URL
u32 release;
std::vector<std::string> screenshots;
bool valid()
{
return !(name.empty() || title.empty() || author.empty() ||
type.empty() || url.empty());
type.empty() || url.empty() || release <= 0);
}
};

View file

@ -116,13 +116,17 @@ SubgameSpec findSubgame(const std::string &id)
if (conf.exists("author"))
game_author = conf.get("author");
int game_release = 0;
if (conf.exists("release"))
game_release = conf.getS32("release");
std::string menuicon_path;
#ifndef SERVER
menuicon_path = getImagePath(
game_path + DIR_DELIM + "menu" + DIR_DELIM + "icon.png");
#endif
return SubgameSpec(id, game_path, gamemod_path, mods_paths, game_name,
menuicon_path, game_author);
menuicon_path, game_author, game_release);
}
SubgameSpec findWorldSubgame(const std::string &world_path)

View file

@ -30,6 +30,7 @@ struct SubgameSpec
std::string id;
std::string name;
std::string author;
int release;
std::string path;
std::string gamemods_path;
std::set<std::string> addon_mods_paths;
@ -41,9 +42,9 @@ struct SubgameSpec
std::set<std::string>(),
const std::string &name = "",
const std::string &menuicon_path = "",
const std::string &author = "") :
const std::string &author = "", int release = 0) :
id(id),
name(name), author(author), path(path),
name(name), author(author), release(release), path(path),
gamemods_path(gamemods_path), addon_mods_paths(addon_mods_paths),
menuicon_path(menuicon_path)
{