private void setupGuide()
{
foreach (Control c in addedControls) {
this.Controls.Remove(c);
c.Dispose();
}
addedControls.Clear();
if (quest != null) {
if (questInstruction == null) {
questTitle.Text = quest.title;
} else {
questTitle.Text = quest.title + " - " + missionName;
}
}
int sizeWidth = 392;
int y = this.questTitle.Location.Y + 40;
int suggestedWidth = SettingsManager.getSettingInt("GuideFormWidth");
if (suggestedWidth > minwidth && suggestedWidth < maxwidth) {
sizeWidth = suggestedWidth;
}
this.Size = new Size(sizeWidth, Size.Height);
this.largestButton.Visible = true;
this.largeButton.Visible = true;
this.normalButton.Visible = true;
this.largestButton.Location = new Point(this.Size.Width - largestButton.Width - 4, 4);
this.largeButton.Location = new Point(this.Size.Width - largestButton.Width * 2 - 4, 4);
this.normalButton.Location = new Point(this.Size.Width - largestButton.Width * 3 - 4, 4);
List<Coordinate> begin = new List<Coordinate>();
List<Coordinate> end = new List<Coordinate>();
List<string> description = new List<string>();
List<string> settings = new List<string>();
if (questInstruction != null) {
int ordering = questInstruction.ordering;
int currentIndex = instructionIndex - 1;
while (currentIndex < questInstructionList.Count && questInstructionList[currentIndex].ordering == ordering) {
begin.Add(questInstructionList[currentIndex].begin);
end.Add(questInstructionList[currentIndex].end);
description.Add(questInstructionList[currentIndex].description);
settings.Add(questInstructionList[currentIndex].settings);
currentIndex++;
}
} else {
int ordering = direction.ordering;
int currentIndex = instructionIndex - 1;
while (currentIndex < hunt.directions.Count && hunt.directions[currentIndex].ordering == ordering) {
begin.Add(hunt.directions[currentIndex].begin);
end.Add(hunt.directions[currentIndex].end);
description.Add(hunt.directions[currentIndex].description);
settings.Add(hunt.directions[currentIndex].settings);
currentIndex++;
}
}
bool noText = true;
if (description.Count > 1) {
for (int i = 1; i < description.Count; i++) {
string str = description[i];
if (str != "") {
noText = false;
continue;
}
}
if (noText && description[0] != "") {
Label label = new Label();
label.Text = description[0];
label.Location = new Point(5, y);
label.ForeColor = StyleManager.NotificationTextColor;
label.BackColor = Color.Transparent;
label.Font = requirementFont;
label.AutoSize = true;
label.MaximumSize = new Size(this.Size.Width - 10, 0);
int labelHeight = 0;
using (Graphics gr = Graphics.FromHwnd(label.Handle)) {
labelHeight = (int)(gr.MeasureString(label.Text, label.Font, this.Size.Width - 10).Height * 1.2);
}
addedControls.Add(label);
this.Controls.Add(label);
y += labelHeight;
}
} else {
noText = false;
}
int startX = 5;
int maxY = 0;
for (int i = 0; i < begin.Count; i++) {
int xOffset;
int newY = drawDirections(begin[i], end[i], settings[i], description[i], startX, y, begin.Count > 1, begin.Count, noText, out xOffset);
if (noText) {
startX += xOffset;
if (newY > maxY) {
maxY = newY;
}
if (startX + 120 > this.Size.Width) {
startX = 5;
y = maxY;
}
if (i == begin.Count - 1) {
y = maxY;
}
} else {
y = newY;
}
}
if (instructionIndex > minInstructions || (maxInstructions > instructionIndex && (quest == null || questInstruction != null))) {
y += 5;
if (maxInstructions > instructionIndex && (quest == null || questInstruction != null)) {
nextButton.Location = new Point(this.Size.Width - 105, y);
nextButton.Visible = true;
} else {
nextButton.Visible = false;
}
if (instructionIndex > minInstructions) {
prevButton.Location = new Point(5, y);
prevButton.Visible = true;
} else {
prevButton.Visible = false;
}
y += 20;
}
this.Size = new Size(sizeWidth, y + 10);
refreshTimer();
}