From 43ba4aba0c466b428fef8e7b6fcad540c6c6fbcb Mon Sep 17 00:00:00 2001 From: Aadhavan Srinivasan Date: Sun, 17 Mar 2024 18:09:01 -0400 Subject: [PATCH] Created a file that contains functions for agnostic text output --- display_text.cpp | 13 +++++++++++++ includes/display_text.hpp | 10 ++++++++++ 2 files changed, 23 insertions(+) create mode 100644 display_text.cpp create mode 100644 includes/display_text.hpp diff --git a/display_text.cpp b/display_text.cpp new file mode 100644 index 0000000..ee2c2ba --- /dev/null +++ b/display_text.cpp @@ -0,0 +1,13 @@ +#include "includes/display_text.hpp" +#include +#include + +void display_text(std::string to_disp, const int if_mode) { + if (if_mode == IF_CLI) { + std::cout << to_disp << std::endl; + } + if (if_mode == IF_GUI) { + display_text_raygui(to_disp); + } + return; +} diff --git a/includes/display_text.hpp b/includes/display_text.hpp new file mode 100644 index 0000000..afb1125 --- /dev/null +++ b/includes/display_text.hpp @@ -0,0 +1,10 @@ +#include "includes/raygui_helpers.hpp" + +/* Constants that can be used by caller function. */ +const int IF_CLI = 1; +const int IF_GUI = 2; + +/* This function is used to display text. It is used to abstract the differences + between GUI invocation and CLI invocation. The if_mode parameter is used to + determine whether the game was launched from GUI or CLI. */ +void display_text(std::string to_disp, const int if_mode);