mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-07-03 10:51:34 +00:00
added fps counter
This commit is contained in:
parent
fb89098ef7
commit
5132531f73
8 changed files with 42 additions and 5 deletions
|
@ -69,6 +69,11 @@ void OMW::Engine::executeLocalScripts()
|
||||||
|
|
||||||
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
{
|
{
|
||||||
|
if(mShowFPS)
|
||||||
|
{
|
||||||
|
mEnvironment.mWindowManager->wmSetFPS(mOgre.getFPS());
|
||||||
|
}
|
||||||
|
|
||||||
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
|
if(mUseSound && !(mEnvironment.mSoundManager->isMusicPlaying()))
|
||||||
{
|
{
|
||||||
// Play some good 'ol tunes
|
// Play some good 'ol tunes
|
||||||
|
@ -190,7 +195,8 @@ bool OMW::Engine::frameStarted(const Ogre::FrameEvent& evt)
|
||||||
}
|
}
|
||||||
|
|
||||||
OMW::Engine::Engine()
|
OMW::Engine::Engine()
|
||||||
: mDebug (false)
|
: mShowFPS (false)
|
||||||
|
, mDebug (false)
|
||||||
, mVerboseScripts (false)
|
, mVerboseScripts (false)
|
||||||
, mNewGame (false)
|
, mNewGame (false)
|
||||||
, mUseSound (true)
|
, mUseSound (true)
|
||||||
|
@ -348,7 +354,7 @@ void OMW::Engine::go()
|
||||||
MWScript::registerExtensions (mExtensions);
|
MWScript::registerExtensions (mExtensions);
|
||||||
|
|
||||||
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
||||||
mExtensions, mNewGame);
|
mExtensions, mShowFPS, mNewGame);
|
||||||
|
|
||||||
// Create sound system
|
// Create sound system
|
||||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
|
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre.getRoot(),
|
||||||
|
|
|
@ -61,6 +61,7 @@ namespace OMW
|
||||||
OEngine::Render::OgreRenderer mOgre;
|
OEngine::Render::OgreRenderer mOgre;
|
||||||
std::string mCellName;
|
std::string mCellName;
|
||||||
std::string mMaster;
|
std::string mMaster;
|
||||||
|
bool mShowFPS;
|
||||||
bool mDebug;
|
bool mDebug;
|
||||||
bool mVerboseScripts;
|
bool mVerboseScripts;
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
|
@ -119,6 +120,9 @@ namespace OMW
|
||||||
/// - Currently OpenMW only supports one master at the same time.
|
/// - Currently OpenMW only supports one master at the same time.
|
||||||
void addMaster (const std::string& master);
|
void addMaster (const std::string& master);
|
||||||
|
|
||||||
|
/// Enable fps counter
|
||||||
|
void showFPS() { mShowFPS = true; }
|
||||||
|
|
||||||
/// Enable debug mode:
|
/// Enable debug mode:
|
||||||
/// - non-exclusive input
|
/// - non-exclusive input
|
||||||
void enableDebugMode();
|
void enableDebugMode();
|
||||||
|
|
|
@ -49,6 +49,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
"set initial cell")
|
"set initial cell")
|
||||||
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
("master", bpo::value<std::string>()->default_value ("Morrowind"),
|
||||||
"master file")
|
"master file")
|
||||||
|
( "showfps", "show fps counter")
|
||||||
( "debug", "debug mode" )
|
( "debug", "debug mode" )
|
||||||
( "nosound", "disable all sound" )
|
( "nosound", "disable all sound" )
|
||||||
( "script-verbose", "verbose script output" )
|
( "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.setCell (variables["start"].as<std::string>());
|
||||||
engine.addMaster (variables["master"].as<std::string>());
|
engine.addMaster (variables["master"].as<std::string>());
|
||||||
|
|
||||||
|
if (variables.count ("showfps"))
|
||||||
|
engine.showFPS();
|
||||||
|
|
||||||
if (variables.count ("debug"))
|
if (variables.count ("debug"))
|
||||||
engine.enableDebugMode();
|
engine.enableDebugMode();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <openengine/gui/layout.hpp>
|
#include <openengine/gui/layout.hpp>
|
||||||
|
|
||||||
#include <boost/array.hpp>
|
#include <boost/array.hpp>
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
@ -58,6 +59,7 @@ namespace MWGui
|
||||||
getWidget(compass, "Compass");
|
getWidget(compass, "Compass");
|
||||||
|
|
||||||
getWidget(crosshair, "Crosshair");
|
getWidget(crosshair, "Crosshair");
|
||||||
|
getWidget(fpscounter, "FPSCounter");
|
||||||
|
|
||||||
compass->setImageTexture("textures\\compass.dds");
|
compass->setImageTexture("textures\\compass.dds");
|
||||||
crosshair->setImageTexture("textures\\target.dds");
|
crosshair->setImageTexture("textures\\target.dds");
|
||||||
|
@ -71,6 +73,11 @@ namespace MWGui
|
||||||
setEffect("icons\\s\\tx_s_chameleon.dds");
|
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)
|
void setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||||
{
|
{
|
||||||
health->setProgressRange(hmax);
|
health->setProgressRange(hmax);
|
||||||
|
@ -146,6 +153,7 @@ namespace MWGui
|
||||||
MyGUI::StaticImagePtr compass;
|
MyGUI::StaticImagePtr compass;
|
||||||
|
|
||||||
MyGUI::StaticImagePtr crosshair;
|
MyGUI::StaticImagePtr crosshair;
|
||||||
|
MyGUI::StaticTextPtr fpscounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapWindow : public OEngine::GUI::Layout
|
class MapWindow : public OEngine::GUI::Layout
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
using namespace MWGui;
|
using namespace MWGui;
|
||||||
|
|
||||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame)
|
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame)
|
||||||
: environment(environment)
|
: environment(environment)
|
||||||
, nameDialog(nullptr)
|
, nameDialog(nullptr)
|
||||||
, raceDialog(nullptr)
|
, raceDialog(nullptr)
|
||||||
|
@ -44,6 +44,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
||||||
, shown(GW_ALL)
|
, shown(GW_ALL)
|
||||||
, allowed(newGame ? GW_None : GW_ALL)
|
, allowed(newGame ? GW_None : GW_ALL)
|
||||||
{
|
{
|
||||||
|
showFPSCounter = fpsSwitch;
|
||||||
|
|
||||||
//Register own widgets with MyGUI
|
//Register own widgets with MyGUI
|
||||||
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
MyGUI::FactoryManager::getInstance().registerFactory<DialogeHistory>("Widget");
|
||||||
|
@ -127,6 +128,10 @@ void WindowManager::update()
|
||||||
environment.mInputManager->setGuiMode(nextMode);
|
environment.mInputManager->setGuiMode(nextMode);
|
||||||
nextMode = GM_Game;
|
nextMode = GM_Game;
|
||||||
}
|
}
|
||||||
|
if (showFPSCounter)
|
||||||
|
{
|
||||||
|
hud->setFPS(mFPS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowManager::setNextMode(GuiMode newMode)
|
void WindowManager::setNextMode(GuiMode newMode)
|
||||||
|
|
|
@ -153,10 +153,13 @@ namespace MWGui
|
||||||
|
|
||||||
void setGuiMode(GuiMode newMode);
|
void setGuiMode(GuiMode newMode);
|
||||||
|
|
||||||
|
bool showFPSCounter;
|
||||||
|
float mFPS;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// The constructor needs the main Gui object
|
/// The constructor needs the main Gui object
|
||||||
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||||
const Compiler::Extensions& extensions, bool newGame);
|
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame);
|
||||||
virtual ~WindowManager();
|
virtual ~WindowManager();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -197,6 +200,8 @@ namespace MWGui
|
||||||
|
|
||||||
MyGUI::Gui* getGui() const { return gui; }
|
MyGUI::Gui* getGui() const { return gui; }
|
||||||
|
|
||||||
|
void wmSetFPS(float fps) { mFPS = fps; }
|
||||||
|
|
||||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||||
///< Set value for the given ID.
|
///< Set value for the given ID.
|
||||||
|
|
||||||
|
|
|
@ -48,5 +48,11 @@
|
||||||
|
|
||||||
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
|
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
|
||||||
32" align="Center Center" name="Crosshair"/>
|
32" align="Center Center" name="Crosshair"/>
|
||||||
|
|
||||||
|
<!-- FPSCounter -->
|
||||||
|
|
||||||
|
<Widget type="StaticText" skin="SandText" position="278 123 65 80" align="Right Bottom"
|
||||||
|
name="FPSCounter"/>
|
||||||
|
|
||||||
</Widget>
|
</Widget>
|
||||||
</MyGUI>
|
</MyGUI>
|
||||||
|
|
Loading…
Reference in a new issue