/// <summary> /// Works correctly even if context is null; will simply skip trying to make the path relative to game directories. /// </summary> public static string MakeRelativePath(WotContext context, string path) { try { if (PathUtil.IsSubpathOfOrSame(path, PathUtil.AppPath)) { return(PathUtil.ToggleRelative(PathUtil.AppPath, path)); } } catch { } try { if (PathUtil.IsSubpathOfOrSame(path, Path.Combine(context.Installation.Path, Ut.ExpandPath(context, context.VersionConfig.PathMods)))) { return(PathUtil.ToggleRelative(Path.Combine(context.Installation.Path, Ut.ExpandPath(context, context.VersionConfig.PathMods)), path)); } } catch { } try { if (PathUtil.IsSubpathOfOrSame(path, context.Installation.Path)) { return(PathUtil.ToggleRelative(context.Installation.Path, path)); } } catch { } return(path); }
/// <summary>Expands a Tank Icon Maker-style path, which may have expandable tokens like "VersionName".</summary> public static string ExpandIconPath(string path, WotContext context, Style style, Country country, Class class_, bool fragment = false, SaveType saveType = SaveType.Icons) { return(ExpandIconPath(path, context, style, country.Pick("ussr", "germany", "usa", "france", "china", "uk", "japan", "czech", "sweden", "poland", "italy", "none"), class_.Pick("light", "medium", "heavy", "destroyer", "artillery", "none"), fragment, saveType)); }
public static BulkSaveSettingsWindow Show(Window owner, string value, WotContext context, Style style) { var wnd = new BulkSaveSettingsWindow(context, style) { Owner = owner }; wnd.ShowDialog(); return(wnd); }
/// <summary>Constructor.</summary> public TestTank(string tankId, int tier, Country country, Class class_, Category category, WotContext context) : base(tankId, tier, country, class_, category) { TankId = tankId; Tier = tier; Country = country; Class = class_; Category = category; Context = context; }
/// <summary>Constructor.</summary> public TestTank(string tankId, int tier, Country country, Class class_, Category category, WotContext context) : base(tankId, tier, country, class_, category) { TankId = tankId; Tier = tier; Country = country; Class = class_; Category = category; Context = context; }
public BulkSaveSettingsWindow(WotContext context, Style style) : this() { MainWindow.ApplyUiZoom(this); Title = App.Translation.BulkSaveSettingsWindow.Title; Lingo.TranslateWindow(this, App.Translation.BulkSaveSettingsWindow); ContentRendered += InitializeEverything; _context = context; _style = style; }
/// <summary>Expands a Tank Icon Maker-style path, which may have expandable tokens like "VersionName".</summary> public static string ExpandPath(WotContext context, string path) { if (path == null) { return(null); } path = path.Replace("\"VersionName\"", context.Installation.GameVersionName); if (path.Contains('"')) { throw new Exception("The path “{0}” contains double-quote characters after expanding all known tokens. Did you mean one of: \"VersionName\"?".Fmt(path)); } return(path); }
public PathTemplateWindow(string value, WotContext context, Style style, SaveType saveType) : this() { MainWindow.ApplyUiZoom(this); Title = App.Translation.PathTemplateWindow.Title; Lingo.TranslateWindow(this, App.Translation.PathTemplateWindow); _context = context; _style = style; _saveType = saveType; ctValue.Text = value; ctValue.Focus(); ctValue_TextChanged(null, null); var isAtlas = saveType != SaveType.Icons; if (isAtlas) { ctIconsPathMacro.Text = "{AtlasPath}"; for (int i = 4; i <= 9; ++i) { var row = this.ctHelpGrid.RowDefinitions[i]; row.Height = new GridLength(0); } } else { _exampleTank = context.Tanks.FirstOrDefault(x => x.TankId.Contains("Object_260")); if (_exampleTank == null) { _exampleTank = context.Tanks.FirstOrDefault(); } } ctIconsPathHelp.Text = isAtlas ? ctIconsPathHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{AtlasPath}", _context, _style, "", "", fragment: true)) : ctIconsPathHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{IconsPath}", _context, _style, "", "", fragment: true)); ctTimPathHelp.Text = ctTimPathHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{TimPath}", _context, _style, "", "", fragment: true)); ctGamePathHelp.Text = ctGamePathHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{GamePath}", _context, _style, "", "", fragment: true)); ctGameVersionHelp.Text = ctGameVersionHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{GameVersion}", _context, _style, "", "", fragment: true)); ctStyleNameHelp.Text = ctStyleNameHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{StyleName}", _context, _style, "", "", fragment: true)); ctStyleAuthorHelp.Text = ctStyleAuthorHelp.Text.Replace("{cur}", Ut.ExpandIconPath("{StyleAuthor}", _context, _style, "", "", fragment: true)); }
public static string Show(Window owner, string value, WotContext context, Style style, SaveType saveType) { var wnd = new PathTemplateWindow(value, context, style, saveType) { Owner = owner }; if (wnd.ShowDialog() != true) { return(null); } return(wnd.ctValue.Text); }
/// <summary>Expands a Tank Icon Maker-style path, which may have expandable tokens like "VersionName".</summary> public static string ExpandIconPath(string path, WotContext context, Style style, WotTank tank, bool fragment = false, SaveType saveType = SaveType.Icons) { if (tank != null) { var country = tank.Country; var class_ = tank.Class; var tankId = tank.TankId; var fullName = tank.ClientData != null ? tank.ClientData.FullName : tank.TankId; var shortName = tank.ClientData != null ? tank.ClientData.ShortName : tank.TankId; var tier = tank.Tier; return(ExpandIconPath(path, context, style, country.Pick("ussr", "germany", "usa", "france", "china", "uk", "japan", "czech", "sweden", "poland", "italy", "none"), class_.Pick("light", "medium", "heavy", "destroyer", "artillery", "none"), tankId, fullName, shortName, tier, fragment, saveType)); } else { return(ExpandIconPath(path, context, style, "none", "none", "none", "none", "none", 0, fragment, saveType)); } }
public TankTypesController(WotContext context) { _context = context; }
/// <summary>Expands a Tank Icon Maker-style path, which may have expandable tokens like "VersionName".</summary> public static string ExpandIconPath(string path, WotContext context, Style style, string country, string class_, string tankId, string tankFullName, string tankShortName, int tankTier, bool fragment = false, SaveType saveType = SaveType.Icons) { if (string.IsNullOrEmpty(path)) { switch (saveType) { case SaveType.Icons: path = "{IconsPath}\\{TankId}{Ext}"; break; case SaveType.BattleAtlas: path = "{AtlasPath}\\" + AtlasBuilder.battleAtlas + ".png"; break; case SaveType.VehicleMarkerAtlas: path = "{AtlasPath}\\" + AtlasBuilder.vehicleMarkerAtlas + ".png"; break; case SaveType.CustomAtlas: path = "{AtlasPath}\\" + AtlasBuilder.customAtlas + ".png"; break; } } path = path.Replace("{IconsPath}", Ut.ExpandPath(context, context.VersionConfig.PathDestination) + @"\"); path = path.Replace("{AtlasPath}", Ut.ExpandPath(context, context.VersionConfig.PathDestinationAtlas) + @"\"); path = path.Replace("{TimPath}", PathUtil.AppPath + @"\"); path = path.Replace("{GamePath}", context.Installation.Path + @"\"); path = path.Replace("{GameVersion}", context.Installation.GameVersionName); if (class_ != null) { path = path.Replace("{TankClass}", class_); } if (country != null) { path = path.Replace("{TankCountry}", country); } if (tankId != null) { path = path.Replace("{TankId}", tankId); } if (tankFullName != null) { path = path.Replace("{TankFullName}", tankFullName); } if (tankShortName != null) { path = path.Replace("{TankShortName}", tankShortName); } path = path.Replace("{TankTier}", tankTier.ToString()); path = path.Replace("{StyleName}", style.Name); path = path.Replace("{StyleAuthor}", style.Author); path = path.Replace("{Ext}", context.VersionConfig.TankIconExtension); path = Environment.ExpandEnvironmentVariables(path); path = path.Replace(@"\\", @"\").Replace(@"\\", @"\").Replace(@"\\", @"\"); if (path.EndsWith(@"\") && !path.EndsWith(@":\")) { path = path.Substring(0, path.Length - 1); } return(fragment ? path : Path.GetFullPath(Path.Combine(context.Installation.Path, path))); }
/// <summary>Expands a Tank Icon Maker-style path, which may have expandable tokens like "VersionName".</summary> public static string ExpandIconPath(string path, WotContext context, Style style, string country, string class_, bool fragment = false, SaveType saveType = SaveType.Icons) { return(ExpandIconPath(path, context, style, country, class_, null, null, null, 0, fragment, saveType)); }
public NationsController(WotContext context) { _context = context; }
public AtlasBuilder(WotContext CurContext) { context = CurContext; }
private void CreateImageList(ref List <SubTextureStruct> ImageList, WotContext context, SaveType atlasType) { int X, Y, Width, Height, i; int BeginCount = ImageList.Count; var nameAtlas = atlasType == SaveType.BattleAtlas ? battleAtlas : vehicleMarkerAtlas; var guiPackage = context.VersionConfig.GuiPackageName.Split(' ', ',', ';'); Stream StreamAtlasDDS = null; foreach (string items in guiPackage) { StreamAtlasDDS = ZipCache.GetZipFileStream(new CompositePath(context, context.Installation.Path, context.VersionConfig.PathSourceAtlas.Replace("\"GuiPackage\"", items), nameAtlas + ".dds")); if (StreamAtlasDDS != null) { break; } } System.Drawing.Bitmap AtlasPNG = null; try { using (MemoryStream memStream = new MemoryStream()) { using (MagickImage AtlasDDS = new MagickImage(StreamAtlasDDS)) { AtlasDDS.Format = MagickFormat.Png; AtlasDDS.Write(memStream); AtlasPNG = new System.Drawing.Bitmap(memStream); } } } catch (Exception e) { MessageBox.Show("Error: " + e.Message, "CreateImageList", MessageBoxButtons.OK, MessageBoxIcon.Error); } AtlasPNG.SetResolution(96.0F, 96.0F); Stream StreamAtlasXML = null; foreach (string items in guiPackage) { StreamAtlasXML = ZipCache.GetZipFileStream(new CompositePath(context, context.Installation.Path, context.VersionConfig.PathSourceAtlas.Replace("\"GuiPackage\"", items), nameAtlas + ".xml")); if (StreamAtlasXML != null) { break; } } XDocument AtlasXML = XDocument.Load(StreamAtlasXML); XElement Root = AtlasXML.Element("root"); SubTextureStruct SubTextureTemp = new SubTextureStruct(); foreach (XElement element in Root.Elements()) { SubTextureTemp.FName = element.Element("name").Value.Trim(); i = 0; while ((i < BeginCount) && (SubTextureTemp.FName != ImageList[i].FName)) { i++; } if (i >= BeginCount) { X = Convert.ToInt32(element.Element("x").Value.Trim()); Y = Convert.ToInt32(element.Element("y").Value.Trim()); Width = Convert.ToInt32(element.Element("width").Value.Trim()); Height = Convert.ToInt32(element.Element("height").Value.Trim()); SubTextureTemp.ImageTank = new System.Drawing.Bitmap(Width, Height); SubTextureTemp.ImageTank.SetResolution(96.0F, 96.0F); SubTextureTemp.MaxParty = Math.Max(Width, Height); using (System.Drawing.Graphics gPNG = System.Drawing.Graphics.FromImage(SubTextureTemp.ImageTank)) { gPNG.DrawImage(AtlasPNG, 0, 0, new System.Drawing.Rectangle(X, Y, Width, Height), System.Drawing.GraphicsUnit.Pixel); } SubTextureTemp.LocRect = new System.Drawing.Rectangle(0, 0, Width, Height); ImageList.Add(SubTextureTemp); } } }