16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 10:29:19 +02:00

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

467
Globals.h
View File

@@ -9,301 +9,186 @@ http://mozilla.org/MPL/2.0/.
#pragma once
#include <string>
#include "renderer.h"
#include "classes.h"
#include "dumb3d.h"
#include "float3d.h"
#include "light.h"
#include "utilities.h"
// definicje klawiszy
const int k_IncMainCtrl = 0; //[Num+]
const int k_IncMainCtrlFAST = 1; //[Num+] [Shift]
const int k_DecMainCtrl = 2; //[Num-]
const int k_DecMainCtrlFAST = 3; //[Num-] [Shift]
const int k_IncScndCtrl = 4; //[Num/]
const int k_IncScndCtrlFAST = 5;
const int k_DecScndCtrl = 6;
const int k_DecScndCtrlFAST = 7;
const int k_IncLocalBrakeLevel = 8;
const int k_IncLocalBrakeLevelFAST = 9;
const int k_DecLocalBrakeLevel = 10;
const int k_DecLocalBrakeLevelFAST = 11;
const int k_IncBrakeLevel = 12;
const int k_DecBrakeLevel = 13;
const int k_Releaser = 14;
const int k_EmergencyBrake = 15;
const int k_Brake3 = 16;
const int k_Brake2 = 17;
const int k_Brake1 = 18;
const int k_Brake0 = 19;
const int k_WaveBrake = 20;
const int k_AntiSlipping = 21;
const int k_Sand = 22;
const int k_Main = 23;
const int k_DirectionForward = 24;
const int k_DirectionBackward = 25;
const int k_Fuse = 26;
const int k_Compressor = 27;
const int k_Converter = 28;
const int k_MaxCurrent = 29;
const int k_CurrentAutoRelay = 30;
const int k_BrakeProfile = 31;
const int k_Czuwak = 32;
const int k_Horn = 33;
const int k_Horn2 = 34;
const int k_FailedEngineCutOff = 35;
const int k_MechUp = 36;
const int k_MechDown = 37;
const int k_MechLeft = 38;
const int k_MechRight = 39;
const int k_MechForward = 40;
const int k_MechBackward = 41;
const int k_CabForward = 42;
const int k_CabBackward = 43;
const int k_Couple = 44;
const int k_DeCouple = 45;
const int k_ProgramQuit = 46;
// const int k_ProgramPause= 47;
const int k_ProgramHelp = 48;
// NBMX
const int k_OpenLeft = 49;
const int k_OpenRight = 50;
const int k_CloseLeft = 51;
const int k_CloseRight = 52;
const int k_DepartureSignal = 53;
// NBMX
const int k_PantFrontUp = 54;
const int k_PantRearUp = 55;
const int k_PantFrontDown = 56;
const int k_PantRearDown = 57;
const int k_Heating = 58;
// const int k_FreeFlyMode= 59;
const int k_LeftSign = 60;
const int k_UpperSign = 61;
const int k_RightSign = 62;
const int k_SmallCompressor = 63;
const int k_StLinOff = 64;
const int k_CurrentNext = 65;
const int k_Univ1 = 66;
const int k_Univ2 = 67;
const int k_Univ3 = 68;
const int k_Univ4 = 69;
const int k_EndSign = 70;
const int k_Active = 71;
// Winger 020304
const int k_Battery = 72;
const int k_WalkMode = 73;
int const k_DimHeadlights = 74;
const int MaxKeys = 75;
class TTranscript
{ // klasa obsługująca linijkę napisu do dźwięku
public:
float fShow; // czas pokazania
float fHide; // czas ukrycia/usunięcia
std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu)
bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego)
};
class TTranscripts
{ // klasa obsługująca napisy do dźwięków
public:
std::deque<TTranscript> aLines;
private:
float fRefreshTime;
public:
TTranscripts();
~TTranscripts();
void AddLine(std::string const &txt, float show, float hide, bool it);
// dodanie tekstów, długość dźwięku, czy istotne
void Add(std::string const &txt, bool background = false);
// usuwanie niepotrzebnych (ok. 10 razy na sekundę)
void Update();
};
class Global {
public:
// methods
static void LoadIniFile(std::string asFileName);
static void ConfigParse( cParser &parser );
static void InitKeys();
inline static Math3D::vector3 GetCameraPosition() { return pCameraPosition; };
static void SetCameraPosition(Math3D::vector3 pNewCameraPosition);
static void TrainDelete(TDynamicObject *d);
static std::string Bezogonkow(std::string str, bool _ = false);
static double Min0RSpeed(double vel1, double vel2);
struct global_settings {
// members
static int Keys[MaxKeys];
static bool RealisticControlMode; // controls ability to steer the vehicle from outside views
static Math3D::vector3 pCameraPosition; // pozycja kamery w świecie
static Math3D::vector3 DebugCameraPosition; // pozycja kamery w świecie
static std::vector<Math3D::vector3> FreeCameraInit; // pozycje kamery
static std::vector<Math3D::vector3> FreeCameraInitAngle;
static int iWindowWidth;
static int iWindowHeight;
static float fDistanceFactor;
static bool bFullScreen;
static bool VSync;
static bool bFreeFly;
static bool bWireFrame;
// McZapkie-131202
static bool bAdjustScreenFreq;
static bool bEnableTraction;
static bool bLoadTraction;
static float fFriction;
static bool bLiveTraction;
static float Global::fMouseXScale;
static float Global::fMouseYScale;
static std::string szDefaultExt;
static std::string SceneryFile;
static std::string AppName;
static std::string asCurrentSceneryPath;
static std::string asCurrentTexturePath;
static std::string asCurrentDynamicPath;
static int iWriteLogEnabled; // maska bitowa: 1-zapis do pliku, 2-okienko
static bool MultipleLogs;
static unsigned int DisabledLogTypes;
// McZapkie-170602: zewnetrzna definicja pojazdu uzytkownika
static std::string asHumanCtrlVehicle;
// world environment
static float Overcast;
static double fFogStart;
static double fFogEnd;
static std::string Season; // season of the year, based on simulation date
static std::string Weather; // current weather
// TODO: put these things in the renderer
static float BaseDrawRange;
static opengl_light DayLight;
static int DynamicLightCount;
static bool ScaleSpecularValues;
static bool BasicRenderer;
static bool RenderShadows;
static struct shadowtune_t {
unsigned int map_size;
float width;
float depth;
float distance;
// data items
// TODO: take these out of the settings
GLFWwindow *window{ nullptr };
bool shiftState{ false }; //m7todo: brzydko
bool ctrlState{ false };
std::mt19937 random_engine{ std::mt19937( static_cast<unsigned int>( std::time( NULL ) ) ) };
TDynamicObject *changeDynObj{ nullptr };// info o zmianie pojazdu
TWorld *pWorld{ nullptr }; // wskaźnik na świat do usuwania pojazdów
TCamera *pCamera{ nullptr }; // parametry kamery
Math3D::vector3 pCameraPosition; // pozycja kamery w świecie
Math3D::vector3 DebugCameraPosition; // pozycja kamery w świecie
std::vector<Math3D::vector3> FreeCameraInit; // pozycje kamery
std::vector<Math3D::vector3> FreeCameraInitAngle;
int iCameraLast{ -1 };
int iSlowMotion{ 0 }; // info o malym FPS: 0-OK, 1-wyłączyć multisampling, 3-promień 1.5km, 7-1km
basic_light DayLight;
float SunAngle{ 0.f }; // angle of the sun relative to horizon
double fLuminance{ 1.0 }; // jasność światła do automatycznego zapalania
double fTimeAngleDeg{ 0.0 }; // godzina w postaci kąta
float fClockAngleDeg[ 6 ]; // kąty obrotu cylindrów dla zegara cyfrowego
std::string LastGLError;
float ZoomFactor{ 1.f }; // determines current camera zoom level. TODO: move it to the renderer
bool CabWindowOpen{ false }; // controls sound attenuation between cab and outside
bool ControlPicking{ false }; // indicates controls pick mode is active
bool DLFont{ false }; // switch indicating presence of basic font
bool bActive{ true }; // czy jest aktywnym oknem
int iPause{ 0 }; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
// settings
// filesystem
bool bLoadTraction{ true };
std::string szTexturesTGA{ ".tga" }; // lista tekstur od TGA
std::string szTexturesDDS{ ".dds" }; // lista tekstur od DDS
std::string szDefaultExt{ szTexturesDDS };
std::string asCurrentSceneryPath{ "scenery/" };
std::string asCurrentTexturePath{ szTexturePath };
std::string asCurrentDynamicPath;
std::string SceneryFile{ "td.scn" };
std::string asHumanCtrlVehicle{ "EU07-424" };
int iConvertModels{ 0 }; // tworzenie plików binarnych
// logs
int iWriteLogEnabled{ 3 }; // maska bitowa: 1-zapis do pliku, 2-okienko, 4-nazwy torów
bool MultipleLogs{ false };
unsigned int DisabledLogTypes{ 0 };
bool bMWDdebugEnable{ false }; // włącz dodawanie do logu
int iMWDDebugMode{ 0 }; // co ma wyświetlać w logu
// simulation
bool RealisticControlMode{ false }; // controls ability to steer the vehicle from outside views
bool bFreeFly{ false };
bool bEnableTraction{ true };
float fFriction{ 1.f }; // mnożnik tarcia - KURS90
bool bLiveTraction{ true };
float Overcast{ 0.1f }; // NOTE: all this weather stuff should be moved elsewhere
GLfloat FogColor[ 3 ] = { 0.6f, 0.7f, 0.8f };
double fFogStart{ 1700 };
double fFogEnd{ 2000 };
std::string Season; // season of the year, based on simulation date
std::string Weather{ "clear" }; // current weather
bool FullPhysics{ true }; // full calculations performed for each simulation step
bool bnewAirCouplers{ true };
double fMoveLight{ -1 }; // numer dnia w roku albo -1
bool FakeLight{ false }; // toggle between fixed and dynamic daylight
double fTimeSpeed{ 1.0 }; // przyspieszenie czasu, zmienna do testów
double fLatitudeDeg{ 52.0 }; // szerokość geograficzna
bool bInactivePause{ true }; // automatyczna pauza, gdy okno nieaktywne
int iSlowMotionMask{ -1 }; // maska wyłączanych właściwości
bool bHideConsole{ false }; // hunter-271211: ukrywanie konsoli
bool bRollFix{ true }; // czy wykonać przeliczanie przechyłki
bool bJoinEvents{ false }; // czy grupować eventy o tych samych nazwach
int iHiddenEvents{ 1 }; // czy łączyć eventy z torami poprzez nazwę toru
// ui
int iTextMode{ 0 }; // tryb pracy wyświetlacza tekstowego
int iScreenMode[ 12 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // numer ekranu wyświetlacza tekstowego
float4 UITextColor{ float4( 225.f / 255.f, 225.f / 255.f, 225.f / 255.f, 1.f ) }; // base color of UI text
std::string asLang{ "pl" }; // domyślny język - http://tools.ietf.org/html/bcp47
// gfx
int iWindowWidth{ 800 };
int iWindowHeight{ 600 };
float fDistanceFactor{ iWindowHeight / 768.f }; // baza do przeliczania odległości dla LoD
bool bFullScreen{ false };
bool VSync{ false };
bool bWireFrame{ false };
bool bAdjustScreenFreq{ true };
float BaseDrawRange{ 2500.f };
int DynamicLightCount{ 3 };
bool ScaleSpecularValues{ true };
bool BasicRenderer{ false };
bool RenderShadows{ true };
struct shadowtune_t {
unsigned int map_size{ 2048 };
float width{ 250.f }; // no longer used
float depth{ 250.f };
float distance{ 500.f }; // no longer used
} shadowtune;
static bool bUseVBO; // czy jest VBO w karcie graficznej
static float AnisotropicFiltering; // requested level of anisotropic filtering. TODO: move it to renderer object
static int ScreenWidth; // current window dimensions. TODO: move it to renderer
static int ScreenHeight;
static float ZoomFactor; // determines current camera zoom level. TODO: move it to the renderer
static float FieldOfView; // vertical field of view for the camera. TODO: move it to the renderer
static GLint iMaxTextureSize; // maksymalny rozmiar tekstury
static int iMultisampling; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
static bool bSmoothTraction; // wygładzanie drutów
static float SplineFidelity; // determines segment size during conversion of splines to geometry
static GLfloat FogColor[];
static bool ResourceSweep; // gfx resource garbage collection
static bool ResourceMove; // gfx resources are moved between cpu and gpu side instead of sending a copy
// sound renderer variables
static bool bSoundEnabled;
static float AudioVolume;
static std::string AudioRenderer;
bool bUseVBO{ true }; // czy jest VBO w karcie graficznej (czy użyć)
float AnisotropicFiltering{ 8.f }; // requested level of anisotropic filtering. TODO: move it to renderer object
float FieldOfView{ 45.f }; // vertical field of view for the camera. TODO: move it to the renderer
GLint iMaxTextureSize{ 4096 }; // maksymalny rozmiar tekstury
int iMultisampling{ 2 }; // tryb antyaliasingu: 0=brak,1=2px,2=4px,3=8px,4=16px
bool bSmoothTraction{ true }; // wygładzanie drutów starym sposobem
float SplineFidelity{ 1.f }; // determines segment size during conversion of splines to geometry
bool ResourceSweep{ true }; // gfx resource garbage collection
bool ResourceMove{ false }; // gfx resources are moved between cpu and gpu side instead of sending a copy
std::string asSky{ "1" };
bool bGlutFont{ false }; // czy tekst generowany przez GLUT32.DLL
double fFpsAverage{ 20.0 }; // oczekiwana wartosć FPS
double fFpsDeviation{ 5.0 }; // odchylenie standardowe FPS
double fFpsMin{ 30.0 }; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
double fFpsMax{ 65.0 }; // górna granica FPS, przy której promień scenerii będzie zwiększany
// audio
bool bSoundEnabled{ true };
float AudioVolume{ 1.25f };
std::string AudioRenderer;
// input
float fMouseXScale{ 1.5f };
float fMouseYScale{ 0.2f };
int iFeedbackMode{ 1 }; // tryb pracy informacji zwrotnej
int iFeedbackPort{ 0 }; // dodatkowy adres dla informacji zwrotnych
bool InputGamepad{ true }; // whether gamepad support is enabled
bool InputMouse{ true }; // whether control pick mode can be activated
double fBrakeStep{ 1.0 }; // krok zmiany hamulca dla klawiszy [Num3] i [Num9]
// parametry kalibracyjne wejść z pulpitu
double fCalibrateIn[ 6 ][ 6 ] = {
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 } };
// parametry kalibracyjne wyjść dla pulpitu
double fCalibrateOut[ 7 ][ 6 ] = {
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 },
{ 0, 1, 0, 0, 0, 0 } };
// wartości maksymalne wyjść dla pulpitu
double fCalibrateOutMax[ 7 ] = {
0, 0, 0, 0, 0, 0, 0 };
int iCalibrateOutDebugInfo { -1 }; // numer wyjścia kalibrowanego dla którego wyświetlać informacje podczas kalibracji
int iPoKeysPWM[ 7 ] = { 0, 1, 2, 3, 4, 5, 6 }; // numery wejść dla PWM
// maciek001: konfiguracja wstępna portu COM
bool bMWDmasterEnable { false };// główne włączenie portu!
std::string sMWDPortId { "COM1" }; // nazwa portu z którego korzystamy
unsigned long int iMWDBaudrate{ 9600 }; // prędkość transmisji danych
bool bMWDInputEnable { false }; // włącz wejścia
bool bMWDBreakEnable { false }; // włącz wejścia analogowe
// wartość max potencjometru, wartość min potencjometru, rozdzielczość (max. wartość jaka może być)
double fMWDAnalogInCalib[ 4 ][ 2 ] = {
{ 0, 1023 },
{ 0, 1023 },
{ 0, 1023 },
{ 0, 1023 } };
double fMWDzg[ 2 ] = { 0.9, 1023 };
double fMWDpg[ 2 ] = { 0.8, 1023 };
double fMWDph[ 2 ] = { 0.6, 1023 };
double fMWDvolt[ 2 ] = { 4000, 1023 };
double fMWDamp[ 2 ] = { 800, 1023 };
double fMWDlowVolt[ 2 ] = { 150, 1023 };
int iMWDdivider { 5 };
// multiplayer
int iMultiplayer{ 0 }; // blokada działania niektórych eventów na rzecz kominikacji
// other
std::string AppName{ "EU07" };
std::string asVersion{ "couldn't retrieve version string" }; // z opisem
static bool FullPhysics; // full calculations performed for each simulation step
static int iSlowMotion;
static TDynamicObject *changeDynObj;
static double ABuDebug;
static std::string asSky;
static bool bnewAirCouplers;
// Ra: nowe zmienne globalne
static std::string LastGLError;
static int iFeedbackMode; // tryb pracy informacji zwrotnej
static int iFeedbackPort; // dodatkowy adres dla informacji zwrotnych
static bool InputGamepad; // whether gamepad support is enabled
static double fLuminance; // jasność światła do automatycznego zapalania
static float SunAngle; // angle of the sun relative to horizon
static int iMultiplayer; // blokada działania niektórych eventów na rzecz kominikacji
static GLFWwindow *window;
static bool shiftState; //m7todo: brzydko
static bool ctrlState;
static bool CabWindowOpen; // controls sound attenuation between cab and outside
static int iCameraLast;
static std::string asVersion; // z opisem
static bool ControlPicking; // indicates controls pick mode is active
static bool InputMouse; // whether control pick mode can be activated
static int iTextMode; // tryb pracy wyświetlacza tekstowego
static int iScreenMode[12]; // numer ekranu wyświetlacza tekstowego
static double fMoveLight; // numer dnia w roku albo -1
static bool FakeLight; // toggle between fixed and dynamic daylight
static double fTimeSpeed; // przyspieszenie czasu, zmienna do testów
static double fTimeAngleDeg; // godzina w postaci kąta
static float fClockAngleDeg[6]; // kąty obrotu cylindrów dla zegara cyfrowego
static double fLatitudeDeg; // szerokość geograficzna
static std::string szTexturesTGA; // lista tekstur od TGA
static std::string szTexturesDDS; // lista tekstur od DDS
static bool DLFont; // switch indicating presence of basic font
static bool bGlutFont; // tekst generowany przez GLUT
static int iPause; // globalna pauza ruchu: b0=start,b1=klawisz,b2=tło,b3=lagi,b4=wczytywanie
static bool bActive; // czy jest aktywnym oknem
static int iConvertModels; // tworzenie plików binarnych
static bool bInactivePause; // automatyczna pauza, gdy okno nieaktywne
static int iSlowMotionMask; // maska wyłączanych właściwości
static bool bHideConsole; // hunter-271211: ukrywanie konsoli
static TWorld *pWorld; // wskaźnik na świat do usuwania pojazdów
static bool bRollFix; // czy wykonać przeliczanie przechyłki
static double fFpsAverage; // oczekiwana wartosć FPS
static double fFpsDeviation; // odchylenie standardowe FPS
static double fFpsMin; // dolna granica FPS, przy której promień scenerii będzie zmniejszany
static double fFpsMax; // górna granica FPS, przy której promień scenerii będzie zwiększany
static TCamera *pCamera; // parametry kamery
static double fCalibrateIn[6][6]; // parametry kalibracyjne wejść z pulpitu
static double fCalibrateOut[7][6]; // parametry kalibracyjne wyjść dla pulpitu
static double fCalibrateOutMax[7]; // wartości maksymalne wyjść dla pulpitu
static int iCalibrateOutDebugInfo; // numer wyjścia kalibrowanego dla którego wyświetlać
// informacje podczas kalibracji
static double fBrakeStep; // krok zmiany hamulca dla klawiszy [Num3] i [Num9]
static bool bJoinEvents; // czy grupować eventy o tych samych nazwach
static TTranscripts tranTexts; // obiekt obsługujący stenogramy dźwięków na ekranie
static float4 UITextColor; // base color of UI text
static std::string asLang; // domyślny język - http://tools.ietf.org/html/bcp47
static int iHiddenEvents; // czy łączyć eventy z torami poprzez nazwę toru
/*
static TTextSound *tsRadioBusy[10]; // zajętość kanałów radiowych (wskaźnik na odgrywany dźwięk)
*/
static int iPoKeysPWM[7]; // numery wejść dla PWM
//randomizacja
static std::mt19937 random_engine;
// maciek001: zmienne dla MWD
static bool bMWDmasterEnable; // główne włączenie portu COM
static bool bMWDdebugEnable; // logowanie pracy
static int iMWDDebugMode;
static std::string sMWDPortId; // nazwa portu COM
static unsigned long int iMWDBaudrate; // prędkość transmisji
static bool bMWDInputEnable; // włącz wejścia
static bool bMWDBreakEnable; // włącz wejścia analogowe (hamulce)
static double fMWDAnalogInCalib[4][2]; // ustawienia kranów hamulca zespolonego i dodatkowego - min i max
static double fMWDzg[2]; // max wartość wskazywana i max wartość generowana (rozdzielczość)
static double fMWDpg[2];
static double fMWDph[2];
static double fMWDvolt[2];
static double fMWDamp[2];
static double fMWDlowVolt[2];
static int iMWDdivider;
// methods
void LoadIniFile( std::string asFileName );
void ConfigParse( cParser &parser );
};
extern global_settings Global;
//---------------------------------------------------------------------------