public int AddItem(Object item, ProgrammingElement param) { int idx = items.Count; items.Add(new ItemData(item, param)); return(idx); }
public int AddGroup(Object item, ProgrammingElement param, UiSelector selectorGroup) { int idx = items.Count; items.Add(new GroupData(item, param, selectorGroup)); return(idx); }
protected void ChangeCard(ReflexCard reflexCard, ProgrammingElement pendingCard) { CleanseDependantCards(reflexCard, pendingCard); // find all cards that are effected after it // remove the cards from listControls // remove the clause repeat from the clause list // animate the cards collapsing // animate the clause repeat collapsing // animate the clause right collapsing }
protected void CleanseDependantCards(ReflexCard reflexCard, ProgrammingElement pendingCard) { ReflexData clip = reflex.Copy(); if (reflexCard.cardType == CardSpace.CardType.Sensor) { if (pendingCard != null) { clip.Sensor = pendingCard as Sensor; } else { clip.Sensor = null; } } if (reflexCard.cardType == CardSpace.CardType.Actuator) { // Kind of a hack here to deal with mixing Switch and Inline. If either // of these actuators are removed and replaced with the other then we need // to clear the Modifier list to prevent loops and self-referential inlines. if (pendingCard != null && reflexCard != null) { if ((pendingCard.upid == "actuator.inlinetask" && reflexCard.Card.upid == "actuator.switchtask") || (pendingCard.upid == "actuator.switchtask" && reflexCard.Card.upid == "actuator.inlinetask")) { clip.Modifiers.Clear(); } } if (pendingCard != null) { clip.Actuator = pendingCard as Actuator; } else { clip.Actuator = null; } } if (reflexCard.cardType == CardSpace.CardType.Selector) { if (pendingCard != null) { clip.Selector = pendingCard as Selector; } else { clip.Selector = null; } } reflex.Paste(clip); }
protected void AddCard(Matrix local, ProgrammingElement element, CardSpace.CardType cardType, ControlRenderObj renderClause) { ReflexCard card = new ReflexCard(this, reflex, element, cardType, controls); card.renderClause = renderClause; ITransform transformCard = card as ITransform; Matrix anchor = card.Anchor(true); // invert the anchor to apply to its owner transformCard.Local.Matrix = local * anchor; // *shiftOutOfSocket; transformCard.Compose(); listControls.Add(card); card.Change += CardChanged; }
public static bool IsMicrobitTile(ProgrammingElement progElement) { if (progElement == null) { return(false); } if (progElement is IMicrobitTile) { return(true); } foreach (string upid in microbitActuatorUpids) { if (progElement.upid == upid) { return(true); } } return(false); }
protected void CardChanged(ReflexCard reflexCard, ProgrammingElement pendingCard) { this.uiRebuild = true; BokuGame.objectListDirty = true; if (pendingCard == null) { // deleted DeleteCard(reflexCard); } else if (reflexCard.Card.upid == ProgrammingElement.upidNull) { // new addition //AppendCard(reflexCard); } else { // just a change reflex.Data.CompactModifiers(); ChangeCard(reflexCard, pendingCard); } }
private void BuildSlices() { ProgrammingElement el = null; ///--------------------- /// float circumferenceAtItems = 5.0f + slices.Count / 6.0f; float maxItemRadius = 0.5f + slices.Count / 40.0f; const float radiusAtItemSpacing = 0.2f; // calculate layout information from items // depreciated.... //CalcLayoutInfoFromItems(out circumferenceAtItems, out maxItemRadius); // calc radius of the pie this.radiusAtItems = circumferenceAtItems / MathHelper.TwoPi + radiusAtItemSpacing; float spacingCircumference = 0.0f; // spacing between items on the circumference // adjust spacing if radius is smaller than the inner radius (one item) if (this.radiusAtItems < maxItemRadius * 2.0f) { // radius is too small, must increase this.radiusAtItems = maxItemRadius * 2.0f + radiusAtItemSpacing; // and provide the extra spacing between items on the circumference float newCircumference = MathHelper.TwoPi * this.radiusAtItems; spacingCircumference = (newCircumference - circumferenceAtItems) / slices.Count; circumferenceAtItems = newCircumference; } float radiusInside = maxItemRadius * 1.2f; // with a little spacing float radiusOutside = this.radiusAtItems + (maxItemRadius * 1.2f); // with a little spacing float arcLength = MathHelper.TwoPi / slices.Count; Vector2 posUV = Vector2.Zero; Matrix invWorld = Matrix.Invert(worldMatrix); Fugly fuglyTransform = new Fugly(); for (int indexItem = 0; indexItem < slices.Count; indexItem++) { ReflexCard reflex = slices[indexItem].MenuItem as ReflexCard; if (reflex != null) { el = reflex.Reflex.Sensor; } float rot = MathHelper.PiOver2 - indexItem * arcLength; // slices[indexItem].mySlice = BuildPieSlice(el, arcLength, radiusInside, radiusOutside); slices[indexItem].mySlice = BuildPieSlice(slices[indexItem].sliceType, arcLength, radiusInside, radiusOutside); innerRadius = radiusInside; outerRadius = radiusOutside; // create a slice for every item ITransform transformSlice = slices[indexItem].mySlice as ITransform; // rotate the slice into place transformSlice.Local.OriginTranslation = SliceOffsetDefault; // move away from center to space them transformSlice.Local.RotationZ = rot; transformSlice.Compose(); // setting position for the icon.... Matrix rotation = Matrix.CreateRotationZ(rot); Vector3 fixRotation = new Vector3(radiusInside + (radiusOutside - radiusInside) * 0.6f, 0.0f, 0.0f); slices[indexItem].Position = camera.WorldToScreenCoordsVector2(Vector3.Transform(fixRotation, rotation)); slices[indexItem].Position -= slices[indexItem].WhenBlockSize / 2; } }
public ItemData(Object item, ProgrammingElement progElement) { this.item = item; this.progElement = progElement; }
public GroupData(Object item, ProgrammingElement param, UiSelector selectorGroup) : base(item, param) { this.selectorGroup = selectorGroup; }
protected void CreateCards(string idState) { // create handle // ReflexHandle reflexHandle = new ReflexHandle(this, reflex, controls); ITransform transformHandle = reflexHandle as ITransform; Matrix anchor; renderPanel.GetPositionTransform(idRowHandleAnchor, out anchor); transformHandle.Local.Matrix = anchor; transformHandle.Compose(); listControls.Add(reflexHandle); Matrix chain; renderPanel.GetPositionTransform(idLeftClauseAnchor, out chain); Matrix clauseOffset = Matrix.Identity; { Matrix leftClause; Matrix rightClause; renderPanel.GetPositionTransform(idLeftClauseAnchor, out leftClause); renderPanel.GetPositionTransform(idRightClauseAnchor, out rightClause); clauseOffset.Translation = rightClause.Translation - leftClause.Translation; } Matrix local; // create the begining of the when clause trays // chain = AddClauseLeft(this.listWhenClause, chain, idWhenClause, idState); // create cards for when clause // //Matrix shiftOutOfSocket = Matrix.CreateTranslation(new Vector3(0.0f, 0.0f, 0.05f)); CardSpace.CardType plusType = CardSpace.CardType.Sensor; ProgrammingElement plusElement = CardSpace.Cards.NullSensor; if (reflex.Sensor != null) { chain = AddClauseRepeat(this.listWhenClause, out local, chain, idWhenClause, idState); AddCard(local, reflex.Sensor, CardSpace.CardType.Sensor, this.listWhenClause[this.listWhenClause.Count - 1] as ControlRenderObj); plusType = CardSpace.CardType.Filter; plusElement = CardSpace.Cards.NullFilter; } if (reflex.RawFilters != null) { for (int iFilter = 0; iFilter < reflex.RawFilters.Count; iFilter++) { Filter filter = reflex.RawFilters[iFilter] as Filter; chain = AddClauseRepeat(this.listWhenClause, out local, chain, idWhenClause, idState); AddCard(local, filter, CardSpace.CardType.Filter, this.listWhenClause[this.listWhenClause.Count - 1] as ControlRenderObj); } } // create the end of the when clause chain = AddClauseRight(this.listWhenClause, out local, chain, idWhenClause, idState); if (ReflexCard.HasSelectableElements(reflex, plusType)) { // add the ever present + with context AddCard(local, plusElement, plusType, this.listWhenClause[this.listWhenClause.Count - 1] as ControlRenderObj); } // adjust for next clause chain *= clauseOffset; // create the begining of the do clause trays // chain = AddClauseLeft(this.listDoClause, chain, idDoClause, idState); plusType = CardSpace.CardType.Actuator; plusElement = CardSpace.Cards.NullActuator; if (reflex.Actuator != null) { chain = AddClauseRepeat(this.listDoClause, out local, chain, idDoClause, idState); AddCard(local, reflex.Actuator, CardSpace.CardType.Actuator, this.listDoClause[this.listDoClause.Count - 1] as ControlRenderObj); // Specify Selector type here, since selector menu will pull in modifiers as well. plusType = CardSpace.CardType.Selector; plusElement = CardSpace.Cards.NullSelector; } if (reflex.Selector != null && !reflex.Selector.hiddenDefault) { chain = AddClauseRepeat(this.listDoClause, out local, chain, idDoClause, idState); AddCard(local, reflex.Selector, CardSpace.CardType.Selector, this.listDoClause[this.listDoClause.Count - 1] as ControlRenderObj); // Specify Selector type here, since selector menu will pull in modifiers as well. plusType = CardSpace.CardType.Selector; plusElement = CardSpace.Cards.NullSelector; } if (reflex.Modifiers != null) { for (int iModifier = 0; iModifier < reflex.Modifiers.Count; iModifier++) { Modifier modifier = reflex.Modifiers[iModifier] as Modifier; chain = AddClauseRepeat(this.listDoClause, out local, chain, idDoClause, idState); AddCard(local, modifier, CardSpace.CardType.Modifier, this.listDoClause[this.listDoClause.Count - 1] as ControlRenderObj); } } // create the end of the do clause chain = AddClauseRight(this.listDoClause, out local, chain, idDoClause, idState); CardSpace.CardType cardTypeMask; if (reflex.Actuator == null) { cardTypeMask = CardSpace.CardType.Actuator; } else if (reflex.Selector == null && reflex.Modifiers.Count == 0) { cardTypeMask = CardSpace.CardType.Selector | CardSpace.CardType.Modifier; } else if (reflex.Selector == null && reflex.Modifiers.Count == 1 && this.ActiveCard > 0 && this.ActiveCard < this.listControls.Count && this.listControls[this.ActiveCard] is ReflexCard) { cardTypeMask = CardSpace.CardType.Modifier; if ((this.listControls[this.ActiveCard] as ReflexCard).Card is Modifier) { cardTypeMask |= CardSpace.CardType.Selector; } } else { cardTypeMask = CardSpace.CardType.Modifier; } if (ReflexCard.HasSelectableElements(reflex, cardTypeMask)) { // HACK HACK If use has DO Move Freeze this will still add a '+' to the // end because it thinks that a selector is still a possibility. The // proper solution is to either make Freeze a selector or, better yet, // do away with selectors altogether. if (reflex.modifierUpids.Length == 0 || reflex.modifierUpids[0] != "modifier.constraint.immobile") { // add the + with context AddCard(local, plusElement, plusType, this.listDoClause[this.listDoClause.Count - 1] as ControlRenderObj); } } for (int indexClause = 0; indexClause < this.listWhenClause.Count; indexClause++) { ControlRenderObj renderObj = this.listWhenClause[indexClause] as ControlRenderObj; renderObj.Activate(); renderPanel.renderList.Add(renderObj); } for (int indexClause = 0; indexClause < this.listDoClause.Count; indexClause++) { ControlRenderObj renderObj = this.listDoClause[indexClause] as ControlRenderObj; renderObj.Activate(); renderPanel.renderList.Add(renderObj); } for (int indexCard = 0; indexCard < this.listControls.Count; indexCard++) { GameObject gameObjCard = this.listControls[indexCard] as GameObject; gameObjCard.Activate(); gameObjCard.Refresh(updateObjEditCards.updateList, renderPanel.renderList); } }