///// <summary> ///// Constructor. Call this from the default constructor of all subclasses, passing in the required information. ///// </summary> ///// <param name="commandName">The command name of the action that this component invokes</param> ///// <param name="name">The name of this component. Keep it simple, single words are best.</param> ///// <param name="nickname">The abbreviation of this component. Keep it short, 1-5 characters are best</param> ///// <param name="description">The description of this component. Be succinct but clear. You can supply whole sentances.</param> ///// <param name="category">The category of this component. Controls which tab components will end up in.</param> ///// <param name="subCategory">The subcategory for this component. Controls which group the component will be in.</param> //protected NewtBaseComponent(string commandName, string name, string nickname, string description, // string subCategory, string category = CategoryName) // : base() //{ // CommandName = commandName; // Host.EnsureInitialisation(); // ActionType = Core.Instance.Actions.GetActionDefinition(CommandName); // Name = name; // NickName = nickname; // Description = description; // Category = category; // SubCategory = subCategory; // PostConstructor(); //} /// <summary> /// Constructor. Call this from the default constructor of all subclasses, passing in the required information. /// </summary> /// <param name="commandName">The command name of the action that this component invokes</param> /// <param name="name">The name of this component. Keep it simple, single words are best.</param> /// <param name="nickname">The abbreviation of this component. Keep it short, 1-5 characters are best</param> /// <param name="category">The category of this component. Controls which tab components will end up in.</param> /// <param name="subCategory">The subcategory for this component. Controls which group the component will be in.</param> protected SalamanderBaseComponent(string commandName, string name, string nickname, string subCategory, GH_Exposure exposure = GH_Exposure.primary, string category = CategoryName) : base() { CommandName = commandName; Host.EnsureInitialisation(true); ActionType = Core.Instance.Actions.GetActionDefinition(CommandName); if (ActionType == null) { throw new Exception("Command '" + CommandName + "' has not been found. The plugin that contains it may not have been successfully loaded."); } var attributes = ActionAttribute.ExtractFrom(ActionType); Name = name; NickName = nickname; Description = attributes.Description.CapitaliseFirst(); Category = category; SubCategory = subCategory; _Exposure = exposure; if (attributes.PreviewLayerType != null) { PreviewLayer = Activator.CreateInstance(attributes.PreviewLayerType) as DisplayLayer; } PostConstructor(); }
/// <summary> /// Erzeugt ein neues MenuButton-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge, einer Zeichenkette für den Namen der Schaltfläche /// und der Aktion, welche bei einem Klick ausgeführt wird Pflicht. /// </summary> public Button(IScreen screen, DisplayLayer drawOrder, string name, Action<GameTime> onClick) : base(screen, drawOrder) { this.name = name; OnClick = onClick; spriteBatch = new SpriteBatch (screen.GraphicsDevice); }
/// <summary> /// Erzeugt ein neues TextItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge und der Zeichenkette, die angezeigt wird, für Pflicht. /// </summary> public TextBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder) { Text = text; State = WidgetState.None; spriteBatch = new SpriteBatch (screen.GraphicsDevice); }
/// <summary> /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angabe der Zeichenreihenfolge Pflicht. /// </summary> public ComboBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder, String.Empty) { dropdown = new Menu(screen: screen, drawOrder: Index + DisplayLayer.Menu); dropdown.Bounds.Position = ValueBounds.Position; dropdown.Bounds.Size = new ScreenPoint(Screen, () => ValueBounds.Size.OnlyX + ValueBounds.Size.OnlyY * 10); dropdown.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; // (s) => Container.ItemForegroundColor (s); dropdown.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; // (s) => Design.WidgetBackground; dropdown.BackgroundColorFunc = (s) => Design.WidgetBackground; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.IsVisible = false; dropdownBorder = new Border( screen: screen, drawOrder: Index + DisplayLayer.Menu, widget: dropdown, lineWidth: 2, padding: 2 ); currentValue = new InputItem(screen: screen, drawOrder: Index, text: text, inputText: String.Empty); currentValue.Bounds = Bounds; currentValue.ForegroundColorFunc = (s) => ForegroundColor; currentValue.BackgroundColorFunc = (s) => Color.Transparent; currentValue.IsVisible = IsVisible; currentValue.IsMouseClickEventEnabled = false; ValidKeys.Add(Keys.Escape); }
protected override void OnDynamicDraw(GetPointDrawEventArgs e) { IAction action = Core.Instance.Actions.CurrentAction; if (action != null) { PreviewParameters pParam; if (SelectionPoints == null) { Point3d basePt; TryGetBasePoint(out basePt); pParam = new PreviewParameters(true, null, FromRC.Convert(e.CurrentPoint), FromRC.Convert(basePt)); } else { IList <Vector> sPts = new List <Vector>(); foreach (Vector pt in SelectionPoints) { sPts.Add(pt); // Draw points: e.Display.DrawPoint(ToRC.Convert(pt), PointStyle.X, 3, System.Drawing.Color.Orange); } sPts.Add(FromRC.Convert(e.CurrentPoint)); pParam = new PreviewParameters(true, null, sPts); } DisplayLayer previewLayer = action.PreviewLayer(pParam); if (previewLayer != null) { var rParam = new RhinoRenderingParameters(e); previewLayer.Draw(rParam); } } base.OnDynamicDraw(e); }
/// <summary> /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angabe der Zeichenreihenfolge Pflicht. /// </summary> public ComboBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder, String.Empty) { dropdown = new Menu (screen: screen, drawOrder: Index + DisplayLayer.Menu); dropdown.Bounds.Position = ValueBounds.Position; dropdown.Bounds.Size = new ScreenPoint (Screen, () => ValueBounds.Size.OnlyX + ValueBounds.Size.OnlyY * 10); dropdown.ItemForegroundColor = Design.ComboBoxItemForegroundColorFunc; // (s) => Container.ItemForegroundColor (s); dropdown.ItemBackgroundColor = Design.ComboBoxItemBackgroundColorFunc; // (s) => Design.WidgetBackground; dropdown.BackgroundColorFunc = (s) => Design.WidgetBackground; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.IsVisible = false; dropdownBorder = new Border ( screen: screen, drawOrder: Index + DisplayLayer.Menu, widget: dropdown, lineWidth: 2, padding: 2 ); currentValue = new InputItem (screen: screen, drawOrder: Index, text: text, inputText: String.Empty); currentValue.Bounds = Bounds; currentValue.ForegroundColorFunc = (s) => ForegroundColor; currentValue.BackgroundColorFunc = (s) => Color.Transparent; currentValue.IsVisible = IsVisible; currentValue.IsMouseClickEventEnabled = false; ValidKeys.Add (Keys.Escape); }
/// <summary> /// Erzeugt ein neues TextItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge und der Zeichenkette, die angezeigt wird, für Pflicht. /// </summary> public TextBox(IScreen screen, DisplayLayer drawOrder, string text) : base(screen, drawOrder) { Text = text; State = WidgetState.None; spriteBatch = new SpriteBatch(screen.GraphicsDevice); }
/// <summary> /// Erzeugt eine neue Instanz eines ColorPicker-Objekts und initialisiert diese /// mit der Farbe, auf welche der Farbwähler beim Aufruf aus Sicht des Spielers zeigt. /// </summary> public ColorPicker(IScreen screen, DisplayLayer drawOrder, Color def) : base(screen, drawOrder) { tileSize = new ScreenPoint (screen, 0.032f, 0.032f); // Widget-Attribute BackgroundColorFunc = (s) => Design.WidgetBackground; ForegroundColorFunc = (s) => Design.WidgetForeground; AlignX = HorizontalAlignment.Left; AlignY = VerticalAlignment.Top; // die Farb-Tiles colors = new List<Color> (CreateColors (64)); colors.Sort (ColorHelper.SortColorsByLuminance); tiles = new List<ScreenPoint> (CreateTiles (colors)); // einen Spritebatch spriteBatch = new SpriteBatch (screen.GraphicsDevice); // Position und Größe Bounds.Position = ScreenPoint.Centered (screen, Bounds); Bounds.Size.RelativeFunc = () => { float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count)); return tileSize * sqrt; }; // Die Callback-Funktion zur Selektion setzt das SelectedColor-Attribut ColorSelected += (color, time) => { SelectedColor = color; }; }
/// <summary> /// Erzeugt ein neues MenuButton-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge, einer Zeichenkette für den Namen der Schaltfläche /// und der Aktion, welche bei einem Klick ausgeführt wird Pflicht. /// </summary> public Button(IScreen screen, DisplayLayer drawOrder, string name, Action <GameTime> onClick) : base(screen, drawOrder) { this.name = name; OnClick = onClick; spriteBatch = new SpriteBatch(screen.GraphicsDevice); }
/// <summary> /// Erzeugt eine neue Instanz eines SliderItem-Objekts und initialisiert diese /// mit dem zugehörigen IGameScreen-Objekt. Zudem ist die Angabe der Zeichenreihenfolge, /// einem minimalen einstellbaren Wert, einem maximalen einstellbaren Wert und einem Standardwert Pflicht. /// </summary> public SliderItem(IScreen screen, DisplayLayer drawOrder, string text, int max, int min, int value) : base(screen, drawOrder, text) { MaxValue = max; MinValue = min; _value = value; }
/// <summary> /// Erzeugt eine neue Instanz eines SliderItem-Objekts und initialisiert diese /// mit dem zugehörigen IGameScreen-Objekt. Zudem ist die Angabe der Zeichenreihenfolge, /// einem minimalen einstellbaren Wert, einem maximalen einstellbaren Wert und einem Standardwert Pflicht. /// </summary> public SliderItem(IScreen screen, DisplayLayer drawOrder, string text, int max, int min, int value) : base(screen, drawOrder, text) { MaxValue = max; MinValue = min; _value = value; }
public DropDownMenu(GameScreen screen, DisplayLayer drawOrder, int itemNum, MenuItemInfo info) : base(screen, drawOrder, itemNum, info) { // drop-down menu dropdown = new VerticalMenu (screen, new WidgetInfo (), DisplayLayer.SubMenu); dropdown.ItemForegroundColor = DropDownForegroundColor; dropdown.ItemBackgroundColor = DropDownBackgroundColor; dropdown.ItemAlignX = HorizontalAlignment.Left; dropdown.ItemAlignY = VerticalAlignment.Center; dropdown.Border = new Border (new Color (0xb4, 0xff, 0x00), 5, 5, 0, 0); dropdown.IsVisible = false; // selected value MenuItemInfo valueInfo = new MenuItemInfo () { Text = "---", RelativePosition = () => ValuePosition (0), RelativeSize = () => ValueSize (0), OnClick = () => info.OnClick (), }; selected = new MenuButton (screen, DisplayLayer.MenuItem, 0, valueInfo); selected.Info.ForegroundColor = () => DropDownForegroundColor (selected.ItemState); selected.Info.BackgroundColor = () => DropDownBackgroundColor (selected.ItemState); // action to open the drop-down menu info.OnClick = () => { GameScreens.VideoOptionScreen.Collapse (this); if (dropdown.IsVisible == true) { dropdown.IsVisible = false; } else { dropdown.IsVisible = true; } }; }
/// <summary> /// Erstelle einen neuen TextInputDialog. /// </summary> public TextInputDialog(IScreen screen, DisplayLayer drawOrder, string title, string text, string inputText) : base(screen, drawOrder, title) { textItem = new TextItem (screen, drawOrder, String.Empty); Cancel = (time) => { Close (time); }; Submit = (time) => { Close (time); }; Bounds.Size = new ScreenPoint (screen, 0.5f, 0.3f); // Der Titel-Text ist mittig ausgerichtet AlignX = HorizontalAlignment.Center; menu = new Menu (Screen, Index + DisplayLayer.Menu); menu.Bounds = ContentBounds; menu.Bounds.Padding = new ScreenPoint (screen, 0.010f, 0.019f); menu.ItemAlignX = HorizontalAlignment.Left; menu.ItemAlignY = VerticalAlignment.Center; //die Texteingabe textInput = new InputItem (Screen, Index + DisplayLayer.MenuItem, text, inputText); menu.Add (textInput); menu.Add (textItem); textInput.IsEnabled = true; textInput.IsInputEnabled = true; textInput.NameWidth = 0.35f; textInput.ValueWidth = 0.65f; ValidKeys.AddRange (new Keys[] { Keys.Enter, Keys.Escape }); }
public TextInput(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { // load fonts font = HfGDesign.MenuFont (screen); spriteBatch = new SpriteBatch (screen.device); }
/// <summary> /// Erzeugt ein neues InputItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge und für evtl. bereits vor-eingetragenen Text Pflicht. /// </summary> public InputItem(IScreen screen, DisplayLayer drawOrder, string text, string inputText) : base(screen, drawOrder, text) { InputText = inputText; ValidKeys.AddRange (TextHelper.ValidKeys); ValidKeys.Add (Keys.Enter); IsInputEnabled = false; }
/// <summary> /// Erzeugt ein neues InputItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge und für evtl. bereits vor-eingetragenen Text Pflicht. /// </summary> public InputItem(IScreen screen, DisplayLayer drawOrder, string text, string inputText) : base(screen, drawOrder, text) { InputText = inputText; ValidKeys.AddRange(TextHelper.ValidKeys); ValidKeys.Add(Keys.Enter); IsInputEnabled = false; }
public Border(IScreen screen, DisplayLayer drawOrder, Bounds bounds, int lineWidth, int padding, Color lineColor, Color outlineColor) : base(screen, drawOrder) { LineWidth = lineWidth; Padding = padding; lines = new Lines(screen, drawOrder, lineWidth, lineColor, outlineColor); Bounds = bounds; }
public Border(IScreen screen, DisplayLayer drawOrder, Bounds bounds, int lineWidth, int padding, Color lineColor, Color outlineColor) : base(screen, drawOrder) { LineWidth = lineWidth; Padding = padding; lines = new Lines (screen, drawOrder, lineWidth, lineColor, outlineColor); Bounds = bounds; }
/// <summary> /// Erzeugt ein neues Menu-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angabe der Zeichenreihenfolge Pflicht. /// </summary> public Container(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { items = new List <Widget> (); ItemAlignX = HorizontalAlignment.Left; ItemAlignY = VerticalAlignment.Center; ItemForegroundColor = Design.MenuItemForegroundColorFunc; ItemBackgroundColor = Design.MenuItemBackgroundColorFunc; }
public Bitmap GenerateBakeIcon(DisplayLayer layer) { if (layer.IconURI != null) { return(IconResourceHelper.CombinedBitmapFromURIs(layer.IconURI, Resources.URIs.BakeIcon)); } else { return(null); } }
public ConfirmDialog(IScreen screen, DisplayLayer drawOrder, string title, string text) : this(screen, drawOrder, title) { // Die Textanzeige foreach (string line in text.Split('\n')) { TextItem displayText = new TextItem(Screen, Index + DisplayLayer.MenuItem, line); menu.Add(displayText); } menu.RelativeItemHeight = Design.DataItemHeight; }
/// <summary> /// Erzeugt eine neue Instanz eines VerticalMenu-Objekts und initialisiert diese mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angaben der Zeichenreihenfolge Pflicht. /// </summary> public Menu(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { RelativeItemHeight = Design.NavigationItemHeight; spriteBatch = new SpriteBatch (screen.GraphicsDevice); ItemBackgroundColor = Design.MenuItemBackgroundColorFunc; ItemForegroundColor = Design.MenuItemForegroundColorFunc; BackgroundColorFunc = Design.WidgetBackgroundColorFunc; ForegroundColorFunc = Design.WidgetForegroundColorFunc; }
/// <summary> /// Erzeugt eine neue Instanz eines VerticalMenu-Objekts und initialisiert diese mit dem zugehörigen IGameScreen-Objekt. /// Zudem ist die Angaben der Zeichenreihenfolge Pflicht. /// </summary> public Menu(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { RelativeItemHeight = Design.NavigationItemHeight; spriteBatch = new SpriteBatch(screen.GraphicsDevice); ItemBackgroundColor = Design.MenuItemBackgroundColorFunc; ItemForegroundColor = Design.MenuItemForegroundColorFunc; BackgroundColorFunc = Design.WidgetBackgroundColorFunc; ForegroundColorFunc = Design.WidgetForegroundColorFunc; }
public Bitmap GenerateIcon(DisplayLayer layer) { if (layer.IconURI != null) { return(IconResourceHelper.BitmapFromURI(layer.IconURI)); } else { return(null); } }
private void PlayerDeath(GameObject gameObject) { gameObject.RemoveGameObject(); var death = new GameObject("Death", gameObject.TopLeft); var deathAnimation = new ScaleAnimationComponent(SpaceGraphics.LargeExpolosionAsset[0], 0, 50, 3000, Color.DarkRed, null, ObjectEvent.RemoveEntity); var exitLevel = new ObjectEventComponent(ObjectEvent.RemoveEntity, ExitLevelAction); death.AddComponent(deathAnimation); death.AddComponent(exitLevel); DisplayLayer.AddGameObject(death); }
/// <summary> /// Erzeugt ein neues Dialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht. /// [base=screen, drawOrder] /// </summary> public Dialog(IScreen screen, DisplayLayer drawOrder, string title) : base(screen, drawOrder) { // Setzte Titel und Text Title = title; // erstelle einen Spritebatch zum Zeichnen der Titelleiste spriteBatch = new SpriteBatch(screen.GraphicsDevice); // Dialoge sind nach dem erstellen sichtbar, und das Delegate zum schließen macht sie unsichtbar IsVisible = true; IsModal = true; Close = (time) => { IsVisible = false; Screen.RemoveGameComponents(time, this); }; // Die Standardposition ist in der Mitte des Bildschirms Bounds.Position = ScreenPoint.Centered(screen, Bounds); // Die Standardgröße Bounds.Size = new ScreenPoint(screen, 0.500f, 0.500f); // Der Standardabstand Bounds.Padding = new ScreenPoint(screen, 0.010f, 0.010f); // Die Standardfarben BackgroundColorFunc = (s) => Design.DialogBackground; ForegroundColorFunc = (s) => Design.DialogForeground; TitleBackgroundColor = () => Design.DefaultLineColor * 0.75f; TitleForegroundColor = () => Design.TitleForegroundColor; // Einen Rahmen um den Titel des Dialogs titleBorder = new Border( screen: screen, drawOrder: Index, bounds: TitleBounds, lineWidth: 2, padding: 1, lineColor: TitleBackgroundColor(), outlineColor: Design.DefaultOutlineColor * 0.75f ); // Einen Rahmen um den Dialog dialogBorder = new Border( screen: screen, drawOrder: Index, widget: this, lineWidth: 2, padding: 1, lineColor: TitleBackgroundColor(), outlineColor: Design.DefaultOutlineColor * 0.75f ); // Tasten, auf die wir reagieren ValidKeys = new List <Keys> (); }
/// <summary> /// Erzeugt ein neues Dialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht. /// [base=screen, drawOrder] /// </summary> public Dialog(IScreen screen, DisplayLayer drawOrder, string title) : base(screen, drawOrder) { // Setzte Titel und Text Title = title; // erstelle einen Spritebatch zum Zeichnen der Titelleiste spriteBatch = new SpriteBatch (screen.GraphicsDevice); // Dialoge sind nach dem erstellen sichtbar, und das Delegate zum schließen macht sie unsichtbar IsVisible = true; IsModal = true; Close = (time) => { IsVisible = false; Screen.RemoveGameComponents (time, this); }; // Die Standardposition ist in der Mitte des Bildschirms Bounds.Position = ScreenPoint.Centered (screen, Bounds); // Die Standardgröße Bounds.Size = new ScreenPoint (screen, 0.500f, 0.500f); // Der Standardabstand Bounds.Padding = new ScreenPoint (screen, 0.010f, 0.010f); // Die Standardfarben BackgroundColorFunc = (s) => Design.DialogBackground; ForegroundColorFunc = (s) => Design.DialogForeground; TitleBackgroundColor = () => Design.DefaultLineColor * 0.75f; TitleForegroundColor = () => Design.TitleForegroundColor; // Einen Rahmen um den Titel des Dialogs titleBorder = new Border ( screen: screen, drawOrder: Index, bounds: TitleBounds, lineWidth: 2, padding: 1, lineColor: TitleBackgroundColor (), outlineColor: Design.DefaultOutlineColor * 0.75f ); // Einen Rahmen um den Dialog dialogBorder = new Border ( screen: screen, drawOrder: Index, widget: this, lineWidth: 2, padding: 1, lineColor: TitleBackgroundColor (), outlineColor: Design.DefaultOutlineColor * 0.75f ); // Tasten, auf die wir reagieren ValidKeys = new List<Keys> (); }
public Lines(IScreen screen, DisplayLayer drawOrder, int lineWidth, Color lineColor, Color outlineColor) : base(screen, drawOrder) { this.lineWidth = lineWidth; points = new List<Vector2> (); spriteBatch = new SpriteBatch (screen.GraphicsDevice); texture = ContentLoader.CreateTexture (Screen.GraphicsDevice, Color.White); LineColor = lineColor; OutlineColor = outlineColor; IsEnabled = true; IsVisible = true; }
public TextInputDialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { var textInputInfo = new WidgetInfo () { RelativePosition = TextInputPosition, RelativeSize = TextInputSize, RelativePadding = () => new Vector2 (0.005f, 0.005f), ForegroundColor = () => Color.Black, BackgroundColor = () => Color.White }; TextInput = new TextInput (screen, textInputInfo, DisplayLayer.SubMenu); }
public Lines(IScreen screen, DisplayLayer drawOrder, int lineWidth, Color lineColor, Color outlineColor) : base(screen, drawOrder) { this.lineWidth = lineWidth; points = new List <Vector2> (); spriteBatch = new SpriteBatch(screen.GraphicsDevice); texture = ContentLoader.CreateTexture(Screen.GraphicsDevice, Color.White); LineColor = lineColor; OutlineColor = outlineColor; IsEnabled = true; IsVisible = true; }
private void CreateScoreDisplay() { var score = new GameObject("Score", new Vector2(10, 10)); var counterComponent = new CounterIncrementComponent(ObjectEvent.ScoreIncrease, ObjectEvent.ScoreIncreaseDisplay, ObjectEvent.Ignore, ObjectEvent.Ignore, 0, 100, false); var scoreComponent = new TextComponent(FontGraphics.PropertialFont_8X8, counterComponent); score.AddComponent(counterComponent); score.AddComponent(scoreComponent); DisplayLayer.AddGameObject(score); _scoreGameObject = score; GameConstants.GameInstance.ScoreEventHandler += ScoreMilestones; }
public VerticalMenu(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { info.RelativeSize = () => new Vector2 ( RelativeItemSize (-1).X, RelativeItemSize (-1).Y * Items.Count + Info.RelativePadding ().Y * (Items.Count - 1) ); RelativeItemSize = (i) => new Vector2 (300, 0); RelativeItemPosition = (n) => { return Info.RelativePosition () + new Vector2 (0, (RelativeItemSize (-1).Y + Info.RelativePadding ().Y) * n); }; Border = Border.Zero; spriteBatch = new SpriteBatch (screen.device); }
/// <summary> /// Erstellt ein neues grafisches Benutzerschnittstellenelement in dem angegebenen Spielzustand /// mit der angegebenen Zeichenreihenfolge. /// </summary> public Widget(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { Bounds = Bounds.Zero(screen); AlignX = HorizontalAlignment.Left; AlignY = VerticalAlignment.Center; ForegroundColorFunc = Design.WidgetForegroundColorFunc; BackgroundColorFunc = Design.WidgetBackgroundColorFunc; ValidKeys = new List <Keys> (); IsVisible = true; _isEnabled = true; IsModal = false; IsLocalized = true; State = WidgetState.None; }
/// <summary> /// Erstellt ein neues grafisches Benutzerschnittstellenelement in dem angegebenen Spielzustand /// mit der angegebenen Zeichenreihenfolge. /// </summary> public Widget(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { Bounds = Bounds.Zero (screen); AlignX = HorizontalAlignment.Left; AlignY = VerticalAlignment.Center; ForegroundColorFunc = Design.WidgetForegroundColorFunc; BackgroundColorFunc = Design.WidgetBackgroundColorFunc; ValidKeys = new List<Keys> (); IsVisible = true; _isEnabled = true; IsModal = false; IsLocalized = true; State = WidgetState.None; }
/// <summary> /// /// </summary> public ChallengePauseDialog(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder, "Pause") { // Der Titel-Text ist mittig ausgerichtet AlignX = HorizontalAlignment.Center; Bounds.Size = new ScreenPoint (screen, 0.3f, 0.31f); // Erstelle das Pause-Menü pauseMenu = new Menu (Screen, Index + DisplayLayer.Menu); pauseMenu.Bounds = ContentBounds; pauseMenu.ItemAlignX = HorizontalAlignment.Left; pauseMenu.ItemAlignY = VerticalAlignment.Center; MenuEntry settingsButton = new MenuEntry ( screen: Screen, drawOrder: Index + DisplayLayer.MenuItem, name: "Settings", onClick: (time) => { Close (time); Screen.NextScreen = new GeneralSettingsScreen (Screen.Game); } ); MenuEntry backButton = new MenuEntry ( screen: Screen, drawOrder: Index + DisplayLayer.MenuItem, name: "Back to Game", onClick: (time) => { Close (time); } ); backButton.AddKey (Keys.Escape); MenuEntry discardExitButton = new MenuEntry ( screen: Screen, drawOrder: Index + DisplayLayer.MenuItem, name: "Abort Challenge", onClick: (time) => { Close (time); Screen.NextScreen = new StartScreen (Screen.Game); } ); backButton.AddKey (Keys.Escape); pauseMenu.Add (settingsButton); pauseMenu.Add (backButton); pauseMenu.Add (discardExitButton); }
public Dialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { IsVisible = true; Done = () => { IsVisible = false; }; // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (screen.device); // menu WidgetInfo menuInfo = new WidgetInfo (); buttons = new Menu (screen, menuInfo, DisplayLayer.Menu); buttons.ItemForegroundColor = ButtonForegroundColor; buttons.ItemBackgroundColor = ButtonBackgroundColor; buttons.ItemAlignX = HorizontalAlignment.Center; buttons.ItemAlignY = VerticalAlignment.Center; }
protected override void PostDrawObjects(DrawEventArgs e) { // Initialise rendering parameters: RhinoRenderingParameters parameters = new RhinoRenderingParameters(e); // Draw everything: // SalamanderHost.Instance.OrnamentTable.DrawAll(parameters); Core.Instance.Layers.Draw(parameters); // Draw current action preview: if (Core.Instance.Actions.CurrentAction != null) { DisplayLayer previewLayer = Core.Instance.Actions.CurrentAction.PreviewLayer(new Actions.PreviewParameters()); if (previewLayer != null) { previewLayer.Draw(parameters); } } }
/// <summary> /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht. /// [base=screen, drawOrder, title, text] /// </summary> public ColorPickDialog(IScreen screen, DisplayLayer drawOrder, Color selectedColor) : base(screen, drawOrder, "Select a color") { // Die ausgewählte Farbe SelectedColor = selectedColor; // Der Titel-Text ist mittig ausgerichtet AlignX = HorizontalAlignment.Center; // Der Colorpicker colorPicker = new ColorPicker (Screen, Index + DisplayLayer.MenuItem, selectedColor); colorPicker.Bounds.Position = ContentBounds.Position; colorPicker.ColorSelected += OnColorSelected; //TODO //RelativeContentSize = colorPicker.RelativeSize (); // Diese Tasten werden akzeptiert ValidKeys.AddRange (new Keys[] { Keys.Escape }); }
protected override void LoadDisplay() { var xPosition = GameHelper.GetRelativeScaleX(0.5f); var yPosition = GameHelper.GetRelativeScaleY(0.1f); var gameCounter = new GameObject("GameCounter", new Vector2(xPosition - 20, yPosition)); var text = new TextComponent(FontGraphics.DigifontFont_16X16, StringFunc); var playerOneOutput = new TextComponent(FontGraphics.DigifontFont_16X16, PlayerOneFunc, new Vector2(-100, 50)); var playerTwoOutput = new TextComponent(FontGraphics.DigifontFont_16X16, PlayerTwoFunc, new Vector2(100, 50)); gameCounter.AddComponent(text); gameCounter.AddComponent(playerOneOutput); gameCounter.AddComponent(playerTwoOutput); DisplayLayer.AddGameObject(gameCounter); var debugHelper = new GameObject("DebugHelper", new Vector2(xPosition - 100, yPosition * 2)); var collisionDetection = new TextComponent(FontGraphics.DigifontFont_16X16, DebugFunc); debugHelper.AddComponent(collisionDetection); DisplayLayer.AddGameObject(debugHelper); }
protected override void LoadDisplay() { var player = new GameObject("PlayerOneSelection", new Vector2(10, 10)); var playerText = new TextComponent(FontGraphics.PropertialFont_8X8, "PLAYER ONE"); var startText = new TextComponent(FontGraphics.PropertialFont_8X8, "PRESS SPACE TO START", new Vector2(0, 100)); var counter = new CounterComponent(ObjectEvent.PreviousCharacter, ObjectEvent.NextCharacter, 0, _playerCharacters.Count() - 1); var sprites = new SpriteMappingsComponent(RpgGraphics.GameboySpriteMapping, _playerCharacters, new Vector2(10, 50), counter); var nextCharacter = new KeyboardEventComponent(Keys.Right, ObjectEvent.NextCharacter); var previousCharacter = new KeyboardEventComponent(Keys.Left, ObjectEvent.PreviousCharacter); var action = new KeyboardActionComponent(Keys.Space, Action); player.AddComponent(playerText); player.AddComponent(startText); player.AddComponent(counter); player.AddComponent(sprites); player.AddComponent(nextCharacter); player.AddComponent(previousCharacter); player.AddComponent(action); DisplayLayer.AddGameObject(player); }
protected override void LoadDisplay() { var xCentre = GameConstants.ScreenBoundary.Width / 2; var yCentre = GameConstants.ScreenBoundary.Height / 2; var display = new GameObject("Text", new Vector2(xCentre, yCentre)); var font = FontGraphics.PropertialFont_8X8; var textSimpleRpg = new TextComponent(font, "SIMPLE RPG", new Vector2(-75, -25), 2); var textEnter = new TextComponent(font, "PRESS ENTER", new Vector2(-80, 25), 2); var shield = new SpriteMappingComponent(RpgGraphics.GameboySpriteMapping, "Sword10", new Vector2(-250, 0), 3f); var sword = new SpriteMappingComponent(RpgGraphics.GameboySpriteMapping, "Shield10", new Vector2(200, 0), 3f); var action = new KeyboardActionComponent(Keys.Enter, Action); display.AddComponent(textSimpleRpg); display.AddComponent(textEnter); display.AddComponent(shield); display.AddComponent(sword); display.AddComponent(action); DisplayLayer.AddGameObject(display); }
public ConfirmDialog(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { // text Text = new string[] {}; // actions Action onYesClick = () => { OnYesClick (); if (CanClose) { Done (); } }; Action onNoClick = () => { OnNoClick (); Done (); }; Action onCancelClick = () => { OnCancelClick (); Done (); }; // buttons buttons.RelativeItemPosition = RelativeButtonPosition; buttons.RelativeItemSize = RelativeButtonSize; var itemInfo = new MenuItemInfo () { Text = "Yes", OnClick = onYesClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "No", OnClick = onNoClick }; buttons.AddButton (itemInfo); itemInfo = new MenuItemInfo () { Text = "Cancel", OnClick = onCancelClick }; buttons.AddButton (itemInfo); }
public ColorPicker(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { info.BackgroundColor = () => Color.Black; info.ForegroundColor = () => Color.White; info.AlignX = HorizontalAlignment.Left; info.AlignY = VerticalAlignment.Top; // colors colors = new List<Color> (CreateColors (64)); colors.Sort (Utilities.ColorHelper.SortColorsByLuminance); tiles = new List<Vector2> (CreateTiles (colors)); // create a new SpriteBatch, which can be used to draw textures spriteBatch = new SpriteBatch (screen.device); info.RelativePosition = () => (Vector2.One - info.RelativeSize ()) / 2; info.RelativeSize = () => { float sqrt = (float)Math.Ceiling (Math.Sqrt (colors.Count)); return tileSize * sqrt; }; }
protected override void LoadDisplay() { var textX = GameHelper.GetRelativeScaleX(0.2f); var textY = GameHelper.GetRelativeScaleY(0.9f); var playerOne = new GameObject("Text", new Vector2(textX, textY)); var textOne = new TextComponent(FontGraphics.BloxxitFont_8X8, "PRESS SPACE"); var actionOne = new KeyboardActionComponent(Keys.Space, CreatePlayerOne); playerOne.AddComponent(textOne); playerOne.AddComponent(actionOne); DisplayLayer.AddGameObject(playerOne); var playerTwo = new GameObject("Text", new Vector2(textX * 2, textY)); var textTwo = new TextComponent(FontGraphics.BloxxitFont_8X8, "PRESS A GAMEPAD"); var actionTwo = new ButtonActionComponent(Buttons.A, CreatePlayerTwo); playerTwo.AddComponent(textTwo); playerTwo.AddComponent(actionTwo); DisplayLayer.AddGameObject(playerTwo); var playerThree = new GameObject("Text", new Vector2(textX * 3, textY)); var textThree = new TextComponent(FontGraphics.BloxxitFont_8X8, "PRESS ENTER"); var actionThree = new KeyboardActionComponent(Keys.Enter, CreatePlayerThree); playerThree.AddComponent(textThree); playerThree.AddComponent(actionThree); DisplayLayer.AddGameObject(playerThree); var foam = new[] { CommonGraphics.TransparentCubeAsset, CommonGraphics.WhiteCubeAsset, CommonGraphics.BlueCubeAsset, CommonGraphics.LightBlueCubeAsset }; var waveManager = new WaveManager(foam, BackgroundLayer, ForegroundLayer, _waveHeight, _waveTopY, _waveSpeed); DisplayLayer.Managers.Add(waveManager); }
private void CreatePlayerTwo(Vector2 startPosition) { var player = new GameObject("PlayerTwoSelection", new Vector2(10, 10) + startPosition); var playerText = new TextComponent(FontGraphics.PropertialFont_8X8, "PLAYER TWO"); var startText = new TextComponent(FontGraphics.PropertialFont_8X8, "PRESS TAB TO START", new Vector2(0, 100)); var counter = new CounterComponent(ObjectEvent.PreviousCharacter, ObjectEvent.NextCharacter, 0, _playerCharacters.Count() - 1); var sprites = new SpriteMappingsComponent(RpgGraphics.GameboySpriteMapping, _playerCharacters, new Vector2(10, 50), counter); var nextCharacter = new KeyboardEventComponent(Keys.D, ObjectEvent.NextCharacter); var previousCharacter = new KeyboardEventComponent(Keys.A, ObjectEvent.PreviousCharacter); var action = new KeyboardActionComponent(Keys.Tab, Action); player.AddComponent(playerText); player.AddComponent(startText); player.AddComponent(counter); player.AddComponent(sprites); player.AddComponent(nextCharacter); player.AddComponent(previousCharacter); player.AddComponent(action); DisplayLayer.AddGameObject(player); }
protected override void LoadDisplay() { var xCentre = GameHelper.GetRelativeScaleX(0.5f); var yCentre = GameHelper.GetRelativeScaleY(0.5f); var xOffset = GameHelper.GetRelativeScaleX(0.1f); var yOffset = GameHelper.GetRelativeScaleX(0.1f); var display = new GameObject("Title", new Vector2(xCentre, yCentre)); var font = FontGraphics.PropertialFont_8X8; var textSimpleRpg = new TextComponent(font, "DEFENDER", new Vector2(-xOffset, -yOffset), 2); var textEnter = new TextComponent(font, "PRESS ENTER", new Vector2(-xOffset - 10, yOffset), 2); var icon1 = new SpriteComponent(SpaceGraphics.PlayerShipAsset.First(), new Vector2(-xOffset * 2, 0)); var icon2 = new SpriteComponent(SpaceGraphics.EnemyShipAsset.First(), new Vector2(xOffset * 2, 0)); var action = new KeyboardActionComponent(Keys.Enter, Action); display.AddComponent(textSimpleRpg); display.AddComponent(textEnter); display.AddComponent(icon1); display.AddComponent(icon2); display.AddComponent(action); DisplayLayer.AddGameObject(display); }
public Border(IScreen screen, DisplayLayer drawOrder, Widget widget, int lineWidth, int padding, Color lineColor, Color outlineColor) : this(screen, drawOrder, widget.Bounds, lineWidth, padding, lineColor, outlineColor) { OnUpdate += (time) => IsVisible = lines.IsVisible = widget.IsVisible; }
public DrawableGameComponentWrapper(DrawableGameComponent component, IScreen screen, DisplayLayer index) : base(screen, index) { Wrapped = component; }
/// <summary> /// Erzeugt ein neues ConfirmDialog-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge, einer Zeichenkette für den Titel und für den eingeblendeten Text Pflicht. /// [base=screen, drawOrder, title, text] /// </summary> public ConfirmDialog(IScreen screen, DisplayLayer drawOrder, string title) : base(screen, drawOrder, title) { // Der Titel-Text ist mittig ausgerichtet AlignX = HorizontalAlignment.Center; Cancel = (time) => { Close(time); }; Submit = (time) => { Close(time); }; // Keys ValidKeys.AddRange(new Keys[] { Keys.Enter, Keys.Escape }); // Menü, in dem die Textanzeige angezeigt wird menu = new Menu(Screen, Index + DisplayLayer.Menu); menu.Bounds = ContentBounds; menu.ItemForegroundColor = (s) => Color.White; menu.ItemBackgroundColor = (s) => Color.Transparent; menu.ItemAlignX = HorizontalAlignment.Left; menu.ItemAlignY = VerticalAlignment.Center; // Button-Container buttons = new Container(screen, Index + DisplayLayer.Menu); buttons.ItemAlignX = HorizontalAlignment.Center; buttons.ItemBackgroundColor = (s) => Design.DialogBackground; // Button zum Canceln Action <GameTime> cancelAction = (time) => { Cancel(time); }; MenuEntry cancelButton = new MenuEntry( screen: Screen, drawOrder: Index + DisplayLayer.MenuItem, name: "Cancel", onClick: cancelAction ); cancelButton.Bounds.Size = new ScreenPoint(screen, () => ContentBounds.Size.Relative.X / 2, () => 0.05f); cancelButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY - cancelButton.Bounds.Size.OnlyY; buttons.Add(cancelButton); // Button zum Submitten Action <GameTime> submitAction = (time) => { Submit(time); }; MenuEntry submitButton = new MenuEntry( screen: Screen, drawOrder: Index + DisplayLayer.MenuItem, name: "Confirm", onClick: submitAction ); submitButton.Bounds.Size = new ScreenPoint(screen, () => ContentBounds.Size.Relative.X / 2, () => 0.05f); submitButton.Bounds.Position = ContentBounds.Position + ContentBounds.Size.OnlyY - submitButton.Bounds.Size.OnlyY + ContentBounds.Size.OnlyX / 2; buttons.Add(submitButton); // Buttons zum Menü hinzufügen menu.Add(buttons); }
public KeyBindingListener(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { }
public Menu(GameScreen screen, WidgetInfo info, DisplayLayer drawOrder) : base(screen, info, drawOrder) { Items = new List<MenuItem> (); }
public Lines(IScreen screen, DisplayLayer drawOrder, int lineWidth) : this(screen, drawOrder, lineWidth, Design.DefaultLineColor, Design.DefaultOutlineColor) { }
public Lines(IScreen screen, DisplayLayer drawOrder, int lineWidth) : this(screen, drawOrder, lineWidth, Design.DefaultLineColor, Design.DefaultOutlineColor) { }
public KeyBindingListener(IScreen screen, DisplayLayer drawOrder) : base(screen, drawOrder) { }
/// <summary> /// Erzeugt ein neues MenuButton-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge, einer Zeichenkette für den Namen der Schaltfläche /// und der Aktion, welche bei einem Klick ausgeführt wird Pflicht. /// </summary> public MenuEntry(IScreen screen, DisplayLayer drawOrder, string name, Action<GameTime> onClick) : base(screen, drawOrder, name) { IsSelectable = false; OnClick = onClick; }
public Border(IScreen screen, DisplayLayer drawOrder, Widget widget) : this(screen: screen, drawOrder: drawOrder, widget: widget, lineWidth: 2, padding: 0) { }
public Border(IScreen screen, DisplayLayer drawOrder, Bounds bounds, int lineWidth, int padding) : this(screen: screen, drawOrder: drawOrder, bounds: bounds, lineWidth: lineWidth, padding: lineWidth, lineColor: Design.DefaultLineColor, outlineColor: Design.DefaultOutlineColor) { }
public Border(IScreen screen, DisplayLayer drawOrder, Widget widget, int lineWidth, int padding) : this(screen: screen, drawOrder: drawOrder, widget: widget, lineWidth: lineWidth, padding: lineWidth, lineColor: Design.DefaultLineColor, outlineColor: Design.DefaultOutlineColor) { }
/// <summary> /// Erzeugt ein neues MenuButton-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angabe der Zeichenreihenfolge, einer Zeichenkette für den Namen der Schaltfläche /// und der Aktion, welche bei einem Klick ausgeführt wird Pflicht. /// </summary> public MenuEntry(IScreen screen, DisplayLayer drawOrder, string name, Action <GameTime> onClick) : base(screen, drawOrder, name) { IsSelectable = false; OnClick = onClick; }
/// <summary> /// Erzeugt ein neues CheckBoxItem-Objekt und initialisiert dieses mit dem zugehörigen IGameScreen-Objekt. /// Zudem sind Angaben zur Zeichenreihenfolge und der Auswahloption Pflicht. /// </summary> public CheckBoxItem(IScreen screen, DisplayLayer drawOrder, string text, BooleanOption option) : base(screen, drawOrder, text) { this.option = option; currentValue = option.Value; }