private static WidgetNode LinkWidgetNodeToList(WidgetNode list, WidgetNode node) { if (list == null || WidgetNode.Before(node, list)) { if (list != null) { list.Prev = node; } node.Next = list; return(node); } else { var n = list; for (; n.Next != null && WidgetNode.Before(n.Next, node); n = n.Next) { ; } node.Prev = n; node.Next = n.Next; if (n.Next != null) { n.Next.Prev = node; } n.Next = node; return(list); } }
public static bool Before(WidgetNode a, WidgetNode b) { if (a.DependenceCount == b.DependenceCount) { return(a.Widget.GetInstanceID() < b.Widget.GetInstanceID()); } return(a.DependenceCount < b.DependenceCount); }
public override Node Visit(WidgetNode node) { if (_widgetNodeExpectations.Count > 0) { _widgetNodeExpectations.Dequeue().Invoke(node); } return(VisitChildren(node)); }
private static WidgetNode AdjustWidgetNodePosInList(WidgetNode list, WidgetNode node) { if ((node.Prev != null && WidgetNode.Before(node, node.Prev)) || (node.Next != null && WidgetNode.Before(node.Next, node))) { list = UnlinkWidgetNodeFromList(list, node); list = LinkWidgetNodeToList(list, node); } return(list); }
public override object Visit(WidgetNode node) { var options = new List <string>(); foreach (var option in node.ChildNodes) { options.Add(option.Accept(this).ToString()); } return(new WidgetData(node.Widget, options.FirstOrDefault() ?? Resources.Yes, options.Skip(1).FirstOrDefault() ?? Resources.No)); }
private static void FindBestSolution(WidgetNode nodeList, ComplexMaterial lastMaterial, int drawCall, List <UIWidget> result, ref int bestDrawCall, List <UIWidget> bestResult, int stopDrawCall) { if (drawCall >= bestDrawCall) { return; } if (nodeList == null) { if (drawCall < bestDrawCall) { bestDrawCall = drawCall; bestResult.Clear(); bestResult.AddRange(result); } return; } var bestNodes = (from node in GetTopWidgetNodesOfList(nodeList) where node.Material == lastMaterial select node).Take(1); if (!bestNodes.Any()) { bestNodes = from node in GetTopWidgetNodesOfList(nodeList) group node by node.Material into g select g.First(); } foreach (var node in bestNodes.ToArray()) { nodeList = UnlinkWidgetNodeFromList(nodeList, node); foreach (var reverseNode in node.ReverseDependences) { --reverseNode.DependenceCount; nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode); } result.Add(node.Widget); FindBestSolution(nodeList, node.Material, lastMaterial == node.Material ? drawCall : drawCall + 1, result, ref bestDrawCall, bestResult, stopDrawCall); result.RemoveAt(result.Count - 1); foreach (var reverseNode in node.ReverseDependences) { ++reverseNode.DependenceCount; nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode); } nodeList = LinkWidgetNodeToList(nodeList, node); if (bestDrawCall == stopDrawCall) { break; } } }
public override Node Visit(WidgetNode node) { var question = _questionTypes.Peek(); var matchingQLSymbol = _symbolTable[question.Label]; if (!node.Widget.IsCompatibleWith(matchingQLSymbol.Type)) { TypeErrors.Add(new WidgetNotCompatible(question.Label, matchingQLSymbol.Type.ToString(), node.Widget.ToString(), node.Token.Line)); } return(VisitChildren(node)); }
public override Node VisitWidget_type([NotNull] Widget_typeContext context) { if (context.option_widget() != null) { var widgetNode = new WidgetNode(context.Start, WidgetFactory.FromTokenToWidgetType(context.Start)); if (context.option().Length == 2) { widgetNode.AddChild(Visit(context.option(0))); widgetNode.AddChild(Visit(context.option(1))); } return(widgetNode); } return(new WidgetNode(context.Start, WidgetFactory.FromTokenToWidgetType(context.Start))); }
private static List <WidgetNode> GetTopWidgetNodesOfList(WidgetNode list) { var result = new List <WidgetNode>(); if (list != null) { var dependenceCount = list.DependenceCount; for (; list != null && list.DependenceCount == dependenceCount; list = list.Next) { result.Add(list); } result.Sort((a, b) => UIWidget.PanelCompareFunc(a.Widget, b.Widget)); } return(result); }
private static WidgetNode UnlinkWidgetNodeFromList(WidgetNode list, WidgetNode node) { if (list == node) { list = node.Next; } if (node.Prev != null) { node.Prev.Next = node.Next; } if (node.Next != null) { node.Next.Prev = node.Prev; } node.Prev = node.Next = null; return(list); }
public static void CalculateDepthForWidgets(UIWidget[] widgets) { var widget2Node = new Dictionary <UIWidget, WidgetNode>(); WidgetNode nodeList = null; foreach (var w in widgets) { var node = new WidgetNode { Widget = w, Material = new ComplexMaterial(w.material, w.mainTexture, w.shader), }; widget2Node[w] = node; } foreach (var node in widget2Node.Values) { var dependences = node.Widget.GetComponent <DepthCalculator>() ? node.Widget.GetComponent <DepthCalculator>().Dependences : new List <UIWidget>(); node.DependenceCount = dependences.Count; foreach (var w in dependences) { widget2Node[w].ReverseDependences.Add(node); } nodeList = LinkWidgetNodeToList(nodeList, node); } if (nodeList == null) { return; } var bestResult = new List <UIWidget>(); int bestDrawCall = int.MaxValue; var stopDrawCall = widget2Node.Values.Select(n => n.Material).Distinct().Count(); FindBestSolution(nodeList, null, 0, new List <UIWidget>(), ref bestDrawCall, bestResult, stopDrawCall); for (var i = 0; i < bestResult.Count; ++i) { bestResult[i].depth = i; } }
public LobbyPopup(Game game, string userData) { _packageContentManager = new PackageContentManager(game, game.Platform.FileSystem.AssetStorage.CreateBinaryPackage("lobby.bip", true)); View = _packageContentManager.Load <AbstractNode>("sceneLobbyPopup.object"); _soundBtn = View.FindById <WidgetNode>("SoundContainer"); _nameTxt = View.FindById <BitmapTextNode>("NameTxt"); _scoresTxt = View.FindById <BitmapTextNode>("ScoresTxt"); _backBtn = View.FindById <ButtonNode>("backBtn"); _lvlOneBtn = View.FindById <ButtonNode>("LevelOneBtn"); _lvlTwoBtn = View.FindById <ButtonNode>("LevelTwoBtn"); _lvlThreeBtn = View.FindById <ButtonNode>("LevelThreeBtn"); _lvlFourBtn = View.FindById <ButtonNode>("LevelFourBtn"); _lvlFiveBtn = View.FindById <ButtonNode>("LevelFiveBtn"); _lvlSixBtn = View.FindById <ButtonNode>("LevelSixBtn"); _lvlSevenBtn = View.FindById <ButtonNode>("LevelSevenBtn"); _lvlEightBtn = View.FindById <ButtonNode>("LevelEightBtn"); View.PostToStateMachine(new ParamEvent <string>("showLobbyPopup")); _nameTxt.TextLineRenderer.Text = userData; _backBtn.Clicked += backBtn_isClicked; }
public static void CalculateDepthForWidgets(UIWidget[] widgets) { var widget2Node = new Dictionary<UIWidget, WidgetNode>(); WidgetNode nodeList = null; foreach (var w in widgets) { var node = new WidgetNode { Widget = w, Material = new ComplexMaterial(w.material, w.mainTexture, w.shader), }; widget2Node[w] = node; } foreach (var node in widget2Node.Values) { var dependences = node.Widget.GetComponent<DepthCalculator>() ? node.Widget.GetComponent<DepthCalculator>().Dependences : new List<UIWidget>(); node.DependenceCount = dependences.Count; foreach (var w in dependences) { widget2Node[w].ReverseDependences.Add(node); } nodeList = LinkWidgetNodeToList(nodeList, node); } if (nodeList == null) return; var bestResult = new List<UIWidget>(); int bestDrawCall = int.MaxValue; var stopDrawCall = widget2Node.Values.Select(n => n.Material).Distinct().Count(); FindBestSolution(nodeList, null, 0, new List<UIWidget>(), ref bestDrawCall, bestResult, stopDrawCall); for (var i = 0; i < bestResult.Count; ++i) bestResult[i].depth = i; }
public ITUWidget CreateITUWidget() { ITUWheel wheel = new ITUWheel(); wheel.type = ITUWidgetType.ITU_WHEEL; wheel.name = this.Name; wheel.flags |= this.TabStop ? ITU.ITU_TAPSTOP : 0; wheel.flags |= this.Touchable ? ITU.ITU_TOUCHABLE : 0; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this); wheel.visible = (bool)properties["Visible"].GetValue(this); wheel.active = false; wheel.dirty = false; wheel.alpha = 255; wheel.tabIndex = this.TabIndex; wheel.rect.x = this.Location.X; wheel.rect.y = this.Location.Y; wheel.rect.width = this.Size.Width; wheel.rect.height = this.Size.Height; wheel.color.alpha = this.BackAlpha; wheel.color.red = this.BackColor.R; wheel.color.green = this.BackColor.G; wheel.color.blue = this.BackColor.B; wheel.bound.x = 0; wheel.bound.y = 0; wheel.bound.width = 0; wheel.bound.height = 0; /* * for (int i = 0; i < this.ItemCount / 2; i++) * { * ITUText text = new ITUText(); * * text.flags = ITU.ITU_CLIP_DISABLED; * text.name = ""; * text.visible = true; * text.active = false; * text.dirty = text.visible ? true : false; * text.alpha = 255; * text.rect.x = 0; * text.rect.y = 0; * text.rect.width = this.Size.Width; * text.rect.height = this.ItemHeight; * text.color.alpha = this.ForeColor.A; * text.color.red = this.ForeColor.R; * text.color.green = this.ForeColor.G; * text.color.blue = this.ForeColor.B; * text.bound.x = 0; * text.bound.y = 0; * text.bound.width = 0; * text.bound.height = 0; * text.bgColor.alpha = 0; * text.bgColor.red = 0; * text.bgColor.green = 0; * text.bgColor.blue = 0; * text.fontHeight = (int)this.Font.SizeInPoints; * text.fontIndex = this.FontIndex; * * string[] texts = new string[] { "" }; * text.stringSet = ITU.CreateStringSetNode(texts); * * switch (this.TextAlign) * { * case ContentAlignment.BottomLeft: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_LEFT; * break; * * case ContentAlignment.MiddleLeft: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_LEFT; * break; * * case ContentAlignment.TopLeft: * text.layout = ITULayout.ITU_LAYOUT_TOP_LEFT; * break; * * case ContentAlignment.BottomCenter: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_CENTER; * break; * * case ContentAlignment.MiddleCenter: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_CENTER; * break; * * case ContentAlignment.TopCenter: * text.layout = ITULayout.ITU_LAYOUT_TOP_CENTER; * break; * * case ContentAlignment.BottomRight: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_RIGHT; * break; * * case ContentAlignment.MiddleRight: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_RIGHT; * break; * * case ContentAlignment.TopRight: * text.layout = ITULayout.ITU_LAYOUT_TOP_RIGHT; * break; * * default: * text.layout = ITULayout.ITU_LAYOUT_DEFAULT; * break; * } * WidgetNode node = new WidgetNode(); * node.widget = text; * wheel.items.Add(node); * } */ int index = 0; foreach (object item in this.Items) { ITUText text = new ITUText(); text.flags = ITU.ITU_CLIP_DISABLED; text.name = ""; text.visible = true; text.active = false; text.dirty = false; text.alpha = 255; text.rect.x = 0; text.rect.y = 0; text.rect.width = this.Size.Width; text.rect.height = this.ItemHeight; text.color.alpha = this.ForeColor.A; text.color.red = this.ForeColor.R; text.color.green = this.ForeColor.G; text.color.blue = this.ForeColor.B; text.bound.x = 0; text.bound.y = 0; text.bound.width = 0; text.bound.height = 0; text.bgColor.alpha = 0; text.bgColor.red = 0; text.bgColor.green = 0; text.bgColor.blue = 0; text.fontWidth = (int)Math.Round(this.Font.Size * (this.Font.FontFamily.GetCellAscent(FontStyle.Regular) + this.Font.FontFamily.GetCellDescent(FontStyle.Regular)) / this.Font.FontFamily.GetEmHeight(FontStyle.Regular)); text.fontHeight = text.fontWidth; text.fontIndex = this.FontIndex; if (base.Font.Bold) { text.textFlags |= ITUText.ITU_TEXT_BOLD; } text.boldSize = this.BoldSize; string[] texts = new string[8]; texts[0] = item.ToString(); if (this.Items1.Count > index) { texts[1] = this.Items1[index].ToString(); } if (this.Items2.Count > index) { texts[2] = this.Items2[index].ToString(); } if (this.Items3.Count > index) { texts[3] = this.Items3[index].ToString(); } if (this.Items4.Count > index) { texts[4] = this.Items4[index].ToString(); } if (this.Items5.Count > index) { texts[5] = this.Items5[index].ToString(); } if (this.Items6.Count > index) { texts[6] = this.Items6[index].ToString(); } if (this.Items7.Count > index) { texts[7] = this.Items7[index].ToString(); } text.stringSet = ITU.CreateStringSetNode(texts); switch (this.TextAlign) { case ContentAlignment.BottomLeft: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_LEFT; break; case ContentAlignment.MiddleLeft: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_LEFT; break; case ContentAlignment.TopLeft: text.layout = ITULayout.ITU_LAYOUT_TOP_LEFT; break; case ContentAlignment.BottomCenter: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_CENTER; break; case ContentAlignment.MiddleCenter: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_CENTER; break; case ContentAlignment.TopCenter: text.layout = ITULayout.ITU_LAYOUT_TOP_CENTER; break; case ContentAlignment.BottomRight: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_RIGHT; break; case ContentAlignment.MiddleRight: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_RIGHT; break; case ContentAlignment.TopRight: text.layout = ITULayout.ITU_LAYOUT_TOP_RIGHT; break; default: text.layout = ITULayout.ITU_LAYOUT_DEFAULT; break; } WidgetNode node = new WidgetNode(); node.widget = text; wheel.items.Add(node); index++; } /* * for (int i = 0; i < this.ItemCount / 2; i++) * { * ITUText text = new ITUText(); * * text.flags = ITU.ITU_CLIP_DISABLED; * text.name = ""; * text.visible = true; * text.active = false; * text.dirty = text.visible ? true : false; * text.alpha = 255; * text.rect.x = 0; * text.rect.y = 0; * text.rect.width = this.Size.Width; * text.rect.height = this.ItemHeight; * text.color.alpha = this.ForeColor.A; * text.color.red = this.ForeColor.R; * text.color.green = this.ForeColor.G; * text.color.blue = this.ForeColor.B; * text.bound.x = 0; * text.bound.y = 0; * text.bound.width = 0; * text.bound.height = 0; * text.bgColor.alpha = 0; * text.bgColor.red = 0; * text.bgColor.green = 0; * text.bgColor.blue = 0; * text.fontHeight = (int)this.Font.SizeInPoints; * text.fontIndex = this.FontIndex; * * string[] texts = new string[] { "" }; * text.stringSet = ITU.CreateStringSetNode(texts); * * switch (this.TextAlign) * { * case ContentAlignment.BottomLeft: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_LEFT; * break; * * case ContentAlignment.MiddleLeft: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_LEFT; * break; * * case ContentAlignment.TopLeft: * text.layout = ITULayout.ITU_LAYOUT_TOP_LEFT; * break; * * case ContentAlignment.BottomCenter: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_CENTER; * break; * * case ContentAlignment.MiddleCenter: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_CENTER; * break; * * case ContentAlignment.TopCenter: * text.layout = ITULayout.ITU_LAYOUT_TOP_CENTER; * break; * * case ContentAlignment.BottomRight: * text.layout = ITULayout.ITU_LAYOUT_BOTTOM_RIGHT; * break; * * case ContentAlignment.MiddleRight: * text.layout = ITULayout.ITU_LAYOUT_MIDDLE_RIGHT; * break; * * case ContentAlignment.TopRight: * text.layout = ITULayout.ITU_LAYOUT_TOP_RIGHT; * break; * * default: * text.layout = ITULayout.ITU_LAYOUT_DEFAULT; * break; * } * WidgetNode node = new WidgetNode(); * node.widget = text; * wheel.items.Add(node); * } */ wheel.focusColor.alpha = this.FocusColor.A; wheel.focusColor.red = this.FocusColor.R; wheel.focusColor.green = this.FocusColor.G; wheel.focusColor.blue = this.FocusColor.B; wheel.normalColor.alpha = this.ForeColor.A; wheel.normalColor.red = this.ForeColor.R; wheel.normalColor.green = this.ForeColor.G; wheel.normalColor.blue = this.ForeColor.B; wheel.tempy = 0; wheel.shift_one = 0; wheel.sliding = 0; wheel.scal = 0; wheel.moving_step = 0; wheel.inside = 0; wheel.slide_step = 2; //this.Speed; wheel.slide_itemcount = 0; // this.SlideCount; wheel.idle = 0; wheel.focusIndex = this.FocusIndex; wheel.itemCount = 7; // this.ItemCount; wheel.totalframe = this.TotalFrame; if (this.Draggable) { wheel.flags |= ITU.ITU_DRAGGABLE; } wheel.fontHeight = (int)this.Font.SizeInPoints; wheel.focusFontHeight = this.FocusFontHeight; if (this.Cycle) { wheel.cycle_tor = 1; } else { wheel.cycle_tor = 0; } wheel.cycle_arr_count = 0; wheel.maxci = 0; wheel.minci = 0; wheel.layout_ci = 0; wheel.fix_count = 0; wheel.focus_c = 0; wheel.focus_dev = 0; if (this.FontSquare) { wheel.fontsquare = 1; } else { wheel.fontsquare = 0; } for (int i = 0; i < ITU.ITU_WHEEL_CYCLE_ARR_LIMIT; i++) { wheel.cycle_arr[i] = 0; } wheel.actions[0].action = (ITUActionType)this.Action01.Action; wheel.actions[0].ev = (ITUEvent)this.Action01.Event; wheel.actions[0].target = this.Action01.Target; wheel.actions[0].param = this.Action01.Parameter; wheel.actions[1].action = (ITUActionType)this.Action02.Action; wheel.actions[1].ev = (ITUEvent)this.Action02.Event; wheel.actions[1].target = this.Action02.Target; wheel.actions[1].param = this.Action02.Parameter; wheel.actions[2].action = (ITUActionType)this.Action03.Action; wheel.actions[2].ev = (ITUEvent)this.Action03.Event; wheel.actions[2].target = this.Action03.Target; wheel.actions[2].param = this.Action03.Parameter; wheel.actions[3].action = (ITUActionType)this.Action04.Action; wheel.actions[3].ev = (ITUEvent)this.Action04.Event; wheel.actions[3].target = this.Action04.Target; wheel.actions[3].param = this.Action04.Parameter; wheel.actions[4].action = (ITUActionType)this.Action05.Action; wheel.actions[4].ev = (ITUEvent)this.Action05.Event; wheel.actions[4].target = this.Action05.Target; wheel.actions[4].param = this.Action05.Parameter; wheel.actions[5].action = (ITUActionType)this.Action06.Action; wheel.actions[5].ev = (ITUEvent)this.Action06.Event; wheel.actions[5].target = this.Action06.Target; wheel.actions[5].param = this.Action06.Parameter; wheel.actions[6].action = (ITUActionType)this.Action07.Action; wheel.actions[6].ev = (ITUEvent)this.Action07.Event; wheel.actions[6].target = this.Action07.Target; wheel.actions[6].param = this.Action07.Parameter; wheel.actions[7].action = (ITUActionType)this.Action08.Action; wheel.actions[7].ev = (ITUEvent)this.Action08.Event; wheel.actions[7].target = this.Action08.Target; wheel.actions[7].param = this.Action08.Parameter; wheel.actions[8].action = (ITUActionType)this.Action09.Action; wheel.actions[8].ev = (ITUEvent)this.Action09.Event; wheel.actions[8].target = this.Action09.Target; wheel.actions[8].param = this.Action09.Parameter; wheel.actions[9].action = (ITUActionType)this.Action10.Action; wheel.actions[9].ev = (ITUEvent)this.Action10.Event; wheel.actions[9].target = this.Action10.Target; wheel.actions[9].param = this.Action10.Parameter; wheel.actions[10].action = (ITUActionType)this.Action11.Action; wheel.actions[10].ev = (ITUEvent)this.Action11.Event; wheel.actions[10].target = this.Action11.Target; wheel.actions[10].param = this.Action11.Parameter; wheel.actions[11].action = (ITUActionType)this.Action12.Action; wheel.actions[11].ev = (ITUEvent)this.Action12.Event; wheel.actions[11].target = this.Action12.Target; wheel.actions[11].param = this.Action12.Parameter; wheel.actions[12].action = (ITUActionType)this.Action13.Action; wheel.actions[12].ev = (ITUEvent)this.Action13.Event; wheel.actions[12].target = this.Action13.Target; wheel.actions[12].param = this.Action13.Parameter; wheel.actions[13].action = (ITUActionType)this.Action14.Action; wheel.actions[13].ev = (ITUEvent)this.Action14.Event; wheel.actions[13].target = this.Action14.Target; wheel.actions[13].param = this.Action14.Parameter; wheel.actions[14].action = (ITUActionType)this.Action15.Action; wheel.actions[14].ev = (ITUEvent)this.Action15.Event; wheel.actions[14].target = this.Action15.Target; wheel.actions[14].param = this.Action15.Parameter; return(wheel); }
public static bool Before(WidgetNode a, WidgetNode b) { if (a.DependenceCount == b.DependenceCount) return a.Widget.GetInstanceID() < b.Widget.GetInstanceID(); return a.DependenceCount < b.DependenceCount; }
private static WidgetNode UnlinkWidgetNodeFromList(WidgetNode list, WidgetNode node) { if (list == node) list = node.Next; if (node.Prev != null) node.Prev.Next = node.Next; if (node.Next != null) node.Next.Prev = node.Prev; node.Prev = node.Next = null; return list; }
private static WidgetNode LinkWidgetNodeToList(WidgetNode list, WidgetNode node) { if (list == null || WidgetNode.Before(node, list)) { if (list != null) list.Prev = node; node.Next = list; return node; } else { var n = list; for (; n.Next != null && WidgetNode.Before(n.Next, node); n = n.Next) ; node.Prev = n; node.Next = n.Next; if (n.Next != null) n.Next.Prev = node; n.Next = node; return list; } }
private static List<WidgetNode> GetTopWidgetNodesOfList(WidgetNode list) { var result = new List<WidgetNode>(); if (list != null) { var dependenceCount = list.DependenceCount; for (; list != null && list.DependenceCount == dependenceCount; list = list.Next) result.Add(list); result.Sort((a, b) => UIWidget.PanelCompareFunc(a.Widget, b.Widget)); } return result; }
private static void FindBestSolution(WidgetNode nodeList, ComplexMaterial lastMaterial, int drawCall, List<UIWidget> result, ref int bestDrawCall, List<UIWidget> bestResult, int stopDrawCall) { if (drawCall >= bestDrawCall) return; if (nodeList == null) { if (drawCall < bestDrawCall) { bestDrawCall = drawCall; bestResult.Clear(); bestResult.AddRange(result); } return; } var bestNodes = (from node in GetTopWidgetNodesOfList(nodeList) where node.Material == lastMaterial select node).Take(1); if (!bestNodes.Any()) { bestNodes = from node in GetTopWidgetNodesOfList(nodeList) group node by node.Material into g select g.First(); } foreach (var node in bestNodes.ToArray()) { nodeList = UnlinkWidgetNodeFromList(nodeList, node); foreach (var reverseNode in node.ReverseDependences) { --reverseNode.DependenceCount; nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode); } result.Add(node.Widget); FindBestSolution(nodeList, node.Material, lastMaterial == node.Material ? drawCall : drawCall + 1, result, ref bestDrawCall, bestResult, stopDrawCall); result.RemoveAt(result.Count - 1); foreach (var reverseNode in node.ReverseDependences) { ++reverseNode.DependenceCount; nodeList = AdjustWidgetNodePosInList(nodeList, reverseNode); } nodeList = LinkWidgetNodeToList(nodeList, node); if (bestDrawCall == stopDrawCall) break; } }
public ITUWidget CreateITUWidget() { ITUTableListBox listbox = new ITUTableListBox(); listbox.type = ITUWidgetType.ITU_TABLELISTBOX; listbox.name = this.Name; listbox.flags |= this.TabStop ? ITU.ITU_TAPSTOP : 0; listbox.flags |= this.HasLongPress ? ITU.ITU_HAS_LONG_PRESS : 0; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this); listbox.visible = (bool)properties["Visible"].GetValue(this); listbox.active = false; listbox.dirty = false; listbox.alpha = 255; listbox.tabIndex = this.TabIndex; listbox.rect.x = this.Location.X; listbox.rect.y = this.Location.Y; listbox.rect.width = this.Size.Width; listbox.rect.height = this.Size.Height; listbox.color.alpha = this.BackAlpha; listbox.color.red = this.BackColor.R; listbox.color.green = this.BackColor.G; listbox.color.blue = this.BackColor.B; listbox.bound.x = 0; listbox.bound.y = 0; listbox.bound.width = 0; listbox.bound.height = 0; for (int i = 0; i < this.ItemCount; i++) { object item; if (i < this.Items.Count) { item = this.Items[i]; } else { item = null; } ITUScrollText text = new ITUScrollText(); text.name = ""; text.visible = true; text.active = false; text.dirty = false; text.alpha = 255; text.rect.x = 0; text.rect.y = 0; text.rect.width = this.Size.Width; text.rect.height = this.ItemHeight; text.color.alpha = this.ForeColor.A; text.color.red = this.ForeColor.R; text.color.green = this.ForeColor.G; text.color.blue = this.ForeColor.B; text.bound.x = 0; text.bound.y = 0; text.bound.width = 0; text.bound.height = 0; text.bgColor.alpha = 0; text.bgColor.red = 0; text.bgColor.green = 0; text.bgColor.blue = 0; text.fontWidth = (int)Math.Round(this.Font.Size * (this.Font.FontFamily.GetCellAscent(FontStyle.Regular) + this.Font.FontFamily.GetCellDescent(FontStyle.Regular)) / this.Font.FontFamily.GetEmHeight(FontStyle.Regular)); text.fontHeight = text.fontWidth; text.fontIndex = this.FontIndex; if (base.Font.Bold) { text.textFlags |= ITUText.ITU_TEXT_BOLD; } text.boldSize = this.BoldSize; string[] texts = new string[1]; if (item == null) { texts[0] = ""; } else { texts[0] = item.ToString(); } text.stringSet = ITU.CreateStringSetNode(texts); text.width = this.Size.Width; switch (this.TextAlign) { case ContentAlignment.BottomLeft: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_LEFT; break; case ContentAlignment.MiddleLeft: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_LEFT; break; case ContentAlignment.TopLeft: text.layout = ITULayout.ITU_LAYOUT_TOP_LEFT; break; case ContentAlignment.BottomCenter: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_CENTER; break; case ContentAlignment.MiddleCenter: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_CENTER; break; case ContentAlignment.TopCenter: text.layout = ITULayout.ITU_LAYOUT_TOP_CENTER; break; case ContentAlignment.BottomRight: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_RIGHT; break; case ContentAlignment.MiddleRight: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_RIGHT; break; case ContentAlignment.TopRight: text.layout = ITULayout.ITU_LAYOUT_TOP_RIGHT; break; default: text.layout = ITULayout.ITU_LAYOUT_DEFAULT; break; } text.scrollDelay = this.ScrollDelay; text.stopDelay = this.StopDelay; text.scrollTextState = 1; WidgetNode node = new WidgetNode(); node.widget = text; listbox.items.Add(node); } listbox.focusColor.alpha = this.FocusColor.A; listbox.focusColor.red = this.FocusColor.R; listbox.focusColor.green = this.FocusColor.G; listbox.focusColor.blue = this.FocusColor.B; listbox.focusFontColor.alpha = this.FocusFontColor.A; listbox.focusFontColor.red = this.FocusFontColor.R; listbox.focusFontColor.green = this.FocusFontColor.G; listbox.focusFontColor.blue = this.FocusFontColor.B; listbox.orgFontColor.alpha = this.ForeColor.A; listbox.orgFontColor.red = this.ForeColor.R; listbox.orgFontColor.green = this.ForeColor.G; listbox.orgFontColor.blue = this.ForeColor.B; listbox.readFontColor.alpha = this.ReadFontColor.A; listbox.readFontColor.red = this.ReadFontColor.R; listbox.readFontColor.green = this.ReadFontColor.G; listbox.readFontColor.blue = this.ReadFontColor.B; listbox.scrollDelay = this.ScrollDelay; listbox.stopDelay = this.StopDelay; listbox.totalframe = this.TotalFrame; listbox.slidePage = this.SlidePage; if (this.Draggable) { listbox.flags |= ITU.ITU_DRAGGABLE; } listbox.actions[0].action = (ITUActionType)this.Action01.Action; listbox.actions[0].ev = (ITUEvent)this.Action01.Event; listbox.actions[0].target = this.Action01.Target; listbox.actions[0].param = this.Action01.Parameter; listbox.actions[1].action = (ITUActionType)this.Action02.Action; listbox.actions[1].ev = (ITUEvent)this.Action02.Event; listbox.actions[1].target = this.Action02.Target; listbox.actions[1].param = this.Action02.Parameter; listbox.actions[2].action = (ITUActionType)this.Action03.Action; listbox.actions[2].ev = (ITUEvent)this.Action03.Event; listbox.actions[2].target = this.Action03.Target; listbox.actions[2].param = this.Action03.Parameter; listbox.actions[3].action = (ITUActionType)this.Action04.Action; listbox.actions[3].ev = (ITUEvent)this.Action04.Event; listbox.actions[3].target = this.Action04.Target; listbox.actions[3].param = this.Action04.Parameter; listbox.actions[4].action = (ITUActionType)this.Action05.Action; listbox.actions[4].ev = (ITUEvent)this.Action05.Event; listbox.actions[4].target = this.Action05.Target; listbox.actions[4].param = this.Action05.Parameter; listbox.actions[5].action = (ITUActionType)this.Action06.Action; listbox.actions[5].ev = (ITUEvent)this.Action06.Event; listbox.actions[5].target = this.Action06.Target; listbox.actions[5].param = this.Action06.Parameter; listbox.actions[6].action = (ITUActionType)this.Action07.Action; listbox.actions[6].ev = (ITUEvent)this.Action07.Event; listbox.actions[6].target = this.Action07.Target; listbox.actions[6].param = this.Action07.Parameter; listbox.actions[7].action = (ITUActionType)this.Action08.Action; listbox.actions[7].ev = (ITUEvent)this.Action08.Event; listbox.actions[7].target = this.Action08.Target; listbox.actions[7].param = this.Action08.Parameter; listbox.actions[8].action = (ITUActionType)this.Action09.Action; listbox.actions[8].ev = (ITUEvent)this.Action09.Event; listbox.actions[8].target = this.Action09.Target; listbox.actions[8].param = this.Action09.Parameter; listbox.actions[9].action = (ITUActionType)this.Action10.Action; listbox.actions[9].ev = (ITUEvent)this.Action10.Event; listbox.actions[9].target = this.Action10.Target; listbox.actions[9].param = this.Action10.Parameter; listbox.actions[10].action = (ITUActionType)this.Action11.Action; listbox.actions[10].ev = (ITUEvent)this.Action11.Event; listbox.actions[10].target = this.Action11.Target; listbox.actions[10].param = this.Action11.Parameter; listbox.actions[11].action = (ITUActionType)this.Action12.Action; listbox.actions[11].ev = (ITUEvent)this.Action12.Event; listbox.actions[11].target = this.Action12.Target; listbox.actions[11].param = this.Action12.Parameter; listbox.actions[12].action = (ITUActionType)this.Action13.Action; listbox.actions[12].ev = (ITUEvent)this.Action13.Event; listbox.actions[12].target = this.Action13.Target; listbox.actions[12].param = this.Action13.Parameter; listbox.actions[13].action = (ITUActionType)this.Action14.Action; listbox.actions[13].ev = (ITUEvent)this.Action14.Event; listbox.actions[13].target = this.Action14.Target; listbox.actions[13].param = this.Action14.Parameter; listbox.actions[14].action = (ITUActionType)this.Action15.Action; listbox.actions[14].ev = (ITUEvent)this.Action15.Event; listbox.actions[14].target = this.Action15.Target; listbox.actions[14].param = this.Action15.Parameter; return(listbox); }
public ITUWidget CreateITUWidget() { ITUScrollMediaFileListBox smflistbox = new ITUScrollMediaFileListBox(); smflistbox.type = ITUWidgetType.ITU_SCROLLMEDIAFILELISTBOX; smflistbox.name = this.Name; smflistbox.flags |= this.TabStop ? ITU.ITU_TAPSTOP : 0; PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this); smflistbox.visible = (bool)properties["Visible"].GetValue(this); smflistbox.active = false; smflistbox.dirty = false; smflistbox.alpha = 255; smflistbox.tabIndex = this.TabIndex; smflistbox.rect.x = this.Location.X; smflistbox.rect.y = this.Location.Y; smflistbox.rect.width = this.Size.Width; smflistbox.rect.height = this.Size.Height; smflistbox.color.alpha = this.BackAlpha; smflistbox.color.red = this.BackColor.R; smflistbox.color.green = this.BackColor.G; smflistbox.color.blue = this.BackColor.B; smflistbox.bound.x = 0; smflistbox.bound.y = 0; smflistbox.bound.width = 0; smflistbox.bound.height = 0; for (int i = 0; i < 3; i++) { foreach (object item in this.Items) { ITUScrollText text = new ITUScrollText(); text.name = ""; text.visible = true; text.active = false; text.dirty = false; text.alpha = 255; text.rect.x = 0; text.rect.y = 0; text.rect.width = this.Size.Width; text.rect.height = base.ItemHeight; text.color.alpha = this.ForeColor.A; text.color.red = this.ForeColor.R; text.color.green = this.ForeColor.G; text.color.blue = this.ForeColor.B; text.bound.x = 0; text.bound.y = 0; text.bound.width = 0; text.bound.height = 0; text.bgColor.alpha = 0; text.bgColor.red = 0; text.bgColor.green = 0; text.bgColor.blue = 0; text.fontWidth = (int)Math.Round(this.Font.Size * (this.Font.FontFamily.GetCellAscent(FontStyle.Regular) + this.Font.FontFamily.GetCellDescent(FontStyle.Regular)) / this.Font.FontFamily.GetEmHeight(FontStyle.Regular)); text.fontHeight = text.fontWidth; text.fontIndex = this.FontIndex; text.width = this.Size.Width; if (base.Font.Bold) { text.textFlags |= ITUText.ITU_TEXT_BOLD; } text.boldSize = this.BoldSize; switch (this.TextAlign) { case ContentAlignment.BottomLeft: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_LEFT; break; case ContentAlignment.MiddleLeft: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_LEFT; break; case ContentAlignment.TopLeft: text.layout = ITULayout.ITU_LAYOUT_TOP_LEFT; break; case ContentAlignment.BottomCenter: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_CENTER; break; case ContentAlignment.MiddleCenter: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_CENTER; break; case ContentAlignment.TopCenter: text.layout = ITULayout.ITU_LAYOUT_TOP_CENTER; break; case ContentAlignment.BottomRight: text.layout = ITULayout.ITU_LAYOUT_BOTTOM_RIGHT; break; case ContentAlignment.MiddleRight: text.layout = ITULayout.ITU_LAYOUT_MIDDLE_RIGHT; break; case ContentAlignment.TopRight: text.layout = ITULayout.ITU_LAYOUT_TOP_RIGHT; break; default: text.layout = ITULayout.ITU_LAYOUT_DEFAULT; break; } text.scrollDelay = this.ScrollDelay; text.stopDelay = this.StopDelay; text.scrollTextState = 1; WidgetNode node = new WidgetNode(); node.widget = text; smflistbox.items.Add(node); } } smflistbox.pageIndexName = this.PageIndexTarget; smflistbox.pageCountName = this.PageCountTarget; smflistbox.focusColor.alpha = this.FocusColor.A; smflistbox.focusColor.red = this.FocusColor.R; smflistbox.focusColor.green = this.FocusColor.G; smflistbox.focusColor.blue = this.FocusColor.B; smflistbox.focusFontColor.alpha = this.FocusFontColor.A; smflistbox.focusFontColor.red = this.FocusFontColor.R; smflistbox.focusFontColor.green = this.FocusFontColor.G; smflistbox.focusFontColor.blue = this.FocusFontColor.B; smflistbox.orgFontColor.alpha = this.ForeColor.A; smflistbox.orgFontColor.red = this.ForeColor.R; smflistbox.orgFontColor.green = this.ForeColor.G; smflistbox.orgFontColor.blue = this.ForeColor.B; smflistbox.readFontColor.alpha = this.ReadFontColor.A; smflistbox.readFontColor.red = this.ReadFontColor.R; smflistbox.readFontColor.green = this.ReadFontColor.G; smflistbox.readFontColor.blue = this.ReadFontColor.B; smflistbox.scrollDelay = this.ScrollDelay; smflistbox.stopDelay = this.StopDelay; smflistbox.path = this.Path; smflistbox.extensions = this.Extensions; smflistbox.totalframe = this.TotalFrame; if (this.Draggable) { smflistbox.flags |= ITU.ITU_DRAGGABLE; } smflistbox.actions[0].action = (ITUActionType)this.Action01.Action; smflistbox.actions[0].ev = (ITUEvent)this.Action01.Event; smflistbox.actions[0].target = this.Action01.Target; smflistbox.actions[0].param = this.Action01.Parameter; smflistbox.actions[1].action = (ITUActionType)this.Action02.Action; smflistbox.actions[1].ev = (ITUEvent)this.Action02.Event; smflistbox.actions[1].target = this.Action02.Target; smflistbox.actions[1].param = this.Action02.Parameter; smflistbox.actions[2].action = (ITUActionType)this.Action03.Action; smflistbox.actions[2].ev = (ITUEvent)this.Action03.Event; smflistbox.actions[2].target = this.Action03.Target; smflistbox.actions[2].param = this.Action03.Parameter; smflistbox.actions[3].action = (ITUActionType)this.Action04.Action; smflistbox.actions[3].ev = (ITUEvent)this.Action04.Event; smflistbox.actions[3].target = this.Action04.Target; smflistbox.actions[3].param = this.Action04.Parameter; smflistbox.actions[4].action = (ITUActionType)this.Action05.Action; smflistbox.actions[4].ev = (ITUEvent)this.Action05.Event; smflistbox.actions[4].target = this.Action05.Target; smflistbox.actions[4].param = this.Action05.Parameter; smflistbox.actions[5].action = (ITUActionType)this.Action06.Action; smflistbox.actions[5].ev = (ITUEvent)this.Action06.Event; smflistbox.actions[5].target = this.Action06.Target; smflistbox.actions[5].param = this.Action06.Parameter; smflistbox.actions[6].action = (ITUActionType)this.Action07.Action; smflistbox.actions[6].ev = (ITUEvent)this.Action07.Event; smflistbox.actions[6].target = this.Action07.Target; smflistbox.actions[6].param = this.Action07.Parameter; smflistbox.actions[7].action = (ITUActionType)this.Action08.Action; smflistbox.actions[7].ev = (ITUEvent)this.Action08.Event; smflistbox.actions[7].target = this.Action08.Target; smflistbox.actions[7].param = this.Action08.Parameter; smflistbox.actions[8].action = (ITUActionType)this.Action09.Action; smflistbox.actions[8].ev = (ITUEvent)this.Action09.Event; smflistbox.actions[8].target = this.Action09.Target; smflistbox.actions[8].param = this.Action09.Parameter; smflistbox.actions[9].action = (ITUActionType)this.Action10.Action; smflistbox.actions[9].ev = (ITUEvent)this.Action10.Event; smflistbox.actions[9].target = this.Action10.Target; smflistbox.actions[9].param = this.Action10.Parameter; smflistbox.actions[10].action = (ITUActionType)this.Action11.Action; smflistbox.actions[10].ev = (ITUEvent)this.Action11.Event; smflistbox.actions[10].target = this.Action11.Target; smflistbox.actions[10].param = this.Action11.Parameter; smflistbox.actions[11].action = (ITUActionType)this.Action12.Action; smflistbox.actions[11].ev = (ITUEvent)this.Action12.Event; smflistbox.actions[11].target = this.Action12.Target; smflistbox.actions[11].param = this.Action12.Parameter; smflistbox.actions[12].action = (ITUActionType)this.Action13.Action; smflistbox.actions[12].ev = (ITUEvent)this.Action13.Event; smflistbox.actions[12].target = this.Action13.Target; smflistbox.actions[12].param = this.Action13.Parameter; smflistbox.actions[13].action = (ITUActionType)this.Action14.Action; smflistbox.actions[13].ev = (ITUEvent)this.Action14.Event; smflistbox.actions[13].target = this.Action14.Target; smflistbox.actions[13].param = this.Action14.Parameter; smflistbox.actions[14].action = (ITUActionType)this.Action15.Action; smflistbox.actions[14].ev = (ITUEvent)this.Action15.Event; smflistbox.actions[14].target = this.Action15.Target; smflistbox.actions[14].param = this.Action15.Parameter; return(smflistbox); }
private static WidgetNode AdjustWidgetNodePosInList(WidgetNode list, WidgetNode node) { if ((node.Prev != null && WidgetNode.Before(node, node.Prev)) || (node.Next != null && WidgetNode.Before(node.Next, node))) { list = UnlinkWidgetNodeFromList(list, node); list = LinkWidgetNodeToList(list, node); } return list; }