Skip to content

Commit

Permalink
[HaCreator] Quest check "Check.img" handling
Browse files Browse the repository at this point in the history
Misc:
- Reduced the keyup delay for list filters to 100ms when sorting maps/mobs/items/npcs

 TODO:
- Check.img/ subJobFlags
- Saving the Check.img changes from the models back to WzProperties
- Some other odd crashes sometimes when navigating between quests checks too quickly [QuestStateIdToQuestStateConverter.cs]
  • Loading branch information
lastbattle committed Oct 23, 2024
1 parent 78e9ddd commit 5e0174d
Show file tree
Hide file tree
Showing 27 changed files with 4,490 additions and 1,058 deletions.
29 changes: 29 additions & 0 deletions HaCreator/Converter/EnumNameIntValueConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace HaCreator.Converter
{
public class EnumNameIntValueConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is Enum enumValue)
{
string name = enumValue.ToString();
int intValue = System.Convert.ToInt32(enumValue);
return $"{name} ({intValue})";
}
return string.Empty;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
10 changes: 6 additions & 4 deletions HaCreator/Converter/QuestIdToQuestNameConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ public class QuestIdToQuestNameConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
const string NO_NAME = "NO NAME";

if (value == null)
return string.Empty;
return NO_NAME;

string questIdString;
if (value is long longValue)
Expand All @@ -28,17 +30,17 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
}
else
{
return string.Empty;
return NO_NAME;
}

if (!Program.InfoManager.QuestInfos.ContainsKey(questIdString))
{
return string.Empty;
return NO_NAME;
}

WzSubProperty questProp = Program.InfoManager.QuestInfos[questIdString];

string questName = (questProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string questName = (questProp["name"] as WzStringProperty)?.Value ?? NO_NAME;
return questName;
}

Expand Down
3 changes: 2 additions & 1 deletion HaCreator/CustomControls/ImageViewer.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 8 additions & 3 deletions HaCreator/CustomControls/ImageViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ public partial class ImageViewer : UserControl

public bool IsText;

/// <summary>
/// Constructor
/// </summary>
public ImageViewer()
{
m_IsThumbnail = false;
Expand Down Expand Up @@ -136,8 +139,10 @@ private float CalculateMP()
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
if (g == null) return;
if (m_Image == null) return;
if (g == null)
return;
if (m_Image == null)
return;

float mp = CalculateMP();

Expand All @@ -149,7 +154,7 @@ protected override void OnPaint(PaintEventArgs e)
g.DrawRectangle(new Pen(Color.Blue, 2), 1, 1, m_Image.Width * mp + 6, m_Image.Height * mp + 6);
}
if (IsText)
g.DrawString(Name, new System.Drawing.Font("Microsoft Sans Serif", 8.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))), Brushes.Black, 0, m_Image.Height * mp + 7);
g.DrawString(Name, new System.Drawing.Font("Segoe UI", 8.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, (byte)177), Brushes.Black, 0, m_Image.Height * mp + 7);
/*g.DrawRectangle(new Pen(Color.Gray), dl, dt, dw, dh);
if (m_IsThumbnail)
Expand Down
2 changes: 1 addition & 1 deletion HaCreator/GUI/EditorPanels/LifePanel.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions HaCreator/GUI/InstanceEditor/LoadItemSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public partial class LoadItemSelector : Form
private bool _isLoading = false;
private bool _bItemsLoaded = false;

private int _filterItemId = 0; // 0 = no filter, 243 = _itemId / 10000
private int _filterItemCategoryId = 0; // 0 = no filter, 243 = _itemId / 10000
private InventoryType _filterInventoryType = InventoryType.NONE; // 0 = no filter, 1 = equip only

// dictionary
private readonly List<string> itemNames = new List<string>(); // cache
Expand All @@ -65,8 +66,9 @@ public int SelectedItemId
/// <summary>
/// Constructor
/// </summary>
/// <param name="filterItemId"></param>
public LoadItemSelector(int filterItemId)
/// <param name="filterItemId">Filter by item category type</param>
/// <param name="filterInventoryType">Filter by inventory type</param>
public LoadItemSelector(int filterItemId, InventoryType filterInventoryType = InventoryType.NONE)
{
InitializeComponent();

Expand All @@ -75,7 +77,8 @@ public LoadItemSelector(int filterItemId)

this.FormClosing += LoadQuestSelector_FormClosing;

this._filterItemId = filterItemId;
this._filterItemCategoryId = filterItemId;
this._filterInventoryType = filterInventoryType;

// load items
load();
Expand All @@ -99,7 +102,9 @@ private void load()
string itemName = item.Value.Item2;
string itemDesc = item.Value.Item3;

if (_filterItemId != 0 && (itemId / 10000 != _filterItemId)) // filters for item category
if (_filterItemCategoryId != 0 && (itemId / 10000 != _filterItemCategoryId)) // filters for item category
continue;
if (_filterInventoryType != InventoryType.NONE && (InventoryTypeExtensions.GetByType((byte) (itemId / 1000000)) != _filterInventoryType)) // filters for item category
continue;

if (ItemIdsCategory.IsEquipment(itemId))
Expand Down
1 change: 1 addition & 0 deletions HaCreator/GUI/InstanceEditor/LoadMapSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public LoadMapSelector()
InitializeComponent();

this.FormClosing += LoadQuestSelector_FormClosing;
this.KeyDown += Load_KeyDown;

DialogResult = DialogResult.Cancel;

Expand Down
3 changes: 2 additions & 1 deletion HaCreator/GUI/InstanceEditor/LoadSearchHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private async Task SearchItemInternal(string searchText)

try
{
await Task.Delay(500, cancellationToken); // Delay for 500ms or until cancelled
// 100ms is the limit at which hoomans think its instant!
await Task.Delay(100, cancellationToken); // Delay until cancelled

List<string> itemsFiltered = _itemNames
.Where(item => item.ToLower().Contains(searchText))
Expand Down
Loading

1 comment on commit 5e0174d

@lastbattle
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image

Please sign in to comment.