maintenance: settings item refactoring, include dependencies fixes

This commit is contained in:
tmj-fstate
2018-01-26 16:44:47 +01:00
parent 9d008d2a3e
commit 0124032d3b
92 changed files with 2226 additions and 2233 deletions

View File

@@ -79,8 +79,8 @@ void screenshot_save_thread( char *img )
png_image png;
memset(&png, 0, sizeof(png_image));
png.version = PNG_IMAGE_VERSION;
png.width = Global::iWindowWidth;
png.height = Global::iWindowHeight;
png.width = Global.iWindowWidth;
png.height = Global.iWindowHeight;
png.format = PNG_FORMAT_RGB;
char datetime[64];
@@ -96,7 +96,7 @@ void screenshot_save_thread( char *img )
std::string filename = "screenshots/" + std::string(datetime) +
"_" + std::to_string(perf) + ".png";
if (png_image_write_to_file(&png, filename.c_str(), 0, img, -Global::iWindowWidth * 3, nullptr) == 1)
if (png_image_write_to_file(&png, filename.c_str(), 0, img, -Global.iWindowWidth * 3, nullptr) == 1)
WriteLog("saved " + filename + ".");
else
WriteLog("failed to save screenshot.");
@@ -106,8 +106,8 @@ void screenshot_save_thread( char *img )
void make_screenshot()
{
char *img = new char[Global::iWindowWidth * Global::iWindowHeight * 3];
glReadPixels(0, 0, Global::iWindowWidth, Global::iWindowHeight, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
char *img = new char[Global.iWindowWidth * Global.iWindowHeight * 3];
glReadPixels(0, 0, Global.iWindowWidth, Global.iWindowHeight, GL_RGB, GL_UNSIGNED_BYTE, (GLvoid*)img);
std::thread t(screenshot_save_thread, img);
t.detach();
@@ -118,9 +118,9 @@ void window_resize_callback(GLFWwindow *window, int w, int h)
{
// NOTE: we have two variables which basically do the same thing as we don't have dynamic fullscreen toggle
// TBD, TODO: merge them?
Global::iWindowWidth = w;
Global::iWindowHeight = h;
Global::fDistanceFactor = std::max( 0.5f, h / 768.0f ); // not sure if this is really something we want to use
Global.iWindowWidth = w;
Global.iWindowHeight = h;
Global.fDistanceFactor = std::max( 0.5f, h / 768.0f ); // not sure if this is really something we want to use
glViewport(0, 0, w, h);
}
@@ -128,7 +128,7 @@ void cursor_pos_callback(GLFWwindow *window, double x, double y)
{
input::Mouse.move( x, y );
if( true == Global::ControlPicking ) {
if( true == Global.ControlPicking ) {
glfwSetCursorPos( window, x, y );
}
else {
@@ -149,16 +149,16 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
input::Keyboard.key( key, action );
Global::shiftState = ( mods & GLFW_MOD_SHIFT ) ? true : false;
Global::ctrlState = ( mods & GLFW_MOD_CONTROL ) ? true : false;
Global.shiftState = ( mods & GLFW_MOD_SHIFT ) ? true : false;
Global.ctrlState = ( mods & GLFW_MOD_CONTROL ) ? true : false;
if( ( true == Global::InputMouse )
if( ( true == Global.InputMouse )
&& ( ( key == GLFW_KEY_LEFT_ALT )
|| ( key == GLFW_KEY_RIGHT_ALT ) ) ) {
// if the alt key was pressed toggle control picking mode and set matching cursor behaviour
if( action == GLFW_RELEASE ) {
if( Global::ControlPicking ) {
if( Global.ControlPicking ) {
// switch off
glfwGetCursorPos( window, &input::mouse_pickmodepos.x, &input::mouse_pickmodepos.y );
glfwSetInputMode( window, GLFW_CURSOR, GLFW_CURSOR_DISABLED );
@@ -170,7 +170,7 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
glfwSetCursorPos( window, input::mouse_pickmodepos.x, input::mouse_pickmodepos.y );
}
// actually toggle the mode
Global::ControlPicking = !Global::ControlPicking;
Global.ControlPicking = !Global.ControlPicking;
}
}
@@ -203,18 +203,18 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
void focus_callback( GLFWwindow *window, int focus )
{
if( Global::bInactivePause ) // jeśli ma być pauzowanie okna w tle
if( Global.bInactivePause ) // jeśli ma być pauzowanie okna w tle
if( focus )
Global::iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie
Global.iPause &= ~4; // odpauzowanie, gdy jest na pierwszym planie
else
Global::iPause |= 4; // włączenie pauzy, gdy nieaktywy
Global.iPause |= 4; // włączenie pauzy, gdy nieaktywy
}
void scroll_callback( GLFWwindow* window, double xoffset, double yoffset ) {
if( Global::ctrlState ) {
if( Global.ctrlState ) {
// ctrl + scroll wheel adjusts fov in debug mode
Global::FieldOfView = clamp( static_cast<float>(Global::FieldOfView - yoffset * 20.0 / Global::fFpsAverage), 15.0f, 75.0f );
Global.FieldOfView = clamp( static_cast<float>(Global.FieldOfView - yoffset * 20.0 / Global.fFpsAverage), 15.0f, 75.0f );
}
}
@@ -253,18 +253,17 @@ int main(int argc, char *argv[])
DeleteFile( "errors.txt" );
_mkdir("logs");
#endif
Global::LoadIniFile("eu07.ini");
Global::InitKeys();
Global.LoadIniFile("eu07.ini");
// hunter-271211: ukrywanie konsoli
if( Global::iWriteLogEnabled & 2 )
if( Global.iWriteLogEnabled & 2 )
{
AllocConsole();
SetConsoleTextAttribute( GetStdHandle( STD_OUTPUT_HANDLE ), FOREGROUND_GREEN );
}
/*
std::string executable( argv[ 0 ] ); auto const pathend = executable.rfind( '\\' );
Global::ExecutableName =
Global.ExecutableName =
( pathend != std::string::npos ?
executable.substr( executable.rfind( '\\' ) + 1 ) :
executable );
@@ -301,7 +300,7 @@ int main(int argc, char *argv[])
&stringdata,
&datasize ) ) {
Global::asVersion = std::string( reinterpret_cast<char*>(stringdata) );
Global.asVersion = std::string( reinterpret_cast<char*>(stringdata) );
}
}
}
@@ -311,18 +310,18 @@ int main(int argc, char *argv[])
std::string token(argv[i]);
if (token == "-e3d") {
if (Global::iConvertModels > 0)
Global::iConvertModels = -Global::iConvertModels;
if (Global.iConvertModels > 0)
Global.iConvertModels = -Global.iConvertModels;
else
Global::iConvertModels = -7; // z optymalizacją, bananami i prawidłowym Opacity
Global.iConvertModels = -7; // z optymalizacją, bananami i prawidłowym Opacity
}
else if (i + 1 < argc && token == "-s")
Global::SceneryFile = std::string(argv[++i]);
Global.SceneryFile = std::string(argv[++i]);
else if (i + 1 < argc && token == "-v")
{
std::string v(argv[++i]);
std::transform(v.begin(), v.end(), v.begin(), ::tolower);
Global::asHumanCtrlVehicle = v;
Global.asHumanCtrlVehicle = v;
}
else
{
@@ -347,23 +346,23 @@ int main(int argc, char *argv[])
glfwWindowHint(GLFW_REFRESH_RATE, vmode->refreshRate);
glfwWindowHint(GLFW_AUTO_ICONIFY, GLFW_FALSE);
if( Global::iMultisampling > 0 ) {
glfwWindowHint( GLFW_SAMPLES, 1 << Global::iMultisampling );
if( Global.iMultisampling > 0 ) {
glfwWindowHint( GLFW_SAMPLES, 1 << Global.iMultisampling );
}
if (Global::bFullScreen)
if (Global.bFullScreen)
{
// match screen dimensions with selected monitor, for 'borderless window' in fullscreen mode
Global::iWindowWidth = vmode->width;
Global::iWindowHeight = vmode->height;
Global.iWindowWidth = vmode->width;
Global.iWindowHeight = vmode->height;
}
GLFWwindow *window =
glfwCreateWindow(
Global::iWindowWidth,
Global::iWindowHeight,
Global::AppName.c_str(),
( Global::bFullScreen ?
Global.iWindowWidth,
Global.iWindowHeight,
Global.AppName.c_str(),
( Global.bFullScreen ?
monitor :
nullptr),
nullptr );
@@ -374,7 +373,7 @@ int main(int argc, char *argv[])
return -1;
}
glfwMakeContextCurrent(window);
glfwSwapInterval(Global::VSync ? 1 : 0); //vsync
glfwSwapInterval(Global.VSync ? 1 : 0); //vsync
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); //capture cursor
glfwSetCursorPos(window, 0.0, 0.0);
glfwSetFramebufferSizeCallback(window, window_resize_callback);
@@ -415,7 +414,7 @@ int main(int argc, char *argv[])
input::Mouse.init();
input::Gamepad.init();
Global::pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
Global.pWorld = &World; // Ra: wskaźnik potrzebny do usuwania pojazdów
try {
if( false == World.Init( window ) ) {
ErrorLog( "Simulation setup failed" );
@@ -433,8 +432,8 @@ int main(int argc, char *argv[])
if( !joyGetNumDevs() )
WriteLog( "No joystick" );
*/
if( Global::iConvertModels < 0 ) {
Global::iConvertModels = -Global::iConvertModels;
if( Global.iConvertModels < 0 ) {
Global.iConvertModels = -Global.iConvertModels;
World.CreateE3D( "models\\" ); // rekurencyjne przeglądanie katalogów
World.CreateE3D( "dynamic\\", true );
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
@@ -447,8 +446,8 @@ int main(int argc, char *argv[])
&& ( true == GfxRenderer.Render() ) ) {
glfwPollEvents();
input::Keyboard.poll();
if( true == Global::InputMouse ) { input::Mouse.poll(); }
if( true == Global::InputGamepad ) { input::Gamepad.poll(); }
if( true == Global.InputMouse ) { input::Mouse.poll(); }
if( true == Global.InputGamepad ) { input::Gamepad.poll(); }
}
}
catch( std::bad_alloc const &Error ) {