mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-19 21:29:19 +02:00
TAirCoupler - partial refactor
- rename private members - refactor TAirCoupler::GetStatus() - add some English comments - add 'doc/' in .gitingore TODO: - rename arguments when refactor other files (as TModel3d, cParser).
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -74,4 +74,6 @@ builds/build_*
|
|||||||
builds/*.zip
|
builds/*.zip
|
||||||
builds/deps_*
|
builds/deps_*
|
||||||
|
|
||||||
|
doc/
|
||||||
|
|
||||||
CMakeLists.txt.user
|
CMakeLists.txt.user
|
||||||
|
|||||||
@@ -19,60 +19,73 @@ TAirCoupler::~TAirCoupler()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// zwraca 1, jeśli istnieje model prosty, 2 gdy skośny
|
||||||
|
/**
|
||||||
|
* Returns 0 when straight model exists,
|
||||||
|
* 2 when oblique model exists, and 0 when neither of them exist.
|
||||||
|
*/
|
||||||
int TAirCoupler::GetStatus()
|
int TAirCoupler::GetStatus()
|
||||||
{ // zwraca 1, jeśli istnieje model prosty, 2 gdy skośny
|
{
|
||||||
int x = 0;
|
if (ModelOn) return 1;
|
||||||
if (pModelOn)
|
if (ModelxOn) return 2;
|
||||||
x = 1;
|
return 0;
|
||||||
if (pModelxOn)
|
|
||||||
x = 2;
|
|
||||||
return x;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// zerowanie wskaźników
|
||||||
|
/**
|
||||||
|
* Reset pointers.
|
||||||
|
*/
|
||||||
void TAirCoupler::Clear()
|
void TAirCoupler::Clear()
|
||||||
{ // zerowanie wskaźników
|
{
|
||||||
pModelOn = NULL;
|
ModelOn = NULL;
|
||||||
pModelOff = NULL;
|
ModelOff = NULL;
|
||||||
pModelxOn = NULL;
|
ModelxOn = NULL;
|
||||||
bOn = false;
|
On = false;
|
||||||
bxOn = false;
|
xOn = false;
|
||||||
}
|
}
|
||||||
|
// wyszukanie submodeli
|
||||||
void TAirCoupler::Init(std::string const &asName, TModel3d *pModel)
|
/**
|
||||||
{ // wyszukanie submodeli
|
* Looks for submodels.
|
||||||
if (!pModel)
|
*/
|
||||||
|
void TAirCoupler::Init(std::string const &asName, TModel3d *Model)
|
||||||
|
{
|
||||||
|
if (!Model)
|
||||||
return; // nie ma w czym szukać
|
return; // nie ma w czym szukać
|
||||||
pModelOn = pModel->GetFromName( asName + "_on" ); // połączony na wprost
|
// polaczony na wprost
|
||||||
pModelOff = pModel->GetFromName( asName + "_off" ); // odwieszony
|
/** Straight connect. */
|
||||||
pModelxOn = pModel->GetFromName( asName + "_xon" ); // połączony na skos
|
ModelOn = Model->GetFromName(asName + "_on");
|
||||||
|
// odwieszony
|
||||||
|
/** Not connected. Hung up. */
|
||||||
|
ModelOff = Model->GetFromName(asName + "_off");
|
||||||
|
// polaczony na skos
|
||||||
|
/** Oblique connect. */
|
||||||
|
ModelxOn = Model->GetFromName(asName + "_xon");
|
||||||
}
|
}
|
||||||
|
|
||||||
void TAirCoupler::Load(cParser *Parser, TModel3d *pModel)
|
void TAirCoupler::Load(cParser *Parser, TModel3d *Model)
|
||||||
{
|
{
|
||||||
std::string name = Parser->getToken<std::string>();
|
std::string name = Parser->getToken<std::string>();
|
||||||
if( pModel ) {
|
if(Model)
|
||||||
|
{
|
||||||
Init( name, pModel );
|
Init(name, Model);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pModelOn = NULL;
|
ModelOn = NULL;
|
||||||
pModelxOn = NULL;
|
ModelxOn = NULL;
|
||||||
pModelOff = NULL;
|
ModelOff = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TAirCoupler::Update()
|
void TAirCoupler::Update()
|
||||||
{
|
{
|
||||||
// if ((pModelOn!=NULL) && (pModelOn!=NULL))
|
// if ((pModelOn!=NULL) && (pModelOn!=NULL)) // legacy bullshitt alert
|
||||||
{
|
{
|
||||||
if (pModelOn)
|
if (ModelOn)
|
||||||
pModelOn->iVisible = bOn;
|
ModelOn->iVisible = On;
|
||||||
if (pModelOff)
|
if (ModelOff)
|
||||||
pModelOff->iVisible = !(bOn || bxOn);
|
ModelOff->iVisible = !(On || xOn);
|
||||||
if (pModelxOn)
|
if (ModelxOn)
|
||||||
pModelxOn->iVisible = bxOn;
|
ModelxOn->iVisible = xOn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|||||||
36
AirCoupler.h
36
AirCoupler.h
@@ -14,40 +14,38 @@ http://mozilla.org/MPL/2.0/.
|
|||||||
|
|
||||||
class TAirCoupler
|
class TAirCoupler
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
// TButtonType eType;
|
// TButtonType eType; //?
|
||||||
TSubModel *pModelOn, *pModelOff, *pModelxOn;
|
TSubModel *ModelOn, *ModelOff, *ModelxOn;
|
||||||
bool bOn;
|
bool On;
|
||||||
bool bxOn;
|
bool xOn;
|
||||||
void Update();
|
void Update();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TAirCoupler();
|
TAirCoupler();
|
||||||
~TAirCoupler();
|
~TAirCoupler();
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
void Init(std::string const &asName, TModel3d *Model);
|
||||||
|
void Load(cParser *Parser, TModel3d *Model);
|
||||||
|
// inline bool Active() { if ((ModelOn)||(ModelOff)) return true; return false;};
|
||||||
|
int GetStatus();
|
||||||
inline void TurnOn()
|
inline void TurnOn()
|
||||||
{
|
{
|
||||||
bOn = true;
|
On = true;
|
||||||
bxOn = false;
|
xOn = false;
|
||||||
Update();
|
Update();
|
||||||
};
|
};
|
||||||
inline void TurnOff()
|
inline void TurnOff()
|
||||||
{
|
{
|
||||||
bOn = false;
|
On = false;
|
||||||
bxOn = false;
|
xOn = false;
|
||||||
Update();
|
Update();
|
||||||
};
|
};
|
||||||
inline void TurnxOn()
|
inline void TurnxOn()
|
||||||
{
|
{
|
||||||
bOn = false;
|
On = false;
|
||||||
bxOn = true;
|
xOn = true;
|
||||||
Update();
|
Update();
|
||||||
};
|
};
|
||||||
// inline bool Active() { if ((pModelOn)||(pModelOff)) return true; return false;};
|
|
||||||
int GetStatus();
|
|
||||||
void Init(std::string const &asName, TModel3d *pModel);
|
|
||||||
void Load(cParser *Parser, TModel3d *pModel);
|
|
||||||
// bool Render();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|||||||
Reference in New Issue
Block a user