Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

i hate new learning version control systems, so i just press buttons …

…until it's happy.
  • Loading branch information...
commit a7b592eda6d22bfda6f8fb5f34e9a4f06ee38c87 1 parent ac24f8c
@Rahil627 authored
View
20 BabycastlesRunner.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual C# Express 2010
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BabycastlesRunner", "BabycastlesRunner.csproj", "{4D36E9AF-CD22-4D63-A82F-B1837EC4BEF2}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|x86 = Debug|x86
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {4D36E9AF-CD22-4D63-A82F-B1837EC4BEF2}.Debug|x86.ActiveCfg = Debug|x86
+ {4D36E9AF-CD22-4D63-A82F-B1837EC4BEF2}.Debug|x86.Build.0 = Debug|x86
+ {4D36E9AF-CD22-4D63-A82F-B1837EC4BEF2}.Release|x86.ActiveCfg = Release|x86
+ {4D36E9AF-CD22-4D63-A82F-B1837EC4BEF2}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
BIN  BabycastlesRunner.suo
Binary file not shown
View
75 GameConfiguration.cs
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Xml;
+using System.IO;
+
+namespace BabycastlesRunner
+{
+ /// <summary>
+ /// Holds game configuration settings
+ /// </summary>
+ public class GameConfiguration
+ {
+ public Boolean hideMouse;
+ public Boolean useJoyToKey;
+ public Boolean repositionMouse;
+ public Boolean fullScreen;
+
+ public int mouseX;
+ public int mouseY;
+
+ public String joyToKeyPath;
+
+ private String gameName; //had to make these properties to set it to Display/ValueMember
+ public String GameName { get { return gameName; } /*set { gameName = value; }*/ }
+ private String gamePath; //upper case public members (fields?) and properties naming convention?
+ public String GamePath { get { return gamePath; } /*set { gamePath = value; }*/ }
+
+ public GameConfiguration(String filePath)
+ {
+ load(filePath);
+ }
+
+ public void load(String filePath)
+ {
+ StreamReader streamReader = new StreamReader(filePath);
+ string parameterXml = streamReader.ReadToEnd();
+ streamReader.Close();
+
+ using (XmlReader reader = XmlReader.Create(new StringReader(parameterXml)))
+ {
+ reader.ReadToFollowing("gameName");
+ gameName = reader.ReadElementContentAsString();
+
+ reader.ReadToFollowing("gamePath");
+ gamePath = reader.ReadElementContentAsString();
+
+ reader.ReadToFollowing("useJoyToKey");
+ useJoyToKey = reader.ReadElementContentAsBoolean();
+
+ if (useJoyToKey)
+ {
+ reader.ReadToFollowing("joyToKeyPath");
+ joyToKeyPath = reader.ReadElementContentAsString();
+ }
+
+ reader.ReadToFollowing("repositionMouse");
+ repositionMouse = reader.ReadElementContentAsBoolean();
+
+ if (repositionMouse)
+ {
+ reader.ReadToFollowing("mouseX");
+ mouseX = reader.ReadElementContentAsInt();
+
+ reader.ReadToFollowing("mouseY");
+ mouseY = reader.ReadElementContentAsInt();
+ }
+
+ reader.ReadToFollowing("hideMouse");
+ // hideMouse = reader.ReadElementContentAsBoolean();
+ }
+ }
+ }
+}
View
91 GameHandler.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.Drawing;
+
+namespace BabycastlesRunner
+{
+ class GameHandler
+ {
+ public GameHandler()
+ {
+
+ }
+
+ public void begin(string pathToGameConfig)
+ {
+ Cursor.Hide();
+ Boolean closed = true;
+ Boolean stopRunner = false;
+ MousePointer pointer = new MousePointer();
+
+ GameConfiguration gameConfig = new GameConfiguration(pathToGameConfig);
+
+ System.Diagnostics.Process game;
+ System.Diagnostics.Process joyToKey;
+
+ gameConfig.useJoyToKey = false;
+ gameConfig.hideMouse = true;
+
+ game = new System.Diagnostics.Process();
+ joyToKey = new System.Diagnostics.Process();
+
+
+ while (!stopRunner)
+ {
+ //restart the game
+ if (Keyboard.IsKeyDown(Keys.A))
+ {
+ game.Kill();
+ closed = true;
+ }
+
+ //stop the auto-handler
+ if (Keyboard.IsKeyDown(Keys.Z))
+ {
+ stopRunner = true;
+ Taskbar.Show();
+ pointer.show();
+
+ }
+ pointer.hide();
+
+ if (closed)
+ {
+ Taskbar.Hide();
+
+ if (gameConfig.repositionMouse)
+ Cursor.Position = new Point(gameConfig.mouseX, gameConfig.mouseY);
+
+ // if (myParameters.hideMouse)
+ pointer.hide();
+
+ System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(gameConfig.GamePath);
+ System.Diagnostics.ProcessStartInfo psiJoy = new System.Diagnostics.ProcessStartInfo(gameConfig.joyToKeyPath);
+ psi.RedirectStandardOutput = false;
+ psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Maximized;
+ psi.UseShellExecute = true;
+ if (gameConfig.useJoyToKey)
+ {
+ psiJoy.RedirectStandardOutput = true;
+ psiJoy.WindowStyle = System.Diagnostics.ProcessWindowStyle.Minimized;
+ psiJoy.UseShellExecute = false;
+
+ joyToKey = System.Diagnostics.Process.Start(psiJoy);
+ }
+ game = System.Diagnostics.Process.Start(psi);
+
+ closed = false;
+ }
+
+ game.WaitForExit(100);
+ if (game.HasExited)
+ {
+ closed = true;
+ }
+ }
+ }
+ }
+}
View
36 General.cs
@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace BabycastlesRunner
+{
+ /// <summary>
+ /// Contains some general classes and functions
+ /// </summary>
+ class General
+ {
+ public static class ListItemData
+ {
+ public static ListItemData<T> Create<T>(T value, string text)
+ {
+ return new ListItemData<T>
+ {
+ Value = value,
+ Text = text
+ };
+ }
+ }
+
+ public class ListItemData<T>
+ {
+ public T Value { get; set; }
+ public string Text { get; set; }
+
+ public override string ToString()
+ {
+ return Text;
+ }
+ }
+ }
+}
View
1  Settings.StyleCop
@@ -0,0 +1 @@
+<StyleCopSettings Version="4.3" />
View
86 UserGUI.Designer.cs
@@ -0,0 +1,86 @@
+namespace BabycastlesRunner
+{
+ partial class UserGUI
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.IContainer components = null;
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.label1 = new System.Windows.Forms.Label();
+ this.gameComboBox = new System.Windows.Forms.ComboBox();
+ this.playButton = new System.Windows.Forms.Button();
+ this.SuspendLayout();
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(11, 15);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(78, 13);
+ this.label1.TabIndex = 0;
+ this.label1.Text = "Select a game:";
+ //
+ // gameComboBox
+ //
+ this.gameComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.gameComboBox.FormattingEnabled = true;
+ this.gameComboBox.Location = new System.Drawing.Point(95, 12);
+ this.gameComboBox.Name = "gameComboBox";
+ this.gameComboBox.Size = new System.Drawing.Size(121, 21);
+ this.gameComboBox.TabIndex = 1;
+ //
+ // playButton
+ //
+ this.playButton.Location = new System.Drawing.Point(222, 10);
+ this.playButton.Name = "playButton";
+ this.playButton.Size = new System.Drawing.Size(75, 23);
+ this.playButton.TabIndex = 2;
+ this.playButton.Text = "Play";
+ this.playButton.UseVisualStyleBackColor = true;
+ this.playButton.Click += new System.EventHandler(this.playButton_Click);
+ //
+ // UserGUI
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(307, 45);
+ this.Controls.Add(this.playButton);
+ this.Controls.Add(this.gameComboBox);
+ this.Controls.Add(this.label1);
+ this.Name = "UserGUI";
+ this.Text = "User GUI";
+ this.Load += new System.EventHandler(this.UserGUI_Load);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.ComboBox gameComboBox;
+ private System.Windows.Forms.Button playButton;
+ }
+}
View
59 UserGUI.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using System.IO;
+using System.Diagnostics;
+
+namespace BabycastlesRunner
+{
+ /// <summary>
+ /// The main window
+ /// </summary>
+ public partial class UserGUI : Form
+ {
+ private List<GameConfiguration> gameConfigs = new List<GameConfiguration>();
+
+ public UserGUI()
+ {
+ InitializeComponent();
+ }
+
+ private void UserGUI_Load(object sender, EventArgs e)
+ {
+ //can do some of this in Program.cs
+
+ //TODO: synchronize game config list with the server
+
+ //create a folder if it does not exist
+
+ //load game configurations from folder
+ string[] filePaths = Directory.GetFiles(@"Game Configurations\", "*.xml");
+
+ foreach (string filePath in filePaths)
+ {
+ GameConfiguration gameConfig = new GameConfiguration(filePath);
+ gameConfigs.Add(gameConfig);
+ }
+
+ //bind combo box
+ gameComboBox.DataSource = gameConfigs;
+ gameComboBox.DisplayMember = "GameName"; //optional, and almost must be a property
+ gameComboBox.ValueMember = "GamePath"; //must be a property
+ }
+
+ private void playButton_Click(object sender, EventArgs e)
+ {
+ //run the selected game
+ GameHandler gameHandler = new GameHandler();
+ gameHandler.begin((string)gameComboBox.SelectedValue);
+
+ //TODO: if game does not exist, download the game, store download URL in game config
+ //but also provide a download all option, for a full setup
+ }
+ }
+}
View
120 UserGUI.resx
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+ <!--
+ Microsoft ResX Schema
+
+ Version 2.0
+
+ The primary goals of this format is to allow a simple XML format
+ that is mostly human readable. The generation and parsing of the
+ various data types are done through the TypeConverter classes
+ associated with the data types.
+
+ Example:
+
+ ... ado.net/XML headers & schema ...
+ <resheader name="resmimetype">text/microsoft-resx</resheader>
+ <resheader name="version">2.0</resheader>
+ <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+ <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+ <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+ <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+ <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+ <value>[base64 mime encoded serialized .NET Framework object]</value>
+ </data>
+ <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+ <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+ <comment>This is a comment</comment>
+ </data>
+
+ There are any number of "resheader" rows that contain simple
+ name/value pairs.
+
+ Each data row contains a name, and value. The row also contains a
+ type or mimetype. Type corresponds to a .NET class that support
+ text/value conversion through the TypeConverter architecture.
+ Classes that don't support this are serialized and stored with the
+ mimetype set.
+
+ The mimetype is used for serialized objects, and tells the
+ ResXResourceReader how to depersist the object. This is currently not
+ extensible. For a given mimetype the value must be set accordingly:
+
+ Note - application/x-microsoft.net.object.binary.base64 is the format
+ that the ResXResourceWriter will generate, however the reader can
+ read any of the formats listed below.
+
+ mimetype: application/x-microsoft.net.object.binary.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.soap.base64
+ value : The object must be serialized with
+ : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+ : and then encoded with base64 encoding.
+
+ mimetype: application/x-microsoft.net.object.bytearray.base64
+ value : The object must be serialized into a byte array
+ : using a System.ComponentModel.TypeConverter
+ : and then encoded with base64 encoding.
+ -->
+ <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+ <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+ <xsd:element name="root" msdata:IsDataSet="true">
+ <xsd:complexType>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:element name="metadata">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" />
+ </xsd:sequence>
+ <xsd:attribute name="name" use="required" type="xsd:string" />
+ <xsd:attribute name="type" type="xsd:string" />
+ <xsd:attribute name="mimetype" type="xsd:string" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="assembly">
+ <xsd:complexType>
+ <xsd:attribute name="alias" type="xsd:string" />
+ <xsd:attribute name="name" type="xsd:string" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="data">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+ <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+ <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+ <xsd:attribute ref="xml:space" />
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="resheader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+ </xsd:sequence>
+ <xsd:attribute name="name" type="xsd:string" use="required" />
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:choice>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:schema>
+ <resheader name="resmimetype">
+ <value>text/microsoft-resx</value>
+ </resheader>
+ <resheader name="version">
+ <value>2.0</value>
+ </resheader>
+ <resheader name="reader">
+ <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+ <resheader name="writer">
+ <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+ </resheader>
+</root>
View
15 bin/Debug/Game Configurations/ai.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<gameSettings>
+ <version>1.0</version>
+ <gameName>Al The Chemist</gameName>
+ <gamePath>Games\Al.exe</gamePath>
+ <useJoyToKey>false</useJoyToKey>
+ <joyToKeyPath>""</joyToKeyPath>
+ <repositionMouse>true</repositionMouse>
+ <hideMouse>true</hideMouse>
+ <mouseX>400</mouseX>
+ <mouseY>400</mouseY>
+ <fullScreen></fullScreen>
+ <fullScreenKeys></fullScreenKeys>
+</gameSettings>
+
View
15 bin/Debug/Game Configurations/nidhogg.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<gameSettings>
+ <version>1.0</version>
+ <gameName>Nidhogg</gameName>
+ <gamePath>Games\Al.exe</gamePath>
+ <useJoyToKey>false</useJoyToKey>
+ <joyToKeyPath>""</joyToKeyPath>
+ <repositionMouse>true</repositionMouse>
+ <hideMouse>true</hideMouse>
+ <mouseX>400</mouseX>
+ <mouseY>400</mouseY>
+ <fullScreen></fullScreen>
+ <fullScreenKeys></fullScreenKeys>
+</gameSettings>
+
View
BIN  bin/Debug/Games/al.exe
Binary file not shown
View
BIN  obj/x86/Debug/BabycastlesRunner.UserGUI.resources
Binary file not shown
View
BIN  obj/x86/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown
View
BIN  obj/x86/Debug/GenerateResource.read.1.tlog
Binary file not shown
View
BIN  obj/x86/Debug/GenerateResource.write.1.tlog
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.