Added libscnumerics for random number utils
This commit is contained in:
parent
be7de106c0
commit
a45a8aa8df
2
Makefile
2
Makefile
@ -39,7 +39,7 @@ else
|
|||||||
CXXFLAGS += -D NDEBUG -O3
|
CXXFLAGS += -D NDEBUG -O3
|
||||||
endif
|
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
|
.PHONY: all clean install modules new
|
||||||
|
|
||||||
|
10
main.cpp
10
main.cpp
@ -24,6 +24,7 @@
|
|||||||
#include <libscerror.hpp>
|
#include <libscerror.hpp>
|
||||||
#include <libscscreensaver.hpp>
|
#include <libscscreensaver.hpp>
|
||||||
#include <libscstring.hpp>
|
#include <libscstring.hpp>
|
||||||
|
#include <libscnumerics.hpp>
|
||||||
#include <sc/plugin.hpp>
|
#include <sc/plugin.hpp>
|
||||||
|
|
||||||
const int WIDTH {1600};
|
const int WIDTH {1600};
|
||||||
@ -88,10 +89,11 @@ int main(int argc, const char * argv[]) {
|
|||||||
try {
|
try {
|
||||||
// gather plugins
|
// gather plugins
|
||||||
#if DEBUG
|
#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
|
#else
|
||||||
sc::plugin<ScreensaverPlugin>::scan_plugins("/usr/local/share/screensaver/plugins", "saver");
|
std::string plugin_dir {"/usr/local/share/screensaver/plugins"};
|
||||||
#endif
|
#endif
|
||||||
|
sc::plugin<ScreensaverPlugin>::scan_plugins(plugin_dir, "saver");
|
||||||
std::unique_ptr<ScreensaverPlugin> saver;
|
std::unique_ptr<ScreensaverPlugin> saver;
|
||||||
bool random_saver {false};
|
bool random_saver {false};
|
||||||
int opt_char, opt_val;
|
int opt_char, opt_val;
|
||||||
@ -130,7 +132,9 @@ int main(int argc, const char * argv[]) {
|
|||||||
if (optind == argc) {
|
if (optind == argc) {
|
||||||
// here when no file args
|
// here when no file args
|
||||||
if (random_saver) {
|
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 {
|
} else {
|
||||||
saver = sc::plugin<ScreensaverPlugin>::get("Default")();
|
saver = sc::plugin<ScreensaverPlugin>::get("Default")();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user