01-14-2015, 07:43 PM
Hi all, I have written a custom launcher for avalon lc and now I release the source.
(Sorry for my bad english)
What is new:
- IP for updates like the gamigo launcher
- Webviewer/Updates cant rightclick, moved the picture its fixed
- Read the displaysize and you can select a size in the launcher (only ep3)
- If a update is running you can click autostart after update
- You can add how often it can start
- Homepage and Forum Button, the buttons open your standard browser.
- You can all edit how u like.
- I help only for 10€ (PayPal or Amazon more over Private Message)
Server:
In the LC/bin/Release folder is a launcher folder for the server .html datas and so on
Comments to the Source
[hide]
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.Diagnostics;
using System.Net;
using System.IO;
using System.Runtime.InteropServices;
namespace LC
{
public partial class frm_launcher : Form
{
public string ip = "0.0.0.0";
private Point mouseposition;
public Launcher cLauncher;
List<string> dissize = new List<string>();
public frm_launcher()
{
InitializeComponent();
this.Cursor = CreateCursor(Properties.Resources.lc, 0, 0);
this.cLauncher = new Launcher();
ip = this.cLauncher.ip; //Catch the IP
isevent();
displaysize();
}
private void displaysize()
{
//Initialize aviable sizes
string[] mysize = { "800 600", "1024 768", "1152 864", "1280 720", "1280 800", "1280 960", "1280 1024", "1440 900", "1600 900", "1600 1200", "1680 1050", "1919 1079" };
//check if all sizes aviable for the user screen
realsize(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, mysize);
//set the actually size
string size = System.IO.File.ReadAllText(Application.StartupPath + "\\Data\\Etc\\DisplaySize.txt");
cB_size.Text = size;
}
private void realsize(int width, int height, string[] enablesize)
{
int ensize = enablesize.Length;
for(int i = 0; i < ensize; i++)
{
string[] splitter = enablesize[i].Split(' ');
if(width >= Convert.ToUInt32(splitter[0]) && height >= Convert.ToUInt32(splitter[1]))
{
dissize.Add(enablesize[i]);
}
}
cB_size.Items.AddRange(dissize.ToArray());
}
private void isevent()
{
//this is the html with your informations for the launcher
string patchtext = Get("http://" + ip + "/launcher/mylauncher.html");
//the background for your launcher in the webbrowser
string img = "http://" + ip + "/launcher/background.jpg";
//the css to fix the background and set the position for a better looking launcher and the source from the mylauncher.html will added
patchtext = "<style type=" + '"' + "text/css" + '"' + ">body{background-attachment: fixed;background-position:-197px -12px;background-repeat:repeat;background-image:url(" + img + ");}</style>" + patchtext;
//webbrowser become the source for showing
wB_update.DocumentText = patchtext;
}
private string Get(string URL)
{
try
{
HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(URL);
Request.Method = "GET";
Request.ContentType = "application/x-www-form-urlencoded";
Request.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
Request.Timeout = 3000;
HttpWebResponse Response = (HttpWebResponse)Request.GetResponse();
Stream DataStream = Response.GetResponseStream();
StreamReader Reader = new StreamReader(DataStream);
string ServerResponse = Reader.ReadToEnd();
Reader.Close();
DataStream.Close();
Response.Close();
return ServerResponse;
}
catch (Exception ex)
{
return "Can´t connect to the Server with the IP Address " + ip + " to the /launcher/mylauncher.html.";
}
}
private void frm_launcher_MouseDown(object sender, MouseEventArgs e)
{
mouseposition = new Point(-e.X, -e.Y);
Cursor = Cursors.SizeAll;
}
private void frm_launcher_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouseposition.X, mouseposition.Y);
Location = mousePos;
}
}
// Last Chaos start
private void start_game()
{
if (this.cLauncher.Version != this.cLauncher.NewestVersion)
{
return;
}
Process[] LC_Process = Process.GetProcessesByName("Nksp");
if (LC_Process.Length != 0) // Look if LastChaos is already running
{
MessageBox.Show("LastChaos is already running!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
else
{
string currentDir = Environment.CurrentDirectory;
// -------------------------------------------------------------------------------------
// The Parameter to start LastChaos " 4022" (EP2) change to " fkzktlfgod!" for (EP3)
// -------------------------------------------------------------------------------------
if (File.Exists(currentDir + "\\Bin\\Nksp.exe"))
{
int run = Convert.ToInt16(nUD.Value);
while (run > 0)
{
Process.Start(currentDir + "\\Bin\\Nksp.exe", " fkzktlfgod!"); // Here start LC with the true parameter 4022 oder fkzktlfgod!
run--;
}
}
else
{
MessageBox.Show("Error: Nksp.exe not found!", "Error: Nksp.exe", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
// -------------------------------------------------------------------------------------
Application.Exit();
}
}
private void frm_launcher_Load(object sender, EventArgs e)
{
this.cLauncher = new Launcher();
ip = this.cLauncher.ip;
this.Update();
}
public new void Update()
{
if (this.cLauncher.Version >= this.cLauncher.NewestVersion)
{
lbl_version.Text = Convert.ToString(this.cLauncher.Version)+ "/" + Convert.ToString(this.cLauncher.NewestVersion);
lbl_status.Text = "Complete";
lbl_status.Visible = true;
lbl_download.Visible = false;
lbl_versiontxt.Visible = false;
lbl_version.Visible = false;
pB_patch.Maximum = 100;
pB_patch.Value = 100;
if (cB_startafter.Checked)
{
start_game();
}
cB_startafter.Visible = false;
}
else
{
WebClient webClient = new WebClient();
cB_startafter.Visible = true;
webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(this.wClient_DownloadProgressChanged);
webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(this.wClient_DownloadFileCompleted);
int Version = this.cLauncher.Version + 1;
string Versions = Convert.ToString(Version);
webClient.DownloadFileAsync(new Uri(this.cLauncher.DownloadUrl + Versions + ".zip"), Versions + ".zip"); //, (string)(object)(this.cLauncher.Version + 1) + (object)".zip"
}
}
private void wClient_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
++this.cLauncher.Version;
int Version = this.cLauncher.Version;
string Versions = Convert.ToString(Version);
lbl_download.Text = "Extract Files";
this.cLauncher.Unzip(Versions + ".zip");
this.cLauncher.WriteVersion();
this.Update();
}
private void wClient_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
this.pB_patch.Value = e.ProgressPercentage;
lbl_download.Text = string.Format("{0:0,0}", Convert.ToInt32(e.BytesReceived)) + "/" + string.Format("{0:0,0}", Convert.ToInt32(e.TotalBytesToReceive));
lbl_version.Text = Convert.ToString(this.cLauncher.Version) + "/" + Convert.ToString(this.cLauncher.NewestVersion);
}
private void btn_close_Click(object sender, EventArgs e)
{
Close();
}
private void p_Name_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
Point mousePos = Control.MousePosition;
mousePos.Offset(mouseposition.X, mouseposition.Y);
Location = mousePos;
}
}
private void p_Name_MouseDown(object sender, MouseEventArgs e)
{
mouseposition = new Point(-e.X, -e.Y);
Cursor = Cursors.SizeAll;
}
private void frm_launcher_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = CreateCursor(Properties.Resources.lc, 0, 0);
}
private void p_Name_MouseUp(object sender, MouseEventArgs e)
{
this.Cursor = CreateCursor(Properties.Resources.lc, 0, 0);
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo);
[DllImport("user32.dll")]
public static extern IntPtr CreateIconIndirect(ref IconInfo icon);
public struct IconInfo
{
public bool fIcon;
public int xHotspot;
public int yHotspot;
public IntPtr hbmMask;
public IntPtr hbmColor;
}
public static Cursor CreateCursor(Bitmap bmp, int xHotSpot, int yHotSpot)
{
IntPtr ptr = bmp.GetHicon();
IconInfo tmp = new IconInfo();
GetIconInfo(ptr, ref tmp);
tmp.xHotspot = xHotSpot;
tmp.yHotspot = yHotSpot;
tmp.fIcon = false;
ptr = CreateIconIndirect(ref tmp);
return new Cursor(ptr);
}
private void btn_closedeinemutter_MouseHover(object sender, EventArgs e)
{
btn_closedeinemutter.BackgroundImage = Properties.Resources.close_2;
}
private void btn_closedeinemutter_MouseLeave(object sender, EventArgs e)
{
btn_closedeinemutter.BackgroundImage = Properties.Resources.close_1;
}
private void btn_closedeinemutter_Click(object sender, EventArgs e)
{
Close();
}
private void p_start_Click(object sender, EventArgs e)
{
start_game();
}
private void p_start_MouseHover(object sender, EventArgs e)
{
p_start.BackgroundImage = Properties.Resources.button1_click;
}
private void p_start_MouseLeave(object sender, EventArgs e)
{
p_start.BackgroundImage = Properties.Resources.button1;
}
private void cB_size_SelectedIndexChanged(object sender, EventArgs e)
{
string write = cB_size.Text;
System.IO.File.WriteAllText(Application.StartupPath + "\\Data\\Etc\\DisplaySize.txt", write);
}
private void open_side(string side)
{
string url = "http://" + ip + "/launcher/" + side + ".php";
Process.Start(url);
}
private void p_homepage_Click(object sender, EventArgs e)
{
open_side("homepage"); //set a redirect into your server /var/www/html/launcher/homepage.php to your homepage url
}
private void p_homepage_MouseHover(object sender, EventArgs e)
{
p_homepage.BackgroundImage = Properties.Resources.button1_click_homepage;
}
private void p_homepage_MouseLeave(object sender, EventArgs e)
{
p_homepage.BackgroundImage = Properties.Resources.button1_homepage;
}
private void p_forum_MouseHover(object sender, EventArgs e)
{
p_forum.BackgroundImage = Properties.Resources.button1_click_forum;
}
private void p_forum_MouseLeave(object sender, EventArgs e)
{
p_forum.BackgroundImage = Properties.Resources.button1_forum;
}
private void p_forum_Click(object sender, EventArgs e)
{
open_side("forum"); //set a redirect into your server /var/www/html/launcher/forum.php to your forum
}
}
}
[/hide]
Downloads
[hide]
2 | 2
[/hide]

