added fps counter

actorid
sergoz 14 years ago
parent fb89098ef7
commit 5132531f73

@ -69,6 +69,11 @@ void OMW::Engine::executeLocalScripts()
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
{
if(mShowFPS)
{
mEnvironment.mWindowManager->wmSetFPS(mOgre.getFPS());
}
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
{
// Play some good 'ol tunes
@ -190,7 +195,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
}
OMW::Engine::Engine()
: mDebug (false)
: mShowFPS (false)
, mDebug (false)
, mVerboseScripts (false)
, mNewGame (false)
, mUseSound (true)
@ -348,7 +354,7 @@ void OMW::Engine::go()
MWScript::registerExtensions (mExtensions);
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
mExtensions, mNewGame);
mExtensions, mShowFPS, mNewGame);
// Create sound system
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),

@ -61,6 +61,7 @@ namespace OMW
OEngine::Render::OgreRenderer mOgre;
std::string mCellName;
std::string mMaster;
bool mShowFPS;
bool mDebug;
bool mVerboseScripts;
bool mNewGame;
@ -119,6 +120,9 @@ namespace OMW
/// - Currently OpenMW only supports one master at the same time.
void addMaster (const std::string& master);
/// Enable fps counter
void showFPS() { mShowFPS = true; }
/// Enable debug mode:
/// - non-exclusive input
void enableDebugMode();

@ -49,6 +49,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
"set initial cell")
("master", bpo::value<std::string>()->default_value ("Morrowind"),
"master file")
( "showfps", "show fps counter")
( "debug", "debug mode" )
( "nosound", "disable all sound" )
( "script-verbose", "verbose script output" )
@ -87,6 +88,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
engine.setCell (variables["start"].as<std::string>());
engine.addMaster (variables["master"].as<std::string>());
if (variables.count ("showfps"))
engine.showFPS();
if (variables.count ("debug"))
engine.enableDebugMode();

@ -7,7 +7,6 @@
#include <cmath>
#include <algorithm>
#include <iterator>
#include <boost/lexical_cast.hpp>
using namespace MWGui;

@ -6,6 +6,7 @@
#include <openengine/gui/layout.hpp>
#include <boost/array.hpp>
#include <boost/lexical_cast.hpp>
#include <sstream>
#include <set>
@ -58,6 +59,7 @@ namespace MWGui
getWidget(compass, "Compass");
getWidget(crosshair, "Crosshair");
getWidget(fpscounter, "FPSCounter");
compass->setImageTexture("textures\\compass.dds");
crosshair->setImageTexture("textures\\target.dds");
@ -71,6 +73,11 @@ namespace MWGui
setEffect("icons\\s\\tx_s_chameleon.dds");
}
void setFPS(float fps)
{
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
}
void setStats(int h, int hmax, int m, int mmax, int s, int smax)
{
health->setProgressRange(hmax);
@ -146,6 +153,7 @@ namespace MWGui
MyGUI::StaticImagePtr compass;
MyGUI::StaticImagePtr crosshair;
MyGUI::StaticTextPtr fpscounter;
};
class MapWindow : public OEngine::GUI::Layout

@ -20,7 +20,7 @@
using namespace MWGui;
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
const Compiler::Extensions& extensions, bool newGame)
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame)
: environment(environment)
, nameDialog(nullptr)
, raceDialog(nullptr)
@ -44,6 +44,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
, shown(GW_ALL)
, allowed(newGame ? GW_None : GW_ALL)
{
showFPSCounter = fpsSwitch;
//Register own widgets with MyGUI
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
@ -127,6 +128,10 @@ void WindowManager::update()
environment.mInputManager->setGuiMode(nextMode);
nextMode = GM_Game;
}
if (showFPSCounter)
{
hud->setFPS(mFPS);
}
}
void WindowManager::setNextMode(GuiMode newMode)

@ -153,10 +153,13 @@ namespace MWGui
void setGuiMode(GuiMode newMode);
bool showFPSCounter;
float mFPS;
public:
/// The constructor needs the main Gui object
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
const Compiler::Extensions& extensions, bool newGame);
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame);
virtual ~WindowManager();
/**
@ -197,6 +200,8 @@ namespace MWGui
MyGUI::Gui* getGui() const { return gui; }
void wmSetFPS(float fps) { mFPS = fps; }
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
///< Set value for the given ID.

@ -48,5 +48,11 @@
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
32" align="Center Center" name="Crosshair"/>
<!-- FPSCounter -->
<Widget type="StaticText" skin="SandText" position="278 123 65 80" align="Right Bottom"
name="FPSCounter"/>
</Widget>
</MyGUI>

Loading…
Cancel
Save