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

custom sounds for cab controls configurable on per-item basis

This commit is contained in:
tmj-fstate
2017-07-15 19:27:49 +02:00
parent 4f9000ebe2
commit 3a67219e30
15 changed files with 687 additions and 570 deletions

View File

@@ -1717,7 +1717,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
if (ConversionError == -8) if (ConversionError == -8)
ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz"); ErrorLog("Missed file: " + BaseDir + "\\" + Type_Name + ".fiz");
Error("Cannot load dynamic object " + asName + " from:\r\n" + BaseDir + "\\" + Type_Name + 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 return 0.0; // zerowa długość to brak pojazdu
} }
bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch bool driveractive = (fVel != 0.0); // jeśli prędkość niezerowa, to aktywujemy ruch

View File

@@ -21,8 +21,8 @@ class TFadeSound
fTime = 0.0f; fTime = 0.0f;
TSoundState State = ss_Off; TSoundState State = ss_Off;
public: public:
TFadeSound(); TFadeSound() = default;
~TFadeSound(); ~TFadeSound();
void Init(std::string const &Name, float fNewFade); void Init(std::string const &Name, float fNewFade);
void TurnOn(); void TurnOn();

190
Gauge.cpp
View File

@@ -20,31 +20,7 @@ http://mozilla.org/MPL/2.0/.
#include "Timer.h" #include "Timer.h"
#include "logs.h" #include "logs.h"
TGauge::TGauge() void TGauge::Init(TSubModel *NewSubModel, TGaugeType eNewType, double fNewScale, double fNewOffset, double fNewFriction, double fNewValue)
{
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)
{ // ustawienie parametrów animacji submodelu { // ustawienie parametrów animacji submodelu
if (NewSubModel) if (NewSubModel)
{ // warunek na wszelki wypadek, gdyby się submodel nie { // 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) bool TGauge::Load(cParser &Parser, TModel3d *md1, TModel3d *md2, double mul) {
{
std::string str1 = Parser.getToken<std::string>(false); std::string submodelname, gaugetypename;
std::string str2 = Parser.getToken<std::string>(); double scale, offset, friction;
Parser.getTokens( 3, false );
double val3, val4, val5; Parser.getTokens();
Parser if( Parser.peek() != "{" ) {
>> val3 // old fixed size config
>> val4 Parser >> submodelname;
>> val5; gaugetypename = Parser.getToken<std::string>( true );
val3 *= mul; Parser.getTokens( 3, false );
TSubModel *sm = md1->GetFromName( str1.c_str() ); Parser
if( val3 == 0.0 ) { >> scale
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" ); >> offset
val3 = 1.0; >> friction;
} }
if (sm) // jeśli nie znaleziony else {
md2 = NULL; // informacja, że znaleziony // new, block type config
else if (md2) // a jest podany drugi model (np. zewnętrzny) // TODO: rework the base part into yaml-compatible flow style mapping
sm = md2->GetFromName(str1.c_str()); // to może tam będzie, co za różnica gdzie cParser mappingparser( Parser.getToken<std::string>( false, "}" ) );
if( sm == nullptr ) { submodelname = mappingparser.getToken<std::string>( false );
ErrorLog( "Failed to locate sub-model \"" + str1 + "\" in 3d model \"" + md1->NameGet() + "\"" ); gaugetypename = mappingparser.getToken<std::string>( 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") scale *= mul;
Init(sm, gt_Move, val3, val4, val5); TSubModel *submodel = md1->GetFromName( submodelname.c_str() );
else if (str2 == "wip") if( scale == 0.0 ) {
Init(sm, gt_Wiper, val3, val4, val5); 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" );
else if (str2 == "dgt") scale = 1.0;
Init(sm, gt_Digital, val3, val4, val5); }
else if (submodel) // jeśli nie znaleziony
Init(sm, gt_Rotate, val3, val4, val5); 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<std::string, TGaugeType> 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 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) void TGauge::PermIncValue(double fNewDesired)
{ {
fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset; fDesiredValue = fDesiredValue + fNewDesired * fScale + fOffset;
@@ -134,9 +176,34 @@ void TGauge::DecValue(double fNewDesired)
fDesiredValue = 0; fDesiredValue = 0;
}; };
void TGauge::UpdateValue(double fNewDesired) // ustawienie wartości docelowej. plays provided fallback sound, if no sound was defined in the control itself
{ // ustawienie wartości docelowej void
TGauge::UpdateValue( double fNewDesired, PSound Fallbacksound ) {
if( static_cast<int>( std::round( ( fDesiredValue - fOffset ) / fScale ) ) == static_cast<int>( fNewDesired ) ) {
return;
}
fDesiredValue = fNewDesired * fScale + fOffset; 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<int>( 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) 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;
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

47
Gauge.h
View File

@@ -10,6 +10,7 @@ http://mozilla.org/MPL/2.0/.
#pragma once #pragma once
#include "Classes.h" #include "Classes.h"
#include "sound.h"
typedef enum typedef enum
{ // typ ruchu { // typ ruchu
@@ -21,35 +22,43 @@ typedef enum
gt_Digital // licznik cyfrowy, np. kilometrów gt_Digital // licznik cyfrowy, np. kilometrów
} TGaugeType; } 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: private:
TGaugeType eType; // typ ruchu TGaugeType eType { gt_Unknown }; // typ ruchu
double fFriction{ 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości double fFriction { 0.0 }; // hamowanie przy zliżaniu się do zadanej wartości
double fDesiredValue{ 0.0 }; // wartość docelowa double fDesiredValue { 0.0 }; // wartość docelowa
double fValue{ 0.0 }; // wartość obecna double fValue { 0.0 }; // wartość obecna
double fOffset{ 0.0 }; // wartość początkowa ("0") double fOffset { 0.0 }; // wartość początkowa ("0")
double fScale{ 1.0 }; // wartość końcowa ("1") double fScale { 1.0 }; // wartość końcowa ("1")
double fStepSize; // nie używane
char cDataType; // typ zmiennej parametru: f-float, d-double, i-int char cDataType; // typ zmiennej parametru: f-float, d-double, i-int
union union {
{ // wskaźnik na parametr pokazywany przez animację // wskaźnik na parametr pokazywany przez animację
float *fData; float *fData;
double *dData; double *dData { nullptr };
int *iData; 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<int, PSound> m_soundfxvalues; // sounds associated with specific values
// methods
// plays specified sound
void
play( PSound Sound );
public: public:
TGauge(); TGauge() = default;
~TGauge(); ~TGauge() {}
void Clear(); inline
void Init(TSubModel *NewSubModel, TGaugeType eNewTyp, double fNewScale = 1, void Clear() { *this = TGauge(); }
double fNewOffset = 0, double fNewFriction = 0, double fNewValue = 0); 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); bool Load(cParser &Parser, TModel3d *md1, TModel3d *md2 = nullptr, double mul = 1.0);
bool Load_mapping( cParser &Input );
void PermIncValue(double fNewDesired); void PermIncValue(double fNewDesired);
void IncValue(double fNewDesired); void IncValue(double fNewDesired);
void DecValue(double fNewDesired); void DecValue(double fNewDesired);
void UpdateValue(double fNewDesired); void UpdateValue(double fNewDesired, PSound Fallbacksound = nullptr );
void PutValue(double fNewDesired); void PutValue(double fNewDesired);
double GetValue() const; double GetValue() const;
void Update(); void Update();

View File

@@ -78,7 +78,8 @@ zwiekszenie nacisku przy duzych predkosciach w hamulcach Oerlikona
*/ */
#include "dumb3d.h" #include "dumb3d.h"
using namespace Math3D;
extern int ConversionError;
const double Steel2Steel_friction = 0.15; //tarcie statyczne const double Steel2Steel_friction = 0.15; //tarcie statyczne
const double g = 9.81; //przyspieszenie ziemskie const double g = 9.81; //przyspieszenie ziemskie
@@ -996,8 +997,8 @@ public:
double FrictConst2d= 0.0; double FrictConst2d= 0.0;
double TotalMassxg = 0.0; /*TotalMass*g*/ double TotalMassxg = 0.0; /*TotalMass*g*/
vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/ Math3D::vector3 vCoulpler[2]; // powtórzenie współrzędnych sprzęgów z DynObj :/
vector3 DimHalf; // połowy rozmiarów do obliczeń geometrycznych 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: nie trabi, 1,2: trabi syreną o podanym numerze
int WarningSignal = 0; // tymczasowo 8bit, ze względu na funkcje w MTools int WarningSignal = 0; // tymczasowo 8bit, ze względu na funkcje w MTools
double fBrakeCtrlPos = -2.0; // płynna nastawa hamulca zespolonego 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); 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 <typename Type_>
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 );

View File

@@ -13,6 +13,7 @@ http://mozilla.org/MPL/2.0/.
#include "../logs.h" #include "../logs.h"
#include "Oerlikon_ESt.h" #include "Oerlikon_ESt.h"
#include "../parser.h" #include "../parser.h"
#include "mctools.h"
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// Ra: tu należy przenosić funcje z mover.pas, które nie są z niego wywoływane. // 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 dEpsilon = 0.01; // 1cm (zależy od typu sprzęgu...)
const double CouplerTune = 0.1; // skalowanie tlumiennosci const double CouplerTune = 0.1; // skalowanie tlumiennosci
int ConversionError = 0;
std::vector<std::string> const TMoverParameters::eimc_labels = { std::vector<std::string> const TMoverParameters::eimc_labels = {
"dfic: ", "dfmax:", "p: ", "scfu: ", "cim: ", "icif: ", "Uzmax:", "Uzh: ", "DU: ", "I0: ", "dfic: ", "dfmax:", "p: ", "scfu: ", "cim: ", "icif: ", "Uzmax:", "Uzh: ", "DU: ", "I0: ",
"fcfu: ", "F0: ", "a1: ", "Pmax: ", "Fh: ", "Ph: ", "Vh0: ", "Vh1: ", "Imax: ", "abed: ", "fcfu: ", "F0: ", "a1: ", "Pmax: ", "Fh: ", "Ph: ", "Vh0: ", "Vh1: ", "Imax: ", "abed: ",
@@ -5097,14 +5100,17 @@ bool TMoverParameters::AutoRelayCheck(void)
// IminLo // IminLo
} }
// main bez samoczynnego rozruchu // 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++;
// MainCtrlActualPos:=MainCtrlPos; //hunter-111012: // MainCtrlActualPos:=MainCtrlPos; //hunter-111012:
// szybkie wchodzenie na bezoporowa (303E) // szybkie wchodzenie na bezoporowa (303E)
@@ -5803,28 +5809,28 @@ std::string TMoverParameters::EngineDescription(int what)
{ {
if (TestFlag(DamageFlag, dtrain_thinwheel)) if (TestFlag(DamageFlag, dtrain_thinwheel))
if (Power > 0.1) if (Power > 0.1)
outstr = "Thin wheel,"; outstr = "Thin wheel";
else else
outstr = "Load shifted,"; outstr = "Load shifted";
if (TestFlag(DamageFlag, dtrain_wheelwear)) if (TestFlag(DamageFlag, dtrain_wheelwear))
outstr = "Wheel wear,"; outstr = "Wheel wear";
if (TestFlag(DamageFlag, dtrain_bearing)) if (TestFlag(DamageFlag, dtrain_bearing))
outstr = "Bearing damaged,"; outstr = "Bearing damaged";
if (TestFlag(DamageFlag, dtrain_coupling)) if (TestFlag(DamageFlag, dtrain_coupling))
outstr = "Coupler broken,"; outstr = "Coupler broken";
if (TestFlag(DamageFlag, dtrain_loaddamage)) if (TestFlag(DamageFlag, dtrain_loaddamage))
if (Power > 0.1) if (Power > 0.1)
outstr = "Ventilator damaged,"; outstr = "Ventilator damaged";
else else
outstr = "Load damaged,"; outstr = "Load damaged";
if (TestFlag(DamageFlag, dtrain_loaddestroyed)) if (TestFlag(DamageFlag, dtrain_loaddestroyed))
if (Power > 0.1) if (Power > 0.1)
outstr = "Engine damaged,"; outstr = "Engine damaged";
else else
outstr = "LOAD DESTROYED,"; outstr = "LOAD DESTROYED";
if (TestFlag(DamageFlag, dtrain_axle)) if (TestFlag(DamageFlag, dtrain_axle))
outstr = "Axle broken,"; outstr = "Axle broken";
if (TestFlag(DamageFlag, dtrain_out)) if (TestFlag(DamageFlag, dtrain_out))
outstr = "DERAILED"; outstr = "DERAILED";
if (outstr == "") if (outstr == "")
@@ -6105,7 +6111,7 @@ bool TMoverParameters::readRList( std::string const &Input ) {
return false; return false;
} }
auto idx = LISTLINE++; 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" ); WriteLog( "Read RList: number of entries exceeded capacity of the data table" );
return false; return false;
} }
@@ -6127,7 +6133,7 @@ bool TMoverParameters::readDList( std::string const &line ) {
cParser parser( line ); cParser parser( line );
parser.getTokens( 3, false ); parser.getTokens( 3, false );
auto idx = LISTLINE++; 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" ); WriteLog( "Read DList: number of entries exceeded capacity of the data table" );
return false; return false;
} }
@@ -6147,7 +6153,7 @@ bool TMoverParameters::readFFList( std::string const &line ) {
return false; return false;
} }
int idx = LISTLINE++; 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" ); WriteLog( "Read FList: number of entries exceeded capacity of the data table" );
return false; return false;
} }
@@ -6167,7 +6173,7 @@ bool TMoverParameters::readWWList( std::string const &line ) {
return false; return false;
} }
int idx = LISTLINE++; 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" ); WriteLog( "Read WWList: number of entries exceeded capacity of the data table" );
return false; return false;
} }
@@ -8364,22 +8370,3 @@ double TMoverParameters::ShowCurrentP(int AmpN)
return current; 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
}
}

