-
Notifications
You must be signed in to change notification settings - Fork 0
/
Plugin.cs
222 lines (193 loc) · 7.33 KB
/
Plugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
using System;
using System.Windows.Forms;
using System.IO;
using System.Collections.Generic;
using System.Collections;
using System.Text.RegularExpressions;
using System.Text;
using GeniePlugin.Interfaces;
using System.Runtime.Serialization.Formatters.Binary;
using System.Data.SQLite;
using System.Data;
using GeniePlugin;
namespace StealingPlugin
{
public class Plugin : GeniePlugin.Interfaces.IPlugin
{
#region IPlugin Members
public IHost _host; //Required for plugin
public System.Windows.Forms.Form _parent; //Required for plugin
public string sSDBLocation { get; set; }
public enum VarList
{
StealingContainer,
StealingMark,
StealingPerceiveHealth,
StealingPerceive,
ROSSMAN_SLING,
ROSSMAN_HERB,
ROSSMAN_GENERAL,
ROSSMAN_FORGE,
ROSSMAN_CLOTHING,
HAVEN_HERB,
HAVEN_IRONWORKS,
HAVEN_NAPHTHA,
HAVEN_FLOWER,
HAVEN_ARMORY,
HAVEN_ARMS,
HAVEN_GENERAL,
HAVEN_CLOTH,
HAVEN_ARTIFICER,
HAVEN_JOY,
HAVEN_SMOKE,
HAVEN_WEAPON,
HAVEN_BARD,
HAVEN_CLERIC,
ARTHE_PATTERN,
ARTHE_FASHION,
ARTHE_ODDS,
ARTHE_BALLAD,
XING_SCRIPT,
XING_CARD,
XING_GENERAL,
XING_WEAPON,
XING_ARMOR,
XING_MUSIC,
XING_EMPATH,
XING_EMPATH2,
XING_EMPATH3,
XING_CLERIC,
XING_BATH,
XING_HABER,
XING_ARTIF,
XING_TANNER,
XING_JEWELRY,
XING_CLOTH,
XING_SHOE,
XING_HERB,
XING_ALCHEMY,
XING_FLOWER,
LETH_SKIN,
LETH_BOW,
LETH_ORIGAMI,
LETH_WEAPON,
LETH_WICKER,
LETH_BARD,
LETH_CLOTHES,
LETH_WOOD,
LETH_GENERAL,
LETH_PERFUME
};
private void ResetVars()
{
foreach (VarList item in Enum.GetValues(typeof(VarList)))
{
_host.set_Variable(item.ToString().Replace("_", "."), "");
}
}
void IPlugin.Initialize(IHost Host)
{
this.sSDBLocation = "NOT FOUND";
_host = Host;
if (File.Exists(this._host.get_Variable("PluginPath") + "StealingDB.sdb"))
{
this.sSDBLocation = this._host.get_Variable("PluginPath") + "StealingDB.sdb";
}
if (File.Exists(Application.StartupPath + @"\Plugins\StealingDB.sdb"))
{
this.sSDBLocation = Application.StartupPath + @"\Plugins\StealingDB.sdb";
}
}
string IPlugin.Name
{
get { return "Stealin with a Feelin"; }
//get { throw new NotImplementedException(); }
}
void IPlugin.ParentClosing()
{
//throw new NotImplementedException();
}
string IPlugin.ParseText(string text)
{
//throw new NotImplementedException();
return text;
}
string IPlugin.ParseInput(string Text)
{
try
{
if (Text == "/TestLocation")
{
this._host.EchoText("SDB Location is: " + sSDBLocation);
}
//throw new NotImplementedException();
if (Text == "/LoadStealing")
{
if(this.sSDBLocation == "NOT FOUND")
throw new Exception("ERROR: The Stealing.SDB is not in the proper Location." + Environment.NewLine + "The valid Locations are: " + this._host.get_Variable("PluginPath") + "StealingDB.sdb" + " or " + Application.StartupPath + @"\Plugins\StealingDB.sdb");
ResetVars();
string sStealSkill = this._host.get_Variable("Stealing.Ranks");
int iStealSkill = int.Parse(sStealSkill.Substring(0, sStealSkill.IndexOf(".")));
SQLiteConnection con = new SQLiteConnection("Data Source= " + this.sSDBLocation);
SQLiteCommand cmd = new SQLiteCommand(con);
cmd.CommandText = string.Format("Select * from ItemList where MinRank < {0} and {0} < Trivial order by Province, City, StoreName, MinRank", iStealSkill.ToString());
con.Open();
// Variable for the Stealing Item
string sVar = string.Empty;
string sVarValue = string.Empty;
SQLiteDataAdapter sda = new SQLiteDataAdapter(cmd);
DataSet ods = new DataSet();
sda.Fill(ods);
if (ods.Tables[0].Rows.Count > 0)
{
foreach (DataRow dr in ods.Tables[0].Rows)
{
sVar = dr["City"].ToString() + "." + dr["StoreName"].ToString();
sVarValue = dr["ItemName1"].ToString();
this._host.set_Variable(sVar, sVarValue);
this._host.EchoText(string.Format("Variable: {0} Set to: {1}", sVar, sVarValue));
}
}
else
this._host.EchoText("No Valid Stealing Items. Either Edit the SDB or Stop stealing so much.");
con.Close();
}
}
catch (Exception ex)
{
MessageBox.Show("Rico can't program for shit, Error: " + Environment.NewLine + ex.Message);
}
return Text;
}
void IPlugin.ParseXML(string XML)
{
//throw new NotImplementedException();
}
void IPlugin.Show()
{
//throw new NotImplementedException();
Steal_a_Feel sf = new Steal_a_Feel(ref this._host, this.sSDBLocation);
sf.tbContainer.Text = this._host.get_Variable("StealingContainer");
sf.cbMark.Checked = this._host.get_Variable("StealingMark") == String.Empty || this._host.get_Variable("StealingMark") == "No" ? false : true;
sf.cbPerceiveHealth.Checked = this._host.get_Variable("StealingPerceiveHealth") == String.Empty || this._host.get_Variable("StealingPerceiveHealth") == "No" ? false : true;
sf.cbPerceive.Checked = this._host.get_Variable("StealingPerceive") == String.Empty || this._host.get_Variable("StealingPerceive") == "No" ? false : true;
if (_parent != null)
sf.MdiParent = _parent;
sf.Show();
}
void IPlugin.VariableChanged(string Variable)
{
//throw new NotImplementedException();
}
string IPlugin.Version
{
get { return "First Version";}
}
public bool Enabled
{
get;
set;
}
#endregion
}
}