OSDN Git Service

Bug fix & merch name fixup
authormelchior <melchior@users.osdn.me>
Mon, 3 Oct 2022 23:42:50 +0000 (19:42 -0400)
committermelchior <melchior@users.osdn.me>
Mon, 3 Oct 2022 23:42:50 +0000 (19:42 -0400)
Automap/AutomapMod.cs
Automap/Designators/DefaultDesignators.cs
Automap/modinfo.json

index 8538f0b..b2d0caa 100644 (file)
@@ -88,7 +88,7 @@ namespace Automap
                {
                //TAKE OUT THE TRASH!
                //_localAutomap = null;
-               _automapDialog.Dispose( );
+               _automapDialog?.Dispose( );
                _automapDialog = null;
 
                base.Dispose( );
index c8e25c1..80c58ff 100644 (file)
@@ -1,6 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Drawing;
+using System.Linq;
 using System.Text;
 using System.Text.RegularExpressions;
 
@@ -187,51 +188,23 @@ namespace Automap
                {
                #if DEBUG
                clientAPI.Logger.VerboseDebug("TRADER Designator Invoked!");
-               #endif
-               //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
-
-               var traderJoe = entity as EntityTrader;
-               if (traderJoe == null) return;
+               #endif          
                
-               var traderName = entity.GetBehavior<EntityBehaviorNameTag>( )?.DisplayName ?? @"?";
-               string code;
-               // this makes me ill
-               switch (entity.Code.Path) {
-               case "humanoid-trader-artisan":
-                       code = "{0} the artisan";
-                       break;
-               case "humanoid-trader-treasurehunter":
-                       code = "{0} the treasure hunter";
-                       break;
-               case "humanoid-trader-buildmaterials":
-                       code = "{0} the building materials trader";
-                       break;
-               case "humanoid-trader-clothing":
-                       code = "{0} the clothing merchant";
-                       break;
-               case "humanoid-trader-commodities":
-                       code = "{0} the commodities merchant";
-                       break;
-               case "humanoid-trader-foods":
-                       code = "{0} the foods supplier";
-                       break;
-               case "humanoid-trader-furniture":
-                       code = "{0} the furniture trader";
-                       break;
-               case "humanoid-trader-luxuries":
-                       code = "{0} the luxuries merchant";
-                       break;
-               case "humanoid-trader-survivalgoods":
-                       code = "{0} the survival goods supplier";
-                       break;
-               default:
-                       code = "";
-                       break;
-               }
-               var message = string.Format(code, traderName);
-               if (traderJoe.TradeProps != null) {
-               message += $" - Gears: {traderJoe.TradeProps.Money}, ";
+               if (entity == null) return;
+               
+               var traderName = entity.GetBehavior<EntityBehaviorNameTag>( )?.DisplayName ?? @"?";             
+
+               //"game:tradingwindow-humanoid-trader-survivalgoods"
+               var langCodeKey = entity.Code.Domain + ":tradingwindow-" + entity.Code.Path;
+               var message = "?";
+               #if DEBUG
+               clientAPI.Logger.VerboseDebug("Using Lang Key Code: \"{0}\"",langCodeKey);
+               #endif
+               if (Lang.AvailableLanguages[@"en"].HasTranslation(langCodeKey)) {
+               var rawLangResponse = Lang.GetL(@"en", langCodeKey, traderName);
+               message = rawLangResponse.Split("-".ToCharArray( ), 2).Last( ).TrimStart( );
                }
+               
                poi.AddReplace(new EntityOfInterest {
                        Name = "Trader",
                        PrettyLocation = posn.PrettyCoords(clientAPI),
index bcc745e..5e186d9 100644 (file)
@@ -4,7 +4,7 @@
   "description" : "Automap; Generates a static HTML5 map dynamically, with P.O.I. Tracking & more.",
   "authors": ["Melchior","VeryGoodDog"],
   "contributors":["VeryGoodDog", "Drakker"],
-  "version": "0.1.8-pre.2",
+  "version": "0.1.8-pre.3",
     "side":"Client",
   "dependencies": { 
        "game": "1.17.0"