Skip to content

Commit

Permalink
Merge pull request #272 from lastbattle/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
lastbattle authored Dec 7, 2024
2 parents 6feff4f + 53335a9 commit ab16678
Show file tree
Hide file tree
Showing 59 changed files with 1,677 additions and 621 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ publish/
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
# *.pubxml
*.publishproj

# Microsoft Azure Web App publish settings. Comment the next line if you want to
Expand Down
7 changes: 5 additions & 2 deletions HaCreator/CustomControls/MapBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
using MapleLib.WzLib.WzStructure;
using System.Data.SQLite;
using HaCreator.GUI.InstanceEditor;
using System.Diagnostics;

namespace HaCreator.CustomControls
{
Expand Down Expand Up @@ -145,6 +146,7 @@ public void InitializeMapsListboxItem(bool special)
if (special)
{
maps.Insert(0, "CashShopPreview");
maps.Insert(1, "ITCPreview");

foreach (string mapLogin in mapLogins)
maps.Insert(0, mapLogin.Replace(".img", ""));
Expand Down Expand Up @@ -186,9 +188,9 @@ public void InitialiseHistoryListboxItem() {
int i = 0;
while (reader.Read()) {
string OpenedMapName = (string)reader["OpenedMapName"];
Console.WriteLine("Entry [" + i + "] Name: '" + OpenedMapName + "'");
Debug.WriteLine("Entry [" + i + "] Name: '" + OpenedMapName + "'");

string mapid_str = OpenedMapName.Substring(0, 9);
string mapid_str = OpenedMapName.Substring(0, Math.Min(OpenedMapName.Length, 9));

if (Program.InfoManager.MapsCache.ContainsKey(mapid_str)) {
Tuple<WzImage, string, string, string, MapInfo> loadedMap = Program.InfoManager.MapsCache[mapid_str];
Expand Down Expand Up @@ -258,6 +260,7 @@ private void mapNamesBox_SelectedIndexChanged(object sender, EventArgs e)
selectedName == "MapLogin4" ||
selectedName == "MapLogin5" ||
selectedName == "CashShopPreview" ||
selectedName == "ITCPreview" ||
selectedName == null)
{
panel_linkWarning.Visible = false;
Expand Down
14 changes: 14 additions & 0 deletions HaCreator/GUI/EditorPanels/TilePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ private void tileBrowse_Click(object sender, EventArgs e)
}
}

/// <summary>
/// Sets the currently selected tileSet, and refresh the list of tiles
/// </summary>
/// <param name="tileSet"></param>
public void SetSelectedTileSet(string tileSet)
{
if (!Program.InfoManager.TileSets.ContainsKey(tileSet))
return;
tileSetList.SelectedItem = tileSet;

LoadTileSetList();
}

private void tileSetList_SelectedIndexChanged(object sender, EventArgs e)
{
LoadTileSetList();
Expand All @@ -81,6 +94,7 @@ public void LoadTileSetList()
return;
WzImage tileSetImage = Program.InfoManager.TileSets[selectedSetName];
int? mag = InfoTool.GetOptionalInt(tileSetImage["info"]["mag"]);

foreach (WzSubProperty tCat in tileSetImage.WzProperties)
{
if (tCat.Name == "info")
Expand Down
24 changes: 16 additions & 8 deletions HaCreator/GUI/HaRibbon.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -409,20 +409,24 @@ private void UpdateLocalLayerInfo()
actualPlatform = platformBox.SelectedItem == null ? 0 : (int)platformBox.SelectedItem;
}

private void UpdateRemoteLayerInfo()
/// <summary>
///
/// </summary>
/// <param name="tileSet">The tileSet name</param>
private void UpdateRemoteLayerInfo(string tileSet)
{
if (LayerViewChanged != null)
LayerViewChanged.Invoke(actualLayerIndex, actualPlatform, layerCheckbox.IsChecked.Value, (layerCheckbox.IsChecked.Value || platformCheckbox.IsChecked.Value));
LayerViewChanged.Invoke(actualLayerIndex, actualPlatform, layerCheckbox.IsChecked.Value, (layerCheckbox.IsChecked.Value || platformCheckbox.IsChecked.Value), tileSet);
}

private void AllLayerView_Executed(object sender, ExecutedRoutedEventArgs e)
{
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}

private void AllPlatformView_Executed(object sender, ExecutedRoutedEventArgs e)
{
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}

private void LoadPlatformsForLayer(SortedSet<int> zms)
Expand All @@ -443,9 +447,13 @@ private void layerBox_SelectionChanged(object sender, SelectionChangedEventArgs
{
if (!isInternal)
{
LoadPlatformsForLayer(layers[layerBox.SelectedIndex].zMList);
Layer layer = layers[layerBox.SelectedIndex];
var zmList = layer.zMList;
string tileSet = layer.tS;

LoadPlatformsForLayer(zmList);
UpdateLocalLayerInfo();
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(tileSet);
}
}

Expand All @@ -454,7 +462,7 @@ private void platformBox_SelectionChanged(object sender, SelectionChangedEventAr
if (!isInternal)
{
UpdateLocalLayerInfo();
UpdateRemoteLayerInfo();
UpdateRemoteLayerInfo(null);
}
}

Expand Down Expand Up @@ -511,7 +519,7 @@ public void SetLayer(Layer layer)
public delegate void EmptyEvent();
public delegate void ViewToggleEvent(bool? tiles, bool? objs, bool? npcs, bool? mobs, bool? reactors, bool? portals, bool? footholds, bool? ropes, bool? chairs, bool? tooltips, bool? backgrounds, bool? misc, bool? mirrorField);
public delegate void ToggleEvent(bool pressed);
public delegate void LayerViewChangedEvent(int layer, int platform, bool allLayers, bool allPlats);
public delegate void LayerViewChangedEvent(int layer, int platform, bool allLayers, bool allPlats, string tileSet);

public event EmptyEvent NewClicked;
public event EmptyEvent OpenClicked;
Expand Down
5 changes: 4 additions & 1 deletion HaCreator/GUI/InfoEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public InfoEditor(Board board, MapInfo info, MultiBoard multiBoard, System.Windo
case MapType.MapLogin:
IDLabel.Text = "MapLogin";
break;
case MapType.ITCPreview:
IDLabel.Text = "ITCPreview";
break;
case MapType.RegularMap:
if (info.id == -1) IDLabel.Text = "";
else IDLabel.Text = info.id.ToString();
Expand Down Expand Up @@ -424,7 +427,7 @@ protected override void okButton_Click(object sender, EventArgs e)
{
lock (multiBoard)
{
if (info.mapType != MapType.CashShopPreview)
if (info.mapType != MapType.CashShopPreview && info.mapType != MapType.ITCPreview)
{
info.bgm = (string)bgmBox.SelectedItem;
info.mapMark = (string)markBox.SelectedItem;
Expand Down
110 changes: 69 additions & 41 deletions HaCreator/GUI/Initialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ private void button2_Click(object sender, EventArgs e)
/// <param name="e"></param>
private void debugButton_Click(object sender, EventArgs e)
{
const string OUTPUT_ERROR_FILENAME = "Debug_errors.txt";
const string OUTPUT_ERROR_FILENAME = "Errors_MapDebug.txt";

// This function iterates over all maps in the game and verifies that we recognize all their props
// It is meant to use by the developer(s) to speed up the process of adjusting this program for different MapleStory versions
Expand Down Expand Up @@ -769,16 +769,19 @@ public void ExtractItemFile()
{
string itemId = itemImg.Name;
WzSubProperty itemProp = itemImg as WzSubProperty;
WzCanvasProperty icon = itemProp["info"]?["icon"] as WzCanvasProperty;
if (icon != null)
if (itemProp != null)
{
int intName = 0;
int.TryParse(itemId, out intName);

lock (Program.InfoManager.ItemIconCache)
WzCanvasProperty icon = itemProp?["info"]?["icon"] as WzCanvasProperty;
if (icon != null)
{
if (!Program.InfoManager.ItemIconCache.ContainsKey(intName))
Program.InfoManager.ItemIconCache.Add(intName, icon);
int intName = 0;
int.TryParse(itemId, out intName);

lock (Program.InfoManager.ItemIconCache)
{
if (!Program.InfoManager.ItemIconCache.ContainsKey(intName))
Program.InfoManager.ItemIconCache.Add(intName, icon);
}
}
}
}
Expand Down Expand Up @@ -1086,7 +1089,7 @@ public void ExtractStringFile(bool bIsBetaMapleStory)
{
// In non-beta, process each item within the category
eqpCategorySubProp.WzProperties
.Cast<WzSubProperty>()
//.Cast<WzSubProperty>()
.ToList()
.ForEach(itemProp => ExtractStringFile_ProcessEquipmentItem(
itemProp,
Expand All @@ -1101,22 +1104,30 @@ public void ExtractStringFile(bool bIsBetaMapleStory)
else
stringInsImg = ((WzImage)Program.WzManager.FindWzImageByName("string", "Ins.img")).WzProperties;

foreach (WzSubProperty insItemImg in stringInsImg) // String.wz/Ins.img/3010000
foreach (WzImageProperty insItemImage in stringInsImg) // String.wz/Ins.img/3010000
{
string itemId = insItemImg.Name;
const string itemCategory = "Ins";
string itemName = (insItemImg["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (insItemImg["desc"] as WzStringProperty)?.Value ?? "NO DESC";
if (insItemImage is WzSubProperty insItemSubProp)
{
string itemId = insItemSubProp.Name;
const string itemCategory = "Ins";
string itemName = (insItemSubProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (insItemSubProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

int intName = 0;
int.TryParse(itemId, out intName);
int intName = 0;
int.TryParse(itemId, out intName);

if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(itemCategory, itemName, itemDesc);
else
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(itemCategory, itemName, itemDesc);
else
{
string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemSubProp.Name);
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
} else
{
string error = string.Format("[Initialization] Duplicate [Ins] item name in String.wz. ItemId='{0}', Category={1}", itemId, insItemImg.Name);
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
// TOOD: Handle MapleStoryN related items
// WzUOLProperty? or is it a mistake
// Ins/3019381 Ins/3700770 Ins/3700771
}
}

Expand Down Expand Up @@ -1242,23 +1253,30 @@ private void ExtractStringFile_ProcessEtcItem(WzSubProperty itemProp, string par
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
}
private void ExtractStringFile_ProcessEquipmentItem(WzSubProperty itemProp, string category)
private void ExtractStringFile_ProcessEquipmentItem(WzImageProperty itemImageProp, string category)
{
string itemId = itemProp.Name;
string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

if (int.TryParse(itemId, out int intName))
if (itemImageProp is WzSubProperty itemProp)
{
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
{
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(category, itemName, itemDesc);
}
else
string itemId = itemProp.Name;
string itemName = (itemProp["name"] as WzStringProperty)?.Value ?? "NO NAME";
string itemDesc = (itemProp["desc"] as WzStringProperty)?.Value ?? "NO DESC";

if (int.TryParse(itemId, out int intName))
{
string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}";
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
if (!Program.InfoManager.ItemNameCache.ContainsKey(intName))
{
Program.InfoManager.ItemNameCache[intName] = new Tuple<string, string, string>(category, itemName, itemDesc);
}
else
{
string error = $"[Initialization] Duplicate [Equip] item name in String.wz. ItemId='{itemId}', Category={category}";
ErrorLogger.Log(ErrorLevel.IncorrectStructure, error);
}
}
} else
{
// TODO: Handle MapleStoryN related equipments
// WzUOLProperty? or is it a mistake
}
}

Expand Down Expand Up @@ -1297,13 +1315,23 @@ public void ExtractMaps() {
streetName = mapNames.Item2;
categoryName = mapNames.Item3;
}
MapInfo info = new MapInfo(mapImage, mapName, streetName, categoryName);
if (mapImage["info"] != null)
{
MapInfo info = new MapInfo(mapImage, mapName, streetName, categoryName);

// Ensure thread safety when writing to the shared resource
lock (Program.InfoManager.MapsCache) {
Program.InfoManager.MapsCache[val.Key] = new Tuple<WzImage, string, string, string, MapInfo>(
mapImage, mapName, streetName, categoryName, info
);
// Ensure thread safety when writing to the shared resource
lock (Program.InfoManager.MapsCache)
{
Program.InfoManager.MapsCache[val.Key] = new Tuple<WzImage, string, string, string, MapInfo>(
mapImage, mapName, streetName, categoryName, info
);
}
} else
{
// Japan Maplestory
// MapID 100020100, 100020101, 120000100, 120000200, 120000201, 120000202, 120000300, 120000301, 120000101
// is missing of "info"
// it is an empty "map".img, likely pre-bb deleted
}
}
//}
Expand Down
30 changes: 24 additions & 6 deletions HaCreator/GUI/Load.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,29 +233,46 @@ private void OnLoadMap(bool bFromHistory) {
if (selectedItem.StartsWith("MapLogin")) // MapLogin, MapLogin1, MapLogin2, MapLogin3
{
List<WzDirectory> uiWzDirs = Program.WzManager.GetWzDirectoriesFromBase("ui");
foreach (WzDirectory uiWzDir in uiWzDirs) {
foreach (WzDirectory uiWzDir in uiWzDirs)
{
mapImage = (WzImage)uiWzDir?[selectedItem + ".img"];
if (mapImage != null)
break;
}
mapName = streetName = categoryName = selectedItem;
info = new MapInfo(mapImage, mapName, streetName, categoryName);
}
else if (selectedItem == "CashShopPreview") {
else if (selectedItem == "CashShopPreview")
{
List<WzDirectory> uiWzDirs = Program.WzManager.GetWzDirectoriesFromBase("ui");
foreach (WzDirectory uiWzDir in uiWzDirs) {
foreach (WzDirectory uiWzDir in uiWzDirs)
{
mapImage = (WzImage)uiWzDir?["CashShopPreview.img"];
if (mapImage != null)
break;
}
mapName = streetName = categoryName = "CashShopPreview";
info = new MapInfo(mapImage, mapName, streetName, categoryName);
}
else {
else if (selectedItem == "ITCPreview")
{
var uiWzDirs = Program.WzManager.GetWzDirectoriesFromBase("ui");
foreach (var uiWzDir in uiWzDirs)
{
mapImage = (WzImage)uiWzDir?["ITCPreview.img"];
if (mapImage != null)
break;
}
mapName = streetName = categoryName = "ITCPreview";
info = new MapInfo(mapImage, mapName, streetName, categoryName);
}
else
{
string mapid_str = selectedItem.Substring(0, 9);
int.TryParse(mapid_str, out mapid);

if (Program.InfoManager.MapsCache.ContainsKey(mapid_str)) {
if (Program.InfoManager.MapsCache.ContainsKey(mapid_str))
{
Tuple<WzImage, string, string, string, MapInfo> loadedMap = Program.InfoManager.MapsCache[mapid_str];

mapImage = loadedMap.Item1;
Expand All @@ -264,7 +281,8 @@ private void OnLoadMap(bool bFromHistory) {
categoryName = loadedMap.Item4;
info = loadedMap.Item5;
}
else {
else
{
MessageBox.Show("Map is missing.", "Error");
return; // map isnt available in Map.wz, despite it being listed on String.wz
}
Expand Down
Loading

0 comments on commit ab16678

Please sign in to comment.