mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 08:19:56 +00:00
Merge remote branch 'yacoby/detailed_fps'
This commit is contained in:
commit
e3631003e9
8 changed files with 81 additions and 26 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <utility>
|
||||
|
||||
#include <OgreRoot.h>
|
||||
#include <OgreRenderWindow.h>
|
||||
|
||||
#include <MyGUI_WidgetManager.h>
|
||||
|
||||
|
@ -112,8 +113,10 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
}
|
||||
|
||||
// update GUI
|
||||
if(mShowFPS)
|
||||
mEnvironment.mWindowManager->wmSetFPS(mOgre->getFPS());
|
||||
Ogre::RenderWindow* window = mOgre->getWindow();
|
||||
mEnvironment.mWindowManager->wmUpdateFps(window->getLastFPS(),
|
||||
window->getTriangleCount(),
|
||||
window->getBatchCount());
|
||||
|
||||
mEnvironment.mWindowManager->onFrame(mEnvironment.mFrameDuration);
|
||||
|
||||
|
@ -157,7 +160,7 @@ bool OMW::Engine::frameRenderingQueued (const Ogre::FrameEvent& evt)
|
|||
OMW::Engine::Engine(Cfg::ConfigurationManager& configurationManager)
|
||||
: mOgre (0)
|
||||
, mPhysicEngine (0)
|
||||
, mShowFPS (false)
|
||||
, mFpsLevel(0)
|
||||
, mDebug (false)
|
||||
, mVerboseScripts (false)
|
||||
, mNewGame (false)
|
||||
|
@ -331,7 +334,7 @@ void OMW::Engine::go()
|
|||
MWScript::registerExtensions (mExtensions);
|
||||
|
||||
mEnvironment.mWindowManager = new MWGui::WindowManager(mGuiManager->getGui(), mEnvironment,
|
||||
mExtensions, mShowFPS, mNewGame);
|
||||
mExtensions, mFpsLevel, mNewGame);
|
||||
|
||||
// Create sound system
|
||||
mEnvironment.mSoundManager = new MWSound::SoundManager(mOgre->getRoot(),
|
||||
|
@ -451,9 +454,9 @@ void OMW::Engine::setSoundUsage(bool soundUsage)
|
|||
mUseSound = soundUsage;
|
||||
}
|
||||
|
||||
void OMW::Engine::showFPS(bool showFps)
|
||||
void OMW::Engine::showFPS(int level)
|
||||
{
|
||||
mShowFPS = showFps;
|
||||
mFpsLevel = level;
|
||||
}
|
||||
|
||||
void OMW::Engine::setEncoding(const std::string& encoding)
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace OMW
|
|||
OEngine::Physic::PhysicEngine* mPhysicEngine;
|
||||
std::string mCellName;
|
||||
std::string mMaster;
|
||||
bool mShowFPS;
|
||||
int mFpsLevel;
|
||||
bool mDebug;
|
||||
bool mVerboseScripts;
|
||||
bool mNewGame;
|
||||
|
@ -128,7 +128,7 @@ namespace OMW
|
|||
void addMaster(const std::string& master);
|
||||
|
||||
/// Enable fps counter
|
||||
void showFPS(bool showFps);
|
||||
void showFPS(int level);
|
||||
|
||||
/// Enable debug mode:
|
||||
/// - non-exclusive input
|
||||
|
|
|
@ -75,8 +75,8 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
|
|||
("plugin", bpo::value<StringsVector>()->default_value(StringsVector(), "")
|
||||
->multitoken(), "plugin file(s)")
|
||||
|
||||
("fps", boost::program_options::value<bool>()->implicit_value(true)
|
||||
->default_value(false), "show fps counter")
|
||||
("fps", boost::program_options::value<int>()->implicit_value(1)
|
||||
->default_value(0), "fps counter detail (0 = off, 1 = fps counter, 2 = full detail)")
|
||||
|
||||
("debug", boost::program_options::value<bool>()->implicit_value(true)
|
||||
->default_value(false), "debug mode")
|
||||
|
@ -200,7 +200,7 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Cfg::Configuratio
|
|||
engine.setNewGame(variables["new-game"].as<bool>());
|
||||
|
||||
// other settings
|
||||
engine.showFPS(variables["fps"].as<bool>());
|
||||
engine.showFPS(variables["fps"].as<int>());
|
||||
engine.setDebugMode(variables["debug"].as<bool>());
|
||||
engine.setSoundUsage(!variables["nosound"].as<bool>());
|
||||
engine.setScriptsVerbosity(variables["script-verbose"].as<bool>());
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
using namespace MWGui;
|
||||
|
||||
|
||||
HUD::HUD(int width, int height, bool fpsSwitch)
|
||||
HUD::HUD(int width, int height, int fpsLevel)
|
||||
: Layout("openmw_hud_layout.xml")
|
||||
{
|
||||
setCoord(0,0, width, height);
|
||||
|
@ -37,10 +37,19 @@ HUD::HUD(int width, int height, bool fpsSwitch)
|
|||
|
||||
getWidget(crosshair, "Crosshair");
|
||||
|
||||
if ( fpsLevel == 2 ){
|
||||
getWidget(fpsbox, "FPSBoxAdv");
|
||||
fpsbox->setVisible(true);
|
||||
getWidget(fpscounter, "FPSCounterAdv");
|
||||
}else if ( fpsLevel == 1 ){
|
||||
getWidget(fpsbox, "FPSBox");
|
||||
fpsbox->setVisible(true);
|
||||
getWidget(fpscounter, "FPSCounter");
|
||||
|
||||
fpsbox->setVisible(fpsSwitch);
|
||||
}else{
|
||||
getWidget(fpscounter, "FPSCounter");
|
||||
}
|
||||
getWidget(trianglecounter, "TriangleCounter");
|
||||
getWidget(batchcounter, "BatchCounter");
|
||||
|
||||
compass->setImageTexture("textures\\compass.dds");
|
||||
crosshair->setImageTexture("textures\\target.dds");
|
||||
|
@ -59,6 +68,15 @@ void HUD::setFPS(float fps)
|
|||
fpscounter->setCaption(boost::lexical_cast<std::string>((int)fps));
|
||||
}
|
||||
|
||||
void HUD::setTriangleCount(size_t count)
|
||||
{
|
||||
trianglecounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setBatchCount(size_t count)
|
||||
{
|
||||
batchcounter->setCaption(boost::lexical_cast<std::string>(count));
|
||||
}
|
||||
|
||||
void HUD::setStats(int h, int hmax, int m, int mmax, int s, int smax)
|
||||
{
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace MWGui
|
|||
class HUD : public OEngine::GUI::Layout
|
||||
{
|
||||
public:
|
||||
HUD(int width, int height, bool fpsSwitch);
|
||||
HUD(int width, int height, int fpsLevel);
|
||||
void setStats(int h, int hmax, int m, int mmax, int s, int smax);
|
||||
void setWeapIcon(const char *str);
|
||||
void setSpellIcon(const char *str);
|
||||
|
@ -41,6 +41,8 @@ namespace MWGui
|
|||
void setEffect(const char *img);
|
||||
void setValue (const std::string& id, const MWMechanics::DynamicStat<int>& value);
|
||||
void setFPS(float fps);
|
||||
void setTriangleCount(size_t count);
|
||||
void setBatchCount(size_t count);
|
||||
|
||||
MyGUI::ProgressPtr health, magicka, stamina;
|
||||
MyGUI::StaticImagePtr weapImage, spellImage;
|
||||
|
@ -53,6 +55,8 @@ namespace MWGui
|
|||
|
||||
MyGUI::WidgetPtr fpsbox;
|
||||
MyGUI::StaticTextPtr fpscounter;
|
||||
MyGUI::StaticTextPtr trianglecounter;
|
||||
MyGUI::StaticTextPtr batchcounter;
|
||||
};
|
||||
|
||||
class MapWindow : public OEngine::GUI::Layout
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
using namespace MWGui;
|
||||
|
||||
WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame)
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame)
|
||||
: environment(environment)
|
||||
, nameDialog(nullptr)
|
||||
, raceDialog(nullptr)
|
||||
|
@ -42,7 +42,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
|||
, shown(GW_ALL)
|
||||
, allowed(newGame ? GW_None : GW_ALL)
|
||||
{
|
||||
showFPSCounter = fpsSwitch;
|
||||
showFPSLevel = fpsLevel;
|
||||
|
||||
creationStage = NotStarted;
|
||||
|
||||
|
@ -54,7 +54,7 @@ WindowManager::WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment
|
|||
int w = gui->getViewSize().width;
|
||||
int h = gui->getViewSize().height;
|
||||
|
||||
hud = new HUD(w,h, showFPSCounter);
|
||||
hud = new HUD(w,h, showFPSLevel);
|
||||
menu = new MainMenu(w,h);
|
||||
map = new MapWindow();
|
||||
stats = new StatsWindow(*this);
|
||||
|
@ -138,9 +138,11 @@ void WindowManager::update()
|
|||
environment.mInputManager->setGuiMode(nextMode);
|
||||
nextMode = GM_Game;
|
||||
}
|
||||
if (showFPSCounter)
|
||||
if (showFPSLevel > 0)
|
||||
{
|
||||
hud->setFPS(mFPS);
|
||||
hud->setTriangleCount(mTriangleCount);
|
||||
hud->setBatchCount(mBatchCount);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -158,13 +158,15 @@ namespace MWGui
|
|||
|
||||
void setGuiMode(GuiMode newMode);
|
||||
|
||||
bool showFPSCounter;
|
||||
int showFPSLevel;
|
||||
float mFPS;
|
||||
size_t mTriangleCount;
|
||||
size_t mBatchCount;
|
||||
|
||||
public:
|
||||
/// The constructor needs the main Gui object
|
||||
WindowManager(MyGUI::Gui *_gui, MWWorld::Environment& environment,
|
||||
const Compiler::Extensions& extensions, bool fpsSwitch, bool newGame);
|
||||
const Compiler::Extensions& extensions, int fpsLevel, bool newGame);
|
||||
virtual ~WindowManager();
|
||||
|
||||
/**
|
||||
|
@ -207,7 +209,12 @@ namespace MWGui
|
|||
|
||||
MyGUI::Gui* getGui() const { return gui; }
|
||||
|
||||
void wmSetFPS(float fps) { mFPS = fps; }
|
||||
void wmUpdateFps(float fps, size_t triangleCount, size_t batchCount)
|
||||
{
|
||||
mFPS = fps;
|
||||
mTriangleCount = triangleCount;
|
||||
mBatchCount = batchCount;
|
||||
}
|
||||
|
||||
void setValue (const std::string& id, const MWMechanics::Stat<int>& value);
|
||||
///< Set value for the given ID.
|
||||
|
|
|
@ -49,12 +49,33 @@
|
|||
<Widget type="StaticImage" skin="StaticImage" position="0 0 32
|
||||
32" align="Center Center" name="Crosshair"/>
|
||||
|
||||
<!-- FPSCounter box -->
|
||||
|
||||
<!-- Basic FPSCounter box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="12 12 28 21" align="Left Top"
|
||||
name="FPSBox">
|
||||
<Property key="Widget_Visible" value="false"/>
|
||||
<Widget type="StaticText" skin="NumFPS" position="3 3 21 17" name="FPSCounter"/>
|
||||
</Widget>
|
||||
|
||||
<!-- Advanced FPSCounter box -->
|
||||
<Widget type="Widget" skin="HUD_Box" position="12 12 118 51" align="Left Top"
|
||||
name="FPSBoxAdv">
|
||||
<Property key="Widget_Visible" value="false"/>
|
||||
|
||||
<Widget type="StaticText" skin="NumFPS" position="3 3 71 17">
|
||||
<Property key="Widget_Caption" value="FPS: "/>
|
||||
</Widget>
|
||||
<Widget type="StaticText" skin="NumFPS" position="53 3 71 17" name="FPSCounterAdv"/>
|
||||
|
||||
<Widget type="StaticText" skin="NumFPS" position="3 3 71 32">
|
||||
<Property key="Widget_Caption" value="Tri Count: "/>
|
||||
</Widget>
|
||||
<Widget type="StaticText" skin="NumFPS" position="53 3 71 32" name="TriangleCounter"/>
|
||||
|
||||
<Widget type="StaticText" skin="NumFPS" position="3 3 71 47">
|
||||
<Property key="Widget_Caption" value="Batch Count: "/>
|
||||
</Widget>
|
||||
<Widget type="StaticText" skin="NumFPS" position="53 3 71 47" name="BatchCounter"/>
|
||||
</Widget>
|
||||
|
||||
</Widget>
|
||||
</MyGUI>
|
||||
|
|
Loading…
Reference in a new issue