Preserve current view on reset/reinit/reposition
This commit is contained in:
parent
b2d02c3970
commit
07e9b48344
2 changed files with 20 additions and 5 deletions
|
@ -158,7 +158,7 @@ compare_values (SGPropertyNode * value1, SGPropertyNode * value2)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Command implementations.
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -375,17 +375,25 @@ do_preferences_load (const SGPropertyNode * arg)
|
|||
}
|
||||
|
||||
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_viewmgr()->next_view();
|
||||
}
|
||||
}
|
||||
|
||||
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_viewmgr()->prev_view();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -144,6 +144,8 @@ FGViewMgr::init ()
|
|||
void
|
||||
FGViewMgr::reinit ()
|
||||
{
|
||||
int current_view_index = current;
|
||||
|
||||
// reset offsets and fov to configuration defaults
|
||||
for (unsigned int i = 0; i < config_list.size(); i++) {
|
||||
SGPropertyNode *n = config_list[i];
|
||||
|
@ -175,7 +177,7 @@ FGViewMgr::reinit ()
|
|||
fgSetDouble("/sim/current-view/target-z-offset-m",
|
||||
n->getDoubleValue("config/target-z-offset-m"));
|
||||
}
|
||||
setView(0);
|
||||
setView(current_view_index);
|
||||
}
|
||||
|
||||
typedef double (FGViewMgr::*double_getter)() const;
|
||||
|
@ -219,7 +221,12 @@ FGViewMgr::do_bind()
|
|||
|
||||
_tiedProperties.Tie("view-number", this,
|
||||
&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,
|
||||
(double_getter)0, &FGViewMgr::setViewAxisLong);
|
||||
|
|
Loading…
Add table
Reference in a new issue