protected override Surface CreateSurface() { Surface surf = new Surface(Width, Height); int y = 0; for (int i = first_visible; i < first_visible + num_visible; i++) { if (i >= items.Count) { break; } Surface item_surface = GuiUtil.ComposeText(items[i], Font, Palette, (!selectable || (!selecting && cursor == i) || (selecting && selectionIndex == i)) ? 4 : 24); surf.Blit(item_surface, new Point(0, y)); y += item_surface.Height; } surf.TransparentColor = Color.Black; /* XXX */ return(surf); }
protected override Surface CreateSurface() { if (calc_width) { Surface textSurf = GuiUtil.ComposeText(Text, Font, Palette, -1, -1, Sensitive ? 4 : 24); Width = (ushort)textSurf.Width; Height = (ushort)textSurf.Height; return(textSurf); } else { /* this is wrong */ Surface surf = new Surface(Width, Height); Surface textSurf = GuiUtil.ComposeText(Text, Font, Palette, Width, Height, Sensitive ? 4 : 24); int x = 0; if (Type == ElementType.LabelRightAlign) { x += Width - textSurf.Width; } else if (Type == ElementType.LabelCenterAlign) { x += (Width - textSurf.Width) / 2; } surf.Blit(textSurf, new Point(x, 0)); surf.TransparentColor = Color.Black /* XXX */; return(surf); } }
void CalculateTextPosition() { if (text_surf == null) { text_surf = GuiUtil.ComposeText(Text, Font, Palette, -1, -1, Sensitive ? 4 : 24); } if ((Flags & ElementFlags.CenterTextHoriz) == ElementFlags.CenterTextHoriz) { text_x = (Width - text_surf.Width) / 2; } else if ((Flags & ElementFlags.RightAlignText) == ElementFlags.RightAlignText) { text_x = (Width - text_surf.Width); } else { text_x = 0; } if ((Flags & ElementFlags.CenterTextVert) == ElementFlags.CenterTextVert) { text_y = (Height - text_surf.Height) / 2; } else if ((Flags & ElementFlags.BottomAlignText) == ElementFlags.BottomAlignText) { text_y = (Height - text_surf.Height); } else { text_y = 0; } }
protected virtual Surface CreateSurface() { switch (Type) { case ElementType.DefaultButton: case ElementType.Button: case ElementType.ButtonWithoutBorder: return(GuiUtil.ComposeText(Text, Font, palette, Width, Height, sensitive ? 4 : 24)); default: return(null); } }
public void Layout() { lineSurfaces = new List <Surface> (); foreach (string l in lines) { if (l.Trim() == "") { lineSurfaces.Add(null); } else { lineSurfaces.Add(GuiUtil.ComposeText(l, fnt, pal, Painter.SCREEN_RES_X - X_OFFSET * 2, -1, 4)); } } }
protected override Surface CreateSurface() { Surface surf = new Surface(Width, Height); /* XXX draw the arrow (and border) */ if (cursor != -1) { Surface item_surface = GuiUtil.ComposeText(items[cursor], Font, Palette, 4); item_surface.TransparentColor = Color.Black; surf.Blit(item_surface, new Point(0, 0)); } return(surf); }
void CreateDropdownSurface() { dropdownSurface = new Surface(Width, items.Count * Font.LineSize); int y = 0; for (int i = 0; i < items.Count; i++) { Surface item_surface = GuiUtil.ComposeText(items[i], Font, Palette, i == selected_item ? 4 : 24); item_surface.TransparentColor = Color.Black; dropdownSurface.Blit(item_surface, new Point(0, y)); y += item_surface.Height; } }
protected override Surface CreateSurface() { return(GuiUtil.ComposeText(Text, Font, Palette, Width, Height, Sensitive ? 4 : 24)); }
public static void Redraw() { #if !RELEASE Rectangle fps_rect = Rectangle.Empty; if (show_fps) { fps_rect = new Rectangle(new Point(10, 10), new Size(80, 30)); frame_count++; if (frame_count == 50) { DateTime after = DateTime.Now; fps = 1.0 / (after - last_time).TotalSeconds * 50; last_time = after; frame_count = 0; /* make sure we invalidate the region where we're going to draw the fps/related info */ Invalidate(fps_rect); } } #endif //Console.WriteLine ("Redraw"); if (Painting != null) { Painting(null, EventArgs.Empty); } if (dirty.IsEmpty) { return; } //Console.WriteLine (" + dirty = {0}", dirty); total_elapsed = 0; now = DateTime.Now; paintingSurface.ClipRectangle = dirty; #if !RELEASE if (debug_dirty) { paintingSurface.Fill(dirty, Color.Red); paintingSurface.Update(); } #endif paintingSurface.Fill(dirty, Color.Black); for (Layer i = Layer.Background; i < Layer.Count; i++) { DrawLayer(layers[(int)i]); } #if !RELEASE if (show_fps) { if (fps_surface != null) { fps_surface.Dispose(); } fps_surface = GuiUtil.ComposeText(String.Format("fps: {0,0:F}", fps), GuiUtil.GetFonts(Game.Instance.PlayingMpq)[1], fontpal); paintingSurface.Blit(fps_surface, new Point(10, 10)); } #endif paintingSurface.Update(); paintingSurface.ClipRectangle = paintingSurface.Rectangle; dirty = Rectangle.Empty; total_elapsed = (DateTime.Now - now).Milliseconds; }