/// <summary> Will remove this Drawable from whatever que it is a member of</summary> internal void removeFromQue() { if (nextDrawable != null) { //middle of que if (previousDrawable != null) { nextDrawable.previousDrawable = this.previousDrawable; previousDrawable.nextDrawable = this.nextDrawable; } //start of que else { nextDrawable.previousDrawable = previousDrawable; } } //end of que else if (previousDrawable != null) { previousDrawable.nextDrawable = nextDrawable; } previousDrawable = null; nextDrawable = null; currentDrawSet = null; movedInDrawSet(); }
/// <summary> /// Will Add this Drawable and all of the Drawables that come after it /// to the queue directly after the specified item /// </summary> /// <param name="previousItem"></param> internal void addListToQueue(Drawable previousItem) { if (previousItem != null) { //Find LastNode and update nodes all nodes in list Drawable lastNode = this; while (lastNode.nextDrawable != null) { lastNode = lastNode.nextDrawable; lastNode.currentDrawSet = previousItem.currentDrawSet; lastNode.priority = previousItem.priority; movedInDrawSet(); } //disconnect from previous node if (previousDrawable != null) { previousDrawable.nextDrawable = null; } //update self previousDrawable = previousItem; lastNode.nextDrawable = previousItem.nextDrawable; currentDrawSet = previousItem.currentDrawSet; priority = previousItem.priority; } movedInDrawSet(); }
/// <summary> /// Will attempt to add this Drawable to the given DrawSet. /// </summary> /// <param name="targetDrawSet">The DrawSet this object will be added to. /// Note, if this objects priority is not within the targetDrawSet's range of available priorities it will be adjusted to to the closest one</param> /// <returns>If True, this was successfully added to the drawSet, if false no changes were made</returns> public bool addToDrawSet(DrawSet targetDrawSet) { if (targetDrawSet != null && (currentDrawSet == null || targetDrawSet != currentDrawSet)) { if (currentDrawSet != null) { removeFromDrawSet(); } return(targetDrawSet.addToDrawSet(this)); } return(false); }
/// <summary> /// Will set this object priority. /// Priority is used to determine draw order, higher priority items are drawn first, lower priority items are drawn last. /// Priority is represented by an inteteger value ranging from zero to the max priority /// maxpriority is determined by the /// </summary> /// <returns>If True the prioirity was changed successfully, otherwise returns false</returns> public bool setPriority(int newPriority) { if (newPriority >= 0 && (currentDrawSet == null || newPriority < currentDrawSet.getAvailablePriorities())) { priority = newPriority; if (currentDrawSet != null) { DrawSet drawSet = currentDrawSet; removeFromDrawSet(); drawSet.addToDrawSet(this); } return(true); } return(false); }
/// <summary>Will add this Drawable Object to que governed by the given nullItem</summary> /// <param name="firstItem"> The FirstDrawable Item in the Que that does not actualy Draw anything</param> internal void addToQueue(Drawable previousItem) { if (previousItem != null) { if (nextDrawable != null || previousDrawable != null) { removeFromQue(); } //update self nextDrawable = previousItem.nextDrawable; if (nextDrawable != null) { nextDrawable.previousDrawable = this; } previousItem.nextDrawable = this; previousDrawable = previousItem; currentDrawSet = previousItem.currentDrawSet; priority = previousItem.priority; movedInDrawSet(); } }
/// <summary> /// Will reset this Drawables currentDrawSet and priority to the following /// Note, No error checks are made by this function /// </summary> /// <param name="newDrawSet"></param> /// <param name="priority"></param> protected internal void setDrawSet(DrawSet newDrawSet, int newPriority) { currentDrawSet = newDrawSet; this.priority = newPriority; }