aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSlendi <slendi@socopon.com>2024-04-02 11:32:28 +0300
committerSlendi <slendi@socopon.com>2024-04-02 11:32:28 +0300
commit72d03a6ae825bfc6917514ef25129e7a73a7d823 (patch)
treea1a44a12bdb0e0044b7331e7ccbe276ac2473fca
parent5790abb09e9b958265cf3f203b1d997b9c091bb4 (diff)
Fix command line parsingHEADmaster
Signed-off-by: Slendi <slendi@socopon.com>
-rw-r--r--main.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/main.cpp b/main.cpp
index 67ef26a..6a96bf1 100644
--- a/main.cpp
+++ b/main.cpp
@@ -24,6 +24,7 @@ struct Config {
bool fullscreen = true;
std::string font_path = FONT_PATH;
int font_size = 128;
+ int monitor = 0;
ProgressBarPosition progress_bar_position = PROGRESS_BAR_DEFAULT_POSITION;
@@ -61,15 +62,15 @@ public:
SetTargetFPS(30);
if (m_config.fullscreen) {
- w = GetMonitorWidth(1);
- h = GetMonitorHeight(1);
+ w = GetMonitorWidth(config.monitor);
+ h = GetMonitorHeight(config.monitor);
}
SetConfigFlags(FLAG_WINDOW_RESIZABLE | FLAG_MSAA_4X_HINT);
InitWindow(w, h, "Presentation");
SetTargetFPS(30);
- SetWindowMonitor(1);
+ SetWindowMonitor(config.monitor);
SetWindowIcon(LoadImage("icon.png"));
@@ -85,8 +86,8 @@ public:
SetTextureFilter(m_font.texture, TEXTURE_FILTER_TRILINEAR);
- int display_width = GetMonitorWidth(1);
- int display_height = GetMonitorHeight(1);
+ int display_width = GetMonitorWidth(config.monitor);
+ int display_height = GetMonitorHeight(config.monitor);
if (m_config.fullscreen)
ToggleFullscreen();
@@ -104,8 +105,8 @@ public:
HideCursor();
while (!WindowShouldClose()) {
float font_scale =
- (GetMonitorWidth(1) / (float)GetScreenWidth() +
- GetMonitorHeight(1) / (float)GetScreenHeight()) /
+ (GetMonitorWidth(m_config.monitor) / (float)GetScreenWidth() +
+ GetMonitorHeight(m_config.monitor) / (float)GetScreenHeight()) /
2.0f;
if (IsKeyPressed(KEY_F))
@@ -346,6 +347,7 @@ std::pair<int, Config> parse_arguments(int argc, char **argv,
*is = &std::cin;
for (int i = 1; i < argc; i++) {
std::string arg = argv[i];
+ std::cout << arg << std::endl;
if (arg == "-h" || arg == "--help") {
std::cout
<< "Usage: " << argv[0] << " [FILE]" << std::endl
@@ -433,10 +435,18 @@ std::pair<int, Config> parse_arguments(int argc, char **argv,
std::cerr << "Vertical padding not provided" << std::endl;
return {0, conf};
}
+ } else if (arg == "-m") {
+ if (i + 1 < argc) {
+ i++;
+ conf.monitor = std::stoi(argv[i]);
+ } else {
+ std::cerr << "Monitor not provided" << std::endl;
+ return {0, conf};
+ }
} else {
- auto file = new std::ifstream(argv[1]);
+ auto file = new std::ifstream(arg);
if (!file->is_open()) {
- std::cerr << "Could not open file: " << argv[1] << std::endl;
+ std::cerr << "Could not open file: " << arg << std::endl;
return {0, conf};
}
*is = file;