View File

@@ -17,41 +17,9 @@ Copyright (C) 2007-2014 Maciej Cierniak
/*================================================*/ /*================================================*/
int ConversionError = 0;
int LineCount = 0;
bool DebugModeFlag = false; bool DebugModeFlag = false;
bool FreeFlyModeFlag = 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) double Max0R(double x1, double x2)
{ {
if (x1 > x2) if (x1 > x2)
@@ -87,13 +55,8 @@ bool TestFlag(int Flag, int Value)
return false; return false;
} }
bool SetFlag(int &Flag, int Value) bool SetFlag(int &Flag, int Value) {
{
return iSetFlag(Flag, Value);
}
bool iSetFlag(int &Flag, int Value)
{
if (Value > 0) if (Value > 0)
{ {
if ((Flag & Value) == 0) if ((Flag & Value) == 0)
@@ -263,33 +226,13 @@ std::string to_hex_str( int const Value, int const Width )
return converter.str(); 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 }; int result { DefaultValue };
std::stringstream converter; std::stringstream converter;
converter << str; converter << str;
converter >> result; converter >> result;
return 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) 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, template <>
double &phi, double &Xout, double &Yout) bool
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ extract_value( bool &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
{
double dX;
double dY;
double Xc;
double Yc;
double gamma;
double alfa;
double AbsR;
if ((R != 0) && (L != 0)) auto value = extract_value( Key, Input );
{ if( false == value.empty() ) {
AbsR = abs(R); // set the specified variable to retrieved value
dX = Xn - X0; Variable = ( ToLower( value ) == "yes" );
dY = Yn - Y0; return true; // located the variable
if (dX != 0) }
gamma = atan(dY * 1.0 / dX); else {
else if (dY > 0) // set the variable to provided default value
gamma = M_PI * 1.0 / 2; if( false == Default.empty() ) {
else Variable = ( ToLower( Default ) == "yes" );
gamma = 3 * M_PI * 1.0 / 2; }
alfa = L * 1.0 / R; return false; // couldn't locate the variable in provided input
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;
} }
}
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 ) { bool FileExists( std::string const &Filename ) {
std::ifstream file( Filename ); std::ifstream file( Filename );
return( true == file.is_open() ); 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

View File

@@ -15,48 +15,16 @@ http://mozilla.org/MPL/2.0/.
#include <string> #include <string>
#include <fstream> #include <fstream>
#include <ctime> #include <ctime>
#include <sys/stat.h>
#include <vector> #include <vector>
#include <sstream> #include <sstream>
/*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 DebugModeFlag;
extern bool FreeFlyModeFlag; extern bool FreeFlyModeFlag;
typedef unsigned long/*?*//*set of: char */ TableChar; /*MCTUTIL*/
/*konwersje*/
/*funkcje matematyczne*/ /*funkcje matematyczne*/
int Max0(int x1, int x2);
int Min0(int x1, int x2);
double Max0R(double x1, double x2); double Max0R(double x1, double x2);
double Min0R(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) inline double Sign(double x)
{ {
return x >= 0 ? 1.0 : -1.0; return x >= 0 ? 1.0 : -1.0;
@@ -68,7 +36,7 @@ inline long Round(double const f)
//return lround(f); //return lround(f);
} }
extern double Random(double a, double b); double Random(double a, double b);
inline double Random() inline double Random()
{ {
@@ -94,10 +62,9 @@ inline double BorlandTime()
std::string Now(); std::string Now();
/*funkcje logiczne*/ /*funkcje logiczne*/
extern bool TestFlag(int Flag, int Value); bool TestFlag(int Flag, int Value);
extern bool SetFlag( int & Flag, int Value); bool SetFlag( int & Flag, int Value);
extern bool iSetFlag( int & Flag, int Value); bool UnSetFlag(int &Flag, int Value);
extern bool UnSetFlag(int &Flag, int Value);
bool FuzzyLogic(double Test, double Threshold, double Probability); bool FuzzyLogic(double Test, double Threshold, double Probability);
/*jesli Test>Threshold to losowanie*/ /*jesli Test>Threshold to losowanie*/
@@ -139,40 +106,48 @@ std::string ToUpper(std::string const &text);
// replaces polish letters with basic ascii // replaces polish letters with basic ascii
void win1250_to_ascii( std::string &Input ); void win1250_to_ascii( std::string &Input );
/*procedury, zmienne i funkcje graficzne*/ inline
void ComputeArc(double X0, double Y0, double Xn, double Yn, double R, double L, double dL, double & phi, double & Xout, double & Yout); std::string
/*wylicza polozenie Xout Yout i orientacje phi punktu na elemencie dL luku*/ extract_value( std::string const &Key, std::string const &Input ) {
void ComputeALine(double X0, double Y0, double Xn, double Yn, double L, double R, double & Xout, double & Yout);
/* std::string value;
inline bool fileExists(const std::string &name) auto lookup = Input.find( Key + "=" );
{ if( lookup != std::string::npos ) {
struct stat buffer; value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
return (stat(name.c_str(), &buffer) == 0); lookup = value.find( ' ' );
}*/ if( lookup != std::string::npos ) {
// trim everything past the value
value.erase( lookup );
}
}
return value;
}
template <typename Type_>
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 ); 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();

View File

@@ -1217,11 +1217,11 @@ TSubModel *TModel3d::GetFromName(const char *sName)
if (!sName) if (!sName)
return Root; // potrzebne do terenu z E3D return Root; // potrzebne do terenu z E3D
if (iFlags & 0x0200) // wczytany z pliku tekstowego, wyszukiwanie rekurencyjne 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 else // wczytano z pliku binarnego, można wyszukać iteracyjnie
{ {
// for (int i=0;i<iSubModelsCount;++i) // for (int i=0;i<iSubModelsCount;++i)
return Root ? Root->GetFromName(sName) : NULL; return Root ? Root->GetFromName(sName) : nullptr;
} }
}; };

460
Train.cpp

File diff suppressed because it is too large Load Diff

46
Train.h
View File

@@ -34,8 +34,9 @@ class TCab
public: public:
TCab(); TCab();
~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); void Load(cParser &Parser);
vector3 CabPos1; vector3 CabPos1;
vector3 CabPos2; vector3 CabPos2;
@@ -43,17 +44,19 @@ class TCab
bool bOccupied; bool bOccupied;
double dimm_r, dimm_g, dimm_b; // McZapkie-120503: tlumienie swiatla double dimm_r, dimm_g, dimm_b; // McZapkie-120503: tlumienie swiatla
double intlit_r, intlit_g, intlit_b; // McZapkie-120503: oswietlenie kabiny double intlit_r, intlit_g, intlit_b; // McZapkie-120503: oswietlenie kabiny
double intlitlow_r, intlitlow_g, double intlitlow_r, intlitlow_g, intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny
intlitlow_b; // McZapkie-120503: przyciemnione oswietlenie kabiny
private: private:
// bool bChangePossible; /*
TGauge *ggList; // Ra 2014-08: lista animacji macierzowych (gałek) w kabinie 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 int iGaugesMax, iGauges; // ile miejsca w tablicy i ile jest w użyciu
TButton *btList; // Ra 2014-08: lista animacji dwustanowych (lampek) w kabinie TButton *btList; // Ra 2014-08: lista animacji dwustanowych (lampek) w kabinie
int iButtonsMax, iButtons; // ile miejsca w tablicy i ile jest w użyciu int iButtonsMax, iButtons; // ile miejsca w tablicy i ile jest w użyciu
*/
std::vector<TGauge> ggList;
std::vector<TButton> btList;
public: public:
TGauge *Gauge(int n = -1); // pobranie adresu obiektu TGauge &Gauge(int n = -1); // pobranie adresu obiektu
TButton *Button(int n = -1); // pobranie adresu obiektu TButton &Button(int n = -1); // pobranie adresu obiektu
void Update(); void Update();
}; };
@@ -103,11 +106,9 @@ class TTrain
// sets cabin controls based on current state of the vehicle // 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 // NOTE: we can get rid of this function once we have per-cab persistent state
void set_cab_controls(); void set_cab_controls();
// initializes a gauge matching provided label. returns: true if the label was found, false // initializes a gauge matching provided label. returns: true if the label was found, false otherwise
// otherwise
bool initialize_gauge(cParser &Parser, std::string const &Label, int const Cabindex); 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 // initializes a button matching provided label. returns: true if the label was found, false otherwise
// otherwise
bool initialize_button(cParser &Parser, std::string const &Label, int const Cabindex); 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 // 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 // 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 ggClockSInd;
TGauge ggClockMInd; TGauge ggClockMInd;
TGauge ggClockHInd; TGauge ggClockHInd;
// TGauge ggHVoltage;
TGauge ggLVoltage; TGauge ggLVoltage;
// TGauge ggEnrot1m;
// TGauge ggEnrot2m;
// TGauge ggEnrot3m;
// TGauge ggEngageRatio;
TGauge ggMainGearStatus; TGauge ggMainGearStatus;
TGauge ggEngineVoltage; TGauge ggEngineVoltage;
@@ -277,13 +273,7 @@ public: // reszta może by?publiczna
TGauge ggHornLowButton; TGauge ggHornLowButton;
TGauge ggHornHighButton; TGauge ggHornHighButton;
TGauge ggNextCurrentButton; TGauge ggNextCurrentButton;
/*
// ABu 090305 - uniwersalne przyciski
TGauge ggUniversal1Button;
TGauge ggUniversal2Button;
TGauge ggUniversal4Button;
bool Universal4Active;
*/
std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table std::array<TGauge, 10> ggUniversals; // NOTE: temporary arrangement until we have dynamically built control table
TGauge ggInstrumentLightButton; TGauge ggInstrumentLightButton;
@@ -336,7 +326,6 @@ public: // reszta może by?publiczna
TButton btLampkaRadio; TButton btLampkaRadio;
TButton btLampkaHamowanie1zes; TButton btLampkaHamowanie1zes;
TButton btLampkaHamowanie2zes; TButton btLampkaHamowanie2zes;
// TButton btLampkaUnknown;
TButton btLampkaOpory; TButton btLampkaOpory;
TButton btLampkaWysRozr; TButton btLampkaWysRozr;
TButton btInstrumentLight; TButton btInstrumentLight;
@@ -363,8 +352,6 @@ public: // reszta może by?publiczna
TButton btLampkaBoczniki; TButton btLampkaBoczniki;
TButton btLampkaMaxSila; TButton btLampkaMaxSila;
TButton btLampkaPrzekrMaxSila; TButton btLampkaPrzekrMaxSila;
// TButton bt;
//
TButton btLampkaDoorLeft; TButton btLampkaDoorLeft;
TButton btLampkaDoorRight; TButton btLampkaDoorRight;
TButton btLampkaDepartureSignal; TButton btLampkaDepartureSignal;
@@ -439,8 +426,6 @@ public: // reszta może by?publiczna
PSound dsbHasler; PSound dsbHasler;
PSound dsbBuzzer; PSound dsbBuzzer;
PSound dsbSlipAlarm; // Bombardier 011010: alarm przy poslizgu dla 181/182 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) int iCabLightFlag; // McZapkie:120503: oswietlenie kabiny (0: wyl, 1: przyciemnione, 2: pelne)
bool bCabLight; // hunter-091012: czy swiatlo jest zapalone? bool bCabLight; // hunter-091012: czy swiatlo jest zapalone?
@@ -454,11 +439,6 @@ public: // reszta może by?publiczna
PSound dsbCouplerStretch; PSound dsbCouplerStretch;
PSound dsbEN57_CouplerStretch; PSound dsbEN57_CouplerStretch;
PSound dsbBufferClamp; PSound dsbBufferClamp;
// TSubModel *smCzuwakShpOn;
// TSubModel *smCzuwakOn;
// TSubModel *smShpOn;
// TSubModel *smCzuwakShpOff;
// double fCzuwakTimer;
double fBlinkTimer; double fBlinkTimer;
float fHaslerTimer; float fHaslerTimer;
float fConverterTimer; // hunter-261211: dla przekaznika float fConverterTimer; // hunter-261211: dla przekaznika

