Skip to content

Commit c5c7959

Browse files
committed
GeneralInfo tab successfully loads an event.
1 parent 6cb1a51 commit c5c7959

File tree

5 files changed

+60
-5
lines changed

5 files changed

+60
-5
lines changed

Event.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class Event
1414
{
1515
{Keys.EVENT_ID_KEY, null},
1616
{Keys.EVENT_TYPE_KEY, "MoveTo"},
17+
{Keys.EVENT_FREQUENCY_KEY, "Uncommon"},
1718
{Keys.POSSIBLE_LOCATIONS_KEY, new List<string>()},
1819
{Keys.REQ_PARTY_KEY, new List<string>()},
1920
{Keys.INTRO_TEXT_KEY, "Demo Intro Text!"},
@@ -28,11 +29,12 @@ public Event(string id)
2829
{
2930
myDictionary[Keys.EVENT_ID_KEY] = id;
3031
}
31-
public Event(string id, string type, List<string> possibleLocs, List<string> reqParty, string introText, List<ResponseOption> respOpts,
32+
public Event(string id, string type, List<string> possibleLocs, List<string> reqParty, string frequency, string introText, List<ResponseOption> respOpts,
3233
Dictionary<string, string> advice, bool targetPartyMember)
3334
{
3435
myDictionary[Keys.EVENT_ID_KEY] = id;
3536
myDictionary[Keys.EVENT_TYPE_KEY] = type;
37+
myDictionary[Keys.EVENT_FREQUENCY_KEY] = frequency;
3638
myDictionary[Keys.POSSIBLE_LOCATIONS_KEY] = possibleLocs;
3739
myDictionary[Keys.REQ_PARTY_KEY] = reqParty;
3840
myDictionary[Keys.INTRO_TEXT_KEY] = introText;
@@ -42,11 +44,12 @@ public Event(string id, string type, List<string> possibleLocs, List<string> req
4244
myDictionary[Keys.FLEE_FAIL_TEXT_KEY] = "You failed to flee!";
4345
myDictionary[Keys.PARTY_MEMBER_TARGETED_KEY] = targetPartyMember;
4446
}
45-
public Event(string id, string type, List<string> possibleLocs, List<string> reqParty, string introText, List<Dictionary<string, object>> respOpts,
47+
public Event(string id, string type, List<string> possibleLocs, List<string> reqParty, string frequency, string introText, List<Dictionary<string, object>> respOpts,
4648
Dictionary<string, string> advice, bool targetPartyMember)
4749
{
4850
myDictionary[Keys.EVENT_ID_KEY] = id;
4951
myDictionary[Keys.EVENT_TYPE_KEY] = type;
52+
myDictionary[Keys.EVENT_FREQUENCY_KEY] = frequency;
5053
myDictionary[Keys.POSSIBLE_LOCATIONS_KEY] = possibleLocs;
5154
myDictionary[Keys.REQ_PARTY_KEY] = reqParty;
5255
myDictionary[Keys.INTRO_TEXT_KEY] = introText;

EventSaver.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,13 @@ private static Dictionary<string, object> MakeDictionary(frmMain frmMain)
5353
string type = frmMain.getEventType();
5454
List<string> possibleLocations = frmMain.getPossibleLocations();
5555
List<string> reqParty = frmMain.getRequiredParty();
56+
string frequency = frmMain.getFrequency();
5657
string introText = frmMain.getIntroText();
5758
List<ResponseOption> responseOptions = frmMain.getResponseOptions();
5859
Dictionary<string, string> advice = frmMain.generateAdviceDictionary();
5960
bool selectPlayer = frmMain.getSelectPlayer();
6061

61-
Event theEvent = new Event(eventId, type, possibleLocations, reqParty, introText, responseOptions, advice, false);
62+
Event theEvent = new Event(eventId, type, possibleLocations, reqParty, frequency, introText, responseOptions, advice, selectPlayer);
6263

6364
return theEvent.myDictionary;
6465
}

Form1.cs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ internal string getEventType()
5050
return (string)eventTypeInput.Items[eventTypeInput.SelectedIndex];
5151
}
5252

53+
internal string getFrequency()
54+
{
55+
return (string)frequencyInput.Items[frequencyInput.SelectedIndex];
56+
}
57+
5358
internal List<string> getPossibleLocations()
5459
{
5560
List<String> possibleLocations = new List<String>();
@@ -104,9 +109,24 @@ private void btnLoadEvent_Click(object sender, EventArgs e)
104109
/// <param name="theEvent">Event to load in</param>
105110
private void GeneralInfoLoadEvent(Event theEvent)
106111
{
107-
//TODO - Load event information for this tab.
112+
eventNameInput.Text = (string)theEvent.myDictionary[Keys.EVENT_ID_KEY];
113+
SelectStrInComboBox(eventTypeInput, (string)theEvent.myDictionary[Keys.EVENT_TYPE_KEY]);
114+
SelectStrInComboBox(frequencyInput, (string)theEvent.myDictionary[Keys.EVENT_FREQUENCY_KEY]);
115+
List<string> locations = GetStringListFromJSON(theEvent.myDictionary[Keys.POSSIBLE_LOCATIONS_KEY]);
116+
for (int i = 0; i < locationsInput.Items.Count; i++)
117+
{
118+
locationsInput.SetItemChecked(i, locations.Contains(locationsInput.Items[i]));
119+
}
120+
List<string> partyNeeded = GetStringListFromJSON(theEvent.myDictionary[Keys.REQ_PARTY_KEY]);
121+
for (int i = 0; i < reqPaMemInput.Items.Count; i++)
122+
{
123+
reqPaMemInput.SetItemChecked(i, partyNeeded.Contains(reqPaMemInput.Items[i]));
124+
}
125+
introDescInput.Text = (string)theEvent.myDictionary[Keys.INTRO_TEXT_KEY];
126+
selectplayerB.Checked = (bool)theEvent.myDictionary[Keys.PARTY_MEMBER_TARGETED_KEY];
108127
}
109128

129+
110130
/* ------------------------------------------------ */
111131
// Advice Stuff //
112132
/* ------------------------------------------------ */
@@ -992,6 +1012,36 @@ private void frmMain_Load(object sender, EventArgs e)
9921012
responseOptions.Add(0, new ResponseOption(textResponse1.Text));
9931013
}
9941014

1015+
public List<int> GetIntListFromJSON(object toList)
1016+
{
1017+
Newtonsoft.Json.Linq.JArray locationsArray = (Newtonsoft.Json.Linq.JArray)(toList);
1018+
return locationsArray.ToObject<List<int>>();
1019+
}
1020+
public List<string> GetStringListFromJSON(object toList)
1021+
{
1022+
Newtonsoft.Json.Linq.JArray locationsArray = (Newtonsoft.Json.Linq.JArray)(toList);
1023+
return locationsArray.ToObject<List<string>>();
1024+
}
1025+
1026+
/// <summary>
1027+
/// Selects the item in the combo box (if there is one) that matches the given string.
1028+
/// Selects -1 if no match.
1029+
/// </summary>
1030+
/// <param name="box">ComboBox to look through</param>
1031+
/// <param name="toSelect">String to find</param>
1032+
public void SelectStrInComboBox(ComboBox box, string toSelect)
1033+
{
1034+
for (int i = 0; i < box.Items.Count; i++)
1035+
{
1036+
if ((string)(box.Items[i]) == toSelect)
1037+
{
1038+
box.SelectedIndex = i;
1039+
return;
1040+
}
1041+
}
1042+
box.SelectedIndex = -1;
1043+
}
1044+
9951045
private void tabGeneralInfo_Click(object sender, EventArgs e)
9961046
{
9971047

Keys.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public static class Keys
2323
public const string FLEE_FAIL_TEXT_KEY = "fleeFailText";
2424

2525
public const string PARTY_MEMBER_TARGETED_KEY = "partyMemberTargeted";
26+
public const string EVENT_FREQUENCY_KEY = "frequency";
2627

2728

2829
//* ----------------------------------- */

TestEvent.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static Event GetEvent() {
3737
advice.Add("Gunther Reinhar", "NI'm hungry.");
3838

3939

40-
Event toRet = new Event(eventId, type, possibleLocations, reqParty, introText, GetResponseOptionSet(), advice, false);
40+
Event toRet = new Event(eventId, type, possibleLocations, reqParty, "Uncommon", introText, GetResponseOptionSet(), advice, false);
4141

4242
return toRet;
4343
}

0 commit comments

Comments
 (0)