├── .gitignore
├── LICENSE
├── README.en-US.md
├── README.md
└── source
├── FastSegatools With GUI.csproj
├── FastSegatools With GUI.sln
├── IPTextBox.Designer.cs
├── IPTextBox.cs
├── IPTextBox.resx
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── Resources
├── Icon.ico
└── segatools.ini
├── StartWin.cs
├── StartWin.resx
├── Startwin.Designer.cs
└── app.config
/.gitignore:
--------------------------------------------------------------------------------
1 | source/.vs/
2 | source/bin/
3 | source/obj/
4 | source/FastSegatools With GUI.csproj.user
5 | source/FastSegatools With GUI.sln.DotSettings.user
6 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Magicial-Studio
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.en-US.md:
--------------------------------------------------------------------------------
1 | # Fast Segatools With GUI
2 |
3 | 
4 | 
5 | ## Description
6 |
7 | This is a C sharp program used to configure segatools without manually modifying segatools.ini
8 |
9 | This program has taken a lot of big people's efforts. I hope you're happy with it
10 |
11 | Thank you all for participating in the development and giving me valuable suggestions. Thank you
12 |
13 | Enjoy yourself
14 |
15 | 2020/2/6 By Raspberry Monster
16 |
17 | ## Notice
18 |
19 | This Program has no English interface yet
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Fast Segatools With GUI
2 |
3 | [English README](https://github.com/Raspberry-Monster/Fast-Segatools-With-GUI/blob/master/README.en-US.md)
4 |
5 | 
6 | 
7 |
8 | ## 简介
9 |
10 | 这是一个用于配置SegaTools,而无需手动修改Segatools.ini的一个C#程序
11 |
12 | 此程序花费了很多大佬的心血 希望你用的开心
13 |
14 | 在此感谢所有参与开发,向我提出了宝贵建议的朋友们 谢谢大家
15 |
16 | 尽情享受吧
17 |
18 | 2020/2/6 By Raspberry Monster
19 |
20 | ---
21 | ## 编译注意事项
22 | - 最低 .NET Framework 4.5 targeting pack
23 | - 如果设计器报错,请根据提示先生成程序
--------------------------------------------------------------------------------
/source/FastSegatools With GUI.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {34714811-13A7-4AA5-87B0-719954D9C2A2}
8 | WinExe
9 | FastSegatools_With_GUI
10 | FastSegatools With GUI
11 | v4.5
12 | 512
13 | true
14 |
15 | publish\
16 | true
17 | Disk
18 | false
19 | Foreground
20 | 7
21 | Days
22 | false
23 | false
24 | true
25 | 0
26 | 1.0.0.%2a
27 | false
28 | false
29 | true
30 |
31 |
32 | AnyCPU
33 | true
34 | full
35 | false
36 | bin\Debug\
37 | DEBUG;TRACE
38 | prompt
39 | 4
40 | false
41 |
42 |
43 | AnyCPU
44 | none
45 | true
46 | bin\Release\
47 | TRACE
48 | prompt
49 | 4
50 | false
51 | false
52 |
53 |
54 | Resources\Icon.ico
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Component
71 |
72 |
73 | IPTextBox.cs
74 |
75 |
76 | Form
77 |
78 |
79 | StartWin.cs
80 |
81 |
82 |
83 |
84 | IPTextBox.cs
85 |
86 |
87 | ResXFileCodeGenerator
88 | Resources.Designer.cs
89 | Designer
90 |
91 |
92 | True
93 | Resources.resx
94 | True
95 |
96 |
97 | StartWin.cs
98 |
99 |
100 |
101 | SettingsSingleFileGenerator
102 | Settings.Designer.cs
103 |
104 |
105 | True
106 | Settings.settings
107 | True
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 | False
119 | .NET Framework 3.5 SP1
120 | false
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
--------------------------------------------------------------------------------
/source/FastSegatools With GUI.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29728.190
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FastSegatools With GUI", "FastSegatools With GUI.csproj", "{34714811-13A7-4AA5-87B0-719954D9C2A2}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {34714811-13A7-4AA5-87B0-719954D9C2A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {34714811-13A7-4AA5-87B0-719954D9C2A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {34714811-13A7-4AA5-87B0-719954D9C2A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {34714811-13A7-4AA5-87B0-719954D9C2A2}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {819237AA-A8C3-485B-8700-3CE2CEE74BB4}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/source/IPTextBox.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace FastSegatools_With_GUI
2 | {
3 | partial class IPTextBox
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region 组件设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.textBox1 = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // textBox1
35 | //
36 | this.textBox1.Location = new System.Drawing.Point(0, 0);
37 | this.textBox1.Name = "textBox1";
38 | this.textBox1.Size = new System.Drawing.Size(100, 21);
39 | this.textBox1.TabIndex = 0;
40 | this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
41 | this.ResumeLayout(false);
42 |
43 | }
44 |
45 | #endregion
46 |
47 | private System.Windows.Forms.TextBox textBox1;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/source/IPTextBox.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Forms;
2 |
3 | namespace FastSegatools_With_GUI
4 | {
5 | public partial class IPTextBox : TextBox
6 | {
7 | public IPTextBox() : base()
8 | {
9 | SetStyle(ControlStyles.ResizeRedraw, true);
10 | }
11 |
12 | protected override CreateParams CreateParams
13 | {
14 | get
15 | {
16 | var cp = base.CreateParams;
17 | cp.ClassName = "SysIPAddress32";
18 | return cp;
19 | }
20 | }
21 |
22 | private void textBox1_TextChanged(object sender, System.EventArgs e)
23 | {
24 |
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/source/IPTextBox.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
124 | False
125 |
126 |
--------------------------------------------------------------------------------
/source/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace FastSegatools_With_GUI
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// 应用程序的主入口点。
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new FastSegaTools_with_GUI.Startwin());
19 | //Supported BY Fantasy GM
20 | //Supported BY Eraser
21 | //Supported BY WM86
22 | //Supported BY Silpher
23 | //Thank You !
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/source/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.InteropServices;
3 |
4 | // 有关程序集的一般信息由以下
5 | // 控制。更改这些特性值可修改
6 | // 与程序集关联的信息。
7 | [assembly: AssemblyTitle("FastSegatools With GUI")]
8 | [assembly: AssemblyDescription("")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("FastSegatools With GUI")]
12 | [assembly: AssemblyCopyright("Copyright © 2020")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // 将 ComVisible 设置为 false 会使此程序集中的类型
17 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
18 | //请将此类型的 ComVisible 特性设置为 true。
19 | [assembly: ComVisible(false)]
20 |
21 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
22 | [assembly: Guid("34714811-13a7-4aa5-87b0-719954d9c2a2")]
23 |
24 | // 程序集的版本信息由下列四个值组成:
25 | //
26 | // 主版本
27 | // 次版本
28 | // 生成号
29 | // 修订号
30 | //
31 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
32 | //通过使用 "*",如下所示:
33 | // [assembly: AssemblyVersion("1.0.*")]
34 | [assembly: AssemblyVersion("1.0.0.0")]
35 | [assembly: AssemblyFileVersion("1.0.0.0")]
--------------------------------------------------------------------------------
/source/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace FastSegatools_With_GUI.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FastSegatools_With_GUI.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 重写当前线程的 CurrentUICulture 属性
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Icon Icon {
67 | get {
68 | object obj = ResourceManager.GetObject("Icon", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// 查找类似 [vfs]
75 | ///; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
76 | ///amfs=C:\
77 | ///; Create an empty directory somewhere and insert the path here.
78 | ///; This directory may be shared between multiple SEGA games.
79 | ///; NOTE: This has nothing to do with Windows %APPDATA%.
80 | ///appdata=C:\
81 | ///
82 | ///[dns]
83 | ///; Insert the hostname or IP address of the server you wish to use here.
84 | ///; Note that 127.0.0.1, localhost etc are specifically rejected.
85 | ///default=localhost
86 | ///
87 | ///[ds]
88 | ///; Region code on the emulated AMEX board DS EEPROM.
89 | ///; 1: Japan
90 | ///; [字符串的其余部分被截断]"; 的本地化字符串。
91 | ///
92 | internal static string segatools_ini {
93 | get {
94 | return ResourceManager.GetString("segatools_ini", resourceCulture);
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/source/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\Icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\resources\segatools.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;gb2312
126 |
127 |
--------------------------------------------------------------------------------
/source/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace FastSegatools_With_GUI.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.4.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/source/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/source/Resources/Icon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Magicial-Studio/Fast-Segatools-With-GUI/cb36c3b8c4156e6b44115226ed3f0e64251b37a2/source/Resources/Icon.ico
--------------------------------------------------------------------------------
/source/Resources/segatools.ini:
--------------------------------------------------------------------------------
1 | [vfs]
2 | ; Insert the path to the game AMFS directory here (contains ICF1 and ICF2)
3 | amfs=C:\
4 | ; Create an empty directory somewhere and insert the path here.
5 | ; This directory may be shared between multiple SEGA games.
6 | ; NOTE: This has nothing to do with Windows %APPDATA%.
7 | appdata=C:\
8 |
9 | [dns]
10 | ; Insert the hostname or IP address of the server you wish to use here.
11 | ; Note that 127.0.0.1, localhost etc are specifically rejected.
12 | default=localhost
13 |
14 | [ds]
15 | ; Region code on the emulated AMEX board DS EEPROM.
16 | ; 1: Japan
17 | ; 4: Export (some UI elements in English)
18 | ;
19 | ; NOTE: Changing this setting causes a factory reset.
20 | region=1
21 |
22 | [netenv]
23 | ; Simulate an ideal LAN environment. This may interfere with head-to-head play.
24 | ; SEGA games are somewhat picky about their LAN environment, so leaving this
25 | ; setting enabled is recommended.
26 | enable=1
27 |
28 | [keychip]
29 | ; The /24 LAN subnet that the emulated keychip will tell the game to expect.
30 | ; If you disable netenv then you must set this to your LAN's IP subnet, and
31 | ; that subnet must start with 192.168.
32 | subnet=192.168.250.0
33 | id=A69E-01A88888888
34 |
35 | [gpio]
36 | ; Emulated Nu DIP switch for Distribution Server setting.
37 | ;
38 | ; If multiple machines are present on the same LAN then set this to 1 on
39 | ; exactly one machine and set this to 0 on all others.
40 | dipsw1=0
41 |
42 | [io3]
43 | ; Input API selection for JVS input emulator.
44 | mode=xinput
45 | ; Automatically reset the simulated shifter to Neutral when XInput Start is
46 | ; pressed (e.g. when navigating menus between races).
47 | autoNeutral=1
48 |
49 | [gfx]
50 | enable=0
--------------------------------------------------------------------------------
/source/StartWin.cs:
--------------------------------------------------------------------------------
1 | using FastSegatools_With_GUI.Properties;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Diagnostics;
5 | using System.IO;
6 | using System.Net.NetworkInformation;
7 | using System.Net.Sockets;
8 | using System.Runtime.InteropServices;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 |
13 | namespace FastSegaTools_with_GUI
14 | {
15 | public partial class Startwin : Form
16 | {
17 | private readonly string segatools_ini = "segatools.ini";
18 |
19 | public Startwin()
20 | {
21 | InitializeComponent();
22 | if (System.IO.File.Exists(@"Custom")) Server_textBox.Text = System.IO.File.ReadAllText(@"Custom");
23 | }
24 |
25 | private void Start_Click(object sender, EventArgs e)
26 | {
27 | /*
28 | if (MessageBox.Show("确认设定?", "", MessageBoxButtons.OKCancel) != DialogResult.OK)
29 | {
30 | info_label.Text = "已取消";
31 | return;
32 | }
33 | */
34 | var subnet = subnet_label.Text;
35 | var server = Server_textBox.Text;
36 |
37 | if (server == "" || subnet == "")
38 | {
39 | info_label.Text = @"未输入服务器或IPv4地址";
40 | return;
41 | }
42 |
43 | if (server == "localhost" || server == "127.0.0.1")
44 | {
45 | info_label.Text = @"DIVA 不接受本地本地环回地址";
46 | return;
47 | }
48 |
49 | string path;
50 | if (checkBox1.Checked)
51 | {
52 | path = SelectINI();
53 | if (path == "")
54 | {
55 | info_label.Text = @"已取消";
56 | return;
57 | }
58 | }
59 | else
60 | {
61 | if (!File.Exists(segatools_ini))
62 | try
63 | {
64 | File.WriteAllText(segatools_ini, Resources.segatools_ini);
65 | }
66 | catch
67 | {
68 | throw new Exception(@"无法在当前目录下保存 " + segatools_ini);
69 | }
70 |
71 | path = segatools_ini;
72 | }
73 |
74 | WriteSetting(path);
75 | }
76 |
77 | [DllImport("KERNEL32.DLL", EntryPoint = "WritePrivateProfileStringW",
78 | SetLastError = true,
79 | CharSet = CharSet.Unicode, ExactSpelling = true,
80 | CallingConvention = CallingConvention.StdCall)]
81 | private static extern int WritePrivateProfileStringW(
82 | string lpAppName,
83 | string lpKeyName,
84 | string lpString,
85 | string lpFilename);
86 |
87 | private void WriteSetting(string path)
88 | {
89 | // 写入配置
90 | WritePrivateProfileStringW("dns", "default", Server_textBox.Text, path);
91 | WritePrivateProfileStringW("keychip", "subnet", subnet_label.Text, path);
92 | info_label.Text = @"已保存入" + path;
93 | }
94 |
95 |
96 | private string SelectINI()
97 | {
98 | // 选择已有配置
99 | var divaPath = "";
100 | // 预测diva.exe路径
101 | var key = Registry.CurrentUser.OpenSubKey(
102 | "SOFTWARE\\Classes\\Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache");
103 | if (key != null)
104 | {
105 | var keyNames = key.GetValueNames();
106 | foreach (var n in keyNames)
107 | {
108 | if (!n.Contains("diva.exe")) continue;
109 | var gamePath = n.Remove(n.LastIndexOf('\\') + 1);
110 | if (!Directory.Exists(gamePath)) continue;
111 | divaPath = gamePath;
112 | break;
113 | }
114 | }
115 |
116 | var openFileDialog1 = new OpenFileDialog
117 | {
118 | Filter = segatools_ini + "|" + segatools_ini,
119 | FilterIndex = 0,
120 | InitialDirectory = divaPath,
121 | RestoreDirectory = true
122 | };
123 |
124 |
125 | if (openFileDialog1.ShowDialog() == DialogResult.OK)
126 | {
127 | divaPath = openFileDialog1.FileName;
128 | return divaPath;
129 | }
130 |
131 | return "";
132 | }
133 |
134 | private static int TestServer(string server)
135 | {
136 | // 测试延迟
137 | Ping pinger = null;
138 | var delay = -1;
139 | try
140 | {
141 | pinger = new Ping();
142 | var reply = pinger.Send(server);
143 | var pingRelied = reply.Status == IPStatus.Success;
144 | if (pingRelied)
145 | delay = (int)reply.RoundtripTime;
146 | else
147 | delay = -1;
148 | }
149 | catch (PingException)
150 | {
151 | // Discard PingExceptions and return false;
152 | }
153 | finally
154 | {
155 | pinger?.Dispose();
156 | }
157 |
158 | return delay;
159 | }
160 |
161 | private static string GetIP()
162 | {
163 | // 得到活动ip
164 | foreach (var network in NetworkInterface.GetAllNetworkInterfaces())
165 | if (network.OperationalStatus == OperationalStatus.Up &&
166 | network.GetIPProperties()?.GatewayAddresses.Count != 0)
167 | foreach (var ip in network.GetIPProperties().UnicastAddresses)
168 | if (ip.Address.AddressFamily == AddressFamily.InterNetwork)
169 | return ip.Address.ToString();
170 | return "";
171 | }
172 |
173 | private string GetSubnet(string ip)
174 | {
175 | // 从ip得到子网
176 | if (ip.Split('.').Length != 4)
177 | return "";
178 | return ip.Remove(ip.LastIndexOf('.') + 1) + "0";
179 | }
180 |
181 | private void Cancel_Click(object sender, EventArgs e)
182 | {
183 | Application.Exit();
184 | }
185 |
186 | private void label_info_TextChanged(object sender, EventArgs e)
187 | {
188 | // 自动重置信息
189 | if (info_label.Text != "")
190 | Task.Run(() =>
191 | {
192 | Thread.Sleep(2000);
193 | Invoke((Action)(() => info_label.Text = ""));
194 | return 1;
195 | });
196 | }
197 |
198 | private void Startwin_Load(object sender, EventArgs e)
199 | {
200 | // 初始化
201 | ipTextBox.Text = GetIP();
202 | if (ipTextBox.Text != @"0.0.0.0")
203 | ipTextBox.Enabled = false;
204 | subnet_label.Text = GetSubnet(ipTextBox.Text);
205 | }
206 |
207 | private void ipTextBox_TextChanged(object sender, EventArgs e)
208 | {
209 | // ip变化更新子网
210 | try
211 | {
212 | subnet_label.Text = GetSubnet(ipTextBox.Text);
213 | }
214 | catch
215 | {
216 | subnet_label.Text = "";
217 | }
218 | }
219 |
220 | private void timer1_Tick(object sender, EventArgs e)
221 | {
222 | Task.Run(() =>
223 | {
224 | var delay = TestServer(Server_textBox.Text).ToString();
225 | //UpdateDelay(delay);
226 |
227 | Invoke((Action)(() => delay_label.Text = @"Delay: " + delay + @"ms"));
228 | return 1;
229 | });
230 | }
231 |
232 | private void label1_Click(object sender, EventArgs e)
233 | {
234 | if (ModifierKeys == Keys.Control) ipTextBox.Enabled = !ipTextBox.Enabled;
235 | }
236 |
237 | private void Server_textBox_TextChanged(object sender, EventArgs e)
238 | {
239 |
240 | }
241 | }
242 | }
--------------------------------------------------------------------------------
/source/StartWin.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/source/Startwin.Designer.cs:
--------------------------------------------------------------------------------
1 | using FastSegatools_With_GUI;
2 | using FastSegatools_With_GUI.Properties;
3 |
4 | namespace FastSegaTools_with_GUI
5 | {
6 | partial class Startwin
7 | {
8 | ///
9 | /// 必需的设计器变量。
10 | ///
11 | private System.ComponentModel.IContainer components = null;
12 |
13 | ///
14 | /// 清理所有正在使用的资源。
15 | ///
16 | /// 如果应释放托管资源,为 true;否则为 false。
17 | protected override void Dispose(bool disposing)
18 | {
19 | if (disposing && (components != null))
20 | {
21 | components.Dispose();
22 | }
23 | base.Dispose(disposing);
24 | }
25 |
26 | #region Windows 窗体设计器生成的代码
27 |
28 | ///
29 | /// 设计器支持所需的方法 - 不要修改
30 | /// 使用代码编辑器修改此方法的内容。
31 | ///
32 | private void InitializeComponent()
33 | {
34 | this.components = new System.ComponentModel.Container();
35 | this.Title1 = new System.Windows.Forms.Label();
36 | this.Set = new System.Windows.Forms.Button();
37 | this.Cancel = new System.Windows.Forms.Button();
38 | this.label2 = new System.Windows.Forms.Label();
39 | this.Server_textBox = new System.Windows.Forms.TextBox();
40 | this.info_label = new System.Windows.Forms.Label();
41 | this.label1 = new System.Windows.Forms.Label();
42 | this.subnet_label = new System.Windows.Forms.Label();
43 | this.subnetText_label = new System.Windows.Forms.Label();
44 | this.checkBox1 = new System.Windows.Forms.CheckBox();
45 | this.delay_label = new System.Windows.Forms.Label();
46 | this.timer1 = new System.Windows.Forms.Timer(this.components);
47 | this.ipTextBox = new FastSegatools_With_GUI.IPTextBox();
48 | this.SuspendLayout();
49 | //
50 | // Title1
51 | //
52 | this.Title1.AutoSize = true;
53 | this.Title1.Font = new System.Drawing.Font("微软雅黑", 15F);
54 | this.Title1.Location = new System.Drawing.Point(110, 22);
55 | this.Title1.Name = "Title1";
56 | this.Title1.Size = new System.Drawing.Size(222, 27);
57 | this.Title1.TabIndex = 0;
58 | this.Title1.Text = "配置 SegaTools 服务器";
59 | //
60 | // Set
61 | //
62 | this.Set.Cursor = System.Windows.Forms.Cursors.Arrow;
63 | this.Set.Font = new System.Drawing.Font("微软雅黑", 9F);
64 | this.Set.Location = new System.Drawing.Point(199, 211);
65 | this.Set.Name = "Set";
66 | this.Set.Size = new System.Drawing.Size(75, 23);
67 | this.Set.TabIndex = 2;
68 | this.Set.Text = "设置";
69 | this.Set.UseVisualStyleBackColor = true;
70 | this.Set.Click += new System.EventHandler(this.Start_Click);
71 | //
72 | // Cancel
73 | //
74 | this.Cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
75 | this.Cancel.Location = new System.Drawing.Point(314, 211);
76 | this.Cancel.Name = "Cancel";
77 | this.Cancel.Size = new System.Drawing.Size(75, 23);
78 | this.Cancel.TabIndex = 3;
79 | this.Cancel.Text = "取消";
80 | this.Cancel.UseVisualStyleBackColor = true;
81 | this.Cancel.Click += new System.EventHandler(this.Cancel_Click);
82 | //
83 | // label2
84 | //
85 | this.label2.AutoSize = true;
86 | this.label2.Location = new System.Drawing.Point(46, 155);
87 | this.label2.Name = "label2";
88 | this.label2.Size = new System.Drawing.Size(47, 12);
89 | this.label2.TabIndex = 7;
90 | this.label2.Text = "Server:";
91 | //
92 | // Server_textBox
93 | //
94 | this.Server_textBox.Location = new System.Drawing.Point(115, 152);
95 | this.Server_textBox.Name = "Server_textBox";
96 | this.Server_textBox.Size = new System.Drawing.Size(152, 21);
97 | this.Server_textBox.TabIndex = 1;
98 | this.Server_textBox.TextChanged += new System.EventHandler(this.Server_textBox_TextChanged);
99 | //
100 | // info_label
101 | //
102 | this.info_label.AutoSize = true;
103 | this.info_label.Location = new System.Drawing.Point(10, 183);
104 | this.info_label.Name = "info_label";
105 | this.info_label.Size = new System.Drawing.Size(0, 12);
106 | this.info_label.TabIndex = 8;
107 | this.info_label.TextChanged += new System.EventHandler(this.label_info_TextChanged);
108 | //
109 | // label1
110 | //
111 | this.label1.AutoSize = true;
112 | this.label1.Location = new System.Drawing.Point(46, 86);
113 | this.label1.Name = "label1";
114 | this.label1.Size = new System.Drawing.Size(35, 12);
115 | this.label1.TabIndex = 9;
116 | this.label1.Text = "IPv4:";
117 | this.label1.Click += new System.EventHandler(this.label1_Click);
118 | //
119 | // subnet_label
120 | //
121 | this.subnet_label.AutoSize = true;
122 | this.subnet_label.Location = new System.Drawing.Point(118, 122);
123 | this.subnet_label.Name = "subnet_label";
124 | this.subnet_label.Size = new System.Drawing.Size(0, 12);
125 | this.subnet_label.TabIndex = 8;
126 | //
127 | // subnetText_label
128 | //
129 | this.subnetText_label.AutoSize = true;
130 | this.subnetText_label.Location = new System.Drawing.Point(46, 122);
131 | this.subnetText_label.Name = "subnetText_label";
132 | this.subnetText_label.Size = new System.Drawing.Size(47, 12);
133 | this.subnetText_label.TabIndex = 9;
134 | this.subnetText_label.Text = "Subnet:";
135 | //
136 | // checkBox1
137 | //
138 | this.checkBox1.AutoSize = true;
139 | this.checkBox1.Checked = true;
140 | this.checkBox1.CheckState = System.Windows.Forms.CheckState.Checked;
141 | this.checkBox1.Location = new System.Drawing.Point(9, 213);
142 | this.checkBox1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
143 | this.checkBox1.Name = "checkBox1";
144 | this.checkBox1.Size = new System.Drawing.Size(156, 16);
145 | this.checkBox1.TabIndex = 10;
146 | this.checkBox1.Text = "更改已有 segatools.ini";
147 | this.checkBox1.UseVisualStyleBackColor = true;
148 | //
149 | // delay_label
150 | //
151 | this.delay_label.AutoSize = true;
152 | this.delay_label.Location = new System.Drawing.Point(287, 159);
153 | this.delay_label.Name = "delay_label";
154 | this.delay_label.Size = new System.Drawing.Size(71, 12);
155 | this.delay_label.TabIndex = 8;
156 | this.delay_label.Text = "Delay: -1ms";
157 | //
158 | // timer1
159 | //
160 | this.timer1.Enabled = true;
161 | this.timer1.Interval = 2000;
162 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
163 | //
164 | // ipTextBox
165 | //
166 | this.ipTextBox.Location = new System.Drawing.Point(115, 84);
167 | this.ipTextBox.Name = "ipTextBox";
168 | this.ipTextBox.Size = new System.Drawing.Size(123, 21);
169 | this.ipTextBox.TabIndex = 1;
170 | this.ipTextBox.Text = "0.0.0.0";
171 | this.ipTextBox.TextChanged += new System.EventHandler(this.ipTextBox_TextChanged);
172 | //
173 | // Startwin
174 | //
175 | this.AcceptButton = this.Set;
176 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
177 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
178 | this.CancelButton = this.Cancel;
179 | this.ClientSize = new System.Drawing.Size(401, 246);
180 | this.Controls.Add(this.checkBox1);
181 | this.Controls.Add(this.ipTextBox);
182 | this.Controls.Add(this.subnetText_label);
183 | this.Controls.Add(this.label1);
184 | this.Controls.Add(this.subnet_label);
185 | this.Controls.Add(this.delay_label);
186 | this.Controls.Add(this.info_label);
187 | this.Controls.Add(this.Server_textBox);
188 | this.Controls.Add(this.label2);
189 | this.Controls.Add(this.Cancel);
190 | this.Controls.Add(this.Set);
191 | this.Controls.Add(this.Title1);
192 | this.Cursor = System.Windows.Forms.Cursors.Arrow;
193 | this.Icon = global::FastSegatools_With_GUI.Properties.Resources.Icon;
194 | this.Name = "Startwin";
195 | this.Text = "Fast SegaTools";
196 | this.Load += new System.EventHandler(this.Startwin_Load);
197 | this.ResumeLayout(false);
198 | this.PerformLayout();
199 |
200 | }
201 |
202 | #endregion
203 |
204 | private System.Windows.Forms.Label Title1;
205 | private System.Windows.Forms.Button Set;
206 | private System.Windows.Forms.Button Cancel;
207 | private System.Windows.Forms.Label label2;
208 | private System.Windows.Forms.TextBox Server_textBox;
209 | private System.Windows.Forms.Label info_label;
210 | private System.Windows.Forms.Label label1;
211 | private System.Windows.Forms.Label subnet_label;
212 | private System.Windows.Forms.Label subnetText_label;
213 | private IPTextBox ipTextBox;
214 | private System.Windows.Forms.CheckBox checkBox1;
215 | private System.Windows.Forms.Timer timer1;
216 | public System.Windows.Forms.Label delay_label;
217 | }
218 | }
219 |
220 |
--------------------------------------------------------------------------------
/source/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------