public Menu(DisplayCaption caption, List <MenuItem> entries, MenuCallback callback) : base(caption, callback) { SubMenu = null; menuEntries = entries; Clear(); }
public Button(Compound gui, Rectangle bounds, DisplayCaption atomCaption, ChemistryButtonCallback callback) : base(gui, bounds, atomCaption) { callbackHandler = callback; pressed = false; }
public bool doEvent(object caller, MouseMotionEventArgs mmData, Point offset) { if (SubMenu != null && SubMenu.doEvent(this, mmData)) { return(true); } Point p = mmData.Position; selected = -1; if (p.X < offset.X || p.Y < offset.Y || p.X >= displaySize.Width + offset.X || p.Y >= displaySize.Height + offset.Y) { // Out of focus, brute force clear Clear(); return(false); } int scanX = Compound.IconSize.Width + Compound.Padding * 2 + offset.X; int index = 0; foreach (MenuItem mi in menuEntries) { if (!(mi is MenuSeperator)) { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = false; int newX = scanX + Compound.Padding * 3 + caption.Width; if (newX > p.X) { selected = index; if (mi.IsPopup()) { if (SubMenu != null) { SubMenu.Clear(); } SubMenu = (PopupMenu)mi; SubMenu.Position = new Point(scanX + Compound.Padding * 3, displaySize.Height - Compound.Padding + offset.Y); SubMenu.Show(); } return(true); } scanX = newX; } index++; } return(true); }
private void BuildList() { List <DisplayCaption> list = new List <DisplayCaption>(); foreach (DirectoryInfo di in directory.GetDirectories()) { DisplayCaption dc = new DisplayCaption(di.Name, DisplaySettings.folderIcon); dc.UserData = di.Name; list.Add(dc); } foreach (FileInfo fi in directory.GetFiles()) { // Check if it"s a valid rom size if (!MapperFarm.AllowedSize((int)fi.Length)) { continue; } try { byte[] data = new byte[fi.Length]; FileStream fo = File.OpenRead(fi.FullName); fo.Read(data, 0, (int)data.Length); fo.Close(); string hash = ProfileManager.GetHash(data); if (ProfileManager.Profiled(hash)) { ProfileManager.GameProfile profile = ProfileManager.GetProfile(hash); DisplayCaption dc = new DisplayCaption(profile.name, DisplaySettings.binaryIcon); dc.UserData = fi.Name; list.Add(dc); } else { DisplayCaption dc = new DisplayCaption(fi.Name); dc.UserData = fi.Name; list.Add(dc); } } catch { Console.WriteLine("Failed to test: " + fi.FullName); } } guiList.List = list; guiScroll.Max = guiList.List.Count - 1; }
public void paint(Surface surface, Rectangle area) { displaySize = new Size(area.Width, Height); MenuItem sel; if (selected >= 0 && selected < menuEntries.Count) { sel = menuEntries[selected]; } else { sel = null; } Rectangle rect = new Rectangle(area.Location, displaySize); rect.Height += Compound.BorderPadding.Height; surface.Fill(rect, DisplaySettings.menuForeground); rect.Height -= Compound.BorderPadding.Height; surface.Fill(rect, DisplaySettings.menuBackground); Point p = new Point(Compound.Padding + Compound.IconSize.Width + area.X, Compound.Padding + area.Y); foreach (MenuItem mi in menuEntries) { if (!(mi is MenuSeperator)) { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = false; if (sel == mi) { Rectangle selrect = new Rectangle(p.X - Compound.Padding * 2, p.Y - Compound.Padding, Compound.Padding * 3, displaySize.Height); selrect.Width += Compound.Padding + caption.Width; surface.Fill(selrect, DisplaySettings.selectedColor); } caption.Blit(surface, p); p.X += caption.Width + Compound.Padding; p.X += Compound.Padding * 3; } } if (SubMenu != null) { SubMenu.Paint(surface); } }
public Molicule(Compound gui, Rectangle r, DisplayCaption cap, List <Atom> atoms) : base(gui, r, cap) { windowAtoms = atoms; draggingAtom = null; dragging = false; menu = null; if (atoms.Count > 0) { activeAtom = atoms[atoms.Count - 1]; } else { activeAtom = null; } }
private static void LoadDefaults() { atomBackground = Color.FromArgb(255, 255, 255); atomBackgroundDimmed = Color.FromArgb(200, 200, 200); atomForeground = Color.FromArgb(0, 0, 0); atomHighlight = Color.FromArgb(200, 200, 255); bodyBlured = Color.FromArgb(0, 102, 155); bodyFocused = Color.FromArgb(0, 150, 255); captionColor = Color.FromArgb(0, 0, 0); desktopColor = Color.FromArgb(151, 149, 128); focused = Color.FromArgb(255, 210, 57); lableColor = Color.FromArgb(0, 0, 0); menuBackground = Color.FromArgb(255, 255, 255); menuForeground = Color.FromArgb(0, 0, 0); selectedColor = Color.FromArgb(255, 210, 57); titleBlured = Color.FromArgb(255, 210, 57); titleFocused = Color.FromArgb(255, 231, 0); bodyBorderBlured = Color.FromArgb(0, 0, 0); bodyBorderFocused = Color.FromArgb(255, 255, 255); lableFont = new SdlDotNet.Graphics.Font(@"freesans.ttf", 12); fixedPointFont = new SdlDotNet.Graphics.Font(@"VeraMoBd.ttf", 12); captionFont = lableFont; desktopAlignment = Alignment.CENTER; desktopImage = new Surface(Images.desktop); Surface icons = new Surface(Images.alerts); popupIcon = new DisplayIcon(icons, new Point(64, 48)); closeIcon = new DisplayIcon(icons, new Point(0, 0)); minimizeIcon = new DisplayIcon(icons, new Point(0, 16)); defaultIcon = new DisplayIcon(icons, new Point(64, 32)); binaryIcon = new DisplayIcon(icons, new Point(96, 32)); folderIcon = new DisplayIcon(icons, new Point(112, 32)); topLeftGlyph = new DisplayIcon(icons, new Point(96, 0)); topRightGlyph = new DisplayIcon(icons, new Point(108, 0)); bottomLeftGlyph = new DisplayIcon(icons, new Point(96, 16)); bottomRightGlyph = new DisplayIcon(icons, new Point(108, 16)); scrollUp = new DisplayIcon(icons, new Point(48, 0)); scrollDown = new DisplayIcon(icons, new Point(48, 16)); scrollLeft = new DisplayIcon(icons, new Point(64, 0)); scrollRight = new DisplayIcon(icons, new Point(64, 16)); scrollMarker = new DisplayIcon(icons, new Point(80, 0)); radioDeselected = new DisplayIcon(icons, new Point(16, 0)); radioSelected = new DisplayIcon(icons, new Point(16, 16)); checkUnchecked = new DisplayIcon(icons, new Point(32, 0)); checkChecked = new DisplayIcon(icons, new Point(32, 16)); spinnerArrows = new DisplayIcon(icons, new Rectangle(80, 16, 10, 16)); checkMatrix = new DisplayIcon(icons, new Point(112, 48)); uncheckMatrix = new DisplayIcon(icons, new Point(96, 48)); HPos = new DisplayIcon(icons, new Point(32, 112)); BLPos = new DisplayIcon(icons, new Point(48, 112)); P0Pos = new DisplayIcon(icons, new Point(64, 112)); M0Pos = new DisplayIcon(icons, new Point(80, 112)); P1Pos = new DisplayIcon(icons, new Point(96, 112)); M1Pos = new DisplayIcon(icons, new Point(112, 112)); defaultCaption = new DisplayCaption("Unnamed", defaultIcon); }
public PopupMenu(DisplayCaption caption, List <MenuItem> entries, MenuCallback callback) : base(caption, entries, callback) { selected = -1; }
override public void Paint(Surface display) { if (visible == false) { return; } dimensions = new Size(Compound.Padding * 2, Compound.Padding * 2); MenuItem sel; if (selected >= 0 && selected < menuEntries.Count) { sel = menuEntries[selected]; } else { sel = null; } foreach (MenuItem mi in menuEntries) { if (mi is MenuSeperator) { dimensions.Height += Compound.Padding + 2; } else { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = true; dimensions.Height += caption.Height; dimensions.Width = Math.Max(dimensions.Width, Compound.Padding * 3 + Compound.IconSize.Width + caption.Width); } } Rectangle rect = new Rectangle(position, dimensions); display.Fill(rect, DisplaySettings.menuBackground); display.Draw(new SdlDotNet.Graphics.Primitives.Box(position, dimensions), DisplaySettings.menuForeground); Point p = new Point(0, Compound.Padding + position.Y); foreach (MenuItem mi in menuEntries) { p.X = Compound.Padding + position.X; if (mi is MenuSeperator) { dimensions.Height = dimensions.Height + SeperatorThickness; Rectangle line = new Rectangle(Compound.Padding + position.X, p.Y + Compound.Padding / 2, dimensions.Width - Compound.Padding * 2, Compound.Seperator); display.Fill(line, DisplaySettings.menuForeground); p.Y += Compound.Padding + 2; } else { DisplayCaption caption = mi.Caption; caption.SizeWithIcon = true; if (sel == mi) { Rectangle selrect = new Rectangle(Compound.Padding + position.X, p.Y, dimensions.Width - Compound.Padding * 2, DisplaySettings.lableFont.Height); display.Fill(selrect, DisplaySettings.selectedColor); } p.X = Compound.Padding + position.X; caption.Blit(display, p); if (mi.IsPopup()) { Point p2 = new Point(); p2.X = dimensions.Width - Compound.IconSize.Width - Compound.Padding + position.X; p2.Y += p.Y + (DisplaySettings.lableFont.Height - Compound.IconSize.Height) / 2; DisplaySettings.popupIcon.Blit(display, p2); } p.Y += DisplaySettings.lableFont.Height; } } if (SubMenu != null) { SubMenu.Paint(display); } }
public MenuEntry(DisplayCaption caption, MenuCallback callback) { menuCaption = caption; callbackEvent = callback; }
public ConfigureRom(Compound gui, string file, string hash, int romSize, DisplayCaption caption) : base(gui, new Rectangle(0, 0, 273, 224), new DisplayCaption("Configure rom"), new List <Atom>()) { gameHash = hash; List <DisplayCaption> controllers = new List <DisplayCaption>(); List <DisplayCaption> mappers = new List <DisplayCaption>(); List <DisplayCaption> signals = new List <DisplayCaption>(); configCaption = caption; filename = file; DisplayCaption s; s = new DisplayCaption("NTSC"); s.UserData = SignalType.VIDEO_NTSC; signals.Add(s); s = new DisplayCaption("PAL"); s.UserData = SignalType.VIDEO_PAL; signals.Add(s); s = new DisplayCaption("SECAM"); s.UserData = SignalType.VIDEO_SECAM; signals.Add(s); foreach (string m in MapperFarm.MappersBySize(romSize)) { mappers.Add(new DisplayCaption(m)); } // TODO: Retrieve from input farm controllers.Add(new DisplayCaption("Joystick")); name = new EditBox(gui, new Rectangle(0, 0, 256, 24), file, null); mapper = new ListBox(gui, new Rectangle(124, 28, 132, 40), mappers, null); ctrl_a = new ListBox(gui, new Rectangle(124, 72, 132, 40), controllers, null); ctrl_b = new ListBox(gui, new Rectangle(124, 116, 132, 40), controllers, null); signal = new Radio(gui, new Rectangle(16, 44, 100, 0), signals, null); Add(new Button(gui, new Rectangle(192, 160, 64, 24), new DisplayCaption("Update"), doProfile)); Add(new Button(gui, new Rectangle(192 - 68, 160, 64, 24), new DisplayCaption("Remove"), removeProfile)); aLable = new Lable(gui, new Rectangle(110, 126, 0, 0), "B", Alignment.LEFT, DisplaySettings.captionColor, DisplaySettings.captionFont); bLable = new Lable(gui, new Rectangle(110, 84, 0, 0), "A", Alignment.LEFT, DisplaySettings.captionColor, DisplaySettings.captionFont); Add(aLable); Add(bLable); if (ProfileManager.Profiled(gameHash)) { ProfileManager.GameProfile profile = ProfileManager.GetProfile(gameHash); name.Value = profile.name; for (int i = 0; i < signals.Count; i++) { if ((SignalType)signals[i].UserData == profile.signal) { signal.Selection = i; break; } } for (int i = 0; i < ctrl_a.List.Count; i++) { if (ctrl_a.List[i].Text == profile.controller_a) { ctrl_a.Selected = i; break; } } for (int i = 0; i < ctrl_b.List.Count; i++) { if (ctrl_b.List[i].Text == profile.controller_b) { ctrl_b.Selected = i; break; } } for (int i = 0; i < mappers.Count; i++) { if (mappers[i].Text == profile.mapper) { mapper.Selected = i; break; } } } Add(name); Add(mapper); Add(ctrl_a); Add(ctrl_b); Add(signal); }
public Atom(Compound GUI, Rectangle bound, DisplayCaption caption) { gui = GUI; Boundaries = bound; Caption = caption; }
public CheckBox(Compound gui, Rectangle bounds, DisplayCaption dc, bool atomChecked, ChemistryCheckboxCallback callback) : base(gui, bounds, dc) { callbackHandler = callback; boxChecked = atomChecked; }