View File

@@ -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) { // omijamy cały ten blok, gdy tor nie ma on żadnych eventów (większość nie ma)
if (fDistance < 0) 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 // dosiądzie, to się nie wykona
if (Owner->Mechanik->Primary()) // tylko dla jednego członu if (Owner->Mechanik->Primary()) // tylko dla jednego członu
// if (TestFlag(iEventFlag,1)) //McZapkie-280503: wyzwalanie event tylko dla // 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 // Owner->RaAxleEvent(pCurrentTrack->Event1); //Ra: dynamic zdecyduje, czy dodać do
// kolejki // kolejki
// if (TestFlag(iEventallFlag,1)) // if (TestFlag(iEventallFlag,1))
if (iSetFlag(iEventallFlag, if (SetFlag(iEventallFlag,
-1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow -1)) // McZapkie-280503: wyzwalanie eventall dla wszystkich pojazdow
if (bPrimary && pCurrentTrack->evEventall1 && if (bPrimary && pCurrentTrack->evEventall1 &&
(!pCurrentTrack->evEventall1->iQueued)) (!pCurrentTrack->evEventall1->iQueued))
@@ -136,7 +136,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
} }
else if (fDistance > 0) 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 // dosiądzie, to się nie wykona
if (Owner->Mechanik->Primary()) // tylko dla jednego członu if (Owner->Mechanik->Primary()) // tylko dla jednego członu
// if (TestFlag(iEventFlag,2)) //sprawdzanie jest od razu w pierwszym // 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 // Owner->RaAxleEvent(pCurrentTrack->Event2); //Ra: dynamic zdecyduje, czy dodać do
// kolejki // kolejki
// if (TestFlag(iEventallFlag,2)) // 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 -2)) // sprawdza i zeruje na przyszłość, true jeśli zmieni z 2 na 0
if (bPrimary && pCurrentTrack->evEventall2 && if (bPrimary && pCurrentTrack->evEventall2 &&
(!pCurrentTrack->evEventall2->iQueued)) (!pCurrentTrack->evEventall2->iQueued))

View File

@@ -33,29 +33,28 @@ class cParser //: public std::stringstream
virtual ~cParser(); virtual ~cParser();
// methods: // methods:
template <typename Type_> template <typename Type_>
cParser& cParser &
operator>>( Type_ &Right ); operator>>( Type_ &Right );
template <> template <>
cParser& cParser &
operator>>( std::string &Right ); operator>>( std::string &Right );
template <> template <>
cParser& cParser &
operator>>( bool &Right ); operator>>( bool &Right );
template <typename _Output> template <typename Output_>
_Output Output_
getToken( bool const ToLower = true ) getToken( bool const ToLower = true, const char *Break = "\n\r\t ;" ) {
{ getTokens( 1, ToLower, Break );
getTokens( 1, ToLower ); Output_ output;
_Output output; *this >> output;
*this >> output; return output; };
return output;
};
template <> template <>
bool bool
getToken<bool>( bool const ToLower ) { getToken<bool>( bool const ToLower, const char *Break ) {
auto const token = getToken<std::string>( true, Break );
return ( getToken<std::string>() == "true" ); return ( ( token == "true" )
} || ( token == "yes" )
|| ( token == "1" ) ); }
inline void ignoreToken() inline void ignoreToken()
{ {
readToken(); readToken();
@@ -77,7 +76,13 @@ class cParser //: public std::stringstream
{ {
return !mStream->fail(); 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 // returns percentage of file processed so far
int getProgress() const; int getProgress() const;
int getFullProgress() const; int getFullProgress() const;

View File

@@ -44,7 +44,7 @@ ui_layer::init( GLFWwindow *Window ) {
DEFAULT_PITCH | FF_DONTCARE, // family and pitch DEFAULT_PITCH | FF_DONTCARE, // family and pitch
"Lucida Console"); // font name "Lucida Console"); // font name
::SelectObject(hDC, font); // selects the font we want ::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 // builds 96 characters starting at character 32
WriteLog( "Display Lists font used" ); //+AnsiString(glGetError()) WriteLog( "Display Lists font used" ); //+AnsiString(glGetError())
WriteLog( "Font init OK" ); //+AnsiString(glGetError()) WriteLog( "Font init OK" ); //+AnsiString(glGetError())
@@ -151,8 +151,8 @@ ui_layer::render_progress() {
Global::iWindowWidth ); Global::iWindowWidth );
float const heightratio = float const heightratio =
( screenratio >= ( 4.0f / 3.0f ) ? ( screenratio >= ( 4.0f / 3.0f ) ?
Global::iWindowHeight / 768.0 : Global::iWindowHeight / 768.f :
Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) ); Global::iWindowHeight / 768.f * screenratio / ( 4.0f / 3.0f ) );
float const height = 768.0f * heightratio; float const height = 768.0f * heightratio;
::glColor4f( 216.0f / 255.0f, 216.0f / 255.0f, 216.0f / 255.0f, 1.0f ); ::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 ); glPushAttrib( GL_ENABLE_BIT );
glDisable( GL_TEXTURE_2D ); glDisable( GL_TEXTURE_2D );
float const width = std::min( 4.0f / 3.0f, static_cast<float>(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight; float const width = std::min( 4.f / 3.f, static_cast<float>(Global::iWindowWidth) / std::max( 1, Global::iWindowHeight ) ) * Global::iWindowHeight;
float const height = Global::iWindowHeight / 768.0; float const height = Global::iWindowHeight / 768.f;
for( auto const &panel : m_panels ) { for( auto const &panel : m_panels ) {
@@ -186,8 +186,8 @@ ui_layer::render_panels() {
::glColor4fv( &line.color.x ); ::glColor4fv( &line.color.x );
::glRasterPos2f( ::glRasterPos2f(
0.5 * ( Global::iWindowWidth - width ) + panel->origin_x * height, 0.5f * ( Global::iWindowWidth - width ) + panel->origin_x * height,
panel->origin_y * height + 20.0 * lineidx ); panel->origin_y * height + 20.f * lineidx );
print( line.data ); print( line.data );
++lineidx; ++lineidx;
} }
@@ -255,14 +255,14 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
float const screenratio = static_cast<float>( Global::iWindowWidth ) / Global::iWindowHeight; float const screenratio = static_cast<float>( Global::iWindowWidth ) / Global::iWindowHeight;
float const width = float const width =
( screenratio >= (4.0f/3.0f) ? ( screenratio >= ( 4.f / 3.f ) ?
( 4.0f / 3.0f ) * Global::iWindowHeight : ( 4.f / 3.f ) * Global::iWindowHeight :
Global::iWindowWidth ); Global::iWindowWidth );
float const heightratio = float const heightratio =
( screenratio >= ( 4.0f / 3.0f ) ? ( screenratio >= ( 4.f / 3.f ) ?
Global::iWindowHeight / 768.0 : Global::iWindowHeight / 768.f :
Global::iWindowHeight / 768.0 * screenratio / ( 4.0f / 3.0f ) ); Global::iWindowHeight / 768.f * screenratio / ( 4.f / 3.f ) );
float const height = 768.0f * heightratio; float const height = 768.f * heightratio;
/* /*
float const heightratio = Global::iWindowHeight / 768.0f; float const heightratio = Global::iWindowHeight / 768.0f;
float const height = 768.0f * heightratio; float const height = 768.0f * heightratio;
@@ -272,10 +272,10 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
glBegin( GL_TRIANGLE_STRIP ); 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.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( 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( 0.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.x * heightratio, 0.5f * ( 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.f, 1.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( 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( 1.f, 0.f ); glVertex2f( 0.5f * ( Global::iWindowWidth - width ) + Coordinates.z * heightratio, 0.5f * ( Global::iWindowHeight - height ) + Coordinates.w * heightratio );
glEnd(); glEnd();
} }

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 17 #define VERSION_MAJOR 17
#define VERSION_MINOR 712 #define VERSION_MINOR 714
#define VERSION_REVISION 0 #define VERSION_REVISION 0