Skip to content

Commit

Permalink
Bites: deprecate ApplicationContext::reconfigure
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Feb 10, 2024
1 parent 4e87c30 commit b8bd260
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
6 changes: 2 additions & 4 deletions Components/Bites/include/OgreApplicationContextBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,8 @@ namespace OgreBites
*/
virtual void loadResources();

/**
Reconfigures the context. Attempts to preserve the current sample state.
*/
virtual void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options);
/// @deprecated use do not use
OGRE_DEPRECATED virtual void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options);


/**
Expand Down
19 changes: 10 additions & 9 deletions Samples/Browser/include/SampleBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -353,10 +353,8 @@ namespace OgreBites
{
bool reset = false;

auto options =
mRoot->getRenderSystemByName(mRendererMenu->getSelectedItem())->getConfigOptions();

Ogre::NameValuePairList newOptions;
Ogre::RenderSystem* rs = mRoot->getRenderSystemByName(mRendererMenu->getSelectedItem());
auto options = rs->getConfigOptions();

// collect new settings and decide if a reset is needed

Expand All @@ -367,12 +365,15 @@ namespace OgreBites
for (unsigned int i = 3; i < mTrayMgr->getWidgets(mRendererMenu->getTrayLocation()).size(); i++)
{
SelectMenu* menu = (SelectMenu*)mTrayMgr->getWidgets(mRendererMenu->getTrayLocation())[i];
if (menu->getSelectedItem() != options[menu->getCaption()].currentValue) reset = true;
newOptions[menu->getCaption()] = menu->getSelectedItem();
if (menu->getSelectedItem() != options[menu->getCaption()].currentValue)
{
rs->setConfigOption(menu->getCaption(), menu->getSelectedItem());
reset = true;
}
}

// reset with new settings if necessary
if (reset) reconfigure(mRendererMenu->getSelectedItem(), newOptions);
if (reset) reconfigure(mRendererMenu->getSelectedItem());
}
else
{
Expand Down Expand Up @@ -1080,7 +1081,7 @@ namespace OgreBites
/*-----------------------------------------------------------------------------
| Extends reconfigure to save the view and the index of last sample run.
-----------------------------------------------------------------------------*/
void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options) override
void reconfigure(const Ogre::String& renderer)
{
mLastViewCategory = mCategoryMenu->getSelectionIndex();
mLastViewTitle = mSampleMenu->getSelectionIndex();
Expand All @@ -1097,7 +1098,7 @@ namespace OgreBites
}
}

SampleContext::reconfigure(renderer, options);
SampleContext::reconfigure(renderer);
}
public:
/*-----------------------------------------------------------------------------
Expand Down
10 changes: 8 additions & 2 deletions Samples/Common/include/SampleContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,15 +326,21 @@ namespace OgreBites
/*-----------------------------------------------------------------------------
| Reconfigures the context. Attempts to preserve the current sample state.
-----------------------------------------------------------------------------*/
void reconfigure(const Ogre::String& renderer, Ogre::NameValuePairList& options) override
void reconfigure(const Ogre::String& renderer)
{
// save current sample state
mLastSample = mCurrentSample;
if (mCurrentSample) mCurrentSample->saveState(mLastSampleState);

mLastRun = false; // we want to go again with the new settings
ApplicationContext::reconfigure(renderer, options);
mNextRenderer = renderer;
#if OGRE_PLATFORM == OGRE_PLATFORM_APPLE_IOS
// Need to save the config on iOS to make sure that changes are kept on disk
mRoot->saveConfig();
#endif
mRoot->queueEndRendering(); // break from render loop
}
using ApplicationContextBase::reconfigure; // unused, silence warning

/*-----------------------------------------------------------------------------
| Recovers the last sample after a reset. You can override in the case that
Expand Down

0 comments on commit b8bd260

Please sign in to comment.