void DrawImage(Gdk.Pixbuf image, double X, double Y, bool highlight) { int x = (int)X - image.Width / 2; int y = (int)Y - image.Height / 2; #if !SYSTEM_DRAWING if (drawer is CairoDrawer) { Cairo.Context context = ((CairoDrawer)drawer).Context; if (highlight) { List <Drawer.Point> points = new List <Drawer.Point>(); points.Add(new Drawer.Point(x - 2.5, y - 2.5)); points.Add(new Drawer.Point(x + image.Width + 1.5, y - 2.5)); points.Add(new Drawer.Point(x + image.Width + 1.5, y + image.Height + 1.5)); points.Add(new Drawer.Point(x - 2.5, y + image.Height + 1.5)); drawer.FillPolygon(new Drawer.Color(1, 1, 0), points); } Gdk.CairoHelper.SetSourcePixbuf(context, image, x, y); context.Paint(); } else { #else { #endif if (highlight) { Gdk.GC gc = new Gdk.GC(GdkWindow); Gdk.Pixmap mask = new Gdk.Pixmap(null, image.Width, image.Height, 1); image.RenderThresholdAlpha(mask, 0, 0, 0, 0, -1, -1, 1); gc.ClipMask = mask; for (int i = -2; i <= 2; ++i) { for (int j = -2; j <= 2; ++j) { gc.SetClipOrigin(x + i, y + j); gc.RgbFgColor = new Gdk.Color(255, 255, 0); GdkWindow.DrawRectangle(gc, true, x + i, y + j, image.Width, image.Height); } } } GdkWindow.DrawPixbuf(new Gdk.GC(GdkWindow), image, 0, 0, x, y, -1, -1, Gdk.RgbDither.Normal, 0, 0); } } void DrawObject(MapObject obj, bool highlight) { if (obj.Type == ObjectType.Player) { if (ShowPlayers) { DrawTriangle(playerColor, Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), obj.Facing, highlight, false); } } else if (obj.Type == ObjectType.Monster) { if (ShowMonsters) { Drawer.Color color; if ((obj.Index >= 12 && obj.Index <= 15) || (obj.Index >= 43 && obj.Index <= 46)) { color = civilianColor; } else { color = monsterColor; } DrawTriangle(color, Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), obj.Facing, highlight, obj.Invisible); } } else if (obj.Type == ObjectType.Scenery) { if (ShowScenery) { DrawImage(sceneryImage, Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), highlight); } } else if (obj.Type == ObjectType.Sound) { if (ShowSounds) { DrawImage(soundImage, Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), highlight); } } else if (obj.Type == ObjectType.Goal) { if (ShowGoals) { DrawImage(goalImage, Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), highlight); } } else if (obj.Type == ObjectType.Item) { if (ShowObjects) { if (itemImages.ContainsKey((ItemType)obj.Index) && itemImages[(ItemType)obj.Index] != null) { DrawImage(itemImages[(ItemType)obj.Index], Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y), highlight); } else { drawer.DrawPoint(objectColor, new Drawer.Point(Transform.ToScreenX(obj.X), Transform.ToScreenY(obj.Y))); } } } } void DrawAnnotation(Annotation note, bool selected) { int X = (int)Transform.ToScreenX(note.X); int Y = (int)Transform.ToScreenY(note.Y); Layout layout = new Pango.Layout(this.PangoContext); layout.SetMarkup(note.Text); int width, height; layout.GetPixelSize(out width, out height); this.GdkWindow.DrawLayout(this.Style.TextGC(Gtk.StateType.Normal), X, Y - height, layout); if (selected) { DrawFatPoint(selectedLineColor, new Point(note.X, note.Y)); } else { DrawFatPoint(annotationColor, new Point(note.X, note.Y)); } } Drawer.Color LoadColor(string xPath, Drawer.Color defaultColor) { Drawer.Color c; c.R = Weland.Settings.GetSetting(xPath + "/Red", defaultColor.R); c.G = Weland.Settings.GetSetting(xPath + "/Green", defaultColor.G); c.B = Weland.Settings.GetSetting(xPath + "/Blue", defaultColor.B); return(c); } void SaveColor(string xPath, Drawer.Color c) { Weland.Settings.PutSetting(xPath + "/Red", c.R); Weland.Settings.PutSetting(xPath + "/Green", c.G); Weland.Settings.PutSetting(xPath + "/Blue", c.B); }