mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 14:39:18 +02:00
build 180131. support for nested material attribute definitions, minor bug fixes, refactoring and master branch unifications
This commit is contained in:
@@ -2616,19 +2616,14 @@ bool TController::DecBrake()
|
||||
|
||||
bool TController::IncSpeed()
|
||||
{ // zwiększenie prędkości; zwraca false, jeśli dalej się nie da zwiększać
|
||||
#ifdef EU07_USE_OLD_SOUNDCODE
|
||||
if (tsGuardSignal) // jeśli jest dźwięk kierownika
|
||||
if (tsGuardSignal->GetStatus() & DSBSTATUS_PLAYING) // jeśli gada, to nie jedziemy
|
||||
return false;
|
||||
#else
|
||||
if( true == tsGuardSignal.is_playing() ) {
|
||||
// jeśli gada, to nie jedziemy
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
bool OK = true;
|
||||
if( ( iDrivigFlags & moveDoorOpened )
|
||||
&& ( VelDesired > 0.0 ) ) { // to prevent door shuffle on stop
|
||||
// zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime)
|
||||
// zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime)
|
||||
Doors( false );
|
||||
}
|
||||
if( fActionTime < 0.0 ) {
|
||||
|
||||
55
DynObj.cpp
55
DynObj.cpp
@@ -3088,7 +3088,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
{ // trzeba usunąć to rozróżnienie
|
||||
case 0:
|
||||
if( ( Global.bLiveTraction == false )
|
||||
&& ( p->hvPowerWire == nullptr ) ) {
|
||||
&& ( p->hvPowerWire == nullptr ) ) {
|
||||
// jeśli nie ma drutu, może pooszukiwać
|
||||
MoverParameters->PantFrontVolt =
|
||||
( p->PantWys >= 1.2 ) ?
|
||||
@@ -3098,19 +3098,20 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
else if( ( true == MoverParameters->PantFrontUp )
|
||||
&& ( PantDiff < 0.01 ) ) // tolerancja niedolegania
|
||||
{
|
||||
if( ( MoverParameters->PantFrontVolt == 0.0 )
|
||||
&& ( MoverParameters->PantRearVolt == 0.0 ) ) {
|
||||
for( auto &pantograph : m_pantographsounds ) {
|
||||
if( pantograph.sPantUp.offset().z > 0 ) {
|
||||
// limit to pantographs located in the front half of the vehicle
|
||||
pantograph.sPantUp.play( sound_flags::exclusive );
|
||||
if (p->hvPowerWire) {
|
||||
auto const wirevoltage { p->hvPowerWire->VoltageGet( MoverParameters->Voltage, fPantCurrent ) };
|
||||
// TODO: refactor reaction to voltage change to mover as sound event for specific pantograph
|
||||
if( ( MoverParameters->PantFrontVolt == 0.0 )
|
||||
&& ( wirevoltage > 0.0 ) ) {
|
||||
for( auto &pantograph : m_pantographsounds ) {
|
||||
if( pantograph.sPantUp.offset().z > 0 ) {
|
||||
// limit to pantographs located in the front half of the vehicle
|
||||
pantograph.sPantUp.play( sound_flags::exclusive );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p->hvPowerWire) {
|
||||
// TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage()
|
||||
MoverParameters->PantFrontVolt =
|
||||
p->hvPowerWire->VoltageGet(MoverParameters->Voltage, fPantCurrent);
|
||||
MoverParameters->PantFrontVolt = wirevoltage;
|
||||
fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf
|
||||
}
|
||||
else
|
||||
@@ -3131,16 +3132,18 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
else if ( ( true == MoverParameters->PantRearUp )
|
||||
&& ( PantDiff < 0.01 ) )
|
||||
{
|
||||
if( ( MoverParameters->PantRearVolt == 0.0 )
|
||||
&& ( MoverParameters->PantFrontVolt == 0.0 ) ) {
|
||||
for( auto &pantograph : m_pantographsounds ) {
|
||||
if( pantograph.sPantUp.offset().z < 0 ) {
|
||||
// limit to pantographs located in the rear half of the vehicle
|
||||
pantograph.sPantUp.play( sound_flags::exclusive );
|
||||
if (p->hvPowerWire) {
|
||||
auto const wirevoltage { p->hvPowerWire->VoltageGet( MoverParameters->Voltage, fPantCurrent ) };
|
||||
// TODO: refactor reaction to voltage change to mover as sound event for specific pantograph
|
||||
if( ( MoverParameters->PantRearVolt == 0.0 )
|
||||
&& ( wirevoltage > 0.0 ) ) {
|
||||
for( auto &pantograph : m_pantographsounds ) {
|
||||
if( pantograph.sPantUp.offset().z < 0 ) {
|
||||
// limit to pantographs located in the rear half of the vehicle
|
||||
pantograph.sPantUp.play( sound_flags::exclusive );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (p->hvPowerWire) {
|
||||
// TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage()
|
||||
MoverParameters->PantRearVolt = p->hvPowerWire->VoltageGet( MoverParameters->Voltage, fPantCurrent );
|
||||
fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf
|
||||
@@ -3888,7 +3891,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
parser.getTokens(); parser >> token;
|
||||
|
||||
if( ( token == "models:" )
|
||||
|| ( token == "models:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token
|
||||
|| ( token == "\xef\xbb\xbfmodels:" ) ) { // crude way to handle utf8 bom potentially appearing before the first token
|
||||
// modele i podmodele
|
||||
m_materialdata.multi_textures = 0; // czy jest wiele tekstur wymiennych?
|
||||
parser.getTokens();
|
||||
@@ -4013,8 +4016,9 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
// Ra: tu wczytywanie modelu ładunku jest w porządku
|
||||
if( false == asLoadName.empty() ) {
|
||||
// try first specialized version of the load model, vehiclename_loadname
|
||||
auto const specializedloadfilename { BaseDir + TypeName + "_" + MoverParameters->LoadType + ".t3d" };
|
||||
if( true == FileExists( specializedloadfilename ) ) {
|
||||
auto const specializedloadfilename { BaseDir + TypeName + "_" + MoverParameters->LoadType };
|
||||
if( ( true == FileExists( specializedloadfilename + ".e3d" ) )
|
||||
|| ( true == FileExists( specializedloadfilename + ".t3d" ) ) ) {
|
||||
mdLoad = TModelsManager::GetModel( specializedloadfilename, true );
|
||||
}
|
||||
if( mdLoad == nullptr ) {
|
||||
@@ -4629,8 +4633,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
m_powertrainsounds.rsWentylator.m_frequencyfactor /= MoverParameters->RVentnmax;
|
||||
}
|
||||
|
||||
else if( ( token == "transmission:" )
|
||||
&& ( MoverParameters->EngineType == ElectricSeriesMotor ) ) {
|
||||
else if( token == "transmission:" ) {
|
||||
// plik z dzwiekiem, mnozniki i ofsety amp. i czest.
|
||||
// NOTE, fixed default parameters, legacy system leftover
|
||||
m_powertrainsounds.transmission.m_amplitudefactor = 0.029;
|
||||
@@ -4777,7 +4780,7 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
|
||||
|
||||
else if( token == "outernoise:" ) {
|
||||
// szum podczas jazdy:
|
||||
rsOuterNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency );
|
||||
rsOuterNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, MoverParameters->Vmax );
|
||||
rsOuterNoise.owner( this );
|
||||
|
||||
rsOuterNoise.m_amplitudefactor /= ( 1 + MoverParameters->Vmax );
|
||||
@@ -5041,7 +5044,7 @@ void TDynamicObject::RadioStop()
|
||||
if( ( MoverParameters->SecuritySystem.RadioStop )
|
||||
&& ( MoverParameters->Radio ) ) {
|
||||
// jeśli pojazd ma RadioStop i jest on aktywny
|
||||
// HAX cast until math types unification
|
||||
// HACK cast until math types unification
|
||||
Mechanik->PutCommand( "Emergency_brake", 1.0, 1.0, &static_cast<glm::dvec3>(vPosition), stopRadio );
|
||||
// add onscreen notification for human driver
|
||||
// TODO: do it selectively for the 'local' driver once the multiplayer is in
|
||||
|
||||
3
DynObj.h
3
DynObj.h
@@ -269,6 +269,7 @@ private:
|
||||
};
|
||||
|
||||
struct pantograph_sounds {
|
||||
// TODO: split pantograph sound into one for contact of arm with the wire, and electric arc sound
|
||||
sound_source sPantUp { sound_placement::external };
|
||||
sound_source sPantDown { sound_placement::external };
|
||||
};
|
||||
@@ -455,7 +456,7 @@ private:
|
||||
TDynamicObject();
|
||||
~TDynamicObject();
|
||||
// zwraca długość pojazdu albo 0, jeśli błąd
|
||||
double TDynamicObject::Init(
|
||||
double Init(
|
||||
std::string Name, std::string BaseDir, std::string asReplacableSkin, std::string Type_Name,
|
||||
TTrack *Track, double fDist, std::string DriverType, double fVel, std::string TrainName,
|
||||
float Load, std::string LoadType, bool Reversed, std::string);
|
||||
|
||||
20
EU07.cpp
20
EU07.cpp
@@ -191,7 +191,7 @@ void key_callback( GLFWwindow *window, int key, int scancode, int action, int mo
|
||||
#ifdef CAN_I_HAS_LIBPNG
|
||||
switch( key )
|
||||
{
|
||||
case GLFW_KEY_F11: {
|
||||
case GLFW_KEY_PRINT_SCREEN: {
|
||||
make_screenshot();
|
||||
break;
|
||||
}
|
||||
@@ -426,20 +426,17 @@ int main(int argc, char *argv[])
|
||||
ErrorLog( "Critical error, memory allocation failure: " + std::string( Error.what() ) );
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef _WINDOWS
|
||||
Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoś zainicjowac trzeba
|
||||
/*
|
||||
if( !joyGetNumDevs() )
|
||||
WriteLog( "No joystick" );
|
||||
*/
|
||||
#endif
|
||||
if( Global.iConvertModels < 0 ) {
|
||||
Global.iConvertModels = -Global.iConvertModels;
|
||||
World.CreateE3D( "models\\" ); // rekurencyjne przeglądanie katalogów
|
||||
World.CreateE3D( "dynamic\\", true );
|
||||
} // po zrobieniu E3D odpalamy normalnie scenerię, by ją zobaczyć
|
||||
|
||||
#ifdef _WINDOWS
|
||||
Console::On(); // włączenie konsoli
|
||||
|
||||
#endif
|
||||
try {
|
||||
while( ( false == glfwWindowShouldClose( window ) )
|
||||
&& ( true == World.Update() )
|
||||
@@ -456,10 +453,11 @@ int main(int argc, char *argv[])
|
||||
return -1;
|
||||
}
|
||||
|
||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||
|
||||
TPythonInterpreter::killInstance();
|
||||
SafeDelete( pConsole );
|
||||
#ifdef _WINDOWS
|
||||
Console::Off(); // wyłączenie konsoli (komunikacji zwrotnej)
|
||||
SafeDelete( pConsole );
|
||||
#endif
|
||||
SafeDelete( simulation::Region );
|
||||
|
||||
glfwDestroyWindow(window);
|
||||
|
||||
28
EvLaunch.cpp
28
EvLaunch.cpp
@@ -128,22 +128,18 @@ bool TEventLauncher::Load(cParser *parser)
|
||||
|
||||
bool TEventLauncher::check_conditions()
|
||||
{ //"renderowanie" wyzwalacza
|
||||
bool bCond = false;
|
||||
if (iKey != 0)
|
||||
{
|
||||
if( Global.bActive ) {
|
||||
// tylko jeśli okno jest aktywne
|
||||
if( iKey > 255 ) {
|
||||
// key and modifier
|
||||
auto const modifier = ( iKey & 0xff00 ) >> 8;
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) )
|
||||
&& ( ( modifier & 1 ) ? Global.shiftState : true )
|
||||
&& ( ( modifier & 2 ) ? Global.ctrlState : true );
|
||||
}
|
||||
else {
|
||||
// just key
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty
|
||||
}
|
||||
auto bCond { false };
|
||||
if (iKey != 0) {
|
||||
if( iKey > 255 ) {
|
||||
// key and modifier
|
||||
auto const modifier = ( iKey & 0xff00 ) >> 8;
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) )
|
||||
&& ( ( modifier & 1 ) ? Global.shiftState : true )
|
||||
&& ( ( modifier & 2 ) ? Global.ctrlState : true );
|
||||
}
|
||||
else {
|
||||
// just key
|
||||
bCond = ( Console::Pressed( iKey & 0xff ) ); // czy klawisz wciśnięty
|
||||
}
|
||||
}
|
||||
if (DeltaTime > 0)
|
||||
|
||||
@@ -1439,7 +1439,7 @@ event_manager::InitEvents() {
|
||||
auto *track = simulation::Paths.find( event->asNodeName );
|
||||
if( track != nullptr ) {
|
||||
// dowiązanie toru
|
||||
if( track->iAction == NULL ) {
|
||||
if( track->iAction == 0 ) {
|
||||
// jeśli nie jest zwrotnicą ani obrotnicą to będzie się zmieniał stan uszkodzenia
|
||||
track->iAction |= 0x100;
|
||||
}
|
||||
|
||||
@@ -104,11 +104,11 @@ class float4
|
||||
z = c;
|
||||
w = d;
|
||||
};
|
||||
float inline float4::LengthSquared() const
|
||||
float inline LengthSquared() const
|
||||
{
|
||||
return x * x + y * y + z * z + w * w;
|
||||
};
|
||||
float inline float4::Length() const
|
||||
float inline Length() const
|
||||
{
|
||||
return sqrt(x * x + y * y + z * z + w * w);
|
||||
};
|
||||
|
||||
16
Globals.cpp
16
Globals.cpp
@@ -558,14 +558,14 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
// color of the ui text. NOTE: will be obsolete once the real ui is in place
|
||||
Parser.getTokens( 3, false );
|
||||
Parser
|
||||
>> UITextColor.x
|
||||
>> UITextColor.y
|
||||
>> UITextColor.z;
|
||||
UITextColor.x = clamp( UITextColor.x, 0.0f, 255.0f );
|
||||
UITextColor.y = clamp( UITextColor.y, 0.0f, 255.0f );
|
||||
UITextColor.z = clamp( UITextColor.z, 0.0f, 255.0f );
|
||||
>> UITextColor.r
|
||||
>> UITextColor.g
|
||||
>> UITextColor.b;
|
||||
UITextColor.r = clamp( UITextColor.r, 0.0f, 255.0f );
|
||||
UITextColor.g = clamp( UITextColor.g, 0.0f, 255.0f );
|
||||
UITextColor.b = clamp( UITextColor.b, 0.0f, 255.0f );
|
||||
UITextColor = UITextColor / 255.0f;
|
||||
UITextColor.w = 1.0f;
|
||||
UITextColor.a = 1.0f;
|
||||
}
|
||||
else if (token == "pyscreenrendererpriority")
|
||||
{
|
||||
@@ -704,7 +704,9 @@ global_settings::ConfigParse(cParser &Parser) {
|
||||
// TBD: remove, or launch depending on passed flag?
|
||||
if (qp)
|
||||
{ // to poniżej wykonywane tylko raz, jedynie po wczytaniu eu07.ini*/
|
||||
#ifdef _WINDOWS
|
||||
Console::ModeSet(iFeedbackMode, iFeedbackPort); // tryb pracy konsoli sterowniczej
|
||||
#endif
|
||||
/*iFpsRadiusMax = 0.000025 * fFpsRadiusMax *
|
||||
fFpsRadiusMax; // maksymalny promień renderowania 3000.0 -> 225
|
||||
if (iFpsRadiusMax > 400)
|
||||
|
||||
@@ -73,7 +73,7 @@ struct global_settings {
|
||||
double fFogStart{ 1700 };
|
||||
double fFogEnd{ 2000 };
|
||||
std::string Season; // season of the year, based on simulation date
|
||||
std::string Weather{ "clear" }; // current weather
|
||||
std::string Weather{ "clear:" }; // current weather
|
||||
bool FullPhysics{ true }; // full calculations performed for each simulation step
|
||||
bool bnewAirCouplers{ true };
|
||||
double fMoveLight{ -1 }; // numer dnia w roku albo -1
|
||||
@@ -89,7 +89,7 @@ struct global_settings {
|
||||
// ui
|
||||
int iTextMode{ 0 }; // tryb pracy wyświetlacza tekstowego
|
||||
int iScreenMode[ 12 ] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // numer ekranu wyświetlacza tekstowego
|
||||
float4 UITextColor{ float4( 225.f / 255.f, 225.f / 255.f, 225.f / 255.f, 1.f ) }; // base color of UI text
|
||||
glm::vec4 UITextColor { glm::vec4( 225.f / 255.f, 225.f / 255.f, 225.f / 255.f, 1.f ) }; // base color of UI text
|
||||
std::string asLang{ "pl" }; // domyślny język - http://tools.ietf.org/html/bcp47
|
||||
// gfx
|
||||
int iWindowWidth{ 800 };
|
||||
@@ -182,7 +182,7 @@ struct global_settings {
|
||||
int iMultiplayer{ 0 }; // blokada działania niektórych eventów na rzecz kominikacji
|
||||
// other
|
||||
std::string AppName{ "EU07" };
|
||||
std::string asVersion{ "couldn't retrieve version string" }; // z opisem
|
||||
std::string asVersion{ "UNKNOWN" }; // z opisem
|
||||
|
||||
// methods
|
||||
void LoadIniFile( std::string asFileName );
|
||||
|
||||
8
Logs.h
8
Logs.h
@@ -13,10 +13,10 @@ http://mozilla.org/MPL/2.0/.
|
||||
|
||||
enum logtype : unsigned int {
|
||||
|
||||
generic = 0x1,
|
||||
file = 0x2,
|
||||
model = 0x4,
|
||||
texture = 0x8
|
||||
generic = ( 1 << 0 ),
|
||||
file = ( 1 << 1 ),
|
||||
model = ( 1 << 2 ),
|
||||
texture = ( 1 << 3 )
|
||||
};
|
||||
|
||||
void WriteLog( const char *str, logtype const Type = logtype::generic );
|
||||
|
||||
@@ -6108,52 +6108,55 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset)
|
||||
// *************************************************************************************************
|
||||
std::string TMoverParameters::EngineDescription(int what)
|
||||
{
|
||||
std::string outstr;
|
||||
|
||||
outstr = "";
|
||||
switch (what)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (DamageFlag == 255)
|
||||
std::string outstr { "OK" };
|
||||
switch (what) {
|
||||
case 0: {
|
||||
if( DamageFlag == 255 ) {
|
||||
outstr = "WRECKED";
|
||||
else
|
||||
{
|
||||
if (TestFlag(DamageFlag, dtrain_thinwheel))
|
||||
if (Power > 0.1)
|
||||
}
|
||||
else {
|
||||
if( TestFlag( DamageFlag, dtrain_thinwheel ) ) {
|
||||
if( Power > 0.1 )
|
||||
outstr = "Thin wheel";
|
||||
else
|
||||
outstr = "Load shifted";
|
||||
if (TestFlag(DamageFlag, dtrain_wheelwear))
|
||||
}
|
||||
if( ( WheelFlat > 5.0 )
|
||||
|| ( TestFlag( DamageFlag, dtrain_wheelwear ) ) ) {
|
||||
outstr = "Wheel wear";
|
||||
if (TestFlag(DamageFlag, dtrain_bearing))
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_bearing ) ) {
|
||||
outstr = "Bearing damaged";
|
||||
if (TestFlag(DamageFlag, dtrain_coupling))
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_coupling ) ) {
|
||||
outstr = "Coupler broken";
|
||||
if (TestFlag(DamageFlag, dtrain_loaddamage))
|
||||
if (Power > 0.1)
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_loaddamage ) ) {
|
||||
if( Power > 0.1 )
|
||||
outstr = "Ventilator damaged";
|
||||
else
|
||||
outstr = "Load damaged";
|
||||
|
||||
if (TestFlag(DamageFlag, dtrain_loaddestroyed))
|
||||
if (Power > 0.1)
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_loaddestroyed ) ) {
|
||||
if( Power > 0.1 )
|
||||
outstr = "Engine damaged";
|
||||
else
|
||||
outstr = "LOAD DESTROYED";
|
||||
if (TestFlag(DamageFlag, dtrain_axle))
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_axle ) ) {
|
||||
outstr = "Axle broken";
|
||||
if (TestFlag(DamageFlag, dtrain_out))
|
||||
}
|
||||
if( TestFlag( DamageFlag, dtrain_out ) ) {
|
||||
outstr = "DERAILED";
|
||||
if (outstr == "")
|
||||
outstr = "OK";
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
default: {
|
||||
outstr = "Invalid qualifier";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return outstr;
|
||||
}
|
||||
|
||||
|
||||
@@ -513,7 +513,7 @@ class TDriverHandle {
|
||||
virtual double GetPos(int i);
|
||||
virtual double GetEP(double pos);
|
||||
|
||||
inline TDriverHandle() { ::SecureZeroMemory( Sounds, sizeof( Sounds ) ); }
|
||||
inline TDriverHandle() { memset( Sounds, 0, sizeof( Sounds ) ); }
|
||||
};
|
||||
|
||||
class TFV4a : public TDriverHandle {
|
||||
|
||||
@@ -4772,7 +4772,7 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName)
|
||||
}
|
||||
else if( token == "runningnoise:" ) {
|
||||
// szum podczas jazdy:
|
||||
rsRunningNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency );
|
||||
rsRunningNoise.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, mvOccupied->Vmax );
|
||||
rsRunningNoise.owner( DynamicObject );
|
||||
|
||||
rsRunningNoise.m_amplitudefactor /= ( 1 + mvOccupied->Vmax );
|
||||
|
||||
@@ -1262,7 +1262,7 @@ TWorld::Update_UI() {
|
||||
( ( owner->iStationStart < table->StationIndex )
|
||||
&& ( i < table->StationIndex )
|
||||
&& ( ( time.wHour * 60 + time.wMinute ) >= ( tableline->Dh * 60 + tableline->Dm ) ) ?
|
||||
float4( 0.0f, 1.0f, 0.0f, 1.0f ) :// czas minął i odjazd był, to nazwa stacji będzie na zielono
|
||||
glm::vec4( 0.0f, 1.0f, 0.0f, 1.0f ) :// czas minął i odjazd był, to nazwa stacji będzie na zielono
|
||||
Global.UITextColor ) );
|
||||
// divider/footer
|
||||
UITable->text_lines.emplace_back( "+----------------------------+-------+-------+-----+", Global.UITextColor );
|
||||
@@ -1556,7 +1556,7 @@ TWorld::Update_UI() {
|
||||
+ ", PM=" + to_string( vehicle->MoverParameters->WheelFlat, 1 )
|
||||
+ " mm; enrot=" + to_string( vehicle->MoverParameters->enrot * 60, 0 )
|
||||
+ " tmrot=" + to_string( std::abs( vehicle->MoverParameters->nrot ) * vehicle->MoverParameters->Transmision.Ratio * 60, 0 )
|
||||
+ "; ventrot=" + to_string( vehicle->MoverParameters->RventRot, 1 );
|
||||
+ "; ventrot=" + to_string( vehicle->MoverParameters->RventRot * 60, 1 );
|
||||
|
||||
uitextline2 =
|
||||
"HamZ=" + to_string( vehicle->MoverParameters->fBrakeCtrlPos, 2 )
|
||||
@@ -1746,7 +1746,7 @@ TWorld::Update_UI() {
|
||||
while( true == parser.getTokens( 1, false, "|" ) ) {
|
||||
|
||||
std::string transcriptline; parser >> transcriptline;
|
||||
transcripts.emplace_back( transcriptline, float4( 1.0f, 1.0f, 0.0f, 1.0f ) );
|
||||
transcripts.emplace_back( transcriptline, glm::vec4( 1.0f, 1.0f, 0.0f, 1.0f ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
83
material.cpp
83
material.cpp
@@ -14,6 +14,14 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "utilities.h"
|
||||
#include "globals.h"
|
||||
|
||||
// helper, returns potential path part from provided file name
|
||||
std::string path( std::string const &Filename ) {
|
||||
return (
|
||||
Filename.rfind( '\\' ) != std::string::npos ?
|
||||
Filename.substr( 0, Filename.rfind( '\\' ) + 1 ) :
|
||||
"" );
|
||||
}
|
||||
|
||||
bool
|
||||
opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
|
||||
|
||||
@@ -33,51 +41,58 @@ opengl_material::deserialize( cParser &Input, bool const Loadnow ) {
|
||||
// imports member data pair from the config file
|
||||
bool
|
||||
opengl_material::deserialize_mapping( cParser &Input, int const Priority, bool const Loadnow ) {
|
||||
// token can be a key or block end
|
||||
std::string const key { Input.getToken<std::string>( true, "\n\r\t ,;[]" ) };
|
||||
|
||||
if( false == Input.getTokens( 2, true, "\n\r\t;, " ) ) {
|
||||
return false;
|
||||
}
|
||||
if( ( true == key.empty() ) || ( key == "}" ) ) { return false; }
|
||||
|
||||
std::string path;
|
||||
if( name.rfind( '\\' ) != std::string::npos ) {
|
||||
path = name.substr( 0, name.rfind( '\\' ) + 1 );
|
||||
}
|
||||
auto const value { Input.getToken<std::string>( true, "\n\r\t ,;" ) };
|
||||
|
||||
std::string key, value;
|
||||
Input
|
||||
>> key
|
||||
>> value;
|
||||
|
||||
if( value == "{" ) {
|
||||
// detect and optionally process config blocks
|
||||
cParser blockparser( Input.getToken<std::string>( false, "}" ) );
|
||||
if( key == Global.Season ) {
|
||||
if( Priority != -1 ) {
|
||||
// regular attribute processing mode
|
||||
if( key == Global.Weather ) {
|
||||
// weather textures override generic (pri 0) and seasonal (pri 1) textures
|
||||
// seasonal weather textures (pri 1+2=3) override generic weather (pri 2) textures
|
||||
while( true == deserialize_mapping( Input, Priority + 2, Loadnow ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
else if( key == Global.Season ) {
|
||||
// seasonal textures override generic textures
|
||||
while( true == deserialize_mapping( blockparser, 1, Loadnow ) ) {
|
||||
while( true == deserialize_mapping( Input, 1, Loadnow ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
else if( key == Global.Weather ) {
|
||||
// weather textures override generic and seasonal textures
|
||||
while( true == deserialize_mapping( blockparser, 2, Loadnow ) ) {
|
||||
else if( key == "texture1:" ) {
|
||||
if( ( texture1 == null_handle )
|
||||
|| ( Priority > priority1 ) ) {
|
||||
texture1 = GfxRenderer.Fetch_Texture( path( name ) + value, Loadnow );
|
||||
priority1 = Priority;
|
||||
}
|
||||
}
|
||||
else if( key == "texture2:" ) {
|
||||
if( ( texture2 == null_handle )
|
||||
|| ( Priority > priority2 ) ) {
|
||||
texture2 = GfxRenderer.Fetch_Texture( path( name ) + value, Loadnow );
|
||||
priority2 = Priority;
|
||||
}
|
||||
}
|
||||
else if( value == "{" ) {
|
||||
// unrecognized or ignored token, but comes with attribute block and potential further nesting
|
||||
// go through it and discard the content
|
||||
while( true == deserialize_mapping( Input, -1, Loadnow ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( key == "texture1:" ) {
|
||||
// TODO: full-fledged priority system
|
||||
if( ( texture1 == null_handle )
|
||||
|| ( Priority > priority1 ) ) {
|
||||
texture1 = GfxRenderer.Fetch_Texture( path + value, Loadnow );
|
||||
priority1 = Priority;
|
||||
}
|
||||
}
|
||||
else if( key == "texture2:" ) {
|
||||
// TODO: full-fledged priority system
|
||||
if( ( texture2 == null_handle )
|
||||
|| ( Priority > priority2 ) ) {
|
||||
texture2 = GfxRenderer.Fetch_Texture( path + value, Loadnow );
|
||||
priority2 = Priority;
|
||||
else {
|
||||
// discard mode; ignores all retrieved tokens
|
||||
if( value == "{" ) {
|
||||
// ignored tokens can come with their own blocks, ignore these recursively
|
||||
// go through it and discard the content
|
||||
while( true == deserialize_mapping( Input, -1, Loadnow ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ sound_source::deserialize( std::string const &Input, sound_type const Legacytype
|
||||
}
|
||||
|
||||
sound_source &
|
||||
sound_source::deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters ) {
|
||||
sound_source::deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters, int const Chunkrange ) {
|
||||
|
||||
// cache parser config, as it may change during deserialization
|
||||
auto const inputautoclear { Input.autoclear() };
|
||||
@@ -80,7 +80,7 @@ sound_source::deserialize( cParser &Input, sound_type const Legacytype, int cons
|
||||
m_crossfaderange * 0.01f );
|
||||
*/
|
||||
}
|
||||
m_soundchunks.back().second.fadeout = std::max( 100, m_soundchunks.back().second.threshold );
|
||||
m_soundchunks.back().second.fadeout = std::max( Chunkrange, m_soundchunks.back().second.threshold );
|
||||
// m_soundchunks.back().second.fadeout = m_soundchunks.back().second.threshold;
|
||||
// test if the chunk table contains any actual samples while at it
|
||||
for( auto &soundchunk : m_soundchunks ) {
|
||||
|
||||
2
sound.h
2
sound.h
@@ -56,7 +56,7 @@ public:
|
||||
// methods
|
||||
// restores state of the class from provided data stream
|
||||
sound_source &
|
||||
deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters = 0 );
|
||||
deserialize( cParser &Input, sound_type const Legacytype, int const Legacyparameters = 0, int const Chunkrange = 100 );
|
||||
sound_source &
|
||||
deserialize( std::string const &Input, sound_type const Legacytype, int const Legacyparameters = 0 );
|
||||
// copies list of sounds from provided source
|
||||
|
||||
24
uilayer.cpp
24
uilayer.cpp
@@ -126,18 +126,18 @@ ui_layer::render_progress() {
|
||||
size = glm::vec2{ 320.0f, 16.0f };
|
||||
}
|
||||
|
||||
quad( float4( origin.x, origin.y, origin.x + size.x, origin.y + size.y ), float4(0.0f, 0.0f, 0.0f, 0.25f) );
|
||||
quad( glm::vec4( origin.x, origin.y, origin.x + size.x, origin.y + size.y ), glm::vec4(0.0f, 0.0f, 0.0f, 0.25f) );
|
||||
// secondary bar
|
||||
if( m_subtaskprogress ) {
|
||||
quad(
|
||||
float4( origin.x, origin.y, origin.x + size.x * m_subtaskprogress, origin.y + size.y),
|
||||
float4( 8.0f/255.0f, 160.0f/255.0f, 8.0f/255.0f, 0.35f ) );
|
||||
glm::vec4( origin.x, origin.y, origin.x + size.x * m_subtaskprogress, origin.y + size.y),
|
||||
glm::vec4( 8.0f/255.0f, 160.0f/255.0f, 8.0f/255.0f, 0.35f ) );
|
||||
}
|
||||
// primary bar
|
||||
if( m_progress ) {
|
||||
quad(
|
||||
float4( origin.x, origin.y, origin.x + size.x * m_progress, origin.y + size.y ),
|
||||
float4( 8.0f / 255.0f, 160.0f / 255.0f, 8.0f / 255.0f, 1.0f ) );
|
||||
glm::vec4( origin.x, origin.y, origin.x + size.x * m_progress, origin.y + size.y ),
|
||||
glm::vec4( 8.0f / 255.0f, 160.0f / 255.0f, 8.0f / 255.0f, 1.0f ) );
|
||||
}
|
||||
|
||||
if( false == m_progresstext.empty() ) {
|
||||
@@ -224,12 +224,12 @@ ui_layer::render_background() {
|
||||
1024.0f : // legacy mode, square texture displayed as 4:3 image
|
||||
texture.width() / ( texture.height() / 768.0f ) );
|
||||
quad(
|
||||
float4(
|
||||
glm::vec4(
|
||||
( 1024.0f * 0.5f ) - ( width * 0.5f ),
|
||||
( 768.0f * 0.5f ) - ( height * 0.5f ),
|
||||
( 1024.0f * 0.5f ) - ( width * 0.5f ) + width,
|
||||
( 768.0f * 0.5f ) - ( height * 0.5f ) + height ),
|
||||
float4( 1.0f, 1.0f, 1.0f, 1.0f ) );
|
||||
colors::white );
|
||||
}
|
||||
|
||||
void
|
||||
@@ -276,7 +276,7 @@ ui_layer::print( std::string const &Text )
|
||||
}
|
||||
|
||||
void
|
||||
ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
|
||||
ui_layer::quad( glm::vec4 const &Coordinates, glm::vec4 const &Color ) {
|
||||
|
||||
float const screenratio = static_cast<float>( Global.iWindowWidth ) / Global.iWindowHeight;
|
||||
float const width =
|
||||
@@ -288,12 +288,8 @@ ui_layer::quad( float4 const &Coordinates, float4 const &Color ) {
|
||||
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;
|
||||
float const width = Global.iWindowWidth * heightratio;
|
||||
*/
|
||||
glColor4fv(&Color.x);
|
||||
|
||||
glColor4fv(glm::value_ptr(Color));
|
||||
|
||||
glBegin( GL_TRIANGLE_STRIP );
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <string>
|
||||
#include "texture.h"
|
||||
#include "float3d.h"
|
||||
|
||||
// GuiLayer -- basic user interface class. draws requested information on top of openGL screen
|
||||
|
||||
@@ -11,10 +10,10 @@ struct ui_panel {
|
||||
|
||||
struct text_line {
|
||||
|
||||
float4 color;
|
||||
glm::vec4 color;
|
||||
std::string data;
|
||||
|
||||
text_line( std::string const &Data, float4 const &Color):
|
||||
text_line( std::string const &Data, glm::vec4 const &Color):
|
||||
data(Data), color(Color)
|
||||
{}
|
||||
};
|
||||
@@ -84,7 +83,7 @@ private:
|
||||
print( std::string const &Text );
|
||||
// draws a quad between coordinates x,y and z,w with uv-coordinates spanning 0-1
|
||||
void
|
||||
quad( float4 const &Coordinates, float4 const &Color );
|
||||
quad( glm::vec4 const &Coordinates, glm::vec4 const &Color );
|
||||
|
||||
|
||||
// members:
|
||||
|
||||
Reference in New Issue
Block a user