Skip to content

Commit

Permalink
Revert "Use Godot print functions instead of cout/cerr"
Browse files Browse the repository at this point in the history
This reverts commit a628d16. Because on
Windows a 'max' function seems not compiling when inluding the
utility_functions.hpp
  • Loading branch information
Lecrapouille committed Jul 20, 2024
1 parent c4d41b3 commit e4a5b6a
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 77 deletions.
36 changes: 18 additions & 18 deletions addons/gdcef/gdcef/src/browser_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c

if ((key >= 32) && (key <= 126)) // ASCII
{
// BROWSER_DEBUG_VAL("ASCII CODE");
BROWSER_DEBUG_VAL("ASCII CODE");
event.windows_key_code = key;
event.character = key16b;
event.unmodified_character = key16b;
Expand All @@ -259,7 +259,7 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
else if (key == godot::KEY_SPACE ||
key == godot::KEY_TAB)
{
// BROWSER_DEBUG_VAL("KEY_SPACE / KEY_TAB");
BROWSER_DEBUG_VAL("KEY_SPACE / KEY_TAB");
event.windows_key_code = key;
event.character = key16b;
event.native_key_code = key;
Expand All @@ -273,19 +273,19 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
key == godot::KEY_KP_ENTER )
{
if (key == godot::KEY_BACKSPACE) {
// BROWSER_DEBUG_VAL("KEY_BACKSPACE");
BROWSER_DEBUG_VAL("KEY_BACKSPACE");
event.windows_key_code = 8;
event.character = 8;
event.unmodified_character = 8;
}
else if (key == godot::KEY_ENTER) {
// BROWSER_DEBUG_VAL("KEY_ENTER");
BROWSER_DEBUG_VAL("KEY_ENTER");
event.windows_key_code = 13;
event.character = 13;
event.unmodified_character = 13;
}
else if (key == godot::KEY_KP_ENTER) {
// BROWSER_DEBUG_VAL("KEY_KP_ENTER");
BROWSER_DEBUG_VAL("KEY_KP_ENTER");
event.windows_key_code = 13;
event.character = 13;
event.unmodified_character = 13;
Expand All @@ -300,7 +300,7 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
}
else if (key >= 320 && key <= 329) // NUMBERS & NUMPAD
{
// BROWSER_DEBUG_VAL("NUMBERS and NUMPAD");
BROWSER_DEBUG_VAL("NUMBERS and NUMPAD");
event.windows_key_code = key;
event.character = key16b;
event.native_key_code = key;
Expand All @@ -324,43 +324,43 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
// https://keycode.info/

if (key == godot::KEY_RIGHT) {
// BROWSER_DEBUG_VAL("KEY_RIGHT");
BROWSER_DEBUG_VAL("KEY_RIGHT");
event.windows_key_code = 39;
}
else if (key == godot::KEY_LEFT) {
// BROWSER_DEBUG_VAL("KEY_LEFT");
BROWSER_DEBUG_VAL("KEY_LEFT");
event.windows_key_code = 37;
}
else if (key == godot::KEY_UP) {
// BROWSER_DEBUG_VAL("KEY_UP");
BROWSER_DEBUG_VAL("KEY_UP");
event.windows_key_code = 38;
}
else if (key == godot::KEY_DOWN) {
// BROWSER_DEBUG_VAL("KEY_DOWN");
BROWSER_DEBUG_VAL("KEY_DOWN");
event.windows_key_code = 40;
}
else if (key == godot::KEY_PAGEUP) {
// BROWSER_DEBUG_VAL("KEY_PAGEUP");
BROWSER_DEBUG_VAL("KEY_PAGEUP");
event.windows_key_code = 33;
}
else if (key == godot::KEY_PAGEDOWN) {
// BROWSER_DEBUG_VAL("KEY_PAGEDOWN");
BROWSER_DEBUG_VAL("KEY_PAGEDOWN");
event.windows_key_code = 34;
}
else if (key == godot::KEY_HOME) {
// BROWSER_DEBUG_VAL("KEY_HOME");
BROWSER_DEBUG_VAL("KEY_HOME");
event.windows_key_code = 36; // Debut
}
else if (key == godot::KEY_END) {
// BROWSER_DEBUG_VAL("KEY_END");
BROWSER_DEBUG_VAL("KEY_END");
event.windows_key_code = 35; // Fin
}
else if (key == godot::KEY_INSERT) {
// BROWSER_DEBUG_VAL("KEY_INSERT");
BROWSER_DEBUG_VAL("KEY_INSERT");
event.windows_key_code = 45; // Insert
}
else if (key == godot::KEY_DELETE) {
// BROWSER_DEBUG_VAL("KEY_DELETE");
BROWSER_DEBUG_VAL("KEY_DELETE");
event.windows_key_code = 46; // Del (not dot when no char event)
}

Expand All @@ -371,7 +371,7 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
}
else
{
// BROWSER_DEBUG_VAL("Any Char");
BROWSER_DEBUG_VAL("Any Char");
event.windows_key_code = key;
event.character = key16b;
event.native_key_code = key;
Expand All @@ -385,7 +385,7 @@ void GDBrowserView::keyPress(int key, bool pressed, bool shift, bool alt, bool c
}
else
{
// BROWSER_DEBUG_VAL("PRESSED FALSE");
BROWSER_DEBUG_VAL("PRESSED FALSE");
event.native_key_code |= int(0xC0000000);
event.type = KEYEVENT_KEYUP;
m_browser->GetHost()->SendKeyEvent(event);
Expand Down
2 changes: 2 additions & 0 deletions addons/gdcef/gdcef/src/gdbrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ void GDBrowserView::navigateForward()
//------------------------------------------------------------------------------
void GDBrowserView::resize_(int width, int height)
{
std::cout << "SIZE: " << width << ", " << height << std::endl;

if (width <= 0) { width = 2; }
if (height <= 0) { height = 2; }
BROWSER_DEBUG_VAL(width << " x " << height);
Expand Down
11 changes: 7 additions & 4 deletions addons/gdcef/gdcef/src/gdcef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ static bool sanity_checks(fs::path const& folder)
void GDCef::_bind_methods()
{
using namespace godot;
GDCEF_DEBUG_VAL("[GDCEF][GDCef::_register_methods]");
std::cout << "[GDCEF][GDCef::_register_methods]" << std::endl;

ClassDB::bind_method(D_METHOD("initialize"), &GDCef::initialize);
ClassDB::bind_method(D_METHOD("get_full_version"), &GDCef::version);
Expand Down Expand Up @@ -233,8 +233,10 @@ static void configureCEF(fs::path const& folder, CefSettings& cef_settings,
fs::path sub_process_path =
getConfig(config, "browser_subprocess_path", folder / SUBPROCESS_NAME);

GDCEF_DEBUG_VAL("Setting SubProcess path: " << sub_process_path.string());
CefString(&cef_settings.browser_subprocess_path).FromString(sub_process_path.string());
std::cout << "[GDCEF][GDCef::configureCEF] Setting SubProcess path: "
<< sub_process_path.string() << std::endl;
CefString(&cef_settings.browser_subprocess_path)
.FromString(sub_process_path.string());

// Incognito mode: cache directories not used.
if (!getConfig(config, "incognito", false))
Expand All @@ -252,7 +254,8 @@ static void configureCEF(fs::path const& folder, CefSettings& cef_settings,
fs::path sub_process_cache =
getConfig(config, "cache_path", folder / "cache");

GDCEF_DEBUG_VAL("Setting cache path: " << sub_process_cache.string());
std::cout << "[GDCEF][GDCef::configureCEF] Setting cache path: "
<< sub_process_cache.string() << std::endl;
CefString(&cef_settings.cache_path)
.FromString(sub_process_cache.string());

Expand Down
4 changes: 3 additions & 1 deletion addons/gdcef/gdcef/src/helper_files.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ bool are_valid_files(fs::path const& folder,
// TODO Compute SHA1 on files to check if they are correct
if (!fs::exists(f))
{
STATIC_GDCEF_ERROR("File " << f << " does not exist and is needed for CEF");
std::cout << "[GDCEF] [" << __func__ << "] File "
<< f << " does not exist and is needed for CEF"
<< std::endl;
failure = true;
}
}
Expand Down
66 changes: 12 additions & 54 deletions addons/gdcef/gdcef/src/helper_log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,69 +28,27 @@

# include <iostream>
# include <sstream>
# include "godot_cpp/variant/utility_functions.hpp"

// ****************************************************************************
// Logging
// ****************************************************************************
#define GDCEF_DEBUG() \
do { \
std::stringstream ss; \
ss << "[DEBUG][GDCEF][GDCEF::" << __func__ << "]" << std::endl; \
godot::UtilityFunctions::print_verbose(ss.str().c_str()); \
} while (0)

std::cout << "[GDCEF][GDCEF::" << __func__ << "]" << std::endl
#define GDCEF_DEBUG_VAL(x) \
do { \
std::stringstream ss; \
ss << "[DEBUG][GDCEF][GDCEF::" << __func__ << "] " << x << std::endl; \
godot::UtilityFunctions::print_verbose(ss.str().c_str()); \
} while (0)

std::cout << "[GDCEF][GDCEF::" << __func__ << "] " << x << std::endl
#define GDCEF_ERROR(x) \
do { \
m_error.str(std::string()); \
m_error << "[ERROR][GDCEF][GDCEF::" << __func__ << "] " \
<< x << std::endl; \
godot::UtilityFunctions::push_error(m_error.str().c_str()); \
} while (0)

m_error << "[GDCEF][GDCEF::" << __func__ << "] " << x << std::endl
#define GDCEF_WARNING(x) \
do { \
std::stringstream ss; \
ss << "[WARNING][GDCEF][GDCEF::" << __func__ << "] " << x << std::endl; \
godot::UtilityFunctions::push_warning(ss.str().c_str()); \
} while (0)

std::cout << "[GDCEF][GDCEF::" << __func__ << "] " << x << std::endl
#define BROWSER_DEBUG() \
do { \
std::stringstream ss; \
ss << "[DEBUG][GDCEF][BrowserView::" << __func__ << "][" << m_id << "]" \
<< std::endl; \
godot::UtilityFunctions::print_verbose(m_error.str().c_str()); \
} while (0)

std::cout << "[GDCEF][BrowserView::" << __func__ << "][" << m_id << "]" \
<< std::endl
#define BROWSER_DEBUG_VAL(x) \
do { \
std::stringstream ss; \
ss << "[DEBUG][GDCEF][BrowserView::" << __func__ << "][" \
<< m_id << "] " << x << std::endl; \
godot::UtilityFunctions::print_verbose(ss.str().c_str()); \
} while (0)

std::cout << "[GDCEF][BrowserView::" << __func__ << "][" << m_id << "] " \
<< x << std::endl
#define BROWSER_ERROR(x) \
do { \
m_error.str(std::string()); \
m_error << "[ERROR][GDCEF][BrowserView::" << __func__ << "][" \
<< m_id << "] " << x << std::endl; \
godot::UtilityFunctions::push_error(m_error.str().c_str()); \
} while (0)

#define STATIC_GDCEF_ERROR(x) \
do { \
std::stringstream ss; \
ss << "[ERROR][GDCEF][" << __func__ << "]" << x << std::endl; \
godot::UtilityFunctions::push_error(ss.str().c_str()); \
} while (0)
m_error << "[GDCEF][BrowserView::" << __func__ << "][" << m_id << "] " \
<< x << std::endl; \
std::cerr << m_error.str()

#endif // GDCEF_HELPER_LOG_HPP
#endif // GDCEF_HELPER_LOG_HPP

0 comments on commit e4a5b6a

Please sign in to comment.