From 3a67219e306ca206a3f1e7358210ee9d6b2dd424 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Sat, 15 Jul 2017 19:27:49 +0200 Subject: [PATCH] custom sounds for cab controls configurable on per-item basis --- DynObj.cpp | 2 +- FadeSound.h | 4 +- Gauge.cpp | 190 ++++++++++++------ Gauge.h | 47 +++-- McZapkie/MOVER.h | 51 +---- McZapkie/Mover.cpp | 67 +++---- McZapkie/mctools.cpp | 182 ++--------------- McZapkie/mctools.h | 121 +++++------- Model3d.cpp | 4 +- Train.cpp | 460 ++++++++++++++++++++++++++++++++++--------- Train.h | 46 ++--- TrkFoll.cpp | 8 +- parser.h | 39 ++-- uilayer.cpp | 34 ++-- version.h | 2 +- 15 files changed, 687 insertions(+), 570 deletions(-) diff --git a/DynObj.cpp b/DynObj.cpp index a47db564..05b2ac47 100644 --- a/DynObj.cpp +++ b/DynObj.cpp @@ -1717,7 +1717,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if (ConversionError == -8) ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz"); Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name + - ".fiz\r\nError " + to_string(ConversionError) + " in line " + to_string(LineCount)); + ".fiz\r\nError " + to_string(ConversionError)); return 0.0; // zerowa długość to brak pojazdu } bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch diff --git a/FadeSound.h b/FadeSound.h index 6ce4e1b0..97c45eb0 100644 --- a/FadeSound.h +++ b/FadeSound.h @@ -21,8 +21,8 @@ class TFadeSound fTime = 0.0f; TSoundState State = ss_Off; - public: - TFadeSound(); +public: + TFadeSound() = default; ~TFadeSound(); void Init(std::string const &Name, float fNewFade); void TurnOn(); diff --git a/Gauge.cpp b/Gauge.cpp index 3883a231..e6e6f0ec 100644 --- a/Gauge.cpp +++ b/Gauge.cpp @@ -20,31 +20,7 @@ http://mozilla.org/MPL/2.0/. #include "Timer.h" #include "logs.h" -TGauge::TGauge() -{ - eType = gt_Unknown; - fFriction = 0.0; - fDesiredValue = 0.0; - fValue = 0.0; - fOffset = 0.0; - fScale = 1.0; - fStepSize = 5; - // iChannel=-1; //kanał analogowej komunikacji zwrotnej - SubModel = NULL; -}; - -TGauge::~TGauge(){}; - -void TGauge::Clear() -{ - SubModel = NULL; - eType = gt_Unknown; - fValue = 0; - fDesiredValue = 0; -}; - -void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, - double fNewFriction, double fNewValue) +void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, double fNewFriction, double fNewValue) { // ustawienie parametrów animacji submodelu if (NewSubModel) { // warunek na wszelki wypadek, gdyby się submodel nie @@ -75,41 +51,107 @@ void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, } }; -bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul) -{ - std::string str1 = Parser.getToken(false); - std::string str2 = Parser.getToken(); - Parser.getTokens( 3, false ); - double val3, val4, val5; - Parser - >> val3 - >> val4 - >> val5; - val3 *= mul; - TSubModel *sm = md1->GetFromName( str1.c_str() ); - if( val3 == 0.0 ) { - ErrorLog( "Scale of 0.0 defined for sub-model \"" + str1 + "\" in 3d model \"" + md1->NameGet() + "\". Forcing scale of 1.0 to prevent division by 0" ); - val3 = 1.0; +bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul) { + + std::string submodelname, gaugetypename; + double scale, offset, friction; + + Parser.getTokens(); + if( Parser.peek() != "{" ) { + // old fixed size config + Parser >> submodelname; + gaugetypename = Parser.getToken( true ); + Parser.getTokens( 3, false ); + Parser + >> scale + >> offset + >> friction; } - if (sm) // jeśli nie znaleziony - md2 = NULL; // informacja, że znaleziony - else if (md2) // a jest podany drugi model (np. zewnętrzny) - sm = md2->GetFromName(str1.c_str()); // to może tam będzie, co za różnica gdzie - if( sm == nullptr ) { - ErrorLog( "Failed to locate sub-model \"" + str1 + "\" in 3d model \"" + md1->NameGet() + "\"" ); + else { + // new, block type config + // TODO: rework the base part into yaml-compatible flow style mapping + cParser mappingparser( Parser.getToken( false, "}" ) ); + submodelname = mappingparser.getToken( false ); + gaugetypename = mappingparser.getToken( true ); + mappingparser.getTokens( 3, false ); + mappingparser + >> scale + >> offset + >> friction; + // new, variable length section + while( true == Load_mapping( mappingparser ) ) { + ; // all work done by while() + } } - if (str2 == "mov") - Init(sm, gt_Move, val3, val4, val5); - else if (str2 == "wip") - Init(sm, gt_Wiper, val3, val4, val5); - else if (str2 == "dgt") - Init(sm, gt_Digital, val3, val4, val5); - else - Init(sm, gt_Rotate, val3, val4, val5); + scale *= mul; + TSubModel *submodel = md1->GetFromName( submodelname.c_str() ); + if( scale == 0.0 ) { + ErrorLog( "Scale of 0.0 defined for sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\". Forcing scale of 1.0 to prevent division by 0" ); + scale = 1.0; + } + if (submodel) // jeśli nie znaleziony + md2 = nullptr; // informacja, że znaleziony + else if (md2) // a jest podany drugi model (np. zewnętrzny) + submodel = md2->GetFromName(submodelname.c_str()); // to może tam będzie, co za różnica gdzie + if( submodel == nullptr ) { + ErrorLog( "Failed to locate sub-model \"" + submodelname + "\" in 3d model \"" + md1->NameGet() + "\"" ); + } + + std::map gaugetypes { + { "mov", gt_Move }, + { "wip", gt_Wiper }, + { "dgt", gt_Digital } + }; + auto lookup = gaugetypes.find( gaugetypename ); + auto const type = ( + lookup != gaugetypes.end() ? + lookup->second : + gt_Rotate ); + Init(submodel, type, scale, offset, friction); + return md2 != nullptr; // true, gdy podany model zewnętrzny, a w kabinie nie było }; +bool +TGauge::Load_mapping( cParser &Input ) { + + if( false == Input.getTokens( 2, true, ", " ) ) { + return false; + } + + std::string key, value; + Input + >> key + >> value; + + if( key == "soundinc:" ) { + m_soundfxincrease = ( + value != "none" ? + TSoundsManager::GetFromName( value, true ) : + nullptr ); + } + else if( key == "sounddec:" ) { + m_soundfxdecrease = ( + value != "none" ? + TSoundsManager::GetFromName( value, true ) : + nullptr ); + } + else if( key.find( "sound" ) == 0 ) { + // sounds assigned to specific gauge values, defined by key soundFoo: where Foo = value + auto const indexstart = key.find_first_of( "1234567890" ); + auto const indexend = key.find_first_not_of( "1234567890", indexstart ); + if( indexstart != std::string::npos ) { + m_soundfxvalues.emplace( + std::stoi( key.substr( indexstart, indexend - indexstart ) ), + ( value != "none" ? + TSoundsManager::GetFromName( value, true ) : + nullptr ) ); + } + } + return true; // return value marks a key: value pair was extracted, nothing about whether it's recognized +} + void TGauge::PermIncValue(double fNewDesired) { fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset; @@ -134,9 +176,34 @@ void TGauge::DecValue(double fNewDesired) fDesiredValue = 0; }; -void TGauge::UpdateValue(double fNewDesired) -{ // ustawienie wartości docelowej +// ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself +void +TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) { + + if( static_cast( std::round( ( fDesiredValue - fOffset ) / fScale ) ) == static_cast( fNewDesired ) ) { + return; + } fDesiredValue = fNewDesired * fScale + fOffset; + // if there's any sound associated with new requested value, play it + // check value-specific table first... + auto const desiredvalue = static_cast( std::round( fNewDesired ) ); + auto const lookup = m_soundfxvalues.find( desiredvalue ); + if( lookup != m_soundfxvalues.end() ) { + play( lookup->second ); + return; + } + // ...and if there isn't any, fall back on the basic set... + auto const currentvalue = GetValue(); + if( ( currentvalue < fNewDesired ) && ( m_soundfxincrease != nullptr ) ) { + play( m_soundfxincrease ); + } + else if( ( currentvalue > fNewDesired ) && ( m_soundfxdecrease != nullptr ) ) { + play( m_soundfxdecrease ); + } + else { + // ...and if that fails too, try the provided fallback sound from legacy system + play( Fallbacksound ); + } }; void TGauge::PutValue(double fNewDesired) @@ -245,4 +312,15 @@ void TGauge::UpdateValue() } }; +void +TGauge::play( PSound Sound ) { + + if( Sound == nullptr ) { return; } + + Sound->SetCurrentPosition( 0 ); + Sound->SetVolume( DSBVOLUME_MAX ); + Sound->Play( 0, 0, 0 ); + return; +} + //--------------------------------------------------------------------------- diff --git a/Gauge.h b/Gauge.h index e2236a8d..0147a61e 100644 --- a/Gauge.h +++ b/Gauge.h @@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/. #pragma once #include "Classes.h" +#include "sound.h" typedef enum { // typ ruchu @@ -21,35 +22,43 @@ typedef enum gt_Digital // licznik cyfrowy, np. kilometrów } TGaugeType; -class TGauge // zmienne "gg" -{ // animowany wskaźnik, mogący przyjmować wiele stanów pośrednich +// animowany wskaźnik, mogący przyjmować wiele stanów pośrednich +class TGauge { + private: - TGaugeType eType; // typ ruchu - double fFriction{ 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości - double fDesiredValue{ 0.0 }; // wartość docelowa - double fValue{ 0.0 }; // wartość obecna - double fOffset{ 0.0 }; // wartość początkowa ("0") - double fScale{ 1.0 }; // wartość końcowa ("1") - double fStepSize; // nie używane + TGaugeType eType { gt_Unknown }; // typ ruchu + double fFriction { 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości + double fDesiredValue { 0.0 }; // wartość docelowa + double fValue { 0.0 }; // wartość obecna + double fOffset { 0.0 }; // wartość początkowa ("0") + double fScale { 1.0 }; // wartość końcowa ("1") char cDataType; // typ zmiennej parametru: f-float, d-double, i-int - union - { // wskaźnik na parametr pokazywany przez animację + union { + // wskaźnik na parametr pokazywany przez animację float *fData; - double *dData; + double *dData { nullptr }; int *iData; }; + PSound m_soundfxincrease { nullptr }; // sound associated with increasing control's value + PSound m_soundfxdecrease { nullptr }; // sound associated with decreasing control's value + std::map m_soundfxvalues; // sounds associated with specific values +// methods + // plays specified sound + void + play( PSound Sound ); public: - TGauge(); - ~TGauge(); - void Clear(); - void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1, - double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0); - bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = NULL, double mul = 1.0); + TGauge() = default; + ~TGauge() {} + inline + void Clear() { *this = TGauge(); } + void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1, double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0); + bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0); + bool Load_mapping( cParser &Input ); void PermIncValue(double fNewDesired); void IncValue(double fNewDesired); void DecValue(double fNewDesired); - void UpdateValue(double fNewDesired); + void UpdateValue(double fNewDesired, PSound Fallbacksound = nullptr ); void PutValue(double fNewDesired); double GetValue() const; void Update(); diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 26c3ad7b..a21608ba 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -78,7 +78,8 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona */ #include "dumb3d.h" -using namespace Math3D; + +extern int ConversionError; const double Steel2Steel_friction = 0.15; //tarcie statyczne const double g = 9.81; //przyspieszenie ziemskie @@ -996,8 +997,8 @@ public: double FrictConst2d= 0.0; double TotalMassxg = 0.0; /*TotalMass*g*/ - vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/ - vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych + Math3D::vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/ + Math3D::vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych // int WarningSignal; //0: nie trabi, 1,2: trabi syreną o podanym numerze int WarningSignal = 0; // tymczasowo 8bit, ze względu na funkcje w MTools double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego @@ -1210,47 +1211,3 @@ private: }; extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); - -inline -std::string -extract_value( std::string const &Key, std::string const &Input ) { - - std::string value; - auto lookup = Input.find( Key + "=" ); - if( lookup != std::string::npos ) { - value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) ); - lookup = value.find( ' ' ); - if( lookup != std::string::npos ) { - // trim everything past the value - value.erase( lookup ); - } - } - return value; -} - -template -bool -extract_value( Type_ &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { - - auto value = extract_value( Key, Input ); - if( false == value.empty() ) { - // set the specified variable to retrieved value - std::stringstream converter; - converter << value; - converter >> Variable; - return true; // located the variable - } - else { - // set the variable to provided default value - if( false == Default.empty() ) { - std::stringstream converter; - converter << Default; - converter >> Variable; - } - return false; // couldn't locate the variable in provided input - } -} - -template <> -bool -extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 9c861dbc..b32c1e07 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/. #include "../logs.h" #include "Oerlikon_ESt.h" #include "../parser.h" +#include "mctools.h" //--------------------------------------------------------------------------- // Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane. @@ -22,6 +23,8 @@ http://mozilla.org/MPL/2.0/. const double dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...) const double CouplerTune = 0.1; // skalowanie tlumiennosci +int ConversionError = 0; + std::vector const TMoverParameters::eimc_labels = { "dfic: ", "dfmax:", "p: ", "scfu: ", "cim: ", "icif: ", "Uzmax:", "Uzh: ", "DU: ", "I0: ", "fcfu: ", "F0: ", "a1: ", "Pmax: ", "Fh: ", "Ph: ", "Vh0: ", "Vh1: ", "Imax: ", "abed: ", @@ -5097,14 +5100,17 @@ bool TMoverParameters::AutoRelayCheck(void) // IminLo } // main bez samoczynnego rozruchu + if( ( MainCtrlActualPos < ( sizeof( RList ) / sizeof( TScheme ) - 1 ) ) // crude guard against running out of current fixed table + && ( ( RList[ MainCtrlActualPos ].Relay < MainCtrlPos ) + || ( RList[ MainCtrlActualPos + 1 ].Relay == MainCtrlPos ) + || ( ( TrainType == dt_ET22 ) + && ( DelayCtrlFlag ) ) ) ) { + + if( ( RList[MainCtrlPos].R == 0 ) + && ( MainCtrlPos > 0 ) + && ( MainCtrlPos != MainCtrlPosNo ) + && ( FastSerialCircuit == 1 ) ) { - if ((RList[MainCtrlActualPos].Relay < MainCtrlPos) || - (RList[MainCtrlActualPos + 1].Relay == MainCtrlPos) || - ((TrainType == dt_ET22) && (DelayCtrlFlag))) - { - if ((RList[MainCtrlPos].R == 0) && (MainCtrlPos > 0) && - (!(MainCtrlPos == MainCtrlPosNo)) && (FastSerialCircuit == 1)) - { MainCtrlActualPos++; // MainCtrlActualPos:=MainCtrlPos; //hunter-111012: // szybkie wchodzenie na bezoporowa (303E) @@ -5803,28 +5809,28 @@ std::string TMoverParameters::EngineDescription(int what) { if (TestFlag(DamageFlag, dtrain_thinwheel)) if (Power > 0.1) - outstr = "Thin wheel,"; + outstr = "Thin wheel"; else - outstr = "Load shifted,"; + outstr = "Load shifted"; if (TestFlag(DamageFlag, dtrain_wheelwear)) - outstr = "Wheel wear,"; + outstr = "Wheel wear"; if (TestFlag(DamageFlag, dtrain_bearing)) - outstr = "Bearing damaged,"; + outstr = "Bearing damaged"; if (TestFlag(DamageFlag, dtrain_coupling)) - outstr = "Coupler broken,"; + outstr = "Coupler broken"; if (TestFlag(DamageFlag, dtrain_loaddamage)) if (Power > 0.1) - outstr = "Ventilator damaged,"; + outstr = "Ventilator damaged"; else - outstr = "Load damaged,"; + outstr = "Load damaged"; if (TestFlag(DamageFlag, dtrain_loaddestroyed)) if (Power > 0.1) - outstr = "Engine damaged,"; + outstr = "Engine damaged"; else - outstr = "LOAD DESTROYED,"; + outstr = "LOAD DESTROYED"; if (TestFlag(DamageFlag, dtrain_axle)) - outstr = "Axle broken,"; + outstr = "Axle broken"; if (TestFlag(DamageFlag, dtrain_out)) outstr = "DERAILED"; if (outstr == "") @@ -6105,7 +6111,7 @@ bool TMoverParameters::readRList( std::string const &Input ) { return false; } auto idx = LISTLINE++; - if( idx >= sizeof( RList ) ) { + if( idx >= sizeof( RList ) / sizeof( TScheme ) ) { WriteLog( "Read RList: number of entries exceeded capacity of the data table" ); return false; } @@ -6127,7 +6133,7 @@ bool TMoverParameters::readDList( std::string const &line ) { cParser parser( line ); parser.getTokens( 3, false ); auto idx = LISTLINE++; - if( idx >= sizeof( RList ) ) { + if( idx >= sizeof( RList ) / sizeof( TScheme ) ) { WriteLog( "Read DList: number of entries exceeded capacity of the data table" ); return false; } @@ -6147,7 +6153,7 @@ bool TMoverParameters::readFFList( std::string const &line ) { return false; } int idx = LISTLINE++; - if( idx >= sizeof( DElist ) ) { + if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) { WriteLog( "Read FList: number of entries exceeded capacity of the data table" ); return false; } @@ -6167,7 +6173,7 @@ bool TMoverParameters::readWWList( std::string const &line ) { return false; } int idx = LISTLINE++; - if( idx >= sizeof( DElist ) ) { + if( idx >= sizeof( DElist ) / sizeof( TDEScheme ) ) { WriteLog( "Read WWList: number of entries exceeded capacity of the data table" ); return false; } @@ -8364,22 +8370,3 @@ double TMoverParameters::ShowCurrentP(int AmpN) return current; } } - -template <> -bool -extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { - - auto value = extract_value( Key, Input ); - if( false == value.empty() ) { - // set the specified variable to retrieved value - Variable = ( ToLower( value ) == "yes" ); - return true; // located the variable - } - else { - // set the variable to provided default value - if( false == Default.empty() ) { - Variable = ( ToLower( Default ) == "yes" ); - } - return false; // couldn't locate the variable in provided input - } -} diff --git a/McZapkie/mctools.cpp b/McZapkie/mctools.cpp index 42f6b17d..33744897 100644 --- a/McZapkie/mctools.cpp +++ b/McZapkie/mctools.cpp @@ -17,41 +17,9 @@ Copyright (C) 2007-2014 Maciej Cierniak /*================================================*/ -int ConversionError = 0; -int LineCount = 0; bool DebugModeFlag = false; bool FreeFlyModeFlag = false; -//std::string Ups(std::string s) -//{ -// int jatka; -// std::string swy; -// -// swy = ""; -// { -// long jatka_end = s.length() + 1; -// for (jatka = 0; jatka < jatka_end; jatka++) -// swy = swy + UpCase(s[jatka]); -// } -// return swy; -//} /*=Ups=*/ - -int Max0(int x1, int x2) -{ - if (x1 > x2) - return x1; - else - return x2; -} - -int Min0(int x1, int x2) -{ - if (x1 < x2) - return x1; - else - return x2; -} - double Max0R(double x1, double x2) { if (x1 > x2) @@ -87,13 +55,8 @@ bool TestFlag(int Flag, int Value) return false; } -bool SetFlag(int &Flag, int Value) -{ - return iSetFlag(Flag, Value); -} +bool SetFlag(int &Flag, int Value) { -bool iSetFlag(int &Flag, int Value) -{ if (Value > 0) { if ((Flag & Value) == 0) @@ -263,33 +226,13 @@ std::string to_hex_str( int const Value, int const Width ) return converter.str(); }; -int stol_def(const std::string &str, const int &DefaultValue) -{ +int stol_def(const std::string &str, const int &DefaultValue) { + int result { DefaultValue }; std::stringstream converter; converter << str; converter >> result; return result; -/* - // this function was developed iteratively on Codereview.stackexchange - // with the assistance of @Corbin - std::size_t len = str.size(); - while (std::isspace(str[len - 1])) - len--; - if (len == 0) - return DefaultValue; - errno = 0; - char *s = new char[len + 1]; - std::strncpy(s, str.c_str(), len); - char *p; - int result = strtol(s, &p, 0); - delete[] s; - if( ( *p != '\0' ) || ( errno != 0 ) ) - { - return DefaultValue; - } - return result; -*/ } std::string ToLower(std::string const &text) @@ -321,114 +264,27 @@ win1250_to_ascii( std::string &Input ) { } } -void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, - double &phi, double &Xout, double &Yout) -/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ -{ - double dX; - double dY; - double Xc; - double Yc; - double gamma; - double alfa; - double AbsR; +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { - if ((R != 0) && (L != 0)) - { - AbsR = abs(R); - dX = Xn - X0; - dY = Yn - Y0; - if (dX != 0) - gamma = atan(dY * 1.0 / dX); - else if (dY > 0) - gamma = M_PI * 1.0 / 2; - else - gamma = 3 * M_PI * 1.0 / 2; - alfa = L * 1.0 / R; - phi = gamma - (alfa + M_PI * Round(R * 1.0 / AbsR)) * 1.0 / 2; - Xc = X0 - AbsR * cos(phi); - Yc = Y0 - AbsR * sin(phi); - phi = phi + alfa * dL * 1.0 / L; - Xout = AbsR * cos(phi) + Xc; - Yout = AbsR * sin(phi) + Yc; + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + Variable = ( ToLower( value ) == "yes" ); + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + Variable = ( ToLower( Default ) == "yes" ); + } + return false; // couldn't locate the variable in provided input } -} - -void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double &Xout, - double &Yout) -{ - double dX; - double dY; - double gamma; - double alfa; - /* pX,pY : real;*/ - - alfa = 0; // ABu: bo nie bylo zainicjowane - dX = Xn - X0; - dY = Yn - Y0; - if (dX != 0) - gamma = atan(dY * 1.0 / dX); - else if (dY > 0) - gamma = M_PI * 1.0 / 2; - else - gamma = 3 * M_PI * 1.0 / 2; - if (R != 0) - alfa = L * 1.0 / R; - Xout = X0 + L * cos(alfa * 1.0 / 2 - gamma); - Yout = Y0 + L * sin(alfa * 1.0 / 2 - gamma); } bool FileExists( std::string const &Filename ) { - std::ifstream file( Filename ); + std::ifstream file( Filename ); return( true == file.is_open() ); } - -/* -//graficzne: - -double Xhor(double h) -{ - return h * Hstep + Xmin; -} - -double Yver(double v) -{ - return (Vsize - v) * Vstep + Ymin; -} - -long Horiz(double x) -{ - x = (x - Xmin) * 1.0 / Hstep; - if (x > -INT_MAX) - if (x < INT_MAX) - return Round(x); - else - return INT_MAX; - else - return -INT_MAX; -} - -long Vert(double Y) -{ - Y = (Y - Ymin) * 1.0 / Vstep; - if (Y > -INT_MAX) - if (Y < INT_MAX) - return Vsize - Round(Y); - else - return INT_MAX; - else - return -INT_MAX; -} -*/ - -// NOTE: this now does nothing. -void ClearPendingExceptions() -// resetuje błędy FPU, wymagane dla Trunc() -{ - ; /*?*/ /* ASM - FNCLEX - ASM END */ -} - -// END diff --git a/McZapkie/mctools.h b/McZapkie/mctools.h index c8171572..8f02ab11 100644 --- a/McZapkie/mctools.h +++ b/McZapkie/mctools.h @@ -15,48 +15,16 @@ http://mozilla.org/MPL/2.0/. #include #include #include -#include #include #include -/*Ra: te stałe nie są używane... - _FileName = ['a'..'z','A'..'Z',':','\','.','*','?','0'..'9','_','-']; - _RealNum = ['0'..'9','-','+','.','E','e']; - _Integer = ['0'..'9','-']; //Ra: to się gryzie z STLport w Builder 6 - _Plus_Int = ['0'..'9']; - _All = [' '..'ţ']; - _Delimiter= [',',';']+_EOL; - _Delimiter_Space=_Delimiter+[' ']; -*/ -static char _EOL[2] = { (char)13, (char)10 }; -static char _Spacesigns[4] = { (char)' ', (char)9, (char)13, (char)10 }; -static std::string _spacesigns = " " + (char)9 + (char)13 + (char)10; -static int const CutLeft = -1; -static int const CutRight = 1; -static int const CutBoth = 0; /*Cut_Space*/ - -extern int ConversionError; -extern int LineCount; extern bool DebugModeFlag; extern bool FreeFlyModeFlag; - -typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/ - -/*konwersje*/ - /*funkcje matematyczne*/ -int Max0(int x1, int x2); -int Min0(int x1, int x2); - double Max0R(double x1, double x2); double Min0R(double x1, double x2); -inline int Sign(int x) -{ - return x >= 0 ? 1 : -1; -} - inline double Sign(double x) { return x >= 0 ? 1.0 : -1.0; @@ -68,7 +36,7 @@ inline long Round(double const f) //return lround(f); } -extern double Random(double a, double b); +double Random(double a, double b); inline double Random() { @@ -94,10 +62,9 @@ inline double BorlandTime() std::string Now(); /*funkcje logiczne*/ -extern bool TestFlag(int Flag, int Value); -extern bool SetFlag( int & Flag, int Value); -extern bool iSetFlag( int & Flag, int Value); -extern bool UnSetFlag(int &Flag, int Value); +bool TestFlag(int Flag, int Value); +bool SetFlag( int & Flag, int Value); +bool UnSetFlag(int &Flag, int Value); bool FuzzyLogic(double Test, double Threshold, double Probability); /*jesli Test>Threshold to losowanie*/ @@ -139,40 +106,48 @@ std::string ToUpper(std::string const &text); // replaces polish letters with basic ascii void win1250_to_ascii( std::string &Input ); -/*procedury, zmienne i funkcje graficzne*/ -void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout); -/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ -void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout); -/* -inline bool fileExists(const std::string &name) -{ - struct stat buffer; - return (stat(name.c_str(), &buffer) == 0); -}*/ +inline +std::string +extract_value( std::string const &Key, std::string const &Input ) { + + std::string value; + auto lookup = Input.find( Key + "=" ); + if( lookup != std::string::npos ) { + value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) ); + lookup = value.find( ' ' ); + if( lookup != std::string::npos ) { + // trim everything past the value + value.erase( lookup ); + } + } + return value; +} + +template +bool +extract_value( Type_ &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) { + + auto value = extract_value( Key, Input ); + if( false == value.empty() ) { + // set the specified variable to retrieved value + std::stringstream converter; + converter << value; + converter >> Variable; + return true; // located the variable + } + else { + // set the variable to provided default value + if( false == Default.empty() ) { + std::stringstream converter; + converter << Default; + converter >> Variable; + } + return false; // couldn't locate the variable in provided input + } +} + +template <> +bool +extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ); + bool FileExists( std::string const &Filename ); -/* -extern double Xmin; -extern double Ymin; -extern double Xmax; -extern double Ymax; -extern double Xaspect; -extern double Yaspect; -extern double Hstep; -extern double Vstep; -extern int Vsize; -extern int Hsize; - - -// Converts horizontal screen coordinate into real X-coordinate. -double Xhor( double h ); - -// Converts vertical screen coordinate into real Y-coordinate. -double Yver( double v ); - -long Horiz(double x); - -long Vert(double Y); -*/ - -void ClearPendingExceptions(); - diff --git a/Model3d.cpp b/Model3d.cpp index 27614b73..b77b9329 100644 --- a/Model3d.cpp +++ b/Model3d.cpp @@ -1217,11 +1217,11 @@ TSubModel *TModel3d::GetFromName(const char *sName) if (!sName) return Root; // potrzebne do terenu z E3D if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne - return Root ? Root->GetFromName(sName) : NULL; + return Root ? Root->GetFromName(sName) : nullptr; else // wczytano z pliku binarnego, można wyszukać iteracyjnie { // for (int i=0;iGetFromName(sName) : NULL; + return Root ? Root->GetFromName(sName) : nullptr; } }; diff --git a/Train.cpp b/Train.cpp index 7e6a1a79..5f768b8e 100644 --- a/Train.cpp +++ b/Train.cpp @@ -56,14 +56,16 @@ TCab::TCab() dimm_r = dimm_g = dimm_b = 1; intlit_r = intlit_g = intlit_b = 0; intlitlow_r = intlitlow_g = intlitlow_b = 0; +/* iGaugesMax = 100; // 95 - trzeba pobierać to z pliku konfiguracyjnego ggList = new TGauge[iGaugesMax]; iGauges = 0; // na razie nie są dodane iButtonsMax = 60; // 55 - trzeba pobierać to z pliku konfiguracyjnego btList = new TButton[iButtonsMax]; iButtons = 0; +*/ } - +/* void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, double Initz2, bool InitEnabled, bool InitOccupied) { @@ -76,9 +78,13 @@ void TCab::Init(double Initx1, double Inity1, double Initz1, double Initx2, doub bEnabled = InitEnabled; bOccupied = InitOccupied; } - +*/ void TCab::Load(cParser &Parser) { + // NOTE: clearing control tables here is bit of a crutch, imposed by current scheme of loading compartments anew on each cab change + ggList.clear(); + btList.clear(); + std::string token; Parser.getTokens(); Parser >> token; @@ -112,12 +118,15 @@ void TCab::Load(cParser &Parser) TCab::~TCab() { +/* delete[] ggList; delete[] btList; +*/ }; -TGauge *TCab::Gauge(int n) +TGauge &TCab::Gauge(int n) { // pobranie adresu obiektu aniomowanego ruchem +/* if (n < 0) { // rezerwacja wolnego ggList[iGauges].Clear(); @@ -126,9 +135,19 @@ TGauge *TCab::Gauge(int n) else if (n < iGauges) return ggList + n; return NULL; +*/ + if( n < 0 ) { + ggList.emplace_back(); + return ggList.back(); + } + else { + return ggList[ n ]; + } }; -TButton *TCab::Button(int n) + +TButton &TCab::Button(int n) { // pobranie adresu obiektu animowanego wyborem 1 z 2 +/* if (n < 0) { // rezerwacja wolnego return btList + iButtons++; @@ -136,10 +155,19 @@ TButton *TCab::Button(int n) else if (n < iButtons) return btList + n; return NULL; +*/ + if( n < 0 ) { + btList.emplace_back(); + return btList.back(); + } + else { + return btList[ n ]; + } }; void TCab::Update() { // odczyt parametrów i ustawienie animacji submodelom +/* int i; for (i = 0; i < iGauges; ++i) { // animacje izometryczne @@ -150,6 +178,16 @@ void TCab::Update() { // animacje dwustanowe btList[i].Update(); // odczyt parametru i wybór submodelu } +*/ + for( auto &gauge : ggList ) { + // animacje izometryczne + gauge.UpdateValue(); // odczyt parametru i przeliczenie na kąt + gauge.Update(); // ustawienie animacji + } + for( auto &button : btList ) { + // animacje dwustanowe + button.Update(); // odczyt parametru i wybór submodelu + } }; // NOTE: we're currently using universal handlers and static handler map but it may be beneficial to have these implemented on individual class instance basis @@ -519,10 +557,14 @@ void TTrain::OnCommand_mastercontrollerincrease( TTrain *Train, command_data con if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->IncMainCtrl( 1 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikJazdy ); } +#else + Train->mvControlled->IncMainCtrl( 1 ); +#endif } } @@ -530,10 +572,14 @@ void TTrain::OnCommand_mastercontrollerincreasefast( TTrain *Train, command_data if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->IncMainCtrl( 2 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikJazdy ); } +#else + Train->mvControlled->IncMainCtrl( 2 ); +#endif } } @@ -541,10 +587,14 @@ void TTrain::OnCommand_mastercontrollerdecrease( TTrain *Train, command_data con if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->DecMainCtrl( 1 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikJazdy ); } +#else + Train->mvControlled->DecMainCtrl( 1 ); +#endif } } @@ -552,10 +602,14 @@ void TTrain::OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->DecMainCtrl( 2 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikJazdy ); } +#else + Train->mvControlled->DecMainCtrl( 2 ); +#endif } } @@ -568,10 +622,16 @@ void TTrain::OnCommand_secondcontrollerincrease( TTrain *Train, command_data con if( Train->mvControlled->AnPos > 1 ) Train->mvControlled->AnPos = 1; } +#ifdef EU07_USE_OLD_CONTROLSOUNDS else if( Train->mvControlled->IncScndCtrl( 1 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikBocz, Train->dsbNastawnikJazdy, DSBVOLUME_MAX, 0 ); } +#else + else { + Train->mvControlled->IncScndCtrl( 1 ); + } +#endif } } @@ -579,10 +639,14 @@ void TTrain::OnCommand_secondcontrollerincreasefast( TTrain *Train, command_data if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->IncScndCtrl( 2 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikBocz, Train->dsbNastawnikJazdy, DSBVOLUME_MAX, 0 ); } +#else + Train->mvControlled->IncScndCtrl( 2 ); +#endif } } @@ -592,6 +656,7 @@ void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down if( false == Train->mvOccupied->AutoRelayFlag ) { // turn on +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvOccupied->AutoRelaySwitch( true ) ) { // audio feedback Train->play_sound( Train->dsbSwitch ); @@ -599,9 +664,13 @@ void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &C // NOTE: there's no button for notching relay control // TBD, TODO: add notching relay control button? } +#else + Train->mvOccupied->AutoRelaySwitch( true ); +#endif } else { //turn off +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvOccupied->AutoRelaySwitch( false ) ) { // audio feedback Train->play_sound( Train->dsbSwitch ); @@ -609,6 +678,9 @@ void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &C // NOTE: there's no button for notching relay control // TBD, TODO: add notching relay control button? } +#else + Train->mvOccupied->AutoRelaySwitch( false ); +#endif } } } @@ -625,20 +697,24 @@ void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, com if( Command.action == GLFW_PRESS ) { // turn on Train->ShowNextCurrent = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggNextCurrentButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggNextCurrentButton.UpdateValue( 1.0 ); } else if( Command.action == GLFW_RELEASE ) { //turn off Train->ShowNextCurrent = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggNextCurrentButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggNextCurrentButton.UpdateValue( 0.0 ); } @@ -653,10 +729,14 @@ void TTrain::OnCommand_secondcontrollerdecrease( TTrain *Train, command_data con if( Train->mvControlled->AnPos > 1 ) Train->mvControlled->AnPos = 1; } +#ifdef EU07_USE_OLD_CONTROLSOUNDS else if( Train->mvControlled->DecScndCtrl( 1 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikBocz, Train->dsbNastawnikJazdy, DSBVOLUME_MAX, 0 ); } +#else + Train->mvControlled->DecScndCtrl( 1 ); +#endif } } @@ -664,10 +744,14 @@ void TTrain::OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data if( Command.action != GLFW_RELEASE ) { // on press or hold +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->mvControlled->DecScndCtrl( 2 ) ) { // sound feedback Train->play_sound( Train->dsbNastawnikBocz, Train->dsbNastawnikJazdy, DSBVOLUME_MAX, 0 ); } +#else + Train->mvControlled->DecScndCtrl( 2 ); +#endif } } @@ -729,10 +813,12 @@ void TTrain::OnCommand_independentbrakebailoff( TTrain *Train, command_data cons if( Command.action != GLFW_RELEASE ) { // press or hold Train->mvOccupied->BrakeReleaser( 1 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggReleaserButton.GetValue() < 0.05 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggReleaserButton.UpdateValue( 1.0 ); } @@ -862,8 +948,8 @@ void TTrain::OnCommand_trainbrakefirstservice( TTrain *Train, command_data const // sound feedback if( ( Train->is_eztoer() ) - && ( Train->mvControlled->Mains ) - && ( Train->mvOccupied->BrakeCtrlPos != 1 ) ) { + && ( Train->mvControlled->Mains ) + && ( Train->mvOccupied->BrakeCtrlPos != 1 ) ) { Train->play_sound( Train->dsbPneumaticSwitch ); } @@ -934,10 +1020,12 @@ void TTrain::OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const if( Command.action != GLFW_RELEASE ) { // press or hold Train->mvControlled->AntiSlippingBrake(); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggAntiSlipButton.GetValue() < 0.05 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggAntiSlipButton.UpdateValue( 1.0 ); } @@ -967,8 +1055,10 @@ void TTrain::OnCommand_sandboxactivate( TTrain *Train, command_data const &Comma if( Command.action == GLFW_PRESS ) { // press Train->mvControlled->Sandbox( true ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); +#endif // visual feedback Train->ggSandButton.UpdateValue( 1.0 ); } @@ -1025,11 +1115,13 @@ void TTrain::OnCommand_brakeactingspeedincrease( TTrain *Train, command_data con Train->mvOccupied->BrakeDelayFlag << 1 : Train->mvOccupied->BrakeDelayFlag | bdelay_M ); if( true == Train->mvOccupied->BrakeDelaySwitch( fasterbrakesetting ) ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); /* Train->play_sound( Train->dsbPneumaticRelay ); */ +#endif // visual feedback if( Train->ggBrakeProfileCtrl.SubModel != nullptr ) { Train->ggBrakeProfileCtrl.UpdateValue( @@ -1065,11 +1157,13 @@ void TTrain::OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data con Train->mvOccupied->BrakeDelayFlag >> 1 : Train->mvOccupied->BrakeDelayFlag ^ bdelay_M ); if( true == Train->mvOccupied->BrakeDelaySwitch( slowerbrakesetting ) ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); /* Train->play_sound( Train->dsbPneumaticRelay ); */ +#endif // visual feedback if( Train->ggBrakeProfileCtrl.SubModel != nullptr ) { Train->ggBrakeProfileCtrl.UpdateValue( @@ -1111,20 +1205,24 @@ void TTrain::OnCommand_mubrakingindicatortoggle( TTrain *Train, command_data con if( false == Train->mvControlled->Signalling) { // turn on Train->mvControlled->Signalling = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggSignallingButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggSignallingButton.UpdateValue( 1.0 ); } else { //turn off Train->mvControlled->Signalling = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggSignallingButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggSignallingButton.UpdateValue( 0.0 ); } @@ -1136,8 +1234,10 @@ void TTrain::OnCommand_reverserincrease( TTrain *Train, command_data const &Comm if( Command.action == GLFW_PRESS ) { if( Train->mvOccupied->DirectionForward() ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbReverserKey, Train->dsbSwitch, DSBVOLUME_MAX, 0 ); +#endif // aktualizacja skrajnych pojazdów w składzie if( ( Train->mvOccupied->ActiveDir ) && ( Train->DynamicObject->Mechanik ) ) { @@ -1153,8 +1253,10 @@ void TTrain::OnCommand_reverserdecrease( TTrain *Train, command_data const &Comm if( Command.action == GLFW_PRESS ) { if( Train->mvOccupied->DirectionBackward() ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbReverserKey, Train->dsbSwitch, DSBVOLUME_MAX, 0 ); +#endif // aktualizacja skrajnych pojazdów w składzie if( ( Train->mvOccupied->ActiveDir ) && ( Train->DynamicObject->Mechanik ) ) { @@ -1181,10 +1283,12 @@ void TTrain::OnCommand_alerteracknowledge( TTrain *Train, command_data const &Co } // visual feedback Train->ggSecurityResetButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggSecurityResetButton.GetValue() < 0.05 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { // release @@ -1212,8 +1316,10 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command if( Train->ggBatteryButton.SubModel ) { Train->ggBatteryButton.UpdateValue( 1 ); } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); +#endif // side-effects if( Train->mvOccupied->LightsPosNo > 0 ) { Train->SetLights(); @@ -1232,8 +1338,10 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command if( Train->ggBatteryButton.SubModel ) { Train->ggBatteryButton.UpdateValue( 0 ); } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); +#endif // side-effects if( false == Train->mvControlled->ConverterFlag ) { // if there's no (low voltage) power source left, drop pantographs @@ -1254,8 +1362,10 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const Train->mvControlled->PantFrontSP = false; if( Train->mvControlled->PantFront( true ) ) { if( Train->mvControlled->PantFrontStart != 1 ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbSwitch ); +#endif // visual feedback Train->ggPantFrontButton.UpdateValue( 1.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses @@ -1284,8 +1394,10 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const Train->mvControlled->PantFrontSP = false; if( false == Train->mvControlled->PantFront( false ) ) { if( Train->mvControlled->PantFrontStart != 0 ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbSwitch ); +#endif // visual feedback Train->ggPantFrontButton.UpdateValue( 0.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses @@ -1303,17 +1415,21 @@ void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const else if( Command.action == GLFW_RELEASE ) { // impulse switches return automatically to neutral position if( Train->mvOccupied->PantSwitchType == "impulse" ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->ggPantFrontButton.GetValue() > 0.35 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->ggPantFrontButton.UpdateValue( 0.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses // TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantSelectedButton.UpdateValue( 0.0 ); // also the switch off button, in cabs which have it +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->ggPantFrontButtonOff.GetValue() > 0.35 ) { Train->play_sound( Train->dsbSwitch ); } +#endif if( Train->ggPantFrontButtonOff.SubModel ) { Train->ggPantFrontButtonOff.UpdateValue( 0.0 ); } @@ -1335,8 +1451,10 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const & Train->mvControlled->PantRearSP = false; if( Train->mvControlled->PantRear( true ) ) { if( Train->mvControlled->PantRearStart != 1 ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbSwitch ); +#endif // visual feedback Train->ggPantRearButton.UpdateValue( 1.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses @@ -1365,8 +1483,10 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const & Train->mvControlled->PantRearSP = false; if( false == Train->mvControlled->PantRear( false ) ) { if( Train->mvControlled->PantRearStart != 0 ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbSwitch ); +#endif // visual feedback Train->ggPantRearButton.UpdateValue( 0.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses @@ -1384,17 +1504,21 @@ void TTrain::OnCommand_pantographtogglerear( TTrain *Train, command_data const & else if( Command.action == GLFW_RELEASE ) { // impulse switches return automatically to neutral position if( Train->mvOccupied->PantSwitchType == "impulse" ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->ggPantRearButton.GetValue() > 0.35 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->ggPantRearButton.UpdateValue( 0.0 ); // NOTE: currently we animate the selectable pantograph control based on standard key presses // TODO: implement actual selection control, and refactor handling this control setup in a separate method Train->ggPantSelectedButton.UpdateValue( 0.0 ); // also the switch off button, in cabs which have it +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( Train->ggPantRearButtonOff.GetValue() > 0.35 ) { Train->play_sound( Train->dsbSwitch ); } +#endif if( Train->ggPantRearButtonOff.SubModel ) { Train->ggPantRearButtonOff.UpdateValue( 0.0 ); } @@ -1421,14 +1545,18 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle( TTrain *Train, command_d if( Train->mvControlled->bPantKurek3 == false ) { // connect pantographs with primary tank Train->mvControlled->bPantKurek3 = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); +#endif } else { // connect pantograps with pantograph compressor Train->mvControlled->bPantKurek3 = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback Train->play_sound( Train->dsbSwitch ); +#endif } } } @@ -1451,10 +1579,12 @@ void TTrain::OnCommand_pantographcompressoractivate( TTrain *Train, command_data if( Command.action != GLFW_RELEASE ) { // press or hold to activate Train->mvControlled->PantCompFlag = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Command.action == GLFW_PRESS ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { // release to disable @@ -1481,11 +1611,13 @@ void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Co // ...and rear Train->mvControlled->PantRearSP = false; Train->mvControlled->PantRear( false ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback // TODO: separate sound effect for pneumatic buttons if( Train->ggPantAllDownButton.GetValue() < 0.35 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggPantAllDownButton.UpdateValue( 1.0 ); if( Train->ggPantSelectedDownButton.SubModel != nullptr ) { @@ -1494,6 +1626,7 @@ void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Co } else if( Command.action == GLFW_RELEASE ) { // release the button +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback /* // NOTE: release sound disabled as this is typically pneumatic button @@ -1502,6 +1635,7 @@ void TTrain::OnCommand_pantographlowerall( TTrain *Train, command_data const &Co Train->play_sound( Train->dsbSwitch ); } */ +#endif // visual feedback Train->ggPantAllDownButton.UpdateValue( 0.0 ); if( Train->ggPantSelectedDownButton.SubModel != nullptr ) { @@ -1539,19 +1673,23 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com } if( Train->ggMainOnButton.SubModel != nullptr ) { // two separate switches to close and break the circuit +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Command.action == GLFW_PRESS ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainOnButton.UpdateValue( 1.0 ); } else if( Train->ggMainButton.SubModel != nullptr ) { // single two-state switch +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Command.action == GLFW_PRESS ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainButton.UpdateValue( 1.0 ); } @@ -1594,10 +1732,12 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com if( Train->ggMainOffButton.SubModel != nullptr ) { // two separate switches to close and break the circuit +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Command.action == GLFW_PRESS ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainOffButton.UpdateValue( 1.0 ); } @@ -1618,10 +1758,12 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com else */ { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Command.action == GLFW_PRESS ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainButton.UpdateValue( 0.0 ); } @@ -1647,20 +1789,24 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com // for setup with two separate swiches if( Train->ggMainOnButton.SubModel != nullptr ) { Train->ggMainOnButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggMainOnButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } if( Train->ggMainOffButton.SubModel != nullptr ) { Train->ggMainOffButton.UpdateValue( 0.0 ); } // and the two-state switch too, for good measure if( Train->ggMainButton.SubModel != nullptr ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggMainButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainButton.UpdateValue( 0.0 ); } @@ -1677,10 +1823,12 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com Train->mvControlled->CompressorSwitch( Train->ggCompressorButton.GetValue() > 0.5 ); } } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggMainOnButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback if( Train->ggMainOnButton.SubModel != nullptr ) { // setup with two separate switches @@ -1691,10 +1839,12 @@ void TTrain::OnCommand_linebreakertoggle( TTrain *Train, command_data const &Com // TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz if( Train->mvControlled->TrainType == dt_EZT ) { if( Train->ggMainButton.SubModel != nullptr ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggMainButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggMainButton.UpdateValue( 0.0 ); } @@ -1719,10 +1869,12 @@ void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Comma if( ( false == Train->mvControlled->ConverterAllow ) && ( Train->ggConverterButton.GetValue() < 0.5 ) ) { // turn on +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggConverterButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggConverterButton.UpdateValue( 1.0 ); /* @@ -1750,6 +1902,7 @@ void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Comma } else { //turn off +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->mvOccupied->ConvSwitchType == "impulse" ) { if( Train->ggConverterOffButton.GetValue() < 0.5 ) { @@ -1761,6 +1914,7 @@ void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Comma Train->play_sound( Train->dsbSwitch ); } } +#endif // visual feedback Train->ggConverterButton.UpdateValue( 0.0 ); if( Train->ggConverterOffButton.SubModel != nullptr ) { @@ -1789,11 +1943,13 @@ void TTrain::OnCommand_convertertoggle( TTrain *Train, command_data const &Comma // on button release... if( Train->mvOccupied->ConvSwitchType == "impulse" ) { // ...return switches to start position if applicable +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( ( Train->ggConverterButton.GetValue() > 0.0 ) || ( Train->ggConverterOffButton.GetValue() > 0.0 ) ) { // sound feedback Train->play_sound( Train->dsbSwitch ); } +#endif Train->ggConverterButton.UpdateValue( 0.0 ); Train->ggConverterOffButton.UpdateValue( 0.0 ); } @@ -1815,10 +1971,12 @@ void TTrain::OnCommand_convertertogglelocal( TTrain *Train, command_data const & if( ( false == Train->mvOccupied->ConverterAllowLocal ) && ( Train->ggConverterLocalButton.GetValue() < 0.5 ) ) { // turn on +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggConverterLocalButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggConverterLocalButton.UpdateValue( 1.0 ); // effect @@ -1836,10 +1994,12 @@ void TTrain::OnCommand_convertertogglelocal( TTrain *Train, command_data const & } else { //turn off +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggConverterLocalButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggConverterLocalButton.UpdateValue( 0.0 ); // effect @@ -1879,19 +2039,23 @@ void TTrain::OnCommand_converteroverloadrelayreset( TTrain *Train, command_data && ( Train->mvControlled->TrainType != dt_EZT ) ) { Train->mvControlled->ConvOvldFlag = false; } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggConverterFuseButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggConverterFuseButton.UpdateValue( 1.0 ); } else if( Command.action == GLFW_RELEASE ) { // release +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggConverterFuseButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggConverterFuseButton.UpdateValue( 0.0 ); } @@ -1909,10 +2073,12 @@ void TTrain::OnCommand_compressortoggle( TTrain *Train, command_data const &Comm // turn on // visual feedback Train->ggCompressorButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggCompressorButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // impulse type switch has no effect if there's no power // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway // (we're presuming impulse type switch for all EMUs for the time being) @@ -1925,8 +2091,10 @@ void TTrain::OnCommand_compressortoggle( TTrain *Train, command_data const &Comm else { //turn off if( true == Train->mvControlled->CompressorSwitch( false ) ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback Train->play_sound( Train->dsbSwitch ); +#endif // NOTE: we don't have switch type definition for the compresor switch // so for the time being we have hard coded "impulse" switches for all EMUs // TODO: have proper switch type config for all switches, and put it in the cab switch descriptions, not in the .fiz @@ -1973,10 +2141,12 @@ void TTrain::OnCommand_compressortogglelocal( TTrain *Train, command_data const // only reacting to press, so the switch doesn't flip back and forth if key is held down if( false == Train->mvOccupied->CompressorAllowLocal ) { // turn on +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggCompressorLocalButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCompressorLocalButton.UpdateValue( 1.0 ); // effect @@ -1984,10 +2154,12 @@ void TTrain::OnCommand_compressortogglelocal( TTrain *Train, command_data const } else { //turn off +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggCompressorLocalButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCompressorLocalButton.UpdateValue( 0.0 ); // effect @@ -2027,10 +2199,12 @@ void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &C Train->mvControlled->Couplers[ 1 ].Connected->StLinSwitchOff = true; } } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggStLinOffButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggStLinOffButton.UpdateValue( 1.0 ); // effect @@ -2074,10 +2248,12 @@ void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &C Train->mvControlled->Couplers[ 1 ].Connected->StLinSwitchOff = false; } } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggStLinOffButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggStLinOffButton.UpdateValue( 0.0 ); } @@ -2103,10 +2279,12 @@ void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &C Train->mvControlled->Couplers[ 1 ].Connected->StLinSwitchOff = false; } } +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggStLinOffButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggStLinOffButton.UpdateValue( 0.0 ); } @@ -2123,10 +2301,14 @@ void TTrain::OnCommand_motordisconnect( TTrain *Train, command_data const &Comma } if( Command.action == GLFW_PRESS ) { +#ifdef EU07_USE_OLD_CONTROLSOUNDS if( true == Train->mvControlled->CutOffEngine() ) { // sound feedback Train->play_sound( Train->dsbSwitch ); } +#else + Train->mvControlled->CutOffEngine(); +#endif } } @@ -2139,10 +2321,12 @@ void TTrain::OnCommand_motoroverloadrelaythresholdtoggle( TTrain *Train, command if( true == Train->mvControlled->CurrentSwitch( true ) ) { // visual feedback Train->ggMaxCurrentCtrl.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggMaxCurrentCtrl.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } else { @@ -2150,10 +2334,12 @@ void TTrain::OnCommand_motoroverloadrelaythresholdtoggle( TTrain *Train, command if( true == Train->mvControlled->CurrentSwitch( false ) ) { // visual feedback Train->ggMaxCurrentCtrl.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggMaxCurrentCtrl.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2171,19 +2357,23 @@ void TTrain::OnCommand_motoroverloadrelayreset( TTrain *Train, command_data cons if( Command.action == GLFW_PRESS ) { // press Train->mvControlled->FuseOn(); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggFuseButton.GetValue() < 0.05 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggFuseButton.UpdateValue( 1.0 ); } else if( Command.action == GLFW_RELEASE ) { // release +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggFuseButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggFuseButton.UpdateValue( 0.0 ); } @@ -2208,20 +2398,24 @@ void TTrain::OnCommand_headlighttoggleleft( TTrain *Train, command_data const &C Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_left; // visual feedback Train->ggLeftLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggLeftLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_left; // visual feedback Train->ggLeftLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggLeftLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2245,20 +2439,24 @@ void TTrain::OnCommand_headlighttoggleright( TTrain *Train, command_data const & Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_right; // visual feedback Train->ggRightLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRightLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_right; // visual feedback Train->ggRightLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRightLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2282,20 +2480,24 @@ void TTrain::OnCommand_headlighttoggleupper( TTrain *Train, command_data const & Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggUpperLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_upper; // visual feedback Train->ggUpperLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggUpperLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2319,20 +2521,24 @@ void TTrain::OnCommand_redmarkertoggleleft( TTrain *Train, command_data const &C Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_left; // visual feedback Train->ggLeftEndLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggLeftEndLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_left; // visual feedback Train->ggLeftEndLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggLeftEndLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2356,20 +2562,24 @@ void TTrain::OnCommand_redmarkertoggleright( TTrain *Train, command_data const & Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_right; // visual feedback Train->ggRightEndLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRightEndLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_right; // visual feedback Train->ggRightEndLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRightEndLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2394,20 +2604,24 @@ void TTrain::OnCommand_headlighttogglerearleft( TTrain *Train, command_data cons Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearLeftLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_right; // visual feedback Train->ggRearLeftLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearLeftLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2432,20 +2646,24 @@ void TTrain::OnCommand_headlighttogglerearright( TTrain *Train, command_data con Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearRightLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_left; // visual feedback Train->ggRearRightLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearRightLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2469,20 +2687,24 @@ void TTrain::OnCommand_headlighttogglerearupper( TTrain *Train, command_data con Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearUpperLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::headlight_upper; // visual feedback Train->ggRearUpperLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearUpperLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2507,20 +2729,24 @@ void TTrain::OnCommand_redmarkertogglerearleft( TTrain *Train, command_data cons Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearLeftEndLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_right; // visual feedback Train->ggRearLeftEndLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearLeftEndLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2545,20 +2771,24 @@ void TTrain::OnCommand_redmarkertogglerearright( TTrain *Train, command_data con Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearRightEndLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } else { //turn off Train->DynamicObject->iLights[ lightsindex ] ^= TMoverParameters::light::redmarker_left; // visual feedback Train->ggRearRightEndLightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggRearRightEndLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif } } } @@ -2579,20 +2809,24 @@ void TTrain::OnCommand_headlightsdimtoggle( TTrain *Train, command_data const &C if( false == Train->DynamicObject->DimHeadlights ) { // turn on Train->DynamicObject->DimHeadlights = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDimHeadlightsButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDimHeadlightsButton.UpdateValue( 1.0 ); } else { //turn off Train->DynamicObject->DimHeadlights = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDimHeadlightsButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDimHeadlightsButton.UpdateValue( 0.0 ); } @@ -2616,10 +2850,12 @@ void TTrain::OnCommand_interiorlighttoggle( TTrain *Train, command_data const &C // turn on Train->bCabLight = true; Train->btCabLight.TurnOn(); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggCabLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCabLightButton.UpdateValue( 1.0 ); } @@ -2627,10 +2863,12 @@ void TTrain::OnCommand_interiorlighttoggle( TTrain *Train, command_data const &C //turn off Train->bCabLight = false; Train->btCabLight.TurnOff(); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggCabLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCabLightButton.UpdateValue( 0.0 ); } @@ -2652,20 +2890,24 @@ void TTrain::OnCommand_interiorlightdimtoggle( TTrain *Train, command_data const if( false == Train->bCabLightDim ) { // turn on Train->bCabLightDim = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggCabLightDimButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCabLightDimButton.UpdateValue( 1.0 ); } else { //turn off Train->bCabLightDim = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggCabLightDimButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggCabLightDimButton.UpdateValue( 0.0 ); } @@ -2689,20 +2931,24 @@ void TTrain::OnCommand_instrumentlighttoggle( TTrain *Train, command_data const if( false == Train->InstrumentLightActive ) { // turn on Train->InstrumentLightActive = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggInstrumentLightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggInstrumentLightButton.UpdateValue( 1.0 ); } else { //turn off Train->InstrumentLightActive = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggInstrumentLightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggInstrumentLightButton.UpdateValue( 0.0 ); } @@ -2723,20 +2969,24 @@ void TTrain::OnCommand_heatingtoggle( TTrain *Train, command_data const &Command if( false == Train->mvControlled->Heating ) { // turn on Train->mvControlled->Heating = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggTrainHeatingButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggTrainHeatingButton.UpdateValue( 1.0 ); } else { //turn off Train->mvControlled->Heating = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggTrainHeatingButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggTrainHeatingButton.UpdateValue( 0.0 ); } @@ -2759,19 +3009,23 @@ void TTrain::OnCommand_generictoggle( TTrain *Train, command_data const &Command // only reacting to press, so the switch doesn't flip back and forth if key is held down if( item.GetValue() < 0.25 ) { // turn on +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( item.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback item.UpdateValue( 1.0 ); } else { //turn off +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( item.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback item.UpdateValue( 0.0 ); } @@ -2794,10 +3048,12 @@ void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Comman // TODO: check wheter we really need separate flags for this Train->mvControlled->DoorSignalling = true; Train->mvOccupied->DoorBlocked = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDoorSignallingButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDoorSignallingButton.UpdateValue( 1.0 ); } @@ -2806,10 +3062,12 @@ void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Comman // TODO: check wheter we really need separate flags for this Train->mvControlled->DoorSignalling = false; Train->mvOccupied->DoorBlocked = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDoorSignallingButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDoorSignallingButton.UpdateValue( 0.0 ); } @@ -2831,10 +3089,12 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman if( Train->mvOccupied->ActiveCab == 1 ) { if( Train->mvOccupied->DoorLeft( true ) ) { Train->ggDoorLeftButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorLeftButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorOpen ); } } @@ -2842,10 +3102,12 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman // in the rear cab sides are reversed if( Train->mvOccupied->DoorRight( true ) ) { Train->ggDoorRightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorRightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorOpen ); } } @@ -2855,10 +3117,12 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman if( Train->mvOccupied->ActiveCab == 1 ) { if( Train->mvOccupied->DoorLeft( false ) ) { Train->ggDoorLeftButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorLeftButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorClose ); } } @@ -2866,10 +3130,12 @@ void TTrain::OnCommand_doortoggleleft( TTrain *Train, command_data const &Comman // in the rear cab sides are reversed if( Train->mvOccupied->DoorRight( false ) ) { Train->ggDoorRightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorRightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorClose ); } } @@ -2892,10 +3158,12 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma if( Train->mvOccupied->ActiveCab == 1 ) { if( Train->mvOccupied->DoorRight( true ) ) { Train->ggDoorRightButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorRightButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorOpen ); } } @@ -2903,10 +3171,12 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma // in the rear cab sides are reversed if( Train->mvOccupied->DoorLeft( true ) ) { Train->ggDoorLeftButton.UpdateValue( 1.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorLeftButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorOpen ); } } @@ -2916,10 +3186,12 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma if( Train->mvOccupied->ActiveCab == 1 ) { if( Train->mvOccupied->DoorRight( false ) ) { Train->ggDoorRightButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorRightButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorClose ); } } @@ -2927,10 +3199,12 @@ void TTrain::OnCommand_doortoggleright( TTrain *Train, command_data const &Comma // in the rear cab sides are reversed if( Train->mvOccupied->DoorLeft( false ) ) { Train->ggDoorLeftButton.UpdateValue( 0.0 ); +#ifdef EU07_USE_OLD_CONTROLSOUNDS // sound feedback if( Train->ggDoorLeftButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif Train->play_sound( Train->dsbDoorClose ); } } @@ -2952,10 +3226,12 @@ void TTrain::OnCommand_departureannounce( TTrain *Train, command_data const &Com if( false == Train->mvControlled->DepartureSignal ) { // turn on Train->mvControlled->DepartureSignal = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDepartureSignalButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDepartureSignalButton.UpdateValue( 1.0 ); } @@ -2963,10 +3239,12 @@ void TTrain::OnCommand_departureannounce( TTrain *Train, command_data const &Com else if( Command.action == GLFW_RELEASE ) { // turn off Train->mvControlled->DepartureSignal = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggDepartureSignalButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggDepartureSignalButton.UpdateValue( 0.0 ); } @@ -2993,11 +3271,13 @@ void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Comma Train->mvControlled->WarningSignal &= ~2; } */ +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( ( Train->ggHornButton.GetValue() > -0.5 ) || ( Train->ggHornLowButton.GetValue() < 0.5 ) ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggHornButton.UpdateValue( -1.0 ); Train->ggHornLowButton.UpdateValue( 1.0 ); @@ -3010,11 +3290,13 @@ void TTrain::OnCommand_hornlowactivate( TTrain *Train, command_data const &Comma Train->mvOccupied->WarningSignal &= ~( 1 | 2 ); */ Train->mvOccupied->WarningSignal &= ~1; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( ( Train->ggHornButton.GetValue() < -0.5 ) || ( Train->ggHornLowButton.GetValue() > 0.5 ) ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggHornButton.UpdateValue( 0.0 ); Train->ggHornLowButton.UpdateValue( 0.0 ); @@ -3042,10 +3324,12 @@ void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Comm Train->mvControlled->WarningSignal &= ~1; } */ +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggHornButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggHornButton.UpdateValue( 1.0 ); Train->ggHornHighButton.UpdateValue( 1.0 ); @@ -3058,10 +3342,12 @@ void TTrain::OnCommand_hornhighactivate( TTrain *Train, command_data const &Comm Train->mvOccupied->WarningSignal &= ~( 1 | 2 ); */ Train->mvOccupied->WarningSignal &= ~2; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggHornButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggHornButton.UpdateValue( 0.0 ); Train->ggHornHighButton.UpdateValue( 0.0 ); @@ -3085,20 +3371,24 @@ void TTrain::OnCommand_radiotoggle( TTrain *Train, command_data const &Command ) if( false == Train->mvOccupied->Radio ) { // turn on Train->mvOccupied->Radio = true; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggRadioButton.GetValue() < 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggRadioButton.UpdateValue( 1.0 ); } else { // turn off Train->mvOccupied->Radio = false; +#ifdef EU07_USE_OLD_CONTROLSOUNDS // audio feedback if( Train->ggRadioButton.GetValue() > 0.5 ) { Train->play_sound( Train->dsbSwitch ); } +#endif // visual feedback Train->ggRadioButton.UpdateValue( 0.0 ); } @@ -6452,8 +6742,7 @@ bool TTrain::InitializeCab(int NewCabNo, std::string const &asFileName) { // ABu: wstawione warunki, wczesniej tylko to: // str=Parser->GetNextSymbol().LowerCase(); - if (parse == true) - { + if (parse == true) { token = ""; parser->getTokens(); @@ -7032,9 +7321,9 @@ void TTrain::set_cab_controls() { // TODO: refactor the cabin controls into some sensible structure bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int const Cabindex) { - +/* TButton *bt; // roboczy wskaźnik na obiekt animujący lampkę - +*/ // SEKCJA LAMPEK if (Label == "i-maxft:") { @@ -7250,9 +7539,9 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co else if (Label == "i-doors:") { int i = Parser.getToken() - 1; - bt = Cabine[Cabindex].Button(-1); // pierwsza wolna lampka - bt->Load(Parser, DynamicObject->mdKabina); - bt->AssignBool(bDoors[0] + 3 * i); + auto &button = Cabine[Cabindex].Button(-1); // pierwsza wolna lampka + button.Load(Parser, DynamicObject->mdKabina); + button.AssignBool(bDoors[0] + 3 * i); } else { @@ -7269,7 +7558,9 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co // TODO: refactor the cabin controls into some sensible structure bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex) { +/* TGauge *gg { nullptr }; // roboczy wskaźnik na obiekt animujący gałkę +*/ std::unordered_map gauges = { { "mainctrl:", ggMainCtrl }, { "scndctrl:", ggScndCtrl }, @@ -7350,73 +7641,55 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con else if( Label == "mainctrlact:" ) { ggMainCtrlAct.Load( Parser, DynamicObject->mdKabina, DynamicObject->mdModel ); } -/* - else if (Label == "universal1:") - { - ggUniversal1Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal2:") - { - ggUniversal2Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal3:") - { - ggInstrumentLightButton.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } - else if (Label == "universal4:") - { - ggUniversal4Button.Load(Parser, DynamicObject->mdKabina, DynamicObject->mdModel); - } -*/ // SEKCJA WSKAZNIKOW else if ((Label == "tachometer:") || (Label == "tachometerb:")) { // predkosciomierz wskaźnikowy z szarpaniem - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocityJump); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocityJump); } else if (Label == "tachometern:") { // predkosciomierz wskaźnikowy bez szarpania - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocity); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocity); } else if (Label == "tachometerd:") { // predkosciomierz cyfrowy - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fTachoVelocity); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fTachoVelocity); } else if ((Label == "hvcurrent1:") || (Label == "hvcurrent1b:")) { // 1szy amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 1); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 1); } else if ((Label == "hvcurrent2:") || (Label == "hvcurrent2b:")) { // 2gi amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 2); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 2); } else if ((Label == "hvcurrent3:") || (Label == "hvcurrent3b:")) { // 3ci amperomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałska - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent + 3); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałska + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent + 3); } else if ((Label == "hvcurrent:") || (Label == "hvcurrentb:")) { // amperomierz calkowitego pradu - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fHCurrent); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fHCurrent); } else if (Label == "eimscreen:") { @@ -7424,9 +7697,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con int i, j; Parser.getTokens(2, false); Parser >> i >> j; - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fEIMParams[i][j]); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fEIMParams[i][j]); } else if (Label == "brakes:") { @@ -7434,43 +7707,43 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con int i, j; Parser.getTokens(2, false); Parser >> i >> j; - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fPress[i - 1][j]); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fPress[i - 1][j]); } else if ((Label == "brakepress:") || (Label == "brakepressb:")) { // manometr cylindrow hamulcowych // Ra 2014-08: przeniesione do TCab - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->BrakePress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->BrakePress); } else if ((Label == "pipepress:") || (Label == "pipepressb:")) { // manometr przewodu hamulcowego - TGauge *gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->PipePress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->PipePress); } else if (Label == "limpipepress:") { // manometr zbiornika sterujacego zaworu maszynisty - ggZbS.Load(Parser, DynamicObject->mdKabina, NULL, 0.1); + ggZbS.Load(Parser, DynamicObject->mdKabina, nullptr, 0.1); } else if (Label == "cntrlpress:") { // manometr zbiornika kontrolnego/rorzďż˝du - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvControlled->PantPress); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvControlled->PantPress); } else if ((Label == "compressor:") || (Label == "compressorb:")) { // manometr sprezarki/zbiornika glownego - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina, NULL, 0.1); - gg->AssignDouble(&mvOccupied->Compressor); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina, nullptr, 0.1); + gauge.AssignDouble(&mvOccupied->Compressor); } // yB - dla drugiej sekcji else if (Label == "hvbcurrent1:") @@ -7500,12 +7773,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con if (Parser.getToken() == "analog") { // McZapkie-300302: zegarek - ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), gt_Rotate, - 0.016666667, 0, 0); - ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), gt_Rotate, - 0.016666667, 0, 0); - ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), gt_Rotate, - 0.083333333, 0, 0); + ggClockSInd.Init(DynamicObject->mdKabina->GetFromName("ClockShand"), gt_Rotate, 1.0/60.0, 0, 0); + ggClockMInd.Init(DynamicObject->mdKabina->GetFromName("ClockMhand"), gt_Rotate, 1.0/60.0, 0, 0); + ggClockHInd.Init(DynamicObject->mdKabina->GetFromName("ClockHhand"), gt_Rotate, 1.0/12.0, 0, 0); } } else if (Label == "evoltage:") @@ -7516,9 +7786,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con else if (Label == "hvoltage:") { // woltomierz wysokiego napiecia - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(&fHVoltage); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(&fHVoltage); } else if (Label == "lvoltage:") { @@ -7528,29 +7798,29 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con else if (Label == "enrot1m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 1); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 1); } // ggEnrot1m.Load(Parser,DynamicObject->mdKabina); else if (Label == "enrot2m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 2); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 2); } // ggEnrot2m.Load(Parser,DynamicObject->mdKabina); else if (Label == "enrot3m:") { // obrotomierz - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignFloat(fEngine + 3); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignFloat(fEngine + 3); } // ggEnrot3m.Load(Parser,DynamicObject->mdKabina); else if (Label == "engageratio:") { // np. ciśnienie sterownika sprzęgła - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignDouble(&mvControlled->dizel_engage); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignDouble(&mvControlled->dizel_engage); } // ggEngageRatio.Load(Parser,DynamicObject->mdKabina); else if (Label == "maingearstatus:") { @@ -7564,9 +7834,9 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con else if (Label == "distcounter:") { // Ra 2014-07: licznik kilometrów - gg = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka - gg->Load(Parser, DynamicObject->mdKabina); - gg->AssignDouble(&mvControlled->DistCounter); + auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka + gauge.Load(Parser, DynamicObject->mdKabina); + gauge.AssignDouble(&mvControlled->DistCounter); } else { diff --git a/Train.h b/Train.h index 6d8fcef9..c9c9e6d2 100644 --- a/Train.h +++ b/Train.h @@ -34,8 +34,9 @@ class TCab public: TCab(); ~TCab(); - void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, - double Initz2, bool InitEnabled, bool InitOccupied); +/* + void Init(double Initx1, double Inity1, double Initz1, double Initx2, double Inity2, double Initz2, bool InitEnabled, bool InitOccupied); +*/ void Load(cParser &Parser); vector3 CabPos1; vector3 CabPos2; @@ -43,17 +44,19 @@ class TCab bool bOccupied; double dimm_r, dimm_g, dimm_b; // McZapkie-120503: tlumienie swiatla double intlit_r, intlit_g, intlit_b; // McZapkie-120503: oswietlenie kabiny - double intlitlow_r, intlitlow_g, - intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny + double intlitlow_r, intlitlow_g, intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny private: - // bool bChangePossible; +/* TGauge *ggList; // Ra 2014-08: lista animacji macierzowych (gałek) w kabinie int iGaugesMax, iGauges; // ile miejsca w tablicy i ile jest w użyciu TButton *btList; // Ra 2014-08: lista animacji dwustanowych (lampek) w kabinie int iButtonsMax, iButtons; // ile miejsca w tablicy i ile jest w użyciu +*/ + std::vector ggList; + std::vector btList; public: - TGauge *Gauge(int n = -1); // pobranie adresu obiektu - TButton *Button(int n = -1); // pobranie adresu obiektu + TGauge &Gauge(int n = -1); // pobranie adresu obiektu + TButton &Button(int n = -1); // pobranie adresu obiektu void Update(); }; @@ -103,11 +106,9 @@ class TTrain // sets cabin controls based on current state of the vehicle // NOTE: we can get rid of this function once we have per-cab persistent state void set_cab_controls(); - // initializes a gauge matching provided label. returns: true if the label was found, false - // otherwise + // initializes a gauge matching provided label. returns: true if the label was found, false otherwise bool initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex); - // initializes a button matching provided label. returns: true if the label was found, false - // otherwise + // initializes a button matching provided label. returns: true if the label was found, false otherwise bool initialize_button(cParser &Parser, std::string const &Label, int const Cabindex); // plays specified sound, or fallback sound if the primary sound isn't presend // NOTE: temporary routine until sound system is sorted out and paired with switches @@ -209,12 +210,7 @@ public: // reszta może by?publiczna TGauge ggClockSInd; TGauge ggClockMInd; TGauge ggClockHInd; - // TGauge ggHVoltage; TGauge ggLVoltage; - // TGauge ggEnrot1m; - // TGauge ggEnrot2m; - // TGauge ggEnrot3m; - // TGauge ggEngageRatio; TGauge ggMainGearStatus; TGauge ggEngineVoltage; @@ -277,13 +273,7 @@ public: // reszta może by?publiczna TGauge ggHornLowButton; TGauge ggHornHighButton; TGauge ggNextCurrentButton; -/* - // ABu 090305 - uniwersalne przyciski - TGauge ggUniversal1Button; - TGauge ggUniversal2Button; - TGauge ggUniversal4Button; - bool Universal4Active; -*/ + std::array ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table TGauge ggInstrumentLightButton; @@ -336,7 +326,6 @@ public: // reszta może by?publiczna TButton btLampkaRadio; TButton btLampkaHamowanie1zes; TButton btLampkaHamowanie2zes; - // TButton btLampkaUnknown; TButton btLampkaOpory; TButton btLampkaWysRozr; TButton btInstrumentLight; @@ -363,8 +352,6 @@ public: // reszta może by?publiczna TButton btLampkaBoczniki; TButton btLampkaMaxSila; TButton btLampkaPrzekrMaxSila; - // TButton bt; - // TButton btLampkaDoorLeft; TButton btLampkaDoorRight; TButton btLampkaDepartureSignal; @@ -439,8 +426,6 @@ public: // reszta może by?publiczna PSound dsbHasler; PSound dsbBuzzer; PSound dsbSlipAlarm; // Bombardier 011010: alarm przy poslizgu dla 181/182 - // TFadeSound sConverter; //przetwornica - // TFadeSound sSmallCompressor; //przetwornica int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne) bool bCabLight; // hunter-091012: czy swiatlo jest zapalone? @@ -454,11 +439,6 @@ public: // reszta może by?publiczna PSound dsbCouplerStretch; PSound dsbEN57_CouplerStretch; PSound dsbBufferClamp; - // TSubModel *smCzuwakShpOn; - // TSubModel *smCzuwakOn; - // TSubModel *smShpOn; - // TSubModel *smCzuwakShpOff; - // double fCzuwakTimer; double fBlinkTimer; float fHaslerTimer; float fConverterTimer; // hunter-261211: dla przekaznika diff --git a/TrkFoll.cpp b/TrkFoll.cpp index d610058e..77c0adf4 100644 --- a/TrkFoll.cpp +++ b/TrkFoll.cpp @@ -114,7 +114,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) { // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma) if (fDistance < 0) { - if (iSetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik + if (SetFlag(iEventFlag, -1)) // zawsze zeruje flagę sprawdzenia, jak mechanik // dosiądzie, to się nie wykona if (Owner->Mechanik->Primary()) // tylko dla jednego członu // if (TestFlag(iEventFlag,1)) //McZapkie-280503: wyzwalanie event tylko dla @@ -126,7 +126,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) // Owner->RaAxleEvent(pCurrentTrack->Event1); //Ra: dynamic zdecyduje, czy dodać do // kolejki // if (TestFlag(iEventallFlag,1)) - if (iSetFlag(iEventallFlag, + if (SetFlag(iEventallFlag, -1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow if (bPrimary && pCurrentTrack->evEventall1 && (!pCurrentTrack->evEventall1->iQueued)) @@ -136,7 +136,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) } else if (fDistance > 0) { - if (iSetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik + if (SetFlag(iEventFlag, -2)) // zawsze ustawia flagę sprawdzenia, jak mechanik // dosiądzie, to się nie wykona if (Owner->Mechanik->Primary()) // tylko dla jednego członu // if (TestFlag(iEventFlag,2)) //sprawdzanie jest od razu w pierwszym @@ -147,7 +147,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary) // Owner->RaAxleEvent(pCurrentTrack->Event2); //Ra: dynamic zdecyduje, czy dodać do // kolejki // if (TestFlag(iEventallFlag,2)) - if (iSetFlag(iEventallFlag, + if (SetFlag(iEventallFlag, -2)) // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0 if (bPrimary && pCurrentTrack->evEventall2 && (!pCurrentTrack->evEventall2->iQueued)) diff --git a/parser.h b/parser.h index 7582c0e1..b8176c0a 100644 --- a/parser.h +++ b/parser.h @@ -33,29 +33,28 @@ class cParser //: public std::stringstream virtual ~cParser(); // methods: template - cParser& + cParser & operator>>( Type_ &Right ); template <> - cParser& + cParser & operator>>( std::string &Right ); template <> - cParser& + cParser & operator>>( bool &Right ); - template - _Output - getToken( bool const ToLower = true ) - { - getTokens( 1, ToLower ); - _Output output; - *this >> output; - return output; - }; + template + Output_ + getToken( bool const ToLower = true, const char *Break = "\n\r\t ;" ) { + getTokens( 1, ToLower, Break ); + Output_ output; + *this >> output; + return output; }; template <> bool - getToken( bool const ToLower ) { - - return ( getToken() == "true" ); - } + getToken( bool const ToLower, const char *Break ) { + auto const token = getToken( true, Break ); + return ( ( token == "true" ) + || ( token == "yes" ) + || ( token == "1" ) ); } inline void ignoreToken() { readToken(); @@ -77,7 +76,13 @@ class cParser //: public std::stringstream { return !mStream->fail(); }; - bool getTokens(unsigned int Count = 1, bool ToLower = true, const char *Break = "\n\r\t ;"); + bool getTokens(unsigned int Count = 1, bool ToLower = true, char const *Break = "\n\r\t ;"); + // returns next incoming token, if any, without removing it from the set + std::string peek() const { + return ( + false == tokens.empty() ? + tokens.front() : + "" ); } // returns percentage of file processed so far int getProgress() const; int getFullProgress() const; diff --git a/uilayer.cpp b/uilayer.cpp index e6ca85c5..0a98e41b 100644 --- a/uilayer.cpp +++ b/uilayer.cpp @@ -44,7 +44,7 @@ ui_layer::init( GLFWwindow *Window ) { DEFAULT_PITCH | FF_DONTCARE, // family and pitch "Lucida Console"); // font name ::SelectObject(hDC, font); // selects the font we want - if( true == ::wglUseFontBitmaps( hDC, 32, 96, m_fontbase ) ) { + if( TRUE == ::wglUseFontBitmaps( hDC, 32, 96, m_fontbase ) ) { // builds 96 characters starting at character 32 WriteLog( "Display Lists font used" ); //+AnsiString(glGetError()) WriteLog( "Font init OK" ); //+AnsiString(glGetError()) @@ -151,8 +151,8 @@ ui_layer::render_progress() { Global::iWindowWidth ); float const heightratio = ( screenratio >= ( 4.0f / 3.0f ) ? - Global::iWindowHeight / 768.0 : - Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) ); + Global::iWindowHeight / 768.f : + Global::iWindowHeight / 768.f * screenratio / ( 4.0f / 3.0f ) ); float const height = 768.0f * heightratio; ::glColor4f( 216.0f / 255.0f, 216.0f / 255.0f, 216.0f / 255.0f, 1.0f ); @@ -176,8 +176,8 @@ ui_layer::render_panels() { glPushAttrib( GL_ENABLE_BIT ); glDisable( GL_TEXTURE_2D ); - float const width = std::min( 4.0f / 3.0f, static_cast(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight; - float const height = Global::iWindowHeight / 768.0; + float const width = std::min( 4.f / 3.f, static_cast(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight; + float const height = Global::iWindowHeight / 768.f; for( auto const &panel : m_panels ) { @@ -186,8 +186,8 @@ ui_layer::render_panels() { ::glColor4fv( &line.color.x ); ::glRasterPos2f( - 0.5 * ( Global::iWindowWidth - width ) + panel->origin_x * height, - panel->origin_y * height + 20.0 * lineidx ); + 0.5f * ( Global::iWindowWidth - width ) + panel->origin_x * height, + panel->origin_y * height + 20.f * lineidx ); print( line.data ); ++lineidx; } @@ -255,14 +255,14 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) { float const screenratio = static_cast( Global::iWindowWidth ) / Global::iWindowHeight; float const width = - ( screenratio >= (4.0f/3.0f) ? - ( 4.0f / 3.0f ) * Global::iWindowHeight : + ( screenratio >= ( 4.f / 3.f ) ? + ( 4.f / 3.f ) * Global::iWindowHeight : Global::iWindowWidth ); float const heightratio = - ( screenratio >= ( 4.0f / 3.0f ) ? - Global::iWindowHeight / 768.0 : - Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) ); - float const height = 768.0f * heightratio; + ( screenratio >= ( 4.f / 3.f ) ? + Global::iWindowHeight / 768.f : + Global::iWindowHeight / 768.f * screenratio / ( 4.f / 3.f ) ); + float const height = 768.f * heightratio; /* float const heightratio = Global::iWindowHeight / 768.0f; float const height = 768.0f * heightratio; @@ -272,10 +272,10 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) { glBegin( GL_TRIANGLE_STRIP ); - glTexCoord2f( 0.0f, 1.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio ); - glTexCoord2f( 0.0f, 0.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio ); - glTexCoord2f( 1.0f, 1.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio ); - glTexCoord2f( 1.0f, 0.0f ); glVertex2f( 0.5 * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5 * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio ); + glTexCoord2f( 0.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio ); + glTexCoord2f( 0.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio ); + glTexCoord2f( 1.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.y * heightratio ); + glTexCoord2f( 1.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio ); glEnd(); } diff --git a/version.h b/version.h index 2fe8cfad..53cafe07 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #pragma once #define VERSION_MAJOR 17 -#define VERSION_MINOR 712 +#define VERSION_MINOR 714 #define VERSION_REVISION 0