Initial commit: TeslaSuite monorepo (TeslaConsole + TeslaLauncher)
Co-locate the two cockpit-pod projects into a single repository:
- Console/ : TeslaConsole, the net48 WinForms operator console (decompiled
reconstruction) plus its differential + catalog test suite.
- Launcher/ : TeslaLauncher, the net6 pod-side Service + Agent rewrite.
Adds a combined TeslaSuite.sln, root README documenting the shared wire
contract (and its current duplication, the main follow-up), and a root
.gitignore. Histories were not preserved per request; this is a fresh start
from the current working state of both projects.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@@ -0,0 +1,17 @@
|
||||
# Normalize line endings: detect text automatically
|
||||
* text=auto
|
||||
|
||||
# Source / project files are CRLF (Windows / Visual Studio)
|
||||
*.cs text eol=crlf
|
||||
*.csproj text eol=crlf
|
||||
*.sln text eol=crlf
|
||||
*.xml text eol=crlf
|
||||
*.resx text eol=crlf
|
||||
*.md text eol=crlf
|
||||
|
||||
# Binary assets — never normalize, never diff as text
|
||||
*.dll binary
|
||||
*.exe binary
|
||||
*.ico binary
|
||||
*.bmp binary
|
||||
*.InstallState binary
|
||||
@@ -0,0 +1,11 @@
|
||||
# Build output
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# IDE / OS
|
||||
.vs/
|
||||
.vscode/
|
||||
.idea/
|
||||
*.user
|
||||
Thumbs.db
|
||||
.DS_Store
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[assembly: AssemblyCompany("Virtual World Entertainment")]
|
||||
[assembly: AssemblyProduct("Tesla Console")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2009")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: Guid("581ca4b6-a91c-4d24-b9b5-207f3b5da379")]
|
||||
[assembly: AssemblyFileVersion("4.11.3.0")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: AssemblyTitle("Tesla Console")]
|
||||
[assembly: AssemblyDescription("All code and UI property of Virtual World Entertainment.\r\n\r\nDeveloped by Elsewhen Studios, LLC in association with VGCorps, LLC.\r\n\r\nElsewhen Studios and the Elsewhen Wormhole are trademarks of Elsewhen Studios, LLC\r\n\r\nIncludes the WeifenLuo DockingPane library. Copyright © 2007 Weifen Luo (email: weifenluo@yahoo.com). Licensed under the MIT License - details can be found in WeifenLuo.txt included in this installation.")]
|
||||
[assembly: AssemblyVersion("4.11.3.37076")]
|
||||
@@ -0,0 +1,83 @@
|
||||
# TeslaConsole
|
||||
|
||||
Reconstructed C# source for the original **TeslaConsole.exe** — the operator
|
||||
console that drives the cockpit pods (the counterpart to `TeslaLauncherService`
|
||||
/ `TeslaLauncherAgent`).
|
||||
|
||||
## Provenance
|
||||
|
||||
This source was recovered by decompiling the original managed assembly with
|
||||
[ILSpy](https://github.com/icsharpcode/ILSpy) (`ilspycmd` 7.2). The original
|
||||
`TeslaConsole.exe` is a **.NET Framework 2.0** WinForms application
|
||||
(`assets/Tesla Console/TeslaConsole.exe`, dated 2012). The reconstructed project
|
||||
here is retargeted to **.NET Framework 4.8** so it builds with current tooling;
|
||||
it is otherwise a faithful decompilation, not a rewrite.
|
||||
|
||||
> Decompiled code is functionally equivalent to the original but not
|
||||
> character-for-character identical to the lost sources. Local variable names,
|
||||
> some control flow, and compiler-generated members differ. Treat this as a
|
||||
> recovered baseline, not pristine source.
|
||||
|
||||
## Dependencies
|
||||
|
||||
The console references five assemblies, vendored as binaries under `lib/`
|
||||
(copied from `assets/Tesla Console/`):
|
||||
|
||||
| Assembly | Origin |
|
||||
|----------|--------|
|
||||
| `WeifenLuo.WinFormsUI.Docking.dll` | Third-party docking UI (open source, see `assets/Tesla Console/WeifenLuo.txt`) |
|
||||
| `TeslaConsoleLaunchLib.dll` | Wire types / launch protocol (proprietary) |
|
||||
| `TeslaSecureConfiguration.dll` | First-boot secure config protocol (proprietary) |
|
||||
| `Munga Net.dll` | Networking helpers (proprietary) |
|
||||
| `BitmapLibrary.dll` | Plasma-display bitmap rendering (proprietary) |
|
||||
|
||||
These are still referenced as compiled binaries. They are also .NET 2.0 managed
|
||||
assemblies and could be decompiled to source later if full-source builds are
|
||||
needed.
|
||||
|
||||
## Layout
|
||||
|
||||
This folder is **self-contained** — it can be lifted out into its own repository
|
||||
and still build and run.
|
||||
|
||||
```
|
||||
TeslaConsole/
|
||||
*.cs, TeslaConsole.*/ decompiled source (by namespace)
|
||||
*.resx, app.ico embedded resources + icon
|
||||
TeslaConsole.csproj net48 project
|
||||
RedPlanet/ runtime content (RPConfig.xml, RPStrings.xml) — copied to output
|
||||
images/ source art (pod art / maps / vehicles) — reference only
|
||||
installer_banner.bmp installer artwork — reference only
|
||||
lib/ referenced binaries + WeifenLuo license
|
||||
original/ original TeslaConsole.exe + .InstallState — reference baseline
|
||||
```
|
||||
|
||||
## Building
|
||||
|
||||
Requirements: .NET SDK (6.0+) — the `Microsoft.NETFramework.ReferenceAssemblies`
|
||||
NuGet package supplies the net48 reference assemblies, so a standalone Framework
|
||||
targeting pack is **not** required.
|
||||
|
||||
```
|
||||
dotnet build TeslaConsole.csproj -c Release
|
||||
```
|
||||
|
||||
Output: `bin/Release/net48/TeslaConsole.exe` (with `RedPlanet/` and all
|
||||
dependency DLLs copied alongside it).
|
||||
|
||||
## Runtime content
|
||||
|
||||
- `RedPlanet\RPConfig.xml`, `RedPlanet\RPStrings.xml` are loaded relative to the
|
||||
exe and are copied to the build output automatically.
|
||||
- `Plasma Images\*.bmp` (under `%ProgramData%`) is an **optional** override set;
|
||||
when absent the console renders plasma-display text procedurally, so it is not
|
||||
required to build or run.
|
||||
|
||||
## Notes
|
||||
|
||||
- The `.resx` resources embed BinaryFormatter-serialized bitmaps. The project
|
||||
sets `GenerateResourceUsePreserializedResources` and references
|
||||
`System.Resources.Extensions` so these build under the modern SDK.
|
||||
- Namespaces: `TeslaConsole` (UI + pod management), `TeslaConsole.RedPlanet`
|
||||
(the Red Planet game scenario/mission model), `TeslaConsole.Properties`
|
||||
(settings + resources).
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Tesla Console product catalog.
|
||||
|
||||
This file is the single source of truth for installable products and the
|
||||
launch entries each one registers on a pod. It replaces the products that
|
||||
were previously hardcoded in SiteManagement.cs.
|
||||
|
||||
Element/attribute reference:
|
||||
<Product id = install/product key (Guid) used while transferring the package
|
||||
name = friendly product name (used in menu + status text)
|
||||
menuText = exact text shown in the Install Product submenu
|
||||
hostTypeDialog = "true" to prompt for resolution + roles
|
||||
(Game Client / Live Camera / Mission Review),
|
||||
"false" to register all launch entries as-is>
|
||||
<Launch key = launch entry Guid registered on the pod (LaunchData.LaunchKey)
|
||||
displayName = name shown in the pod's app list
|
||||
exe = absolute path to the executable on the pod
|
||||
args = command-line arguments; "{res}" expands to " -res W H"
|
||||
when a custom resolution was chosen, otherwise to ""
|
||||
workingDirectory = optional; defaults to the directory of exe
|
||||
autoRestart = "true"/"false"
|
||||
hostType = GameClient | LiveCamera | MissionReview | None
|
||||
(only meaningful when hostTypeDialog="true"; an entry
|
||||
is registered only if its role was selected) />
|
||||
</Product>
|
||||
|
||||
To add a product, append a <Product> with one <Launch>. exe must live under
|
||||
the install directory the package extracts to (currently C:\Games\...).
|
||||
-->
|
||||
<AppCatalog>
|
||||
<Product id="7D241B1F-AB6D-4e08-9C20-12294E743D94"
|
||||
name="Red Planet 4.11"
|
||||
menuText="Red Planet 4.11..."
|
||||
hostTypeDialog="true">
|
||||
<Launch key="7D241B1F-AB6D-4e08-9C20-12294E743D94"
|
||||
displayName="Red Planet 4.11"
|
||||
exe="C:\Games\RP411\rpl4opt.exe"
|
||||
args="-net 1501{res}"
|
||||
autoRestart="true"
|
||||
hostType="GameClient" />
|
||||
<Launch key="57A0B3C2-D5CF-46d6-ABED-A8F4A26AB086"
|
||||
displayName="Red Planet 4.11 LC"
|
||||
exe="C:\Games\RP411\rpl4opt.exe"
|
||||
args="-net 1501{res} -lc"
|
||||
autoRestart="true"
|
||||
hostType="LiveCamera" />
|
||||
<Launch key="8F71D5C2-38E4-413c-8E22-88CAD08774D2"
|
||||
displayName="Red Planet 4.11 MR"
|
||||
exe="C:\Games\RP411\rpl4opt.exe"
|
||||
args="-net 1501{res} -mr"
|
||||
autoRestart="true"
|
||||
hostType="MissionReview" />
|
||||
</Product>
|
||||
|
||||
<Product id="CC8500ED-A653-45a7-BEF8-C332D30371A6"
|
||||
name="BattleTech Firestorm"
|
||||
menuText="BattleTech Firestorm..."
|
||||
hostTypeDialog="false">
|
||||
<Launch key="CC8500ED-A653-45a7-BEF8-C332D30371A6"
|
||||
displayName="BattleTech Firestorm"
|
||||
exe="C:\Games\MW4\launcher.exe"
|
||||
args=""
|
||||
autoRestart="true"
|
||||
hostType="None" />
|
||||
</Product>
|
||||
|
||||
<Product id="8EE93A6C-F16A-49be-B867-37FAE9087FFF"
|
||||
name="BattleTech Firestorm LC"
|
||||
menuText="BattleTech Firestorm LC..."
|
||||
hostTypeDialog="false">
|
||||
<Launch key="8EE93A6C-F16A-49be-B867-37FAE9087FFF"
|
||||
displayName="BattleTech Firestorm LC"
|
||||
exe="C:\Games\MW4\launcher.exe"
|
||||
args=""
|
||||
autoRestart="true"
|
||||
hostType="None" />
|
||||
</Product>
|
||||
</AppCatalog>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<RedPlanet>
|
||||
<race name="Martian Death Race">
|
||||
<invalid type="map" key="headmf" />
|
||||
|
||||
<color key="Red" name="Red" />
|
||||
<color key="Blue" name="Blue" />
|
||||
<color key="Green" name="Green" />
|
||||
<color key="White" name="White" />
|
||||
<color key="Pink" name="Pink" />
|
||||
<color key="Aqua" name="Aqua" />
|
||||
<color key="Yellow" name="Yellow" />
|
||||
<color key="Purple" name="Purple" />
|
||||
<color key="Black" name="Black" />
|
||||
|
||||
<badge key="None" name="None" />
|
||||
<badge key="Celtic" name="Celtic" />
|
||||
<badge key="Desert" name="Desert" />
|
||||
<badge key="Flames" name="Flames" />
|
||||
<badge key="Giraffe" name="Giraffe" />
|
||||
<badge key="Hawaii" name="Hawaii" />
|
||||
<badge key="Korean" name="Korean Camo" />
|
||||
<badge key="Lightning" name="Lightning" />
|
||||
<badge key="Razzle Dazzle" name="Razzle Dazzle" />
|
||||
<badge key="Rising Sun" name="Rising Sun" />
|
||||
<badge key="Tiger Stripe" name="Tiger Stripes" />
|
||||
</race>
|
||||
|
||||
<football name="Martian Football">
|
||||
<invalid type="map" key="pain" />
|
||||
<invalid type="map" key="headoff" />
|
||||
|
||||
<team key="Red/Pink" name="Red/Pink" runnerColor="Pink" teamColor="Red" />
|
||||
<team key="Blue/Aqua" name="Blue/Aqua" runnerColor="Aqua" teamColor="Blue" />
|
||||
<team key="Green/Yellow" name="Green/Yellow" runnerColor="Yellow" teamColor="Green" />
|
||||
<team key="Black/Purple" name="Black/Purple" runnerColor="Purple" teamColor="Black" />
|
||||
|
||||
<position key="crusher" name="Crusher" />
|
||||
<position key="blocker" name="Blocker" />
|
||||
<position key="runner" name="Runner" />
|
||||
</football>
|
||||
|
||||
<map key="wise" name="Wiseguy's Wake" image="images/red planet maps/Wiseguy's Wake.bmp" />
|
||||
<map key="lyzlane" name="Lyz's Lane" image="images/red planet maps/Lyz's Lane.bmp" />
|
||||
<map key="yip" name="Yip's Yahoorama" image="images/red planet maps/Yip's Yahoorama.bmp" />
|
||||
<map key="blade" name="Blade's Edge" image="images/red planet maps/Blade's Edge.bmp" />
|
||||
<map key="otto" name="Berserker's Bahnzai" image="images/red planet maps/Berserker's Bahnzai.bmp" />
|
||||
<map key="frstrm" name="Firestorm's Fury" image="images/red planet maps/Firestorm's Fury.bmp" />
|
||||
<map key="burnt" name="Burnt Cookies" image="images/red planet maps/Burnt Cookies.bmp" />
|
||||
<map key="brewers" name="Brewer's Bane" image="images/red planet maps/Brewer's Bane.bmp" />
|
||||
<map key="pain" name="Paingod's Passage" image="images/red planet maps/Pain God's Passage.bmp" />
|
||||
<map key="headoff" name="Freezemoon's Freeway" />
|
||||
<map key="headmf" name="Freezemoon's Freeway" />
|
||||
|
||||
<vehicle key="quark" name="Quark" image="images/red planet vehicles/Quark.bmp" />
|
||||
<vehicle key="lepton" name="Lepton" image="images/red planet vehicles/Quark.bmp" />
|
||||
<vehicle key="proton" name="Proton" image="images/red planet vehicles/Quark.bmp" />
|
||||
|
||||
<vehicle key="bug" name="Bug" image="images/red planet vehicles/Bug.bmp" />
|
||||
<vehicle key="speck" name="Speck" image="images/red planet vehicles/Bug.bmp" />
|
||||
<vehicle key="blkspk" name="Black Speck" image="images/red planet vehicles/Bug.bmp" />
|
||||
|
||||
<vehicle key="chigger" name="Chigger" image="images/red planet vehicles/Skeeter.bmp" />
|
||||
<vehicle key="flea" name="Flea" image="images/red planet vehicles/Skeeter.bmp" />
|
||||
<vehicle key="roach" name="Roach" image="images/red planet vehicles/Skeeter.bmp" />
|
||||
<vehicle key="skeeter" name="Skeeter" image="images/red planet vehicles/Skeeter.bmp" />
|
||||
<vehicle key="wasp" name="Wasp" image="images/red planet vehicles/Skeeter.bmp" />
|
||||
|
||||
<vehicle key="barge" name="Barge" image="images/red planet vehicles/Mule.bmp" />
|
||||
<vehicle key="broccoli" name="Screaming Broccoli" image="images/red planet vehicles/Mule.bmp" />
|
||||
<vehicle key="burro" name="Burro" image="images/red planet vehicles/Mule.bmp" />
|
||||
<vehicle key="mule" name="Mule" image="images/red planet vehicles/Mule.bmp" />
|
||||
|
||||
<vehicle key="bttlbrg" name="Battle Barge" image="images/red planet vehicles/Vole.bmp" />
|
||||
<vehicle key="gator" name="Gator" image="images/red planet vehicles/Vole.bmp" />
|
||||
<vehicle key="grunt" name="Grunt" image="images/red planet vehicles/Vole.bmp" />
|
||||
<vehicle key="vole" name="Vole" image="images/red planet vehicles/Vole.bmp" />
|
||||
|
||||
<vehicle key="bull" name="Bull" image="images/red planet vehicles/Bull.bmp" />
|
||||
<vehicle key="tarntula" name="Tarantula" image="images/red planet vehicles/Bull.bmp" />
|
||||
<!--<vehicle key="blktran" name="Black Tarantula" image="images/red planet vehicles/Bull.bmp" />-->
|
||||
|
||||
<vehicle key="mantis" name="Mantis" image="images/red planet vehicles/Roadblock.bmp" />
|
||||
<vehicle key="ripper" name="Ripper" image="images/red planet vehicles/Roadblock.bmp" />
|
||||
<vehicle key="roadblk" name="Road Block" image="images/red planet vehicles/Roadblock.bmp" />
|
||||
<vehicle key="spitter" name="Spitter" image="images/red planet vehicles/Roadblock.bmp" />
|
||||
|
||||
<vehicle key="puck" name="Armadillo" image="images/red planet vehicles/Armadillo.bmp" />
|
||||
|
||||
<vehicle key="dragon" name="Dragon" image="images/red planet vehicles/Police.bmp" />
|
||||
|
||||
<time key="day" name="Day" />
|
||||
<time key="night" name="Night" />
|
||||
|
||||
<weather key="clear" name="Clear" />
|
||||
<weather key="fog" name="Light Fog" />
|
||||
<weather key="soup" name="Heavy Fog" />
|
||||
</RedPlanet>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<RPStrings>
|
||||
<FirstScore>{time} - First into the score zone is {player}!</FirstScore>
|
||||
|
||||
<FirstBoost>{player} gets off to a roaring start as the first booster of the mission is ignited.</FirstBoost>
|
||||
|
||||
<FirstDeath>It is a sorry state of affairs when {player} is the first to trash their {vehicle}.</FirstDeath>
|
||||
|
||||
<FirstKill>High glory goes to {player} as the first kill of the mission is delivered unto {damager}!</FirstKill>
|
||||
|
||||
<ShortestLap>The crowd is on their feet as {player} brings in the shortest lap of {lap_time} of the mission!</ShortestLap>
|
||||
|
||||
<LightDamage>{time} - Sparks fly as {damager} lightly damages {player}'s vehicle.</LightDamage>
|
||||
<LightDamage>{time} - {damager} implements a light impact against {player}.</LightDamage>
|
||||
<LightDamage>{damager} provides a light spanking to {player}'s vehicle.</LightDamage>
|
||||
<LightDamage>{player} laughs defiantly as {damager} can only deliver light damage to {player}'s vehicle.</LightDamage>
|
||||
|
||||
<ModerateDamage>{time} - Sparks fly as {damager} moderately damages {player}'s vehicle.</ModerateDamage>
|
||||
<ModerateDamage>{player} still has a chance as {damager} delivers a moderate blow to {player}'s vehicle.</ModerateDamage>
|
||||
<ModerateDamage>{damager} provides a moderate spanking to {player}'s vehicle.</ModerateDamage>
|
||||
<ModerateDamage>{time} - {damager} implements a moderate impact against {player}.</ModerateDamage>
|
||||
|
||||
<HeavyDamage>{time} - Sparks fly as {damager} heavily damages {player}'s vehicle.</HeavyDamage>
|
||||
<HeavyDamage>{player} lets out a sob of disgust as {damager} nearly dismembers {player}'s vehicle.</HeavyDamage>
|
||||
<HeavyDamage>{damager} provides a heavy handed spanking to {player}'s vehicle.</HeavyDamage>
|
||||
<HeavyDamage>{time} - {damager} implements a heavy impact against {player}.</HeavyDamage>
|
||||
|
||||
<Kill>{time} - {damager} delivers righteous kill to {player}.</Kill>
|
||||
<Kill>{damager} rules as sheer death panic is brought down upon {player}.</Kill>
|
||||
<Kill>{time} - {damager} delivers peace, love, rest to {player}.</Kill>
|
||||
<Kill>The burning wreckage of {player}'s vehicle twists in the Martian wind as {damager} smiles joyously.</Kill>
|
||||
|
||||
<SelfKill>Tragedy strikes {player}'s {vehicle} as the clumsy pilot ejects to safety.</SelfKill>
|
||||
<SelfKill>{time} - Smoke roils from the {vehicle} as {player} learns a hard piloting lesson.</SelfKill>
|
||||
<SelfKill>{player} destroys the {vehicle} and bails out.</SelfKill>
|
||||
<SelfKill>{time} - {player} takes a risk which ends with the {vehicle} in flames.</SelfKill>
|
||||
|
||||
<Score>{time} - {player}'s ears are still ringing from the score zone buzzer.</Score>
|
||||
<Score>{time} - {player} maneuvers into the score zone.</Score>
|
||||
<Score>{time} - {player} scores!</Score>
|
||||
<Score>{time} - {player} adds another notch, entering the score zone.</Score>
|
||||
|
||||
<Boost>{time} - A righteous booster is deployed by {player}.</Boost>
|
||||
<Boost>{player}'s {vehicle} shows awesome booster power.</Boost>
|
||||
<Boost>{time} - {player} is not babysitting on a booster.</Boost>
|
||||
<Boost>{time} - {player}'s {vehicle} is cruising on a full booster thrust.</Boost>
|
||||
|
||||
<Recap>...and at the end of the mission it's: {winners} followed by {looser}.</Recap>
|
||||
</RPStrings>
|
||||
@@ -0,0 +1,306 @@
|
||||
using System.CodeDom.Compiler;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace TeslaConsole.Properties;
|
||||
|
||||
[DebuggerNonUserCode]
|
||||
[CompilerGenerated]
|
||||
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
|
||||
internal class Resources
|
||||
{
|
||||
private static ResourceManager resourceMan;
|
||||
|
||||
private static CultureInfo resourceCulture;
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if (object.ReferenceEquals(resourceMan, null))
|
||||
{
|
||||
ResourceManager resourceManager = (resourceMan = new ResourceManager("TeslaConsole.Properties.Resources", typeof(Resources).Assembly));
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
[EditorBrowsable(EditorBrowsableState.Advanced)]
|
||||
internal static CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap Add
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Add", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap Blank
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Blank", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap DeleteHS
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("DeleteHS", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap Error
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Error", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string ErrorReportsDir => ResourceManager.GetString("ErrorReportsDir", resourceCulture);
|
||||
|
||||
internal static Bitmap install
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("install", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap openHS
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("openHS", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap Play
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Play", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodBad16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodBad16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodBad32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodBad32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodBadImageKey => ResourceManager.GetString("PodBadImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap PodGo16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodGo16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodGo32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodGo32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodGoImageKey => ResourceManager.GetString("PodGoImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap PodOffline16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodOffline16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodOffline32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodOffline32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodOfflineImageKey => ResourceManager.GetString("PodOfflineImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap PodOfflineQuestion32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodOfflineQuestion32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodOnline16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodOnline16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodOnline32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodOnline32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodOnlineImageKey => ResourceManager.GetString("PodOnlineImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap PodQuestion16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodQuestion16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodQuestion32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodQuestion32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodQuestionImageKey => ResourceManager.GetString("PodQuestionImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap PodRun16
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodRun16", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap PodRun32
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("PodRun32", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static string PodRunImageKey => ResourceManager.GetString("PodRunImageKey", resourceCulture);
|
||||
|
||||
internal static Bitmap Power
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Power", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap RefreshDoc
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("RefreshDoc", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap saveHS
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("saveHS", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap square_throbber
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("square_throbber", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap Stop
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("Stop", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Icon swirl
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("swirl", resourceCulture);
|
||||
return (Icon)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal static Bitmap WebRefreshHH
|
||||
{
|
||||
get
|
||||
{
|
||||
object @object = ResourceManager.GetObject("WebRefreshHH", resourceCulture);
|
||||
return (Bitmap)@object;
|
||||
}
|
||||
}
|
||||
|
||||
internal Resources()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Configuration;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace TeslaConsole.Properties;
|
||||
|
||||
[CompilerGenerated]
|
||||
[GeneratedCode("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
|
||||
internal sealed class Settings : ApplicationSettingsBase
|
||||
{
|
||||
private static Settings defaultInstance = (Settings)SettingsBase.Synchronized(new Settings());
|
||||
|
||||
public static Settings Default => defaultInstance;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class BoostEvent : MissionEvent
|
||||
{
|
||||
public readonly int BoosterOn;
|
||||
|
||||
public override IEnumerable<RPPlayer> InvolvedPilots => new RPPlayer[1] { ReportingPilot };
|
||||
|
||||
public BoostEvent(RPPlayer reportingPilot, TimeSpan missionTime, int boosterOn)
|
||||
: base(reportingPilot, missionTime)
|
||||
{
|
||||
BoosterOn = boosterOn;
|
||||
}
|
||||
|
||||
private BoostEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class DamagedEvent : MissionEvent
|
||||
{
|
||||
public readonly RPPlayer Damager;
|
||||
|
||||
public readonly int DamageLoss;
|
||||
|
||||
public readonly int PointsTransfered;
|
||||
|
||||
public override IEnumerable<RPPlayer> InvolvedPilots => new RPPlayer[2] { ReportingPilot, Damager };
|
||||
|
||||
public DamagedEvent(RPPlayer reportingPilot, TimeSpan missionTime, RPPlayer damager, int damageLoss, int pointsTransfered)
|
||||
: base(reportingPilot, missionTime)
|
||||
{
|
||||
Damager = damager;
|
||||
DamageLoss = damageLoss;
|
||||
PointsTransfered = pointsTransfered;
|
||||
}
|
||||
|
||||
private DamagedEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class DeathRaceScenario : Scenario
|
||||
{
|
||||
private Dictionary<string, string> mColors = new Dictionary<string, string>();
|
||||
|
||||
private Dictionary<string, string> mBadges = new Dictionary<string, string>();
|
||||
|
||||
public Dictionary<string, string> Colors => mColors;
|
||||
|
||||
public Dictionary<string, string> Badges => mBadges;
|
||||
|
||||
internal DeathRaceScenario(XmlNode scenarioNode)
|
||||
: base(scenarioNode)
|
||||
{
|
||||
foreach (XmlNode childNode in scenarioNode.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "color":
|
||||
RPConfig.AddKeyNameNode(childNode, mColors);
|
||||
break;
|
||||
case "badge":
|
||||
RPConfig.AddKeyNameNode(childNode, mBadges);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class FootballScenario : Scenario
|
||||
{
|
||||
private Dictionary<string, RPTeam> mTeams = new Dictionary<string, RPTeam>();
|
||||
|
||||
private Dictionary<string, string> mPositions = new Dictionary<string, string>();
|
||||
|
||||
public Dictionary<string, RPTeam> Teams => mTeams;
|
||||
|
||||
public Dictionary<string, string> Positions => mPositions;
|
||||
|
||||
internal FootballScenario(XmlNode scenarioNode)
|
||||
: base(scenarioNode)
|
||||
{
|
||||
foreach (XmlNode childNode in scenarioNode.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "position":
|
||||
RPConfig.AddKeyNameNode(childNode, mPositions);
|
||||
break;
|
||||
case "team":
|
||||
{
|
||||
RPTeam rPTeam = new RPTeam(childNode);
|
||||
mTeams.Add(rPTeam.Key, rPTeam);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class KilledEvent : MissionEvent
|
||||
{
|
||||
public readonly RPPlayer Killer;
|
||||
|
||||
public override IEnumerable<RPPlayer> InvolvedPilots => new RPPlayer[2] { ReportingPilot, Killer };
|
||||
|
||||
public KilledEvent(RPPlayer reportingPilot, TimeSpan missionTime, RPPlayer killer)
|
||||
: base(reportingPilot, missionTime)
|
||||
{
|
||||
Killer = killer;
|
||||
}
|
||||
|
||||
private KilledEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal abstract class MissionEvent
|
||||
{
|
||||
public readonly TimeSpan GameTime;
|
||||
|
||||
public readonly RPPlayer ReportingPilot;
|
||||
|
||||
public abstract IEnumerable<RPPlayer> InvolvedPilots { get; }
|
||||
|
||||
public MissionEvent(RPPlayer reportingPilot, TimeSpan missionTime)
|
||||
{
|
||||
ReportingPilot = reportingPilot;
|
||||
GameTime = missionTime;
|
||||
}
|
||||
|
||||
protected MissionEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPCamera : RPParticipant
|
||||
{
|
||||
public RPCamera(string podHostAddress, HostType hostType)
|
||||
: base(podHostAddress, hostType)
|
||||
{
|
||||
if (hostType != HostType.MissionReviewHostType)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("hostType");
|
||||
}
|
||||
}
|
||||
|
||||
protected sealed override void AppendParticipantSpecificData(int index, StringBuilder sb)
|
||||
{
|
||||
sb.Append("dropzone=one\n");
|
||||
sb.Append("name=Camera\n");
|
||||
sb.Append("loadzones=0\n");
|
||||
sb.Append("vehicle=camera\n");
|
||||
sb.Append("color=Black\n");
|
||||
sb.Append("badge=None\n");
|
||||
sb.Append("team=Camera\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public static class RPConfig
|
||||
{
|
||||
private static readonly DeathRaceScenario mRace;
|
||||
|
||||
private static readonly FootballScenario mFootball;
|
||||
|
||||
private static readonly Dictionary<string, RPMap> mMaps;
|
||||
|
||||
private static readonly Dictionary<string, RPVehicle> mVehicles;
|
||||
|
||||
private static readonly Dictionary<string, string> mTimesOfDay;
|
||||
|
||||
private static readonly Dictionary<string, string> mWeather;
|
||||
|
||||
public static DeathRaceScenario DeathRace => mRace;
|
||||
|
||||
public static FootballScenario Football => mFootball;
|
||||
|
||||
public static Dictionary<string, RPMap> Maps => mMaps;
|
||||
|
||||
public static Dictionary<string, RPVehicle> Vehicles => mVehicles;
|
||||
|
||||
public static Dictionary<string, string> TimesOfDay => mTimesOfDay;
|
||||
|
||||
public static Dictionary<string, string> Weather => mWeather;
|
||||
|
||||
static RPConfig()
|
||||
{
|
||||
mRace = null;
|
||||
mFootball = null;
|
||||
mMaps = new Dictionary<string, RPMap>();
|
||||
mVehicles = new Dictionary<string, RPVehicle>();
|
||||
mTimesOfDay = new Dictionary<string, string>();
|
||||
mWeather = new Dictionary<string, string>();
|
||||
XmlNode scenarioNode = null;
|
||||
XmlNode scenarioNode2 = null;
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RedPlanet\\RPConfig.xml"));
|
||||
foreach (XmlNode childNode in xmlDocument.DocumentElement.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "race":
|
||||
scenarioNode = childNode;
|
||||
break;
|
||||
case "football":
|
||||
scenarioNode2 = childNode;
|
||||
break;
|
||||
case "map":
|
||||
{
|
||||
RPMap rPMap = new RPMap(childNode);
|
||||
mMaps.Add(rPMap.Key, rPMap);
|
||||
break;
|
||||
}
|
||||
case "vehicle":
|
||||
{
|
||||
RPVehicle rPVehicle = new RPVehicle(childNode);
|
||||
mVehicles.Add(rPVehicle.Key, rPVehicle);
|
||||
break;
|
||||
}
|
||||
case "time":
|
||||
AddKeyNameNode(childNode, mTimesOfDay);
|
||||
break;
|
||||
case "weather":
|
||||
AddKeyNameNode(childNode, mWeather);
|
||||
break;
|
||||
}
|
||||
}
|
||||
mRace = new DeathRaceScenario(scenarioNode);
|
||||
mFootball = new FootballScenario(scenarioNode2);
|
||||
}
|
||||
|
||||
internal static void AddKeyNameNode(XmlNode node, Dictionary<string, string> list)
|
||||
{
|
||||
list.Add(node.Attributes["key"].InnerText, node.Attributes["name"].InnerText);
|
||||
}
|
||||
|
||||
public static string MapNameOrKey(string mapKey)
|
||||
{
|
||||
if (!mMaps.ContainsKey(mapKey))
|
||||
{
|
||||
return mapKey;
|
||||
}
|
||||
return mMaps[mapKey].Name;
|
||||
}
|
||||
|
||||
public static string VehicleNameOrKey(string vehicleKey)
|
||||
{
|
||||
if (!mVehicles.ContainsKey(vehicleKey))
|
||||
{
|
||||
return vehicleKey;
|
||||
}
|
||||
return mVehicles[vehicleKey].Name;
|
||||
}
|
||||
|
||||
public static string TimeOfDayNameOrKey(string timeOfDayKey)
|
||||
{
|
||||
if (!mTimesOfDay.ContainsKey(timeOfDayKey))
|
||||
{
|
||||
return timeOfDayKey;
|
||||
}
|
||||
return mTimesOfDay[timeOfDayKey];
|
||||
}
|
||||
|
||||
public static string WeatherNameOrKey(string weatherKey)
|
||||
{
|
||||
if (!mWeather.ContainsKey(weatherKey))
|
||||
{
|
||||
return weatherKey;
|
||||
}
|
||||
return mWeather[weatherKey];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,416 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
internal static class RPDefaults
|
||||
{
|
||||
public abstract class ScenarioDefaults
|
||||
{
|
||||
private bool mScoreCompression;
|
||||
|
||||
private TimeSpan mMissionLength = new TimeSpan(0, 10, 0);
|
||||
|
||||
private string mMapKey;
|
||||
|
||||
private string mVehicleKey;
|
||||
|
||||
private string mTimeOfDayKey;
|
||||
|
||||
private string mWeatherKey;
|
||||
|
||||
private int mLaunchDelay = 15;
|
||||
|
||||
public bool ScoreCompression
|
||||
{
|
||||
get
|
||||
{
|
||||
return mScoreCompression;
|
||||
}
|
||||
set
|
||||
{
|
||||
mScoreCompression = value;
|
||||
}
|
||||
}
|
||||
|
||||
public TimeSpan MissionLength
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMissionLength;
|
||||
}
|
||||
set
|
||||
{
|
||||
mMissionLength = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string MapKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMapKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mMapKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string VehicleKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mVehicleKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mVehicleKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string TimeOfDayKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mTimeOfDayKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mTimeOfDayKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string WeatherKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mWeatherKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mWeatherKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int LaunchDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
return mLaunchDelay;
|
||||
}
|
||||
set
|
||||
{
|
||||
mLaunchDelay = value;
|
||||
}
|
||||
}
|
||||
|
||||
public ScenarioDefaults()
|
||||
{
|
||||
}
|
||||
|
||||
public abstract void Save(XmlNode parrentNode);
|
||||
|
||||
protected void SaveCommonData(XmlNode scenarioNode)
|
||||
{
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("ScoreCompression")).InnerText = mScoreCompression.ToString();
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("MissionLength")).InnerText = mMissionLength.ToString();
|
||||
if (!string.IsNullOrEmpty(mMapKey))
|
||||
{
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("MapKey")).InnerText = mMapKey;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mVehicleKey))
|
||||
{
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("VehicleKey")).InnerText = mVehicleKey;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mTimeOfDayKey))
|
||||
{
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("TimeOfDayKey")).InnerText = mTimeOfDayKey;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mWeatherKey))
|
||||
{
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("WeatherKey")).InnerText = mWeatherKey;
|
||||
}
|
||||
scenarioNode.AppendChild(scenarioNode.OwnerDocument.CreateElement("LaunchDelay")).InnerText = mLaunchDelay.ToString();
|
||||
}
|
||||
|
||||
public abstract void Parse(XmlNode scenarioNode);
|
||||
|
||||
protected bool ParseCommonData(XmlNode node)
|
||||
{
|
||||
switch (node.Name)
|
||||
{
|
||||
case "ScoreCompression":
|
||||
{
|
||||
if (bool.TryParse(node.InnerText, out var result2))
|
||||
{
|
||||
mScoreCompression = result2;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "MissionLength":
|
||||
{
|
||||
if (TimeSpan.TryParse(node.InnerText, out var result3))
|
||||
{
|
||||
mMissionLength = result3;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "MapKey":
|
||||
if (!string.IsNullOrEmpty(node.InnerText))
|
||||
{
|
||||
mMapKey = node.InnerText;
|
||||
}
|
||||
return true;
|
||||
case "VehicleKey":
|
||||
if (!string.IsNullOrEmpty(node.InnerText))
|
||||
{
|
||||
mVehicleKey = node.InnerText;
|
||||
}
|
||||
return true;
|
||||
case "TimeOfDayKey":
|
||||
if (!string.IsNullOrEmpty(node.InnerText))
|
||||
{
|
||||
mTimeOfDayKey = node.InnerText;
|
||||
}
|
||||
return true;
|
||||
case "WeatherKey":
|
||||
if (!string.IsNullOrEmpty(node.InnerText))
|
||||
{
|
||||
mWeatherKey = node.InnerText;
|
||||
}
|
||||
return true;
|
||||
case "LaunchDelay":
|
||||
{
|
||||
if (int.TryParse(node.InnerText, out var result))
|
||||
{
|
||||
mLaunchDelay = result;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class DeathRaceDefaults : ScenarioDefaults
|
||||
{
|
||||
public const string DeathRaceNode = "DeathRaceDefaults";
|
||||
|
||||
private string mColorKey;
|
||||
|
||||
private string mBadgeKey;
|
||||
|
||||
public string ColorKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mColorKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mColorKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string BadgeKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mBadgeKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mBadgeKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Save(XmlNode parrentNode)
|
||||
{
|
||||
XmlNode xmlNode = parrentNode.AppendChild(parrentNode.OwnerDocument.CreateElement("DeathRaceDefaults"));
|
||||
SaveCommonData(xmlNode);
|
||||
if (!string.IsNullOrEmpty(mColorKey))
|
||||
{
|
||||
xmlNode.AppendChild(xmlNode.OwnerDocument.CreateElement("ColorKey")).InnerText = mColorKey;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mBadgeKey))
|
||||
{
|
||||
xmlNode.AppendChild(xmlNode.OwnerDocument.CreateElement("BadgeKey")).InnerText = mBadgeKey;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Parse(XmlNode scenarioNode)
|
||||
{
|
||||
foreach (XmlNode childNode in scenarioNode.ChildNodes)
|
||||
{
|
||||
if (ParseCommonData(childNode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "ColorKey":
|
||||
if (!string.IsNullOrEmpty(childNode.InnerText))
|
||||
{
|
||||
mColorKey = childNode.InnerText;
|
||||
}
|
||||
break;
|
||||
case "BadgeKey":
|
||||
if (!string.IsNullOrEmpty(childNode.InnerText))
|
||||
{
|
||||
mBadgeKey = childNode.InnerText;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class FootballDefaults : ScenarioDefaults
|
||||
{
|
||||
public const string FootballNode = "FootballDefaults";
|
||||
|
||||
private string mTeamKey;
|
||||
|
||||
private string mPositionKey;
|
||||
|
||||
public string TeamKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mTeamKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mTeamKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PositionKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return mPositionKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mPositionKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Save(XmlNode parrentNode)
|
||||
{
|
||||
XmlNode xmlNode = parrentNode.AppendChild(parrentNode.OwnerDocument.CreateElement("FootballDefaults"));
|
||||
SaveCommonData(xmlNode);
|
||||
if (!string.IsNullOrEmpty(mTeamKey))
|
||||
{
|
||||
xmlNode.AppendChild(xmlNode.OwnerDocument.CreateElement("TeamKey")).InnerText = mTeamKey;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(mPositionKey))
|
||||
{
|
||||
xmlNode.AppendChild(xmlNode.OwnerDocument.CreateElement("PositionKey")).InnerText = mPositionKey;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Parse(XmlNode scenarioNode)
|
||||
{
|
||||
foreach (XmlNode childNode in scenarioNode.ChildNodes)
|
||||
{
|
||||
if (ParseCommonData(childNode))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "TeamKey":
|
||||
if (!string.IsNullOrEmpty(childNode.InnerText))
|
||||
{
|
||||
mTeamKey = childNode.InnerText;
|
||||
}
|
||||
break;
|
||||
case "PositionKey":
|
||||
if (!string.IsNullOrEmpty(childNode.InnerText))
|
||||
{
|
||||
mPositionKey = childNode.InnerText;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string sDefaultsFilePath;
|
||||
|
||||
private static readonly DeathRaceDefaults sDeathRace;
|
||||
|
||||
private static readonly FootballDefaults sFootball;
|
||||
|
||||
public static DeathRaceDefaults DeathRace => sDeathRace;
|
||||
|
||||
public static FootballDefaults Football => sFootball;
|
||||
|
||||
static RPDefaults()
|
||||
{
|
||||
sDefaultsFilePath = Path.Combine(Program.GetCommonAppDataDirectory(), "RPDefaults.rpd");
|
||||
sDeathRace = new DeathRaceDefaults();
|
||||
sFootball = new FootballDefaults();
|
||||
if (File.Exists(sDefaultsFilePath))
|
||||
{
|
||||
try
|
||||
{
|
||||
Import(sDefaultsFilePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("The Red Planet defaults file appears to be corrupt. Please open the Red Planet Defaults Dialog and save to create a new defaults file.", "Error Loading Red Planet Defaults!", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Import(string fileName)
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(fileName);
|
||||
foreach (XmlNode childNode in xmlDocument.DocumentElement.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "DeathRaceDefaults":
|
||||
sDeathRace.Parse(childNode);
|
||||
break;
|
||||
case "FootballDefaults":
|
||||
sFootball.Parse(childNode);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Save()
|
||||
{
|
||||
try
|
||||
{
|
||||
Export(sDefaultsFilePath);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("The Red Planet defaults file could not be saved. These defaults will only be remembered until the application is closed.", "Error Saving Red Planet Defaults!", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Export(string filePath)
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.AppendChild(xmlDocument.CreateElement("RPDefaults"));
|
||||
sDeathRace.Save(xmlDocument.DocumentElement);
|
||||
sFootball.Save(xmlDocument.DocumentElement);
|
||||
string directoryName = Path.GetDirectoryName(filePath);
|
||||
if (!Directory.Exists(directoryName))
|
||||
{
|
||||
Directory.CreateDirectory(directoryName);
|
||||
}
|
||||
xmlDocument.Save(filePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,619 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TeslaConsole.Properties;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class RPDefaultsDialog : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private TableLayoutPanel mMainTable;
|
||||
|
||||
private Label label2;
|
||||
|
||||
private Label label3;
|
||||
|
||||
private Label label4;
|
||||
|
||||
private Label label5;
|
||||
|
||||
private Label label6;
|
||||
|
||||
private Label label7;
|
||||
|
||||
private Label label8;
|
||||
|
||||
private Label label9;
|
||||
|
||||
private Label label1;
|
||||
|
||||
private Label label10;
|
||||
|
||||
private ComboBox mDeathRaceScoreCompression;
|
||||
|
||||
private ComboBox mFootballScoreCompression;
|
||||
|
||||
private ComboBox mFootballPosition;
|
||||
|
||||
private ComboBox mDeathRaceBadge;
|
||||
|
||||
private ComboBox mFootballTeam;
|
||||
|
||||
private ComboBox mDeathRaceColor;
|
||||
|
||||
private ComboBox mFootballWeather;
|
||||
|
||||
private ComboBox mDeathRaceWeather;
|
||||
|
||||
private ComboBox mFootballTimeOfDay;
|
||||
|
||||
private ComboBox mDeathRaceTimeOfDay;
|
||||
|
||||
private ComboBox mDeathRaceMap;
|
||||
|
||||
private ComboBox mFootballMap;
|
||||
|
||||
private ComboBox mDeathRaceVehicle;
|
||||
|
||||
private ComboBox mFootballVehicle;
|
||||
|
||||
private TableLayoutPanel mButtonsTable;
|
||||
|
||||
private Button mCancel;
|
||||
|
||||
private Button mOK;
|
||||
|
||||
private MaskedTextBox mDeathRaceMissionLength;
|
||||
|
||||
private MaskedTextBox mFootballMissionLength;
|
||||
|
||||
private Label label11;
|
||||
|
||||
private NumericUpDown mDeathraceLaunchDelay;
|
||||
|
||||
private NumericUpDown mFootballLaunchDelay;
|
||||
|
||||
private static RPDefaultsDialog mSingletonDialog;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mMainTable = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.mFootballPosition = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceBadge = new System.Windows.Forms.ComboBox();
|
||||
this.mFootballTeam = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceColor = new System.Windows.Forms.ComboBox();
|
||||
this.label8 = new System.Windows.Forms.Label();
|
||||
this.label9 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.label10 = new System.Windows.Forms.Label();
|
||||
this.mButtonsTable = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.mCancel = new System.Windows.Forms.Button();
|
||||
this.mOK = new System.Windows.Forms.Button();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.mDeathRaceVehicle = new System.Windows.Forms.ComboBox();
|
||||
this.mFootballVehicle = new System.Windows.Forms.ComboBox();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.label7 = new System.Windows.Forms.Label();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label6 = new System.Windows.Forms.Label();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.mDeathRaceMap = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceTimeOfDay = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceScoreCompression = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceWeather = new System.Windows.Forms.ComboBox();
|
||||
this.mDeathRaceMissionLength = new System.Windows.Forms.MaskedTextBox();
|
||||
this.mFootballMap = new System.Windows.Forms.ComboBox();
|
||||
this.mFootballTimeOfDay = new System.Windows.Forms.ComboBox();
|
||||
this.mFootballScoreCompression = new System.Windows.Forms.ComboBox();
|
||||
this.mFootballMissionLength = new System.Windows.Forms.MaskedTextBox();
|
||||
this.mFootballWeather = new System.Windows.Forms.ComboBox();
|
||||
this.label11 = new System.Windows.Forms.Label();
|
||||
this.mDeathraceLaunchDelay = new System.Windows.Forms.NumericUpDown();
|
||||
this.mFootballLaunchDelay = new System.Windows.Forms.NumericUpDown();
|
||||
this.mMainTable.SuspendLayout();
|
||||
this.mButtonsTable.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)this.mDeathraceLaunchDelay).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)this.mFootballLaunchDelay).BeginInit();
|
||||
base.SuspendLayout();
|
||||
this.mMainTable.ColumnCount = 3;
|
||||
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
|
||||
this.mMainTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
|
||||
this.mMainTable.Controls.Add(this.mFootballLaunchDelay, 2, 9);
|
||||
this.mMainTable.Controls.Add(this.mFootballPosition, 2, 8);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceBadge, 1, 8);
|
||||
this.mMainTable.Controls.Add(this.mFootballTeam, 2, 7);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceColor, 1, 7);
|
||||
this.mMainTable.Controls.Add(this.label8, 0, 7);
|
||||
this.mMainTable.Controls.Add(this.label9, 0, 8);
|
||||
this.mMainTable.Controls.Add(this.label1, 1, 0);
|
||||
this.mMainTable.Controls.Add(this.label10, 2, 0);
|
||||
this.mMainTable.Controls.Add(this.mButtonsTable, 0, 10);
|
||||
this.mMainTable.Controls.Add(this.label5, 0, 6);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceVehicle, 1, 6);
|
||||
this.mMainTable.Controls.Add(this.mFootballVehicle, 2, 6);
|
||||
this.mMainTable.Controls.Add(this.label4, 0, 1);
|
||||
this.mMainTable.Controls.Add(this.label7, 0, 2);
|
||||
this.mMainTable.Controls.Add(this.label2, 0, 4);
|
||||
this.mMainTable.Controls.Add(this.label6, 0, 3);
|
||||
this.mMainTable.Controls.Add(this.label3, 0, 5);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceMap, 1, 1);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceTimeOfDay, 1, 3);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceScoreCompression, 1, 4);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceWeather, 1, 2);
|
||||
this.mMainTable.Controls.Add(this.mDeathRaceMissionLength, 1, 5);
|
||||
this.mMainTable.Controls.Add(this.mFootballMap, 2, 1);
|
||||
this.mMainTable.Controls.Add(this.mFootballTimeOfDay, 2, 3);
|
||||
this.mMainTable.Controls.Add(this.mFootballScoreCompression, 2, 4);
|
||||
this.mMainTable.Controls.Add(this.mFootballMissionLength, 2, 5);
|
||||
this.mMainTable.Controls.Add(this.mFootballWeather, 2, 2);
|
||||
this.mMainTable.Controls.Add(this.label11, 0, 9);
|
||||
this.mMainTable.Controls.Add(this.mDeathraceLaunchDelay, 1, 9);
|
||||
this.mMainTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mMainTable.Location = new System.Drawing.Point(3, 3);
|
||||
this.mMainTable.Name = "mMainTable";
|
||||
this.mMainTable.RowCount = 11;
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.mMainTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.mMainTable.Size = new System.Drawing.Size(478, 298);
|
||||
this.mMainTable.TabIndex = 0;
|
||||
this.mFootballPosition.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballPosition.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballPosition.FormattingEnabled = true;
|
||||
this.mFootballPosition.Location = new System.Drawing.Point(302, 204);
|
||||
this.mFootballPosition.Name = "mFootballPosition";
|
||||
this.mFootballPosition.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballPosition.TabIndex = 15;
|
||||
this.mDeathRaceBadge.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceBadge.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceBadge.FormattingEnabled = true;
|
||||
this.mDeathRaceBadge.Location = new System.Drawing.Point(123, 204);
|
||||
this.mDeathRaceBadge.Name = "mDeathRaceBadge";
|
||||
this.mDeathRaceBadge.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceBadge.TabIndex = 14;
|
||||
this.mFootballTeam.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballTeam.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballTeam.FormattingEnabled = true;
|
||||
this.mFootballTeam.Location = new System.Drawing.Point(302, 177);
|
||||
this.mFootballTeam.Name = "mFootballTeam";
|
||||
this.mFootballTeam.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballTeam.TabIndex = 13;
|
||||
this.mDeathRaceColor.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceColor.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceColor.FormattingEnabled = true;
|
||||
this.mDeathRaceColor.Location = new System.Drawing.Point(123, 177);
|
||||
this.mDeathRaceColor.Name = "mDeathRaceColor";
|
||||
this.mDeathRaceColor.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceColor.TabIndex = 12;
|
||||
this.label8.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label8.AutoSize = true;
|
||||
this.label8.Location = new System.Drawing.Point(51, 181);
|
||||
this.label8.Name = "label8";
|
||||
this.label8.Size = new System.Drawing.Size(66, 13);
|
||||
this.label8.TabIndex = 7;
|
||||
this.label8.Text = "Color/Team:";
|
||||
this.label9.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label9.AutoSize = true;
|
||||
this.label9.Location = new System.Drawing.Point(34, 208);
|
||||
this.label9.Name = "label9";
|
||||
this.label9.Size = new System.Drawing.Size(83, 13);
|
||||
this.label9.TabIndex = 8;
|
||||
this.label9.Text = "Badge/Position:";
|
||||
this.label1.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(177, 0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(65, 13);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Death Race";
|
||||
this.label10.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.label10.AutoSize = true;
|
||||
this.label10.Location = new System.Drawing.Point(366, 0);
|
||||
this.label10.Name = "label10";
|
||||
this.label10.Size = new System.Drawing.Size(44, 13);
|
||||
this.label10.TabIndex = 9;
|
||||
this.label10.Text = "Football";
|
||||
this.mButtonsTable.ColumnCount = 2;
|
||||
this.mMainTable.SetColumnSpan(this.mButtonsTable, 3);
|
||||
this.mButtonsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.mButtonsTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.mButtonsTable.Controls.Add(this.mCancel, 1, 0);
|
||||
this.mButtonsTable.Controls.Add(this.mOK, 0, 0);
|
||||
this.mButtonsTable.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mButtonsTable.Location = new System.Drawing.Point(0, 254);
|
||||
this.mButtonsTable.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.mButtonsTable.Name = "mButtonsTable";
|
||||
this.mButtonsTable.RowCount = 1;
|
||||
this.mButtonsTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.mButtonsTable.Size = new System.Drawing.Size(478, 44);
|
||||
this.mButtonsTable.TabIndex = 27;
|
||||
this.mCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mCancel.Location = new System.Drawing.Point(400, 19);
|
||||
this.mCancel.Name = "mCancel";
|
||||
this.mCancel.Size = new System.Drawing.Size(75, 22);
|
||||
this.mCancel.TabIndex = 1;
|
||||
this.mCancel.Text = "&Cancel";
|
||||
this.mCancel.UseVisualStyleBackColor = true;
|
||||
this.mCancel.Click += new System.EventHandler(mCancel_Click);
|
||||
this.mOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mOK.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.mOK.Location = new System.Drawing.Point(319, 19);
|
||||
this.mOK.Name = "mOK";
|
||||
this.mOK.Size = new System.Drawing.Size(75, 22);
|
||||
this.mOK.TabIndex = 0;
|
||||
this.mOK.Text = "&OK";
|
||||
this.mOK.UseVisualStyleBackColor = true;
|
||||
this.mOK.Click += new System.EventHandler(mOK_Click);
|
||||
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Location = new System.Drawing.Point(72, 154);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(45, 13);
|
||||
this.label5.TabIndex = 4;
|
||||
this.label5.Text = "Vehicle:";
|
||||
this.mDeathRaceVehicle.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceVehicle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceVehicle.FormattingEnabled = true;
|
||||
this.mDeathRaceVehicle.Location = new System.Drawing.Point(123, 150);
|
||||
this.mDeathRaceVehicle.Name = "mDeathRaceVehicle";
|
||||
this.mDeathRaceVehicle.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceVehicle.TabIndex = 10;
|
||||
this.mFootballVehicle.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballVehicle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballVehicle.FormattingEnabled = true;
|
||||
this.mFootballVehicle.Location = new System.Drawing.Point(302, 150);
|
||||
this.mFootballVehicle.Name = "mFootballVehicle";
|
||||
this.mFootballVehicle.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballVehicle.TabIndex = 11;
|
||||
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(86, 20);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(31, 13);
|
||||
this.label4.TabIndex = 3;
|
||||
this.label4.Text = "Map:";
|
||||
this.label7.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label7.AutoSize = true;
|
||||
this.label7.Location = new System.Drawing.Point(66, 47);
|
||||
this.label7.Name = "label7";
|
||||
this.label7.Size = new System.Drawing.Size(51, 13);
|
||||
this.label7.TabIndex = 6;
|
||||
this.label7.Text = "Weather:";
|
||||
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(16, 101);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(101, 13);
|
||||
this.label2.TabIndex = 1;
|
||||
this.label2.Text = "Score Compression:";
|
||||
this.label6.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label6.AutoSize = true;
|
||||
this.label6.Location = new System.Drawing.Point(48, 74);
|
||||
this.label6.Name = "label6";
|
||||
this.label6.Size = new System.Drawing.Size(69, 13);
|
||||
this.label6.TabIndex = 5;
|
||||
this.label6.Text = "Time Of Day:";
|
||||
this.label3.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(36, 127);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(81, 13);
|
||||
this.label3.TabIndex = 2;
|
||||
this.label3.Text = "Mission Length:";
|
||||
this.mDeathRaceMap.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceMap.FormattingEnabled = true;
|
||||
this.mDeathRaceMap.Location = new System.Drawing.Point(123, 16);
|
||||
this.mDeathRaceMap.Name = "mDeathRaceMap";
|
||||
this.mDeathRaceMap.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceMap.TabIndex = 0;
|
||||
this.mDeathRaceTimeOfDay.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceTimeOfDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceTimeOfDay.FormattingEnabled = true;
|
||||
this.mDeathRaceTimeOfDay.Location = new System.Drawing.Point(123, 70);
|
||||
this.mDeathRaceTimeOfDay.Name = "mDeathRaceTimeOfDay";
|
||||
this.mDeathRaceTimeOfDay.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceTimeOfDay.TabIndex = 4;
|
||||
this.mDeathRaceScoreCompression.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceScoreCompression.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceScoreCompression.FormattingEnabled = true;
|
||||
this.mDeathRaceScoreCompression.Location = new System.Drawing.Point(123, 97);
|
||||
this.mDeathRaceScoreCompression.Name = "mDeathRaceScoreCompression";
|
||||
this.mDeathRaceScoreCompression.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceScoreCompression.TabIndex = 6;
|
||||
this.mDeathRaceWeather.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceWeather.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mDeathRaceWeather.FormattingEnabled = true;
|
||||
this.mDeathRaceWeather.Location = new System.Drawing.Point(123, 43);
|
||||
this.mDeathRaceWeather.Name = "mDeathRaceWeather";
|
||||
this.mDeathRaceWeather.Size = new System.Drawing.Size(173, 21);
|
||||
this.mDeathRaceWeather.TabIndex = 2;
|
||||
this.mDeathRaceMissionLength.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mDeathRaceMissionLength.Location = new System.Drawing.Point(123, 124);
|
||||
this.mDeathRaceMissionLength.Name = "mDeathRaceMissionLength";
|
||||
this.mDeathRaceMissionLength.Size = new System.Drawing.Size(173, 20);
|
||||
this.mDeathRaceMissionLength.TabIndex = 8;
|
||||
this.mFootballMap.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballMap.FormattingEnabled = true;
|
||||
this.mFootballMap.Location = new System.Drawing.Point(302, 16);
|
||||
this.mFootballMap.Name = "mFootballMap";
|
||||
this.mFootballMap.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballMap.TabIndex = 1;
|
||||
this.mFootballTimeOfDay.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballTimeOfDay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballTimeOfDay.FormattingEnabled = true;
|
||||
this.mFootballTimeOfDay.Location = new System.Drawing.Point(302, 70);
|
||||
this.mFootballTimeOfDay.Name = "mFootballTimeOfDay";
|
||||
this.mFootballTimeOfDay.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballTimeOfDay.TabIndex = 5;
|
||||
this.mFootballScoreCompression.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballScoreCompression.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballScoreCompression.FormattingEnabled = true;
|
||||
this.mFootballScoreCompression.Location = new System.Drawing.Point(302, 97);
|
||||
this.mFootballScoreCompression.Name = "mFootballScoreCompression";
|
||||
this.mFootballScoreCompression.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballScoreCompression.TabIndex = 7;
|
||||
this.mFootballMissionLength.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballMissionLength.Location = new System.Drawing.Point(302, 124);
|
||||
this.mFootballMissionLength.Name = "mFootballMissionLength";
|
||||
this.mFootballMissionLength.Size = new System.Drawing.Size(173, 20);
|
||||
this.mFootballMissionLength.TabIndex = 9;
|
||||
this.mFootballWeather.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFootballWeather.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.mFootballWeather.FormattingEnabled = true;
|
||||
this.mFootballWeather.Location = new System.Drawing.Point(302, 43);
|
||||
this.mFootballWeather.Name = "mFootballWeather";
|
||||
this.mFootballWeather.Size = new System.Drawing.Size(173, 21);
|
||||
this.mFootballWeather.TabIndex = 3;
|
||||
this.label11.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label11.AutoSize = true;
|
||||
this.label11.Location = new System.Drawing.Point(3, 228);
|
||||
this.label11.Name = "label11";
|
||||
this.label11.Size = new System.Drawing.Size(114, 26);
|
||||
this.label11.TabIndex = 28;
|
||||
this.label11.Text = "Autotranslocate Delay:";
|
||||
this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.mDeathraceLaunchDelay.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mDeathraceLaunchDelay.Location = new System.Drawing.Point(123, 231);
|
||||
this.mDeathraceLaunchDelay.Name = "mDeathraceLaunchDelay";
|
||||
this.mDeathraceLaunchDelay.Size = new System.Drawing.Size(173, 20);
|
||||
this.mDeathraceLaunchDelay.TabIndex = 31;
|
||||
this.mFootballLaunchDelay.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mFootballLaunchDelay.Location = new System.Drawing.Point(302, 231);
|
||||
this.mFootballLaunchDelay.Name = "mFootballLaunchDelay";
|
||||
this.mFootballLaunchDelay.Size = new System.Drawing.Size(173, 20);
|
||||
this.mFootballLaunchDelay.TabIndex = 32;
|
||||
base.AcceptButton = this.mOK;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(484, 304);
|
||||
base.Controls.Add(this.mMainTable);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
base.MaximizeBox = false;
|
||||
base.Name = "RPDefaultsDialog";
|
||||
base.Padding = new System.Windows.Forms.Padding(3);
|
||||
this.Text = "Red Planet Defaults";
|
||||
this.mMainTable.ResumeLayout(false);
|
||||
this.mMainTable.PerformLayout();
|
||||
this.mButtonsTable.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)this.mDeathraceLaunchDelay).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)this.mFootballLaunchDelay).EndInit();
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
|
||||
public static void ShowSingleton()
|
||||
{
|
||||
if (mSingletonDialog == null || mSingletonDialog.IsDisposed)
|
||||
{
|
||||
mSingletonDialog = new RPDefaultsDialog();
|
||||
}
|
||||
mSingletonDialog.Show();
|
||||
mSingletonDialog.Focus();
|
||||
mSingletonDialog.WindowState = FormWindowState.Normal;
|
||||
}
|
||||
|
||||
private RPDefaultsDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
base.Icon = Resources.swirl;
|
||||
BuildScoreCompressionOptions(mDeathRaceScoreCompression, RPDefaults.DeathRace.ScoreCompression);
|
||||
BuildScoreCompressionOptions(mFootballScoreCompression, RPDefaults.Football.ScoreCompression);
|
||||
BuildMissionLengthControl(mDeathRaceMissionLength, RPDefaults.DeathRace.MissionLength);
|
||||
BuildMissionLengthControl(mFootballMissionLength, RPDefaults.Football.MissionLength);
|
||||
BuildMapOption(mDeathRaceMap, RPConfig.DeathRace.Maps, RPDefaults.DeathRace.MapKey);
|
||||
BuildMapOption(mFootballMap, RPConfig.Football.Maps, RPDefaults.Football.MapKey);
|
||||
BuildGenericOption(mDeathRaceTimeOfDay, RPConfig.DeathRace.TimesOfDay, RPDefaults.DeathRace.TimeOfDayKey);
|
||||
BuildGenericOption(mFootballTimeOfDay, RPConfig.Football.TimesOfDay, RPDefaults.Football.TimeOfDayKey);
|
||||
BuildGenericOption(mDeathRaceWeather, RPConfig.DeathRace.Weather, RPDefaults.DeathRace.WeatherKey);
|
||||
BuildGenericOption(mFootballWeather, RPConfig.Football.Weather, RPDefaults.Football.WeatherKey);
|
||||
BuildVehicleOption(mDeathRaceVehicle, RPConfig.DeathRace.Vehicles, RPDefaults.DeathRace.VehicleKey);
|
||||
BuildVehicleOption(mFootballVehicle, RPConfig.Football.Vehicles, RPDefaults.Football.VehicleKey);
|
||||
BuildGenericOption(mDeathRaceColor, RPConfig.DeathRace.Colors, RPDefaults.DeathRace.ColorKey);
|
||||
BuildTeamOption(mFootballTeam, RPConfig.Football.Teams, RPDefaults.Football.TeamKey);
|
||||
BuildGenericOption(mDeathRaceBadge, RPConfig.DeathRace.Badges, RPDefaults.DeathRace.BadgeKey);
|
||||
BuildGenericOption(mFootballPosition, RPConfig.Football.Positions, RPDefaults.Football.PositionKey);
|
||||
BuildDelayControl(mDeathraceLaunchDelay, RPDefaults.DeathRace.LaunchDelay);
|
||||
BuildDelayControl(mFootballLaunchDelay, RPDefaults.Football.LaunchDelay);
|
||||
}
|
||||
|
||||
private static void BuildScoreCompressionOptions(ComboBox comboBox, bool defaultValue)
|
||||
{
|
||||
comboBox.DisplayMember = "Value";
|
||||
comboBox.ValueMember = "Key";
|
||||
comboBox.Items.Add(new KeyValuePair<bool, string>(key: false, "Off"));
|
||||
comboBox.Items.Add(new KeyValuePair<bool, string>(key: true, "On"));
|
||||
comboBox.SelectedIndex = (defaultValue ? 1 : 0);
|
||||
}
|
||||
|
||||
private static void BuildMissionLengthControl(MaskedTextBox maskedTextBox, TimeSpan defaultValue)
|
||||
{
|
||||
maskedTextBox.Mask = "00:00:00";
|
||||
maskedTextBox.ValidatingType = typeof(TimeSpan);
|
||||
maskedTextBox.Text = defaultValue.ToString();
|
||||
}
|
||||
|
||||
private static void BuildDelayControl(NumericUpDown maskedTextBox, int defaultValue)
|
||||
{
|
||||
maskedTextBox.Value = defaultValue;
|
||||
}
|
||||
|
||||
private static void BuildMapOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPMap>> options, string defaultKey)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
int num = 0;
|
||||
comboBox.DisplayMember = "Name";
|
||||
comboBox.ValueMember = "Key";
|
||||
foreach (KeyValuePair<string, RPMap> option in options)
|
||||
{
|
||||
comboBox.Items.Add(option.Value);
|
||||
if (option.Key == defaultKey)
|
||||
{
|
||||
selectedIndex = num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
comboBox.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
private static void BuildVehicleOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPVehicle>> options, string defaultKey)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
int num = 0;
|
||||
comboBox.DisplayMember = "Name";
|
||||
comboBox.ValueMember = "Key";
|
||||
foreach (KeyValuePair<string, RPVehicle> option in options)
|
||||
{
|
||||
comboBox.Items.Add(option.Value);
|
||||
if (option.Key == defaultKey)
|
||||
{
|
||||
selectedIndex = num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
comboBox.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
private static void BuildTeamOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, RPTeam>> options, string defaultKey)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
int num = 0;
|
||||
comboBox.DisplayMember = "Name";
|
||||
comboBox.ValueMember = "Key";
|
||||
foreach (KeyValuePair<string, RPTeam> option in options)
|
||||
{
|
||||
comboBox.Items.Add(option.Value);
|
||||
if (option.Key == defaultKey)
|
||||
{
|
||||
selectedIndex = num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
comboBox.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
private static void BuildGenericOption(ComboBox comboBox, IEnumerable<KeyValuePair<string, string>> options, string defaultKey)
|
||||
{
|
||||
int selectedIndex = 0;
|
||||
int num = 0;
|
||||
comboBox.DisplayMember = "Value";
|
||||
comboBox.ValueMember = "Key";
|
||||
foreach (KeyValuePair<string, string> option in options)
|
||||
{
|
||||
comboBox.Items.Add(option);
|
||||
if (option.Key == defaultKey)
|
||||
{
|
||||
selectedIndex = num;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
comboBox.SelectedIndex = selectedIndex;
|
||||
}
|
||||
|
||||
private void mCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void mOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
RPDefaults.DeathRace.ScoreCompression = ExtractSelectedKey<bool>(mDeathRaceScoreCompression);
|
||||
RPDefaults.Football.ScoreCompression = ExtractSelectedKey<bool>(mFootballScoreCompression);
|
||||
RPDefaults.DeathRace.MissionLength = (TimeSpan)mDeathRaceMissionLength.ValidateText();
|
||||
RPDefaults.Football.MissionLength = (TimeSpan)mFootballMissionLength.ValidateText();
|
||||
RPDefaults.DeathRace.MapKey = ExtractSelectedMapKey(mDeathRaceMap);
|
||||
RPDefaults.Football.MapKey = ExtractSelectedMapKey(mFootballMap);
|
||||
RPDefaults.DeathRace.TimeOfDayKey = ExtractSelectedKey<string>(mDeathRaceTimeOfDay);
|
||||
RPDefaults.Football.TimeOfDayKey = ExtractSelectedKey<string>(mFootballTimeOfDay);
|
||||
RPDefaults.DeathRace.WeatherKey = ExtractSelectedKey<string>(mDeathRaceWeather);
|
||||
RPDefaults.Football.WeatherKey = ExtractSelectedKey<string>(mFootballWeather);
|
||||
RPDefaults.DeathRace.VehicleKey = ExtractVehicleKey(mDeathRaceVehicle);
|
||||
RPDefaults.Football.VehicleKey = ExtractVehicleKey(mFootballVehicle);
|
||||
RPDefaults.DeathRace.ColorKey = ExtractSelectedKey<string>(mDeathRaceColor);
|
||||
RPDefaults.Football.TeamKey = ExtractTeamKey(mFootballTeam);
|
||||
RPDefaults.DeathRace.BadgeKey = ExtractSelectedKey<string>(mDeathRaceBadge);
|
||||
RPDefaults.Football.PositionKey = ExtractSelectedKey<string>(mFootballPosition);
|
||||
RPDefaults.DeathRace.LaunchDelay = (int)mDeathraceLaunchDelay.Value;
|
||||
RPDefaults.Football.LaunchDelay = (int)mFootballLaunchDelay.Value;
|
||||
RPDefaults.Save();
|
||||
Hide();
|
||||
}
|
||||
|
||||
private static T ExtractSelectedKey<T>(ComboBox comboBox)
|
||||
{
|
||||
if (comboBox.SelectedItem is KeyValuePair<T, string>)
|
||||
{
|
||||
return ((KeyValuePair<T, string>)comboBox.SelectedItem).Key;
|
||||
}
|
||||
return (T)comboBox.SelectedItem;
|
||||
}
|
||||
|
||||
private static string ExtractSelectedMapKey(ComboBox comboBox)
|
||||
{
|
||||
if (comboBox.SelectedItem is RPMap)
|
||||
{
|
||||
return ((RPMap)comboBox.SelectedItem).Key;
|
||||
}
|
||||
return (string)comboBox.SelectedItem;
|
||||
}
|
||||
|
||||
private static string ExtractVehicleKey(ComboBox comboBox)
|
||||
{
|
||||
if (comboBox.SelectedItem is RPVehicle)
|
||||
{
|
||||
return ((RPVehicle)comboBox.SelectedItem).Key;
|
||||
}
|
||||
return (string)comboBox.SelectedItem;
|
||||
}
|
||||
|
||||
private static string ExtractTeamKey(ComboBox comboBox)
|
||||
{
|
||||
if (comboBox.SelectedItem is RPTeam)
|
||||
{
|
||||
return ((RPTeam)comboBox.SelectedItem).Key;
|
||||
}
|
||||
return (string)comboBox.SelectedItem;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPFootballMission : RPMission
|
||||
{
|
||||
private readonly List<RPFootballPlayer> mFootballPlayers = new List<RPFootballPlayer>();
|
||||
|
||||
public IEnumerable<RPFootballPlayer> FootballPlayers => mFootballPlayers;
|
||||
|
||||
public override IEnumerable<RPPlayer> Players => mFootballPlayers.ToArray();
|
||||
|
||||
public override int PlayerCount => mFootballPlayers.Count;
|
||||
|
||||
public RPFootballMission(string mapKey, string timeOfDayKey, string weatherKey, bool scoreCompression, TimeSpan gameLength)
|
||||
: base(RPConfig.Football.Key, mapKey, timeOfDayKey, weatherKey, scoreCompression, gameLength)
|
||||
{
|
||||
}
|
||||
|
||||
public void AddFootballTeam(IEnumerable<RPFootballPlayer> footballTeam)
|
||||
{
|
||||
bool flag = false;
|
||||
string text = null;
|
||||
foreach (RPFootballPlayer item in footballTeam)
|
||||
{
|
||||
if (text == null)
|
||||
{
|
||||
text = item.TeamKey;
|
||||
foreach (RPFootballPlayer mFootballPlayer in mFootballPlayers)
|
||||
{
|
||||
if (mFootballPlayer.TeamKey == item.TeamKey)
|
||||
{
|
||||
throw new ArgumentException("The provided RPFootballPlayers' team has already been added", "footballTeam");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (text != item.TeamKey)
|
||||
{
|
||||
throw new ArgumentException("The provided RPFootballPlayers were not on the same team", "footballTeam");
|
||||
}
|
||||
if (item.PositionKey == "runner")
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
throw new ArgumentException("The provided RPFootballPlayers contained more than one runner", "footballTeam");
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
throw new ArgumentException("The provided RPFootballPlayers did not contain a runner", "footballTeam");
|
||||
}
|
||||
mFootballPlayers.AddRange(footballTeam);
|
||||
}
|
||||
|
||||
protected override void AppendMissionSpecificData(StringBuilder egg)
|
||||
{
|
||||
Dictionary<string, List<RPFootballPlayer>> dictionary = new Dictionary<string, List<RPFootballPlayer>>();
|
||||
foreach (RPFootballPlayer mFootballPlayer in mFootballPlayers)
|
||||
{
|
||||
if (!dictionary.ContainsKey(mFootballPlayer.TeamKey))
|
||||
{
|
||||
dictionary.Add(mFootballPlayer.TeamKey, new List<RPFootballPlayer>());
|
||||
}
|
||||
dictionary[mFootballPlayer.TeamKey].Add(mFootballPlayer);
|
||||
}
|
||||
int num = 1;
|
||||
StringBuilder stringBuilder = new StringBuilder("[teams]\n");
|
||||
StringBuilder stringBuilder2 = new StringBuilder();
|
||||
StringBuilder stringBuilder3 = new StringBuilder("[teambitmap]\n");
|
||||
StringBuilder stringBuilder4 = new StringBuilder();
|
||||
StringBuilder stringBuilder5 = new StringBuilder();
|
||||
foreach (KeyValuePair<string, List<RPFootballPlayer>> item in dictionary)
|
||||
{
|
||||
stringBuilder.AppendFormat("team=team::{0}\n", item.Key);
|
||||
stringBuilder2.AppendFormat("[team::{0}]\n", item.Key);
|
||||
stringBuilder2.AppendFormat("bitmapindex={0}\n", num++);
|
||||
stringBuilder2.AppendFormat("pilots=pilots::{0}\n", item.Key);
|
||||
stringBuilder3.AppendFormat("bitmap=BitMap::Small::team::{0}\n", item.Key);
|
||||
stringBuilder4.AppendFormat("[BitMap::Small::team::{0}]\n", item.Key);
|
||||
stringBuilder4.Append(PlasmaBitmaps.GenerateString(64, 16, item.Key));
|
||||
stringBuilder4.Append("width=4\n");
|
||||
stringBuilder5.AppendFormat("[pilots::{0}]\n", item.Key);
|
||||
foreach (RPFootballPlayer item2 in item.Value)
|
||||
{
|
||||
stringBuilder5.AppendFormat("pilot={0}\n", item2.PodHostAddress);
|
||||
}
|
||||
}
|
||||
egg.Append(stringBuilder);
|
||||
egg.Append(stringBuilder2);
|
||||
egg.Append(stringBuilder5);
|
||||
egg.Append(stringBuilder3);
|
||||
egg.Append(stringBuilder4);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPFootballPlayer : RPPlayer
|
||||
{
|
||||
private readonly string mTeamKey;
|
||||
|
||||
private readonly string mPositionKey;
|
||||
|
||||
public string TeamKey => mTeamKey;
|
||||
|
||||
public string PositionKey => mPositionKey;
|
||||
|
||||
public RPFootballPlayer(string podHostAddress, string name, string vehicleKey, string teamKey, string positionKey, string colorKey)
|
||||
: base(podHostAddress, name, vehicleKey, colorKey, "None")
|
||||
{
|
||||
if (teamKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("teamKey");
|
||||
}
|
||||
if (positionKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("positionKey");
|
||||
}
|
||||
mTeamKey = teamKey;
|
||||
mPositionKey = positionKey;
|
||||
}
|
||||
|
||||
protected sealed override void AppendMissionSpecificPilot(int index, StringBuilder sb)
|
||||
{
|
||||
sb.AppendFormat("team=team::{0}\n", mTeamKey);
|
||||
sb.AppendFormat("position={0}\n", mPositionKey);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class RPMap
|
||||
{
|
||||
private readonly string mKey;
|
||||
|
||||
private readonly string mName;
|
||||
|
||||
private readonly string mImagePath;
|
||||
|
||||
public string Key => mKey;
|
||||
|
||||
public string Name => mName;
|
||||
|
||||
public Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mImagePath == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ImageCache.GetImage(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), mImagePath));
|
||||
}
|
||||
}
|
||||
|
||||
internal RPMap(XmlNode mapNode)
|
||||
{
|
||||
XmlAttribute xmlAttribute = mapNode.Attributes["image"];
|
||||
mKey = mapNode.Attributes["key"].InnerText;
|
||||
mName = mapNode.Attributes["name"].InnerText;
|
||||
mImagePath = xmlAttribute?.InnerText;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,306 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Munga.Net;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal abstract class RPMission
|
||||
{
|
||||
private string mScenarioKey;
|
||||
|
||||
private string mMapKey;
|
||||
|
||||
private string mTimeOfDayKey;
|
||||
|
||||
private string mWeatherKey;
|
||||
|
||||
private bool mScoreCompression;
|
||||
|
||||
private TimeSpan mGameLength;
|
||||
|
||||
private readonly List<RPCamera> mCameras = new List<RPCamera>();
|
||||
|
||||
public string ScenarioKey => mScenarioKey;
|
||||
|
||||
public string MapKey => mMapKey;
|
||||
|
||||
public string TimeOfDayKey => mTimeOfDayKey;
|
||||
|
||||
public string WeatherKey => mWeatherKey;
|
||||
|
||||
public bool ScoreCompression => mScoreCompression;
|
||||
|
||||
public TimeSpan GameLength => mGameLength;
|
||||
|
||||
public abstract IEnumerable<RPPlayer> Players { get; }
|
||||
|
||||
public abstract int PlayerCount { get; }
|
||||
|
||||
public List<RPCamera> Cameras => mCameras;
|
||||
|
||||
protected RPMission(string scenarioKey, string mapKey, string timeOfDayKey, string weatherKey, bool scoreCompression, TimeSpan gameLength)
|
||||
{
|
||||
if (scenarioKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("scenarioKey");
|
||||
}
|
||||
if (mapKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("mapKey");
|
||||
}
|
||||
if (timeOfDayKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("timeOfDayKey");
|
||||
}
|
||||
if (weatherKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("weatherKey");
|
||||
}
|
||||
if (gameLength <= TimeSpan.Zero)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("gameLength");
|
||||
}
|
||||
mScenarioKey = scenarioKey;
|
||||
mMapKey = mapKey;
|
||||
mTimeOfDayKey = timeOfDayKey;
|
||||
mWeatherKey = weatherKey;
|
||||
mScoreCompression = scoreCompression;
|
||||
mGameLength = gameLength;
|
||||
}
|
||||
|
||||
public EggFileMessage[] ToEggFileMessages()
|
||||
{
|
||||
string text = ToEggString();
|
||||
text = text.Replace("\r\n", "\0");
|
||||
text = text.Replace('\n', '\0');
|
||||
byte[] bytes = Encoding.ASCII.GetBytes(text);
|
||||
EggFileMessage[] array = new EggFileMessage[(bytes.Length + 999) / 1000];
|
||||
byte[] array2 = new byte[1000];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
int num = i * 1000;
|
||||
int num2 = bytes.Length - num;
|
||||
if (num2 > 1000)
|
||||
{
|
||||
num2 = 1000;
|
||||
}
|
||||
Buffer.BlockCopy(bytes, num, array2, 0, num2);
|
||||
array[i] = new EggFileMessage(i, bytes.Length, num2, array2);
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
public string ToEggString()
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
List<string> list = new List<string>();
|
||||
stringBuilder.Append("[mission]\n");
|
||||
stringBuilder.Append("adventure=Red Planet\n");
|
||||
stringBuilder.AppendFormat("map={0}\n", mMapKey);
|
||||
stringBuilder.AppendFormat("scenario={0}\n", mScenarioKey);
|
||||
stringBuilder.AppendFormat("time={0}\n", mTimeOfDayKey);
|
||||
stringBuilder.AppendFormat("weather={0}\n", mWeatherKey);
|
||||
stringBuilder.AppendFormat("temperature=0\n");
|
||||
stringBuilder.AppendFormat("compression={0}\n", mScoreCompression ? "1" : "0");
|
||||
stringBuilder.AppendFormat("length={0}\n", mGameLength.TotalSeconds);
|
||||
stringBuilder.Append("[pilots]\n");
|
||||
foreach (RPPlayer player in Players)
|
||||
{
|
||||
stringBuilder.AppendFormat("pilot={0}\n", player.PodHostAddress);
|
||||
}
|
||||
foreach (RPCamera camera in Cameras)
|
||||
{
|
||||
stringBuilder.AppendFormat("pilot={0}\n", camera.PodHostAddress);
|
||||
}
|
||||
int num = 1;
|
||||
foreach (RPPlayer player2 in Players)
|
||||
{
|
||||
player2.AppendParticipant(num++, stringBuilder);
|
||||
list.Add(player2.Name);
|
||||
}
|
||||
foreach (RPCamera camera2 in Cameras)
|
||||
{
|
||||
camera2.AppendParticipant(num++, stringBuilder);
|
||||
list.Add("Camera");
|
||||
}
|
||||
AppendMissionSpecificData(stringBuilder);
|
||||
stringBuilder.Append("[largebitmap]\n");
|
||||
foreach (string item in list)
|
||||
{
|
||||
stringBuilder.AppendFormat("bitmap=BitMap::Large::{0}\n", item);
|
||||
}
|
||||
stringBuilder.Append("[smallbitmap]\n");
|
||||
foreach (string item2 in list)
|
||||
{
|
||||
stringBuilder.AppendFormat("bitmap=BitMap::Small::{0}\n", item2);
|
||||
}
|
||||
foreach (string item3 in list)
|
||||
{
|
||||
stringBuilder.AppendFormat("[BitMap::Large::{0}]\n", item3);
|
||||
stringBuilder.Append(PlasmaBitmaps.GenerateString(128, 32, item3));
|
||||
stringBuilder.Append("width=8\n");
|
||||
stringBuilder.AppendFormat("[BitMap::Small::{0}]\n", item3);
|
||||
stringBuilder.Append(PlasmaBitmaps.GenerateString(64, 16, item3));
|
||||
stringBuilder.Append("width=4\n");
|
||||
}
|
||||
AppendOrdinals(stringBuilder);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
protected abstract void AppendMissionSpecificData(StringBuilder egg);
|
||||
|
||||
private static void AppendOrdinals(StringBuilder sb)
|
||||
{
|
||||
sb.Append("[ordinals]\n");
|
||||
sb.Append("bitmap=Ordinal::BitMap::1\n");
|
||||
sb.Append("bitmap=Ordinal::BitMap::2\n");
|
||||
sb.Append("bitmap=Ordinal::BitMap::3\n");
|
||||
sb.Append("bitmap=Ordinal::BitMap::4\n");
|
||||
sb.Append("[Ordinal::BitMap::1]\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=000038000003C000001FF00000000F00\n");
|
||||
sb.Append("bitmap=0000F8000003C000003FF80000000F00\n");
|
||||
sb.Append("bitmap=0001F8000003C00000707C0000000F00\n");
|
||||
sb.Append("bitmap=0001F8000003C00000603C0000000F00\n");
|
||||
sb.Append("bitmap=00007801FC0FF00000003C3DF807FF00\n");
|
||||
sb.Append("bitmap=00007803FE0FF00000003C3FFC0FFF00\n");
|
||||
sb.Append("bitmap=00007803C703C00000003C3E3C1F0F00\n");
|
||||
sb.Append("bitmap=000078078303C0000000783C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078078003C0000000783C1E1E0F00\n");
|
||||
sb.Append("bitmap=00007807C003C0000000F03C1E1E0F00\n");
|
||||
sb.Append("bitmap=00007807F003C0000001E03C1E1E0F00\n");
|
||||
sb.Append("bitmap=00007803FC03C0000003C03C1E1E0F00\n");
|
||||
sb.Append("bitmap=00007801FE03C0000007803C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078007F03C000000F003C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078001F03C000001E003C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078000F03C000003C003C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078060F03C0000078003C1E1E0F00\n");
|
||||
sb.Append("bitmap=000078071E03E0000078003C1E1F1F00\n");
|
||||
sb.Append("bitmap=00007803FE01F000007FFC3C1E0FFF00\n");
|
||||
sb.Append("bitmap=00007801FC00F000007FFC3C1E07EF00\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("x=128\n");
|
||||
sb.Append("y=32\n");
|
||||
sb.Append("width=8\n");
|
||||
sb.Append("[Ordinal::BitMap::2]\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=001FFF0000003C0000003C03C0780000\n");
|
||||
sb.Append("bitmap=001FFF0000003C0000007C03C0780000\n");
|
||||
sb.Append("bitmap=00000E0000003C000000FC03C0780000\n");
|
||||
sb.Append("bitmap=00003C0000003C000001BC03C0780000\n");
|
||||
sb.Append("bitmap=0000700F3E1FFC000003BC0FF07BF000\n");
|
||||
sb.Append("bitmap=0001E00F7E3FFC0000073C0FF07FF800\n");
|
||||
sb.Append("bitmap=0003800FFE7C3C0000063C03C07C7800\n");
|
||||
sb.Append("bitmap=0007F80FFE783C00000C3C03C0783C00\n");
|
||||
sb.Append("bitmap=0007FE0F80783C0000183C03C0783C00\n");
|
||||
sb.Append("bitmap=00001E0F00783C0000383C03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C0000703C03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C00007FFF03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C00007FFF03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C0000003C03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C0000003C03C0783C00\n");
|
||||
sb.Append("bitmap=00000F0F00783C0000003C03C0783C00\n");
|
||||
sb.Append("bitmap=00180F0F00783C0000003C03C0783C00\n");
|
||||
sb.Append("bitmap=001C1F0F007C7C0000003C03E0783C00\n");
|
||||
sb.Append("bitmap=000FFE0F003FFC0000003C01F0783C00\n");
|
||||
sb.Append("bitmap=0007FC0F001FBC0000003C00F0783C00\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("x=128\n");
|
||||
sb.Append("y=32\n");
|
||||
sb.Append("width=8\n");
|
||||
sb.Append("[Ordinal::BitMap::3]\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=001FFF03C07800000000FC03C0780000\n");
|
||||
sb.Append("bitmap=001FFF03C07800000003FC03C0780000\n");
|
||||
sb.Append("bitmap=001E0003C07800000007C003C0780000\n");
|
||||
sb.Append("bitmap=001E0003C0780000000F0003C0780000\n");
|
||||
sb.Append("bitmap=001E000FF07BF000000F000FF07BF000\n");
|
||||
sb.Append("bitmap=001E000FF07FF800001E000FF07FF800\n");
|
||||
sb.Append("bitmap=001E0003C07C7800001E0003C07C7800\n");
|
||||
sb.Append("bitmap=001FFC03C0783C00001EFC03C0783C00\n");
|
||||
sb.Append("bitmap=001FFE03C0783C00001FFE03C0783C00\n");
|
||||
sb.Append("bitmap=00001F03C0783C00001F1F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00000F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00180F03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=001C1F03E0783C00001F1F03E0783C00\n");
|
||||
sb.Append("bitmap=000FFE01F0783C00000FFE01F0783C00\n");
|
||||
sb.Append("bitmap=0007FC00F0783C000007FC00F0783C00\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("x=128\n");
|
||||
sb.Append("y=32\n");
|
||||
sb.Append("width=8\n");
|
||||
sb.Append("[Ordinal::BitMap::4]\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=001FFF03C07800000007FC03C0780000\n");
|
||||
sb.Append("bitmap=001FFF03C0780000000FFE03C0780000\n");
|
||||
sb.Append("bitmap=00000F03C0780000001F1F03C0780000\n");
|
||||
sb.Append("bitmap=00000F03C0780000001E0F03C0780000\n");
|
||||
sb.Append("bitmap=00000F0FF07BF000001E0F0FF07BF000\n");
|
||||
sb.Append("bitmap=00001F0FF07FF800001E0F0FF07FF800\n");
|
||||
sb.Append("bitmap=00001E03C07C7800001E0F03C07C7800\n");
|
||||
sb.Append("bitmap=00003E03C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=00003C03C0783C00000F1E03C0783C00\n");
|
||||
sb.Append("bitmap=00003C03C0783C000007FC03C0783C00\n");
|
||||
sb.Append("bitmap=00007803C0783C000007FC03C0783C00\n");
|
||||
sb.Append("bitmap=00007803C0783C00000F1E03C0783C00\n");
|
||||
sb.Append("bitmap=00007803C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=0000F003C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=0000F003C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=0000F003C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=0000F003C0783C00001E0F03C0783C00\n");
|
||||
sb.Append("bitmap=0000F003E0783C00000F1E03E0783C00\n");
|
||||
sb.Append("bitmap=0000F001F0783C00000FFE01F0783C00\n");
|
||||
sb.Append("bitmap=0000F000F0783C000007FC00F0783C00\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("bitmap=00000000000000000000000000000000\n");
|
||||
sb.Append("x=128\n");
|
||||
sb.Append("y=32\n");
|
||||
sb.Append("width=8\n");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using System;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
internal class RPMissionRecorder
|
||||
{
|
||||
private RPMissionResults mMissionResults;
|
||||
|
||||
private bool mStartSet;
|
||||
|
||||
public RPMissionRecorder(RPMission mission)
|
||||
{
|
||||
mMissionResults = new RPMissionResults(mission);
|
||||
}
|
||||
|
||||
public void SetMissionStart()
|
||||
{
|
||||
if (mStartSet)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
mMissionResults.mMissionStart = DateTime.Now;
|
||||
mStartSet = true;
|
||||
}
|
||||
|
||||
private void ValidatePlayer(RPPlayer player, string param)
|
||||
{
|
||||
if (player == null)
|
||||
{
|
||||
throw new ArgumentNullException(param);
|
||||
}
|
||||
foreach (RPPlayer player2 in mMissionResults.Mission.Players)
|
||||
{
|
||||
if (player2 == player)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new ArgumentException(param);
|
||||
}
|
||||
|
||||
private TimeSpan GetMissionTime()
|
||||
{
|
||||
if (!mStartSet)
|
||||
{
|
||||
return TimeSpan.Zero;
|
||||
}
|
||||
return DateTime.Now - mMissionResults.mMissionStart;
|
||||
}
|
||||
|
||||
public void PlayerScored(RPPlayer reportingPlayer)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
TimeSpan missionTime = GetMissionTime();
|
||||
mMissionResults.mEvents.Add(new ScoredEvent(reportingPlayer, missionTime));
|
||||
}
|
||||
|
||||
public void PlayerKilled(RPPlayer reportingPlayer, RPPlayer killer)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
ValidatePlayer(killer, "killer");
|
||||
TimeSpan missionTime = GetMissionTime();
|
||||
mMissionResults.mEvents.Add(new KilledEvent(reportingPlayer, missionTime, killer));
|
||||
}
|
||||
|
||||
public void PlayerBoost(RPPlayer reportingPlayer, int boosterOn)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
TimeSpan missionTime = GetMissionTime();
|
||||
mMissionResults.mEvents.Add(new BoostEvent(reportingPlayer, missionTime, boosterOn));
|
||||
}
|
||||
|
||||
public void PlayerScoreUpdate(RPPlayer reportingPlayer, int score)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
TimeSpan missionTime = GetMissionTime();
|
||||
mMissionResults.mEvents.Add(new ScoreUpdateEvent(reportingPlayer, missionTime, score));
|
||||
}
|
||||
|
||||
public void PlayerDamaged(RPPlayer reportingPlayer, RPPlayer damager, int damageLoss, int pointsTransfered)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
ValidatePlayer(damager, "damager");
|
||||
TimeSpan missionTime = GetMissionTime();
|
||||
mMissionResults.mEvents.Add(new DamagedEvent(reportingPlayer, missionTime, damager, damageLoss, pointsTransfered));
|
||||
}
|
||||
|
||||
public void PlayerFinalScore(RPPlayer reportingPlayer, int finalScore)
|
||||
{
|
||||
ValidatePlayer(reportingPlayer, "reportingPlayer");
|
||||
mMissionResults.mFinalScores.Add(reportingPlayer, finalScore);
|
||||
}
|
||||
|
||||
public RPMissionResults EndMission(TimeSpan missionLength)
|
||||
{
|
||||
mMissionResults.mActuallMissionTime = missionLength;
|
||||
RPMissionResults result = mMissionResults;
|
||||
mMissionResults = null;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Printing;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPMissionResults
|
||||
{
|
||||
private RPMission mMission;
|
||||
|
||||
internal DateTime mMissionStart;
|
||||
|
||||
internal TimeSpan mActuallMissionTime;
|
||||
|
||||
internal readonly List<MissionEvent> mEvents = new List<MissionEvent>();
|
||||
|
||||
internal readonly Dictionary<RPPlayer, int> mFinalScores = new Dictionary<RPPlayer, int>();
|
||||
|
||||
public RPMission Mission => mMission;
|
||||
|
||||
public DateTime MissionStart => mMissionStart;
|
||||
|
||||
public TimeSpan ActuallMissionTime => mActuallMissionTime;
|
||||
|
||||
public IEnumerable<MissionEvent> Events => mEvents;
|
||||
|
||||
internal RPMissionResults(RPMission mission)
|
||||
{
|
||||
mMission = mission;
|
||||
}
|
||||
|
||||
public static string GetRPMissionsDirectory()
|
||||
{
|
||||
string text = Path.Combine(Program.GetCommonAppDataDirectory(), "RP Missions");
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static RPMissionResults Load(string file)
|
||||
{
|
||||
using GZipStream gZipStream = new GZipStream(File.OpenRead(file), CompressionMode.Decompress);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
RPMissionResults result = (RPMissionResults)binaryFormatter.Deserialize(gZipStream);
|
||||
gZipStream.Close();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
string path = Path.Combine(GetRPMissionsDirectory(), mMissionStart.ToString("yyyy-MM-dd HH-mm-ss.ffff") + ".rpm");
|
||||
using GZipStream gZipStream = new GZipStream(File.OpenWrite(path), CompressionMode.Compress);
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
binaryFormatter.Serialize(gZipStream, this);
|
||||
gZipStream.Close();
|
||||
}
|
||||
|
||||
private RPPlayer GetScoreReportingPlayer(RPPlayer player)
|
||||
{
|
||||
if (player is RPFootballPlayer)
|
||||
{
|
||||
RPFootballPlayer rPFootballPlayer = (RPFootballPlayer)player;
|
||||
if (rPFootballPlayer.PositionKey != "runner")
|
||||
{
|
||||
RPFootballMission rPFootballMission = (RPFootballMission)mMission;
|
||||
{
|
||||
foreach (RPFootballPlayer footballPlayer in rPFootballMission.FootballPlayers)
|
||||
{
|
||||
if (footballPlayer.PositionKey == "runner" && footballPlayer.TeamKey == rPFootballPlayer.TeamKey)
|
||||
{
|
||||
return footballPlayer;
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
}
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
public int GetScore(RPPlayer player)
|
||||
{
|
||||
return GetScore(player, TimeSpan.MaxValue);
|
||||
}
|
||||
|
||||
public int GetScore(RPPlayer player, TimeSpan gameTime)
|
||||
{
|
||||
RPPlayer scoreReportingPlayer = GetScoreReportingPlayer(player);
|
||||
if (gameTime == TimeSpan.MaxValue && mFinalScores.ContainsKey(scoreReportingPlayer))
|
||||
{
|
||||
return mFinalScores[scoreReportingPlayer];
|
||||
}
|
||||
int result = 1000;
|
||||
TimeSpan timeSpan = TimeSpan.MinValue;
|
||||
foreach (MissionEvent mEvent in mEvents)
|
||||
{
|
||||
if (mEvent is ScoreUpdateEvent && mEvent.ReportingPilot == scoreReportingPlayer && mEvent.GameTime > timeSpan && mEvent.GameTime <= gameTime)
|
||||
{
|
||||
result = ((ScoreUpdateEvent)mEvent).Score;
|
||||
timeSpan = mEvent.GameTime;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public int GetFinalPlace(RPPlayer player)
|
||||
{
|
||||
int num = 1;
|
||||
int score = GetScore(player, TimeSpan.MaxValue);
|
||||
if (mMission is RPFootballMission)
|
||||
{
|
||||
RPFootballMission rPFootballMission = (RPFootballMission)mMission;
|
||||
RPFootballPlayer rPFootballPlayer = (RPFootballPlayer)player;
|
||||
{
|
||||
foreach (RPFootballPlayer footballPlayer in rPFootballMission.FootballPlayers)
|
||||
{
|
||||
if (footballPlayer.PositionKey == "runner" && footballPlayer.TeamKey != rPFootballPlayer.TeamKey && GetScore(footballPlayer, TimeSpan.MaxValue) > score)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
}
|
||||
foreach (RPPlayer player2 in mMission.Players)
|
||||
{
|
||||
if (player2 != player && GetScore(player2, TimeSpan.MaxValue) > score)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public RPPlayer[][] GetChartOrder()
|
||||
{
|
||||
return GetChartOrder(TimeSpan.MaxValue);
|
||||
}
|
||||
|
||||
public RPPlayer[][] GetChartOrder(TimeSpan gameTime)
|
||||
{
|
||||
List<Tuple<RPPlayer[], int>> list = new List<Tuple<RPPlayer[], int>>();
|
||||
if (mMission is RPFootballMission)
|
||||
{
|
||||
RPFootballMission rPFootballMission = (RPFootballMission)mMission;
|
||||
Dictionary<string, List<RPPlayer>> dictionary = new Dictionary<string, List<RPPlayer>>();
|
||||
foreach (RPFootballPlayer footballPlayer in rPFootballMission.FootballPlayers)
|
||||
{
|
||||
if (!dictionary.ContainsKey(footballPlayer.TeamKey))
|
||||
{
|
||||
dictionary.Add(footballPlayer.TeamKey, new List<RPPlayer>());
|
||||
}
|
||||
if (footballPlayer.PositionKey == "runner")
|
||||
{
|
||||
dictionary[footballPlayer.TeamKey].Insert(0, footballPlayer);
|
||||
}
|
||||
else
|
||||
{
|
||||
dictionary[footballPlayer.TeamKey].Add(footballPlayer);
|
||||
}
|
||||
}
|
||||
foreach (List<RPPlayer> value2 in dictionary.Values)
|
||||
{
|
||||
list.Add(new Tuple<RPPlayer[], int>(value2.ToArray(), GetScore(value2[0], gameTime)));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (RPPlayer player in Mission.Players)
|
||||
{
|
||||
list.Add(new Tuple<RPPlayer[], int>(new RPPlayer[1] { player }, GetScore(player, gameTime)));
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < list.Count - 1; i++)
|
||||
{
|
||||
for (int j = i + 1; j < list.Count; j++)
|
||||
{
|
||||
if (list[i].B < list[j].B || (list[i].B == list[j].B && string.CompareOrdinal(list[i].A[0].Name, list[j].A[0].Name) > 0))
|
||||
{
|
||||
Tuple<RPPlayer[], int> value = list[i];
|
||||
list[i] = list[j];
|
||||
list[j] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
List<RPPlayer[]> list2 = new List<RPPlayer[]>();
|
||||
foreach (Tuple<RPPlayer[], int> item in list)
|
||||
{
|
||||
list2.Add(item.A);
|
||||
}
|
||||
return list2.ToArray();
|
||||
}
|
||||
|
||||
public PrintDocument GetPrintDocument()
|
||||
{
|
||||
return new RPPrintDocument(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal abstract class RPParticipant
|
||||
{
|
||||
private readonly string mPodHostAddress;
|
||||
|
||||
private readonly HostType mHostType;
|
||||
|
||||
public string PodHostAddress => mPodHostAddress;
|
||||
|
||||
public HostType HostType => mHostType;
|
||||
|
||||
protected RPParticipant(string podHostAddress, HostType hostType)
|
||||
{
|
||||
mPodHostAddress = podHostAddress;
|
||||
mHostType = hostType;
|
||||
}
|
||||
|
||||
public void AppendParticipant(int index, StringBuilder sb)
|
||||
{
|
||||
sb.AppendFormat("[{0}]\n", mPodHostAddress);
|
||||
sb.AppendFormat("hostType={0}\n", (int)mHostType);
|
||||
AppendParticipantSpecificData(index, sb);
|
||||
}
|
||||
|
||||
protected abstract void AppendParticipantSpecificData(int index, StringBuilder sb);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal abstract class RPPlayer : RPParticipant
|
||||
{
|
||||
private readonly string mName;
|
||||
|
||||
private readonly string mVehicleKey;
|
||||
|
||||
private readonly string mColorKey;
|
||||
|
||||
private readonly string mBadgeKey;
|
||||
|
||||
public string Name => mName;
|
||||
|
||||
public string VehicleKey => mVehicleKey;
|
||||
|
||||
public string ColorKey => mColorKey;
|
||||
|
||||
public string BadgeKey => mBadgeKey;
|
||||
|
||||
protected RPPlayer(string podHostAddress, string name, string vehicleKey, string colorKey, string badgeKey)
|
||||
: base(podHostAddress, HostType.GameMachineHostType)
|
||||
{
|
||||
if (podHostAddress == null)
|
||||
{
|
||||
throw new ArgumentNullException("podHostAddress");
|
||||
}
|
||||
if (name == null)
|
||||
{
|
||||
throw new ArgumentNullException("name");
|
||||
}
|
||||
if (vehicleKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("vehicleKey");
|
||||
}
|
||||
if (colorKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("colorKey");
|
||||
}
|
||||
if (badgeKey == null)
|
||||
{
|
||||
throw new ArgumentNullException("badgeKey");
|
||||
}
|
||||
mName = name;
|
||||
mVehicleKey = vehicleKey;
|
||||
mColorKey = colorKey;
|
||||
mBadgeKey = badgeKey;
|
||||
}
|
||||
|
||||
protected sealed override void AppendParticipantSpecificData(int index, StringBuilder sb)
|
||||
{
|
||||
sb.Append("dropzone=one\n");
|
||||
sb.AppendFormat("name={0}\n", mName);
|
||||
sb.AppendFormat("bitmapindex={0}\n", index);
|
||||
sb.Append("loadzones=1\n");
|
||||
sb.AppendFormat("vehicle={0}\n", mVehicleKey);
|
||||
sb.AppendFormat("color={0}\n", mColorKey);
|
||||
sb.AppendFormat("badge={0}\n", mBadgeKey);
|
||||
AppendMissionSpecificPilot(index, sb);
|
||||
}
|
||||
|
||||
protected abstract void AppendMissionSpecificPilot(int index, StringBuilder sb);
|
||||
}
|
||||
@@ -0,0 +1,816 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Printing;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class RPPrintDocument : PrintDocument
|
||||
{
|
||||
private const int sThinBorderSize = 3;
|
||||
|
||||
private const int sThickBorderSize = 14;
|
||||
|
||||
private const int sChampherSize = 14;
|
||||
|
||||
private const double sSmallRectWidthDropFraction = 0.5721493440968718;
|
||||
|
||||
private const double sSmallRectHeightDropFraction = 245.0 / 372.0;
|
||||
|
||||
private const string sSansSerifFontName = "Helvetica LT Std";
|
||||
|
||||
private const string sSerifFontName = "Courier New";
|
||||
|
||||
private readonly RPMissionResults mMissionResults;
|
||||
|
||||
private readonly RPPlayer[][] mFinalRanking;
|
||||
|
||||
private readonly RPPlayer[] mPrintOrder;
|
||||
|
||||
private int mCurrentPlayer;
|
||||
|
||||
private Dictionary<RPPlayer, List<Point>> mPlayerLines;
|
||||
|
||||
private int[] mChartRows;
|
||||
|
||||
private Dictionary<TimeSpan, int> mChartCols;
|
||||
|
||||
internal RPPrintDocument(RPMissionResults missionResults)
|
||||
{
|
||||
mMissionResults = missionResults;
|
||||
base.DocumentName = string.Format("Red Planet {0} mission at {1} on {2}", (mMissionResults.Mission is RPFootballMission) ? "Football" : "Death Race", mMissionResults.MissionStart.ToLongTimeString(), mMissionResults.MissionStart.ToLongDateString());
|
||||
mFinalRanking = mMissionResults.GetChartOrder();
|
||||
List<RPPlayer> list = new List<RPPlayer>();
|
||||
for (int i = 0; i < mFinalRanking.Length; i++)
|
||||
{
|
||||
list.Add(mFinalRanking[i][0]);
|
||||
}
|
||||
for (int j = 0; j < mFinalRanking.Length; j++)
|
||||
{
|
||||
for (int k = 1; k < mFinalRanking[j].Length; k++)
|
||||
{
|
||||
list.Add(mFinalRanking[j][k]);
|
||||
}
|
||||
}
|
||||
mPrintOrder = list.ToArray();
|
||||
}
|
||||
|
||||
protected override void OnQueryPageSettings(QueryPageSettingsEventArgs e)
|
||||
{
|
||||
e.PageSettings.Margins = new Margins(50, 50, 50, 50);
|
||||
e.PageSettings.Landscape = true;
|
||||
base.OnQueryPageSettings(e);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
protected override void OnBeginPrint(PrintEventArgs e)
|
||||
{
|
||||
mCurrentPlayer = 0;
|
||||
base.OnBeginPrint(e);
|
||||
}
|
||||
|
||||
protected override void OnPrintPage(PrintPageEventArgs e)
|
||||
{
|
||||
RPPlayer rPPlayer = mPrintOrder[mCurrentPlayer];
|
||||
List<MissionEvent> list = new List<MissionEvent>();
|
||||
foreach (MissionEvent @event in mMissionResults.Events)
|
||||
{
|
||||
if (Contains(@event.InvolvedPilots, rPPlayer))
|
||||
{
|
||||
list.Add(@event);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < list.Count - 1; i++)
|
||||
{
|
||||
for (int j = i + 1; j < list.Count; j++)
|
||||
{
|
||||
if (list[i].GameTime > list[j].GameTime)
|
||||
{
|
||||
MissionEvent value = list[i];
|
||||
list[i] = list[j];
|
||||
list[j] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
int score = mMissionResults.GetScore(rPPlayer);
|
||||
int finalPlace = mMissionResults.GetFinalPlace(rPPlayer);
|
||||
Size size = new Size(e.PageBounds.Width - 100, e.PageBounds.Height - 100);
|
||||
if (size.Width > e.MarginBounds.Width)
|
||||
{
|
||||
size.Width = e.MarginBounds.Width;
|
||||
}
|
||||
if (size.Height > e.MarginBounds.Height)
|
||||
{
|
||||
size.Height = e.MarginBounds.Height;
|
||||
}
|
||||
Rectangle rectangle = new Rectangle((e.MarginBounds.Width - size.Width) / 2 + e.MarginBounds.Left, (e.MarginBounds.Height - size.Height) / 2 + e.MarginBounds.Top, size.Width, size.Height);
|
||||
Rectangle inputRect = rectangle;
|
||||
inputRect.Inflate(-14, -14);
|
||||
Rectangle rectangle2 = rectangle;
|
||||
rectangle2.Inflate(-3, -3);
|
||||
Rectangle inputRect2 = rectangle2;
|
||||
inputRect2.Inflate(-14, -14);
|
||||
Rectangle rectangle3 = rectangle2;
|
||||
rectangle3.Inflate(-7, -7);
|
||||
Rectangle inputRect3 = rectangle3;
|
||||
inputRect3.Inflate(-14, -14);
|
||||
Rectangle rectangle4 = rectangle2;
|
||||
rectangle4.Inflate(-14, -14);
|
||||
Rectangle inputRect4 = rectangle4;
|
||||
inputRect4.Inflate(-14, -14);
|
||||
Rectangle rectangle5 = rectangle4;
|
||||
rectangle5.Inflate(-3, -3);
|
||||
Rectangle inputRect5 = rectangle5;
|
||||
inputRect5.Inflate(-14, -14);
|
||||
int widthDrop = (int)(0.5721493440968718 * (double)rectangle3.Width + 0.5);
|
||||
int heightDrop = (int)(245.0 / 372.0 * (double)rectangle3.Height + 0.5);
|
||||
Rectangle rectangle6 = RectDrop(rectangle, widthDrop, heightDrop);
|
||||
Rectangle rectangle7 = RectDrop(inputRect, widthDrop, heightDrop);
|
||||
Rectangle rectangle8 = RectDrop(rectangle2, widthDrop, heightDrop);
|
||||
Rectangle rectangle9 = RectDrop(inputRect2, widthDrop, heightDrop);
|
||||
Rectangle rectangle10 = RectDrop(rectangle3, widthDrop, heightDrop);
|
||||
Rectangle rectangle11 = RectDrop(inputRect3, widthDrop, heightDrop);
|
||||
Rectangle rectangle12 = RectDrop(rectangle4, widthDrop, heightDrop);
|
||||
Rectangle rectangle13 = RectDrop(inputRect4, widthDrop, heightDrop);
|
||||
Rectangle rectangle14 = RectDrop(rectangle5, widthDrop, heightDrop);
|
||||
Rectangle rectangle15 = RectDrop(inputRect5, widthDrop, heightDrop);
|
||||
using (GraphicsPath graphicsPath = new GraphicsPath())
|
||||
{
|
||||
graphicsPath.AddLine(rectangle.Left, inputRect.Bottom, rectangle.Left, inputRect.Top);
|
||||
graphicsPath.AddLine(inputRect.Left, rectangle.Top, inputRect.Right, rectangle.Top);
|
||||
graphicsPath.AddLine(rectangle3.Right, rectangle3.Top, inputRect3.Left, rectangle3.Top);
|
||||
graphicsPath.AddLine(rectangle3.Left, inputRect3.Top, rectangle3.Left, rectangle3.Bottom);
|
||||
graphicsPath.StartFigure();
|
||||
graphicsPath.AddLine(rectangle3.Left, inputRect5.Bottom, rectangle5.Left, inputRect5.Bottom);
|
||||
graphicsPath.AddLine(inputRect5.Left, rectangle5.Bottom, inputRect5.Right, rectangle5.Bottom);
|
||||
graphicsPath.AddLine(rectangle5.Right, inputRect5.Bottom, rectangle5.Right, rectangle3.Top);
|
||||
graphicsPath.AddLine(rectangle3.Right, rectangle3.Top, rectangle3.Right, inputRect3.Bottom);
|
||||
graphicsPath.AddLine(inputRect3.Right, rectangle3.Bottom, rectangle3.Left, rectangle3.Bottom);
|
||||
graphicsPath.StartFigure();
|
||||
graphicsPath.AddLine(rectangle10.Left, rectangle15.Bottom, rectangle14.Left, rectangle15.Bottom);
|
||||
graphicsPath.AddLine(rectangle15.Left, rectangle14.Bottom, rectangle15.Right, rectangle14.Bottom);
|
||||
graphicsPath.AddLine(rectangle14.Right, rectangle15.Bottom, rectangle14.Right, rectangle10.Top);
|
||||
graphicsPath.AddLine(rectangle10.Right, rectangle10.Top, rectangle10.Right, rectangle11.Bottom);
|
||||
graphicsPath.AddLine(rectangle11.Right, rectangle10.Bottom, rectangle10.Left, rectangle10.Bottom);
|
||||
e.Graphics.FillPath(Brushes.LightGray, graphicsPath);
|
||||
}
|
||||
using (GraphicsPath graphicsPath2 = new GraphicsPath())
|
||||
{
|
||||
graphicsPath2.AddLine(rectangle2.Left, inputRect2.Bottom, rectangle.Left, inputRect.Bottom);
|
||||
graphicsPath2.AddLine(inputRect.Left, rectangle.Bottom, inputRect.Right, rectangle.Bottom);
|
||||
graphicsPath2.AddLine(rectangle.Right, inputRect.Bottom, rectangle.Right, inputRect.Top);
|
||||
graphicsPath2.AddLine(inputRect.Right, rectangle.Top, inputRect2.Right, rectangle2.Top);
|
||||
graphicsPath2.AddLine(inputRect2.Right, rectangle3.Top, rectangle3.Right, inputRect3.Top);
|
||||
graphicsPath2.AddLine(rectangle3.Right, inputRect3.Bottom, inputRect3.Right, rectangle3.Bottom);
|
||||
graphicsPath2.AddLine(inputRect2.Left, rectangle3.Bottom, rectangle3.Left, inputRect2.Bottom);
|
||||
graphicsPath2.StartFigure();
|
||||
graphicsPath2.AddLine(rectangle12.Left, rectangle13.Bottom, rectangle14.Left, rectangle15.Bottom);
|
||||
graphicsPath2.AddLine(rectangle14.Left, rectangle15.Top, rectangle15.Left, rectangle14.Top);
|
||||
graphicsPath2.AddLine(rectangle15.Right, rectangle14.Top, rectangle14.Right, rectangle15.Top);
|
||||
graphicsPath2.AddLine(rectangle12.Right, rectangle13.Top, rectangle10.Right, rectangle13.Top);
|
||||
graphicsPath2.AddLine(rectangle10.Right, rectangle10.Top, rectangle11.Left, rectangle10.Top);
|
||||
graphicsPath2.AddLine(rectangle10.Left, rectangle11.Top, rectangle10.Left, rectangle13.Bottom);
|
||||
graphicsPath2.StartFigure();
|
||||
graphicsPath2.AddLine(rectangle4.Left, inputRect4.Bottom, rectangle5.Left, inputRect5.Bottom);
|
||||
graphicsPath2.AddLine(rectangle5.Left, rectangle6.Bottom + 14, inputRect5.Left, rectangle6.Bottom);
|
||||
graphicsPath2.AddLine(rectangle7.Right, rectangle6.Bottom, rectangle6.Right, rectangle7.Bottom);
|
||||
graphicsPath2.AddLine(rectangle6.Right, inputRect5.Top, rectangle6.Right + 14, rectangle5.Top);
|
||||
graphicsPath2.AddLine(inputRect5.Right, rectangle5.Top, rectangle5.Right, inputRect5.Top);
|
||||
graphicsPath2.AddLine(rectangle4.Right, inputRect4.Top, rectangle3.Right, inputRect4.Top);
|
||||
graphicsPath2.AddLine(rectangle3.Right, inputRect3.Top, inputRect3.Right, rectangle3.Top);
|
||||
graphicsPath2.AddLine(rectangle10.Right, rectangle3.Top, rectangle10.Right, rectangle11.Bottom);
|
||||
graphicsPath2.AddLine(rectangle11.Right, rectangle10.Bottom, inputRect3.Left, rectangle10.Bottom);
|
||||
graphicsPath2.AddLine(rectangle3.Left, rectangle10.Bottom, rectangle3.Left, inputRect4.Bottom);
|
||||
e.Graphics.FillPath(Brushes.DarkGray, graphicsPath2);
|
||||
}
|
||||
using (GraphicsPath graphicsPath3 = new GraphicsPath())
|
||||
{
|
||||
graphicsPath3.AddLine(rectangle2.Left, inputRect2.Bottom, rectangle2.Left, inputRect2.Top);
|
||||
graphicsPath3.AddLine(inputRect2.Left, rectangle2.Top, inputRect2.Right, rectangle2.Top);
|
||||
graphicsPath3.AddLine(rectangle2.Right, inputRect2.Top, rectangle2.Right, inputRect2.Bottom);
|
||||
graphicsPath3.AddLine(inputRect2.Right, rectangle2.Bottom, inputRect2.Left, rectangle2.Bottom);
|
||||
graphicsPath3.StartFigure();
|
||||
graphicsPath3.AddLine(rectangle12.Left, rectangle13.Bottom, rectangle12.Left, rectangle13.Top);
|
||||
graphicsPath3.AddLine(rectangle13.Left, rectangle12.Top, rectangle13.Right, rectangle12.Top);
|
||||
graphicsPath3.AddLine(rectangle12.Right, rectangle13.Top, rectangle12.Right, rectangle13.Bottom);
|
||||
graphicsPath3.AddLine(rectangle13.Right, rectangle12.Bottom, rectangle13.Left, rectangle12.Bottom);
|
||||
graphicsPath3.StartFigure();
|
||||
graphicsPath3.AddLine(rectangle4.Left, inputRect4.Bottom, rectangle4.Left, rectangle8.Bottom + 14);
|
||||
graphicsPath3.AddLine(rectangle13.Left, rectangle8.Bottom, rectangle9.Right, rectangle8.Bottom);
|
||||
graphicsPath3.AddLine(rectangle8.Right, rectangle9.Bottom, rectangle8.Right, inputRect4.Top);
|
||||
graphicsPath3.AddLine(rectangle8.Right + 14, rectangle4.Top, inputRect4.Right, rectangle4.Top);
|
||||
graphicsPath3.AddLine(rectangle4.Right, inputRect4.Top, rectangle4.Right, inputRect4.Bottom);
|
||||
graphicsPath3.AddLine(inputRect4.Right, rectangle4.Bottom, inputRect4.Left, rectangle4.Bottom);
|
||||
e.Graphics.FillPath(Brushes.Gray, graphicsPath3);
|
||||
}
|
||||
using Font font3 = new Font("Helvetica LT Std", 12f);
|
||||
using Font font = new Font("Helvetica LT Std", 8f);
|
||||
Rectangle rectangle16 = rectangle14;
|
||||
rectangle16.X += 175;
|
||||
rectangle16.Width -= 178;
|
||||
rectangle16.Y += 58;
|
||||
rectangle16.Height -= 86;
|
||||
RPVehicle rPVehicle = (RPConfig.Vehicles.ContainsKey(rPPlayer.VehicleKey) ? RPConfig.Vehicles[rPPlayer.VehicleKey] : null);
|
||||
Image image = rPVehicle?.Image;
|
||||
if (image != null)
|
||||
{
|
||||
e.Graphics.DrawImage(image, GetCenteredScaledRect(rectangle16, image.Size));
|
||||
}
|
||||
else
|
||||
{
|
||||
StringFormat stringFormat = new StringFormat();
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
stringFormat.Alignment = StringAlignment.Center;
|
||||
using (StringFormat format = stringFormat)
|
||||
{
|
||||
Rectangle rectangle17 = rectangle16;
|
||||
rectangle17.Inflate(-20, -20);
|
||||
e.Graphics.DrawString("Null-flux resonation is disrupting contact with the camera drone. Recon immagry could not be obtained for this vehicle.", font, Brushes.Black, rectangle17, format);
|
||||
}
|
||||
e.Graphics.DrawRectangle(Pens.Black, rectangle16);
|
||||
}
|
||||
using (Font font2 = new Font("Helvetica LT Std", 18f, FontStyle.Bold))
|
||||
{
|
||||
using StringFormat stringFormat2 = new StringFormat();
|
||||
stringFormat2.Alignment = StringAlignment.Center;
|
||||
stringFormat2.LineAlignment = StringAlignment.Far;
|
||||
e.Graphics.DrawString(rPPlayer.Name, font2, Brushes.Black, rectangle14.Left + rectangle14.Width / 2, rectangle16.Top - 10, stringFormat2);
|
||||
}
|
||||
using (StringFormat stringFormat3 = new StringFormat())
|
||||
{
|
||||
stringFormat3.Alignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString((rPVehicle != null) ? rPVehicle.Name : rPPlayer.VehicleKey, font3, Brushes.Black, rectangle16.Left + rectangle16.Width / 2, rectangle16.Bottom + 5, stringFormat3);
|
||||
}
|
||||
int num = rectangle15.Left - 7;
|
||||
Rectangle rectangle18 = new Rectangle(num, rectangle16.Top, rectangle16.Left - num, rectangle15.Bottom - rectangle16.Top);
|
||||
using (Font font4 = new Font("Helvetica LT Std", 16f, FontStyle.Bold))
|
||||
{
|
||||
using StringFormat stringFormat4 = new StringFormat();
|
||||
stringFormat4.Alignment = StringAlignment.Center;
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
if (rPPlayer is RPFootballPlayer)
|
||||
{
|
||||
RPFootballPlayer rPFootballPlayer = (RPFootballPlayer)rPPlayer;
|
||||
stringBuilder.AppendLine(RPConfig.Football.Teams.ContainsKey(rPFootballPlayer.TeamKey) ? RPConfig.Football.Teams[rPFootballPlayer.TeamKey].Name : rPFootballPlayer.TeamKey);
|
||||
stringBuilder.AppendLine(RPConfig.Football.Positions.ContainsKey(rPFootballPlayer.PositionKey) ? RPConfig.Football.Positions[rPFootballPlayer.PositionKey] : rPFootballPlayer.PositionKey);
|
||||
}
|
||||
stringBuilder.AppendLine(string.Format("{0}{1} Place", finalPlace, finalPlace switch
|
||||
{
|
||||
3 => "rd",
|
||||
2 => "nd",
|
||||
1 => "st",
|
||||
_ => "th",
|
||||
}));
|
||||
e.Graphics.DrawString(stringBuilder.ToString(), font4, Brushes.Black, rectangle18, stringFormat4);
|
||||
}
|
||||
using (StringFormat stringFormat5 = new StringFormat())
|
||||
{
|
||||
stringFormat5.LineAlignment = StringAlignment.Far;
|
||||
stringFormat5.SetTabStops(0f, new float[1] { 80f });
|
||||
int laps = 0;
|
||||
TimeSpan fastestLap = TimeSpan.Zero;
|
||||
int deaths = 0;
|
||||
int kills = 0;
|
||||
GetPlayerStats(out laps, out fastestLap, out deaths, out kills, rPPlayer, list);
|
||||
StringBuilder stringBuilder2 = new StringBuilder();
|
||||
if (rPPlayer is RPFootballPlayer)
|
||||
{
|
||||
stringBuilder2.AppendLine($"Team Score:\t{score}");
|
||||
stringBuilder2.AppendLine();
|
||||
}
|
||||
else
|
||||
{
|
||||
stringBuilder2.AppendLine($"Score:\t{score}");
|
||||
stringBuilder2.AppendLine();
|
||||
stringBuilder2.AppendLine($"Laps:\t{laps}");
|
||||
stringBuilder2.AppendLine();
|
||||
stringBuilder2.AppendLine($"Fastest Lap:\t{RPStrings.GetTimeString(fastestLap)}");
|
||||
stringBuilder2.AppendLine();
|
||||
}
|
||||
stringBuilder2.AppendLine($"Deaths:\t{deaths}");
|
||||
stringBuilder2.AppendLine();
|
||||
stringBuilder2.AppendLine($"Kills:\t{kills}");
|
||||
e.Graphics.DrawString(stringBuilder2.ToString(), font, Brushes.Black, rectangle18, stringFormat5);
|
||||
}
|
||||
int num2 = rectangle5.Top + 40;
|
||||
Rectangle rectangle19 = new Rectangle(rectangle6.Right + 5, num2, rectangle5.Right - rectangle6.Right - 10, rectangle6.Bottom - 5 - num2);
|
||||
using (StringFormat stringFormat6 = new StringFormat())
|
||||
{
|
||||
stringFormat6.Alignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString("Mission Highlights", font3, Brushes.Black, (rectangle19.Right + rectangle19.Left) / 2, rectangle5.Top + 15, stringFormat6);
|
||||
}
|
||||
using (Font font5 = new Font("Courier New", 10f))
|
||||
{
|
||||
string text = mMissionResults.mMissionStart.ToString() + " ";
|
||||
string s = text;
|
||||
string text2 = "";
|
||||
if (mMissionResults.Mission is RPRaceMission)
|
||||
{
|
||||
List<string> list2 = new List<string>();
|
||||
RPPlayer[][] array = mFinalRanking;
|
||||
foreach (RPPlayer[] array2 in array)
|
||||
{
|
||||
list2.Add(array2[0].Name);
|
||||
}
|
||||
text2 = RPStrings.Recap(list2.ToArray());
|
||||
}
|
||||
Random random = new Random();
|
||||
List<MissionEvent> list3 = new List<MissionEvent>(list);
|
||||
SortedList<TimeSpan, string> sortedList = new SortedList<TimeSpan, string>();
|
||||
string text3 = text + text2;
|
||||
while (e.Graphics.MeasureString(text3, font5, rectangle19.Width).Height < (float)rectangle19.Height)
|
||||
{
|
||||
s = text3;
|
||||
if (list3.Count < 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int index = random.Next(list3.Count);
|
||||
MissionEvent missionEvent = list3[index];
|
||||
list3.RemoveAt(index);
|
||||
string text4 = null;
|
||||
if (missionEvent is BoostEvent && ((BoostEvent)missionEvent).BoosterOn == 1)
|
||||
{
|
||||
text4 = RPStrings.Boost(missionEvent.GameTime, missionEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(missionEvent.ReportingPilot.VehicleKey));
|
||||
}
|
||||
else if (missionEvent is ScoredEvent)
|
||||
{
|
||||
text4 = RPStrings.Score(missionEvent.GameTime, missionEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(missionEvent.ReportingPilot.VehicleKey));
|
||||
}
|
||||
else if (missionEvent is DamagedEvent)
|
||||
{
|
||||
DamagedEvent damagedEvent = (DamagedEvent)missionEvent;
|
||||
if (damagedEvent.DamageLoss > 0)
|
||||
{
|
||||
text4 = ((damagedEvent.DamageLoss < 10) ? RPStrings.LightDamage(damagedEvent.GameTime, damagedEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(damagedEvent.ReportingPilot.VehicleKey), damagedEvent.Damager.Name) : ((damagedEvent.DamageLoss >= 100) ? RPStrings.HeavyDamage(damagedEvent.GameTime, damagedEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(damagedEvent.ReportingPilot.VehicleKey), damagedEvent.Damager.Name) : RPStrings.ModerateDamage(damagedEvent.GameTime, damagedEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(damagedEvent.ReportingPilot.VehicleKey), damagedEvent.Damager.Name)));
|
||||
}
|
||||
}
|
||||
else if (missionEvent is KilledEvent)
|
||||
{
|
||||
KilledEvent killedEvent = (KilledEvent)missionEvent;
|
||||
text4 = ((killedEvent.ReportingPilot != killedEvent.Killer) ? RPStrings.Kill(killedEvent.GameTime, killedEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(killedEvent.ReportingPilot.VehicleKey), killedEvent.Killer.Name) : RPStrings.SelfKill(killedEvent.GameTime, killedEvent.ReportingPilot.Name, RPConfig.VehicleNameOrKey(killedEvent.ReportingPilot.VehicleKey)));
|
||||
}
|
||||
if (text4 != null)
|
||||
{
|
||||
TimeSpan gameTime;
|
||||
for (gameTime = missionEvent.GameTime; sortedList.ContainsKey(gameTime); gameTime += TimeSpan.FromTicks(1L))
|
||||
{
|
||||
}
|
||||
sortedList.Add(gameTime, text4);
|
||||
}
|
||||
StringBuilder stringBuilder3 = new StringBuilder(text);
|
||||
foreach (KeyValuePair<TimeSpan, string> item in sortedList)
|
||||
{
|
||||
if (stringBuilder3.Length > 0)
|
||||
{
|
||||
stringBuilder3.Append(" ");
|
||||
}
|
||||
stringBuilder3.Append(item.Value);
|
||||
}
|
||||
if (stringBuilder3.Length > 0)
|
||||
{
|
||||
stringBuilder3.Append(" ");
|
||||
}
|
||||
stringBuilder3.Append(text2);
|
||||
text3 = stringBuilder3.ToString();
|
||||
}
|
||||
e.Graphics.DrawString(s, font5, Brushes.Black, rectangle19);
|
||||
}
|
||||
int num3 = rectangle6.Bottom + 5;
|
||||
Rectangle rectangle20 = new Rectangle(inputRect5.Left, num3, inputRect5.Width, rectangle5.Bottom - num3);
|
||||
Rectangle rectangle21 = new Rectangle(rectangle20.Right - 250, rectangle20.Top, 250, rectangle20.Height - 20);
|
||||
Image image2 = (RPConfig.Maps.ContainsKey(mMissionResults.Mission.MapKey) ? RPConfig.Maps[mMissionResults.Mission.MapKey] : null)?.Image;
|
||||
if (image2 != null)
|
||||
{
|
||||
e.Graphics.DrawImage(image2, GetCenteredScaledRect(rectangle21, image2.Size));
|
||||
}
|
||||
else
|
||||
{
|
||||
StringFormat stringFormat7 = new StringFormat();
|
||||
stringFormat7.LineAlignment = StringAlignment.Center;
|
||||
stringFormat7.Alignment = StringAlignment.Center;
|
||||
using (StringFormat format2 = stringFormat7)
|
||||
{
|
||||
Rectangle rectangle22 = rectangle21;
|
||||
rectangle22.Inflate(-20, -20);
|
||||
e.Graphics.DrawString("The surveillance satellite is currently on a transitional orbit. Satellite imagery could not be obtained for this map.", font, Brushes.Black, rectangle22, format2);
|
||||
}
|
||||
e.Graphics.DrawRectangle(Pens.Black, rectangle21);
|
||||
}
|
||||
Rectangle rect = new Rectangle(rectangle20.Left, rectangle20.Top, rectangle21.Left - 5 - rectangle20.Left, 92);
|
||||
Dictionary<RPPlayer, int[]> dictionary = new Dictionary<RPPlayer, int[]>();
|
||||
foreach (RPPlayer player in mMissionResults.Mission.Players)
|
||||
{
|
||||
if (player != rPPlayer)
|
||||
{
|
||||
dictionary.Add(player, new int[4]);
|
||||
}
|
||||
}
|
||||
foreach (MissionEvent event2 in mMissionResults.Events)
|
||||
{
|
||||
if (event2 is KilledEvent)
|
||||
{
|
||||
KilledEvent killedEvent2 = (KilledEvent)event2;
|
||||
if (killedEvent2.ReportingPilot != killedEvent2.Killer)
|
||||
{
|
||||
if (killedEvent2.Killer == rPPlayer)
|
||||
{
|
||||
dictionary[killedEvent2.ReportingPilot][3]++;
|
||||
}
|
||||
else if (killedEvent2.ReportingPilot == rPPlayer)
|
||||
{
|
||||
dictionary[killedEvent2.Killer][2]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!(event2 is DamagedEvent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
DamagedEvent damagedEvent2 = (DamagedEvent)event2;
|
||||
if (damagedEvent2.ReportingPilot != damagedEvent2.Damager)
|
||||
{
|
||||
if (damagedEvent2.Damager == rPPlayer)
|
||||
{
|
||||
dictionary[damagedEvent2.ReportingPilot][1] += damagedEvent2.DamageLoss;
|
||||
}
|
||||
else if (damagedEvent2.ReportingPilot == rPPlayer)
|
||||
{
|
||||
dictionary[damagedEvent2.Damager][0] += damagedEvent2.DamageLoss;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using (Pen pen = new Pen(Color.Gray, 2f))
|
||||
{
|
||||
using Font font6 = new Font("Helvetica LT Std", 6f, FontStyle.Regular);
|
||||
using StringFormat stringFormat8 = new StringFormat();
|
||||
e.Graphics.DrawRectangle(Pens.Gray, rect);
|
||||
int num4 = 120;
|
||||
int num5 = 14;
|
||||
int num6 = rect.Left + 1;
|
||||
int num7 = rect.Left + num4;
|
||||
int num8 = (rect.Width - num4) / Math.Max(1, dictionary.Count);
|
||||
if (dictionary.Count == 0)
|
||||
{
|
||||
e.Graphics.DrawLine(pen, num7, rect.Top, num7, rect.Bottom);
|
||||
}
|
||||
int num9 = rect.Bottom;
|
||||
for (int l = 0; l < 5; l++)
|
||||
{
|
||||
num9 -= num5;
|
||||
e.Graphics.DrawLine(Pens.Gray, rect.Left, num9, rect.Right, num9);
|
||||
}
|
||||
int num10 = rect.Top + 1;
|
||||
stringFormat8.LineAlignment = StringAlignment.Near;
|
||||
e.Graphics.DrawString("Pilot", font6, Brushes.Black, num6, num10, stringFormat8);
|
||||
int num11 = rect.Bottom - num5 / 2;
|
||||
int num12 = num11 - num5;
|
||||
int num13 = num12 - num5;
|
||||
int num14 = num13 - num5;
|
||||
int num15 = num14 - num5;
|
||||
stringFormat8.LineAlignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString("Score", font6, Brushes.Black, num6, num15, stringFormat8);
|
||||
e.Graphics.DrawString("Damage You Received From", font6, Brushes.Black, num6, num14, stringFormat8);
|
||||
e.Graphics.DrawString("Damage You Inflicted On", font6, Brushes.Black, num6, num13, stringFormat8);
|
||||
e.Graphics.DrawString("Times You Were Killed By", font6, Brushes.Black, num6, num12, stringFormat8);
|
||||
e.Graphics.DrawString("Times You Killed", font6, Brushes.Black, num6, num11, stringFormat8);
|
||||
int num16 = num7;
|
||||
foreach (KeyValuePair<RPPlayer, int[]> item2 in dictionary)
|
||||
{
|
||||
int num17 = num16 + 1;
|
||||
e.Graphics.DrawLine(pen, num16, rect.Top, num16, rect.Bottom);
|
||||
stringFormat8.LineAlignment = StringAlignment.Near;
|
||||
e.Graphics.DrawString(item2.Key.Name, font6, Brushes.Black, num17, num10, stringFormat8);
|
||||
stringFormat8.LineAlignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString(mMissionResults.GetScore(item2.Key).ToString(), font6, Brushes.Black, num17, num15, stringFormat8);
|
||||
e.Graphics.DrawString(item2.Value[0].ToString(), font6, Brushes.Black, num17, num14, stringFormat8);
|
||||
e.Graphics.DrawString(item2.Value[1].ToString(), font6, Brushes.Black, num17, num13, stringFormat8);
|
||||
e.Graphics.DrawString(item2.Value[2].ToString(), font6, Brushes.Black, num17, num12, stringFormat8);
|
||||
e.Graphics.DrawString(item2.Value[3].ToString(), font6, Brushes.Black, num17, num11, stringFormat8);
|
||||
num16 += num8;
|
||||
}
|
||||
}
|
||||
int num18 = rectangle20.Left + 60;
|
||||
int num19 = rect.Bottom + 120;
|
||||
Rectangle rectangle23 = new Rectangle(num18, num19, rect.Right - 75 - num18, rectangle20.Bottom - 85 - num19);
|
||||
if (mPlayerLines == null)
|
||||
{
|
||||
mPlayerLines = new Dictionary<RPPlayer, List<Point>>();
|
||||
RPPlayer[][] array = mFinalRanking;
|
||||
foreach (RPPlayer[] array3 in array)
|
||||
{
|
||||
RPPlayer[] array4 = array3;
|
||||
foreach (RPPlayer key in array4)
|
||||
{
|
||||
mPlayerLines.Add(key, new List<Point>());
|
||||
}
|
||||
}
|
||||
mChartRows = new int[mPlayerLines.Count];
|
||||
float num20 = (float)rectangle23.Height / (float)mPlayerLines.Count;
|
||||
for (int n = 0; n < mChartRows.Length; n++)
|
||||
{
|
||||
mChartRows[n] = (int)(num20 * (float)n + 0.5f) + rectangle23.Top;
|
||||
}
|
||||
mChartCols = new Dictionary<TimeSpan, int>();
|
||||
TimeSpan timeSpan = mMissionResults.ActuallMissionTime.Subtract(TimeSpan.FromSeconds(10.0));
|
||||
TimeSpan timeSpan2 = TimeSpan.FromSeconds(15.0);
|
||||
for (TimeSpan timeSpan3 = timeSpan2; timeSpan3 < timeSpan; timeSpan3 += timeSpan2)
|
||||
{
|
||||
mChartCols.Add(timeSpan3, (int)((float)timeSpan3.Ticks / (float)mMissionResults.ActuallMissionTime.Ticks * (float)rectangle23.Width + 0.5f) + rectangle23.Left);
|
||||
}
|
||||
int num21 = 0;
|
||||
array = mFinalRanking;
|
||||
foreach (RPPlayer[] array5 in array)
|
||||
{
|
||||
RPPlayer[] array4 = array5;
|
||||
foreach (RPPlayer key2 in array4)
|
||||
{
|
||||
mPlayerLines[key2].Add(new Point(rectangle23.Left, mChartRows[num21++]));
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<TimeSpan, int> mChartCol in mChartCols)
|
||||
{
|
||||
num21 = 0;
|
||||
array = mMissionResults.GetChartOrder(mChartCol.Key);
|
||||
foreach (RPPlayer[] array6 in array)
|
||||
{
|
||||
RPPlayer[] array4 = array6;
|
||||
foreach (RPPlayer key3 in array4)
|
||||
{
|
||||
mPlayerLines[key3].Add(new Point(mChartCol.Value, mChartRows[num21++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
num21 = 0;
|
||||
array = mFinalRanking;
|
||||
foreach (RPPlayer[] array7 in array)
|
||||
{
|
||||
RPPlayer[] array4 = array7;
|
||||
foreach (RPPlayer key4 in array4)
|
||||
{
|
||||
mPlayerLines[key4].Add(new Point(rectangle23.Right, mChartRows[num21++]));
|
||||
}
|
||||
}
|
||||
}
|
||||
using (Font font7 = new Font("Helvetica LT Std", 8f))
|
||||
{
|
||||
using (StringFormat stringFormat9 = new StringFormat())
|
||||
{
|
||||
stringFormat9.LineAlignment = StringAlignment.Center;
|
||||
foreach (KeyValuePair<RPPlayer, List<Point>> mPlayerLine in mPlayerLines)
|
||||
{
|
||||
if (mPlayerLine.Key != rPPlayer)
|
||||
{
|
||||
DrawPlayerLine(e.Graphics, mPlayerLine.Key, mPlayerLine.Value.ToArray(), rectangle23.Right + 5, Pens.LightGray, Brushes.LightGray, font7, stringFormat9);
|
||||
}
|
||||
}
|
||||
DrawPlayerLine(e.Graphics, rPPlayer, mPlayerLines[rPPlayer].ToArray(), rectangle23.Right + 5, Pens.Black, Brushes.Black, font7, stringFormat9);
|
||||
}
|
||||
using Pen pen2 = new Pen(Color.Black, 1.5f);
|
||||
using (Font font8 = new Font("Courier New", 8f))
|
||||
{
|
||||
int num22 = 5;
|
||||
int num23 = 3;
|
||||
e.Graphics.DrawLines(pen2, new Point[3]
|
||||
{
|
||||
new Point(rectangle23.Left, rectangle23.Top),
|
||||
new Point(rectangle23.Left, rectangle23.Bottom),
|
||||
new Point(rectangle23.Right, rectangle23.Bottom)
|
||||
});
|
||||
using StringFormat stringFormat10 = new StringFormat();
|
||||
stringFormat10.Alignment = StringAlignment.Far;
|
||||
stringFormat10.LineAlignment = StringAlignment.Center;
|
||||
int num24 = 0;
|
||||
int num25 = 0;
|
||||
RPPlayer[][] array = mFinalRanking;
|
||||
foreach (RPPlayer[] array8 in array)
|
||||
{
|
||||
int num26 = mChartRows[num25];
|
||||
e.Graphics.DrawLine(pen2, rectangle23.Left - num22, num26, rectangle23.Left + num22, num26);
|
||||
Graphics graphics = e.Graphics;
|
||||
int num27 = ++num25;
|
||||
graphics.DrawString(num27.ToString(), font8, Brushes.Black, rectangle23.Left - 10, num26, stringFormat10);
|
||||
RPPlayer[] array4 = array8;
|
||||
for (int m = 0; m < array4.Length; m++)
|
||||
{
|
||||
_ = array4[m];
|
||||
num24++;
|
||||
}
|
||||
}
|
||||
int num28 = rectangle23.Bottom + 23;
|
||||
stringFormat10.Alignment = StringAlignment.Center;
|
||||
stringFormat10.LineAlignment = StringAlignment.Near;
|
||||
e.Graphics.DrawString("0", font8, Brushes.Black, rectangle23.Left, num28, stringFormat10);
|
||||
foreach (KeyValuePair<TimeSpan, int> mChartCol2 in mChartCols)
|
||||
{
|
||||
if (mChartCol2.Key.Seconds == 0)
|
||||
{
|
||||
e.Graphics.DrawLine(pen2, mChartCol2.Value, rectangle23.Bottom - num22, mChartCol2.Value, rectangle23.Bottom + num22);
|
||||
e.Graphics.DrawString(mChartCol2.Key.Minutes.ToString(), font8, Brushes.Black, mChartCol2.Value, num28, stringFormat10);
|
||||
}
|
||||
else
|
||||
{
|
||||
e.Graphics.DrawLine(pen2, mChartCol2.Value, rectangle23.Bottom - num23, mChartCol2.Value, rectangle23.Bottom);
|
||||
}
|
||||
}
|
||||
e.Graphics.DrawLine(pen2, rectangle23.Right, rectangle23.Bottom - num22, rectangle23.Right, rectangle23.Bottom + num22);
|
||||
e.Graphics.DrawString(((int)(mMissionResults.ActuallMissionTime.TotalMinutes + 0.5)).ToString(), font8, Brushes.Black, rectangle23.Right, num28, stringFormat10);
|
||||
e.Graphics.DrawString("Time", font, Brushes.Black, (rectangle23.Left + rectangle23.Right) / 2, rectangle23.Bottom + 68, stringFormat10);
|
||||
stringFormat10.LineAlignment = StringAlignment.Center;
|
||||
e.Graphics.DrawString("P\r\nl\r\na\r\nc\r\ne", font, Brushes.Black, rectangle23.Left - 54, (rectangle23.Bottom + rectangle23.Top) / 2, stringFormat10);
|
||||
int num29 = rectangle23.Top - 70;
|
||||
int num30 = rectangle23.Left + 10;
|
||||
int num31 = (rectangle23.Right + rectangle23.Left) / 2 - 30;
|
||||
int num32 = rectangle23.Right - 85;
|
||||
stringFormat10.Alignment = StringAlignment.Near;
|
||||
DrawScoreMarker(e.Graphics, pen2, num30, num29, 15f);
|
||||
e.Graphics.DrawString("Score", font7, Brushes.Black, num30 + 15, num29, stringFormat10);
|
||||
DrawKillMarker(e.Graphics, pen2, num31, num29, 15f);
|
||||
e.Graphics.DrawString("Kill", font7, Brushes.Black, num31 + 15, num29, stringFormat10);
|
||||
DrawDeathMarker(e.Graphics, pen2, num32, num29, 15f);
|
||||
e.Graphics.DrawString("Death", font7, Brushes.Black, num32 + 15, num29, stringFormat10);
|
||||
}
|
||||
foreach (MissionEvent event3 in mMissionResults.Events)
|
||||
{
|
||||
if (event3 is ScoredEvent)
|
||||
{
|
||||
DrawScoreMarker(e.Graphics, (event3.ReportingPilot == rPPlayer) ? Pens.Black : Pens.LightGray, GetMarkerPosition(event3.GameTime, mPlayerLines[event3.ReportingPilot], rectangle23), 10f);
|
||||
}
|
||||
else if (event3 is KilledEvent)
|
||||
{
|
||||
KilledEvent killedEvent3 = (KilledEvent)event3;
|
||||
if (killedEvent3.Killer != killedEvent3.ReportingPilot)
|
||||
{
|
||||
DrawKillMarker(e.Graphics, (killedEvent3.ReportingPilot == rPPlayer || killedEvent3.Killer == rPPlayer) ? Pens.Black : Pens.LightGray, GetMarkerPosition(killedEvent3.GameTime, mPlayerLines[killedEvent3.Killer], rectangle23), 10f);
|
||||
}
|
||||
DrawDeathMarker(e.Graphics, (killedEvent3.ReportingPilot == rPPlayer || killedEvent3.Killer == rPPlayer) ? Pens.Black : Pens.LightGray, GetMarkerPosition(killedEvent3.GameTime, mPlayerLines[killedEvent3.ReportingPilot], rectangle23), 10f);
|
||||
}
|
||||
}
|
||||
}
|
||||
e.HasMorePages = ++mCurrentPlayer < mPrintOrder.Length;
|
||||
base.OnPrintPage(e);
|
||||
}
|
||||
|
||||
private PointF GetMarkerPosition(TimeSpan time, List<Point> chartLine, RectangleF chartArea)
|
||||
{
|
||||
TimeSpan timeSpan = TimeSpan.Zero;
|
||||
TimeSpan timeSpan2 = mMissionResults.ActuallMissionTime;
|
||||
int num = 0;
|
||||
foreach (KeyValuePair<TimeSpan, int> mChartCol in mChartCols)
|
||||
{
|
||||
timeSpan2 = mChartCol.Key;
|
||||
if (mChartCol.Key < time)
|
||||
{
|
||||
num++;
|
||||
timeSpan = timeSpan2;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (timeSpan == timeSpan2)
|
||||
{
|
||||
timeSpan2 = mMissionResults.ActuallMissionTime;
|
||||
}
|
||||
float num2 = ((float)time.Ticks - (float)timeSpan.Ticks) / ((float)timeSpan2.Ticks - (float)timeSpan.Ticks);
|
||||
PointF pointF = chartLine[num];
|
||||
PointF pointF2 = chartLine[num + 1];
|
||||
return new PointF((pointF2.X - pointF.X) * num2 + pointF.X, (pointF2.Y - pointF.Y) * num2 + pointF.Y);
|
||||
}
|
||||
|
||||
private static void DrawKillMarker(Graphics graphics, Pen pen, PointF point, float size)
|
||||
{
|
||||
DrawKillMarker(graphics, pen, point.X, point.Y, size);
|
||||
}
|
||||
|
||||
private static void DrawKillMarker(Graphics graphics, Pen pen, float x, float y, float size)
|
||||
{
|
||||
float y2 = y + size / 2f;
|
||||
graphics.DrawPolygon(pen, new PointF[3]
|
||||
{
|
||||
new PointF(x - size / 2f, y2),
|
||||
new PointF(x + size / 2f, y2),
|
||||
new PointF(x, y - size / 2f)
|
||||
});
|
||||
}
|
||||
|
||||
private static void DrawDeathMarker(Graphics graphics, Pen pen, PointF point, float size)
|
||||
{
|
||||
DrawDeathMarker(graphics, pen, point.X, point.Y, size);
|
||||
}
|
||||
|
||||
private static void DrawDeathMarker(Graphics graphics, Pen pen, float x, float y, float size)
|
||||
{
|
||||
graphics.DrawRectangle(pen, x - size / 2f, y - size / 2f, size, size);
|
||||
}
|
||||
|
||||
private static void DrawScoreMarker(Graphics graphics, Pen pen, PointF point, float size)
|
||||
{
|
||||
DrawScoreMarker(graphics, pen, point.X, point.Y, size);
|
||||
}
|
||||
|
||||
private static void DrawScoreMarker(Graphics graphics, Pen pen, float x, float y, float size)
|
||||
{
|
||||
graphics.DrawEllipse(pen, x - size / 2f, y - size / 2f, size, size);
|
||||
}
|
||||
|
||||
private static void DrawPlayerLine(Graphics graphics, RPPlayer player, Point[] points, int playerNameX, Pen pen, Brush brush, Font font, StringFormat format)
|
||||
{
|
||||
graphics.DrawLines(pen, points);
|
||||
graphics.DrawString(player.Name, font, brush, playerNameX, points[points.Length - 1].Y, format);
|
||||
}
|
||||
|
||||
private static void GetPlayerStats(out int laps, out TimeSpan fastestLap, out int deaths, out int kills, RPPlayer player, IEnumerable<MissionEvent> relaventEventsSorted)
|
||||
{
|
||||
laps = 0;
|
||||
fastestLap = TimeSpan.MaxValue;
|
||||
deaths = 0;
|
||||
kills = 0;
|
||||
bool flag = true;
|
||||
TimeSpan timeSpan = TimeSpan.Zero;
|
||||
foreach (MissionEvent item in relaventEventsSorted)
|
||||
{
|
||||
if (item.ReportingPilot == player)
|
||||
{
|
||||
if (item is ScoredEvent)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan timeSpan2 = item.GameTime - timeSpan;
|
||||
if (timeSpan2 < fastestLap)
|
||||
{
|
||||
fastestLap = timeSpan2;
|
||||
}
|
||||
laps++;
|
||||
}
|
||||
timeSpan = item.GameTime;
|
||||
}
|
||||
else if (item is KilledEvent)
|
||||
{
|
||||
flag = true;
|
||||
deaths++;
|
||||
}
|
||||
}
|
||||
else if (item is KilledEvent && ((KilledEvent)item).Killer == player)
|
||||
{
|
||||
kills++;
|
||||
}
|
||||
}
|
||||
if (fastestLap == TimeSpan.MaxValue)
|
||||
{
|
||||
fastestLap = TimeSpan.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawRedXBox(Graphics g, Rectangle rect)
|
||||
{
|
||||
g.DrawRectangle(Pens.Red, rect);
|
||||
g.DrawLine(Pens.Red, rect.Left, rect.Top, rect.Right, rect.Bottom);
|
||||
g.DrawLine(Pens.Red, rect.Left, rect.Bottom, rect.Right, rect.Top);
|
||||
}
|
||||
|
||||
private static Rectangle RectDrop(Rectangle inputRect, int widthDrop, int heightDrop)
|
||||
{
|
||||
return new Rectangle(inputRect.X, inputRect.Y, inputRect.Width - widthDrop, inputRect.Height - heightDrop);
|
||||
}
|
||||
|
||||
private static Rectangle GetCenteredScaledRect(Rectangle bounds, Size originalSize)
|
||||
{
|
||||
float num = (float)bounds.Width / (float)bounds.Height;
|
||||
float num2 = (float)originalSize.Width / (float)originalSize.Height;
|
||||
Size size = bounds.Size;
|
||||
if (num > num2)
|
||||
{
|
||||
size.Width = (int)((float)size.Height * num2 + 0.5f);
|
||||
}
|
||||
else
|
||||
{
|
||||
size.Height = (int)((float)size.Width / num2 + 0.5f);
|
||||
}
|
||||
return new Rectangle(bounds.X + (bounds.Width - size.Width) / 2, bounds.Y + (bounds.Height - size.Height) / 2, size.Width, size.Height);
|
||||
}
|
||||
|
||||
private static bool Contains(IEnumerable<RPPlayer> players, RPPlayer player)
|
||||
{
|
||||
foreach (RPPlayer player2 in players)
|
||||
{
|
||||
if (player2 == player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPRaceMission : RPMission
|
||||
{
|
||||
private readonly List<RPRacePlayer> mRacePlayers = new List<RPRacePlayer>();
|
||||
|
||||
public List<RPRacePlayer> RacePlayers => mRacePlayers;
|
||||
|
||||
public override IEnumerable<RPPlayer> Players => mRacePlayers.ToArray();
|
||||
|
||||
public override int PlayerCount => mRacePlayers.Count;
|
||||
|
||||
public RPRaceMission(string mapKey, string timeOfDayKey, string weatherKey, bool scoreCompression, TimeSpan gameLength)
|
||||
: base(RPConfig.DeathRace.Key, mapKey, timeOfDayKey, weatherKey, scoreCompression, gameLength)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void AppendMissionSpecificData(StringBuilder egg)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class RPRacePlayer : RPPlayer
|
||||
{
|
||||
public RPRacePlayer(string podHostAddress, string name, string vehicleKey, string colorKey, string badgeKey)
|
||||
: base(podHostAddress, name, vehicleKey, colorKey, badgeKey)
|
||||
{
|
||||
}
|
||||
|
||||
protected sealed override void AppendMissionSpecificPilot(int index, StringBuilder sb)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class RPTeam
|
||||
{
|
||||
private string mKey;
|
||||
|
||||
private string mName;
|
||||
|
||||
private string mRunnerColor;
|
||||
|
||||
private string mTeamColor;
|
||||
|
||||
public string Key => mKey;
|
||||
|
||||
public string Name => mName;
|
||||
|
||||
public string RunnerColor => mRunnerColor;
|
||||
|
||||
public string TeamColor => mTeamColor;
|
||||
|
||||
internal RPTeam(XmlNode teamNode)
|
||||
{
|
||||
mKey = teamNode.Attributes["key"].InnerText;
|
||||
mName = teamNode.Attributes["name"].InnerText;
|
||||
mRunnerColor = teamNode.Attributes["runnerColor"].InnerText;
|
||||
mTeamColor = teamNode.Attributes["teamColor"].InnerText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class RPVehicle
|
||||
{
|
||||
private readonly string mKey;
|
||||
|
||||
private readonly string mName;
|
||||
|
||||
private readonly string mImagePath;
|
||||
|
||||
public string Key => mKey;
|
||||
|
||||
public string Name => mName;
|
||||
|
||||
public Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mImagePath == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return ImageCache.GetImage(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), mImagePath));
|
||||
}
|
||||
}
|
||||
|
||||
internal RPVehicle(XmlNode vehicleNode)
|
||||
{
|
||||
XmlAttribute xmlAttribute = vehicleNode.Attributes["image"];
|
||||
mKey = vehicleNode.Attributes["key"].InnerText;
|
||||
mName = vehicleNode.Attributes["name"].InnerText;
|
||||
mImagePath = xmlAttribute?.InnerText;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
public class Scenario
|
||||
{
|
||||
private string mKey;
|
||||
|
||||
private string mName;
|
||||
|
||||
private Dictionary<string, RPMap> mMaps = new Dictionary<string, RPMap>();
|
||||
|
||||
private Dictionary<string, RPVehicle> mVehicles = new Dictionary<string, RPVehicle>();
|
||||
|
||||
private Dictionary<string, string> mTimesOfDay = new Dictionary<string, string>();
|
||||
|
||||
private Dictionary<string, string> mWeather = new Dictionary<string, string>();
|
||||
|
||||
public string Key => mKey;
|
||||
|
||||
public string Name => mName;
|
||||
|
||||
public Dictionary<string, RPMap> Maps => mMaps;
|
||||
|
||||
public Dictionary<string, RPVehicle> Vehicles => mVehicles;
|
||||
|
||||
public Dictionary<string, string> TimesOfDay => mTimesOfDay;
|
||||
|
||||
public Dictionary<string, string> Weather => mWeather;
|
||||
|
||||
internal Scenario(XmlNode scenarioNode)
|
||||
{
|
||||
mKey = scenarioNode.Name;
|
||||
mName = scenarioNode.Attributes["name"].InnerText;
|
||||
List<KeyValuePair<string, string>> list = new List<KeyValuePair<string, string>>();
|
||||
foreach (XmlNode childNode in scenarioNode.ChildNodes)
|
||||
{
|
||||
if (childNode.Name == "invalid")
|
||||
{
|
||||
list.Add(new KeyValuePair<string, string>(childNode.Attributes["type"].InnerText, childNode.Attributes["key"].InnerText));
|
||||
}
|
||||
}
|
||||
foreach (RPMap value in RPConfig.Maps.Values)
|
||||
{
|
||||
if (!IsInvalid("map", value.Key, list))
|
||||
{
|
||||
mMaps.Add(value.Key, value);
|
||||
}
|
||||
}
|
||||
foreach (RPVehicle value2 in RPConfig.Vehicles.Values)
|
||||
{
|
||||
if (!IsInvalid("vehicle", value2.Key, list))
|
||||
{
|
||||
mVehicles.Add(value2.Key, value2);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, string> item in RPConfig.TimesOfDay)
|
||||
{
|
||||
if (!IsInvalid("time", item.Key, list))
|
||||
{
|
||||
mTimesOfDay.Add(item.Key, item.Value);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<string, string> item2 in RPConfig.Weather)
|
||||
{
|
||||
if (!IsInvalid("weather", item2.Key, list))
|
||||
{
|
||||
mWeather.Add(item2.Key, item2.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsInvalid(string type, string value, List<KeyValuePair<string, string>> invalid)
|
||||
{
|
||||
foreach (KeyValuePair<string, string> item in invalid)
|
||||
{
|
||||
if (item.Key == type && item.Value == value)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class ScoreUpdateEvent : MissionEvent
|
||||
{
|
||||
public readonly int Score;
|
||||
|
||||
public override IEnumerable<RPPlayer> InvolvedPilots => new RPPlayer[1] { ReportingPilot };
|
||||
|
||||
public ScoreUpdateEvent(RPPlayer reportingPilot, TimeSpan missionTime, int score)
|
||||
: base(reportingPilot, missionTime)
|
||||
{
|
||||
Score = score;
|
||||
}
|
||||
|
||||
private ScoreUpdateEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole.RedPlanet;
|
||||
|
||||
[Serializable]
|
||||
internal class ScoredEvent : MissionEvent
|
||||
{
|
||||
public override IEnumerable<RPPlayer> InvolvedPilots => new RPPlayer[1] { ReportingPilot };
|
||||
|
||||
public ScoredEvent(RPPlayer reportingPilot, TimeSpan missionTime)
|
||||
: base(reportingPilot, missionTime)
|
||||
{
|
||||
}
|
||||
|
||||
private ScoredEvent()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>TeslaConsole</AssemblyName>
|
||||
<GenerateAssemblyInfo>False</GenerateAssemblyInfo>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<UseWindowsForms>True</UseWindowsForms>
|
||||
<TargetFramework>net48</TargetFramework>
|
||||
<LangVersion>Preview</LangVersion>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<ApplicationIcon>app.ico</ApplicationIcon>
|
||||
<RootNamespace />
|
||||
<!-- Decompiled from the original net20 TeslaConsole.exe; legacy WinForms 2.0 sources -->
|
||||
<Nullable>disable</Nullable>
|
||||
<ImplicitUsings>disable</ImplicitUsings>
|
||||
<!-- .resx files embed BinaryFormatter-serialized bitmaps (non-string resources) -->
|
||||
<GenerateResourceUsePreserializedResources>true</GenerateResourceUsePreserializedResources>
|
||||
<!-- CS0649: decompiled WinForms designer 'components' fields are never assigned -->
|
||||
<NoWarn>$(NoWarn);CS0649</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- net48 reference assemblies so the project builds without a full targeting pack installed -->
|
||||
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="all" />
|
||||
<!-- Required to read the pre-serialized binary resources above -->
|
||||
<PackageReference Include="System.Resources.Extensions" Version="6.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Runtime content the console loads relative to the exe (RPConfig.cs / RPStrings.cs / AppRegistry.cs) -->
|
||||
<Content Include="RedPlanet\RPConfig.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="RedPlanet\RPStrings.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
<Content Include="RedPlanet\Apps.xml" CopyToOutputDirectory="PreserveNewest" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- Reference-only material: original binary + source art. Not compiled, not copied. -->
|
||||
<None Remove="original\**" />
|
||||
<None Remove="images\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<!-- The differential test project lives under tests\; keep its sources out of this build. -->
|
||||
<Compile Remove="tests\**" />
|
||||
<None Remove="tests\**" />
|
||||
<Content Remove="tests\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.ServiceProcess" />
|
||||
<Reference Include="Microsoft.VisualBasic" />
|
||||
<Reference Include="WeifenLuo.WinFormsUI.Docking">
|
||||
<HintPath>lib\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TeslaSecureConfiguration">
|
||||
<HintPath>lib\TeslaSecureConfiguration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Munga Net">
|
||||
<HintPath>lib\Munga Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="TeslaConsoleLaunchLib">
|
||||
<HintPath>lib\TeslaConsoleLaunchLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BitmapLibrary">
|
||||
<HintPath>lib\BitmapLibrary.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class AlertButtonClickEventArgs : EventArgs
|
||||
{
|
||||
private DialogResult mDialogResult;
|
||||
|
||||
private string mInput;
|
||||
|
||||
public DialogResult DialogResult => mDialogResult;
|
||||
|
||||
public string Input => mInput;
|
||||
|
||||
public AlertButtonClickEventArgs(DialogResult dialogResult, string input)
|
||||
{
|
||||
mDialogResult = dialogResult;
|
||||
mInput = input;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,473 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using Tesla.Net;
|
||||
using TeslaConsole.Properties;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class AppControlGrid : UserControl
|
||||
{
|
||||
private class ApplicationInstanceGroup
|
||||
{
|
||||
public Guid LaunchKey { get; set; }
|
||||
|
||||
public string AppDisplayName { get; set; }
|
||||
|
||||
public List<Guid> RunningPods { get; private set; }
|
||||
|
||||
public List<Guid> StoppedPods { get; private set; }
|
||||
|
||||
public string RunningKey => "running:" + LaunchKey;
|
||||
|
||||
public string StoppedKey => "stopped:" + LaunchKey;
|
||||
|
||||
public ApplicationInstanceGroup(LaunchPair launchPair)
|
||||
{
|
||||
LaunchKey = launchPair.LaunchKey;
|
||||
AppDisplayName = launchPair.DisplayName;
|
||||
RunningPods = new List<Guid>();
|
||||
StoppedPods = new List<Guid>();
|
||||
}
|
||||
|
||||
public void AddInstance(PodAppInstance instance)
|
||||
{
|
||||
if (instance.IsRunning)
|
||||
{
|
||||
RunningPods.Add(instance.PodId);
|
||||
}
|
||||
else
|
||||
{
|
||||
StoppedPods.Add(instance.PodId);
|
||||
}
|
||||
}
|
||||
|
||||
public void StartPod(Guid podId)
|
||||
{
|
||||
if (StoppedPods.Contains(podId))
|
||||
{
|
||||
StoppedPods.Remove(podId);
|
||||
if (!RunningPods.Contains(podId))
|
||||
{
|
||||
RunningPods.Add(podId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAllPods()
|
||||
{
|
||||
List<Guid> list = new List<Guid>(StoppedPods);
|
||||
foreach (Guid item in list)
|
||||
{
|
||||
StartPod(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void StopPod(Guid podId)
|
||||
{
|
||||
if (RunningPods.Contains(podId))
|
||||
{
|
||||
RunningPods.Remove(podId);
|
||||
if (!StoppedPods.Contains(podId))
|
||||
{
|
||||
StoppedPods.Add(podId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StopAllPods()
|
||||
{
|
||||
List<Guid> list = new List<Guid>(RunningPods);
|
||||
foreach (Guid item in list)
|
||||
{
|
||||
StopPod(item);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is ApplicationInstanceGroup)
|
||||
{
|
||||
return LaunchKey == ((ApplicationInstanceGroup)obj).LaunchKey;
|
||||
}
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return LaunchKey.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
private Dictionary<Guid, ApplicationInstanceGroup> mAppGroups = new Dictionary<Guid, ApplicationInstanceGroup>();
|
||||
|
||||
private IContainer components;
|
||||
|
||||
private NoSelectDataGridView grdApps;
|
||||
|
||||
private DataGridViewLinkColumn colAction;
|
||||
|
||||
private DataGridViewTextBoxColumn colStatus;
|
||||
|
||||
private DataGridViewTextBoxColumn colName;
|
||||
|
||||
private DataGridViewImageColumn colError;
|
||||
|
||||
public bool ShowCounts { get; set; }
|
||||
|
||||
public event EventHandler<AppEventArgs> LaunchApp;
|
||||
|
||||
public event EventHandler<AppEventArgs> KillApp;
|
||||
|
||||
public AppControlGrid()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void grdApps_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.RowIndex < 0 || e.RowIndex >= grdApps.Rows.Count)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DataGridViewRow dataGridViewRow = grdApps.Rows[e.RowIndex];
|
||||
string text = (string)dataGridViewRow.Tag;
|
||||
ApplicationInstanceGroup applicationInstanceGroup = mAppGroups[new Guid(text.Split(':')[1])];
|
||||
if (!(dataGridViewRow.Cells[e.ColumnIndex] is DataGridViewLinkCell dataGridViewLinkCell))
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (DataGridViewRow item in (IEnumerable)grdApps.Rows)
|
||||
{
|
||||
item.Cells[3].Value = Resources.Blank;
|
||||
((List<string>)item.Cells[3].Tag).Clear();
|
||||
}
|
||||
Rectangle cellDisplayRectangle = grdApps.GetCellDisplayRectangle(0, e.RowIndex, cutOverflow: false);
|
||||
PictureBox pictureBox = new PictureBox();
|
||||
pictureBox.Name = text;
|
||||
pictureBox.Image = Resources.square_throbber;
|
||||
pictureBox.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
pictureBox.Location = cellDisplayRectangle.Location;
|
||||
pictureBox.Size = cellDisplayRectangle.Size;
|
||||
pictureBox.Tag = e.RowIndex;
|
||||
grdApps.Controls.Add(pictureBox);
|
||||
pictureBox.BringToFront();
|
||||
if ((string)dataGridViewLinkCell.Value == "Start")
|
||||
{
|
||||
if (this.LaunchApp != null)
|
||||
{
|
||||
this.LaunchApp(this, new AppEventArgs(applicationInstanceGroup.LaunchKey, applicationInstanceGroup.StoppedPods));
|
||||
}
|
||||
}
|
||||
else if ((string)dataGridViewLinkCell.Value == "Stop" && this.KillApp != null)
|
||||
{
|
||||
this.KillApp(this, new AppEventArgs(applicationInstanceGroup.LaunchKey, applicationInstanceGroup.RunningPods));
|
||||
}
|
||||
}
|
||||
|
||||
private void grdApps_Scroll(object sender, ScrollEventArgs e)
|
||||
{
|
||||
foreach (Control control in grdApps.Controls)
|
||||
{
|
||||
if (control is PictureBox)
|
||||
{
|
||||
Rectangle cellDisplayRectangle = grdApps.GetCellDisplayRectangle(0, (int)control.Tag, cutOverflow: false);
|
||||
control.Location = cellDisplayRectangle.Location;
|
||||
control.Size = cellDisplayRectangle.Size;
|
||||
control.BringToFront();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
mAppGroups.Clear();
|
||||
grdApps.Rows.Clear();
|
||||
grdApps.Controls.Clear();
|
||||
}
|
||||
|
||||
public void SetData(IEnumerable<PodAppInstance> instances)
|
||||
{
|
||||
Clear();
|
||||
foreach (PodAppInstance instance in instances)
|
||||
{
|
||||
if (!mAppGroups.TryGetValue(instance.LaunchPair.LaunchKey, out var value))
|
||||
{
|
||||
value = new ApplicationInstanceGroup(instance.LaunchPair);
|
||||
mAppGroups.Add(instance.LaunchPair.LaunchKey, value);
|
||||
}
|
||||
value.AddInstance(instance);
|
||||
}
|
||||
Refresh();
|
||||
grdApps.Sort(grdApps.Columns[2], ListSortDirection.Ascending);
|
||||
}
|
||||
|
||||
public void StartApp(Guid podId, Guid appId)
|
||||
{
|
||||
if (mAppGroups.ContainsKey(appId))
|
||||
{
|
||||
ApplicationInstanceGroup applicationInstanceGroup = mAppGroups[appId];
|
||||
applicationInstanceGroup.StartPod(podId);
|
||||
RefreshAppGroup(applicationInstanceGroup);
|
||||
Resort();
|
||||
}
|
||||
}
|
||||
|
||||
public void StartAppFailed(Guid appId, string podDisplayName)
|
||||
{
|
||||
if (mAppGroups.ContainsKey(appId))
|
||||
{
|
||||
ApplicationInstanceGroup applicationInstanceGroup = mAppGroups[appId];
|
||||
FlagError(applicationInstanceGroup.StoppedKey, podDisplayName, "The following pods failed to stop:");
|
||||
}
|
||||
}
|
||||
|
||||
public void StopApp(Guid podId, Guid appId)
|
||||
{
|
||||
if (mAppGroups.ContainsKey(appId))
|
||||
{
|
||||
ApplicationInstanceGroup applicationInstanceGroup = mAppGroups[appId];
|
||||
applicationInstanceGroup.StopPod(podId);
|
||||
RefreshAppGroup(applicationInstanceGroup);
|
||||
Resort();
|
||||
}
|
||||
}
|
||||
|
||||
public void StopAppFailed(Guid appId, string podDisplayName)
|
||||
{
|
||||
if (mAppGroups.ContainsKey(appId))
|
||||
{
|
||||
ApplicationInstanceGroup applicationInstanceGroup = mAppGroups[appId];
|
||||
FlagError(applicationInstanceGroup.RunningKey, podDisplayName, "The following pods failed to stop:");
|
||||
}
|
||||
}
|
||||
|
||||
private void FlagError(string rowKey, string podDisplayName, string error)
|
||||
{
|
||||
Control[] array = grdApps.Controls.Find(rowKey, searchAllChildren: false);
|
||||
foreach (Control value in array)
|
||||
{
|
||||
grdApps.Controls.Remove(value);
|
||||
}
|
||||
foreach (DataGridViewRow item in (IEnumerable)grdApps.Rows)
|
||||
{
|
||||
if (object.Equals(item.Tag, rowKey))
|
||||
{
|
||||
((List<string>)item.Cells[3].Tag).Add(podDisplayName);
|
||||
RefreshRowError(item, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
grdApps.SuspendLayout();
|
||||
foreach (ApplicationInstanceGroup value in mAppGroups.Values)
|
||||
{
|
||||
RefreshAppGroup(value);
|
||||
}
|
||||
grdApps.ResumeLayout();
|
||||
grdApps.AutoResizeColumns();
|
||||
Resort();
|
||||
}
|
||||
|
||||
private void RefreshAppGroup(ApplicationInstanceGroup group)
|
||||
{
|
||||
bool flag = false;
|
||||
bool flag2 = false;
|
||||
for (int num = grdApps.Rows.Count - 1; num >= 0; num--)
|
||||
{
|
||||
DataGridViewRow dataGridViewRow = grdApps.Rows[num];
|
||||
if (object.Equals(dataGridViewRow.Tag, group.RunningKey))
|
||||
{
|
||||
flag = true;
|
||||
if (group.RunningPods.Count > 0)
|
||||
{
|
||||
RefreshRow(dataGridViewRow, isRunning: true, group.RunningPods.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveRow(num);
|
||||
}
|
||||
}
|
||||
else if (object.Equals(dataGridViewRow.Tag, group.StoppedKey))
|
||||
{
|
||||
flag2 = true;
|
||||
if (group.StoppedPods.Count > 0)
|
||||
{
|
||||
RefreshRow(dataGridViewRow, isRunning: false, group.StoppedPods.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveRow(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag && group.RunningPods.Count > 0)
|
||||
{
|
||||
grdApps.Rows.Add(CreateRow(group, isRunning: true));
|
||||
}
|
||||
if (!flag2 && group.StoppedPods.Count > 0)
|
||||
{
|
||||
grdApps.Rows.Add(CreateRow(group, isRunning: false));
|
||||
}
|
||||
}
|
||||
|
||||
private void Resort()
|
||||
{
|
||||
if (grdApps.SortOrder != 0)
|
||||
{
|
||||
grdApps.Sort(grdApps.SortedColumn, (grdApps.SortOrder != SortOrder.Ascending) ? ListSortDirection.Descending : ListSortDirection.Ascending);
|
||||
}
|
||||
}
|
||||
|
||||
private DataGridViewRow CreateRow(ApplicationInstanceGroup group, bool isRunning)
|
||||
{
|
||||
DataGridViewRow dataGridViewRow = new DataGridViewRow();
|
||||
dataGridViewRow.Tag = (isRunning ? group.RunningKey : group.StoppedKey);
|
||||
dataGridViewRow.Cells.Add(new DataGridViewLinkCell());
|
||||
dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell());
|
||||
DataGridViewTextBoxCell dataGridViewTextBoxCell = new DataGridViewTextBoxCell();
|
||||
dataGridViewTextBoxCell.Value = group.AppDisplayName;
|
||||
dataGridViewRow.Cells.Add(dataGridViewTextBoxCell);
|
||||
DataGridViewImageCell dataGridViewImageCell = new DataGridViewImageCell();
|
||||
dataGridViewImageCell.Value = Resources.Blank;
|
||||
dataGridViewImageCell.Tag = new List<string>();
|
||||
dataGridViewRow.Cells.Add(dataGridViewImageCell);
|
||||
RefreshRow(dataGridViewRow, isRunning, isRunning ? group.RunningPods.Count : group.StoppedPods.Count);
|
||||
return dataGridViewRow;
|
||||
}
|
||||
|
||||
private void RefreshRow(DataGridViewRow row, bool isRunning, int count)
|
||||
{
|
||||
DataGridViewLinkCell dataGridViewLinkCell = (DataGridViewLinkCell)row.Cells[0];
|
||||
dataGridViewLinkCell.Value = (isRunning ? "Stop" : "Start");
|
||||
Color color2 = (dataGridViewLinkCell.VisitedLinkColor = (isRunning ? Color.Red : Color.Green));
|
||||
Color color5 = (dataGridViewLinkCell.LinkColor = (dataGridViewLinkCell.ActiveLinkColor = color2));
|
||||
DataGridViewTextBoxCell dataGridViewTextBoxCell = (DataGridViewTextBoxCell)row.Cells[1];
|
||||
if (ShowCounts)
|
||||
{
|
||||
dataGridViewTextBoxCell.Value = count + (isRunning ? " Running" : " Stopped");
|
||||
}
|
||||
else
|
||||
{
|
||||
dataGridViewTextBoxCell.Value = (isRunning ? "Running" : "Stopped");
|
||||
}
|
||||
dataGridViewTextBoxCell.Style.ForeColor = (isRunning ? Color.Green : Color.Black);
|
||||
}
|
||||
|
||||
private void RefreshRowError(DataGridViewRow row, string errorPrefix)
|
||||
{
|
||||
row.Cells[3].Value = Resources.Error;
|
||||
StringBuilder stringBuilder = new StringBuilder(errorPrefix);
|
||||
foreach (string item in (List<string>)row.Cells[3].Tag)
|
||||
{
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.Append(" - ");
|
||||
stringBuilder.Append(item);
|
||||
}
|
||||
row.Cells[3].ToolTipText = stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private void RemoveRow(int index)
|
||||
{
|
||||
Control[] array = grdApps.Controls.Find((string)grdApps.Rows[index].Tag, searchAllChildren: false);
|
||||
foreach (Control value in array)
|
||||
{
|
||||
grdApps.Controls.Remove(value);
|
||||
}
|
||||
grdApps.Rows.RemoveAt(index);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.grdApps = new TeslaConsole.NoSelectDataGridView();
|
||||
this.colAction = new System.Windows.Forms.DataGridViewLinkColumn();
|
||||
this.colStatus = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colError = new System.Windows.Forms.DataGridViewImageColumn();
|
||||
((System.ComponentModel.ISupportInitialize)this.grdApps).BeginInit();
|
||||
base.SuspendLayout();
|
||||
this.grdApps.AllowUserToAddRows = false;
|
||||
this.grdApps.AllowUserToDeleteRows = false;
|
||||
this.grdApps.AllowUserToResizeRows = false;
|
||||
this.grdApps.BackgroundColor = System.Drawing.Color.White;
|
||||
this.grdApps.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.grdApps.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None;
|
||||
this.grdApps.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
|
||||
this.grdApps.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.grdApps.Columns.AddRange(this.colAction, this.colStatus, this.colName, this.colError);
|
||||
this.grdApps.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.grdApps.EditMode = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
|
||||
this.grdApps.GridColor = System.Drawing.Color.White;
|
||||
this.grdApps.Location = new System.Drawing.Point(0, 0);
|
||||
this.grdApps.MultiSelect = false;
|
||||
this.grdApps.Name = "grdApps";
|
||||
this.grdApps.ReadOnly = true;
|
||||
this.grdApps.RowHeadersVisible = false;
|
||||
this.grdApps.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.grdApps.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.grdApps.Size = new System.Drawing.Size(366, 215);
|
||||
this.grdApps.TabIndex = 8;
|
||||
this.grdApps.Scroll += new System.Windows.Forms.ScrollEventHandler(grdApps_Scroll);
|
||||
this.grdApps.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(grdApps_CellContentClick);
|
||||
this.colAction.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
||||
dataGridViewCellStyle.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
this.colAction.DefaultCellStyle = dataGridViewCellStyle;
|
||||
this.colAction.Frozen = true;
|
||||
this.colAction.HeaderText = "Action";
|
||||
this.colAction.LinkColor = System.Drawing.Color.Blue;
|
||||
this.colAction.MinimumWidth = 50;
|
||||
this.colAction.Name = "colAction";
|
||||
this.colAction.ReadOnly = true;
|
||||
this.colAction.VisitedLinkColor = System.Drawing.Color.Blue;
|
||||
this.colAction.Width = 50;
|
||||
this.colStatus.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells;
|
||||
dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
|
||||
dataGridViewCellStyle2.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
|
||||
this.colStatus.DefaultCellStyle = dataGridViewCellStyle2;
|
||||
this.colStatus.Frozen = true;
|
||||
this.colStatus.HeaderText = "Status";
|
||||
this.colStatus.MinimumWidth = 50;
|
||||
this.colStatus.Name = "colStatus";
|
||||
this.colStatus.ReadOnly = true;
|
||||
this.colStatus.Width = 62;
|
||||
this.colName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
|
||||
this.colName.DefaultCellStyle = dataGridViewCellStyle3;
|
||||
this.colName.HeaderText = "Application Name";
|
||||
this.colName.MinimumWidth = 100;
|
||||
this.colName.Name = "colName";
|
||||
this.colName.ReadOnly = true;
|
||||
this.colError.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
|
||||
this.colError.HeaderText = "";
|
||||
this.colError.MinimumWidth = 20;
|
||||
this.colError.Name = "colError";
|
||||
this.colError.ReadOnly = true;
|
||||
this.colError.Width = 20;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.Controls.Add(this.grdApps);
|
||||
base.Name = "AppControlGrid";
|
||||
base.Size = new System.Drawing.Size(366, 215);
|
||||
((System.ComponentModel.ISupportInitialize)this.grdApps).EndInit();
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class AppEventArgs : EventArgs
|
||||
{
|
||||
public Guid ApplicationId { get; private set; }
|
||||
|
||||
public List<Guid> PodIds { get; private set; }
|
||||
|
||||
public AppEventArgs(Guid applicationId, IEnumerable<Guid> podIds)
|
||||
{
|
||||
ApplicationId = applicationId;
|
||||
PodIds = new List<Guid>(podIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
using Tesla.Net;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
/// <summary>Role a launch entry fills; only meaningful for products that prompt with the start-params dialog.</summary>
|
||||
public enum AppHostType
|
||||
{
|
||||
None,
|
||||
GameClient,
|
||||
LiveCamera,
|
||||
MissionReview
|
||||
}
|
||||
|
||||
/// <summary>One launchable application a product registers on a pod.</summary>
|
||||
public class LaunchEntryDefinition
|
||||
{
|
||||
public Guid LaunchKey;
|
||||
|
||||
public string DisplayName = "";
|
||||
|
||||
public string Exe = "";
|
||||
|
||||
/// <summary>Arguments; the token "{res}" expands to " -res W H" when a custom resolution is chosen, else "".</summary>
|
||||
public string Args = "";
|
||||
|
||||
/// <summary>Optional; when null/empty the working directory is derived from <see cref="Exe"/>.</summary>
|
||||
public string WorkingDirectory;
|
||||
|
||||
public bool AutoRestart = true;
|
||||
|
||||
public AppHostType HostType;
|
||||
|
||||
/// <summary>Builds the wire <see cref="LaunchData"/> for this entry, expanding {res} from the optional resolution.</summary>
|
||||
public LaunchData ToLaunchData(Size? resolution)
|
||||
{
|
||||
string resArg = resolution.HasValue
|
||||
? $" -res {resolution.Value.Width} {resolution.Value.Height}"
|
||||
: "";
|
||||
LaunchData data = default(LaunchData);
|
||||
data.LaunchPair.DisplayName = DisplayName;
|
||||
data.LaunchPair.LaunchKey = LaunchKey;
|
||||
data.ExeFile = Exe;
|
||||
data.Arguments = (Args ?? "").Replace("{res}", resArg);
|
||||
data.WorkingDirectory = string.IsNullOrEmpty(WorkingDirectory)
|
||||
? Path.GetDirectoryName(Exe)
|
||||
: WorkingDirectory;
|
||||
data.AutoRestart = AutoRestart;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>An installable product: an install/package key plus the launch entries it registers.</summary>
|
||||
public class ProductDefinition
|
||||
{
|
||||
public Guid Id;
|
||||
|
||||
public string Name = "";
|
||||
|
||||
public string MenuText = "";
|
||||
|
||||
/// <summary>When true, installing prompts for resolution + roles and only selected-role entries are registered.</summary>
|
||||
public bool HostTypeDialog;
|
||||
|
||||
public List<LaunchEntryDefinition> Entries = new List<LaunchEntryDefinition>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Data-driven catalog of installable products, loaded from RedPlanet\Apps.xml (next to the exe).
|
||||
/// Replaces the products that were hardcoded in <see cref="SiteManagement"/>.
|
||||
/// </summary>
|
||||
public static class AppRegistry
|
||||
{
|
||||
private static readonly List<ProductDefinition> mProducts = new List<ProductDefinition>();
|
||||
|
||||
private static readonly Dictionary<Guid, ProductDefinition> mById = new Dictionary<Guid, ProductDefinition>();
|
||||
|
||||
public static IReadOnlyList<ProductDefinition> Products => mProducts;
|
||||
|
||||
public static string CatalogPath =>
|
||||
Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RedPlanet\\Apps.xml");
|
||||
|
||||
static AppRegistry()
|
||||
{
|
||||
Reload();
|
||||
}
|
||||
|
||||
public static ProductDefinition GetProduct(Guid id)
|
||||
{
|
||||
return mById.TryGetValue(id, out var product) ? product : null;
|
||||
}
|
||||
|
||||
/// <summary>(Re)loads the catalog from <see cref="CatalogPath"/>. Safe if the file is missing — yields an empty catalog.</summary>
|
||||
public static void Reload()
|
||||
{
|
||||
LoadFromFile(CatalogPath);
|
||||
}
|
||||
|
||||
/// <summary>Loads the catalog from an explicit path. Safe if the file is missing — yields an empty catalog.</summary>
|
||||
public static void LoadFromFile(string path)
|
||||
{
|
||||
mProducts.Clear();
|
||||
mById.Clear();
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.Load(path);
|
||||
foreach (XmlNode node in doc.DocumentElement.ChildNodes)
|
||||
{
|
||||
if (node.NodeType == XmlNodeType.Element && node.Name == "Product")
|
||||
{
|
||||
ProductDefinition product = ParseProduct(node);
|
||||
mProducts.Add(product);
|
||||
mById[product.Id] = product;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Adds a product to the catalog and persists the whole catalog to disk.</summary>
|
||||
public static void AddProduct(ProductDefinition product)
|
||||
{
|
||||
mProducts.Add(product);
|
||||
mById[product.Id] = product;
|
||||
Save();
|
||||
}
|
||||
|
||||
/// <summary>Writes the catalog back to <see cref="CatalogPath"/>.</summary>
|
||||
public static void Save()
|
||||
{
|
||||
XmlDocument doc = new XmlDocument();
|
||||
doc.AppendChild(doc.CreateXmlDeclaration("1.0", "utf-8", null));
|
||||
doc.AppendChild(doc.CreateComment(
|
||||
" Tesla Console product catalog. Managed by Site Management (Add Product...). "));
|
||||
XmlElement root = doc.CreateElement("AppCatalog");
|
||||
doc.AppendChild(root);
|
||||
foreach (ProductDefinition product in mProducts)
|
||||
{
|
||||
XmlElement pe = doc.CreateElement("Product");
|
||||
pe.SetAttribute("id", product.Id.ToString("D"));
|
||||
pe.SetAttribute("name", product.Name);
|
||||
pe.SetAttribute("menuText", product.MenuText);
|
||||
pe.SetAttribute("hostTypeDialog", product.HostTypeDialog ? "true" : "false");
|
||||
foreach (LaunchEntryDefinition entry in product.Entries)
|
||||
{
|
||||
XmlElement le = doc.CreateElement("Launch");
|
||||
le.SetAttribute("key", entry.LaunchKey.ToString("D"));
|
||||
le.SetAttribute("displayName", entry.DisplayName);
|
||||
le.SetAttribute("exe", entry.Exe);
|
||||
le.SetAttribute("args", entry.Args ?? "");
|
||||
if (!string.IsNullOrEmpty(entry.WorkingDirectory))
|
||||
{
|
||||
le.SetAttribute("workingDirectory", entry.WorkingDirectory);
|
||||
}
|
||||
le.SetAttribute("autoRestart", entry.AutoRestart ? "true" : "false");
|
||||
le.SetAttribute("hostType", entry.HostType.ToString());
|
||||
pe.AppendChild(le);
|
||||
}
|
||||
root.AppendChild(pe);
|
||||
}
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(CatalogPath));
|
||||
doc.Save(CatalogPath);
|
||||
}
|
||||
|
||||
private static ProductDefinition ParseProduct(XmlNode node)
|
||||
{
|
||||
ProductDefinition product = new ProductDefinition
|
||||
{
|
||||
Id = ParseGuid(Attr(node, "id")),
|
||||
Name = Attr(node, "name"),
|
||||
MenuText = Attr(node, "menuText"),
|
||||
HostTypeDialog = ParseBool(Attr(node, "hostTypeDialog"))
|
||||
};
|
||||
if (string.IsNullOrEmpty(product.MenuText))
|
||||
{
|
||||
product.MenuText = product.Name + "...";
|
||||
}
|
||||
foreach (XmlNode child in node.ChildNodes)
|
||||
{
|
||||
if (child.NodeType == XmlNodeType.Element && child.Name == "Launch")
|
||||
{
|
||||
product.Entries.Add(ParseLaunch(child));
|
||||
}
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
private static LaunchEntryDefinition ParseLaunch(XmlNode node)
|
||||
{
|
||||
return new LaunchEntryDefinition
|
||||
{
|
||||
LaunchKey = ParseGuid(Attr(node, "key")),
|
||||
DisplayName = Attr(node, "displayName"),
|
||||
Exe = Attr(node, "exe"),
|
||||
Args = Attr(node, "args"),
|
||||
WorkingDirectory = HasAttr(node, "workingDirectory") ? Attr(node, "workingDirectory") : null,
|
||||
AutoRestart = !HasAttr(node, "autoRestart") || ParseBool(Attr(node, "autoRestart")),
|
||||
HostType = ParseHostType(Attr(node, "hostType"))
|
||||
};
|
||||
}
|
||||
|
||||
private static bool HasAttr(XmlNode node, string name)
|
||||
{
|
||||
return node.Attributes?[name] != null;
|
||||
}
|
||||
|
||||
private static string Attr(XmlNode node, string name)
|
||||
{
|
||||
return node.Attributes?[name]?.InnerText ?? "";
|
||||
}
|
||||
|
||||
private static Guid ParseGuid(string value)
|
||||
{
|
||||
return Guid.TryParse(value, out var guid) ? guid : Guid.Empty;
|
||||
}
|
||||
|
||||
private static bool ParseBool(string value)
|
||||
{
|
||||
return string.Equals(value, "true", StringComparison.OrdinalIgnoreCase) || value == "1";
|
||||
}
|
||||
|
||||
private static AppHostType ParseHostType(string value)
|
||||
{
|
||||
return Enum.TryParse<AppHostType>(value, ignoreCase: true, out var result) ? result : AppHostType.None;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class ApplicationCompletedEventArgs : AsyncCompletedEventArgs
|
||||
{
|
||||
private Guid mAppId;
|
||||
|
||||
public Guid ApplicationId => mAppId;
|
||||
|
||||
public ApplicationCompletedEventArgs(Guid appId, Exception e, bool canceled, object state)
|
||||
: base(e, canceled, state)
|
||||
{
|
||||
mAppId = appId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class AsyncControlState
|
||||
{
|
||||
public AsyncOperation asyncOp;
|
||||
|
||||
public Exception ex;
|
||||
|
||||
public AsyncControlState(Exception ex, AsyncOperation asyncOp)
|
||||
{
|
||||
this.ex = ex;
|
||||
this.asyncOp = asyncOp;
|
||||
}
|
||||
}
|
||||
internal class AsyncControlState<T> : AsyncControlState
|
||||
{
|
||||
public T state = default(T);
|
||||
|
||||
public AsyncControlState(T state, Exception ex, AsyncOperation asyncOp)
|
||||
: base(ex, asyncOp)
|
||||
{
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Threading;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class AsyncDelegates<T>
|
||||
{
|
||||
public T Worker;
|
||||
|
||||
public SendOrPostCallback OnProgressReport;
|
||||
|
||||
public SendOrPostCallback OnCompleted;
|
||||
|
||||
public SendOrPostCallback CompletionMethod;
|
||||
|
||||
public AsyncDelegates(SendOrPostCallback completed, SendOrPostCallback completionMethod)
|
||||
: this((SendOrPostCallback)null, completed, completionMethod)
|
||||
{
|
||||
}
|
||||
|
||||
public AsyncDelegates(SendOrPostCallback progressReport, SendOrPostCallback completed, SendOrPostCallback completionMethod)
|
||||
{
|
||||
OnProgressReport = progressReport;
|
||||
OnCompleted = completed;
|
||||
CompletionMethod = completionMethod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class Cached<T> where T : class
|
||||
{
|
||||
private T mItem;
|
||||
|
||||
private DateTime mNextExpireTime;
|
||||
|
||||
private TimeSpan mCacheDuration;
|
||||
|
||||
private object mSyncRoot = new object();
|
||||
|
||||
public T Item
|
||||
{
|
||||
get
|
||||
{
|
||||
return mItem;
|
||||
}
|
||||
set
|
||||
{
|
||||
mItem = value;
|
||||
mNextExpireTime = DateTime.Now + mCacheDuration;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExpired => DateTime.Now > mNextExpireTime;
|
||||
|
||||
public object SyncRoot => mSyncRoot;
|
||||
|
||||
public Cached(TimeSpan cacheDuration)
|
||||
{
|
||||
mItem = null;
|
||||
mNextExpireTime = DateTime.MinValue;
|
||||
mCacheDuration = cacheDuration;
|
||||
}
|
||||
|
||||
public void Expire()
|
||||
{
|
||||
mNextExpireTime = DateTime.MinValue;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace TeslaConsole;
|
||||
|
||||
public enum HostType
|
||||
{
|
||||
GameMachineHostType = 0,
|
||||
MissionReviewHostType = 2,
|
||||
ConsoleHostType = 3
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class HostTypeHelper
|
||||
{
|
||||
private static readonly Dictionary<HostType, HostTypeHelper> mCache;
|
||||
|
||||
private HostType mHostType;
|
||||
|
||||
public HostType HostType => mHostType;
|
||||
|
||||
static HostTypeHelper()
|
||||
{
|
||||
mCache = new Dictionary<HostType, HostTypeHelper>();
|
||||
foreach (object value in Enum.GetValues(typeof(HostType)))
|
||||
{
|
||||
HostType hostType = (HostType)value;
|
||||
mCache.Add(hostType, new HostTypeHelper(hostType));
|
||||
}
|
||||
}
|
||||
|
||||
public static explicit operator HostTypeHelper(HostType hostType)
|
||||
{
|
||||
return mCache[hostType];
|
||||
}
|
||||
|
||||
public static explicit operator HostType(HostTypeHelper helper)
|
||||
{
|
||||
return helper.HostType;
|
||||
}
|
||||
|
||||
public static bool operator ==(HostTypeHelper a, HostTypeHelper b)
|
||||
{
|
||||
return a.mHostType == b.mHostType;
|
||||
}
|
||||
|
||||
public static bool operator !=(HostTypeHelper a, HostTypeHelper b)
|
||||
{
|
||||
return !(a == b);
|
||||
}
|
||||
|
||||
public static HostTypeHelper Parse(string str)
|
||||
{
|
||||
foreach (HostTypeHelper value in mCache.Values)
|
||||
{
|
||||
if (value.ToString() == str)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
HostType hostType = (HostType)Enum.Parse(typeof(HostType), str);
|
||||
return (HostTypeHelper)hostType;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
throw new ArgumentException();
|
||||
}
|
||||
|
||||
private HostTypeHelper(HostType hostType)
|
||||
{
|
||||
mHostType = hostType;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj is HostTypeHelper && ((HostTypeHelper)obj).mHostType == mHostType)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return (int)mHostType;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return mHostType switch
|
||||
{
|
||||
HostType.GameMachineHostType => "Game Machine",
|
||||
HostType.MissionReviewHostType => "Mission Review",
|
||||
HostType.ConsoleHostType => "Console",
|
||||
_ => mHostType.ToString(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using TeslaConsole.Properties;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class ImageCache
|
||||
{
|
||||
private static readonly Bitmap mPodBad16;
|
||||
|
||||
private static readonly Bitmap mPodGo16;
|
||||
|
||||
private static readonly Bitmap mPodOffline16;
|
||||
|
||||
private static readonly Bitmap mPodOnline16;
|
||||
|
||||
private static readonly Bitmap mPodQuestion16;
|
||||
|
||||
private static readonly Bitmap mPodRun16;
|
||||
|
||||
private static Dictionary<string, Image> mCache;
|
||||
|
||||
public static Bitmap PodBad16 => mPodBad16;
|
||||
|
||||
public static Bitmap PodGo16 => mPodGo16;
|
||||
|
||||
public static Bitmap PodOffline16 => mPodOffline16;
|
||||
|
||||
public static Bitmap PodOnline16 => mPodOnline16;
|
||||
|
||||
public static Bitmap PodQuestion16 => mPodQuestion16;
|
||||
|
||||
public static Bitmap PodRun16 => mPodRun16;
|
||||
|
||||
static ImageCache()
|
||||
{
|
||||
mCache = new Dictionary<string, Image>();
|
||||
mPodBad16 = Resources.PodBad16;
|
||||
mPodGo16 = Resources.PodGo16;
|
||||
mPodOffline16 = Resources.PodOffline16;
|
||||
mPodOnline16 = Resources.PodOnline16;
|
||||
mPodQuestion16 = Resources.PodQuestion16;
|
||||
mPodRun16 = Resources.PodRun16;
|
||||
}
|
||||
|
||||
public static Image GetImage(string path)
|
||||
{
|
||||
lock (mCache)
|
||||
{
|
||||
if (!mCache.ContainsKey(path))
|
||||
{
|
||||
try
|
||||
{
|
||||
mCache.Add(path, Image.FromFile(path));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return mCache.ContainsKey(path) ? mCache[path] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class InstallProductCompletedEventArgs : AsyncCompletedEventArgs
|
||||
{
|
||||
private string mUncPath;
|
||||
|
||||
public string UncPath
|
||||
{
|
||||
get
|
||||
{
|
||||
RaiseExceptionIfNecessary();
|
||||
return mUncPath;
|
||||
}
|
||||
}
|
||||
|
||||
public InstallProductCompletedEventArgs(string uncPath, Exception e, bool canceled, object state)
|
||||
: base(e, canceled, state)
|
||||
{
|
||||
mUncPath = uncPath;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class InstallProductProgressEventArgs : ProgressChangedEventArgs
|
||||
{
|
||||
private string mStatus = "";
|
||||
|
||||
public string Status => mStatus;
|
||||
|
||||
public InstallProductProgressEventArgs(string status, int progressPercentage, object userState)
|
||||
: base(progressPercentage, userState)
|
||||
{
|
||||
mStatus = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class LogOutputWindow : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private TextBox txtOutput;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtOutput = new System.Windows.Forms.TextBox();
|
||||
base.SuspendLayout();
|
||||
this.txtOutput.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.txtOutput.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtOutput.Multiline = true;
|
||||
this.txtOutput.Name = "txtOutput";
|
||||
this.txtOutput.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
|
||||
this.txtOutput.Size = new System.Drawing.Size(663, 451);
|
||||
this.txtOutput.TabIndex = 0;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(663, 451);
|
||||
base.Controls.Add(this.txtOutput);
|
||||
base.Name = "LogOutputWindow";
|
||||
this.Text = "Log Output Window";
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
|
||||
public LogOutputWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public void LogMessage(string message, params object[] args)
|
||||
{
|
||||
LogMessage(string.Format(message, args));
|
||||
}
|
||||
|
||||
public void LogMessage(string message)
|
||||
{
|
||||
if (!txtOutput.IsDisposed)
|
||||
{
|
||||
int textLength = txtOutput.TextLength;
|
||||
message = $"\r\n{message}";
|
||||
if (textLength + message.Length > txtOutput.MaxLength)
|
||||
{
|
||||
txtOutput.Text = txtOutput.Text.Substring(message.Length);
|
||||
}
|
||||
txtOutput.AppendText(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration.Install;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
[RunInstaller(true)]
|
||||
public class MigrateIsolatedStorage : Installer
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new Container();
|
||||
}
|
||||
|
||||
public MigrateIsolatedStorage()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public override void Commit(IDictionary savedState)
|
||||
{
|
||||
base.Commit(savedState);
|
||||
base.Context.LogMessage("Migrating IsolatedStorage");
|
||||
string path = base.Context.Parameters["targetdir"];
|
||||
string fileName = Path.GetFileName(Assembly.GetExecutingAssembly().CodeBase);
|
||||
string text = Path.Combine(path, fileName);
|
||||
base.Context.LogMessage("Running \"" + text + "\" /migrateIsoStore");
|
||||
using Process process = new Process();
|
||||
process.StartInfo.FileName = text;
|
||||
process.StartInfo.Arguments = "/migrateIsoStore";
|
||||
process.StartInfo.UseShellExecute = false;
|
||||
process.StartInfo.CreateNoWindow = true;
|
||||
if (!process.Start())
|
||||
{
|
||||
throw new InstallException("Unable to start IsolatedStorage migrator process.");
|
||||
}
|
||||
process.WaitForExit();
|
||||
if (process.ExitCode != 0)
|
||||
{
|
||||
throw new InstallException("IsolatedStorage migrator exited with code " + process.ExitCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace TeslaConsole;
|
||||
|
||||
public enum MungaConnectionState
|
||||
{
|
||||
Disconnected,
|
||||
Connecting,
|
||||
Connected
|
||||
}
|
||||
@@ -0,0 +1,364 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Munga.Net;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class MungaGame
|
||||
{
|
||||
private readonly object mInternalLock = new object();
|
||||
|
||||
private readonly Pod mPod;
|
||||
|
||||
private Image mImage;
|
||||
|
||||
private string mStatusMessage;
|
||||
|
||||
private MungaSocket mSocket;
|
||||
|
||||
private DateTime mNextStateQuery = DateTime.MinValue;
|
||||
|
||||
private ApplicationState? mAppState;
|
||||
|
||||
private ApplicationID? mAppID;
|
||||
|
||||
private DateTime mEggDelayTimer = DateTime.MinValue;
|
||||
|
||||
private DateTime mEggSent = DateTime.MinValue;
|
||||
|
||||
private bool mEggAck;
|
||||
|
||||
private MungaConnectionState mState;
|
||||
|
||||
private readonly List<object> mRequestors = new List<object>();
|
||||
|
||||
private Form mOwner;
|
||||
|
||||
public Image Image => mImage;
|
||||
|
||||
public string StatusMessage => mStatusMessage;
|
||||
|
||||
public Pod Pod => mPod;
|
||||
|
||||
public ApplicationState? AppState => mAppState;
|
||||
|
||||
public ApplicationID? AppID => mAppID;
|
||||
|
||||
public DateTime EggDelayTimer
|
||||
{
|
||||
get
|
||||
{
|
||||
return mEggDelayTimer;
|
||||
}
|
||||
set
|
||||
{
|
||||
mEggDelayTimer = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime EggSent
|
||||
{
|
||||
get
|
||||
{
|
||||
return mEggSent;
|
||||
}
|
||||
set
|
||||
{
|
||||
mEggSent = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool EggAcknowledged => mEggAck;
|
||||
|
||||
public MungaConnectionState State
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (mState == MungaConnectionState.Connected)
|
||||
{
|
||||
if (mSocket != null && mSocket.Connected)
|
||||
{
|
||||
return MungaConnectionState.Connected;
|
||||
}
|
||||
Disconnect();
|
||||
}
|
||||
return mState;
|
||||
}
|
||||
}
|
||||
private set
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
mState = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Requested
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
return mRequestors.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOwned
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mOwner != null && mOwner.IsDisposed)
|
||||
{
|
||||
mOwner = null;
|
||||
}
|
||||
return mOwner != null;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler OnPodStatusUpdated;
|
||||
|
||||
public void QueryStateIfNeeded()
|
||||
{
|
||||
DateTime now = DateTime.Now;
|
||||
if (mNextStateQuery < now)
|
||||
{
|
||||
Send(0, 1, new StateQueryMessage(1));
|
||||
mNextStateQuery = now.AddSeconds(1.0);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsPodAppState(ApplicationID app, ApplicationState state)
|
||||
{
|
||||
return IsPodAppState(app, new ApplicationState[1] { state });
|
||||
}
|
||||
|
||||
public bool IsPodAppState(ApplicationID app, IEnumerable<ApplicationState> states)
|
||||
{
|
||||
if (IsPodOperational(app))
|
||||
{
|
||||
foreach (ApplicationState state in states)
|
||||
{
|
||||
if (mAppState.Value == state)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsPodOperational(ApplicationID app)
|
||||
{
|
||||
if (State == MungaConnectionState.Connected && mAppID.HasValue && mAppID.Value == app)
|
||||
{
|
||||
return mAppState.HasValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void MakeRequested(object requestor)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (!mRequestors.Contains(requestor))
|
||||
{
|
||||
mRequestors.Add(requestor);
|
||||
if (mRequestors.Count == 1)
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseRequest(object requestor)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (mRequestors.Contains(requestor))
|
||||
{
|
||||
mRequestors.Remove(requestor);
|
||||
if (mRequestors.Count == 0)
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsOwner(Form owner)
|
||||
{
|
||||
if (mOwner != null && mOwner.IsDisposed)
|
||||
{
|
||||
mOwner = null;
|
||||
}
|
||||
return mOwner == owner;
|
||||
}
|
||||
|
||||
public void TakeOwnership(Form owner)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (mOwner == null)
|
||||
{
|
||||
mOwner = owner;
|
||||
ForceStatusUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReleaseOwnership(Form owner)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (mOwner == owner)
|
||||
{
|
||||
mOwner = null;
|
||||
ForceStatusUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MungaGame(Pod pod)
|
||||
{
|
||||
mPod = pod;
|
||||
}
|
||||
|
||||
public void SetStatus(Image img, string statusMessage)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (mImage != img || mStatusMessage != statusMessage)
|
||||
{
|
||||
mImage = img;
|
||||
mStatusMessage = statusMessage;
|
||||
ForceStatusUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ForceStatusUpdate()
|
||||
{
|
||||
if (this.OnPodStatusUpdated != null)
|
||||
{
|
||||
this.OnPodStatusUpdated(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void Connect()
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
if (State != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
State = MungaConnectionState.Connecting;
|
||||
ShutdownSocket();
|
||||
mSocket = new MungaSocket();
|
||||
mSocket.BeginConnect(mPod.IPAddress, 1501, delegate(IAsyncResult ar)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
mSocket.EndConnect(ar);
|
||||
State = MungaConnectionState.Connected;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}
|
||||
}
|
||||
|
||||
private void Disconnect()
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
State = MungaConnectionState.Disconnected;
|
||||
mAppState = null;
|
||||
mAppID = null;
|
||||
mNextStateQuery = DateTime.MinValue;
|
||||
ShutdownSocket();
|
||||
if (Requested)
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShutdownSocket()
|
||||
{
|
||||
if (mSocket != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mSocket.Shutdown();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
mSocket = null;
|
||||
}
|
||||
}
|
||||
|
||||
public MetaMessage Receive()
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
MetaMessage metaMessage = mSocket.Receive();
|
||||
if (metaMessage != null)
|
||||
{
|
||||
if (metaMessage.Message is StateResponseMessage)
|
||||
{
|
||||
StateResponseMessage stateResponseMessage = (StateResponseMessage)metaMessage.Message;
|
||||
mAppID = stateResponseMessage.Application;
|
||||
if (stateResponseMessage.ApplicationState == ApplicationState.WaitingForEgg && stateResponseMessage.ApplicationState != mAppState)
|
||||
{
|
||||
mEggDelayTimer = DateTime.Now.AddSeconds(5.0);
|
||||
mEggSent = DateTime.MinValue;
|
||||
mEggAck = false;
|
||||
}
|
||||
mAppState = stateResponseMessage.ApplicationState;
|
||||
}
|
||||
else if (metaMessage.Message is AcknowledgeEggFileMessage)
|
||||
{
|
||||
mEggAck = true;
|
||||
}
|
||||
}
|
||||
return metaMessage;
|
||||
}
|
||||
catch
|
||||
{
|
||||
Disconnect();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Send(int gameID, int fromHost, MungaMessage message)
|
||||
{
|
||||
lock (mInternalLock)
|
||||
{
|
||||
try
|
||||
{
|
||||
mSocket.Send(gameID, fromHost, message);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class NoDoubleClickTreeView : TreeView
|
||||
{
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
if (m.Msg == 515)
|
||||
{
|
||||
m.Result = IntPtr.Zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class NoSelectDataGridView : DataGridView
|
||||
{
|
||||
protected override void SetSelectedRowCore(int rowIndex, bool selected)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,503 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class NotificationAlert : Form
|
||||
{
|
||||
private const double FadeInDuration = 0.3;
|
||||
|
||||
private const double FadeOutDuration = 0.3;
|
||||
|
||||
private const int AlertSpacing = 0;
|
||||
|
||||
private static List<NotificationAlert> mAlerts = new List<NotificationAlert>();
|
||||
|
||||
private double mDoubleTop;
|
||||
|
||||
private double mDestTop;
|
||||
|
||||
private bool mMoving;
|
||||
|
||||
private IContainer components;
|
||||
|
||||
private PictureBox picIcon;
|
||||
|
||||
private Label lblMessage;
|
||||
|
||||
private Button cmdRightButton;
|
||||
|
||||
private Button cmdCenterButton;
|
||||
|
||||
private Button cmdLeftButton;
|
||||
|
||||
private Timer tmrFadeIn;
|
||||
|
||||
private Timer tmrFadeOut;
|
||||
|
||||
private Timer tmrSlideDown;
|
||||
|
||||
private TextBox txtInput;
|
||||
|
||||
private Timer tmrSlideUp;
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
if (lblMessage == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return lblMessage.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (lblMessage != null)
|
||||
{
|
||||
lblMessage.Text = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new Image Icon
|
||||
{
|
||||
get
|
||||
{
|
||||
return picIcon.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
picIcon.Image = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool LeftButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdLeftButton.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdLeftButton.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string LeftButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdLeftButton.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdLeftButton.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DialogResult LeftButtonDialogResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdLeftButton.DialogResult;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdLeftButton.DialogResult = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool CenterButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdCenterButton.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdCenterButton.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string CenterButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdCenterButton.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdCenterButton.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DialogResult CenterButtonDialogResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdCenterButton.DialogResult;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdCenterButton.DialogResult = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool RightButton
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdRightButton.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdRightButton.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string RightButtonText
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdRightButton.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdRightButton.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public DialogResult RightButtonDialogResult
|
||||
{
|
||||
get
|
||||
{
|
||||
return cmdRightButton.DialogResult;
|
||||
}
|
||||
set
|
||||
{
|
||||
cmdRightButton.DialogResult = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShowInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return txtInput.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != txtInput.Visible)
|
||||
{
|
||||
txtInput.Visible = value;
|
||||
if (value)
|
||||
{
|
||||
base.Height += txtInput.Height + txtInput.Margin.Bottom;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Height -= txtInput.Height + txtInput.Margin.Bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<AlertButtonClickEventArgs> AlertButtonClick;
|
||||
|
||||
public NotificationAlert()
|
||||
{
|
||||
InitializeComponent();
|
||||
mAlerts.Add(this);
|
||||
base.Opacity = 0.01;
|
||||
ShowInput = false;
|
||||
}
|
||||
|
||||
public new void Show()
|
||||
{
|
||||
mMoving = true;
|
||||
base.Left = Screen.PrimaryScreen.WorkingArea.Right - base.Width - 30;
|
||||
base.Top = Screen.PrimaryScreen.WorkingArea.Bottom - base.Height - 30;
|
||||
mMoving = false;
|
||||
base.Opacity = 0.01;
|
||||
base.Show();
|
||||
tmrFadeIn.Stop();
|
||||
tmrFadeIn.Start();
|
||||
int num = mAlerts.IndexOf(this);
|
||||
if (num > 0)
|
||||
{
|
||||
NotificationAlert notificationAlert = mAlerts[num - 1];
|
||||
notificationAlert.mDoubleTop = notificationAlert.Top;
|
||||
notificationAlert.mDestTop = base.Top - notificationAlert.Height;
|
||||
notificationAlert.tmrSlideUp.Tag = num - 1;
|
||||
notificationAlert.tmrSlideUp.Stop();
|
||||
notificationAlert.tmrSlideUp.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrFadeIn_Tick(object sender, EventArgs e)
|
||||
{
|
||||
double num = (double)tmrFadeIn.Interval / 1000.0;
|
||||
base.Opacity += 3.3333333333333335 * num;
|
||||
if (base.Opacity >= 1.0)
|
||||
{
|
||||
base.Opacity = 1.0;
|
||||
tmrFadeIn.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrFadeOut_Tick(object sender, EventArgs e)
|
||||
{
|
||||
double num = (double)tmrFadeIn.Interval / 1000.0;
|
||||
base.Opacity -= 3.3333333333333335 * num;
|
||||
if (base.Opacity <= 0.01)
|
||||
{
|
||||
base.Opacity = 0.01;
|
||||
Close();
|
||||
tmrFadeOut.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrSlideUp_Tick(object sender, EventArgs e)
|
||||
{
|
||||
double dT = (double)tmrSlideUp.Interval / 1000.0;
|
||||
SlideUp((int)tmrSlideUp.Tag, dT);
|
||||
if (mDoubleTop <= mDestTop)
|
||||
{
|
||||
tmrSlideUp.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrSlideDown_Tick(object sender, EventArgs e)
|
||||
{
|
||||
double dT = (double)tmrSlideDown.Interval / 1000.0;
|
||||
SlideDown((int)tmrSlideDown.Tag, dT);
|
||||
if (mDoubleTop >= mDestTop)
|
||||
{
|
||||
tmrSlideDown.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void NotificationAlert_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (e.CloseReason != CloseReason.UserClosing || !(base.Opacity > 0.01))
|
||||
{
|
||||
return;
|
||||
}
|
||||
e.Cancel = true;
|
||||
tmrFadeOut.Stop();
|
||||
tmrFadeOut.Start();
|
||||
int num = mAlerts.IndexOf(this);
|
||||
if (num > 0)
|
||||
{
|
||||
NotificationAlert notificationAlert = mAlerts[num - 1];
|
||||
notificationAlert.mDoubleTop = notificationAlert.Top;
|
||||
if (num == mAlerts.Count - 1)
|
||||
{
|
||||
notificationAlert.mDestTop = (double)(Screen.PrimaryScreen.WorkingArea.Bottom - notificationAlert.Height) - 30.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationAlert.mDestTop = mAlerts[num + 1].Top - notificationAlert.Height;
|
||||
}
|
||||
notificationAlert.tmrSlideDown.Tag = num - 1;
|
||||
notificationAlert.tmrSlideDown.Stop();
|
||||
notificationAlert.tmrSlideDown.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private static void SlideUp(int index, double dT)
|
||||
{
|
||||
if (index >= 0 && index <= mAlerts.Count)
|
||||
{
|
||||
for (int i = 0; i <= index; i++)
|
||||
{
|
||||
NotificationAlert notificationAlert = mAlerts[i];
|
||||
notificationAlert.mDoubleTop -= (double)notificationAlert.Height / 0.3 * dT;
|
||||
notificationAlert.mMoving = true;
|
||||
notificationAlert.Top = (int)Math.Round(notificationAlert.mDoubleTop);
|
||||
notificationAlert.mMoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SlideDown(int index, double dT)
|
||||
{
|
||||
if (index >= 0 && index <= mAlerts.Count)
|
||||
{
|
||||
for (int num = index; num >= 0; num--)
|
||||
{
|
||||
NotificationAlert notificationAlert = mAlerts[num];
|
||||
notificationAlert.mDoubleTop += (double)notificationAlert.Height / 0.3 * dT;
|
||||
notificationAlert.mMoving = true;
|
||||
notificationAlert.Top = (int)Math.Round(notificationAlert.mDoubleTop);
|
||||
notificationAlert.mMoving = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void NotificationAlert_Move(object sender, EventArgs e)
|
||||
{
|
||||
if (mMoving)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int num = mAlerts.IndexOf(this);
|
||||
mAlerts.Remove(this);
|
||||
if (num > 0)
|
||||
{
|
||||
NotificationAlert notificationAlert = mAlerts[num - 1];
|
||||
notificationAlert.mDoubleTop = notificationAlert.Top;
|
||||
if (num == mAlerts.Count)
|
||||
{
|
||||
notificationAlert.mDestTop = (double)(Screen.PrimaryScreen.WorkingArea.Bottom - notificationAlert.Height) - 30.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
notificationAlert.mDestTop = mAlerts[num].Top - notificationAlert.Height;
|
||||
}
|
||||
notificationAlert.tmrSlideDown.Tag = num - 1;
|
||||
notificationAlert.tmrSlideDown.Stop();
|
||||
notificationAlert.tmrSlideDown.Start();
|
||||
}
|
||||
}
|
||||
|
||||
private void cmdButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is Button button && this.AlertButtonClick != null)
|
||||
{
|
||||
this.AlertButtonClick(this, new AlertButtonClickEventArgs(button.DialogResult, ShowInput ? txtInput.Text : null));
|
||||
}
|
||||
}
|
||||
|
||||
private void txtInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int selectionStart = txtInput.SelectionStart;
|
||||
int selectionLength = txtInput.SelectionLength;
|
||||
txtInput.Text = txtInput.Text.ToUpper();
|
||||
txtInput.Select(selectionStart, selectionLength);
|
||||
}
|
||||
|
||||
private void txtInput_KeyPress(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
if (e.KeyChar == '\r')
|
||||
{
|
||||
cmdCenterButton.PerformClick();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.picIcon = new System.Windows.Forms.PictureBox();
|
||||
this.lblMessage = new System.Windows.Forms.Label();
|
||||
this.cmdRightButton = new System.Windows.Forms.Button();
|
||||
this.cmdCenterButton = new System.Windows.Forms.Button();
|
||||
this.cmdLeftButton = new System.Windows.Forms.Button();
|
||||
this.tmrFadeIn = new System.Windows.Forms.Timer(this.components);
|
||||
this.tmrFadeOut = new System.Windows.Forms.Timer(this.components);
|
||||
this.tmrSlideDown = new System.Windows.Forms.Timer(this.components);
|
||||
this.txtInput = new System.Windows.Forms.TextBox();
|
||||
this.tmrSlideUp = new System.Windows.Forms.Timer(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)this.picIcon).BeginInit();
|
||||
base.SuspendLayout();
|
||||
this.picIcon.Location = new System.Drawing.Point(12, 12);
|
||||
this.picIcon.Name = "picIcon";
|
||||
this.picIcon.Size = new System.Drawing.Size(40, 40);
|
||||
this.picIcon.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.picIcon.TabIndex = 0;
|
||||
this.picIcon.TabStop = false;
|
||||
this.lblMessage.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblMessage.Location = new System.Drawing.Point(58, 12);
|
||||
this.lblMessage.Name = "lblMessage";
|
||||
this.lblMessage.Size = new System.Drawing.Size(206, 40);
|
||||
this.lblMessage.TabIndex = 1;
|
||||
this.lblMessage.Text = "Message";
|
||||
this.cmdRightButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdRightButton.Location = new System.Drawing.Point(189, 77);
|
||||
this.cmdRightButton.Name = "cmdRightButton";
|
||||
this.cmdRightButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdRightButton.TabIndex = 2;
|
||||
this.cmdRightButton.Text = "Cancel";
|
||||
this.cmdRightButton.UseVisualStyleBackColor = true;
|
||||
this.cmdRightButton.Click += new System.EventHandler(cmdButton_Click);
|
||||
this.cmdCenterButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdCenterButton.Location = new System.Drawing.Point(108, 77);
|
||||
this.cmdCenterButton.Name = "cmdCenterButton";
|
||||
this.cmdCenterButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdCenterButton.TabIndex = 3;
|
||||
this.cmdCenterButton.Text = "Okay";
|
||||
this.cmdCenterButton.UseVisualStyleBackColor = true;
|
||||
this.cmdCenterButton.Visible = false;
|
||||
this.cmdCenterButton.Click += new System.EventHandler(cmdButton_Click);
|
||||
this.cmdLeftButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdLeftButton.Location = new System.Drawing.Point(27, 77);
|
||||
this.cmdLeftButton.Name = "cmdLeftButton";
|
||||
this.cmdLeftButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdLeftButton.TabIndex = 4;
|
||||
this.cmdLeftButton.Text = "Yes";
|
||||
this.cmdLeftButton.UseVisualStyleBackColor = true;
|
||||
this.cmdLeftButton.Visible = false;
|
||||
this.cmdLeftButton.Click += new System.EventHandler(cmdButton_Click);
|
||||
this.tmrFadeIn.Interval = 50;
|
||||
this.tmrFadeIn.Tick += new System.EventHandler(tmrFadeIn_Tick);
|
||||
this.tmrFadeOut.Interval = 50;
|
||||
this.tmrFadeOut.Tick += new System.EventHandler(tmrFadeOut_Tick);
|
||||
this.tmrSlideDown.Interval = 50;
|
||||
this.tmrSlideDown.Tick += new System.EventHandler(tmrSlideDown_Tick);
|
||||
this.txtInput.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtInput.Location = new System.Drawing.Point(61, 54);
|
||||
this.txtInput.Name = "txtInput";
|
||||
this.txtInput.Size = new System.Drawing.Size(203, 20);
|
||||
this.txtInput.TabIndex = 5;
|
||||
this.txtInput.Visible = false;
|
||||
this.txtInput.TextChanged += new System.EventHandler(txtInput_TextChanged);
|
||||
this.txtInput.KeyPress += new System.Windows.Forms.KeyPressEventHandler(txtInput_KeyPress);
|
||||
this.tmrSlideUp.Interval = 50;
|
||||
this.tmrSlideUp.Tick += new System.EventHandler(tmrSlideUp_Tick);
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(276, 112);
|
||||
base.Controls.Add(this.txtInput);
|
||||
base.Controls.Add(this.cmdLeftButton);
|
||||
base.Controls.Add(this.cmdCenterButton);
|
||||
base.Controls.Add(this.cmdRightButton);
|
||||
base.Controls.Add(this.lblMessage);
|
||||
base.Controls.Add(this.picIcon);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
base.Name = "NotificationAlert";
|
||||
base.ShowInTaskbar = false;
|
||||
base.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.Text = "NotificationAlert";
|
||||
base.TopMost = true;
|
||||
base.Move += new System.EventHandler(NotificationAlert_Move);
|
||||
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(NotificationAlert_FormClosing);
|
||||
((System.ComponentModel.ISupportInitialize)this.picIcon).EndInit();
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public static class PilotNameCache
|
||||
{
|
||||
private static readonly AutoCompleteStringCollection mPilotNames = new AutoCompleteStringCollection();
|
||||
|
||||
public static AutoCompleteStringCollection PilotNames => mPilotNames;
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PlasmaBitmaps
|
||||
{
|
||||
public const string DefaultFontFamily = "Microsoft Sans Serif";
|
||||
|
||||
private static bool sEnableCustomBitmaps;
|
||||
|
||||
public static bool EnableCustomBitmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
return sEnableCustomBitmaps;
|
||||
}
|
||||
set
|
||||
{
|
||||
sEnableCustomBitmaps = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateBitmaps(out Bitmap large, out Bitmap small, string str)
|
||||
{
|
||||
GenerateBitmaps(out large, out small, "Microsoft Sans Serif", str);
|
||||
}
|
||||
|
||||
public static void GenerateBitmaps(out Bitmap large, out Bitmap small, string fontName, string str)
|
||||
{
|
||||
large = GenerateBitmap(128, 32, fontName, str);
|
||||
small = GenerateBitmap(64, 16, fontName, str);
|
||||
}
|
||||
|
||||
public static Bitmap GenerateBitmap(int width, int height, string str)
|
||||
{
|
||||
return GenerateBitmap(width, height, "Microsoft Sans Serif", str);
|
||||
}
|
||||
|
||||
public static Bitmap GenerateBitmap(int width, int height, string fontName, string str)
|
||||
{
|
||||
if (sEnableCustomBitmaps)
|
||||
{
|
||||
string text = Path.Combine(Program.GetCommonAppDataDirectory(), $"Plasma Images\\{str}_{width}x{height}.bmp");
|
||||
if (File.Exists(text))
|
||||
{
|
||||
try
|
||||
{
|
||||
Bitmap bitmap = (Bitmap)Image.FromFile(text);
|
||||
if (bitmap.Width == width && bitmap.Height == height)
|
||||
{
|
||||
return bitmap;
|
||||
}
|
||||
bitmap.Dispose();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Bitmap bitmap2 = new Bitmap(width, height);
|
||||
using Graphics graphics = Graphics.FromImage(bitmap2);
|
||||
graphics.SmoothingMode = SmoothingMode.None;
|
||||
graphics.CompositingQuality = CompositingQuality.AssumeLinear;
|
||||
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixelGridFit;
|
||||
graphics.Clear(Color.Black);
|
||||
int num = 24;
|
||||
while (true)
|
||||
{
|
||||
using Font font = new Font(fontName, num);
|
||||
SizeF sizeF = graphics.MeasureString(str, font);
|
||||
if (sizeF.Width <= (float)bitmap2.Width && sizeF.Height <= (float)bitmap2.Height)
|
||||
{
|
||||
Rectangle rectangle = new Rectangle(0, 0, bitmap2.Width, bitmap2.Height);
|
||||
StringFormat stringFormat = new StringFormat();
|
||||
stringFormat.Alignment = StringAlignment.Center;
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
graphics.DrawString(str, font, Brushes.White, rectangle, stringFormat);
|
||||
return bitmap2;
|
||||
}
|
||||
num = ((num <= 2) ? (num / 2) : (num - 2));
|
||||
}
|
||||
}
|
||||
|
||||
public static void GenerateStrings(out string large, out string small, string str)
|
||||
{
|
||||
GenerateStrings(out large, out small, "Microsoft Sans Serif", str);
|
||||
}
|
||||
|
||||
public static void GenerateStrings(out string large, out string small, string fontName, string str)
|
||||
{
|
||||
large = GenerateString(128, 32, fontName, str);
|
||||
small = GenerateString(64, 16, fontName, str);
|
||||
}
|
||||
|
||||
public static string GenerateString(int width, int height, string str)
|
||||
{
|
||||
return GenerateString(width, height, "Microsoft Sans Serif", str);
|
||||
}
|
||||
|
||||
public static string GenerateString(int width, int height, string fontName, string str)
|
||||
{
|
||||
using Bitmap bitmap = GenerateBitmap(width, height, fontName, str);
|
||||
return ConvertBitmap(bitmap);
|
||||
}
|
||||
|
||||
public static string ConvertBitmap(Bitmap bitmap)
|
||||
{
|
||||
if (bitmap.Width % 8 != 0 || bitmap.Height % 8 != 0)
|
||||
{
|
||||
throw new ArgumentOutOfRangeException("bitmap");
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
for (int i = 0; i < bitmap.Height; i++)
|
||||
{
|
||||
stringBuilder.Append("bitmap=");
|
||||
for (int j = 0; j < bitmap.Width / 8; j++)
|
||||
{
|
||||
byte b = 0;
|
||||
for (int k = 0; k < 8; k++)
|
||||
{
|
||||
if (bitmap.GetPixel(j * 8 + k, i).GetBrightness() >= 0.5f)
|
||||
{
|
||||
b = (byte)(b | (byte)(128 >> k));
|
||||
}
|
||||
}
|
||||
stringBuilder.Append(b.ToString("X2"));
|
||||
}
|
||||
stringBuilder.Append("\n");
|
||||
}
|
||||
stringBuilder.AppendFormat("x={0}\n", bitmap.Width);
|
||||
stringBuilder.AppendFormat("y={0}\n", bitmap.Height);
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,157 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PlasmaFontTool : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private TableLayoutPanel tableLayoutPanel1;
|
||||
|
||||
private PlasmaView mLargePlasma;
|
||||
|
||||
private PlasmaView mSmallPlasma;
|
||||
|
||||
private TableLayoutPanel tableLayoutPanel2;
|
||||
|
||||
private TextBox mText;
|
||||
|
||||
private Label mTextLabel;
|
||||
|
||||
private Label mFontLabel;
|
||||
|
||||
private ComboBox mFont;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.mLargePlasma = new TeslaConsole.PlasmaView();
|
||||
this.mSmallPlasma = new TeslaConsole.PlasmaView();
|
||||
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.mText = new System.Windows.Forms.TextBox();
|
||||
this.mTextLabel = new System.Windows.Forms.Label();
|
||||
this.mFontLabel = new System.Windows.Forms.Label();
|
||||
this.mFont = new System.Windows.Forms.ComboBox();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.tableLayoutPanel2.SuspendLayout();
|
||||
base.SuspendLayout();
|
||||
this.tableLayoutPanel1.ColumnCount = 2;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 66.66666f));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33334f));
|
||||
this.tableLayoutPanel1.Controls.Add(this.mLargePlasma, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.mSmallPlasma, 1, 1);
|
||||
this.tableLayoutPanel1.Controls.Add(this.tableLayoutPanel2, 1, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 3;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25f));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50f));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 25f));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(1035, 425);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
this.mLargePlasma.BackColor = System.Drawing.Color.Black;
|
||||
this.mLargePlasma.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mLargePlasma.Enabled = false;
|
||||
this.mLargePlasma.ForeColor = System.Drawing.Color.DarkOrange;
|
||||
this.mLargePlasma.Location = new System.Drawing.Point(3, 3);
|
||||
this.mLargePlasma.Name = "mLargePlasma";
|
||||
this.tableLayoutPanel1.SetRowSpan(this.mLargePlasma, 3);
|
||||
this.mLargePlasma.Size = new System.Drawing.Size(683, 419);
|
||||
this.mLargePlasma.TabIndex = 0;
|
||||
this.mSmallPlasma.BackColor = System.Drawing.Color.Black;
|
||||
this.mSmallPlasma.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mSmallPlasma.Enabled = false;
|
||||
this.mSmallPlasma.ForeColor = System.Drawing.Color.DarkOrange;
|
||||
this.mSmallPlasma.Location = new System.Drawing.Point(692, 109);
|
||||
this.mSmallPlasma.Name = "mSmallPlasma";
|
||||
this.mSmallPlasma.Size = new System.Drawing.Size(340, 206);
|
||||
this.mSmallPlasma.TabIndex = 1;
|
||||
this.tableLayoutPanel2.ColumnCount = 2;
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tableLayoutPanel2.Controls.Add(this.mText, 1, 1);
|
||||
this.tableLayoutPanel2.Controls.Add(this.mTextLabel, 0, 1);
|
||||
this.tableLayoutPanel2.Controls.Add(this.mFontLabel, 0, 0);
|
||||
this.tableLayoutPanel2.Controls.Add(this.mFont, 1, 0);
|
||||
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel2.Location = new System.Drawing.Point(692, 3);
|
||||
this.tableLayoutPanel2.Name = "tableLayoutPanel2";
|
||||
this.tableLayoutPanel2.RowCount = 3;
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tableLayoutPanel2.Size = new System.Drawing.Size(340, 100);
|
||||
this.tableLayoutPanel2.TabIndex = 2;
|
||||
this.mText.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mText.Location = new System.Drawing.Point(40, 30);
|
||||
this.mText.Name = "mText";
|
||||
this.mText.Size = new System.Drawing.Size(297, 20);
|
||||
this.mText.TabIndex = 0;
|
||||
this.mText.TextChanged += new System.EventHandler(RebuildImages);
|
||||
this.mTextLabel.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mTextLabel.AutoSize = true;
|
||||
this.mTextLabel.Location = new System.Drawing.Point(3, 33);
|
||||
this.mTextLabel.Name = "mTextLabel";
|
||||
this.mTextLabel.Size = new System.Drawing.Size(31, 13);
|
||||
this.mTextLabel.TabIndex = 1;
|
||||
this.mTextLabel.Text = "Text:";
|
||||
this.mFontLabel.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFontLabel.AutoSize = true;
|
||||
this.mFontLabel.Location = new System.Drawing.Point(3, 7);
|
||||
this.mFontLabel.Name = "mFontLabel";
|
||||
this.mFontLabel.Size = new System.Drawing.Size(31, 13);
|
||||
this.mFontLabel.TabIndex = 2;
|
||||
this.mFontLabel.Text = "Font:";
|
||||
this.mFont.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mFont.FormattingEnabled = true;
|
||||
this.mFont.Location = new System.Drawing.Point(40, 3);
|
||||
this.mFont.Name = "mFont";
|
||||
this.mFont.Size = new System.Drawing.Size(297, 21);
|
||||
this.mFont.TabIndex = 3;
|
||||
this.mFont.SelectedIndexChanged += new System.EventHandler(RebuildImages);
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(1035, 425);
|
||||
base.Controls.Add(this.tableLayoutPanel1);
|
||||
base.Name = "PlasmaFontTool";
|
||||
this.Text = "Plasma Font Tool";
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.ResumeLayout(false);
|
||||
this.tableLayoutPanel2.PerformLayout();
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
|
||||
public PlasmaFontTool()
|
||||
{
|
||||
InitializeComponent();
|
||||
FontFamily[] families = new InstalledFontCollection().Families;
|
||||
foreach (FontFamily fontFamily in families)
|
||||
{
|
||||
mFont.Items.Add(fontFamily.Name);
|
||||
}
|
||||
mFont.SelectedItem = "Microsoft Sans Serif";
|
||||
}
|
||||
|
||||
private void RebuildImages(object sender, EventArgs e)
|
||||
{
|
||||
PlasmaBitmaps.GenerateBitmaps(out var large, out var small, mFont.Text, mText.Text);
|
||||
mLargePlasma.SetBitmap(large);
|
||||
mSmallPlasma.SetBitmap(small);
|
||||
large.Dispose();
|
||||
small.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,313 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
[Serializable]
|
||||
public class Pod : IDisposable
|
||||
{
|
||||
[NonSerialized]
|
||||
private EventHandler mOnOnlineChanged;
|
||||
|
||||
private Guid mId = Guid.NewGuid();
|
||||
|
||||
private IPAddress mIPAddress = IPAddress.Any;
|
||||
|
||||
private IPAddress mGateway = IPAddress.Any;
|
||||
|
||||
private IPAddress mDns = IPAddress.Any;
|
||||
|
||||
private IPAddress mSubnet = IPAddress.Any;
|
||||
|
||||
private string mHostName = "";
|
||||
|
||||
private byte[] mKey;
|
||||
|
||||
private byte[] mMacAddress;
|
||||
|
||||
private string mName;
|
||||
|
||||
private string mPodArtPath;
|
||||
|
||||
private HostType mHostType;
|
||||
|
||||
private bool mOnline;
|
||||
|
||||
[NonSerialized]
|
||||
private Image mPodArtImage;
|
||||
|
||||
[NonSerialized]
|
||||
private MungaGame mMungaGame;
|
||||
|
||||
public Guid ID
|
||||
{
|
||||
get
|
||||
{
|
||||
return mId;
|
||||
}
|
||||
set
|
||||
{
|
||||
mId = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLocal
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mKey != null)
|
||||
{
|
||||
return mKey.Length > 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress IPAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return mIPAddress;
|
||||
}
|
||||
set
|
||||
{
|
||||
mIPAddress = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress DNS
|
||||
{
|
||||
get
|
||||
{
|
||||
return mDns;
|
||||
}
|
||||
set
|
||||
{
|
||||
mDns = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress Gateway
|
||||
{
|
||||
get
|
||||
{
|
||||
return mGateway;
|
||||
}
|
||||
set
|
||||
{
|
||||
mGateway = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IPAddress Subnet
|
||||
{
|
||||
get
|
||||
{
|
||||
return mSubnet;
|
||||
}
|
||||
set
|
||||
{
|
||||
mSubnet = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string HostName
|
||||
{
|
||||
get
|
||||
{
|
||||
return mHostName;
|
||||
}
|
||||
set
|
||||
{
|
||||
mHostName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] Key
|
||||
{
|
||||
get
|
||||
{
|
||||
return mKey;
|
||||
}
|
||||
set
|
||||
{
|
||||
mKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
set
|
||||
{
|
||||
mName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] MacAddress
|
||||
{
|
||||
get
|
||||
{
|
||||
return mMacAddress;
|
||||
}
|
||||
set
|
||||
{
|
||||
mMacAddress = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string PodArtFilePath
|
||||
{
|
||||
get
|
||||
{
|
||||
return mPodArtPath;
|
||||
}
|
||||
set
|
||||
{
|
||||
mPodArtPath = value;
|
||||
}
|
||||
}
|
||||
|
||||
public HostType HostType
|
||||
{
|
||||
get
|
||||
{
|
||||
return mHostType;
|
||||
}
|
||||
set
|
||||
{
|
||||
mHostType = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Image PodArtImage
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mPodArtImage == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (mPodArtPath == null || !File.Exists(mPodArtPath))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
mPodArtImage = Image.FromFile(mPodArtPath);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
return mPodArtImage;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Online
|
||||
{
|
||||
get
|
||||
{
|
||||
return mOnline;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != mOnline)
|
||||
{
|
||||
mOnline = value;
|
||||
if (mOnOnlineChanged != null)
|
||||
{
|
||||
mOnOnlineChanged(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MungaGame MungaGame
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mMungaGame == null)
|
||||
{
|
||||
mMungaGame = new MungaGame(this);
|
||||
}
|
||||
return mMungaGame;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler OnOnlineChanged
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
add
|
||||
{
|
||||
mOnOnlineChanged = (EventHandler)Delegate.Combine(mOnOnlineChanged, value);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
remove
|
||||
{
|
||||
mOnOnlineChanged = (EventHandler)Delegate.Remove(mOnOnlineChanged, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Pod()
|
||||
{
|
||||
mMungaGame = new MungaGame(this);
|
||||
}
|
||||
|
||||
public Pod Clone()
|
||||
{
|
||||
Pod pod = new Pod();
|
||||
pod.mId = mId;
|
||||
pod.mIPAddress = mIPAddress;
|
||||
pod.mGateway = mGateway;
|
||||
pod.mDns = mDns;
|
||||
pod.mSubnet = mSubnet;
|
||||
pod.mHostName = mHostName;
|
||||
pod.mKey = mKey;
|
||||
pod.mMacAddress = mMacAddress;
|
||||
pod.mName = mName;
|
||||
pod.mPodArtPath = mPodArtPath;
|
||||
pod.mHostType = mHostType;
|
||||
pod.mOnline = mOnline;
|
||||
pod.mPodArtImage = mPodArtImage;
|
||||
pod.mMungaGame = mMungaGame;
|
||||
return pod;
|
||||
}
|
||||
|
||||
public bool MacAddressEquals(byte[] macAddress)
|
||||
{
|
||||
if (mMacAddress == null)
|
||||
{
|
||||
return macAddress == null;
|
||||
}
|
||||
if (mMacAddress.Length != macAddress.Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < macAddress.Length; i++)
|
||||
{
|
||||
if (mMacAddress[i] != macAddress[i])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
~Pod()
|
||||
{
|
||||
Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (mPodArtImage != null)
|
||||
{
|
||||
mPodArtImage.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PodActionDialog : Form
|
||||
{
|
||||
private delegate void ActionCompleted();
|
||||
|
||||
private class ActionItem
|
||||
{
|
||||
private readonly PodInfo mPodInfo;
|
||||
|
||||
private readonly Action<PodInfo> mAction;
|
||||
|
||||
private readonly ActionCompleted mActionCompleted;
|
||||
|
||||
private readonly ListViewItem rListViewItem;
|
||||
|
||||
private bool mDone;
|
||||
|
||||
private bool mCanceled;
|
||||
|
||||
private bool mError;
|
||||
|
||||
public ListViewItem ListViewItem => rListViewItem;
|
||||
|
||||
public bool Done
|
||||
{
|
||||
get
|
||||
{
|
||||
return mDone;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!mDone && value)
|
||||
{
|
||||
mDone = true;
|
||||
mActionCompleted();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Canceled
|
||||
{
|
||||
get
|
||||
{
|
||||
return mCanceled;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!mDone && !mCanceled && value)
|
||||
{
|
||||
mCanceled = true;
|
||||
Done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool Error => mError;
|
||||
|
||||
public ActionItem(PodInfo podInfo, Action<PodInfo> action, ActionCompleted complete)
|
||||
{
|
||||
mPodInfo = podInfo;
|
||||
mAction = action;
|
||||
mActionCompleted = complete;
|
||||
rListViewItem = new ListViewItem(new string[2]
|
||||
{
|
||||
mPodInfo.Pod.Name,
|
||||
"Connecting..."
|
||||
});
|
||||
}
|
||||
|
||||
public void Begin()
|
||||
{
|
||||
mPodInfo.EnqueueConnectAction(DoAction);
|
||||
}
|
||||
|
||||
private void DoAction(PodInfo pod)
|
||||
{
|
||||
if (!mCanceled)
|
||||
{
|
||||
try
|
||||
{
|
||||
mAction(pod);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rListViewItem.SubItems[1].Text = ex.Message;
|
||||
mError = true;
|
||||
}
|
||||
if (!mError)
|
||||
{
|
||||
rListViewItem.SubItems[1].Text = "Complete";
|
||||
}
|
||||
Done = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IContainer components;
|
||||
|
||||
private Button mCancel;
|
||||
|
||||
private ListView mActionList;
|
||||
|
||||
private ColumnHeader mPodColumn;
|
||||
|
||||
private ColumnHeader mStatusColumn;
|
||||
|
||||
private readonly List<ActionItem> mActionItems = new List<ActionItem>();
|
||||
|
||||
private bool mDone;
|
||||
|
||||
private bool mError;
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.mCancel = new System.Windows.Forms.Button();
|
||||
this.mActionList = new System.Windows.Forms.ListView();
|
||||
this.mPodColumn = new System.Windows.Forms.ColumnHeader();
|
||||
this.mStatusColumn = new System.Windows.Forms.ColumnHeader();
|
||||
base.SuspendLayout();
|
||||
this.mCancel.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mCancel.Location = new System.Drawing.Point(377, 247);
|
||||
this.mCancel.Name = "mCancel";
|
||||
this.mCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.mCancel.TabIndex = 0;
|
||||
this.mCancel.Text = "Cancel";
|
||||
this.mCancel.UseVisualStyleBackColor = true;
|
||||
this.mCancel.Click += new System.EventHandler(mCancel_Click);
|
||||
this.mActionList.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.mActionList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[2] { this.mPodColumn, this.mStatusColumn });
|
||||
this.mActionList.GridLines = true;
|
||||
this.mActionList.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable;
|
||||
this.mActionList.Location = new System.Drawing.Point(12, 12);
|
||||
this.mActionList.MultiSelect = false;
|
||||
this.mActionList.Name = "mActionList";
|
||||
this.mActionList.Size = new System.Drawing.Size(440, 229);
|
||||
this.mActionList.TabIndex = 1;
|
||||
this.mActionList.UseCompatibleStateImageBehavior = false;
|
||||
this.mActionList.View = System.Windows.Forms.View.Details;
|
||||
this.mPodColumn.Text = "Pod";
|
||||
this.mPodColumn.Width = 300;
|
||||
this.mStatusColumn.Text = "Status";
|
||||
this.mStatusColumn.Width = 120;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(464, 282);
|
||||
base.Controls.Add(this.mActionList);
|
||||
base.Controls.Add(this.mCancel);
|
||||
base.Name = "PodActionDialog";
|
||||
this.Text = "Performing Action...";
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
|
||||
public static void Show(ICollection<PodInfo> pods, Action<PodInfo> action, string title)
|
||||
{
|
||||
if (pods.Count > 0)
|
||||
{
|
||||
PodActionDialog podActionDialog = new PodActionDialog(pods, action, title);
|
||||
if (!podActionDialog.IsDisposed)
|
||||
{
|
||||
podActionDialog.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PodActionDialog()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private PodActionDialog(IEnumerable<PodInfo> pods, Action<PodInfo> action, string title)
|
||||
: this()
|
||||
{
|
||||
Text = title;
|
||||
foreach (PodInfo pod in pods)
|
||||
{
|
||||
ActionItem actionItem = new ActionItem(pod, action, ItemDone);
|
||||
mActionItems.Add(actionItem);
|
||||
mActionList.Items.Add(actionItem.ListViewItem);
|
||||
}
|
||||
foreach (ActionItem mActionItem in mActionItems)
|
||||
{
|
||||
mActionItem.Begin();
|
||||
}
|
||||
if (mActionItems.Count < 1)
|
||||
{
|
||||
ItemDone();
|
||||
}
|
||||
}
|
||||
|
||||
private void ItemDone()
|
||||
{
|
||||
if (mDone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (ActionItem mActionItem in mActionItems)
|
||||
{
|
||||
if (!mActionItem.Done)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (mActionItem.Error)
|
||||
{
|
||||
mError = true;
|
||||
}
|
||||
}
|
||||
mDone = true;
|
||||
if (!mError)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
mCancel.Text = "OK";
|
||||
}
|
||||
}
|
||||
|
||||
private void mCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void OnClosing(CancelEventArgs e)
|
||||
{
|
||||
if (!mDone)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you wish to cancel this action?", "Cancel?", MessageBoxButtons.YesNoCancel) == DialogResult.Yes)
|
||||
{
|
||||
foreach (ActionItem mActionItem in mActionItems)
|
||||
{
|
||||
mActionItem.Canceled = true;
|
||||
}
|
||||
}
|
||||
e.Cancel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using Tesla.Net;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PodAppInstance
|
||||
{
|
||||
public LaunchPair LaunchPair { get; set; }
|
||||
|
||||
public Guid PodId { get; set; }
|
||||
|
||||
public bool IsRunning { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PodConfigurationException : Exception
|
||||
{
|
||||
private Pod mPod;
|
||||
|
||||
public Pod Pod => mPod;
|
||||
|
||||
public PodConfigurationException(string message, Pod pod)
|
||||
: base(message)
|
||||
{
|
||||
mPod = pod;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,910 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Net;
|
||||
using System.ServiceProcess;
|
||||
using System.Threading;
|
||||
using Tesla.Net;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class PodInfo : Component
|
||||
{
|
||||
private delegate void ConnectWorkerEventHandler(AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void LaunchAppWorkerEventHandler(Guid appId, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void KillAppWorkerEventHandler(Guid appId, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void ShutdownWorkerEventHandler(bool restart, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void InstallProductWorkerEventHandler(string uncPath, SendOrPostCallback progressCallback, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void UninstallProductWorkerEventHandler(AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private delegate void ServiceWorkerEventHandler(string machineName, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate);
|
||||
|
||||
private const int ManagePort = 53290;
|
||||
|
||||
private static Dictionary<Guid, PodInfo> mPods = new Dictionary<Guid, PodInfo>();
|
||||
|
||||
private AsyncDelegates<ConnectWorkerEventHandler> connectDelegates;
|
||||
|
||||
private SendOrPostCallback onLaunchAppCompletedDelegate;
|
||||
|
||||
private SendOrPostCallback launchAppCompletionMethodDelegate;
|
||||
|
||||
private SendOrPostCallback onKillAppCompletedDelegate;
|
||||
|
||||
private SendOrPostCallback killAppCompletionMethodDelegate;
|
||||
|
||||
private AsyncDelegates<InstallProductWorkerEventHandler> installProductDelegates;
|
||||
|
||||
private AsyncDelegates<UninstallProductWorkerEventHandler> uninstallProductDelegates;
|
||||
|
||||
private AsyncDelegates<ServiceWorkerEventHandler> serviceGetDelegates;
|
||||
|
||||
private AsyncDelegates<ServiceWorkerEventHandler> serviceStartDelegates;
|
||||
|
||||
private AsyncDelegates<ServiceWorkerEventHandler> serviceStopDelegates;
|
||||
|
||||
private Pod mPod;
|
||||
|
||||
private IPodManagerConnection mConnection = new PodManagerConnection();
|
||||
|
||||
private object mConnectSyncRoot = new object();
|
||||
|
||||
private AsyncOperation mConnectAsyncOp;
|
||||
|
||||
private Exception mLastConnectionException;
|
||||
|
||||
private Cached<LaunchData[]> mAllApps = new Cached<LaunchData[]>(TimeSpan.FromMinutes(30.0));
|
||||
|
||||
private Cached<List<LaunchedAppData>> mRunningApps = new Cached<List<LaunchedAppData>>(TimeSpan.FromSeconds(60.0));
|
||||
|
||||
private float mVolume = float.NaN;
|
||||
|
||||
private readonly List<Action<PodInfo>> rConnectActions = new List<Action<PodInfo>>();
|
||||
|
||||
private IContainer components;
|
||||
|
||||
public Pod Pod => mPod;
|
||||
|
||||
public bool IsConnecting => mConnectAsyncOp != null;
|
||||
|
||||
public bool IsConnected
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsConnecting && mConnection != null)
|
||||
{
|
||||
return mConnection.IsOpen;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Exception LastConnectionException => mLastConnectionException;
|
||||
|
||||
public LaunchData[] AllApplications
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mAllApps.IsExpired && mConnection.IsOpen)
|
||||
{
|
||||
try
|
||||
{
|
||||
mAllApps.Item = mConnection.GetInstalledApps();
|
||||
}
|
||||
catch
|
||||
{
|
||||
mConnection.Close();
|
||||
mAllApps.Expire();
|
||||
return new LaunchData[0];
|
||||
}
|
||||
}
|
||||
return mAllApps.Item;
|
||||
}
|
||||
}
|
||||
|
||||
public LaunchedAppData[] RunningApplications
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!mConnection.IsOpen)
|
||||
{
|
||||
return new LaunchedAppData[0];
|
||||
}
|
||||
if (mRunningApps.IsExpired)
|
||||
{
|
||||
try
|
||||
{
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
mRunningApps.Item = new List<LaunchedAppData>(mConnection.GetLaunchedApps());
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
mConnection.Close();
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
mRunningApps.Expire();
|
||||
}
|
||||
return new LaunchedAppData[0];
|
||||
}
|
||||
}
|
||||
if (mRunningApps.Item == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return mRunningApps.Item.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public float Volume
|
||||
{
|
||||
get
|
||||
{
|
||||
if (float.IsNaN(mVolume) && mConnection.IsOpen)
|
||||
{
|
||||
try
|
||||
{
|
||||
mVolume = mConnection.VolumeLevel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
mConnection.Close();
|
||||
mVolume = float.NaN;
|
||||
}
|
||||
}
|
||||
return mVolume;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (mConnection.IsOpen)
|
||||
{
|
||||
mVolume = value;
|
||||
try
|
||||
{
|
||||
mConnection.VolumeLevel = value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
mConnection.Close();
|
||||
mVolume = float.NaN;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsServiceRunning
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
ServiceController serviceController = new ServiceController("TeslaLauncherService", mPod.IPAddress.ToString());
|
||||
return serviceController.Status == ServiceControllerStatus.Running;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<AsyncCompletedEventArgs> ConnectCompleted;
|
||||
|
||||
public event EventHandler<ApplicationCompletedEventArgs> LaunchApplicationCompleted;
|
||||
|
||||
public event EventHandler<ApplicationCompletedEventArgs> KillApplicationCompleted;
|
||||
|
||||
public event EventHandler<InstallProductProgressEventArgs> InstallProductProgress;
|
||||
|
||||
public event EventHandler<InstallProductCompletedEventArgs> InstallProductCompleted;
|
||||
|
||||
public event EventHandler<AsyncCompletedEventArgs> UninstallProductCompleted;
|
||||
|
||||
public event EventHandler<ServiceStatusEventArgs> ServiceStatusGetCompleted;
|
||||
|
||||
public event EventHandler<AsyncCompletedEventArgs> ServiceStartCompleted;
|
||||
|
||||
public event EventHandler<AsyncCompletedEventArgs> ServiceStopCompleted;
|
||||
|
||||
public PodInfo()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitializeDelegates();
|
||||
}
|
||||
|
||||
public PodInfo(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
InitializeComponent();
|
||||
InitializeDelegates();
|
||||
}
|
||||
|
||||
public PodInfo(Pod pod)
|
||||
: this(pod, register: false)
|
||||
{
|
||||
}
|
||||
|
||||
public PodInfo(Pod pod, bool register)
|
||||
: this()
|
||||
{
|
||||
mPod = pod;
|
||||
if (register)
|
||||
{
|
||||
RegisterPod(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void InitializeDelegates()
|
||||
{
|
||||
connectDelegates = new AsyncDelegates<ConnectWorkerEventHandler>(ConnectCompletedInternal, ConnectCompletionMethod);
|
||||
onLaunchAppCompletedDelegate = LaunchAppCompleted;
|
||||
launchAppCompletionMethodDelegate = LaunchAppCompletionMethod;
|
||||
onKillAppCompletedDelegate = KillAppCompleted;
|
||||
killAppCompletionMethodDelegate = KillAppCompletionMethod;
|
||||
installProductDelegates = new AsyncDelegates<InstallProductWorkerEventHandler>(InstallProductReportProgress, InstallProductInternalCompleted, InstallProductCompletionMethod);
|
||||
uninstallProductDelegates = new AsyncDelegates<UninstallProductWorkerEventHandler>(UninstallProductInternalCompleted, UninstallProductCompletionMethod);
|
||||
serviceGetDelegates = new AsyncDelegates<ServiceWorkerEventHandler>(ServiceStatusGetCompletedInternal, ServiceStatusGetCompletionMethod);
|
||||
serviceStartDelegates = new AsyncDelegates<ServiceWorkerEventHandler>(ServiceStartCompletedInternal, ServiceStartCompletionMethod);
|
||||
serviceStopDelegates = new AsyncDelegates<ServiceWorkerEventHandler>(ServiceStopCompletedInternal, ServiceStopCompletionMethod);
|
||||
}
|
||||
|
||||
public static void RegisterPod(PodInfo pod)
|
||||
{
|
||||
mPods[pod.Pod.ID] = pod;
|
||||
}
|
||||
|
||||
public static PodInfo GetPod(Guid id)
|
||||
{
|
||||
PodInfo value = null;
|
||||
if (mPods.TryGetValue(id, out value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public bool EnqueueConnectAction(Action<PodInfo> action)
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
action(this);
|
||||
return true;
|
||||
}
|
||||
rConnectActions.Add(action);
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Disconnect()
|
||||
{
|
||||
if (mConnectAsyncOp != null)
|
||||
{
|
||||
CancelConnectAsync();
|
||||
}
|
||||
else if (IsConnected)
|
||||
{
|
||||
mConnection.Close();
|
||||
}
|
||||
mLastConnectionException = null;
|
||||
mAllApps.Expire();
|
||||
mRunningApps.Expire();
|
||||
mVolume = float.NaN;
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot refresh pod info while disconnected.");
|
||||
}
|
||||
try
|
||||
{
|
||||
FullUpdateData fullUpdateData = mConnection.FullUpdate();
|
||||
mAllApps.Item = fullUpdateData.InstalledApps;
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
mRunningApps.Item = new List<LaunchedAppData>(fullUpdateData.LaunchedApps);
|
||||
}
|
||||
mVolume = fullUpdateData.VolumeLevel;
|
||||
}
|
||||
catch
|
||||
{
|
||||
mConnection.Close();
|
||||
mAllApps.Expire();
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
mRunningApps.Expire();
|
||||
}
|
||||
mVolume = float.NaN;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAppRunning(Guid appId)
|
||||
{
|
||||
LaunchedAppData[] runningApplications = RunningApplications;
|
||||
return Array.Exists(runningApplications, (LaunchedAppData app) => app.LaunchKey == appId);
|
||||
}
|
||||
|
||||
public void AddApp(LaunchData appData)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Application cannot be added while disconnected.");
|
||||
}
|
||||
try
|
||||
{
|
||||
mConnection.InstallApp(appData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Program.LogException(ex, "Add Application Failed.");
|
||||
mConnection.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void Shutdown(bool restart)
|
||||
{
|
||||
try
|
||||
{
|
||||
mConnection.Shutdown(restart);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Program.LogExceptionAndShowDialog(ex, "Remote Shutdown Failed.", "Remote Shutdown Failed.");
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearStore()
|
||||
{
|
||||
mConnection.ClearStore();
|
||||
}
|
||||
|
||||
private void ConnectCompletedInternal(object operationState)
|
||||
{
|
||||
AsyncCompletedEventArgs e = operationState as AsyncCompletedEventArgs;
|
||||
OnConnectCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnConnectCompleted(AsyncCompletedEventArgs e)
|
||||
{
|
||||
if (IsConnected)
|
||||
{
|
||||
foreach (Action<PodInfo> rConnectAction in rConnectActions)
|
||||
{
|
||||
rConnectAction(this);
|
||||
}
|
||||
rConnectActions.Clear();
|
||||
}
|
||||
if (this.ConnectCompleted != null)
|
||||
{
|
||||
this.ConnectCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState asyncControlState = completionState as AsyncControlState;
|
||||
AsyncCompletedEventArgs asyncCompletedEventArgs = new AsyncCompletedEventArgs(asyncControlState.ex, cancelled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
mLastConnectionException = asyncCompletedEventArgs.Error;
|
||||
lock (mConnectSyncRoot)
|
||||
{
|
||||
if (mConnectAsyncOp != null)
|
||||
{
|
||||
mConnectAsyncOp.PostOperationCompleted(connectDelegates.OnCompleted, asyncCompletedEventArgs);
|
||||
mConnectAsyncOp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ConnectWorker(AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
mAllApps.Expire();
|
||||
mRunningApps.Expire();
|
||||
mVolume = float.NaN;
|
||||
try
|
||||
{
|
||||
if (!mConnection.IsOpen)
|
||||
{
|
||||
if (mPod.IPAddress == IPAddress.None)
|
||||
{
|
||||
throw new ArgumentException("Pod IP address cannot be empty.", "IPAddress");
|
||||
}
|
||||
if (mPod.Key == null || mPod.Key.Length == 0)
|
||||
{
|
||||
throw new ArgumentException("Pod encryption key cannot be empty.", "Key");
|
||||
}
|
||||
mConnection.Open(new IPEndPoint(mPod.IPAddress, 53290), mPod.Key);
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState state = new AsyncControlState(ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void ConnectAsync(object userState)
|
||||
{
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
lock (mConnectSyncRoot)
|
||||
{
|
||||
if (mConnectAsyncOp != null)
|
||||
{
|
||||
throw new InvalidOperationException("Already connecting. Cannot connect again.");
|
||||
}
|
||||
mConnectAsyncOp = asyncOp;
|
||||
}
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
ConnectWorker(asyncOp, connectDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
public void CancelConnectAsync()
|
||||
{
|
||||
lock (mConnectSyncRoot)
|
||||
{
|
||||
if (mConnectAsyncOp != null)
|
||||
{
|
||||
AsyncCompletedEventArgs arg = new AsyncCompletedEventArgs(null, cancelled: true, mConnectAsyncOp.UserSuppliedState);
|
||||
mConnectAsyncOp.PostOperationCompleted(connectDelegates.OnCompleted, arg);
|
||||
mConnectAsyncOp = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchAppCompleted(object operationState)
|
||||
{
|
||||
ApplicationCompletedEventArgs e = operationState as ApplicationCompletedEventArgs;
|
||||
OnLaunchApplicationCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnLaunchApplicationCompleted(ApplicationCompletedEventArgs e)
|
||||
{
|
||||
if (this.LaunchApplicationCompleted != null)
|
||||
{
|
||||
this.LaunchApplicationCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void LaunchAppCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<Guid> asyncControlState = completionState as AsyncControlState<Guid>;
|
||||
ApplicationCompletedEventArgs arg = new ApplicationCompletedEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(onLaunchAppCompletedDelegate, arg);
|
||||
}
|
||||
|
||||
private void LaunchAppWorker(Guid appId, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
int processId = mConnection.LaunchApp(appId);
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
if (mRunningApps.Item == null)
|
||||
{
|
||||
mRunningApps.Item = new List<LaunchedAppData>();
|
||||
}
|
||||
mRunningApps.Item.Add(new LaunchedAppData
|
||||
{
|
||||
ProcessId = processId,
|
||||
LaunchKey = appId
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
completionMethodDelegate(new AsyncControlState<Guid>(appId, ex, asyncOp));
|
||||
}
|
||||
|
||||
public void LaunchApplicationAsync(Guid appId, object userState)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot launch application while disconnected.");
|
||||
}
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
LaunchAppWorker(appId, asyncOp, launchAppCompletionMethodDelegate);
|
||||
});
|
||||
}
|
||||
|
||||
private void KillAppCompleted(object operationState)
|
||||
{
|
||||
ApplicationCompletedEventArgs e = operationState as ApplicationCompletedEventArgs;
|
||||
OnKillApplicationCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnKillApplicationCompleted(ApplicationCompletedEventArgs e)
|
||||
{
|
||||
if (this.KillApplicationCompleted != null)
|
||||
{
|
||||
this.KillApplicationCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void KillAppCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<Guid> asyncControlState = completionState as AsyncControlState<Guid>;
|
||||
ApplicationCompletedEventArgs arg = new ApplicationCompletedEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(onKillAppCompletedDelegate, arg);
|
||||
}
|
||||
|
||||
private void KillAppWorker(Guid appId, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
mConnection.KillAllOfType(appId);
|
||||
lock (mRunningApps.SyncRoot)
|
||||
{
|
||||
if (mRunningApps.Item != null)
|
||||
{
|
||||
for (int num = mRunningApps.Item.Count - 1; num >= 0; num--)
|
||||
{
|
||||
if (mRunningApps.Item[num].LaunchKey == appId)
|
||||
{
|
||||
mRunningApps.Item.RemoveAt(num);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState<Guid> state = new AsyncControlState<Guid>(appId, ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void KillApplicationAsync(Guid appId, object userState)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot kill application while disconnected.");
|
||||
}
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
KillAppWorker(appId, asyncOp, killAppCompletionMethodDelegate);
|
||||
});
|
||||
}
|
||||
|
||||
private void InstallProductInternalCompleted(object operationState)
|
||||
{
|
||||
InstallProductCompletedEventArgs e = operationState as InstallProductCompletedEventArgs;
|
||||
OnInstallProductCompleted(e);
|
||||
}
|
||||
|
||||
private void InstallProductReportProgress(object state)
|
||||
{
|
||||
InstallProductProgressEventArgs e = state as InstallProductProgressEventArgs;
|
||||
OnInstallProductProgress(e);
|
||||
}
|
||||
|
||||
protected void OnInstallProductCompleted(InstallProductCompletedEventArgs e)
|
||||
{
|
||||
if (this.InstallProductCompleted != null)
|
||||
{
|
||||
this.InstallProductCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void OnInstallProductProgress(InstallProductProgressEventArgs e)
|
||||
{
|
||||
if (this.InstallProductProgress != null)
|
||||
{
|
||||
this.InstallProductProgress(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallProductCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<string> asyncControlState = completionState as AsyncControlState<string>;
|
||||
InstallProductCompletedEventArgs arg = new InstallProductCompletedEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(installProductDelegates.OnCompleted, arg);
|
||||
}
|
||||
|
||||
private void InstallProductWorker(string filePath, SendOrPostCallback progressCallback, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (!mConnection.IsOpen)
|
||||
{
|
||||
mConnection.Open(new IPEndPoint(mPod.IPAddress, 53290), mPod.Key);
|
||||
}
|
||||
Guid guid = mConnection.InstallProduct(filePath);
|
||||
if (guid == Guid.Empty)
|
||||
{
|
||||
throw new Exception($"'{filePath}' is an invalid install file.");
|
||||
}
|
||||
OutOfBandProgress outOfBandProgress;
|
||||
do
|
||||
{
|
||||
Thread.Sleep(250);
|
||||
outOfBandProgress = mConnection.GetOutOfBandProgress(guid);
|
||||
InstallProductProgressEventArgs arg = new InstallProductProgressEventArgs(outOfBandProgress.Status, outOfBandProgress.PercentComplete, asyncOp.UserSuppliedState);
|
||||
asyncOp.Post(installProductDelegates.OnProgressReport, arg);
|
||||
if (progressCallback != null)
|
||||
{
|
||||
asyncOp.Post(progressCallback, arg);
|
||||
}
|
||||
}
|
||||
while (!outOfBandProgress.IsCompleted);
|
||||
if (outOfBandProgress.PercentComplete == 99)
|
||||
{
|
||||
mAllApps.Expire();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Program.LogException(ex2, "Installation Failed");
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState<string> state = new AsyncControlState<string>(filePath, ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void InstallProductAsync(string uncPath, object userState)
|
||||
{
|
||||
InstallProductAsync(uncPath, userState, null);
|
||||
}
|
||||
|
||||
public void InstallProductAsync(string uncPath, object userState, Action<InstallProductProgressEventArgs> progressCallback)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot install application while disconnected.");
|
||||
}
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
InstallProductWorker(uncPath, delegate(object e)
|
||||
{
|
||||
progressCallback((InstallProductProgressEventArgs)e);
|
||||
}, asyncOp, installProductDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
private void UninstallProductInternalCompleted(object operationState)
|
||||
{
|
||||
AsyncCompletedEventArgs e = operationState as AsyncCompletedEventArgs;
|
||||
OnUninstallProductCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnUninstallProductCompleted(AsyncCompletedEventArgs e)
|
||||
{
|
||||
if (this.UninstallProductCompleted != null)
|
||||
{
|
||||
this.UninstallProductCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void UninstallProductCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState asyncControlState = completionState as AsyncControlState;
|
||||
AsyncCompletedEventArgs arg = new AsyncCompletedEventArgs(asyncControlState.ex, cancelled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(uninstallProductDelegates.OnCompleted, arg);
|
||||
}
|
||||
|
||||
private void UninstallProductWorker(Guid launchKey, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
if (!mConnection.IsOpen)
|
||||
{
|
||||
mConnection.Open(new IPEndPoint(mPod.IPAddress, 53290), mPod.Key);
|
||||
}
|
||||
mConnection.UninstallApp(launchKey);
|
||||
mAllApps.Expire();
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
Program.LogException(ex2, "Uninstallation Failed");
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState state = new AsyncControlState(ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void UninstallProductAsync(Guid launchKey, object userState)
|
||||
{
|
||||
if (!IsConnected)
|
||||
{
|
||||
throw new InvalidOperationException("Cannot uninstall application while disconnected.");
|
||||
}
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
UninstallProductWorker(launchKey, asyncOp, uninstallProductDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
private void ServiceStatusGetCompletedInternal(object operationState)
|
||||
{
|
||||
ServiceStatusEventArgs e = operationState as ServiceStatusEventArgs;
|
||||
OnServiceStatusGetCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnServiceStatusGetCompleted(ServiceStatusEventArgs e)
|
||||
{
|
||||
if (this.ServiceStatusGetCompleted != null)
|
||||
{
|
||||
this.ServiceStatusGetCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ServiceStatusGetCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<ServiceControllerStatus> asyncControlState = completionState as AsyncControlState<ServiceControllerStatus>;
|
||||
ServiceStatusEventArgs arg = new ServiceStatusEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(serviceGetDelegates.OnCompleted, arg);
|
||||
}
|
||||
|
||||
private void ServiceStatusWorker(string machineName, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
ServiceControllerStatus state = ServiceControllerStatus.Stopped;
|
||||
try
|
||||
{
|
||||
if (IPAddress.TryParse(machineName, out var address))
|
||||
{
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(address);
|
||||
machineName = hostEntry.HostName;
|
||||
}
|
||||
using ServiceController serviceController = new ServiceController("TeslaLauncherService", machineName);
|
||||
state = serviceController.Status;
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState<ServiceControllerStatus> state2 = new AsyncControlState<ServiceControllerStatus>(state, ex, asyncOp);
|
||||
completionMethodDelegate(state2);
|
||||
}
|
||||
|
||||
public void GetServiceStatusAsync(string machineName, object userState)
|
||||
{
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
ServiceStatusWorker(machineName, asyncOp, serviceGetDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
private void ServiceStartCompletedInternal(object operationState)
|
||||
{
|
||||
ServiceStatusEventArgs e = operationState as ServiceStatusEventArgs;
|
||||
OnServiceStartCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnServiceStartCompleted(ServiceStatusEventArgs e)
|
||||
{
|
||||
if (this.ServiceStartCompleted != null)
|
||||
{
|
||||
this.ServiceStartCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ServiceStartCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<ServiceControllerStatus> asyncControlState = completionState as AsyncControlState<ServiceControllerStatus>;
|
||||
ServiceStatusEventArgs arg = new ServiceStatusEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(serviceGetDelegates.OnCompleted, arg);
|
||||
}
|
||||
|
||||
private void ServiceStartWorker(string machineName, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
if (IPAddress.TryParse(machineName, out var address))
|
||||
{
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(address);
|
||||
machineName = hostEntry.HostName;
|
||||
}
|
||||
using ServiceController serviceController = new ServiceController("TeslaLauncherService", machineName);
|
||||
serviceController.Start();
|
||||
serviceController.WaitForStatus(ServiceControllerStatus.Running, TimeSpan.FromSeconds(30.0));
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState state = new AsyncControlState(ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void ServiceStartAsync(string machineName, object userState)
|
||||
{
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
ServiceStartWorker(machineName, asyncOp, serviceStartDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
private void ServiceStopCompletedInternal(object operationState)
|
||||
{
|
||||
ServiceStatusEventArgs e = operationState as ServiceStatusEventArgs;
|
||||
OnServiceStopCompleted(e);
|
||||
}
|
||||
|
||||
protected void OnServiceStopCompleted(ServiceStatusEventArgs e)
|
||||
{
|
||||
if (this.ServiceStopCompleted != null)
|
||||
{
|
||||
this.ServiceStopCompleted(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void ServiceStopCompletionMethod(object completionState)
|
||||
{
|
||||
AsyncControlState<ServiceControllerStatus> asyncControlState = completionState as AsyncControlState<ServiceControllerStatus>;
|
||||
ServiceStatusEventArgs arg = new ServiceStatusEventArgs(asyncControlState.state, asyncControlState.ex, canceled: false, asyncControlState.asyncOp.UserSuppliedState);
|
||||
asyncControlState.asyncOp.PostOperationCompleted(serviceGetDelegates.OnCompleted, arg);
|
||||
}
|
||||
|
||||
private void ServiceStopWorker(string machineName, AsyncOperation asyncOp, SendOrPostCallback completionMethodDelegate)
|
||||
{
|
||||
Exception ex = null;
|
||||
try
|
||||
{
|
||||
if (IPAddress.TryParse(machineName, out var address))
|
||||
{
|
||||
IPHostEntry hostEntry = Dns.GetHostEntry(address);
|
||||
machineName = hostEntry.HostName;
|
||||
}
|
||||
using ServiceController serviceController = new ServiceController("TeslaLauncherService", machineName);
|
||||
serviceController.Stop();
|
||||
serviceController.WaitForStatus(ServiceControllerStatus.Stopped, TimeSpan.FromSeconds(30.0));
|
||||
}
|
||||
catch (Exception ex2)
|
||||
{
|
||||
ex = ex2;
|
||||
}
|
||||
AsyncControlState state = new AsyncControlState(ex, asyncOp);
|
||||
completionMethodDelegate(state);
|
||||
}
|
||||
|
||||
public void ServiceStopAsync(string machineName, object userState)
|
||||
{
|
||||
AsyncOperation asyncOp = AsyncOperationManager.CreateOperation(userState);
|
||||
ThreadPool.QueueUserWorkItem(delegate
|
||||
{
|
||||
ServiceStopWorker(machineName, asyncOp, serviceStopDelegates.CompletionMethod);
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new Container();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Tesla;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal static class PodManager
|
||||
{
|
||||
public delegate void PodReadyConfigHandler(string requestId, byte[] macAddress);
|
||||
|
||||
private const int ConfigPort = 53291;
|
||||
|
||||
private static PodConfigurationServer mServer;
|
||||
|
||||
private static Dictionary<string, byte[]> mActivePods = new Dictionary<string, byte[]>();
|
||||
|
||||
public static List<string> ActiveConfigRequests => new List<string>(mActivePods.Keys);
|
||||
|
||||
public static event PodReadyConfigHandler PodReadyForConfig;
|
||||
|
||||
public static event PodReadyConfigHandler PodConfigured;
|
||||
|
||||
public static void StartConfigurationServer()
|
||||
{
|
||||
mServer = new PodConfigurationServer(53291, 53292, PodConfigurationRequestHandler);
|
||||
}
|
||||
|
||||
private static void PodConfigurationRequestHandler(byte[] macAddress, string requestId)
|
||||
{
|
||||
lock (mActivePods)
|
||||
{
|
||||
if (mActivePods.ContainsKey(requestId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
mActivePods.Add(requestId, macAddress);
|
||||
}
|
||||
if (PodManager.PodReadyForConfig != null)
|
||||
{
|
||||
PodManager.PodReadyForConfig(requestId, macAddress);
|
||||
}
|
||||
}
|
||||
|
||||
public static byte[] ConfigurePod(string requestId, string passphrase, Pod pod)
|
||||
{
|
||||
if (PodManager.PodConfigured != null)
|
||||
{
|
||||
PodManager.PodConfigured(requestId, pod.MacAddress);
|
||||
}
|
||||
byte[] result = null;
|
||||
try
|
||||
{
|
||||
result = mServer.SendEncryptionKey(passphrase, pod.IPAddress, pod.Subnet, pod.Gateway, pod.DNS, pod.HostName, TimeSpan.FromSeconds(60.0));
|
||||
}
|
||||
catch (TimeoutException)
|
||||
{
|
||||
}
|
||||
mActivePods.Remove(requestId);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static byte[] GetMacAddressForRequest(string requestId)
|
||||
{
|
||||
if (mActivePods.ContainsKey(requestId))
|
||||
{
|
||||
return mActivePods[requestId];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace TeslaConsole;
|
||||
|
||||
public enum PodState
|
||||
{
|
||||
Offline = -5,
|
||||
Disconnected,
|
||||
Connecting,
|
||||
Critical,
|
||||
Connected,
|
||||
InitializingState,
|
||||
WaitingForEgg,
|
||||
LoadingMission,
|
||||
WaitingForLaunch,
|
||||
LaunchingMission,
|
||||
RunningMission,
|
||||
EndingMission,
|
||||
StoppingMission,
|
||||
SuspendingMission,
|
||||
ResumingMission,
|
||||
AbortingMission,
|
||||
CreatingMission,
|
||||
ApplicationStateCount
|
||||
}
|
||||
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.IsolatedStorage;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
private static Mutex sInstanceMutex = null;
|
||||
|
||||
private static readonly string sExceptionFile = Path.Combine(GetCommonAppDataDirectory(), "ExceptionLog.txt");
|
||||
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
if (args.Length >= 1 && args[0] == "/migrateIsoStore")
|
||||
{
|
||||
try
|
||||
{
|
||||
string path = Path.Combine(GetCommonAppDataDirectory(), "local.siteconfig");
|
||||
IsolatedStorageFile machineStoreForAssembly = IsolatedStorageFile.GetMachineStoreForAssembly();
|
||||
if (machineStoreForAssembly.GetFileNames("local.siteconfig").Length > 0)
|
||||
{
|
||||
using (IsolatedStorageFileStream isolatedStorageFileStream = new IsolatedStorageFileStream("local.siteconfig", FileMode.Open, FileAccess.Read, FileShare.Read, machineStoreForAssembly))
|
||||
{
|
||||
using FileStream fileStream = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.Read);
|
||||
byte[] array = new byte[4096];
|
||||
int count;
|
||||
while ((count = isolatedStorageFileStream.Read(array, 0, array.Length)) > 0)
|
||||
{
|
||||
fileStream.Write(array, 0, count);
|
||||
}
|
||||
isolatedStorageFileStream.Close();
|
||||
fileStream.Close();
|
||||
}
|
||||
machineStoreForAssembly.DeleteFile("local.siteconfig");
|
||||
}
|
||||
Environment.Exit(0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.ToString());
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
sInstanceMutex = new Mutex(initiallyOwned: false, "TeslaConsole1Instance", out var createdNew);
|
||||
if (!createdNew)
|
||||
{
|
||||
MessageBox.Show("Another instance of the Tesla Console is alread open.", "Tesla Console Open", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
Application.ThreadException += Application_ThreadException;
|
||||
}
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(defaultValue: false);
|
||||
Application.Run(new TeslaConsoleForm());
|
||||
}
|
||||
|
||||
internal static string GetCommonAppDataDirectory()
|
||||
{
|
||||
string text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Tesla Console");
|
||||
if (!Directory.Exists(text))
|
||||
{
|
||||
Directory.CreateDirectory(text);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
LogExceptionAndShowDialog(e.Exception, "An unhandled exception occurred, and the console must exit.", "Unhandled Exception");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
|
||||
public static bool LogException(Exception ex, string generalMessage)
|
||||
{
|
||||
return LogString((generalMessage != null) ? generalMessage : "No general message available.", (ex != null) ? ex.ToString() : "The exception was null!");
|
||||
}
|
||||
|
||||
public static bool LogMessage(string generalMessage)
|
||||
{
|
||||
return LogString(generalMessage, null);
|
||||
}
|
||||
|
||||
private static bool LogString(string generalString, string exceptionString)
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendLine("**********");
|
||||
stringBuilder.AppendLine(DateTime.Now.ToString());
|
||||
if (!string.IsNullOrEmpty(generalString))
|
||||
{
|
||||
stringBuilder.AppendLine(generalString);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(exceptionString))
|
||||
{
|
||||
stringBuilder.AppendLine(exceptionString);
|
||||
}
|
||||
lock (sExceptionFile)
|
||||
{
|
||||
string commonAppDataDirectory = GetCommonAppDataDirectory();
|
||||
if (!Directory.Exists(commonAppDataDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(commonAppDataDirectory);
|
||||
}
|
||||
File.AppendAllText(sExceptionFile, stringBuilder.ToString(), Encoding.UTF8);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void LogExceptionAndShowDialog(Exception ex, string generalMessage, string messageBoxTitle)
|
||||
{
|
||||
if (LogException(ex, generalMessage))
|
||||
{
|
||||
MessageBox.Show($"{generalMessage} The associated exception has been logged in \"{sExceptionFile}\". Please send this file to support@elsewhenstudios.com", messageBoxTitle, MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.AppendLine((generalMessage != null) ? generalMessage : "No general message available.");
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine("The associated exception could not be logged. Please give the following information to support@elsewhenstudios.com");
|
||||
stringBuilder.AppendLine();
|
||||
stringBuilder.AppendLine((ex != null) ? ex.ToString() : "The exception was null!");
|
||||
MessageBox.Show(stringBuilder.ToString(), messageBoxTitle, MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class RPStrings
|
||||
{
|
||||
private static bool sInitalized = false;
|
||||
|
||||
private static List<string> sFirstScore = new List<string>();
|
||||
|
||||
private static List<string> sFirstBoost = new List<string>();
|
||||
|
||||
private static List<string> sFirstDeath = new List<string>();
|
||||
|
||||
private static List<string> sFirstKill = new List<string>();
|
||||
|
||||
private static List<string> sShortestLap = new List<string>();
|
||||
|
||||
private static List<string> sLightDamage = new List<string>();
|
||||
|
||||
private static List<string> sModerateDamage = new List<string>();
|
||||
|
||||
private static List<string> sHeavyDamage = new List<string>();
|
||||
|
||||
private static List<string> sKill = new List<string>();
|
||||
|
||||
private static List<string> sSelfKill = new List<string>();
|
||||
|
||||
private static List<string> sScore = new List<string>();
|
||||
|
||||
private static List<string> sBoost = new List<string>();
|
||||
|
||||
private static List<string> sRecap = new List<string>();
|
||||
|
||||
private static Random sRandom = new Random();
|
||||
|
||||
private static void Initalize()
|
||||
{
|
||||
XmlDocument xmlDocument = new XmlDocument();
|
||||
xmlDocument.Load(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "RedPlanet\\RPStrings.xml"));
|
||||
if (xmlDocument.DocumentElement.Name != "RPStrings")
|
||||
{
|
||||
throw new XmlException("Document element was not an RPStrings node.");
|
||||
}
|
||||
foreach (XmlNode childNode in xmlDocument.DocumentElement.ChildNodes)
|
||||
{
|
||||
switch (childNode.Name)
|
||||
{
|
||||
case "FirstScore":
|
||||
if (!sFirstScore.Contains(childNode.InnerText))
|
||||
{
|
||||
sFirstScore.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "FirstBoost":
|
||||
if (!sFirstBoost.Contains(childNode.InnerText))
|
||||
{
|
||||
sFirstBoost.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "FirstDeath":
|
||||
if (!sFirstDeath.Contains(childNode.InnerText))
|
||||
{
|
||||
sFirstDeath.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "FirstKill":
|
||||
if (!sFirstKill.Contains(childNode.InnerText))
|
||||
{
|
||||
sFirstKill.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "ShortestLap":
|
||||
if (!sShortestLap.Contains(childNode.InnerText))
|
||||
{
|
||||
sShortestLap.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "LightDamage":
|
||||
if (!sLightDamage.Contains(childNode.InnerText))
|
||||
{
|
||||
sLightDamage.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "ModerateDamage":
|
||||
if (!sModerateDamage.Contains(childNode.InnerText))
|
||||
{
|
||||
sModerateDamage.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "HeavyDamage":
|
||||
if (!sHeavyDamage.Contains(childNode.InnerText))
|
||||
{
|
||||
sHeavyDamage.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "Kill":
|
||||
if (!sKill.Contains(childNode.InnerText))
|
||||
{
|
||||
sKill.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "SelfKill":
|
||||
if (!sSelfKill.Contains(childNode.InnerText))
|
||||
{
|
||||
sSelfKill.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "Score":
|
||||
if (!sScore.Contains(childNode.InnerText))
|
||||
{
|
||||
sScore.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "Boost":
|
||||
if (!sBoost.Contains(childNode.InnerText))
|
||||
{
|
||||
sBoost.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
case "Recap":
|
||||
if (!sRecap.Contains(childNode.InnerText))
|
||||
{
|
||||
sRecap.Add(childNode.InnerText);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
sInitalized = true;
|
||||
}
|
||||
|
||||
private static string GetRandomStringAndReplace(List<string> list, TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
if (!sInitalized)
|
||||
{
|
||||
Initalize();
|
||||
}
|
||||
if (list.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list[sRandom.Next(list.Count)].Replace("{time}", GetTimeString(time)).Replace("{player}", player).Replace("{vehicle}", vehicle)
|
||||
.Replace("{damager}", damager);
|
||||
}
|
||||
|
||||
public static string GetTimeString(TimeSpan time)
|
||||
{
|
||||
int num = (int)(time.TotalSeconds + 0.5);
|
||||
int num2 = num / 60;
|
||||
return $"{num2:D2}:{num % 60:D2}";
|
||||
}
|
||||
|
||||
public static string FirstScore(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sFirstScore, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string FirstBoost(TimeSpan time, string player, string vehicle)
|
||||
{
|
||||
return GetRandomStringAndReplace(sFirstBoost, time, player, vehicle, "");
|
||||
}
|
||||
|
||||
public static string FirstDeath(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sFirstDeath, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string FirstKill(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sFirstKill, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string ShortestLap(TimeSpan time, TimeSpan lapTime, string player, string vehicle)
|
||||
{
|
||||
return GetRandomStringAndReplace(sShortestLap, time, player, vehicle, "").Replace("{lap_time}", GetTimeString(lapTime));
|
||||
}
|
||||
|
||||
public static string LightDamage(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sLightDamage, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string ModerateDamage(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sModerateDamage, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string HeavyDamage(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sHeavyDamage, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string Kill(TimeSpan time, string player, string vehicle, string damager)
|
||||
{
|
||||
return GetRandomStringAndReplace(sKill, time, player, vehicle, damager);
|
||||
}
|
||||
|
||||
public static string SelfKill(TimeSpan time, string player, string vehicle)
|
||||
{
|
||||
return GetRandomStringAndReplace(sSelfKill, time, player, vehicle, "");
|
||||
}
|
||||
|
||||
public static string Score(TimeSpan time, string player, string vehicle)
|
||||
{
|
||||
return GetRandomStringAndReplace(sScore, time, player, vehicle, "");
|
||||
}
|
||||
|
||||
public static string Boost(TimeSpan time, string player, string vehicle)
|
||||
{
|
||||
return GetRandomStringAndReplace(sBoost, time, player, vehicle, "");
|
||||
}
|
||||
|
||||
public static string Recap(string[] playerRanking)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder(playerRanking[0]);
|
||||
for (int i = 1; i < playerRanking.Length - 1; i++)
|
||||
{
|
||||
stringBuilder.AppendFormat(", {0}", playerRanking[i]);
|
||||
}
|
||||
return GetRandomStringAndReplace(sRecap, TimeSpan.Zero, "", "", "").Replace("{winners}", stringBuilder.ToString()).Replace("{looser}", (playerRanking.Length > 1) ? playerRanking[playerRanking.Length - 1] : "nobody");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ServiceProcess;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class ServiceStatusEventArgs : AsyncCompletedEventArgs
|
||||
{
|
||||
private ServiceControllerStatus mStatus;
|
||||
|
||||
public ServiceControllerStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
RaiseExceptionIfNecessary();
|
||||
return mStatus;
|
||||
}
|
||||
}
|
||||
|
||||
public ServiceStatusEventArgs(ServiceControllerStatus status, Exception e, bool canceled, object state)
|
||||
: base(e, canceled, state)
|
||||
{
|
||||
mStatus = status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,676 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Net;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class SetupPod : Form
|
||||
{
|
||||
private Pod mPod;
|
||||
|
||||
private Pod[] mKnownPods;
|
||||
|
||||
private IContainer components;
|
||||
|
||||
private Label lblMacAddress;
|
||||
|
||||
private TextBox txtMacAddress;
|
||||
|
||||
private TextBox txtIPAddress;
|
||||
|
||||
private Label lblIPAddress;
|
||||
|
||||
private GroupBox gbNetwork;
|
||||
|
||||
private TextBox txtSubnet;
|
||||
|
||||
private Label lblSubnet;
|
||||
|
||||
private TextBox txtDNS;
|
||||
|
||||
private Label lblDNS;
|
||||
|
||||
private Label lblGateway;
|
||||
|
||||
private TextBox txtGateway;
|
||||
|
||||
private TextBox txtPodId;
|
||||
|
||||
private Label lblPodId;
|
||||
|
||||
private TextBox txtPodName;
|
||||
|
||||
private Label lblPodName;
|
||||
|
||||
private Label lblPodType;
|
||||
|
||||
private ComboBox cmbPodType;
|
||||
|
||||
private Button cmdCancel;
|
||||
|
||||
private Button cmdOK;
|
||||
|
||||
private ErrorProvider errProvider;
|
||||
|
||||
private TextBox txtPassphrase;
|
||||
|
||||
private Label lblPassphrase;
|
||||
|
||||
private ComboBox cmbSquad;
|
||||
|
||||
private Label lblSquad;
|
||||
|
||||
private Label lblHostName;
|
||||
|
||||
private TextBox txtHostName;
|
||||
|
||||
private TableLayoutPanel tblMain;
|
||||
|
||||
private TableLayoutPanel tblButtons;
|
||||
|
||||
private TableLayoutPanel tblNetwork;
|
||||
|
||||
public Pod Pod
|
||||
{
|
||||
get
|
||||
{
|
||||
mPod.Name = txtPodName.Text;
|
||||
mPod.HostType = ((HostTypeHelper)cmbPodType.SelectedItem).HostType;
|
||||
mPod.IPAddress = IPAddress.Parse(txtIPAddress.Text);
|
||||
mPod.Subnet = IPAddress.Parse(txtSubnet.Text);
|
||||
if (string.IsNullOrEmpty(txtGateway.Text))
|
||||
{
|
||||
mPod.Gateway = IPAddress.Any;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPod.Gateway = IPAddress.Parse(txtGateway.Text);
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtDNS.Text))
|
||||
{
|
||||
mPod.DNS = IPAddress.Any;
|
||||
}
|
||||
else
|
||||
{
|
||||
mPod.DNS = IPAddress.Parse(txtDNS.Text);
|
||||
}
|
||||
mPod.HostName = txtHostName.Text;
|
||||
return mPod;
|
||||
}
|
||||
private set
|
||||
{
|
||||
mPod = value;
|
||||
txtPodName.Text = mPod.Name;
|
||||
cmbPodType.SelectedItem = (HostTypeHelper)mPod.HostType;
|
||||
txtPodId.Text = mPod.ID.ToString();
|
||||
txtMacAddress.Text = MacAddressToString(mPod.MacAddress);
|
||||
txtIPAddress.Text = (mPod.IPAddress.Equals(IPAddress.Any) ? "" : mPod.IPAddress.ToString());
|
||||
txtSubnet.Text = (mPod.IPAddress.Equals(IPAddress.Any) ? "" : mPod.Subnet.ToString());
|
||||
txtGateway.Text = ((mPod.Gateway == IPAddress.Any) ? "" : mPod.Gateway.ToString());
|
||||
txtDNS.Text = ((mPod.DNS == IPAddress.Any) ? "" : mPod.DNS.ToString());
|
||||
txtHostName.Text = mPod.HostName;
|
||||
}
|
||||
}
|
||||
|
||||
public Squad Squad => (Squad)cmbSquad.SelectedItem;
|
||||
|
||||
public string Passphrase => txtPassphrase.Text;
|
||||
|
||||
internal SetupPod(string requestId, Pod pod, List<Squad> squads)
|
||||
{
|
||||
InitializeComponent();
|
||||
cmbPodType.Items.Add((HostTypeHelper)HostType.GameMachineHostType);
|
||||
cmbPodType.Items.Add((HostTypeHelper)HostType.MissionReviewHostType);
|
||||
Text = "Configure Pod - " + requestId;
|
||||
Pod = pod;
|
||||
cmbSquad.Items.Add(new Squad(Guid.Empty, "<new squad>"));
|
||||
List<Pod> list = new List<Pod>();
|
||||
foreach (Squad squad in squads)
|
||||
{
|
||||
cmbSquad.Items.Add(squad);
|
||||
foreach (Pod pod2 in squad.Pods)
|
||||
{
|
||||
list.Add(pod2);
|
||||
}
|
||||
}
|
||||
cmbSquad.SelectedIndex = ((cmbSquad.Items.Count > 1) ? 1 : 0);
|
||||
mKnownPods = list.ToArray();
|
||||
}
|
||||
|
||||
private string MacAddressToString(byte[] macAddress)
|
||||
{
|
||||
if (macAddress.Length < 1)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder(macAddress.Length * 3 - 1);
|
||||
stringBuilder.Append(macAddress[0].ToString("X2"));
|
||||
for (int i = 1; i < macAddress.Length; i++)
|
||||
{
|
||||
stringBuilder.Append('-');
|
||||
stringBuilder.Append(macAddress[i].ToString("X2"));
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
private void txtPassphrase_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
int selectionStart = txtPassphrase.SelectionStart;
|
||||
int selectionLength = txtPassphrase.SelectionLength;
|
||||
txtPassphrase.Text = txtPassphrase.Text.ToUpper();
|
||||
txtPassphrase.Select(selectionStart, selectionLength);
|
||||
}
|
||||
|
||||
private void txtPassphrase_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
errProvider.SetError(txtPassphrase, "");
|
||||
if (txtPassphrase.Enabled && txtPassphrase.Text.Length != 5)
|
||||
{
|
||||
errProvider.SetError(txtPassphrase, "The passphrase is invalid.");
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void txtPodName_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
errProvider.SetError(txtPodName, "");
|
||||
if (string.IsNullOrEmpty(txtPodName.Text))
|
||||
{
|
||||
errProvider.SetError(txtPodName, "Pod must be given a name.");
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private bool CheckIpTextBox(TextBox textbox, bool required, CancelEventArgs e, out IPAddress address)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textbox.Text))
|
||||
{
|
||||
if (required)
|
||||
{
|
||||
errProvider.SetError(textbox, "You must enter a valid address.");
|
||||
e.Cancel = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
errProvider.SetError(textbox, "");
|
||||
}
|
||||
address = null;
|
||||
return false;
|
||||
}
|
||||
if (!IPAddress.TryParse(textbox.Text, out address) || address.ToString() != textbox.Text || address.Equals(IPAddress.Any) || address.Equals(IPAddress.Broadcast))
|
||||
{
|
||||
errProvider.SetError(textbox, "You must enter a valid address.");
|
||||
e.Cancel = true;
|
||||
address = null;
|
||||
return false;
|
||||
}
|
||||
errProvider.SetError(textbox, "");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ValidateRequiredIP(object sender, CancelEventArgs e)
|
||||
{
|
||||
CheckIpTextBox((TextBox)sender, required: true, e, out var _);
|
||||
}
|
||||
|
||||
private void ValidateOptionalIP(object sender, CancelEventArgs e)
|
||||
{
|
||||
CheckIpTextBox((TextBox)sender, required: false, e, out var _);
|
||||
}
|
||||
|
||||
private void txtIPAddress_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (!CheckIpTextBox((TextBox)sender, required: true, e, out var address))
|
||||
{
|
||||
return;
|
||||
}
|
||||
Pod[] array = mKnownPods;
|
||||
foreach (Pod pod in array)
|
||||
{
|
||||
if (pod.IPAddress.Equals(address))
|
||||
{
|
||||
errProvider.SetError((TextBox)sender, "The specified address is already in use.");
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void txtHostName_Validating(object sender, CancelEventArgs e)
|
||||
{
|
||||
errProvider.SetError(txtHostName, "");
|
||||
if (string.IsNullOrEmpty(txtHostName.Text))
|
||||
{
|
||||
errProvider.SetError(txtHostName, "Pod must be given a host name.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
if (txtHostName.Text.Length > 63)
|
||||
{
|
||||
errProvider.SetError(txtHostName, "The host name may not be longer than 63 characters.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
string text = txtHostName.Text;
|
||||
foreach (char c in text)
|
||||
{
|
||||
if ((c < '0' || c > '9') && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z') && c != '-' && c != '_')
|
||||
{
|
||||
errProvider.SetError(txtHostName, "The host name may only contain ASCII letters and number or the dash and underscore characters.");
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
Pod[] array = mKnownPods;
|
||||
foreach (Pod pod in array)
|
||||
{
|
||||
if (pod.HostName.Equals(txtHostName.Text, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
errProvider.SetError((TextBox)sender, "The specified host name is already in use.");
|
||||
e.Cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (!ValidateChildren())
|
||||
{
|
||||
return;
|
||||
}
|
||||
IPAddress iPAddress = IPAddress.Parse(txtIPAddress.Text);
|
||||
IPAddress obj = IPAddress.Parse(txtSubnet.Text);
|
||||
if (iPAddress.AddressFamily == AddressFamily.InterNetwork)
|
||||
{
|
||||
uint num = BitConverter.ToUInt32(iPAddress.GetAddressBytes(), 0);
|
||||
bool flag = false;
|
||||
bool flag2 = false;
|
||||
try
|
||||
{
|
||||
NetworkInterface[] allNetworkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
|
||||
foreach (NetworkInterface networkInterface in allNetworkInterfaces)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (UnicastIPAddressInformation unicastAddress in networkInterface.GetIPProperties().UnicastAddresses)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (unicastAddress.Address.AddressFamily != AddressFamily.InterNetwork || unicastAddress.IPv4Mask == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
uint num2 = BitConverter.ToUInt32(unicastAddress.Address.GetAddressBytes(), 0);
|
||||
uint num3 = BitConverter.ToUInt32(unicastAddress.IPv4Mask.GetAddressBytes(), 0);
|
||||
if ((num2 & num3) == (num & num3))
|
||||
{
|
||||
flag = true;
|
||||
if (unicastAddress.IPv4Mask.Equals(obj))
|
||||
{
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
if ((!flag && MessageBox.Show("The specified IP Address does not appear to be on any network directly attached to this console. Are you sure it is correct?", "IP Address Not Local", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) || (!flag2 && MessageBox.Show("The specified Subnet Mask does not match the subnet mask specified for this console. Are you sure it is correct?", "Subnet Mask Mismatch", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
base.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.lblMacAddress = new System.Windows.Forms.Label();
|
||||
this.txtMacAddress = new System.Windows.Forms.TextBox();
|
||||
this.txtIPAddress = new System.Windows.Forms.TextBox();
|
||||
this.lblIPAddress = new System.Windows.Forms.Label();
|
||||
this.gbNetwork = new System.Windows.Forms.GroupBox();
|
||||
this.lblHostName = new System.Windows.Forms.Label();
|
||||
this.txtHostName = new System.Windows.Forms.TextBox();
|
||||
this.txtGateway = new System.Windows.Forms.TextBox();
|
||||
this.txtDNS = new System.Windows.Forms.TextBox();
|
||||
this.lblDNS = new System.Windows.Forms.Label();
|
||||
this.lblGateway = new System.Windows.Forms.Label();
|
||||
this.txtSubnet = new System.Windows.Forms.TextBox();
|
||||
this.lblSubnet = new System.Windows.Forms.Label();
|
||||
this.txtPodId = new System.Windows.Forms.TextBox();
|
||||
this.lblPodId = new System.Windows.Forms.Label();
|
||||
this.txtPodName = new System.Windows.Forms.TextBox();
|
||||
this.lblPodName = new System.Windows.Forms.Label();
|
||||
this.lblPodType = new System.Windows.Forms.Label();
|
||||
this.cmbPodType = new System.Windows.Forms.ComboBox();
|
||||
this.cmdCancel = new System.Windows.Forms.Button();
|
||||
this.cmdOK = new System.Windows.Forms.Button();
|
||||
this.errProvider = new System.Windows.Forms.ErrorProvider(this.components);
|
||||
this.txtPassphrase = new System.Windows.Forms.TextBox();
|
||||
this.lblPassphrase = new System.Windows.Forms.Label();
|
||||
this.cmbSquad = new System.Windows.Forms.ComboBox();
|
||||
this.lblSquad = new System.Windows.Forms.Label();
|
||||
this.tblMain = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.tblButtons = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.tblNetwork = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.gbNetwork.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)this.errProvider).BeginInit();
|
||||
this.tblMain.SuspendLayout();
|
||||
this.tblButtons.SuspendLayout();
|
||||
this.tblNetwork.SuspendLayout();
|
||||
base.SuspendLayout();
|
||||
this.lblMacAddress.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblMacAddress.AutoSize = true;
|
||||
this.lblMacAddress.Location = new System.Drawing.Point(18, 6);
|
||||
this.lblMacAddress.Name = "lblMacAddress";
|
||||
this.lblMacAddress.Size = new System.Drawing.Size(74, 13);
|
||||
this.lblMacAddress.TabIndex = 0;
|
||||
this.lblMacAddress.Text = "MAC Address:";
|
||||
this.txtMacAddress.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtMacAddress.Location = new System.Drawing.Point(98, 3);
|
||||
this.txtMacAddress.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtMacAddress.Name = "txtMacAddress";
|
||||
this.txtMacAddress.ReadOnly = true;
|
||||
this.txtMacAddress.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtMacAddress.TabIndex = 1;
|
||||
this.txtMacAddress.TabStop = false;
|
||||
this.txtIPAddress.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtIPAddress.Location = new System.Drawing.Point(98, 29);
|
||||
this.txtIPAddress.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtIPAddress.Name = "txtIPAddress";
|
||||
this.txtIPAddress.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtIPAddress.TabIndex = 3;
|
||||
this.txtIPAddress.Validating += new System.ComponentModel.CancelEventHandler(txtIPAddress_Validating);
|
||||
this.lblIPAddress.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblIPAddress.AutoSize = true;
|
||||
this.lblIPAddress.Location = new System.Drawing.Point(31, 32);
|
||||
this.lblIPAddress.Name = "lblIPAddress";
|
||||
this.lblIPAddress.Size = new System.Drawing.Size(61, 13);
|
||||
this.lblIPAddress.TabIndex = 2;
|
||||
this.lblIPAddress.Text = "IP Address:";
|
||||
this.gbNetwork.AutoSize = true;
|
||||
this.tblMain.SetColumnSpan(this.gbNetwork, 2);
|
||||
this.gbNetwork.Controls.Add(this.tblNetwork);
|
||||
this.gbNetwork.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.gbNetwork.Location = new System.Drawing.Point(3, 135);
|
||||
this.gbNetwork.Name = "gbNetwork";
|
||||
this.gbNetwork.Size = new System.Drawing.Size(288, 175);
|
||||
this.gbNetwork.TabIndex = 11;
|
||||
this.gbNetwork.TabStop = false;
|
||||
this.gbNetwork.Text = "Network Setup";
|
||||
this.lblHostName.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblHostName.AutoSize = true;
|
||||
this.lblHostName.Location = new System.Drawing.Point(29, 136);
|
||||
this.lblHostName.Name = "lblHostName";
|
||||
this.lblHostName.Size = new System.Drawing.Size(63, 13);
|
||||
this.lblHostName.TabIndex = 11;
|
||||
this.lblHostName.Text = "Host Name:";
|
||||
this.txtHostName.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtHostName.Location = new System.Drawing.Point(98, 133);
|
||||
this.txtHostName.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtHostName.Name = "txtHostName";
|
||||
this.txtHostName.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtHostName.TabIndex = 10;
|
||||
this.txtHostName.Validating += new System.ComponentModel.CancelEventHandler(txtHostName_Validating);
|
||||
this.txtGateway.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtGateway.Location = new System.Drawing.Point(98, 81);
|
||||
this.txtGateway.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtGateway.Name = "txtGateway";
|
||||
this.txtGateway.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtGateway.TabIndex = 7;
|
||||
this.txtGateway.Validating += new System.ComponentModel.CancelEventHandler(ValidateOptionalIP);
|
||||
this.txtDNS.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtDNS.Location = new System.Drawing.Point(98, 107);
|
||||
this.txtDNS.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtDNS.Name = "txtDNS";
|
||||
this.txtDNS.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtDNS.TabIndex = 9;
|
||||
this.txtDNS.Validating += new System.ComponentModel.CancelEventHandler(ValidateOptionalIP);
|
||||
this.lblDNS.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblDNS.AutoSize = true;
|
||||
this.lblDNS.Location = new System.Drawing.Point(25, 110);
|
||||
this.lblDNS.Name = "lblDNS";
|
||||
this.lblDNS.Size = new System.Drawing.Size(67, 13);
|
||||
this.lblDNS.TabIndex = 8;
|
||||
this.lblDNS.Text = "DNS Server:";
|
||||
this.lblGateway.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblGateway.AutoSize = true;
|
||||
this.lblGateway.Location = new System.Drawing.Point(3, 84);
|
||||
this.lblGateway.Name = "lblGateway";
|
||||
this.lblGateway.Size = new System.Drawing.Size(89, 13);
|
||||
this.lblGateway.TabIndex = 6;
|
||||
this.lblGateway.Text = "Default Gateway:";
|
||||
this.txtSubnet.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtSubnet.Location = new System.Drawing.Point(98, 55);
|
||||
this.txtSubnet.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtSubnet.Name = "txtSubnet";
|
||||
this.txtSubnet.Size = new System.Drawing.Size(154, 20);
|
||||
this.txtSubnet.TabIndex = 5;
|
||||
this.txtSubnet.Validating += new System.ComponentModel.CancelEventHandler(ValidateRequiredIP);
|
||||
this.lblSubnet.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblSubnet.AutoSize = true;
|
||||
this.lblSubnet.Location = new System.Drawing.Point(19, 58);
|
||||
this.lblSubnet.Name = "lblSubnet";
|
||||
this.lblSubnet.Size = new System.Drawing.Size(73, 13);
|
||||
this.lblSubnet.TabIndex = 4;
|
||||
this.lblSubnet.Text = "Subnet Mask:";
|
||||
this.txtPodId.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtPodId.Location = new System.Drawing.Point(74, 3);
|
||||
this.txtPodId.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtPodId.Name = "txtPodId";
|
||||
this.txtPodId.ReadOnly = true;
|
||||
this.txtPodId.Size = new System.Drawing.Size(190, 20);
|
||||
this.txtPodId.TabIndex = 1;
|
||||
this.txtPodId.TabStop = false;
|
||||
this.txtPodId.Text = "{1AD57794-BD4B-4593-B1FC-B7C0F5DF360D}";
|
||||
this.lblPodId.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblPodId.AutoSize = true;
|
||||
this.lblPodId.Location = new System.Drawing.Point(25, 6);
|
||||
this.lblPodId.Name = "lblPodId";
|
||||
this.lblPodId.Size = new System.Drawing.Size(43, 13);
|
||||
this.lblPodId.TabIndex = 0;
|
||||
this.lblPodId.Text = "Pod ID:";
|
||||
this.txtPodName.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtPodName.Location = new System.Drawing.Point(74, 29);
|
||||
this.txtPodName.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtPodName.Name = "txtPodName";
|
||||
this.txtPodName.Size = new System.Drawing.Size(190, 20);
|
||||
this.txtPodName.TabIndex = 3;
|
||||
this.txtPodName.Validating += new System.ComponentModel.CancelEventHandler(txtPodName_Validating);
|
||||
this.lblPodName.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblPodName.AutoSize = true;
|
||||
this.lblPodName.Location = new System.Drawing.Point(30, 32);
|
||||
this.lblPodName.Name = "lblPodName";
|
||||
this.lblPodName.Size = new System.Drawing.Size(38, 13);
|
||||
this.lblPodName.TabIndex = 2;
|
||||
this.lblPodName.Text = "Name:";
|
||||
this.lblPodType.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblPodType.AutoSize = true;
|
||||
this.lblPodType.Location = new System.Drawing.Point(34, 59);
|
||||
this.lblPodType.Name = "lblPodType";
|
||||
this.lblPodType.Size = new System.Drawing.Size(34, 13);
|
||||
this.lblPodType.TabIndex = 4;
|
||||
this.lblPodType.Text = "Type:";
|
||||
this.cmbPodType.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmbPodType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbPodType.FormattingEnabled = true;
|
||||
this.cmbPodType.Location = new System.Drawing.Point(74, 55);
|
||||
this.cmbPodType.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.cmbPodType.Name = "cmbPodType";
|
||||
this.cmbPodType.Size = new System.Drawing.Size(190, 21);
|
||||
this.cmbPodType.TabIndex = 5;
|
||||
this.cmdCancel.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdCancel.CausesValidation = false;
|
||||
this.cmdCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cmdCancel.Location = new System.Drawing.Point(216, 3);
|
||||
this.cmdCancel.Name = "cmdCancel";
|
||||
this.cmdCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdCancel.TabIndex = 13;
|
||||
this.cmdCancel.Text = "Cancel";
|
||||
this.cmdCancel.UseVisualStyleBackColor = true;
|
||||
this.cmdOK.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdOK.Location = new System.Drawing.Point(135, 3);
|
||||
this.cmdOK.Name = "cmdOK";
|
||||
this.cmdOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdOK.TabIndex = 12;
|
||||
this.cmdOK.Text = "OK";
|
||||
this.cmdOK.UseVisualStyleBackColor = true;
|
||||
this.cmdOK.Click += new System.EventHandler(cmdOK_Click);
|
||||
this.errProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
|
||||
this.errProvider.ContainerControl = this;
|
||||
this.txtPassphrase.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtPassphrase.Location = new System.Drawing.Point(74, 109);
|
||||
this.txtPassphrase.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.txtPassphrase.MaxLength = 5;
|
||||
this.txtPassphrase.Name = "txtPassphrase";
|
||||
this.txtPassphrase.Size = new System.Drawing.Size(190, 20);
|
||||
this.txtPassphrase.TabIndex = 9;
|
||||
this.txtPassphrase.TextChanged += new System.EventHandler(txtPassphrase_TextChanged);
|
||||
this.txtPassphrase.Validating += new System.ComponentModel.CancelEventHandler(txtPassphrase_Validating);
|
||||
this.lblPassphrase.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblPassphrase.AutoSize = true;
|
||||
this.lblPassphrase.Location = new System.Drawing.Point(3, 112);
|
||||
this.lblPassphrase.Name = "lblPassphrase";
|
||||
this.lblPassphrase.Size = new System.Drawing.Size(65, 13);
|
||||
this.lblPassphrase.TabIndex = 8;
|
||||
this.lblPassphrase.Text = "Passphrase:";
|
||||
this.cmbSquad.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmbSquad.DisplayMember = "Name";
|
||||
this.cmbSquad.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.cmbSquad.FormattingEnabled = true;
|
||||
this.cmbSquad.Location = new System.Drawing.Point(74, 82);
|
||||
this.cmbSquad.Margin = new System.Windows.Forms.Padding(3, 3, 30, 3);
|
||||
this.cmbSquad.Name = "cmbSquad";
|
||||
this.cmbSquad.Size = new System.Drawing.Size(190, 21);
|
||||
this.cmbSquad.TabIndex = 7;
|
||||
this.lblSquad.Anchor = System.Windows.Forms.AnchorStyles.Right;
|
||||
this.lblSquad.AutoSize = true;
|
||||
this.lblSquad.Location = new System.Drawing.Point(27, 86);
|
||||
this.lblSquad.Name = "lblSquad";
|
||||
this.lblSquad.Size = new System.Drawing.Size(41, 13);
|
||||
this.lblSquad.TabIndex = 6;
|
||||
this.lblSquad.Text = "Squad:";
|
||||
this.tblMain.ColumnCount = 2;
|
||||
this.tblMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tblMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tblMain.Controls.Add(this.lblPodId, 0, 0);
|
||||
this.tblMain.Controls.Add(this.txtPodId, 1, 0);
|
||||
this.tblMain.Controls.Add(this.lblPodName, 0, 1);
|
||||
this.tblMain.Controls.Add(this.txtPodName, 1, 1);
|
||||
this.tblMain.Controls.Add(this.lblPodType, 0, 2);
|
||||
this.tblMain.Controls.Add(this.cmbPodType, 1, 2);
|
||||
this.tblMain.Controls.Add(this.lblSquad, 0, 3);
|
||||
this.tblMain.Controls.Add(this.cmbSquad, 1, 3);
|
||||
this.tblMain.Controls.Add(this.lblPassphrase, 0, 4);
|
||||
this.tblMain.Controls.Add(this.txtPassphrase, 1, 4);
|
||||
this.tblMain.Controls.Add(this.gbNetwork, 0, 5);
|
||||
this.tblMain.Controls.Add(this.tblButtons, 0, 7);
|
||||
this.tblMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tblMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.tblMain.Name = "tblMain";
|
||||
this.tblMain.RowCount = 8;
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tblMain.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblMain.Size = new System.Drawing.Size(294, 347);
|
||||
this.tblMain.TabIndex = 14;
|
||||
this.tblButtons.AutoSize = true;
|
||||
this.tblButtons.ColumnCount = 2;
|
||||
this.tblMain.SetColumnSpan(this.tblButtons, 2);
|
||||
this.tblButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tblButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tblButtons.Controls.Add(this.cmdOK, 0, 0);
|
||||
this.tblButtons.Controls.Add(this.cmdCancel, 1, 0);
|
||||
this.tblButtons.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tblButtons.Location = new System.Drawing.Point(0, 318);
|
||||
this.tblButtons.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tblButtons.Name = "tblButtons";
|
||||
this.tblButtons.RowCount = 1;
|
||||
this.tblButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tblButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20f));
|
||||
this.tblButtons.Size = new System.Drawing.Size(294, 29);
|
||||
this.tblButtons.TabIndex = 12;
|
||||
this.tblNetwork.AutoSize = true;
|
||||
this.tblNetwork.ColumnCount = 2;
|
||||
this.tblNetwork.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tblNetwork.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100f));
|
||||
this.tblNetwork.Controls.Add(this.lblMacAddress, 0, 0);
|
||||
this.tblNetwork.Controls.Add(this.txtMacAddress, 1, 0);
|
||||
this.tblNetwork.Controls.Add(this.lblIPAddress, 0, 1);
|
||||
this.tblNetwork.Controls.Add(this.txtIPAddress, 1, 1);
|
||||
this.tblNetwork.Controls.Add(this.lblSubnet, 0, 2);
|
||||
this.tblNetwork.Controls.Add(this.txtSubnet, 1, 2);
|
||||
this.tblNetwork.Controls.Add(this.lblGateway, 0, 3);
|
||||
this.tblNetwork.Controls.Add(this.txtGateway, 1, 3);
|
||||
this.tblNetwork.Controls.Add(this.lblDNS, 0, 4);
|
||||
this.tblNetwork.Controls.Add(this.txtDNS, 1, 4);
|
||||
this.tblNetwork.Controls.Add(this.lblHostName, 0, 5);
|
||||
this.tblNetwork.Controls.Add(this.txtHostName, 1, 5);
|
||||
this.tblNetwork.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tblNetwork.Location = new System.Drawing.Point(3, 16);
|
||||
this.tblNetwork.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tblNetwork.Name = "tblNetwork";
|
||||
this.tblNetwork.RowCount = 6;
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tblNetwork.Size = new System.Drawing.Size(282, 156);
|
||||
this.tblNetwork.TabIndex = 12;
|
||||
base.AcceptButton = this.cmdOK;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoValidate = System.Windows.Forms.AutoValidate.EnableAllowFocusChange;
|
||||
base.CancelButton = this.cmdCancel;
|
||||
base.ClientSize = new System.Drawing.Size(294, 347);
|
||||
base.Controls.Add(this.tblMain);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
base.Name = "SetupPod";
|
||||
base.ShowInTaskbar = false;
|
||||
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Configure Pod";
|
||||
this.gbNetwork.ResumeLayout(false);
|
||||
this.gbNetwork.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)this.errProvider).EndInit();
|
||||
this.tblMain.ResumeLayout(false);
|
||||
this.tblMain.PerformLayout();
|
||||
this.tblButtons.ResumeLayout(false);
|
||||
this.tblNetwork.ResumeLayout(false);
|
||||
this.tblNetwork.PerformLayout();
|
||||
base.ResumeLayout(false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class ShutdownCompletedEventArgs : AsyncCompletedEventArgs
|
||||
{
|
||||
private bool mSuccessful;
|
||||
|
||||
public bool WasSuccessful
|
||||
{
|
||||
get
|
||||
{
|
||||
RaiseExceptionIfNecessary();
|
||||
return mSuccessful;
|
||||
}
|
||||
}
|
||||
|
||||
public ShutdownCompletedEventArgs(bool wasSuccessful, Exception e, bool canceled, object state)
|
||||
: base(e, canceled, state)
|
||||
{
|
||||
mSuccessful = wasSuccessful;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class Site
|
||||
{
|
||||
private static Site mActiveConfig;
|
||||
|
||||
private List<Squad> mSquads = new List<Squad>();
|
||||
|
||||
public static Site Active
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mActiveConfig == null)
|
||||
{
|
||||
LoadFromStore();
|
||||
}
|
||||
return mActiveConfig;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Squad> Squads => mSquads;
|
||||
|
||||
public static Site LoadFromStore()
|
||||
{
|
||||
mActiveConfig = new Site();
|
||||
mActiveConfig.Load();
|
||||
return mActiveConfig;
|
||||
}
|
||||
|
||||
public static Site LoadFromFile(string filename)
|
||||
{
|
||||
mActiveConfig = new Site();
|
||||
mActiveConfig.LoadFrom(filename);
|
||||
return mActiveConfig;
|
||||
}
|
||||
|
||||
protected void Load()
|
||||
{
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
string path = Path.Combine(Program.GetCommonAppDataDirectory(), "local.siteconfig");
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using FileStream input = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
BinaryReader binaryReader = new BinaryReader(input);
|
||||
int num = binaryReader.ReadInt32();
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
Squad squad = (Squad)binaryFormatter.Deserialize(binaryReader.BaseStream);
|
||||
mSquads.Add(squad);
|
||||
int num2 = binaryReader.ReadInt32();
|
||||
for (int j = 0; j < num2; j++)
|
||||
{
|
||||
squad.Pods.Add((Pod)binaryFormatter.Deserialize(binaryReader.BaseStream));
|
||||
}
|
||||
}
|
||||
binaryReader.Close();
|
||||
}
|
||||
|
||||
protected void LoadFrom(string filename)
|
||||
{
|
||||
BinaryReader binaryReader = new BinaryReader(File.OpenRead(filename));
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
int num = binaryReader.ReadInt32();
|
||||
for (int i = 0; i < num; i++)
|
||||
{
|
||||
Squad squad = (Squad)binaryFormatter.Deserialize(binaryReader.BaseStream);
|
||||
mSquads.Add(squad);
|
||||
int num2 = binaryReader.ReadInt32();
|
||||
for (int j = 0; j < num2; j++)
|
||||
{
|
||||
squad.Pods.Add((Pod)binaryFormatter.Deserialize(binaryReader.BaseStream));
|
||||
}
|
||||
}
|
||||
binaryReader.Close();
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
string path = Path.Combine(Program.GetCommonAppDataDirectory(), "local.siteconfig");
|
||||
using (FileStream output = File.Open(path, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
BinaryWriter binaryWriter = new BinaryWriter(output);
|
||||
binaryWriter.Write(mSquads.Count);
|
||||
foreach (Squad mSquad in mSquads)
|
||||
{
|
||||
binaryFormatter.Serialize(binaryWriter.BaseStream, mSquad);
|
||||
binaryWriter.Write(mSquad.Pods.Count);
|
||||
foreach (Pod pod in mSquad.Pods)
|
||||
{
|
||||
binaryFormatter.Serialize(binaryWriter.BaseStream, pod);
|
||||
}
|
||||
}
|
||||
binaryWriter.Close();
|
||||
}
|
||||
mActiveConfig = this;
|
||||
}
|
||||
|
||||
public void SaveAs(string filename)
|
||||
{
|
||||
BinaryWriter binaryWriter = new BinaryWriter(File.OpenWrite(filename));
|
||||
BinaryFormatter binaryFormatter = new BinaryFormatter();
|
||||
binaryWriter.Write(mSquads.Count);
|
||||
foreach (Squad mSquad in mSquads)
|
||||
{
|
||||
binaryFormatter.Serialize(binaryWriter.BaseStream, mSquad);
|
||||
binaryWriter.Write(mSquad.Pods.Count);
|
||||
foreach (Pod pod in mSquad.Pods)
|
||||
{
|
||||
binaryFormatter.Serialize(binaryWriter.BaseStream, pod);
|
||||
}
|
||||
}
|
||||
binaryWriter.Close();
|
||||
}
|
||||
|
||||
public Pod FindPod(byte[] macAddress)
|
||||
{
|
||||
foreach (Squad mSquad in mSquads)
|
||||
{
|
||||
foreach (Pod pod in mSquad.Pods)
|
||||
{
|
||||
if (pod.MacAddressEquals(macAddress))
|
||||
{
|
||||
return pod;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Squad FindSquad(Guid id)
|
||||
{
|
||||
foreach (Squad mSquad in mSquads)
|
||||
{
|
||||
if (mSquad.Guid == id)
|
||||
{
|
||||
return mSquad;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
[Serializable]
|
||||
internal class Squad
|
||||
{
|
||||
[NonSerialized]
|
||||
private EventHandler mOnOnlineChanged;
|
||||
|
||||
private Guid mGuid = Guid.NewGuid();
|
||||
|
||||
private string mName = "";
|
||||
|
||||
private bool mOnline;
|
||||
|
||||
[NonSerialized]
|
||||
private List<Pod> mPods = new List<Pod>();
|
||||
|
||||
public Guid Guid => mGuid;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
set
|
||||
{
|
||||
mName = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLocal
|
||||
{
|
||||
get
|
||||
{
|
||||
int num = 0;
|
||||
foreach (Pod pod in Pods)
|
||||
{
|
||||
if (pod.IsLocal)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
}
|
||||
return num > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool Online
|
||||
{
|
||||
get
|
||||
{
|
||||
return mOnline;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == mOnline)
|
||||
{
|
||||
return;
|
||||
}
|
||||
mOnline = value;
|
||||
if (mOnOnlineChanged != null)
|
||||
{
|
||||
mOnOnlineChanged(this, EventArgs.Empty);
|
||||
}
|
||||
foreach (Pod mPod in mPods)
|
||||
{
|
||||
mPod.Online = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<Pod> Pods
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mPods == null)
|
||||
{
|
||||
mPods = new List<Pod>();
|
||||
}
|
||||
return mPods;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Pod> OnlinePods
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Pod> list = new List<Pod>();
|
||||
foreach (Pod mPod in mPods)
|
||||
{
|
||||
if (mPod.Online)
|
||||
{
|
||||
list.Add(mPod);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler OnOnlineChanged
|
||||
{
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
add
|
||||
{
|
||||
mOnOnlineChanged = (EventHandler)Delegate.Combine(mOnOnlineChanged, value);
|
||||
}
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
remove
|
||||
{
|
||||
mOnOnlineChanged = (EventHandler)Delegate.Remove(mOnOnlineChanged, value);
|
||||
}
|
||||
}
|
||||
|
||||
public Squad()
|
||||
: this(Guid.NewGuid(), "")
|
||||
{
|
||||
}
|
||||
|
||||
public Squad(string name)
|
||||
: this(Guid.NewGuid(), name)
|
||||
{
|
||||
}
|
||||
|
||||
public Squad(Guid guid, string name)
|
||||
{
|
||||
mGuid = guid;
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public Squad Clone()
|
||||
{
|
||||
Squad squad = new Squad(mGuid, mName);
|
||||
squad.mOnline = mOnline;
|
||||
squad.mPods.AddRange(mPods);
|
||||
return squad;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,602 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Printing;
|
||||
using System.Windows.Forms;
|
||||
using Munga.Net;
|
||||
using TeslaConsole.RedPlanet;
|
||||
using WeifenLuo.WinFormsUI.Docking;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class TeslaConsoleForm : Form
|
||||
{
|
||||
private SitePanel mSitePanel = new SitePanel();
|
||||
|
||||
private IContainer components;
|
||||
|
||||
private DockPanel mMainDockPanel;
|
||||
|
||||
private Timer mRPNetworkScanTimer;
|
||||
|
||||
private MenuStrip mMenu;
|
||||
|
||||
private ToolStripMenuItem mFileMenu;
|
||||
|
||||
private ToolStripMenuItem mShowSitePanelMenuItem;
|
||||
|
||||
private ToolStripSeparator mSitePanelSeparator;
|
||||
|
||||
private ToolStripMenuItem mPlasmaEditor;
|
||||
|
||||
private ToolStripMenuItem mExit;
|
||||
|
||||
private ToolStripMenuItem mGamesMenu;
|
||||
|
||||
private ToolStripMenuItem mRpDeathRace;
|
||||
|
||||
private ToolStripMenuItem mRpMartianFootball;
|
||||
|
||||
private ToolStripMenuItem mPlasmaFontTool;
|
||||
|
||||
private ToolStripMenuItem mRpMissionPrintPreview;
|
||||
|
||||
private PrintPreviewDialog mRPPrintPreviewDialog;
|
||||
|
||||
private ToolStripMenuItem mPrintRpMission;
|
||||
|
||||
private ToolStripSeparator mSeperator1;
|
||||
|
||||
private PrintDialog mRPPrintDialog;
|
||||
|
||||
private ToolStripMenuItem mPlasmaBitmapDecoder;
|
||||
|
||||
private ToolStripSeparator mSeperator2;
|
||||
|
||||
private OpenFileDialog mRPMissionOpenDialog;
|
||||
|
||||
private ToolStripMenuItem aboutToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem aboutToolStripMenuItem1;
|
||||
|
||||
private ToolStripMenuItem settingsToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem redPlanetDefaultsToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem importRedPlanetDefaultsToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem exportRedPlanetDefaultsToolStripMenuItem;
|
||||
|
||||
private OpenFileDialog mRPDefaultsOpenDialog;
|
||||
|
||||
private SaveFileDialog mRPDefaultsSaveDialog;
|
||||
|
||||
private ToolStripSeparator toolStripSeparator1;
|
||||
|
||||
private ToolStripMenuItem enableCustomBitmapsToolStripMenuItem;
|
||||
|
||||
private ToolStripMenuItem mExceptionsMenu;
|
||||
|
||||
private ToolStripMenuItem mThrowHandledExceptionMenuItem;
|
||||
|
||||
private ToolStripMenuItem mThrownUnHandledExceptionMenuItem;
|
||||
|
||||
public TeslaConsoleForm()
|
||||
{
|
||||
InitializeComponent();
|
||||
mRpMissionPrintPreview.Visible = false;
|
||||
mSeperator1.Visible = false;
|
||||
mExceptionsMenu.Visible = false;
|
||||
enableCustomBitmapsToolStripMenuItem.Checked = PlasmaBitmaps.EnableCustomBitmaps;
|
||||
mRPMissionOpenDialog.InitialDirectory = RPMissionResults.GetRPMissionsDirectory();
|
||||
TeslaConsole.Site.LoadFromStore();
|
||||
PodManager.StartConfigurationServer();
|
||||
}
|
||||
|
||||
protected override void OnShown(EventArgs e)
|
||||
{
|
||||
base.OnShown(e);
|
||||
ShowSitePanel();
|
||||
}
|
||||
|
||||
private void mShowSitePanelMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
ShowSitePanel();
|
||||
}
|
||||
|
||||
private void ShowSitePanel()
|
||||
{
|
||||
if (mSitePanel == null || mSitePanel.IsDisposed)
|
||||
{
|
||||
mSitePanel = new SitePanel();
|
||||
}
|
||||
mSitePanel.Show(mMainDockPanel, DockState.DockRight);
|
||||
mSitePanel.Activate();
|
||||
}
|
||||
|
||||
private void NetworkScan(object sender, EventArgs e)
|
||||
{
|
||||
foreach (Squad squad in TeslaConsole.Site.Active.Squads)
|
||||
{
|
||||
foreach (Pod pod in squad.Pods)
|
||||
{
|
||||
switch (pod.MungaGame.State)
|
||||
{
|
||||
case MungaConnectionState.Connected:
|
||||
pod.MungaGame.QueryStateIfNeeded();
|
||||
if (!pod.MungaGame.IsOwned)
|
||||
{
|
||||
while (pod.MungaGame.Receive() != null)
|
||||
{
|
||||
}
|
||||
}
|
||||
if (!pod.MungaGame.AppID.HasValue || !pod.MungaGame.AppState.HasValue)
|
||||
{
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Waiting For State Update...");
|
||||
break;
|
||||
}
|
||||
if (pod.MungaGame.AppID.Value != 0)
|
||||
{
|
||||
pod.MungaGame.SetStatus(ImageCache.PodBad16, "Pod Not Running RP");
|
||||
break;
|
||||
}
|
||||
switch (pod.MungaGame.AppState.Value)
|
||||
{
|
||||
case ApplicationState.InitializingState:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "RP Initalizing");
|
||||
break;
|
||||
case ApplicationState.WaitingForEgg:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodOnline16, "Waiting For A Game");
|
||||
break;
|
||||
case ApplicationState.LoadingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Loading Mission");
|
||||
break;
|
||||
case ApplicationState.WaitingForLaunch:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodGo16, "Waiting For Launch");
|
||||
break;
|
||||
case ApplicationState.LaunchingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Launching Mission");
|
||||
break;
|
||||
case ApplicationState.RunningMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodRun16, "Mission Running");
|
||||
break;
|
||||
case ApplicationState.EndingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Ending Mission");
|
||||
break;
|
||||
case ApplicationState.StoppingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Stopping Mission");
|
||||
break;
|
||||
case ApplicationState.SuspendingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Suspending Mission");
|
||||
break;
|
||||
case ApplicationState.ResumingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Resuming Mission");
|
||||
break;
|
||||
case ApplicationState.AbortingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Aborting Mission");
|
||||
break;
|
||||
case ApplicationState.CreatingMission:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Creating Mission");
|
||||
break;
|
||||
default:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodBad16, "Pod State Unknown");
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MungaConnectionState.Connecting:
|
||||
pod.MungaGame.SetStatus(ImageCache.PodQuestion16, "Connecting...");
|
||||
break;
|
||||
default:
|
||||
if (pod.MungaGame.Requested)
|
||||
{
|
||||
pod.MungaGame.SetStatus(ImageCache.PodBad16, "Not Connected");
|
||||
}
|
||||
else
|
||||
{
|
||||
pod.MungaGame.SetStatus(ImageCache.PodOffline16, "");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void redPlanetDeathRaceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewRPGame(footballMode: false);
|
||||
}
|
||||
|
||||
private void redPlanetMartianFootballToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
CreateNewRPGame(footballMode: true);
|
||||
}
|
||||
|
||||
private void CreateNewRPGame(bool footballMode)
|
||||
{
|
||||
RPGame rPGame = new RPGame(TeslaConsole.Site.Active, footballMode);
|
||||
rPGame.MdiParent = this;
|
||||
rPGame.Show(mMainDockPanel, DockState.Document);
|
||||
}
|
||||
|
||||
private void plasmaEditorToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new PlasmaEditor().Show();
|
||||
}
|
||||
|
||||
private void plasmaFontToolToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new PlasmaFontTool().Show();
|
||||
}
|
||||
|
||||
private void plasmaBitmapDecoderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
new PlasmaBitmapDecoder().Show();
|
||||
}
|
||||
|
||||
private PrintDocument GetMissionPrintDocument()
|
||||
{
|
||||
if (mRPMissionOpenDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
RPMissionResults rPMissionResults = RPMissionResults.Load(mRPMissionOpenDialog.FileName);
|
||||
return rPMissionResults.GetPrintDocument();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("The selected document could not be loaded because it appears to be corrupt.", "Error Loading Mission Data", MessageBoxButtons.OK);
|
||||
Program.LogException(ex, $"Error Loading RP Mission Results (\"{mRPMissionOpenDialog.FileName}\").");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void printPreviewToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
PrintDocument missionPrintDocument = GetMissionPrintDocument();
|
||||
if (missionPrintDocument != null)
|
||||
{
|
||||
if (mRPPrintPreviewDialog.IsDisposed)
|
||||
{
|
||||
mRPPrintPreviewDialog = new PrintPreviewDialog();
|
||||
}
|
||||
mRPPrintPreviewDialog.Document = missionPrintDocument;
|
||||
mRPPrintPreviewDialog.Show();
|
||||
mRPPrintPreviewDialog.DesktopBounds = Screen.PrimaryScreen.WorkingArea;
|
||||
}
|
||||
}
|
||||
|
||||
private void printToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
PrintDocument missionPrintDocument = GetMissionPrintDocument();
|
||||
if (missionPrintDocument != null)
|
||||
{
|
||||
mRPPrintDialog.Document = missionPrintDocument;
|
||||
if (mRPPrintDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
mRPPrintDialog.Document.Print();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void TeslaConsoleForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
if (mSitePanel != null && !mSitePanel.IsDisposed)
|
||||
{
|
||||
mSitePanel.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
|
||||
{
|
||||
using abtTeslaConsole abtTeslaConsole2 = new abtTeslaConsole();
|
||||
abtTeslaConsole2.ShowDialog();
|
||||
}
|
||||
|
||||
private void changeRedPlanetDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
RPDefaultsDialog.ShowSingleton();
|
||||
}
|
||||
|
||||
private void importRedPlanetDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (mRPDefaultsOpenDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
RPDefaults.Import(mRPDefaultsOpenDialog.FileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("This Red Planet defaults file appears to be corrupt.", "Error Loading Red Planet Defaults!", MessageBoxButtons.OK);
|
||||
return;
|
||||
}
|
||||
RPDefaults.Save();
|
||||
}
|
||||
}
|
||||
|
||||
private void exportRedPlanetDefaultsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (mRPDefaultsSaveDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
RPDefaults.Export(mRPDefaultsSaveDialog.FileName);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
MessageBox.Show("The Red Planet defaults file could not be exported.", "Error Exporting Red Planet Defaults!", MessageBoxButtons.OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void enableCustomBitmapsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
enableCustomBitmapsToolStripMenuItem.Checked = (PlasmaBitmaps.EnableCustomBitmaps = !PlasmaBitmaps.EnableCustomBitmaps);
|
||||
}
|
||||
|
||||
private void mThrowHandledExceptionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
mThrownUnHandledExceptionMenuItem_Click(sender, e);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Program.LogExceptionAndShowDialog(ex, "The user pressed the exception generating button.", "An Exception Occured.");
|
||||
}
|
||||
}
|
||||
|
||||
private void mThrownUnHandledExceptionMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
throw new Exception("User Generated Exception");
|
||||
}
|
||||
|
||||
private void mExit_Click(object sender, EventArgs e)
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPanelSkin dockPanelSkin = new WeifenLuo.WinFormsUI.Docking.DockPanelSkin();
|
||||
WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin autoHideStripSkin = new WeifenLuo.WinFormsUI.Docking.AutoHideStripSkin();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin dockPaneStripSkin = new WeifenLuo.WinFormsUI.Docking.DockPaneStripSkin();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient dockPaneStripGradient = new WeifenLuo.WinFormsUI.Docking.DockPaneStripGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient2 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient2 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient3 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient dockPaneStripToolWindowGradient = new WeifenLuo.WinFormsUI.Docking.DockPaneStripToolWindowGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient4 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient5 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.DockPanelGradient dockPanelGradient3 = new WeifenLuo.WinFormsUI.Docking.DockPanelGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient6 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
WeifenLuo.WinFormsUI.Docking.TabGradient tabGradient7 = new WeifenLuo.WinFormsUI.Docking.TabGradient();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TeslaConsole.TeslaConsoleForm));
|
||||
this.mMainDockPanel = new WeifenLuo.WinFormsUI.Docking.DockPanel();
|
||||
this.mRPNetworkScanTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.mMenu = new System.Windows.Forms.MenuStrip();
|
||||
this.mFileMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mShowSitePanelMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mSitePanelSeparator = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mRpMissionPrintPreview = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mPrintRpMission = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mSeperator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mPlasmaEditor = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mPlasmaFontTool = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mPlasmaBitmapDecoder = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mSeperator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.mExit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.redPlanetDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.importRedPlanetDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.exportRedPlanetDefaultsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.enableCustomBitmapsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mGamesMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mRpDeathRace = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mRpMartianFootball = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mExceptionsMenu = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mThrowHandledExceptionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mThrownUnHandledExceptionMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.mRPPrintPreviewDialog = new System.Windows.Forms.PrintPreviewDialog();
|
||||
this.mRPPrintDialog = new System.Windows.Forms.PrintDialog();
|
||||
this.mRPMissionOpenDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.mRPDefaultsOpenDialog = new System.Windows.Forms.OpenFileDialog();
|
||||
this.mRPDefaultsSaveDialog = new System.Windows.Forms.SaveFileDialog();
|
||||
this.mMenu.SuspendLayout();
|
||||
base.SuspendLayout();
|
||||
this.mMainDockPanel.ActiveAutoHideContent = null;
|
||||
this.mMainDockPanel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.mMainDockPanel.DockBackColor = System.Drawing.SystemColors.Control;
|
||||
this.mMainDockPanel.Location = new System.Drawing.Point(0, 24);
|
||||
this.mMainDockPanel.Name = "mMainDockPanel";
|
||||
this.mMainDockPanel.Size = new System.Drawing.Size(1168, 567);
|
||||
dockPanelGradient.EndColor = System.Drawing.SystemColors.ControlLight;
|
||||
dockPanelGradient.StartColor = System.Drawing.SystemColors.ControlLight;
|
||||
autoHideStripSkin.DockStripGradient = dockPanelGradient;
|
||||
tabGradient.EndColor = System.Drawing.SystemColors.Control;
|
||||
tabGradient.StartColor = System.Drawing.SystemColors.Control;
|
||||
tabGradient.TextColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
autoHideStripSkin.TabGradient = tabGradient;
|
||||
dockPanelSkin.AutoHideStripSkin = autoHideStripSkin;
|
||||
tabGradient2.EndColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
tabGradient2.StartColor = System.Drawing.SystemColors.ControlLightLight;
|
||||
tabGradient2.TextColor = System.Drawing.SystemColors.ControlText;
|
||||
dockPaneStripGradient.ActiveTabGradient = tabGradient2;
|
||||
dockPanelGradient2.EndColor = System.Drawing.SystemColors.Control;
|
||||
dockPanelGradient2.StartColor = System.Drawing.SystemColors.Control;
|
||||
dockPaneStripGradient.DockStripGradient = dockPanelGradient2;
|
||||
tabGradient3.EndColor = System.Drawing.SystemColors.ControlLight;
|
||||
tabGradient3.StartColor = System.Drawing.SystemColors.ControlLight;
|
||||
tabGradient3.TextColor = System.Drawing.SystemColors.ControlText;
|
||||
dockPaneStripGradient.InactiveTabGradient = tabGradient3;
|
||||
dockPaneStripSkin.DocumentGradient = dockPaneStripGradient;
|
||||
tabGradient4.EndColor = System.Drawing.SystemColors.ActiveCaption;
|
||||
tabGradient4.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
|
||||
tabGradient4.StartColor = System.Drawing.SystemColors.GradientActiveCaption;
|
||||
tabGradient4.TextColor = System.Drawing.SystemColors.ActiveCaptionText;
|
||||
dockPaneStripToolWindowGradient.ActiveCaptionGradient = tabGradient4;
|
||||
tabGradient5.EndColor = System.Drawing.SystemColors.Control;
|
||||
tabGradient5.StartColor = System.Drawing.SystemColors.Control;
|
||||
tabGradient5.TextColor = System.Drawing.SystemColors.ControlText;
|
||||
dockPaneStripToolWindowGradient.ActiveTabGradient = tabGradient5;
|
||||
dockPanelGradient3.EndColor = System.Drawing.SystemColors.ControlLight;
|
||||
dockPanelGradient3.StartColor = System.Drawing.SystemColors.ControlLight;
|
||||
dockPaneStripToolWindowGradient.DockStripGradient = dockPanelGradient3;
|
||||
tabGradient6.EndColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
tabGradient6.LinearGradientMode = System.Drawing.Drawing2D.LinearGradientMode.Vertical;
|
||||
tabGradient6.StartColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
tabGradient6.TextColor = System.Drawing.SystemColors.ControlText;
|
||||
dockPaneStripToolWindowGradient.InactiveCaptionGradient = tabGradient6;
|
||||
tabGradient7.EndColor = System.Drawing.Color.Transparent;
|
||||
tabGradient7.StartColor = System.Drawing.Color.Transparent;
|
||||
tabGradient7.TextColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
dockPaneStripToolWindowGradient.InactiveTabGradient = tabGradient7;
|
||||
dockPaneStripSkin.ToolWindowGradient = dockPaneStripToolWindowGradient;
|
||||
dockPanelSkin.DockPaneStripSkin = dockPaneStripSkin;
|
||||
this.mMainDockPanel.Skin = dockPanelSkin;
|
||||
this.mMainDockPanel.TabIndex = 0;
|
||||
this.mRPNetworkScanTimer.Enabled = true;
|
||||
this.mRPNetworkScanTimer.Tick += new System.EventHandler(NetworkScan);
|
||||
this.mMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[5] { this.mFileMenu, this.settingsToolStripMenuItem, this.mGamesMenu, this.aboutToolStripMenuItem, this.mExceptionsMenu });
|
||||
this.mMenu.Location = new System.Drawing.Point(0, 0);
|
||||
this.mMenu.Name = "mMenu";
|
||||
this.mMenu.Size = new System.Drawing.Size(1168, 24);
|
||||
this.mMenu.TabIndex = 3;
|
||||
this.mMenu.Text = "menuStrip1";
|
||||
this.mFileMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[10] { this.mShowSitePanelMenuItem, this.mSitePanelSeparator, this.mRpMissionPrintPreview, this.mPrintRpMission, this.mSeperator1, this.mPlasmaEditor, this.mPlasmaFontTool, this.mPlasmaBitmapDecoder, this.mSeperator2, this.mExit });
|
||||
this.mFileMenu.Name = "mFileMenu";
|
||||
this.mFileMenu.Size = new System.Drawing.Size(37, 20);
|
||||
this.mFileMenu.Text = "File";
|
||||
this.mShowSitePanelMenuItem.Name = "mShowSitePanelMenuItem";
|
||||
this.mShowSitePanelMenuItem.Size = new System.Drawing.Size(204, 22);
|
||||
this.mShowSitePanelMenuItem.Text = "Pod Control Panel";
|
||||
this.mShowSitePanelMenuItem.Click += new System.EventHandler(mShowSitePanelMenuItem_Click);
|
||||
this.mSitePanelSeparator.Name = "mSitePanelSeparator";
|
||||
this.mSitePanelSeparator.Size = new System.Drawing.Size(201, 6);
|
||||
this.mRpMissionPrintPreview.Name = "mRpMissionPrintPreview";
|
||||
this.mRpMissionPrintPreview.Size = new System.Drawing.Size(204, 22);
|
||||
this.mRpMissionPrintPreview.Text = "RP Mission Print Preview";
|
||||
this.mRpMissionPrintPreview.Click += new System.EventHandler(printPreviewToolStripMenuItem_Click);
|
||||
this.mPrintRpMission.Name = "mPrintRpMission";
|
||||
this.mPrintRpMission.Size = new System.Drawing.Size(204, 22);
|
||||
this.mPrintRpMission.Text = "Print RP Mission";
|
||||
this.mPrintRpMission.Click += new System.EventHandler(printToolStripMenuItem_Click);
|
||||
this.mSeperator1.Name = "mSeperator1";
|
||||
this.mSeperator1.Size = new System.Drawing.Size(201, 6);
|
||||
this.mPlasmaEditor.Name = "mPlasmaEditor";
|
||||
this.mPlasmaEditor.Size = new System.Drawing.Size(204, 22);
|
||||
this.mPlasmaEditor.Text = "Plasma Editor";
|
||||
this.mPlasmaEditor.Click += new System.EventHandler(plasmaEditorToolStripMenuItem_Click);
|
||||
this.mPlasmaFontTool.Name = "mPlasmaFontTool";
|
||||
this.mPlasmaFontTool.Size = new System.Drawing.Size(204, 22);
|
||||
this.mPlasmaFontTool.Text = "Plasma Font Tool";
|
||||
this.mPlasmaFontTool.Click += new System.EventHandler(plasmaFontToolToolStripMenuItem_Click);
|
||||
this.mPlasmaBitmapDecoder.Name = "mPlasmaBitmapDecoder";
|
||||
this.mPlasmaBitmapDecoder.Size = new System.Drawing.Size(204, 22);
|
||||
this.mPlasmaBitmapDecoder.Text = "Plasma Bitmap Decoder";
|
||||
this.mPlasmaBitmapDecoder.Click += new System.EventHandler(plasmaBitmapDecoderToolStripMenuItem_Click);
|
||||
this.mSeperator2.Name = "mSeperator2";
|
||||
this.mSeperator2.Size = new System.Drawing.Size(201, 6);
|
||||
this.mExit.Name = "mExit";
|
||||
this.mExit.Size = new System.Drawing.Size(204, 22);
|
||||
this.mExit.Text = "Exit";
|
||||
this.mExit.Click += new System.EventHandler(mExit_Click);
|
||||
this.settingsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[5] { this.redPlanetDefaultsToolStripMenuItem, this.importRedPlanetDefaultsToolStripMenuItem, this.exportRedPlanetDefaultsToolStripMenuItem, this.toolStripSeparator1, this.enableCustomBitmapsToolStripMenuItem });
|
||||
this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem";
|
||||
this.settingsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
|
||||
this.settingsToolStripMenuItem.Text = "Settings";
|
||||
this.redPlanetDefaultsToolStripMenuItem.Name = "redPlanetDefaultsToolStripMenuItem";
|
||||
this.redPlanetDefaultsToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.redPlanetDefaultsToolStripMenuItem.Text = "&Change Red Planet Defaults";
|
||||
this.redPlanetDefaultsToolStripMenuItem.Click += new System.EventHandler(changeRedPlanetDefaultsToolStripMenuItem_Click);
|
||||
this.importRedPlanetDefaultsToolStripMenuItem.Name = "importRedPlanetDefaultsToolStripMenuItem";
|
||||
this.importRedPlanetDefaultsToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.importRedPlanetDefaultsToolStripMenuItem.Text = "&Import Red Planet Defaults";
|
||||
this.importRedPlanetDefaultsToolStripMenuItem.Click += new System.EventHandler(importRedPlanetDefaultsToolStripMenuItem_Click);
|
||||
this.exportRedPlanetDefaultsToolStripMenuItem.Name = "exportRedPlanetDefaultsToolStripMenuItem";
|
||||
this.exportRedPlanetDefaultsToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.exportRedPlanetDefaultsToolStripMenuItem.Text = "&Export Red Planet Defaults";
|
||||
this.exportRedPlanetDefaultsToolStripMenuItem.Click += new System.EventHandler(exportRedPlanetDefaultsToolStripMenuItem_Click);
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(217, 6);
|
||||
this.enableCustomBitmapsToolStripMenuItem.Name = "enableCustomBitmapsToolStripMenuItem";
|
||||
this.enableCustomBitmapsToolStripMenuItem.Size = new System.Drawing.Size(220, 22);
|
||||
this.enableCustomBitmapsToolStripMenuItem.Text = "Enable Custom Bitmaps";
|
||||
this.enableCustomBitmapsToolStripMenuItem.Click += new System.EventHandler(enableCustomBitmapsToolStripMenuItem_Click);
|
||||
this.mGamesMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.mRpDeathRace, this.mRpMartianFootball });
|
||||
this.mGamesMenu.Name = "mGamesMenu";
|
||||
this.mGamesMenu.Size = new System.Drawing.Size(55, 20);
|
||||
this.mGamesMenu.Text = "Games";
|
||||
this.mRpDeathRace.Name = "mRpDeathRace";
|
||||
this.mRpDeathRace.Size = new System.Drawing.Size(223, 22);
|
||||
this.mRpDeathRace.Text = "Red Planet: Death Race";
|
||||
this.mRpDeathRace.Click += new System.EventHandler(redPlanetDeathRaceToolStripMenuItem_Click);
|
||||
this.mRpMartianFootball.Name = "mRpMartianFootball";
|
||||
this.mRpMartianFootball.Size = new System.Drawing.Size(223, 22);
|
||||
this.mRpMartianFootball.Text = "Red Planet: Martian Football";
|
||||
this.mRpMartianFootball.Click += new System.EventHandler(redPlanetMartianFootballToolStripMenuItem_Click);
|
||||
this.aboutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[1] { this.aboutToolStripMenuItem1 });
|
||||
this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
|
||||
this.aboutToolStripMenuItem.Size = new System.Drawing.Size(52, 20);
|
||||
this.aboutToolStripMenuItem.Text = "About";
|
||||
this.aboutToolStripMenuItem1.Name = "aboutToolStripMenuItem1";
|
||||
this.aboutToolStripMenuItem1.Size = new System.Drawing.Size(107, 22);
|
||||
this.aboutToolStripMenuItem1.Text = "About";
|
||||
this.aboutToolStripMenuItem1.Click += new System.EventHandler(aboutToolStripMenuItem1_Click);
|
||||
this.mExceptionsMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[2] { this.mThrowHandledExceptionMenuItem, this.mThrownUnHandledExceptionMenuItem });
|
||||
this.mExceptionsMenu.Name = "mExceptionsMenu";
|
||||
this.mExceptionsMenu.Size = new System.Drawing.Size(75, 20);
|
||||
this.mExceptionsMenu.Text = "Exceptions";
|
||||
this.mThrowHandledExceptionMenuItem.Name = "mThrowHandledExceptionMenuItem";
|
||||
this.mThrowHandledExceptionMenuItem.Size = new System.Drawing.Size(237, 22);
|
||||
this.mThrowHandledExceptionMenuItem.Text = "Throw Handled Exception";
|
||||
this.mThrowHandledExceptionMenuItem.Click += new System.EventHandler(mThrowHandledExceptionMenuItem_Click);
|
||||
this.mThrownUnHandledExceptionMenuItem.Name = "mThrownUnHandledExceptionMenuItem";
|
||||
this.mThrownUnHandledExceptionMenuItem.Size = new System.Drawing.Size(237, 22);
|
||||
this.mThrownUnHandledExceptionMenuItem.Text = "Thrown Un-Handled Exception";
|
||||
this.mThrownUnHandledExceptionMenuItem.Click += new System.EventHandler(mThrownUnHandledExceptionMenuItem_Click);
|
||||
this.mRPPrintPreviewDialog.AutoScrollMargin = new System.Drawing.Size(0, 0);
|
||||
this.mRPPrintPreviewDialog.AutoScrollMinSize = new System.Drawing.Size(0, 0);
|
||||
this.mRPPrintPreviewDialog.ClientSize = new System.Drawing.Size(400, 300);
|
||||
this.mRPPrintPreviewDialog.Enabled = true;
|
||||
this.mRPPrintPreviewDialog.Icon = (System.Drawing.Icon)resources.GetObject("mRPPrintPreviewDialog.Icon");
|
||||
this.mRPPrintPreviewDialog.Name = "printPreviewDialog1";
|
||||
this.mRPPrintPreviewDialog.Visible = false;
|
||||
this.mRPPrintDialog.UseEXDialog = true;
|
||||
this.mRPMissionOpenDialog.Filter = "RP Mission (*.rpm)|*.rpm";
|
||||
this.mRPDefaultsOpenDialog.Filter = "RP Defaults (*.rpd)|*.rpd";
|
||||
this.mRPDefaultsSaveDialog.Filter = "RP Defaults (*.rpd)|*.rpd";
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(1168, 591);
|
||||
base.Controls.Add(this.mMainDockPanel);
|
||||
base.Controls.Add(this.mMenu);
|
||||
base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon");
|
||||
base.IsMdiContainer = true;
|
||||
base.MainMenuStrip = this.mMenu;
|
||||
base.Name = "TeslaConsoleForm";
|
||||
this.Text = "Tesla Console";
|
||||
base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(TeslaConsoleForm_FormClosing);
|
||||
this.mMenu.ResumeLayout(false);
|
||||
this.mMenu.PerformLayout();
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,172 @@
|
||||
namespace TeslaConsole;
|
||||
|
||||
public static class Tuple
|
||||
{
|
||||
public static Tuple<T1, T2> Create<T1, T2>(T1 a, T2 b)
|
||||
{
|
||||
return new Tuple<T1, T2>(a, b);
|
||||
}
|
||||
|
||||
public static Tuple<T1, T2, T3> Create<T1, T2, T3>(T1 a, T2 b, T3 c)
|
||||
{
|
||||
return new Tuple<T1, T2, T3>(a, b, c);
|
||||
}
|
||||
|
||||
public static Tuple<T1, T2, T3, T4> Create<T1, T2, T3, T4>(T1 a, T2 b, T3 c, T4 d)
|
||||
{
|
||||
return new Tuple<T1, T2, T3, T4>(a, b, c, d);
|
||||
}
|
||||
}
|
||||
public class Tuple<T1, T2>
|
||||
{
|
||||
private T1 mA;
|
||||
|
||||
private T2 mB;
|
||||
|
||||
public T1 A
|
||||
{
|
||||
get
|
||||
{
|
||||
return mA;
|
||||
}
|
||||
set
|
||||
{
|
||||
mA = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T2 B
|
||||
{
|
||||
get
|
||||
{
|
||||
return mB;
|
||||
}
|
||||
set
|
||||
{
|
||||
mB = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple(T1 a, T2 b)
|
||||
{
|
||||
mA = a;
|
||||
mB = b;
|
||||
}
|
||||
}
|
||||
public class Tuple<T1, T2, T3>
|
||||
{
|
||||
private T1 mA;
|
||||
|
||||
private T2 mB;
|
||||
|
||||
private T3 mC;
|
||||
|
||||
public T1 A
|
||||
{
|
||||
get
|
||||
{
|
||||
return mA;
|
||||
}
|
||||
set
|
||||
{
|
||||
mA = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T2 B
|
||||
{
|
||||
get
|
||||
{
|
||||
return mB;
|
||||
}
|
||||
set
|
||||
{
|
||||
mB = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T3 C
|
||||
{
|
||||
get
|
||||
{
|
||||
return mC;
|
||||
}
|
||||
set
|
||||
{
|
||||
mC = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple(T1 a, T2 b, T3 c)
|
||||
{
|
||||
mA = a;
|
||||
mB = b;
|
||||
mC = c;
|
||||
}
|
||||
}
|
||||
public class Tuple<T1, T2, T3, T4>
|
||||
{
|
||||
private T1 mA;
|
||||
|
||||
private T2 mB;
|
||||
|
||||
private T3 mC;
|
||||
|
||||
private T4 mD;
|
||||
|
||||
public T1 A
|
||||
{
|
||||
get
|
||||
{
|
||||
return mA;
|
||||
}
|
||||
set
|
||||
{
|
||||
mA = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T2 B
|
||||
{
|
||||
get
|
||||
{
|
||||
return mB;
|
||||
}
|
||||
set
|
||||
{
|
||||
mB = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T3 C
|
||||
{
|
||||
get
|
||||
{
|
||||
return mC;
|
||||
}
|
||||
set
|
||||
{
|
||||
mC = value;
|
||||
}
|
||||
}
|
||||
|
||||
public T4 D
|
||||
{
|
||||
get
|
||||
{
|
||||
return mD;
|
||||
}
|
||||
set
|
||||
{
|
||||
mD = value;
|
||||
}
|
||||
}
|
||||
|
||||
public Tuple(T1 a, T2 b, T3 c, T4 d)
|
||||
{
|
||||
mA = a;
|
||||
mB = b;
|
||||
mC = c;
|
||||
mD = d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace TeslaConsole;
|
||||
|
||||
public delegate void VoidDelegate();
|
||||
@@ -0,0 +1,214 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
using TeslaConsole.Properties;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
internal class abtTeslaConsole : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private Label labelProductName;
|
||||
|
||||
private Label labelVersion;
|
||||
|
||||
private Label labelCopyright;
|
||||
|
||||
private Label labelCompanyName;
|
||||
|
||||
private Button okButton;
|
||||
|
||||
private PictureBox picLogo;
|
||||
|
||||
private TextBox textBoxDescription;
|
||||
|
||||
public string AssemblyTitle
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false);
|
||||
if (customAttributes.Length > 0)
|
||||
{
|
||||
AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)customAttributes[0];
|
||||
if (assemblyTitleAttribute.Title != "")
|
||||
{
|
||||
return assemblyTitleAttribute.Title;
|
||||
}
|
||||
}
|
||||
return Path.GetFileNameWithoutExtension(Assembly.GetExecutingAssembly().CodeBase);
|
||||
}
|
||||
}
|
||||
|
||||
public string AssemblyVersion => Assembly.GetExecutingAssembly().GetName().Version.ToString();
|
||||
|
||||
public string AssemblyDescription
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyDescriptionAttribute), inherit: false);
|
||||
if (customAttributes.Length == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return ((AssemblyDescriptionAttribute)customAttributes[0]).Description;
|
||||
}
|
||||
}
|
||||
|
||||
public string AssemblyProduct
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), inherit: false);
|
||||
if (customAttributes.Length == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return ((AssemblyProductAttribute)customAttributes[0]).Product;
|
||||
}
|
||||
}
|
||||
|
||||
public string AssemblyCopyright
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), inherit: false);
|
||||
if (customAttributes.Length == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return ((AssemblyCopyrightAttribute)customAttributes[0]).Copyright;
|
||||
}
|
||||
}
|
||||
|
||||
public string AssemblyCompany
|
||||
{
|
||||
get
|
||||
{
|
||||
object[] customAttributes = Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), inherit: false);
|
||||
if (customAttributes.Length == 0)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return ((AssemblyCompanyAttribute)customAttributes[0]).Company;
|
||||
}
|
||||
}
|
||||
|
||||
public abtTeslaConsole()
|
||||
{
|
||||
InitializeComponent();
|
||||
Text = $"About {AssemblyTitle}";
|
||||
labelProductName.Text = AssemblyProduct;
|
||||
labelVersion.Text = $"Version {AssemblyVersion}";
|
||||
labelCopyright.Text = AssemblyCopyright;
|
||||
labelCompanyName.Text = AssemblyCompany;
|
||||
textBoxDescription.Text = AssemblyDescription;
|
||||
picLogo.Image = new Icon(Resources.swirl, 64, 64).ToBitmap();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelProductName = new System.Windows.Forms.Label();
|
||||
this.labelVersion = new System.Windows.Forms.Label();
|
||||
this.labelCopyright = new System.Windows.Forms.Label();
|
||||
this.labelCompanyName = new System.Windows.Forms.Label();
|
||||
this.okButton = new System.Windows.Forms.Button();
|
||||
this.picLogo = new System.Windows.Forms.PictureBox();
|
||||
this.textBoxDescription = new System.Windows.Forms.TextBox();
|
||||
((System.ComponentModel.ISupportInitialize)this.picLogo).BeginInit();
|
||||
base.SuspendLayout();
|
||||
this.labelProductName.AutoSize = true;
|
||||
this.labelProductName.Location = new System.Drawing.Point(85, 12);
|
||||
this.labelProductName.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.labelProductName.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.labelProductName.Name = "labelProductName";
|
||||
this.labelProductName.Size = new System.Drawing.Size(74, 13);
|
||||
this.labelProductName.TabIndex = 19;
|
||||
this.labelProductName.Text = "Tesla Console";
|
||||
this.labelProductName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.labelVersion.AutoSize = true;
|
||||
this.labelVersion.Location = new System.Drawing.Point(85, 31);
|
||||
this.labelVersion.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.labelVersion.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.labelVersion.Name = "labelVersion";
|
||||
this.labelVersion.Size = new System.Drawing.Size(22, 13);
|
||||
this.labelVersion.TabIndex = 0;
|
||||
this.labelVersion.Text = "1.0";
|
||||
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.labelCopyright.AutoSize = true;
|
||||
this.labelCopyright.Location = new System.Drawing.Point(85, 50);
|
||||
this.labelCopyright.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.labelCopyright.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.labelCopyright.Name = "labelCopyright";
|
||||
this.labelCopyright.Size = new System.Drawing.Size(90, 13);
|
||||
this.labelCopyright.TabIndex = 21;
|
||||
this.labelCopyright.Text = "Copyright © 2009";
|
||||
this.labelCopyright.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.labelCompanyName.AutoSize = true;
|
||||
this.labelCompanyName.Location = new System.Drawing.Point(85, 69);
|
||||
this.labelCompanyName.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.labelCompanyName.MaximumSize = new System.Drawing.Size(0, 17);
|
||||
this.labelCompanyName.Name = "labelCompanyName";
|
||||
this.labelCompanyName.Size = new System.Drawing.Size(135, 13);
|
||||
this.labelCompanyName.TabIndex = 22;
|
||||
this.labelCompanyName.Text = "Virtual World Entertainment";
|
||||
this.labelCompanyName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.okButton.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.okButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.okButton.Location = new System.Drawing.Point(358, 234);
|
||||
this.okButton.Name = "okButton";
|
||||
this.okButton.Size = new System.Drawing.Size(75, 23);
|
||||
this.okButton.TabIndex = 24;
|
||||
this.okButton.Text = "&OK";
|
||||
this.picLogo.Location = new System.Drawing.Point(12, 12);
|
||||
this.picLogo.Name = "picLogo";
|
||||
this.picLogo.Size = new System.Drawing.Size(64, 70);
|
||||
this.picLogo.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.picLogo.TabIndex = 1;
|
||||
this.picLogo.TabStop = false;
|
||||
this.textBoxDescription.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.textBoxDescription.Location = new System.Drawing.Point(12, 88);
|
||||
this.textBoxDescription.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.textBoxDescription.Multiline = true;
|
||||
this.textBoxDescription.Name = "textBoxDescription";
|
||||
this.textBoxDescription.ReadOnly = true;
|
||||
this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxDescription.Size = new System.Drawing.Size(421, 140);
|
||||
this.textBoxDescription.TabIndex = 23;
|
||||
this.textBoxDescription.TabStop = false;
|
||||
base.AcceptButton = this.okButton;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(445, 269);
|
||||
base.Controls.Add(this.textBoxDescription);
|
||||
base.Controls.Add(this.labelCompanyName);
|
||||
base.Controls.Add(this.okButton);
|
||||
base.Controls.Add(this.labelCopyright);
|
||||
base.Controls.Add(this.labelVersion);
|
||||
base.Controls.Add(this.labelProductName);
|
||||
base.Controls.Add(this.picLogo);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
base.MaximizeBox = false;
|
||||
base.MinimizeBox = false;
|
||||
base.Name = "abtTeslaConsole";
|
||||
base.Padding = new System.Windows.Forms.Padding(9);
|
||||
base.ShowIcon = false;
|
||||
base.ShowInTaskbar = false;
|
||||
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "About";
|
||||
((System.ComponentModel.ISupportInitialize)this.picLogo).EndInit();
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
/// <summary>
|
||||
/// Defines a new catalog product (a single launch entry) and, optionally, an install
|
||||
/// package to deploy. The validated result is exposed as <see cref="Product"/>; the
|
||||
/// caller persists it to the catalog and (optionally) pushes it to selected pods.
|
||||
/// </summary>
|
||||
internal class dlgAddProduct : Form
|
||||
{
|
||||
private TextBox txtName;
|
||||
|
||||
private TextBox txtInstallDir;
|
||||
|
||||
private TextBox txtExe;
|
||||
|
||||
private TextBox txtArgs;
|
||||
|
||||
private TextBox txtPackage;
|
||||
|
||||
private CheckBox chkAutoRestart;
|
||||
|
||||
private CheckBox chkPushNow;
|
||||
|
||||
private Button cmdOK;
|
||||
|
||||
private Button cmdCancel;
|
||||
|
||||
/// <summary>The product the operator defined. Valid only after the dialog returns <see cref="DialogResult.OK"/>.</summary>
|
||||
public ProductDefinition Product { get; private set; }
|
||||
|
||||
/// <summary>Optional install package (zip) to deploy with the entry; null/empty for entry-only.</summary>
|
||||
public string PackagePath => string.IsNullOrWhiteSpace(txtPackage.Text) ? null : txtPackage.Text.Trim();
|
||||
|
||||
/// <summary>Whether to push the new product to the currently selected pods after adding it.</summary>
|
||||
public bool PushNow => chkPushNow.Checked;
|
||||
|
||||
public dlgAddProduct()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.txtName = new TextBox();
|
||||
this.txtInstallDir = new TextBox();
|
||||
this.txtExe = new TextBox();
|
||||
this.txtArgs = new TextBox();
|
||||
this.txtPackage = new TextBox();
|
||||
this.chkAutoRestart = new CheckBox();
|
||||
this.chkPushNow = new CheckBox();
|
||||
this.cmdOK = new Button();
|
||||
this.cmdCancel = new Button();
|
||||
base.SuspendLayout();
|
||||
|
||||
int labelX = 12;
|
||||
int fieldX = 130;
|
||||
int fieldW = 300;
|
||||
int browseX = fieldX + fieldW + 6;
|
||||
int y = 15;
|
||||
int rowH = 28;
|
||||
|
||||
AddLabel("Product name:", labelX, y);
|
||||
this.txtName.SetBounds(fieldX, y - 3, fieldW, 20);
|
||||
y += rowH;
|
||||
|
||||
AddLabel("Install directory:", labelX, y);
|
||||
this.txtInstallDir.SetBounds(fieldX, y - 3, fieldW, 20);
|
||||
AddBrowseButton(browseX, y - 4, BrowseInstallDir);
|
||||
y += rowH;
|
||||
|
||||
AddLabel("Executable:", labelX, y);
|
||||
this.txtExe.SetBounds(fieldX, y - 3, fieldW, 20);
|
||||
AddBrowseButton(browseX, y - 4, BrowseExe);
|
||||
y += rowH;
|
||||
|
||||
AddLabel("Arguments:", labelX, y);
|
||||
this.txtArgs.SetBounds(fieldX, y - 3, fieldW, 20);
|
||||
y += rowH;
|
||||
|
||||
AddLabel("Install package (optional):", labelX, y);
|
||||
this.txtPackage.SetBounds(fieldX, y - 3, fieldW, 20);
|
||||
AddBrowseButton(browseX, y - 4, BrowsePackage);
|
||||
y += rowH;
|
||||
|
||||
this.chkAutoRestart.SetBounds(fieldX, y, 200, 20);
|
||||
this.chkAutoRestart.Text = "Auto-restart if it exits";
|
||||
this.chkAutoRestart.Checked = true;
|
||||
y += 24;
|
||||
|
||||
this.chkPushNow.SetBounds(fieldX, y, 280, 20);
|
||||
this.chkPushNow.Text = "Push to selected pods now";
|
||||
this.chkPushNow.Checked = true;
|
||||
y += 36;
|
||||
|
||||
this.cmdOK.SetBounds(browseX - 169, y, 80, 24);
|
||||
this.cmdOK.Text = "OK";
|
||||
this.cmdOK.Click += cmdOK_Click;
|
||||
|
||||
this.cmdCancel.SetBounds(browseX - 83, y, 80, 24);
|
||||
this.cmdCancel.Text = "Cancel";
|
||||
this.cmdCancel.DialogResult = DialogResult.Cancel;
|
||||
|
||||
base.AcceptButton = this.cmdOK;
|
||||
base.CancelButton = this.cmdCancel;
|
||||
base.FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
base.MaximizeBox = false;
|
||||
base.MinimizeBox = false;
|
||||
base.StartPosition = FormStartPosition.CenterParent;
|
||||
base.ClientSize = new Size(browseX + 40, y + 36);
|
||||
base.Controls.Add(this.txtName);
|
||||
base.Controls.Add(this.txtInstallDir);
|
||||
base.Controls.Add(this.txtExe);
|
||||
base.Controls.Add(this.txtArgs);
|
||||
base.Controls.Add(this.txtPackage);
|
||||
base.Controls.Add(this.chkAutoRestart);
|
||||
base.Controls.Add(this.chkPushNow);
|
||||
base.Controls.Add(this.cmdOK);
|
||||
base.Controls.Add(this.cmdCancel);
|
||||
base.Name = "dlgAddProduct";
|
||||
this.Text = "Add Product";
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
|
||||
private void AddLabel(string text, int x, int y)
|
||||
{
|
||||
Label label = new Label
|
||||
{
|
||||
Text = text,
|
||||
AutoSize = true
|
||||
};
|
||||
label.SetBounds(x, y, 110, 16);
|
||||
base.Controls.Add(label);
|
||||
}
|
||||
|
||||
private void AddBrowseButton(int x, int y, EventHandler onClick)
|
||||
{
|
||||
Button button = new Button
|
||||
{
|
||||
Text = "..."
|
||||
};
|
||||
button.SetBounds(x, y, 30, 22);
|
||||
button.Click += onClick;
|
||||
base.Controls.Add(button);
|
||||
}
|
||||
|
||||
private void BrowseInstallDir(object sender, EventArgs e)
|
||||
{
|
||||
using FolderBrowserDialog dialog = new FolderBrowserDialog();
|
||||
if (!string.IsNullOrWhiteSpace(txtInstallDir.Text))
|
||||
{
|
||||
dialog.SelectedPath = txtInstallDir.Text;
|
||||
}
|
||||
if (dialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
txtInstallDir.Text = dialog.SelectedPath;
|
||||
}
|
||||
}
|
||||
|
||||
private void BrowseExe(object sender, EventArgs e)
|
||||
{
|
||||
using OpenFileDialog dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Executables (*.exe)|*.exe|All Files (*.*)|*.*",
|
||||
Title = "Select Executable"
|
||||
};
|
||||
if (dialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
txtExe.Text = dialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private void BrowsePackage(object sender, EventArgs e)
|
||||
{
|
||||
using OpenFileDialog dialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "VWE Install Archive (*.zip)|*.zip|All Files (*.*)|*.*",
|
||||
Title = "Select Install Package"
|
||||
};
|
||||
if (dialog.ShowDialog(this) == DialogResult.OK)
|
||||
{
|
||||
txtPackage.Text = dialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
private void cmdOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
string name = txtName.Text.Trim();
|
||||
string installDir = txtInstallDir.Text.Trim();
|
||||
string exe = txtExe.Text.Trim();
|
||||
|
||||
if (name.Length == 0)
|
||||
{
|
||||
Warn("Please enter a product name.");
|
||||
return;
|
||||
}
|
||||
if (exe.Length == 0)
|
||||
{
|
||||
Warn("Please specify the executable path.");
|
||||
return;
|
||||
}
|
||||
if (installDir.Length == 0)
|
||||
{
|
||||
Warn("Please specify the install directory.");
|
||||
return;
|
||||
}
|
||||
|
||||
string fullExe, fullDir;
|
||||
try
|
||||
{
|
||||
fullExe = Path.GetFullPath(exe);
|
||||
fullDir = Path.GetFullPath(installDir);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Warn("The executable or install directory path is not valid.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Invariant: the exe must live under the install directory the package extracts to.
|
||||
string dirWithSep = fullDir.TrimEnd('\\', '/') + "\\";
|
||||
if (!fullExe.StartsWith(dirWithSep, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
Warn("The executable must be located inside the install directory:\n" + fullDir);
|
||||
return;
|
||||
}
|
||||
|
||||
Guid id = Guid.NewGuid();
|
||||
Product = new ProductDefinition
|
||||
{
|
||||
Id = id,
|
||||
Name = name,
|
||||
MenuText = name + "...",
|
||||
HostTypeDialog = false
|
||||
};
|
||||
Product.Entries.Add(new LaunchEntryDefinition
|
||||
{
|
||||
LaunchKey = id,
|
||||
DisplayName = name,
|
||||
Exe = fullExe,
|
||||
Args = txtArgs.Text.Trim(),
|
||||
WorkingDirectory = fullDir,
|
||||
AutoRestart = chkAutoRestart.Checked,
|
||||
HostType = AppHostType.None
|
||||
});
|
||||
|
||||
base.DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Warn(string message)
|
||||
{
|
||||
MessageBox.Show(this, message, "Add Product", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,266 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class dlgOptionalStartParams : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private Label label1;
|
||||
|
||||
private TableLayoutPanel tlpResolution;
|
||||
|
||||
private Label label2;
|
||||
|
||||
private CheckBox chkCustomResolution;
|
||||
|
||||
private TextBox txtResX;
|
||||
|
||||
private TextBox txtResY;
|
||||
|
||||
private Label label3;
|
||||
|
||||
private Label label4;
|
||||
|
||||
private CheckBox chkLiveCamera;
|
||||
|
||||
private Button cmdOK;
|
||||
|
||||
private CheckBox chkGameClient;
|
||||
|
||||
private CheckBox chkMissionReview;
|
||||
|
||||
private Label label5;
|
||||
|
||||
public Size? Resolution
|
||||
{
|
||||
get
|
||||
{
|
||||
if (chkCustomResolution.Checked && txtResX.Text != "" && txtResY.Text != "")
|
||||
{
|
||||
return new Size(int.Parse(txtResX.Text), int.Parse(txtResY.Text));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
set
|
||||
{
|
||||
chkCustomResolution.Checked = value.HasValue;
|
||||
if (value.HasValue)
|
||||
{
|
||||
txtResX.Text = value.Value.Width.ToString();
|
||||
txtResY.Text = value.Value.Height.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsGameClient
|
||||
{
|
||||
get
|
||||
{
|
||||
return chkGameClient.Checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
chkGameClient.Checked = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLiveCam
|
||||
{
|
||||
get
|
||||
{
|
||||
return chkLiveCamera.Checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
chkLiveCamera.Checked = value;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsMissionReview
|
||||
{
|
||||
get
|
||||
{
|
||||
return chkMissionReview.Checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
chkMissionReview.Checked = value;
|
||||
}
|
||||
}
|
||||
|
||||
public dlgOptionalStartParams()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void chkCustomResolution_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
tlpResolution.Enabled = chkCustomResolution.Checked;
|
||||
}
|
||||
|
||||
private void txtRes_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextBox textBox = (TextBox)sender;
|
||||
int selectionStart = textBox.SelectionStart;
|
||||
int selectionLength = textBox.SelectionLength;
|
||||
textBox.Text = Regex.Replace(textBox.Text, "[^0-9]", "");
|
||||
textBox.Select(selectionStart, selectionLength);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.tlpResolution = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.txtResX = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtResY = new System.Windows.Forms.TextBox();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.chkCustomResolution = new System.Windows.Forms.CheckBox();
|
||||
this.chkLiveCamera = new System.Windows.Forms.CheckBox();
|
||||
this.cmdOK = new System.Windows.Forms.Button();
|
||||
this.chkGameClient = new System.Windows.Forms.CheckBox();
|
||||
this.chkMissionReview = new System.Windows.Forms.CheckBox();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.tlpResolution.SuspendLayout();
|
||||
base.SuspendLayout();
|
||||
this.label1.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(195, 32);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Select options you would like sent to Red Planet when it starts.";
|
||||
this.tlpResolution.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.tlpResolution.ColumnCount = 3;
|
||||
this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
|
||||
this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
|
||||
this.tlpResolution.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50f));
|
||||
this.tlpResolution.Controls.Add(this.txtResX, 0, 1);
|
||||
this.tlpResolution.Controls.Add(this.label2, 0, 0);
|
||||
this.tlpResolution.Controls.Add(this.txtResY, 2, 1);
|
||||
this.tlpResolution.Controls.Add(this.label3, 1, 1);
|
||||
this.tlpResolution.Controls.Add(this.label4, 2, 0);
|
||||
this.tlpResolution.Enabled = false;
|
||||
this.tlpResolution.Location = new System.Drawing.Point(27, 67);
|
||||
this.tlpResolution.Name = "tlpResolution";
|
||||
this.tlpResolution.RowCount = 2;
|
||||
this.tlpResolution.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpResolution.RowStyles.Add(new System.Windows.Forms.RowStyle());
|
||||
this.tlpResolution.Size = new System.Drawing.Size(180, 42);
|
||||
this.tlpResolution.TabIndex = 1;
|
||||
this.txtResX.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtResX.Location = new System.Drawing.Point(3, 17);
|
||||
this.txtResX.MaxLength = 5;
|
||||
this.txtResX.Name = "txtResX";
|
||||
this.txtResX.Size = new System.Drawing.Size(75, 20);
|
||||
this.txtResX.TabIndex = 3;
|
||||
this.txtResX.TextChanged += new System.EventHandler(txtRes_TextChanged);
|
||||
this.label2.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(3, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(35, 13);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Width";
|
||||
this.txtResY.Anchor = System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.txtResY.Location = new System.Drawing.Point(102, 17);
|
||||
this.txtResY.MaxLength = 5;
|
||||
this.txtResY.Name = "txtResY";
|
||||
this.txtResY.Size = new System.Drawing.Size(75, 20);
|
||||
this.txtResY.TabIndex = 5;
|
||||
this.txtResY.TextChanged += new System.EventHandler(txtRes_TextChanged);
|
||||
this.label3.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Location = new System.Drawing.Point(84, 21);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(12, 13);
|
||||
this.label3.TabIndex = 6;
|
||||
this.label3.Text = "x";
|
||||
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.label4.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left;
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Location = new System.Drawing.Point(102, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(38, 13);
|
||||
this.label4.TabIndex = 7;
|
||||
this.label4.Text = "Height";
|
||||
this.chkCustomResolution.AutoSize = true;
|
||||
this.chkCustomResolution.Location = new System.Drawing.Point(12, 44);
|
||||
this.chkCustomResolution.Name = "chkCustomResolution";
|
||||
this.chkCustomResolution.Size = new System.Drawing.Size(114, 17);
|
||||
this.chkCustomResolution.TabIndex = 2;
|
||||
this.chkCustomResolution.Text = "Custom Resolution";
|
||||
this.chkCustomResolution.UseVisualStyleBackColor = true;
|
||||
this.chkCustomResolution.CheckedChanged += new System.EventHandler(chkCustomResolution_CheckedChanged);
|
||||
this.chkLiveCamera.AutoSize = true;
|
||||
this.chkLiveCamera.Location = new System.Drawing.Point(12, 185);
|
||||
this.chkLiveCamera.Name = "chkLiveCamera";
|
||||
this.chkLiveCamera.Size = new System.Drawing.Size(85, 17);
|
||||
this.chkLiveCamera.TabIndex = 3;
|
||||
this.chkLiveCamera.Text = "Live Camera";
|
||||
this.chkLiveCamera.UseVisualStyleBackColor = true;
|
||||
this.cmdOK.Anchor = System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.cmdOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.cmdOK.Location = new System.Drawing.Point(132, 244);
|
||||
this.cmdOK.Name = "cmdOK";
|
||||
this.cmdOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.cmdOK.TabIndex = 4;
|
||||
this.cmdOK.Text = "OK";
|
||||
this.cmdOK.UseVisualStyleBackColor = true;
|
||||
this.chkGameClient.AutoSize = true;
|
||||
this.chkGameClient.Location = new System.Drawing.Point(12, 162);
|
||||
this.chkGameClient.Name = "chkGameClient";
|
||||
this.chkGameClient.Size = new System.Drawing.Size(83, 17);
|
||||
this.chkGameClient.TabIndex = 5;
|
||||
this.chkGameClient.Text = "Game Client";
|
||||
this.chkGameClient.UseVisualStyleBackColor = true;
|
||||
this.chkMissionReview.AutoSize = true;
|
||||
this.chkMissionReview.Location = new System.Drawing.Point(12, 208);
|
||||
this.chkMissionReview.Name = "chkMissionReview";
|
||||
this.chkMissionReview.Size = new System.Drawing.Size(100, 17);
|
||||
this.chkMissionReview.TabIndex = 6;
|
||||
this.chkMissionReview.Text = "Mission Review";
|
||||
this.chkMissionReview.UseVisualStyleBackColor = true;
|
||||
this.label5.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.label5.Location = new System.Drawing.Point(9, 127);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(195, 32);
|
||||
this.label5.TabIndex = 7;
|
||||
this.label5.Text = "Select which roles you would like this machine to fill.";
|
||||
base.AcceptButton = this.cmdOK;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(219, 279);
|
||||
base.Controls.Add(this.label5);
|
||||
base.Controls.Add(this.chkMissionReview);
|
||||
base.Controls.Add(this.chkGameClient);
|
||||
base.Controls.Add(this.cmdOK);
|
||||
base.Controls.Add(this.chkLiveCamera);
|
||||
base.Controls.Add(this.label1);
|
||||
base.Controls.Add(this.chkCustomResolution);
|
||||
base.Controls.Add(this.tlpResolution);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
base.MaximizeBox = false;
|
||||
base.MinimizeBox = false;
|
||||
base.Name = "dlgOptionalStartParams";
|
||||
this.Text = "Select Optional Parameters";
|
||||
this.tlpResolution.ResumeLayout(false);
|
||||
this.tlpResolution.PerformLayout();
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TeslaConsole;
|
||||
|
||||
public class dlgProgress : Form
|
||||
{
|
||||
private IContainer components;
|
||||
|
||||
private Label lblStatus;
|
||||
|
||||
private ProgressBar pbarProgress;
|
||||
|
||||
public int ProgressPercentage
|
||||
{
|
||||
get
|
||||
{
|
||||
return pbarProgress.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
pbarProgress.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
public string Status
|
||||
{
|
||||
get
|
||||
{
|
||||
return lblStatus.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
lblStatus.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public dlgProgress()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && components != null)
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lblStatus = new System.Windows.Forms.Label();
|
||||
this.pbarProgress = new System.Windows.Forms.ProgressBar();
|
||||
base.SuspendLayout();
|
||||
this.lblStatus.AutoSize = true;
|
||||
this.lblStatus.Location = new System.Drawing.Point(12, 9);
|
||||
this.lblStatus.Name = "lblStatus";
|
||||
this.lblStatus.Size = new System.Drawing.Size(96, 13);
|
||||
this.lblStatus.TabIndex = 0;
|
||||
this.lblStatus.Text = "Status goes here...";
|
||||
this.pbarProgress.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right;
|
||||
this.pbarProgress.Location = new System.Drawing.Point(15, 25);
|
||||
this.pbarProgress.Name = "pbarProgress";
|
||||
this.pbarProgress.Size = new System.Drawing.Size(364, 23);
|
||||
this.pbarProgress.TabIndex = 1;
|
||||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 13f);
|
||||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
base.ClientSize = new System.Drawing.Size(391, 57);
|
||||
base.Controls.Add(this.pbarProgress);
|
||||
base.Controls.Add(this.lblStatus);
|
||||
base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
base.MaximizeBox = false;
|
||||
base.MinimizeBox = false;
|
||||
base.Name = "dlgProgress";
|
||||
base.ShowInTaskbar = false;
|
||||
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Progress";
|
||||
base.ResumeLayout(false);
|
||||
base.PerformLayout();
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 138 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.7 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 3.5 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 2.9 KiB |