Added libscnumerics for random number utils

This commit is contained in:
Bob Polis 2021-10-06 11:08:12 +02:00
parent be7de106c0
commit a45a8aa8df
2 changed files with 8 additions and 4 deletions

View File

@ -39,7 +39,7 @@ else
CXXFLAGS += -D NDEBUG -O3
endif
LDLIBS := -lm -lpthread -lscgui -lSDL2 -lcairo -lscerror -lscstring -lscscreensaver -ldl
LDLIBS := -lm -lpthread -lscgui -lSDL2 -lcairo -lscerror -lscstring -lscscreensaver -ldl -lscnumerics
.PHONY: all clean install modules new

View File

@ -24,6 +24,7 @@
#include <libscerror.hpp>
#include <libscscreensaver.hpp>
#include <libscstring.hpp>
#include <libscnumerics.hpp>
#include <sc/plugin.hpp>
const int WIDTH {1600};
@ -88,10 +89,11 @@ int main(int argc, const char * argv[]) {
try {
// gather plugins
#if DEBUG
sc::plugin<ScreensaverPlugin>::scan_plugins(sc::dirname(sc::tool_path(argv[0])) + "/plugins", "saver");
std::string plugin_dir {sc::dirname(sc::tool_path(argv[0])) + "/plugins"};
#else
sc::plugin<ScreensaverPlugin>::scan_plugins("/usr/local/share/screensaver/plugins", "saver");
std::string plugin_dir {"/usr/local/share/screensaver/plugins"};
#endif
sc::plugin<ScreensaverPlugin>::scan_plugins(plugin_dir, "saver");
std::unique_ptr<ScreensaverPlugin> saver;
bool random_saver {false};
int opt_char, opt_val;
@ -130,7 +132,9 @@ int main(int argc, const char * argv[]) {
if (optind == argc) {
// here when no file args
if (random_saver) {
saver = sc::plugin<ScreensaverPlugin>::random_choice()();
std::vector<std::string> names {sc::plugin<ScreensaverPlugin>::names()};
std::string name {sc::random::choice(names)};
saver = sc::plugin<ScreensaverPlugin>::get(name)();
} else {
saver = sc::plugin<ScreensaverPlugin>::get("Default")();
}