mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-28 16:09:41 +00:00
[Client] Add network statistics (CTRL+F2)
This commit is contained in:
parent
e7a5919477
commit
3495fd43f4
5 changed files with 33 additions and 0 deletions
|
@ -23,6 +23,7 @@ namespace mwmp
|
|||
GUIChat::GUIChat(int x, int y, int w, int h)
|
||||
: WindowBase("tes3mp_chat.layout")
|
||||
{
|
||||
netStat = false;
|
||||
setCoord(x, y, w, h);
|
||||
|
||||
getWidget(mCommandLine, "edit_Command");
|
||||
|
@ -250,10 +251,21 @@ namespace mwmp
|
|||
this->mMainWidget->setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
if(netStat)
|
||||
{
|
||||
auto rss = Main::get().getNetworking()->getNetworkStatistics();
|
||||
mHistory->setCaption(rss);
|
||||
}
|
||||
}
|
||||
|
||||
void GUIChat::setDelay(float delay)
|
||||
{
|
||||
this->delay = delay;
|
||||
}
|
||||
|
||||
void GUIChat::switchNetstat()
|
||||
{
|
||||
netStat = !netStat;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,6 +68,8 @@ namespace mwmp
|
|||
|
||||
void send(const std::string &str);
|
||||
|
||||
void switchNetstat();
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
|
@ -82,6 +84,7 @@ namespace mwmp
|
|||
|
||||
int windowState;
|
||||
bool editState;
|
||||
bool netStat;
|
||||
float delay;
|
||||
float curTime;
|
||||
};
|
||||
|
|
|
@ -177,6 +177,12 @@ bool mwmp::GUIController::pressedKey(int key)
|
|||
MWBase::WindowManager *windowManager = MWBase::Environment::get().getWindowManager();
|
||||
if (mChat == nullptr || windowManager->getMode() != MWGui::GM_None)
|
||||
return false;
|
||||
|
||||
if(key == SDL_SCANCODE_F2 && (SDL_GetModState() & KMOD_CTRL) > 0)
|
||||
{
|
||||
mChat->switchNetstat();
|
||||
return true;
|
||||
}
|
||||
if (key == keyChatMode)
|
||||
{
|
||||
mChat->pressedChatMode();
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
#include <SDL_messagebox.h>
|
||||
#include <RakSleep.h>
|
||||
#include <RakNetStatistics.h>
|
||||
#include <iomanip>
|
||||
#include <components/version/version.hpp>
|
||||
|
||||
|
@ -194,6 +195,7 @@ Networking::~Networking()
|
|||
RakNet::RakPeerInterface::DestroyInstance(peer);
|
||||
}
|
||||
|
||||
|
||||
void Networking::update()
|
||||
{
|
||||
RakNet::Packet *packet;
|
||||
|
@ -450,3 +452,11 @@ bool Networking::isConnected()
|
|||
{
|
||||
return connected;
|
||||
}
|
||||
|
||||
std::string Networking::getNetworkStatistics()
|
||||
{
|
||||
static char message[2048];
|
||||
auto rss = peer->GetStatistics(peer->GetSystemAddressFromIndex(0));
|
||||
StatisticsToString(rss, message, 2);
|
||||
return message;
|
||||
}
|
||||
|
|
|
@ -46,6 +46,8 @@ namespace mwmp
|
|||
ActorList *getActorList();
|
||||
WorldEvent *getWorldEvent();
|
||||
|
||||
std::string getNetworkStatistics();
|
||||
|
||||
private:
|
||||
bool connected;
|
||||
RakNet::RakPeerInterface *peer;
|
||||
|
|
Loading…
Reference in a new issue