Revision: 2644 http://rigsofrods.svn.sourceforge.net/rigsofrods/?rev=2644&view=rev Author: rorthomas Date: 2012-05-24 00:58:01 +0000 (Thu, 24 May 2012) Log Message: ----------- new dashboard features: - dashboard parts will get shown/hidden depending on the vehicle configuration - updated dashboard layout: separated old images, added tractioncontrol lamp and anti-lock-brake lamp
Modified Paths: -------------- trunk/bin/resources/dashboards.zip trunk/source/main/gui/DashBoardManager.cpp trunk/source/main/gui/DashBoardManager.h trunk/source/main/physics/Beam.cpp trunk/source/main/physics/Beam.h Modified: trunk/bin/resources/dashboards.zip =================================================================== (Binary files differ) Modified: trunk/source/main/gui/DashBoardManager.cpp =================================================================== --- trunk/source/main/gui/DashBoardManager.cpp 2012-05-24 00:47:48 UTC (rev 2643) +++ trunk/source/main/gui/DashBoardManager.cpp 2012-05-24 00:58:01 UTC (rev 2644) @@ -163,6 +163,14 @@ } } +void DashBoardManager::updateFeatures() +{ + for(int i=0; i < free_dashboard; i++) + { + dashboards[i]->updateFeatures(); + } +} + float DashBoardManager::getNumeric( size_t key ) { switch(data[key].type) @@ -221,6 +229,17 @@ MyGUI::LayoutManager::getInstance().unloadLayout(widgets); } +void DashBoard::updateFeatures() +{ + // this hides / shows parts of the gui depending on the vehicle features + for(int i = 0; i < free_controls; i++) + { + bool enabled = manager->getEnabled(controls[i].linkID); + + controls[i].widget->setVisible(enabled); + } +} + void DashBoard::update( float &dt ) { // walk all controls and animate them @@ -373,9 +392,10 @@ void DashBoard::loadLayoutRecursive(MyGUI::WidgetPtr w) { - std::string name = w->getName(); - std::string anim = w->getUserString("anim"); - std::string debug = w->getUserString("debug"); + std::string name = w->getName(); + std::string anim = w->getUserString("anim"); + std::string debug = w->getUserString("debug"); + std::string linkArgs = w->getUserString("link"); // make it unclickable w->setUserString("interactive", "0"); @@ -407,7 +427,7 @@ // animations for this control? - if(!anim.empty()) + if(!linkArgs.empty()) { layoutLink_t ctrl; @@ -422,7 +442,7 @@ // establish the link { - String linkArgs = w->getUserString("link"); + replaceString(linkArgs, ">", ">"); replaceString(linkArgs, "<", "<"); String linkName = ""; Modified: trunk/source/main/gui/DashBoardManager.h =================================================================== --- trunk/source/main/gui/DashBoardManager.h 2012-05-24 00:47:48 UTC (rev 2643) +++ trunk/source/main/gui/DashBoardManager.h 2012-05-24 00:58:01 UTC (rev 2644) @@ -51,16 +51,19 @@ { char type; // DC_* dataContainer_t data; + bool enabled; const char *name; // char string of name dashData_t() : type(DC_INVALID) { memset(&data, 0, sizeof(data)); + enabled = false; } dashData_t(char type, const char *name) : type(type), name(name) { memset(&data, 0, sizeof(data)); + enabled = true; } } dashData_t; @@ -176,12 +179,15 @@ inline float _getFloat(size_t key) { return data[key].data.value_float; }; inline float getNumeric(size_t key); inline char *getChar(size_t key) { return data[key].data.value_char; }; + inline bool getEnabled( size_t key ) { return data[key].enabled; }; inline void setBool(size_t key, bool &val) { data[key].data.value_bool = val; }; inline void setInt(size_t key, int &val) { data[key].data.value_int = val; }; inline void setFloat(size_t key, float &val) { data[key].data.value_float = val; }; inline void setChar(size_t key, const char *val) { strncpy(data[key].data.value_char, val, DD_MAXCHAR); }; + inline void setEnabled(size_t key, bool val) { data[key].enabled = val; }; + inline int getDataType(size_t key) { return data[key].type; }; int getLinkIDForName(Ogre::String &str); @@ -189,6 +195,7 @@ int loadDashBoard(Ogre::String filename, bool textureLayer); void update(float &dt); + void updateFeatures(); bool wasLoaded() { return (free_dashboard > 0); }; @@ -196,7 +203,6 @@ void setVisible3d(bool visibility); bool getVisible() { return visible; }; void windowResized(); - protected: bool visible; dashData_t data[DD_MAX]; @@ -217,6 +223,7 @@ bool getIsTextureLayer() { return textureLayer; } void update(float &dt); + void updateFeatures(); void windowResized(); Modified: trunk/source/main/physics/Beam.cpp =================================================================== --- trunk/source/main/physics/Beam.cpp 2012-05-24 00:47:48 UTC (rev 2643) +++ trunk/source/main/physics/Beam.cpp 2012-05-24 00:58:01 UTC (rev 2644) @@ -183,6 +183,7 @@ , disableTruckTruckCollisions(false) , disableTruckTruckSelfCollisions(false) , pointCD(0) + , guiInitialized(false) { airbrakeval = 0; @@ -5772,8 +5773,8 @@ int cg = engine->getAutoShift(); if(cg != BeamEngine::MANUALMODE) { - str = ((cg == BeamEngine::REAR) ?"#ff0012":"#8a000a") + String("R\n"); - str += ((cg == BeamEngine::NEUTRAL)?"#ffffff":"#868686") + String("N\n"); + str = ((cg == BeamEngine::REAR) ?"#ffffff":"#868686") + String("R\n"); + str += ((cg == BeamEngine::NEUTRAL)?"#ff0012":"#8a000a") + String("N\n"); str += ((cg == BeamEngine::DRIVE) ?"#12ff00":"#248c00") + String("D\n"); str += ((cg == BeamEngine::TWO) ?"#ffffff":"#868686") + String("2\n"); str += ((cg == BeamEngine::ONE) ?"#ffffff":"#868686") + String("1"); @@ -6020,6 +6021,33 @@ dash->setFloat(DD_ODOMETER_USER, odometerUser); + // set the features of this vehicle once + if(!guiInitialized) + { + bool hasEngine = (engine != 0); + bool hasturbo = false; + + dash->setEnabled(DD_ENGINE_TURBO, engine->hasturbo); + dash->setEnabled(DD_ENGINE_GEAR, hasEngine); + dash->setEnabled(DD_ENGINE_NUM_GEAR, hasEngine); + dash->setEnabled(DD_ENGINE_GEAR_STRING, hasEngine); + dash->setEnabled(DD_ENGINE_AUTOGEAR_STRING, hasEngine); + dash->setEnabled(DD_ENGINE_AUTO_GEAR, hasEngine); + dash->setEnabled(DD_ENGINE_CLUTCH, hasEngine); + dash->setEnabled(DD_ENGINE_RPM, hasEngine); + dash->setEnabled(DD_ENGINE_IGNITION, hasEngine); + dash->setEnabled(DD_ENGINE_BATTERY, hasEngine); + dash->setEnabled(DD_ENGINE_CLUTCH_WARNING, hasEngine); + + dash->setEnabled(DD_TRACTIONCONTROL_MODE, tc_present); + dash->setEnabled(DD_ANTILOCKBRAKE_MODE, alb_present); + dash->setEnabled(DD_TIES_MODE, !ties.empty()); + dash->setEnabled(DD_LOCKED, !hooks.empty()); + + dash->updateFeatures(); + guiInitialized = true; + } + // TODO: compass value #if 0 Modified: trunk/source/main/physics/Beam.h =================================================================== --- trunk/source/main/physics/Beam.h 2012-05-24 00:47:48 UTC (rev 2643) +++ trunk/source/main/physics/Beam.h 2012-05-24 00:58:01 UTC (rev 2644) @@ -472,6 +472,7 @@ // SLIDE NODES ///////////////////////////////////////////////////////////// //! true if SlideNodes are locked, false if not bool SlideNodesLocked; + bool guiInitialized; /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Rigsofrods-devel mailing list Rigsofrods-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rigsofrods-devel