1
0
Fork 0

Preserve current view on reset/reinit/reposition

This commit is contained in:
Thomas Geymayer 2013-06-22 17:06:34 +02:00
parent b2d02c3970
commit 07e9b48344
2 changed files with 20 additions and 5 deletions

View file

@ -158,7 +158,7 @@ compare_values (SGPropertyNode * value1, SGPropertyNode * value2)
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
// Command implementations. // Command implementations.
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
@ -375,17 +375,25 @@ do_preferences_load (const SGPropertyNode * arg)
} }
static void static void
do_view_next( bool ) do_view_next(bool do_it)
{ {
// Only switch view if really requested to do so (and not for example while
// reset/reposition where /command/view/next is set to false)
if( do_it )
{
globals->get_current_view()->setHeadingOffset_deg(0.0); globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->next_view(); globals->get_viewmgr()->next_view();
}
} }
static void static void
do_view_prev( bool ) do_view_prev(bool do_it)
{ {
if( do_it )
{
globals->get_current_view()->setHeadingOffset_deg(0.0); globals->get_current_view()->setHeadingOffset_deg(0.0);
globals->get_viewmgr()->prev_view(); globals->get_viewmgr()->prev_view();
}
} }
/** /**

View file

@ -144,6 +144,8 @@ FGViewMgr::init ()
void void
FGViewMgr::reinit () FGViewMgr::reinit ()
{ {
int current_view_index = current;
// reset offsets and fov to configuration defaults // reset offsets and fov to configuration defaults
for (unsigned int i = 0; i < config_list.size(); i++) { for (unsigned int i = 0; i < config_list.size(); i++) {
SGPropertyNode *n = config_list[i]; SGPropertyNode *n = config_list[i];
@ -175,7 +177,7 @@ FGViewMgr::reinit ()
fgSetDouble("/sim/current-view/target-z-offset-m", fgSetDouble("/sim/current-view/target-z-offset-m",
n->getDoubleValue("config/target-z-offset-m")); n->getDoubleValue("config/target-z-offset-m"));
} }
setView(0); setView(current_view_index);
} }
typedef double (FGViewMgr::*double_getter)() const; typedef double (FGViewMgr::*double_getter)() const;
@ -219,7 +221,12 @@ FGViewMgr::do_bind()
_tiedProperties.Tie("view-number", this, _tiedProperties.Tie("view-number", this,
&FGViewMgr::getView, &FGViewMgr::setView); &FGViewMgr::getView, &FGViewMgr::setView);
fgSetArchivable("/sim/current-view/view-number", false); SGPropertyNode* view_number =
_tiedProperties.getRoot()->getNode("view-number");
view_number->setAttribute(SGPropertyNode::ARCHIVE, false);
// Keep view on reset/reinit
view_number->setAttribute(SGPropertyNode::PRESERVE, true);
_tiedProperties.Tie("axes/long", this, _tiedProperties.Tie("axes/long", this,
(double_getter)0, &FGViewMgr::setViewAxisLong); (double_getter)0, &FGViewMgr::setViewAxisLong);