private void setGraphiclist(ResponseValue responseValue, Graphiclist graphiclistConfig, ref SvgImage svgElement) { int value = int.Parse(responseValue.value.ToString()); string path = graphiclistConfig.items[value].path; if (path.Contains(PathDef.PhysicalPath)) { path = path.Replace(PathDef.PhysicalPath, ""); } var newValue = path; svgElement.Href = newValue; }
public static void getGraphicLists(string pathSvgCfg, List <string> subGraphicDir, List <string> pathGraphicCfg, List <Graphiclist> graphicLists) { foreach (string subDir in subGraphicDir) { foreach (string pathCfg in pathGraphicCfg) { var lines = System.IO.File.ReadAllLines(pathCfg).Select(line => line.Split(new char[] { '\t' })); List <string[]> graphiclistItems = lines.Where(line => line.Length != 0).ToList(); Graphiclist graphiclist = new Graphiclist(); graphiclist.items = new List <GraphiclistItem>(); foreach (string[] item in graphiclistItems) { GraphiclistItem graphiclistItem = new GraphiclistItem(); graphiclistItem.index = int.Parse(item[0]); if (item.Length > 1) { graphiclistItem.path = item[1]; } else { string mask; if (graphiclistItem.index < 10) { mask = "*_0" + graphiclistItem.index + "*"; } else { mask = "*_" + graphiclistItem.index + "*"; } string[] path = Directory.GetFiles(pathCfg.Substring(0, pathCfg.LastIndexOf("\\")) + subDir, mask); if (path.Length == 0) { throw new Exception(); } else { graphiclistItem.path = path[0]; } } graphiclist.items.Add(graphiclistItem); graphiclist.name = subDir; graphiclist.name = graphiclist.name.Replace("/", string.Empty); } XmlSerializer serializer = new XmlSerializer(typeof(Graphiclist)); using (TextWriter writer = new StreamWriter(pathSvgCfg, append: true)) { serializer.Serialize(writer, graphiclist); } } } }
public CommandWheel(CommandData[] commands) { commands = commands?.Where(x => GameEvent.checkDependanciesAndRestrictions(x.Dependancies))?.ToArray(); if (commands == null) { //World.Remove(this); return; } this.commands = commands; lastMouse = new Point(Mouse.ScreenX, Mouse.ScreenY); //Make the wheel wheel = new Image(Library.GetTexture("./content/UI/CommandWheel/Wheel.png")); wheel.CenterOrigin(); X = Mouse.ScreenX; Y = Mouse.ScreenY; Layer = Utility.WHEEL_UI_LAYER; AddComponent(wheel); //Add commands gcommands = new Graphiclist(); if (this.commands != null && this.commands.Length > 0) { int deg = -90, deginc = 360 / this.commands.Length; foreach (var c in this.commands) { Image img = new Image(Library.GetTexture("./content/UI/CommandWheel/" + c.Name + ".png")); img.CenterOrigin(); img.Y = -wheel.Height / 2 + img.Height / 2; FP.AngleXY(ref img.X, ref img.Y, deg, wheel.Height / 2 - img.Height / 2); commandImages.Add(c, img); deg += deginc; gcommands.Add(img); } } AddComponent(gcommands); ClampHorizontal(0, FP.Width, 100); ClampVertical(0, FP.Height, 100); }
/** * Adds the graphic to the Entity via a Graphiclist. * @param g Graphic to add. */ public Graphic AddGraphic(Graphic g) { if (this.Graphic is Graphiclist) { (this.Graphic as Graphiclist).Add(g); } else { Graphiclist list = new Graphiclist(); if (this.Graphic) { list.Add(this.Graphic); } list.Add(g); Graphic = list; } return(g); }
public void AddPlayers(List <Player> players) { foreach (var p in players) { var e = new Entity(); var lives = new Text(StartingLives.ToString()); lives.Italicized = true; lives.Size = 18; lives.X = 10; lives.Y = 15; lives.ScrollX = lives.ScrollY = 0; var head = new Image(Library.GetTexture("players/" + p.ImageName + "_head.png")); head.CenterOO(); head.X = -10; head.Y = 25; head.ScrollX = head.ScrollY = 0; var graphics = new Graphiclist(lives, head); graphics.ScrollX = graphics.ScrollY = 0; e.AddComponent(graphics); if (StartingHealth != 0 && PunchDamage != 0) { var health = new Text(string.Format("{0}/{0}", StartingHealth)); health.Bold = true; health.Size = 18; health.X = head.X - head.Width / 2; health.Y = lives.Y + 30; health.ScrollX = health.ScrollY = 0; graphics.Add(health); e.AddResponse(HUD.Message.UpdateDamage, OnDamage(p, health)); } e.AddResponse(Player.Message.Die, OnDeath(p, lives, head)); e.AddResponse(Player.Message.UpgradeAcquired, OnUpgradeAcquired(p, lives, head)); e.AddResponse(Upgrade.Message.Used, OnUpgradeUsed()); Players.Add(e); upgradeIcons.Add(new Stack <Image>()); } }
/// <summary> /// Adds the graphic to the Entity via a Graphiclist. /// </summary> /// <param name="g">Graphic to add.</param> /// <returns>The added Graphic.</returns> public Graphic AddGraphic(Graphic g) { var list = Graphic as Graphiclist; if (list != null) { list.Add(g); } else { list = new Graphiclist(); if (Graphic != null) { list.Add(Graphic); } list.Add(g); Graphic = list; } return(g); }
private void refreshGraphicList(SvgConfig config, SvgDocument svg, ResponseValue responseVar) { string name = config.BindingTags.First(p => p.id == responseVar.Id).name; string idG = config.BindingTags.First(p => p.id == responseVar.Id).id; config.SchemeGraphicsList.First(p => p.name == name).id = idG; Graphiclist graphiclistConfig = config.SchemeGraphicsList.First(p => p.id == responseVar.Id); int i = 0; while (i < 1000) { string id = responseVar.Id + "#" + i; if (svg.GetElementById(id) is SvgImage) { var element = (SvgImage)svg.GetElementById(id); setGraphiclist(responseVar, graphiclistConfig, ref element); break; } else { i++; } } }