Skip to content

Commit

Permalink
quest view fixes
Browse files Browse the repository at this point in the history
page numbering
focused background color
name display
  • Loading branch information
myangelkamikaze committed Jul 18, 2020
1 parent 027233f commit 71e4b82
Showing 1 changed file with 48 additions and 41 deletions.
89 changes: 48 additions & 41 deletions ElectronicObserver/Window/FormQuest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ void Updated()

QuestView.Rows.Clear();

foreach (var q in KCDatabase.Instance.Quest.Quests.Values)
foreach ((QuestData q, int questIndex) in KCDatabase.Instance.Quest.Quests.Values.Select((q, i) => (q, i)))
{

if (MenuMain_ShowRunningOnly.Checked && !(q.State == 2 || q.State == 3))
Expand All @@ -275,13 +275,15 @@ void Updated()
break;
case 5:
if (q.QuestID == 211 || q.QuestID == 212)
{ // 空母3か輸送5
{
// 空母3か輸送5
if (!MenuMain_ShowDaily.Checked) continue;
}
else
{
if (!MenuMain_ShowOther.Checked) continue;
}

break;
}

Expand All @@ -290,17 +292,40 @@ void Updated()
row.CreateCells(QuestView);
row.Height = 21;

row.Cells[QuestView_State.Index].Value = (q.State == 3) ? ((bool?)null) : (q.State == 2);
// Add support for tooltip-based page numbering
Color color = (questIndex / 5 % 2) switch
{
0 => Configuration.Config.UI.BackColor,
_ => Configuration.Config.UI.SubBackColor
};

row.Cells[QuestView_State.Index].Value = (q.State == 3) ? ((bool?) null) : (q.State == 2);
row.Cells[QuestView_State.Index].ToolTipText = $"Page #{questIndex / 5 + 1}";
row.Cells[QuestView_State.Index].Style.BackColor = color;
row.Cells[QuestView_State.Index].Style.SelectionBackColor = color;

row.Cells[QuestView_Type.Index].Value = q.LabelType >= 100 ? q.LabelType : q.Type;
row.Cells[QuestView_Type.Index].ToolTipText = Constants.GetQuestLabelType(q.LabelType);
row.Cells[QuestView_Type.Index].Style.BackColor = color;
row.Cells[QuestView_Type.Index].Style.SelectionBackColor = color;

row.Cells[QuestView_Category.Index].Value = q.Category;
row.Cells[QuestView_Category.Index].ToolTipText = Constants.GetQuestCategory(q.Category);
row.Cells[QuestView_Category.Index].Style = CSCategories[Math.Min(q.Category - 1, CSCategories.Length - 1)];
row.Cells[QuestView_Category.Index].Style =
CSCategories[Math.Min(q.Category - 1, CSCategories.Length - 1)];

row.Cells[QuestView_Name.Index].Value = q.QuestID;
row.Cells[QuestView_Name.Index].Style.BackColor = color;
row.Cells[QuestView_Name.Index].Style.SelectionBackColor = color;

row.Cells[QuestView_Progress.Index].Style.BackColor = color;
row.Cells[QuestView_Progress.Index].Style.SelectionBackColor = color;

{
var progress = KCDatabase.Instance.QuestProgress[q.QuestID];
var code = q.Code != "" ? $"{q.Code}: " : "";
row.Cells[QuestView_Name.Index].ToolTipText = $"{code}{q.Name} (ID: {q.QuestID})\r\n{q.Description}\r\n{progress?.GetClearCondition() ?? ""}";
row.Cells[QuestView_Name.Index].ToolTipText =
$"{code}{q.Name} (ID: {q.QuestID})\r\n{q.Description}\r\n{progress?.GetClearCondition() ?? ""}";
}
{
string value;
Expand Down Expand Up @@ -374,25 +399,6 @@ void Updated()
if (QuestView.SortedColumn != null)
QuestView.Sort(QuestView.SortedColumn, QuestView.SortOrder == SortOrder.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending);


// Add support for tooltip-based page numbering
int pageNumber = 1;
var useBackColor = false;
for (int i = 0; i < QuestView.Rows.Count; i++)
{
var color = useBackColor ? Configuration.Config.UI.SubBackColor : Configuration.Config.UI.BackColor;
QuestView.Rows[i].Cells[QuestView_State.Index].Style.BackColor = color;
QuestView.Rows[i].Cells[QuestView_State.Index].ToolTipText = $"Page #{pageNumber}";
QuestView.Rows[i].Cells[QuestView_Type.Index].Style.BackColor = color;
QuestView.Rows[i].Cells[QuestView_Name.Index].Style.BackColor = color;
QuestView.Rows[i].Cells[QuestView_Progress.Index].Style.BackColor = color;
if (i % 5 == 4)
{
useBackColor = !useBackColor;
pageNumber++;
}
}

// Retain scroll position
if (QuestView.Rows.Count > scrollPos)
QuestView.FirstDisplayedScrollingRowIndex = scrollPos;
Expand All @@ -403,28 +409,29 @@ void Updated()

private void QuestView_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
{
if (!(e.Value is int questId)) return;

if (e.Value is int)
if (e.ColumnIndex == QuestView_Type.Index)
{
if (e.ColumnIndex == QuestView_Type.Index)
{
e.Value = Constants.GetQuestType((int)e.Value);
e.FormattingApplied = true;
e.Value = Constants.GetQuestType(questId);
e.FormattingApplied = true;

}
else if (e.ColumnIndex == QuestView_Category.Index)
{
e.Value = Constants.GetQuestCategory((int)e.Value);
e.FormattingApplied = true;
}
else if (e.ColumnIndex == QuestView_Category.Index)
{
e.Value = Constants.GetQuestCategory(questId);
e.FormattingApplied = true;

}
else if (e.ColumnIndex == QuestView_Name.Index)
}
else if (e.ColumnIndex == QuestView_Name.Index)
{
var quest = KCDatabase.Instance.Quest[questId];
e.Value = quest switch
{
var quest = KCDatabase.Instance.Quest[(int)e.Value];
e.Value = quest != null ? quest.Name : "???";
e.FormattingApplied = true;

}
{} => $"{quest.Code}: {quest.Name}",
_ => "???"
};
e.FormattingApplied = true;

}

Expand Down

0 comments on commit 71e4b82

Please sign in to comment.