private void DrawActorLabelFancy(GameData.ActorItem actor, Vector2 canvasPt, Graphics graphics, float markerRadius, Font useFont) { const float markerOffset = 5; SizeF drawTextSize = graphics.MeasureString(actor.OverlaySettings.Description, useFont); float textPosX = canvasPt.X + (markerOffset * 2); float anchorX0 = canvasPt.X + markerRadius - 1; float anchorX1 = textPosX - 2; float anchorX2 = textPosX + drawTextSize.Width + 2; if (anchorX2 > Width) { textPosX = canvasPt.X - drawTextSize.Width - (markerOffset * 2); anchorX2 = textPosX - 2; anchorX1 = textPosX + drawTextSize.Width + 2; anchorX0 = canvasPt.X - markerRadius + 1; } float textPosY = canvasPt.Y - markerOffset - drawTextSize.Height; float anchorY = textPosY + drawTextSize.Height; float anchorY0 = canvasPt.Y - markerRadius + 1; if (textPosY < 0) { textPosY = canvasPt.Y + markerOffset; anchorY = textPosY; anchorY0 = canvasPt.Y + markerRadius - 1; } graphics.FillRectangle(labelBackgroundBrush, textPosX - 2, textPosY, drawTextSize.Width + 4, drawTextSize.Height); graphics.DrawString(actor.OverlaySettings.Description, useFont, labelForegroundBrush, textPosX, textPosY); graphics.DrawLine(actor.OverlaySettings.DrawPen, anchorX0, anchorY0, anchorX1, anchorY); graphics.DrawLine(actor.OverlaySettings.DrawPen, anchorX1, anchorY, anchorX2, anchorY); }
private void listViewActors_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && listViewActors.SelectedItems.Count == 1) { GameData.ActorItem tagActor = (GameData.ActorItem)listViewActors.SelectedItems[0].Tag; DoDragDrop(tagActor, DragDropEffects.Move); } }
private void DrawActorLabelSimple(GameData.ActorItem actor, Vector2 canvasPt, Graphics graphics, float markerRadius, Font useFont) { SizeF drawTextSize = graphics.MeasureString(actor.OverlaySettings.Description, useFont); float textPosX = canvasPt.X - (drawTextSize.Width * 0.5f); float textPosY = canvasPt.Y + markerRadius + 2; graphics.FillRectangle(labelBackgroundBrush, textPosX - 2, textPosY, drawTextSize.Width + 4, drawTextSize.Height); graphics.DrawString(actor.OverlaySettings.Description, useFont, labelForegroundBrush, textPosX, textPosY); }
private void UpdateShownDistance() { for (int Idx = 0; Idx < listViewActors.Items.Count; Idx++) { GameData.ActorItem tagActor = (GameData.ActorItem)listViewActors.Items[Idx].Tag; if (tagActor != null) { listViewActors.Items[Idx].SubItems[3].Text = tagActor.ShowDistance; } } if (actorListSorter.SortColumn == columnHeaderDistance.Index) { listViewActors.Sort(); } }
private void listViewPresetEdit_DragDrop(object sender, DragEventArgs e) { GameData.ActorItem actor = (GameData.ActorItem)e.Data.GetData(typeof(GameData.ActorItem)); Logger.WriteLine("Filter edit, drop: " + actor); ActorFilter filterOb = new ActorFilter(); filterOb.Description = actor.ShowName; filterOb.Pen = Pens.Gray; filterOb.Mode = GameData.OverlaySettings.DisplayMode.WhenClose; filterOb.MatchType = actor.Type; filterOb.MatchNpcId = actor.NpcId; filterOb.UseMatchType = true; filterOb.UseMatchNpcId = (actor.Type != MemoryLayout.ActorType.Player); CreateFilterItem(filterOb); }
private bool CanShowActor(GameData.ActorItem actor, Vector3 projectedPt) { bool canShow = false; if (projectedPt.Z > 0) { if (actor.OverlaySettings.Mode == GameData.OverlaySettings.DisplayMode.Always || actor.OverlaySettings.IsHighlighted) { canShow = true; } else if (actor.OverlaySettings.Mode == GameData.OverlaySettings.DisplayMode.WhenClose) { canShow = (actor.Distance < maxDistanceFromCamera); } else if (actor.OverlaySettings.Mode == GameData.OverlaySettings.DisplayMode.WhenLookingAt || actor.OverlaySettings.Mode == GameData.OverlaySettings.DisplayMode.WhenCloseAndLookingAt) { float distFromCenterSq = ((projectedPt.X / projectedPt.Z) * (projectedPt.X / projectedPt.Z)) + ((projectedPt.Y / projectedPt.Z) * (projectedPt.Y / projectedPt.Z)); if (distFromCenterSq < maxProjectedDistFromCenterSq) { if (actor.OverlaySettings.Mode == GameData.OverlaySettings.DisplayMode.WhenLookingAt) { canShow = true; } else { canShow = (actor.Distance < maxDistanceFromCamera); } } } if (actor.IsHidden && !actor.OverlaySettings.IsHighlighted) { canShow = false; } } else { if (actor.OverlaySettings.IsHighlighted) { canShow = true; projectedPt.Z = -projectedPt.Z; } } return(canShow); }
public void Apply(GameData.ActorItem actor) { bool hasMatch = false; foreach (ActorFilter filter in Filters) { if (filter.Apply(actor)) { hasMatch = true; break; } } if (!hasMatch) { actor.OverlaySettings.Description = actor.ShowName; actor.OverlaySettings.Mode = ShowOnlyMatching ? GameData.OverlaySettings.DisplayMode.Never : GameData.OverlaySettings.DisplayMode.WhenClose; actor.OverlaySettings.DrawPen = Pens.Gray; actor.OverlaySettings.IsMatchingFilters = false; } }
private void listViewActors_SelectedIndexChanged(object sender, EventArgs e) { if (selectedActor != null) { selectedActor.OverlaySettings.IsHighlighted = false; selectedActor = null; } if (listViewActors.SelectedItems.Count == 1) { selectedActor = (GameData.ActorItem)listViewActors.SelectedItems[0].Tag; selectedActor.OverlaySettings.IsHighlighted = true; labelSelectedName.Text = selectedActor.Name; labelSelectedPos.Text = selectedActor.ShowPos + ", dist: " + selectedActor.ShowDistance; labelSelectedNpcID.Text = "0x" + selectedActor.NpcId.ToString("X"); labelSelectedIDActorA.Text = "0x" + selectedActor.ActorIdA.ToString("X"); labelSelectedIDActorB.Text = "0x" + selectedActor.ActorIdB.ToString("X"); labelSelectedFlags.Text = "0x" + selectedActor.Flags.ToString("X2"); labelSelectedType.Text = selectedActor.Type.ToString(); labelSelectedSubType.Text = selectedActor.SubType.ToString(); labelSelectedFlagsHidden.Text = selectedActor.IsHidden ? "(hidden)" : ""; } else { labelSelectedName.Text = ""; labelSelectedPos.Text = ""; labelSelectedNpcID.Text = ""; labelSelectedIDActorA.Text = ""; labelSelectedIDActorB.Text = ""; labelSelectedFlags.Text = ""; labelSelectedType.Text = ""; labelSelectedSubType.Text = ""; labelSelectedFlagsHidden.Text = ""; } }
public bool Apply(GameData.ActorItem actor) { bool hasMatch = true; if (UseMatchType && actor.Type != MatchType) { hasMatch = false; } if (UseMatchNpcId && actor.NpcId != MatchNpcId) { hasMatch = false; } if (hasMatch) { actor.OverlaySettings.Mode = Mode; actor.OverlaySettings.DrawPen = Pen; actor.OverlaySettings.Description = HasDescriptionOverride ? Description : actor.ShowName; actor.OverlaySettings.IsMatchingFilters = true; } return(hasMatch); }
private void RefreshActorList() { listViewActors.SuspendLayout(); listViewActors.BeginUpdate(); // remove missing for (int Idx = listViewActors.Items.Count - 1; Idx >= 0; Idx--) { GameData.ActorItem tagActor = (GameData.ActorItem)listViewActors.Items[Idx].Tag; bool shouldRemove = !gameData.listActors.Contains(tagActor); if (checkFilterNearby.Checked && !tagActor.OverlaySettings.IsMatchingFilters) { shouldRemove = true; } if (shouldRemove) { listViewActors.Items.RemoveAt(Idx); } else { listViewActors.Items[Idx].BackColor = tagActor.IsHidden ? Color.LightGray : SystemColors.Window; } } // add new if (listViewActors.Items.Count < gameData.listActors.Count) { List <GameData.ActorItem> knownActors = new List <GameData.ActorItem>(); for (int Idx = 0; Idx < listViewActors.Items.Count; Idx++) { GameData.ActorItem tagActor = (GameData.ActorItem)listViewActors.Items[Idx].Tag; knownActors.Add(tagActor); } foreach (GameData.ActorItem actor in gameData.listActors) { if (!knownActors.Contains(actor)) { if (activePreset != null) { activePreset.Apply(actor); } else { actor.OverlaySettings.SetDefault(actor.ShowName); } bool canAdd = !checkFilterNearby.Checked || actor.OverlaySettings.IsMatchingFilters; if (canAdd) { ListViewItem lvi = new ListViewItem(actor.ShowName); lvi.Tag = actor; lvi.SubItems.Add(actor.ShowType); lvi.SubItems.Add(actor.ShowId); lvi.SubItems.Add(actor.ShowDistance); lvi.BackColor = actor.IsHidden ? Color.LightGray : SystemColors.Window; listViewActors.Items.Add(lvi); } } } } listViewActors.ResumeLayout(); listViewActors.Sort(); listViewActors.EndUpdate(); }