| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- function execNetGraphGuiGUI()
- {
- if ( isObject( NetGraphGui ) )
- NetGraphGui.delete();
-
- if ( isObject( NetGraphProfile ) )
- NetGraphProfile.delete();
-
- if ( isObject( NetGraphGhostsActiveProfile ) )
- NetGraphGhostsActiveProfile.delete();
-
- if ( isObject( NetGraphGhostUpdatesProfile ) )
- NetGraphGhostUpdatesProfile.delete();
-
- if ( isObject( NetGraphBitsSentProfile ) )
- NetGraphBitsSentProfile.delete();
-
- if ( isObject( NetGraphBitsReceivedProfile ) )
- NetGraphBitsReceivedProfile.delete();
-
- if ( isObject( NetGraphLatencyProfile ) )
- NetGraphLatencyProfile.delete();
-
- if ( isObject( NetGraphPacketLossProfile ) )
- NetGraphPacketLossProfile.delete();
-
- exec( "./NetGraphGui.gui" );
- }
- // Profiles
- new GuiControlProfile (NetGraphProfile)
- {
- modal = false;
- opaque = false;
- canKeyFocus = false;
- };
- new GuiControlProfile (NetGraphKeyContainerProfile)
- {
- border = true;
- opaque = true;
- fillColor = "100 100 100 200";
- };
- new GuiControlProfile (NetGraphGhostsActiveProfile)
- {
- border = false;
- fontColor = "255 255 255";
- };
- new GuiControlProfile (NetGraphGhostUpdatesProfile)
- {
- border = false;
- fontColor = "255 0 0";
- };
- new GuiControlProfile (NetGraphBitsSentProfile)
- {
- border = false;
- fontColor = "0 255 0";
- };
- new GuiControlProfile (NetGraphBitsReceivedProfile)
- {
- border = false;
- fontColor = "0 0 255";
- };
- new GuiControlProfile (NetGraphLatencyProfile)
- {
- border = false;
- fontColor = "0 255 255";
- };
- new GuiControlProfile (NetGraphPacketLossProfile)
- {
- border = false;
- fontColor = "0 0 0";
- };
- //--- OBJECT WRITE BEGIN ---
- $guiContent = new GuiControl(NetGraphGui) {
- position = "0 0";
- extent = "1024 768";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "1";
- noCursor = "1";
- new GuiGraphCtrl(NetGraph) {
- centerY = "1";
- plotColor[0] = "1 1 1 1";
- plotColor[1] = "1 0 0 1";
- plotColor[2] = "0 1 0 1";
- plotColor[3] = "0 0 1 1";
- plotColor[4] = "0 1 1 1";
- plotColor[5] = "0 0 0 1";
- plotType[0] = "PolyLine";
- plotType[1] = "PolyLine";
- plotType[2] = "PolyLine";
- plotType[3] = "PolyLine";
- plotType[4] = "PolyLine";
- plotType[5] = "PolyLine";
- plotInterval[0] = "0";
- plotInterval[1] = "0";
- plotInterval[2] = "0";
- plotInterval[3] = "0";
- plotInterval[4] = "0";
- plotInterval[5] = "0";
- position = "816 5";
- extent = "200 200";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphKeyContainerProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "0";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiControl() {
- position = "816 205";
- extent = "200 104";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphKeyContainerProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- new GuiTextCtrl(GhostsActive) {
- text = "Ghosts Active";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 0";
- extent = "100 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphGhostsActiveProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(GhostUpdates) {
- text = "Ghost Updates";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "100 0";
- extent = "100 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphGhostUpdatesProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(BitsSent) {
- text = "Bytes Sent";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 18";
- extent = "100 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphBitsSentProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(BitsReceived) {
- text = "Bytes Received";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "100 18";
- extent = "100 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphBitsReceivedProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(Latency) {
- text = "Latency";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 36";
- extent = "100 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphLatencyProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl(PacketLoss) {
- text = "Packet Loss";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "100 36";
- extent = "59 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Network Simulation:";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 52";
- extent = "97 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Simulated Latency:";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 68";
- extent = "91 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "ms";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "179 68";
- extent = "20 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl(NetGraphSimLatency) {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "0";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "112 67";
- extent = "64 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "Simulated Packet Loss:";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "0 83";
- extent = "111 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextCtrl() {
- text = "%";
- maxLength = "255";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "179 84";
- extent = "20 18";
- minExtent = "8 2";
- horizSizing = "left";
- vertSizing = "bottom";
- profile = "NetGraphPacketLossProfile";
- visible = "1";
- active = "1";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- new GuiTextEditCtrl(NetGraphSimPacket) {
- historySize = "0";
- tabComplete = "0";
- sinkAllKeyEvents = "0";
- password = "0";
- passwordMask = "*";
- text = "0";
- maxLength = "1024";
- margin = "0 0 0 0";
- padding = "0 0 0 0";
- anchorTop = "1";
- anchorBottom = "0";
- anchorLeft = "1";
- anchorRight = "0";
- position = "112 85";
- extent = "64 18";
- minExtent = "8 2";
- horizSizing = "right";
- vertSizing = "bottom";
- profile = "GuiTextEditProfile";
- visible = "1";
- active = "1";
- command = "if(NetGraphSimLatency.text $= \"\" || NetGraphSimLatency.text < 0)\n{\n NetGraphSimLatency.text = 0;\n}\n\nif(NetGraphSimPacket.text $= \"\" || NetGraphSimPacket.text < 0)\n{\n NetGraphSimLatency.text = 0;\n}\nelse if(NetGraphSimPacket.text > 100)\n{\n NetGraphSimPacket.text = 100;\n}\n\nnetSimulateLag( NetGraphSimLatency.text, NetGraphSimPacket.text );";
- tooltipProfile = "GuiToolTipProfile";
- hovertime = "1000";
- isContainer = "1";
- canSave = "1";
- canSaveDynamicFields = "0";
- };
- };
- };
- //--- OBJECT WRITE END ---
- // Functions
- function toggleNetGraph()
- {
- if(!$NetGraph::isInitialized)
- {
- NetGraph::updateStats();
- $NetGraph::isInitialized = true;
- }
- if(!Canvas.isMember(NetGraphGui))
- {
- Canvas.add(NetGraphGui);
- }
- else
- {
- Canvas.remove(NetGraphGui);
- netSimulateLag( 0, 0 );
- }
- }
- function NetGraph::updateStats()
- {
- $NetGraphThread = NetGraph.schedule(32, "updateStats");
- if(!$Stats::netGhostUpdates)
- return;
- if(isobject(NetGraph))
- {
- if(isobject(ServerConnection))
- NetGraph.addDatum(0,ServerConnection.getGhostsActive());
- GhostsActive.setText("Ghosts Active: " @ ServerConnection.getGhostsActive());
- NetGraph.addDatum(1,$Stats::netGhostUpdates);
- GhostUpdates.setText("Ghost Updates: " @ $Stats::netGhostUpdates);
- NetGraph.addDatum(2,$Stats::netBitsSent);
- BitsSent.setText("Bytes Sent: " @ $Stats::netBitsSent);
- NetGraph.addDatum(3,$Stats::netBitsReceived);
- BitsReceived.setText("Bytes Received: " @ $Stats::netBitsReceived);
- NetGraph.matchScale(2,3);
- NetGraph.addDatum(4,ServerConnection.getPing());
- Latency.setText("Latency: " @ ServerConnection.getPing());
- NetGraph.addDatum(5,ServerConnection.getPacketLoss());
- PacketLoss.setText("Packet Loss: " @ ServerConnection.getPacketLoss());
- }
- }
- function NetGraph::toggleKey()
- {
- if(!GhostsActive.visible)
- {
- GhostsActive.visible = 1;
- GhostUpdates.visible = 1;
- BitsSent.visible = 1;
- BitsReceived.visible = 1;
- Latency.visible = 1;
- PacketLoss.visible = 1;
- }
- else
- {
- GhostsActive.visible = 0;
- GhostUpdates.visible = 0;
- BitsSent.visible = 0;
- BitsReceived.visible = 0;
- Latency.visible = 0;
- PacketLoss.visible = 0;
- }
- }
- function NetGraphSimLatency::onReturn(%this)
- {
- NetGraph.updateNetworkSimulation();
- }
- function NetGraphSimPacket::onReturn(%this)
- {
- NetGraph.updateNetworkSimulation();
- }
- function NetGraph::updateNetworkSimulation(%this)
- {
- %latency = NetGraphSimLatency.getText();
-
- if(%latency $= "" || %latency < 0)
- {
- NetGraphSimLatency.text = 0;
- %latency = 0;
- }
-
- %packetLoss = NetGraphSimPacket.getText();
-
- if(%packetLoss $= "" || %packetLoss < 0)
- {
- NetGraphSimLatency.text = 0;
- %packetLoss = 0;
- }
- else if(%packetLoss > 100)
- {
- NetGraphSimPacket.text = 100;
- %packetLoss = 100;
- }
-
- netSimulateLag( %latency, %packetLoss );
- }
|