mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-09 13:14:02 +02:00
Do not show desktop-only options on mobile systems
This commit is contained in:
parent
d18b240d6d
commit
20ec747440
@ -115,6 +115,11 @@ void InterfaceObjectConfigurable::build(const JsonNode &config)
|
|||||||
addWidget(item["name"].String(), buildWidget(item));
|
addWidget(item["name"].String(), buildWidget(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InterfaceObjectConfigurable::addConditional(const std::string & name, bool active)
|
||||||
|
{
|
||||||
|
conditionals[name] = active;
|
||||||
|
}
|
||||||
|
|
||||||
void InterfaceObjectConfigurable::addWidget(const std::string & namePreferred, std::shared_ptr<CIntObject> widget)
|
void InterfaceObjectConfigurable::addWidget(const std::string & namePreferred, std::shared_ptr<CIntObject> widget)
|
||||||
{
|
{
|
||||||
static const std::string unnamedObjectPrefix = "__widget_";
|
static const std::string unnamedObjectPrefix = "__widget_";
|
||||||
@ -502,6 +507,21 @@ std::shared_ptr<CIntObject> InterfaceObjectConfigurable::buildLayout(const JsonN
|
|||||||
if (item["type"].String().empty())
|
if (item["type"].String().empty())
|
||||||
item["type"].String() = customType;
|
item["type"].String() = customType;
|
||||||
|
|
||||||
|
if (!item["created"].isNull())
|
||||||
|
{
|
||||||
|
std::string name = item["created"].String();
|
||||||
|
|
||||||
|
if (conditionals.count(name) != 0)
|
||||||
|
{
|
||||||
|
if (!conditionals.at(name))
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logMod->warn("Unknown condition %s in widget!", name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto widget = buildWidget(item);
|
auto widget = buildWidget(item);
|
||||||
|
|
||||||
addWidget(item["name"].String(), widget);
|
addWidget(item["name"].String(), widget);
|
||||||
|
@ -51,6 +51,8 @@ protected:
|
|||||||
//must be called after adding callbacks
|
//must be called after adding callbacks
|
||||||
void build(const JsonNode & config);
|
void build(const JsonNode & config);
|
||||||
|
|
||||||
|
void addConditional(const std::string & name, bool active);
|
||||||
|
|
||||||
void addWidget(const std::string & name, std::shared_ptr<CIntObject> widget);
|
void addWidget(const std::string & name, std::shared_ptr<CIntObject> widget);
|
||||||
|
|
||||||
void addCallback(const std::string & callbackName, std::function<void(int)> callback);
|
void addCallback(const std::string & callbackName, std::function<void(int)> callback);
|
||||||
@ -110,5 +112,6 @@ private:
|
|||||||
std::map<std::string, BuilderFunction> builders;
|
std::map<std::string, BuilderFunction> builders;
|
||||||
std::map<std::string, std::shared_ptr<CIntObject>> widgets;
|
std::map<std::string, std::shared_ptr<CIntObject>> widgets;
|
||||||
std::map<std::string, std::function<void(int)>> callbacks;
|
std::map<std::string, std::function<void(int)>> callbacks;
|
||||||
|
std::map<std::string, bool> conditionals;
|
||||||
std::map<EShortcut, ShortcutState> shortcuts;
|
std::map<EShortcut, ShortcutState> shortcuts;
|
||||||
};
|
};
|
||||||
|
@ -78,6 +78,13 @@ GeneralOptionsTab::GeneralOptionsTab()
|
|||||||
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
||||||
type |= REDRAW_PARENT;
|
type |= REDRAW_PARENT;
|
||||||
|
|
||||||
|
addConditional("mobile", false);
|
||||||
|
addConditional("desktop", true);
|
||||||
|
#ifdef VCMI_MOBILE
|
||||||
|
addConditional("mobile", true);
|
||||||
|
addConditional("desktop", false);
|
||||||
|
#endif
|
||||||
|
|
||||||
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
|
const JsonNode config(ResourceID("config/widgets/settings/generalOptionsTab.json"));
|
||||||
addCallback("spellbookAnimationChanged", [](bool value)
|
addCallback("spellbookAnimationChanged", [](bool value)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user