Skip to content

Commit 64543d3

Browse files
committed
Transfer Commit
1 parent e3324de commit 64543d3

25 files changed

+1799
-0
lines changed

ProjectSWGScriptEditor.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectSWGScriptEditor", "ProjectSWGScriptEditor\ProjectSWGScriptEditor.csproj", "{BDF562E6-942A-4E0B-BD6F-6FABC0465DC2}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|x86 = Debug|x86
9+
Release|x86 = Release|x86
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{BDF562E6-942A-4E0B-BD6F-6FABC0465DC2}.Debug|x86.ActiveCfg = Debug|x86
13+
{BDF562E6-942A-4E0B-BD6F-6FABC0465DC2}.Debug|x86.Build.0 = Debug|x86
14+
{BDF562E6-942A-4E0B-BD6F-6FABC0465DC2}.Release|x86.ActiveCfg = Release|x86
15+
{BDF562E6-942A-4E0B-BD6F-6FABC0465DC2}.Release|x86.Build.0 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

ProjectSWGScriptEditor.suo

34 KB
Binary file not shown.
733 Bytes
Loading
715 Bytes
Loading

ProjectSWGScriptEditor/Config.cs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using System;
2+
using System.IO;
3+
using System.Collections.Generic;
4+
5+
namespace ProjectSWGScriptEditor
6+
{
7+
public class Config
8+
{
9+
static public String returnValue(string key)
10+
{
11+
var config = File.OpenText("./pswgse.cfg");
12+
while (config.BaseStream.CanSeek)
13+
{
14+
String[] entry = config.ReadLine().Split('=');
15+
if (entry[0].Equals(key))
16+
{
17+
config.Close();
18+
return entry[1].ToString();
19+
}
20+
}
21+
config.Close();
22+
return null;
23+
}
24+
25+
static public Boolean containsKey(string key)
26+
{
27+
var config = File.OpenText("./pswgse.cfg");
28+
while (config.BaseStream.CanSeek)
29+
{
30+
string line = config.ReadLine();
31+
if (line == null)
32+
{
33+
config.Close();
34+
return false;
35+
}
36+
37+
String[] entry = line.Split('=');
38+
39+
if (entry[0].Equals(key))
40+
{
41+
config.Close();
42+
return true;
43+
}
44+
}
45+
config.Close();
46+
return false;
47+
}
48+
49+
static public void setValue(string key, object value)
50+
{
51+
var config = File.OpenText("./pswgse.cfg");
52+
SortedList<string, string> entries = new SortedList<string, string>();
53+
54+
while (config.Peek() >= 0)
55+
{
56+
string temp = config.ReadLine();
57+
58+
if (temp != null)
59+
{
60+
string[] entry = temp.Split('=');
61+
entries.Add(entry[0], entry[1]);
62+
}
63+
}
64+
config.Close();
65+
66+
if (!entries.ContainsKey(key)) entries.Add(key, value.ToString());
67+
else entries[key] = value.ToString();
68+
69+
List<string> listToSave = new List<string>();
70+
for (int i = 0; i < entries.Count; i++) listToSave.Add(entries.Keys[i] + "=" + entries.Values[i]);
71+
72+
File.WriteAllLines("./pswgse.cfg", listToSave);
73+
}
74+
}
75+
}

ProjectSWGScriptEditor/Editors/BonusSetEditor.Designer.cs

Lines changed: 114 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Windows.Forms;
9+
using System.IO;
10+
11+
namespace ProjectSWGScriptEditor.Editors
12+
{
13+
public partial class BonusSetEditor : Form
14+
{
15+
public BonusSetEditor(string scriptPath)
16+
{
17+
InitializeComponent();
18+
scriptPathLbl.Text = scriptPath;
19+
loadScriptIntoForm();
20+
if (!this.IsDisposed) this.Show();
21+
}
22+
23+
private void loadScriptIntoForm()
24+
{
25+
scriptTreeView.Nodes.Clear();
26+
string[] file = File.ReadAllLines(scriptPathLbl.Text);
27+
28+
TreeNode bonusSetNameNode = scriptTreeView.Nodes.Add("Set Name: ");
29+
TreeNode requiredItemsNode = scriptTreeView.Nodes.Add("Required Items");
30+
TreeNode bonusesNode = scriptTreeView.Nodes.Add("Bonuses");
31+
try
32+
{
33+
for (int i = 0; i < file.Length; i++)
34+
{
35+
if (file[i].Contains("bonusSet = BonusSetTemplate"))
36+
{
37+
bonusSetNameNode.Text = "Set Name: " + file[i].Split('"')[1];
38+
}
39+
else if (file[i].Contains("bonusSet.addRequiredItem"))
40+
{
41+
requiredItemsNode.Nodes.Add(file[i].Split('"')[1]);
42+
}
43+
else if (file[i].Contains("if wornItems == "))
44+
{
45+
string requiredItemCount = file[i].Split('=')[2];
46+
TreeNode bonusNode = bonusesNode.Nodes.Add(requiredItemCount);
47+
48+
int temp = i + 1;
49+
while (!(file[temp].Contains("elif wornItems == ") || file[temp].Contains("else:")))
50+
{
51+
bonusNode.Nodes.Add(file[temp]);
52+
temp++;
53+
}
54+
}
55+
}
56+
}
57+
catch (Exception ex)
58+
{
59+
MessageBox.Show("The editor has encountered an error while trying to parse the selected script.");
60+
this.Close();
61+
}
62+
}
63+
64+
private void addRequiredItemBtn_Click(object sender, EventArgs e)
65+
{
66+
List<String> file = File.ReadAllLines(scriptPathLbl.Text).ToList<String>();
67+
foreach (string line in file)
68+
{
69+
if (line.Contains("bonusSet.addRequiredItem"))
70+
{
71+
file.Insert(file.IndexOf(line) + 1, "\tbonusSet.addRequiredItem(\"" + objectTemplateTb.Text + "\")");
72+
File.WriteAllLines(scriptPathLbl.Text, file);
73+
loadScriptIntoForm();
74+
return;
75+
}
76+
}
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)