Discovery Gaming Community
DSAM - StatisticsGenerator.cs - Printable Version

+- Discovery Gaming Community (https://discoverygc.com/forums)
+-- Forum: Discovery Development (https://discoverygc.com/forums/forumdisplay.php?fid=7)
+--- Forum: Discovery Mod General Discussion (https://discoverygc.com/forums/forumdisplay.php?fid=37)
+--- Thread: DSAM - StatisticsGenerator.cs (/showthread.php?tid=109768)



DSAM - StatisticsGenerator.cs - Cortexian - 01-05-2014

Hey all, I'm a web developer and I didn't like the style of the DSAM Statistics file so I've gone ahead and attempted to update the StatisticsGenerator.cs file without any prior knowledge of c# or Visual Studio.

When I say I'm a web developer, I literally just mean the web-side of things! Forgive me if there are any errors here.

First things first, the raw HTML that I updated. I borrowed heavily from the FLstat theme, and combined it with the default background image and theme from a couple of the vanilla Freelancer apps (direct ip and mp key recovery tools). They come together really well, and I'm using the same theme for all of my FLstat files now as well.

Code:
<html>
<head>
<title>Players Online</title>
<style type=text/css>
TR {
  background-color: #DDDDFF;
}

TR.footer {
  background-color: #BBBBFF;
}

TH {
  background-color: navy;
  color: white;
  font-family: sans-serif;
  font-size: x-small;
  font-weight: bold;
  padding-left: 4px;
  padding-right: 4px;
  padding-top: 2px;
  padding-bottom: 2px;
}

TD {
  font-family: sans-serif;
  font-size: x-small;
  padding-right: 4px;
  padding-left: 4px;
}

body {
    background-image:url('backgroundpattern.jpg');
    }

h1 {
    color:#87c3e0;
}
    
h3 {
    color:#87c3e0;
}
</style>
</head>
<body>
<h1 align="center">Players Online</h1><br>
<br>
<h3 align="center">Characters by Name</h3>
<table width="90%" border="0" align="center">
<tr>
<th align="left">Character</th>
<th align="left">System</th>
</tr>
<tr>
<td class="column0">player</td>
<td class="column1">system</td>
</tr>
<tr class="footer">
<td colspan="11" align="center"><i>- used slots: <strong>1</strong> - last update: <strong>1/5/2014 2:19:57 PM</strong> - Generated by <A HREF="http://forge.the-starport.net/projects/dsam/"><strong>DSAM</strong></A> -</i></TD>
</tr>
</table><br>
<br>
<h3 align="center">Characters by System</h3>
<table width="90%" border="0" align="center">
<tr>
<th align="left">Character</th>
<th align="left">System</th>
</tr>
<tr>
<td class="column0">player</td>
<td class="column1">system</td>
</tr>
<tr class="footer">
<td colspan="11" align="center"><i>- used slots: <strong>1</strong> - last update: <strong>1/5/2014 2:19:57 PM</strong> - Generated by <A HREF="http://forge.the-starport.net/projects/dsam/"><strong>DSAM</strong></A> -</i></TD>
</tr>
</table>

<br>
<br>
<i></i>
</body>
</html>

https://www.dropbox.com/s/xm73soqw9puy0yn/players_online.html.7z

Now I Have literally no experience converting this into a usable format in the actual StatisticsGenerator.cs file... But I'm going to dive in and see if I can get it working. How hard could it be? Wink

I'll be back with my attempt in a bit, but if someone (cannon?) could implement this properly, I might have a new hero!


RE: DSAM - StatisticsGenerator.cs - Cortexian - 01-06-2014

OK so here's my attempt at editing the HTML generation portion to use my code... No idea if it will work as I have no experience compiling stuff.

Code:
//*****   generate the html contents ...
            string contents = "<html><head><title>Players Online</title><style type=text/css>"; ;
            contents += "tr {background-color: #DDDDFF;}";
            contents += "tr.footer {background-color: #BBBBFF;}";
            contents += "th {background-color: navy; color: white; font-family: sans-serif; font-size: x-small; font-weight: bold;  padding-left: 4px;  padding-right: 4px; padding-top: 2px; padding-bottom: 2px;}";
            contents += "td {font-family: sans-serif; font-size: x-small; padding-right: 4px; padding-left: 4px;}";
            contents += "body {background-image:url('backgroundpattern.jpg');}";
            contents += "h1 {color:#87c3e0;}";
            contents += "h3 {color:#87c3e0;}";
            contents += "</style>";
            contents += "</head><body>";
            contents += "<h1 align=\"center\">Players Online</h1><br><br>";
            
            if (AppSettings.Default.setStatPlayerListShowCharsByName)
            {
                contents += "<h3 align=\"center\">Characters by Name</h3>";
                contents += "<table width=\"90%\" border=\"0\" align=\"center\">";
                contents += "<tr>";
                foreach (string field in playerlistFields)
                {
                    if (column0)
                        contents += "<th align=\"left\">";
                    else
                        contents += "<th align=\"left\">";
                    contents += field;
                    contents += "</th>";
                    column0 = !column0;
                }
                column0 = true;
                contents += "</tr>";
                foreach (KeyValuePair<string, FLHookSocket.PlayerInfo> kvp in char_list)
                {
                    contents += "<tr>";

                    foreach (string field in playerlistFields)
                    {
                        string toAdd = string.Empty;
                        switch (field)
                        {
                            case "Character": toAdd = kvp.Key; break;
                            case "System": toAdd = m_gameData.GetItemDescByNickNameX(kvp.Value.system); break;
                            case "ID": toAdd = kvp.Value.id.ToString(); break;
                            case "IP": toAdd = kvp.Value.ip.ToString(); break;
                            case "Ping": toAdd = kvp.Value.ping.ToString(); break;
                            case "Loss": toAdd = kvp.Value.loss.ToString(); break;
                            case "Fluct": toAdd = kvp.Value.ping_fluct.ToString(); break;
                            case "Saturation": toAdd = kvp.Value.saturation.ToString(); break;
                            case "TxQueue": toAdd = kvp.Value.txqueue.ToString(); break;
                            case "Lag": toAdd = kvp.Value.lag.ToString(); break;
                        }

                        //toAdd = HtmlEncode(toAdd);

                        contents += "<td class=\"column" + (column0 ? "0" : "1") + "\">";
                        contents += toAdd;
                        contents += "</td>";
                        column0 = !column0;
                    }

                    contents += "</tr>";
                    contents += "<tr class=\"footer\">";
                    
                    //*****   Totally winging it ...
                    contents += "<i>- used slots: <strong>" + String.Format("{0}", slots_in_use) + "</strong> ";
            if (AppSettings.Default.setStatPlayerListShowCharsByName)
            {
if (AppSettings.Default.setStatPlayerListTimeUTC)
                contents += "- last update: <strong>" + DateTime.UtcNow.ToString() + " [UTC]</strong> ";
            else
                contents += "- last update: <strong>" + DateTime.Now.ToString() + "</strong> ";
                
                contents += "- Generated by <a href=\"http://forge.the-starport.net/projects/dsam/\"><strong>DSAM</strong></a> -</i>";
                    //*****   Totally winging it ...
                
                contents += "</tr>";
                }
                contents += "</table><br><br>";
            }
            if (AppSettings.Default.setStatPlayerListShowCharsBySys)
            {
                contents += "<h3 align=\"center\">Characters by System</h3>";
                contents += "<table width=\"90%\" border=\"0\" align=\"center\">";
                contents += "<tr><th align=\"left\">Character</th><th align=\"left\">System</th></tr>";
                foreach (KeyValuePair<string, List<string>> kvp in system_list)
                {
                    kvp.Value.Sort();
                    foreach (string character in kvp.Value)
                    {
                        contents += "<tr><td class=\"column0\">" + character + "</td><td class=\"column1\">" + kvp.Key + "</td></tr>";
                    }
                }
                
                contents += "<tr class=\"footer\">";
                    
                    //*****   Totally winging it ...
                    contents += "<i>- used slots: <strong>" + String.Format("{0}", slots_in_use) + "</strong> ";
            if (AppSettings.Default.setStatPlayerListShowCharsByName)
            {
if (AppSettings.Default.setStatPlayerListTimeUTC)
                contents += "- last update: <strong>" + DateTime.UtcNow.ToString() + " [UTC]</strong> ";
            else
                contents += "- last update: <strong>" + DateTime.Now.ToString() + "</strong> ";
                
                contents += "- Generated by <a href=\"http://forge.the-starport.net/projects/dsam/\"><strong>DSAM</strong></a> -</i>";
                    //*****   Totally winging it ...
                
                contents += "</tr>";
                
                contents += "</table>";
            }
            contents += "</body></html>";

https://www.dropbox.com/s/5dmxc4grwtf4ztj/StatisticsGenerator.cs.7z

There are a couple of sections that I had to do some significant code alterations on. They're duplicates of each other and marked inside of the following comments:
//***** Totally winging it ...
stuff I made up...
//***** Totally winging it ...

So that stuff probably won't work at all, again, I have no C# knowledge. If someone more experience could try compiling this and fixing my inevitable mistakes that would be great!

Edit: So I download Visual Studio 2013 Windows Desktop, checked out the SVN, and popped my code into the project and recompiled. Went fine, but the html file being generated is still the same... What's going on?

Edit Edit: Tried a "Recompile" and it found an error on Line 219 Column 10 of StatisticsGenerator.cs. I have no idea how to fix it so hopefully one of the devs can complete what I've started here!


RE: DSAM - StatisticsGenerator.cs - utrack - 01-06-2014

What's at line 219?


RE: DSAM - StatisticsGenerator.cs - Cortexian - 01-06-2014

Just:

Code:
}

I never edited anything outside lines 91 - 203 though, so whatever the problem is, it probably starts in there!


RE: DSAM - StatisticsGenerator.cs - Cortexian - 01-06-2014

Alternatively, I'm curious to know how you guys are generating this page:
http://discoverygc.com/forums/serverinterface.php?action=players_online


RE: DSAM - StatisticsGenerator.cs - utrack - 01-07-2014

I'll check it out tomorrow, but it's very likely the closing bracket was lost somewhere.