mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-14 19:15:05 -05:00
code cleanup: remove unnecessary template
Some checks failed
Build Binaries / Build Windows (push) Has been cancelled
Build Binaries / Build macOS (push) Has been cancelled
Build Binaries / Build Android (64-bit) (push) Has been cancelled
Build Binaries / Build Android (32-bit) (push) Has been cancelled
Build Binaries / Publish (push) Has been cancelled
Some checks failed
Build Binaries / Build Windows (push) Has been cancelled
Build Binaries / Build macOS (push) Has been cancelled
Build Binaries / Build Android (64-bit) (push) Has been cancelled
Build Binaries / Build Android (32-bit) (push) Has been cancelled
Build Binaries / Publish (push) Has been cancelled
This commit is contained in:
parent
a04edcfd54
commit
5f8d272816
14 changed files with 55 additions and 55 deletions
|
@ -1115,7 +1115,7 @@ public:
|
|||
geode::utils::MiniFunction<typename Filter::Callback> callback,
|
||||
Args&&... args
|
||||
) {
|
||||
return this->template addEventListener<Filter, Args...>(
|
||||
return this->addEventListener<Filter, Args...>(
|
||||
"", callback, std::forward<Args>(args)...
|
||||
);
|
||||
}
|
||||
|
|
|
@ -324,8 +324,8 @@ namespace geode {
|
|||
}
|
||||
|
||||
bool load(matjson::Value const& json) override {
|
||||
if (json.template is<T>()) {
|
||||
m_impl->value = json.template as<T>();
|
||||
if (json.is<T>()) {
|
||||
m_impl->value = json.as<T>();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -148,14 +148,14 @@ namespace geode {
|
|||
template <class T>
|
||||
bool is() {
|
||||
if (this->isError()) return false;
|
||||
return self().m_json.template is<T>();
|
||||
return self().m_json.is<T>();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
JsonMaybeValue& validate(JsonValueValidator<T> validator) {
|
||||
if (this->isError()) return *this;
|
||||
if (self().m_json.template is<T>()) {
|
||||
if (!validator(self().m_json.template as<T>())) {
|
||||
if (self().m_json.is<T>()) {
|
||||
if (!validator(self().m_json.as<T>())) {
|
||||
this->setError(self().m_hierarchy + ": Invalid value format");
|
||||
}
|
||||
}
|
||||
|
@ -196,9 +196,9 @@ namespace geode {
|
|||
this->inferType<A>();
|
||||
if (this->isError()) return *this;
|
||||
|
||||
if (self().m_json.template is<A>()) {
|
||||
if (self().m_json.is<A>()) {
|
||||
try {
|
||||
target = self().m_json.template as<A>();
|
||||
target = self().m_json.as<A>();
|
||||
}
|
||||
catch(matjson::JsonException const& e) {
|
||||
this->setError(
|
||||
|
@ -220,8 +220,8 @@ namespace geode {
|
|||
T get() {
|
||||
this->inferType<T>();
|
||||
if (this->isError()) return T();
|
||||
if (self().m_json.template is<T>()) {
|
||||
return self().m_json.template as<T>();
|
||||
if (self().m_json.is<T>()) {
|
||||
return self().m_json.as<T>();
|
||||
}
|
||||
return T();
|
||||
}
|
||||
|
@ -326,8 +326,8 @@ namespace geode {
|
|||
}
|
||||
else {
|
||||
try {
|
||||
if (this->getJSONRef().template is<T>()) {
|
||||
return this->getJSONRef().template as<T>();
|
||||
if (this->getJSONRef().is<T>()) {
|
||||
return this->getJSONRef().as<T>();
|
||||
}
|
||||
else {
|
||||
this->setError(
|
||||
|
@ -397,21 +397,21 @@ namespace geode {
|
|||
|
||||
template <class T>
|
||||
T get(T const& defaultValue = T()) {
|
||||
if (auto v = this->template tryGet<T>()) {
|
||||
if (auto v = this->tryGet<T>()) {
|
||||
return *std::move(v);
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
template <class T>
|
||||
JsonExpectedValue& into(T& value) {
|
||||
if (auto v = this->template tryGet<T>()) {
|
||||
if (auto v = this->tryGet<T>()) {
|
||||
value = *std::move(v);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
template <class T>
|
||||
JsonExpectedValue& into(std::optional<T>& value) {
|
||||
if (auto v = this->template tryGet<T>()) {
|
||||
if (auto v = this->tryGet<T>()) {
|
||||
value.emplace(*std::move(v));
|
||||
}
|
||||
return *this;
|
||||
|
@ -421,7 +421,7 @@ namespace geode {
|
|||
{ predicate(std::declval<T>()) } -> std::convertible_to<bool>;
|
||||
} {
|
||||
if (this->hasError()) return *this;
|
||||
if (auto v = this->template tryGet<T>()) {
|
||||
if (auto v = this->tryGet<T>()) {
|
||||
if (!predicate(*v)) {
|
||||
this->setError("json value is not {}", name);
|
||||
}
|
||||
|
@ -433,7 +433,7 @@ namespace geode {
|
|||
{ predicate(std::declval<T>()) } -> std::convertible_to<Result<>>;
|
||||
} {
|
||||
if (this->hasError()) return *this;
|
||||
if (auto v = this->template tryGet<T>()) {
|
||||
if (auto v = this->tryGet<T>()) {
|
||||
auto p = predicate(*v);
|
||||
if (!p) {
|
||||
this->setError("json value is not {}: {}", name, p.unwrapErr());
|
||||
|
|
|
@ -32,10 +32,10 @@ namespace geode::utils::file {
|
|||
template <class T>
|
||||
Result<T> readFromJson(std::filesystem::path const& file) {
|
||||
GEODE_UNWRAP_INTO(auto json, readJson(file));
|
||||
if (!json.template is<T>()) {
|
||||
if (!json.is<T>()) {
|
||||
return Err("JSON is not of type {}", typeid(T).name());
|
||||
}
|
||||
return Ok(json.template as<T>());
|
||||
return Ok(json.as<T>());
|
||||
}
|
||||
|
||||
GEODE_DLL Result<> writeString(std::filesystem::path const& path, std::string const& data);
|
||||
|
|
|
@ -144,7 +144,7 @@ struct CustomMenuLayer : Modify<CustomMenuLayer, MenuLayer> {
|
|||
if (
|
||||
crashlog::didLastLaunchCrash() &&
|
||||
!shownLastCrash &&
|
||||
!Mod::get()->template getSettingValue<bool>("disable-last-crashed-popup")
|
||||
!Mod::get()->getSettingValue<bool>("disable-last-crashed-popup")
|
||||
) {
|
||||
shownLastCrash = true;
|
||||
|
||||
|
|
|
@ -33,8 +33,8 @@ $on_mod(Loaded) {
|
|||
JsonChecker checker(args);
|
||||
auto root = checker.root("[ipc/list-mods]").obj();
|
||||
|
||||
auto includeRunTimeInfo = root.has("include-runtime-info").template get<bool>();
|
||||
auto dontIncludeLoader = root.has("dont-include-loader").template get<bool>();
|
||||
auto includeRunTimeInfo = root.has("include-runtime-info").get<bool>();
|
||||
auto dontIncludeLoader = root.has("dont-include-loader").get<bool>();
|
||||
|
||||
if (!dontIncludeLoader) {
|
||||
res.push_back(
|
||||
|
|
|
@ -535,7 +535,7 @@ void Loader::Impl::findProblems() {
|
|||
|
||||
switch(dep.importance) {
|
||||
case ModMetadata::Dependency::Importance::Suggested:
|
||||
if (!Mod::get()->template getSavedValue<bool>(dismissKey)) {
|
||||
if (!Mod::get()->getSavedValue<bool>(dismissKey)) {
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Suggestion,
|
||||
mod,
|
||||
|
@ -548,7 +548,7 @@ void Loader::Impl::findProblems() {
|
|||
}
|
||||
break;
|
||||
case ModMetadata::Dependency::Importance::Recommended:
|
||||
if (!Mod::get()->template getSavedValue<bool>(dismissKey)) {
|
||||
if (!Mod::get()->getSavedValue<bool>(dismissKey)) {
|
||||
this->addProblem({
|
||||
LoadProblem::Type::Recommendation,
|
||||
mod,
|
||||
|
|
|
@ -170,7 +170,7 @@ Result<ModMetadata> ModMetadata::Impl::createFromSchemaV010(ModJson const& rawJs
|
|||
return Err("[mod.json] can not have both \"developer\" and \"developers\" specified");
|
||||
}
|
||||
for (auto& dev : root.needs("developers").items()) {
|
||||
impl->m_developers.push_back(dev.template get<std::string>());
|
||||
impl->m_developers.push_back(dev.get<std::string>());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -290,7 +290,7 @@ Result<ModMetadata> ModMetadata::Impl::createFromSchemaV010(ModJson const& rawJs
|
|||
|
||||
// Tags. Actual validation is done when interacting with the server in the UI
|
||||
for (auto& tag : root.has("tags").items()) {
|
||||
impl->m_tags.insert(tag.template get<std::string>());
|
||||
impl->m_tags.insert(tag.get<std::string>());
|
||||
}
|
||||
|
||||
// with new cli, binary name is always mod id
|
||||
|
|
|
@ -16,7 +16,7 @@ static void parseCommon(T& sett, JsonMaybeObject& obj) {
|
|||
obj.has("description").into(sett.description);
|
||||
if (auto defValue = obj.needs("default")) {
|
||||
// Platform-specific default value
|
||||
if (defValue.template is<matjson::Object>()) {
|
||||
if (defValue.is<matjson::Object>()) {
|
||||
auto def = defValue.obj();
|
||||
if (auto plat = def.has(PlatformID::toShortString(GEODE_PLATFORM_TARGET, true))) {
|
||||
plat.into(sett.defaultValue);
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace enable_if_parsing {
|
|||
}
|
||||
Result<> eval(std::string const& defaultModID) const override {
|
||||
if (auto mod = Loader::get()->getLoadedMod(modID)) {
|
||||
if (mod->template getSettingValue<bool>(settingID)) {
|
||||
if (mod->getSettingValue<bool>(settingID)) {
|
||||
return Ok();
|
||||
}
|
||||
// This is an if-check just in case, even though check() should already
|
||||
|
@ -86,7 +86,7 @@ namespace enable_if_parsing {
|
|||
}
|
||||
Result<> eval(std::string const& defaultModID) const override {
|
||||
if (auto mod = Loader::get()->getLoadedMod(modID)) {
|
||||
if (mod->template getSavedValue<bool>(savedValue)) {
|
||||
if (mod->getSavedValue<bool>(savedValue)) {
|
||||
return Ok();
|
||||
}
|
||||
if (modID == defaultModID) {
|
||||
|
@ -485,7 +485,7 @@ void SettingV3::init(std::string const& key, std::string const& modID, JsonExpec
|
|||
// Keys every setting must have
|
||||
json.needs("type");
|
||||
for (auto& plat : json.has("platforms").items()) {
|
||||
ranges::push(m_impl->platforms, PlatformID::getCovered(plat.template get<std::string>()));
|
||||
ranges::push(m_impl->platforms, PlatformID::getCovered(plat.get<std::string>()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -495,7 +495,7 @@ void SettingV3::parseNameAndDescription(JsonExpectedValue& json) {
|
|||
}
|
||||
void SettingV3::parseEnableIf(JsonExpectedValue& json) {
|
||||
json.has("enable-if")
|
||||
.template mustBe<std::string>("a valid \"enable-if\" scheme", [this](std::string const& str) -> Result<> {
|
||||
.mustBe<std::string>("a valid \"enable-if\" scheme", [this](std::string const& str) -> Result<> {
|
||||
GEODE_UNWRAP_INTO(auto tree, enable_if_parsing::Parser::parse(str, m_impl->modID));
|
||||
GEODE_UNWRAP(tree->check());
|
||||
m_impl->enableIfTree = std::move(tree);
|
||||
|
@ -748,10 +748,10 @@ Result<std::shared_ptr<IntSettingV3>> IntSettingV3::parse(std::string const& key
|
|||
// This silly code is because step size being 0 is what defines if they are enabled
|
||||
|
||||
// Small arrows are enabled by default
|
||||
if (!root.has("control").has("arrows").template get<bool>(true)) {
|
||||
if (!root.has("control").has("arrows").get<bool>(true)) {
|
||||
ret->m_impl->controls.arrowStepSize = 0;
|
||||
}
|
||||
if (!root.has("control").has("big-arrows").template get<bool>()) {
|
||||
if (!root.has("control").has("big-arrows").get<bool>()) {
|
||||
ret->m_impl->controls.bigArrowStepSize = 0;
|
||||
}
|
||||
|
||||
|
@ -879,10 +879,10 @@ Result<std::shared_ptr<FloatSettingV3>> FloatSettingV3::parse(std::string const&
|
|||
|
||||
// Disable arrows if they aren't enabled
|
||||
// Small arrows are enabled by default
|
||||
if (!root.has("control").has("arrows").template get<bool>(true)) {
|
||||
if (!root.has("control").has("arrows").get<bool>(true)) {
|
||||
ret->m_impl->controls.arrowStepSize = 0;
|
||||
}
|
||||
if (!root.has("control").has("big-arrows").template get<bool>()) {
|
||||
if (!root.has("control").has("big-arrows").get<bool>()) {
|
||||
ret->m_impl->controls.bigArrowStepSize = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -109,9 +109,9 @@ void updater::downloadLatestLoaderResources() {
|
|||
// find release asset
|
||||
for (auto asset : root.needs("assets").iterate()) {
|
||||
auto obj = asset.obj();
|
||||
if (obj.needs("name").template get<std::string>() == "resources.zip") {
|
||||
if (obj.needs("name").get<std::string>() == "resources.zip") {
|
||||
updater::tryDownloadLoaderResources(
|
||||
obj.needs("browser_download_url").template get<std::string>(),
|
||||
obj.needs("browser_download_url").get<std::string>(),
|
||||
false
|
||||
);
|
||||
return;
|
||||
|
@ -213,9 +213,9 @@ void updater::downloadLoaderResources(bool useLatestRelease) {
|
|||
// find release asset
|
||||
for (auto asset : root.needs("assets").iterate()) {
|
||||
auto obj = asset.obj();
|
||||
if (obj.needs("name").template get<std::string>() == "resources.zip") {
|
||||
if (obj.needs("name").get<std::string>() == "resources.zip") {
|
||||
updater::tryDownloadLoaderResources(
|
||||
obj.needs("browser_download_url").template get<std::string>(),
|
||||
obj.needs("browser_download_url").get<std::string>(),
|
||||
false
|
||||
);
|
||||
return *response;
|
||||
|
@ -391,11 +391,11 @@ void updater::checkForLoaderUpdates() {
|
|||
for (auto asset : root.needs("assets").iterate()) {
|
||||
auto obj = asset.obj();
|
||||
if (string::endsWith(
|
||||
obj.needs("name").template get<std::string>(),
|
||||
obj.needs("name").get<std::string>(),
|
||||
fmt::format("{}.zip", PlatformID::toShortString(GEODE_PLATFORM_TARGET, true))
|
||||
)) {
|
||||
updater::downloadLoaderUpdate(
|
||||
obj.needs("browser_download_url").template get<std::string>()
|
||||
obj.needs("browser_download_url").get<std::string>()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ static ServerError parseServerError(web::WebResponse const& error) {
|
|||
if (json.is_object() && json.contains("error")) {
|
||||
return ServerError(
|
||||
error.code(),
|
||||
"{}", json.template get<std::string>("error")
|
||||
"{}", json.get<std::string>("error")
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -264,13 +264,13 @@ Result<ServerModVersion> ServerModVersion::parse(matjson::Value const& raw) {
|
|||
|
||||
auto res = ServerModVersion();
|
||||
|
||||
res.metadata.setGeodeVersion(root.needs("geode").template get<VersionInfo>());
|
||||
res.metadata.setGeodeVersion(root.needs("geode").get<VersionInfo>());
|
||||
|
||||
// Verify target GD version
|
||||
auto gd_obj = root.needs("gd").obj();
|
||||
std::string gd = "0.000";
|
||||
if (gd_obj.has(GEODE_PLATFORM_SHORT_IDENTIFIER)) {
|
||||
gd = gd_obj.has(GEODE_PLATFORM_SHORT_IDENTIFIER).template get<std::string>();
|
||||
gd = gd_obj.has(GEODE_PLATFORM_SHORT_IDENTIFIER). get<std::string>();
|
||||
}
|
||||
|
||||
if (gd != "*") {
|
||||
|
@ -283,11 +283,11 @@ Result<ServerModVersion> ServerModVersion::parse(matjson::Value const& raw) {
|
|||
root.needs("hash").into(res.hash);
|
||||
|
||||
// Get mod metadata info
|
||||
res.metadata.setID(root.needs("mod_id").template get<std::string>());
|
||||
res.metadata.setName(root.needs("name").template get<std::string>());
|
||||
res.metadata.setDescription(root.needs("description").template get<std::string>());
|
||||
res.metadata.setVersion(root.needs("version").template get<VersionInfo>());
|
||||
res.metadata.setIsAPI(root.needs("api").template get<bool>());
|
||||
res.metadata.setID(root.needs("mod_id").get<std::string>());
|
||||
res.metadata.setName(root.needs("name").get<std::string>());
|
||||
res.metadata.setDescription(root.needs("description").get<std::string>());
|
||||
res.metadata.setVersion(root.needs("version").get<VersionInfo>());
|
||||
res.metadata.setIsAPI(root.needs("api").get<bool>());
|
||||
|
||||
std::vector<ModMetadata::Dependency> dependencies {};
|
||||
for (auto dep : root.has("dependencies").iterate()) {
|
||||
|
@ -433,10 +433,10 @@ Result<ServerModMetadata> ServerModMetadata::parse(matjson::Value const& raw) {
|
|||
root.has("changelog").into(res.changelog);
|
||||
root.has("repository").into(res.repository);
|
||||
if (root.has("created_at")) {
|
||||
GEODE_UNWRAP_INTO(res.createdAt, ServerDateTime::parse(root.has("created_at").template get<std::string>()));
|
||||
GEODE_UNWRAP_INTO(res.createdAt, ServerDateTime::parse(root.has("created_at").get<std::string>()));
|
||||
}
|
||||
if (root.has("updated_at")) {
|
||||
GEODE_UNWRAP_INTO(res.updatedAt, ServerDateTime::parse(root.has("updated_at").template get<std::string>()));
|
||||
GEODE_UNWRAP_INTO(res.updatedAt, ServerDateTime::parse(root.has("updated_at").get<std::string>()));
|
||||
}
|
||||
|
||||
std::vector<std::string> developerNames;
|
||||
|
@ -470,7 +470,7 @@ Result<ServerModMetadata> ServerModMetadata::parse(matjson::Value const& raw) {
|
|||
}
|
||||
|
||||
for (auto item : root.has("tags").iterate()) {
|
||||
res.tags.insert(item.template get<std::string>());
|
||||
res.tags.insert(item.get<std::string>());
|
||||
}
|
||||
|
||||
root.needs("download_count").into(res.downloadCount);
|
||||
|
|
|
@ -70,12 +70,12 @@ $on_mod(Loaded) {
|
|||
Loader::get()->queueInMainThread([updateColors = updateColors] {
|
||||
// this code is ran during static init, where settings aren't loaded yet, and getSettingValue will always return false.
|
||||
// because of that, we have to delay it until next frame.
|
||||
updateColors(Mod::get()->template getSettingValue<bool>("enable-geode-theme"));
|
||||
updateColors(Mod::get()->getSettingValue<bool>("enable-geode-theme"));
|
||||
});
|
||||
}
|
||||
|
||||
bool isGeodeTheme(bool forceDisableTheme) {
|
||||
return !forceDisableTheme && Mod::get()->template getSettingValue<bool>("enable-geode-theme");
|
||||
return !forceDisableTheme && Mod::get()->getSettingValue<bool>("enable-geode-theme");
|
||||
}
|
||||
|
||||
bool GeodeSquareSprite::init(CCSprite* top, bool* state, bool forceDisableTheme) {
|
||||
|
|
|
@ -684,7 +684,7 @@ void ModsLayer::onSearch(CCObject*) {
|
|||
}
|
||||
}
|
||||
void ModsLayer::onTheme(CCObject*) {
|
||||
auto old = Mod::get()->template getSettingValue<bool>("enable-geode-theme");
|
||||
auto old = Mod::get()->getSettingValue<bool>("enable-geode-theme");
|
||||
createQuickPopup(
|
||||
"Switch Theme",
|
||||
fmt::format(
|
||||
|
|
Loading…
Reference in a new issue