Skip to content

Commit fd2586b

Browse files
committed
added more exception catching on json parse
fixed weird background on hud
1 parent f566b4e commit fd2586b

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ include $(DEVKITPRO)/libnx/switch_rules
3838
# NACP building is skipped as well.
3939
#---------------------------------------------------------------------------------
4040
APP_TITLE := SplitNX
41-
APP_VERSION := 2.1.1
41+
APP_VERSION := 2.1.2
4242
TARGET := $(notdir $(CURDIR))
4343
BUILD := build
4444
SOURCES := source lib/Atmosphere-libs/libstratosphere/source/dmnt

include/splitter.hpp

+9-2
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,17 @@ struct Splits
4848
file = splitsJson["file"].get<std::string>();
4949
game = splitsJson["game"].get<std::string>();
5050
category = splitsJson["category"].get<std::string>();
51-
loading = split(splitsJson["loading"]);
51+
try
52+
{
53+
loading = split(splitsJson["loading"]);
54+
} catch(const json::type_error& e) { loading = split(); }
55+
5256
for (auto j : splitsJson["splits"])
5357
{
54-
splits.push_back(split(j));
58+
try
59+
{
60+
splits.push_back(split(j));
61+
} catch(const json::type_error& e) {}
5562
}
5663
}
5764
Splits() {}

source/main.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ class SplitterGui : public tsl::Gui {
3636
renderer->clearScreen();
3737
if (draw_square)
3838
{
39-
renderer->drawRect(0, 0, 125, 20, a(tsl::style::color::ColorFrameBackground));
4039
if (time_string != "0:00")
4140
{
4241
renderer->drawRect(0, 0, 125, 35, a(tsl::style::color::ColorFrameBackground));
4342
renderer->drawString(split_string.c_str(), false, 0, 30, 15, renderer->a(tsl::Color(255,255,255,255)));
4443
}
44+
else
45+
{
46+
renderer->drawRect(0, 0, 125, 20, a(tsl::style::color::ColorFrameBackground));
47+
}
4548
renderer->drawString(time_string.c_str(), false, 0, 15, 15, renderer->a(tsl::Color(255,255,255,255)));
4649
}
4750
});
@@ -247,7 +250,7 @@ class MainGui : public tsl::Gui {
247250
splitter.Reload(splits.back());
248251
default_loaded = true;
249252
}
250-
} catch (json::parse_error &e) {}
253+
} catch (json::parse_error &e) {} catch (json::type_error &e) {}
251254
}
252255
}
253256
}

0 commit comments

Comments
 (0)