Commit 9217edf9 authored by 247321453's avatar 247321453

add

parent 737b767a
F:\game\YGOPRO
\ No newline at end of file
......@@ -222,21 +222,21 @@ private void InitializeComponent()
//
this.menuitem_about.Name = "menuitem_about";
this.menuitem_about.ShortcutKeys = System.Windows.Forms.Keys.F1;
this.menuitem_about.Size = new System.Drawing.Size(136, 22);
this.menuitem_about.Size = new System.Drawing.Size(152, 22);
this.menuitem_about.Text = "关于";
this.menuitem_about.Click += new System.EventHandler(this.Menuitem_aboutClick);
//
// menuitem_checkupdate
//
this.menuitem_checkupdate.Name = "menuitem_checkupdate";
this.menuitem_checkupdate.Size = new System.Drawing.Size(136, 22);
this.menuitem_checkupdate.Text = "下载新版本";
this.menuitem_checkupdate.Size = new System.Drawing.Size(152, 22);
this.menuitem_checkupdate.Text = "检查更新";
this.menuitem_checkupdate.Click += new System.EventHandler(this.Menuitem_checkupdateClick);
//
// menuitem_github
//
this.menuitem_github.Name = "menuitem_github";
this.menuitem_github.Size = new System.Drawing.Size(136, 22);
this.menuitem_github.Size = new System.Drawing.Size(152, 22);
this.menuitem_github.Text = "程序源码";
this.menuitem_github.Click += new System.EventHandler(this.Menuitem_githubClick);
//
......
......@@ -20,7 +20,8 @@ namespace DataEditorX
public partial class DataEditForm : Form
{
#region 成员变量
string GAMEPATH,PICPATH,UPDATEURL,GITURL,LUAPTH,INIPATH;
string GAMEPATH,PICPATH,LUAPTH;
string GITURL="https://github.com/247321453/DataEcitorX";
Card oldCard=new Card(0);
Card srcCard=new Card(0);
ImageForm imgform=new ImageForm();
......@@ -86,25 +87,19 @@ void DataEditFormLoad(object sender, EventArgs e)
void InitPath()
{
GAMEPATH=Application.StartupPath;
INIPATH=Path.Combine(GAMEPATH,"DataEditorX.txt");
if(File.Exists(INIPATH))
{
string[] lines=File.ReadAllLines(INIPATH, Encoding.UTF8);
GAMEPATH=(lines.Length>0)?lines[0]:Application.StartupPath;
UPDATEURL=(lines.Length>1)?lines[1]:"http://247321453@ys168.com";
GITURL=(lines.Length>2)?lines[2]:"https://github.com/247321453/DataEditorX";
}
else
string datapath=Path.Combine(Application.StartupPath,"data");
string txt=Path.Combine(datapath,"ygopro.txt");
if(File.Exists(txt))
{
GAMEPATH=Application.StartupPath;
UPDATEURL="http://247321453@ys168.com";
GITURL="https://github.com/247321453/DataEcitorX";
string[] lines=File.ReadAllLines(txt, Encoding.UTF8);
if(Directory.Exists(lines[0]))
GAMEPATH=(lines.Length>0)?lines[0]:Application.StartupPath;
else
MyMsg.Warning(string.Format("游戏目录不存在,请重新设置。\n{0}\n设置文件:\n{0}",lines[0],txt));
}
PICPATH=Path.Combine(GAMEPATH,"pics");
LUAPTH=Path.Combine(GAMEPATH,"script");
string datapath=Path.Combine(Application.StartupPath,"data");
confrule=Path.Combine(datapath,"card-rule.txt");
confattribute=Path.Combine(datapath,"card-attribute.txt");
confrace=Path.Combine(datapath,"card-race.txt");
......@@ -116,8 +111,7 @@ void InitPath()
}
void DataEditFormFormClosing(object sender, FormClosingEventArgs e)
{
if(!File.Exists(INIPATH))
File.WriteAllLines(INIPATH,new string[]{GAMEPATH,UPDATEURL,GITURL},Encoding.UTF8);
}
void SaveDic(string file, Dictionary<long, string> dic)
......@@ -794,7 +788,10 @@ void Menuitem_aboutClick(object sender, EventArgs e)
void Menuitem_checkupdateClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(UPDATEURL);
if(MyUpdate.CheckUpdate())
{
MyUpdate.Download();
}
}
void Menuitem_githubClick(object sender, EventArgs e)
{
......
......@@ -56,6 +56,7 @@
<DependentUpon>ImageForm.cs</DependentUpon>
</Compile>
<Compile Include="MyMsg.cs" />
<Compile Include="MyUpdate.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
......@@ -73,9 +74,6 @@
<Folder Include="Update" />
</ItemGroup>
<ItemGroup>
<None Include="DataEditorX.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Data\card-attribute.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......@@ -100,6 +98,9 @@
<None Include="Data\cover.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="Data\ygopro.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="readme.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
......
F:\game\YGOPRO
http://247321453.ys168.com
https://github.com/247321453/DataEditorX
\ No newline at end of file
/*
* 由SharpDevelop创建。
* 用户: Acer
* 日期: 5月21 星期三
* 时间: 10:10
*
*/
using System;
using System.IO;
using System.Text;
using System.Net;
using System.Windows.Forms;
namespace DataEditorX
{
/// <summary>
/// Description of MyUpdate.
/// </summary>
public static class MyUpdate
{
static readonly string VERURL="https://github.com/247321453/DataEditorX/raw/master/DataEditorX/Update/version.txt";
static readonly string DOWNURL="https://github.com/247321453/DataEditorX/raw/master/DataEditorX/Update/Release.zip";
public static bool CheckUpdate()
{
string ver,lasttime;
int l=-1;
string html=GetHtmlContentByUrl(VERURL);
if(string.IsNullOrEmpty(html))
{
MyMsg.Error("无法获取版本!");
return false;
}
l=html.IndexOf(" ");
ver=(l>=0)?html.Substring(0,l):"?.?.?.?";
lasttime=(l>=0)?html.Substring(l):"????-??-?? ??:??";
MyMsg.Show("当前版本:"+Application.ProductVersion
+"\n最新版本:"+ver
+"\n最后更新时间:"+lasttime);
return false;
}
public static void Download()
{
}
/// <summary>
///根据url获取网站html内容 /// </summary>
/// <param name="url">网址</param> /// <returns>获取网站html内容</returns>
public static string GetHtmlContentByUrl(string url)
{
string htmlContent = string.Empty;
try {
HttpWebRequest httpWebRequest =
(HttpWebRequest)WebRequest.Create(url);
httpWebRequest.Timeout = 5000;
using(HttpWebResponse httpWebResponse =
(HttpWebResponse)httpWebRequest.GetResponse())
{
using(Stream stream = httpWebResponse.GetResponseStream())
{
using(StreamReader streamReader =
new StreamReader(stream, Encoding.UTF8))
{
htmlContent = streamReader.ReadToEnd();
streamReader.Close();
}
stream.Close();
}
httpWebResponse.Close();
}
return htmlContent;
}
catch{
}
return "";
}
}
}
1.1.0.3
2014-5-21 10:00
\ No newline at end of file
1.1.0.3 2014-5-21 10:00
\ No newline at end of file
......@@ -15,8 +15,7 @@
2.更新网址
3.源码网址
DataEditorX.txt
F:\game\YGOPRO
http://247321453.ys168.com
https://github.com/247321453/DataEditorX
★设置游戏路径
data\ygopro.txt
注意:文本编码:UTF-8,最好是完整路径
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment