Ejemplo n.º 1
0
 public static AABBox CalculateAbsoluteWidgetBounds(Transform trans)
 {
     using (WidgetList list = GetWidgetsInChildren(trans))
     {
         if (list.empty)
         {
             return(new AABBox());
         }
         AABBox box  = new AABBox();
         bool   flag = true;
         foreach (UIWidget widget in list)
         {
             Vector2 vector;
             Vector2 vector2;
             AABBox  box2;
             Vector3 vector3;
             Vector3 vector4;
             widget.GetPivotOffsetAndRelativeSize(out vector2, out vector);
             vector3.x  = (vector2.x + 0.5f) * vector.x;
             vector3.y  = (vector2.y - 0.5f) * vector.y;
             vector4.x  = vector3.x + (vector.x * 0.5f);
             vector4.y  = vector3.y + (vector.y * 0.5f);
             vector3.x -= vector.x * 0.5f;
             vector3.y -= vector.y * 0.5f;
             vector3.z  = 0f;
             vector4.z  = 0f;
             AABBox    box3 = new AABBox(ref vector3, ref vector4);
             Matrix4x4 localToWorldMatrix = widget.cachedTransform.localToWorldMatrix;
             box3.TransformedAABB3x4(ref localToWorldMatrix, out box2);
             if (flag)
             {
                 box  = box2;
                 flag = false;
             }
             else
             {
                 box.Encapsulate(ref box2);
             }
         }
         if (flag)
         {
             return(new AABBox(trans.position));
         }
         return(box);
     }
 }
Ejemplo n.º 2
0
        public void check_that_get_NOT_by_id_returns_null_for_non_mocked_values()
        {
            const int MOCK_ID = 10000000;

            // Wire up a random repo
            Widget expectedWidget = new Widget();

            expectedWidget.Description = "Testing";
            expectedWidget.DbId        = MOCK_ID;
            AutoWireUpMockRepositoryGetById <WidgetRepository, Widget>(expectedWidget);

            // Make a call to WidgetRepo.GetByThingId to get a non specified widget
            WidgetList widgets = Kernel.Get <WidgetRepository>().GetByThingId(MOCK_ID);

            Assert.IsNull(widgets, "widget returned incorrectly");
            widgets = Kernel.Get <WidgetRepository>().GetAll();
            Assert.IsNull(widgets, "widget returned incorrectly");
        }
Ejemplo n.º 3
0
        private void DisableInteraction()
        {
            CanEdit = false;
            if (_widgetOpenAction != null)
            {
                DeselectPage(_widgetOpenAction.LinkPageGuid);
            }

            _selectedWidget   = null;
            _widgetOpenAction = null;

            Raw_ExternalLink = string.Empty;
            Raw_NoneChecked  = Raw_PageChecked = Raw_LinkChecked = false;

            WidgetList.Clear();
            InitShowHideAction();
            FirePropertyChanged("IsNewWindowChecked");
        }
Ejemplo n.º 4
0
 public static AABBox CalculateRelativeWidgetBounds(Transform root, Transform child)
 {
     using (WidgetList list = GetWidgetsInChildren(child))
     {
         if (list.empty)
         {
             return(new AABBox());
         }
         bool      flag = true;
         AABBox    box  = new AABBox();
         Matrix4x4 worldToLocalMatrix = root.worldToLocalMatrix;
         foreach (UIWidget widget in list)
         {
             Vector2 vector;
             Vector2 vector2;
             Vector3 vector3;
             Vector3 vector4;
             AABBox  box3;
             widget.GetPivotOffsetAndRelativeSize(out vector2, out vector);
             vector3.x  = (vector2.x + 0.5f) * vector.x;
             vector3.y  = (vector2.x - 0.5f) * vector.y;
             vector3.z  = 0f;
             vector4.x  = vector3.x + (vector.x * 0.5f);
             vector4.y  = vector3.y + (vector.y * 0.5f);
             vector4.z  = 0f;
             vector3.x -= vector.x * 0.5f;
             vector3.y -= vector.y * 0.5f;
             Matrix4x4 t = worldToLocalMatrix * widget.cachedTransform.localToWorldMatrix;
             new AABBox(ref vector3, ref vector4).TransformedAABB3x4(ref t, out box3);
             if (flag)
             {
                 box  = box3;
                 flag = false;
             }
             else
             {
                 box.Encapsulate(ref box3);
             }
         }
         return(box);
     }
 }
Ejemplo n.º 5
0
    private static void FillWidgetListWithChildren(Transform trans, ref WidgetList list, ref bool madeList)
    {
        UIWidget component = trans.GetComponent <UIWidget>();

        if (component != null)
        {
            if (!madeList)
            {
                list     = WidgetList.Generate();
                madeList = true;
            }
            list.Add(component);
        }
        int childCount = trans.childCount;

        while (childCount-- > 0)
        {
            FillWidgetListWithChildren(trans.GetChild(childCount), ref list, ref madeList);
        }
    }
Ejemplo n.º 6
0
        public TabLoadWorld()
        {
            Icon = new Sprite(Resources.TileIcons, new Point(2, 2));

            var title = new WidgetLabel
            {
                Text = "Load World",
                Font = Resources.FontAlagard,
                Dock = Dock.Top
            };

            var saveList = new WidgetList()
            {
                Dock = Dock.Fill
            };

            var loadButton = new WidgetButton
            {
                Text = "Load",
                Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((sender) =>
            {
                if (saveList.SelectedItem != null)
                {
                    var item = (ListItemWorld)saveList.SelectedItem;
                    Game.Play(item.WorldPath);
                }
            });

            Content = new LayoutDock();
            Content.AddChildren(title, loadButton, saveList);
            Content.Padding = new Spacing(16);

            var s = Directory.GetDirectories(Game.SavesFolder);

            foreach (var save in s)
            {
                saveList.AddItem(new ListItemWorld(Path.GetFileName(save), save));
            }
        }
Ejemplo n.º 7
0
        private void updateGameWidgetList(String game)
        {
            listViewGameWidgetList.Clear();

            if ((game.Length == 0 || (Program.UserId != ((ModInfoDb)Program.allGames[game]).ownerId) && (Program.isSuperAdmin == false)))
            {
                this.toggleGameWidgetListDisplayElements(false);
                return;
            }

            toggleGameWidgetListDisplayElements(true);
            this.toggleGameWidgetInfoDisplayElements(false);

            Program.allGames       = Program.fetcher.getActivationMods();
            Program.allGameWidgets = Program.fetcher.getModWidgetsAll();

            ModInfoDb  minfo         = (ModInfoDb)Program.allGames[game];
            WidgetList modWidgetList = minfo.modWidgets;

            foreach (DictionaryEntry elem in modWidgetList)
            {
                WidgetInfo   winfo = (WidgetInfo)elem.Value;
                ListViewItem item  = new ListViewItem(winfo.headerName);
                item.Tag = winfo.id.ToString();

                listViewGameWidgetList.Items.Add(item);
            }
            try
            {
                this.updateGameWidgetInfo(getSelectedGameWidgetId());
            }
            catch (Exception)
            {
            }

            this.textBoxGameShortname.Text = minfo.abbreviation;
            this.textBoxOrderFilename.Text = minfo.configOrderFilename;
        }
Ejemplo n.º 8
0
        public TabNewWorld()
        {
            Icon = new Sprite(Resources.TileIcons, new Point(1, 2));

            var worldNameTextBox = new WidgetTextBox()
            {
                Padding = new Spacing(8),
                Text    = "new world"
            };

            var worldSeedtextBox = new WidgetTextBox()
            {
                Padding = new Spacing(8),
                Text    = Rise.Rnd.Next().ToString()
            };

            var worldTypeList = new WidgetList()
            {
                UnitBound = new Rectangle(0, 0, 256, 128)
            };

            foreach (var item in GENERATOR.GENERATORS)
            {
                worldTypeList.AddItem(new ListItemText(item.Key));
            }

            worldTypeList.SelectFirst();

            var generateButton = new WidgetButton {
                Text = "Generate", Dock = Dock.Bottom
            }
            .RegisterMouseClickEvent((s) => Game.New(worldNameTextBox.Text, worldSeedtextBox.Text,
                                                     GENERATOR.GENERATORS[((ListItemText)worldTypeList.SelectedItem).Text]));

            var worldOptions = new LayoutFlow
            {
                Flow     = LayoutFlowDirection.TopToBottom,
                Dock     = Dock.Fill,
                Children =
                {
                    new WidgetLabel
                    {
                        Text = "World name:", Padding = new Spacing(8), TextAlignement = TextAlignement.Left
                    },
                    worldNameTextBox,
                    new WidgetLabel {
                        Text = "Seed:", Padding = new Spacing(8), TextAlignement = TextAlignement.Left
                    },
                    worldSeedtextBox,
                    new WidgetLabel
                    {
                        Text = "World type:", Padding = new Spacing(8), TextAlignement = TextAlignement.Left
                    },
                    worldTypeList
                }
            };

            Content = new LayoutDock()
            {
                Padding  = new Spacing(16),
                Children =
                {
                    new WidgetLabel {
                        Text = "New World", Font = Resources.FontAlagard, Dock = Dock.Top
                    },
                    generateButton,
                    worldOptions,
                }
            };
        }
Ejemplo n.º 9
0
 public static void Save(WidgetList widgetList)
 {
     _instance.Save(widgetList);
 }
Ejemplo n.º 10
0
 public static void Save(Flags toSave, WidgetList widgetList)
 {
     _instance.Save(toSave, widgetList);
 }
Ejemplo n.º 11
0
 public static void Populate(WidgetList widgetList, Flags toPopulate)
 {
     _instance.Populate(widgetList, toPopulate);
 }
Ejemplo n.º 12
0
 public static void Refresh(WidgetList widgetList, Flags toPopulate)
 {
     _instance.Refresh(widgetList, toPopulate);
 }
Ejemplo n.º 13
0
 public void OnAdd(WidgetList <T> list)
 {
     _list = list;
 }
Ejemplo n.º 14
0
 public WidgetDrawer(object game)
     : base(game)
 {
     _widgets = new WidgetList();
 }
Ejemplo n.º 15
0
 public WidgetDrawer(object game)
     : base(game)
 {
     _widgets = new WidgetList();
 }
Ejemplo n.º 16
0
        /// <summary>
        /// load all widgets/groups which is not in a group in current page.
        /// which means,only load top level  widget/group.
        /// </summary>
        public void LoadPageWidgets()
        {
            if (_selectedWidget == null || _widgetShowHideAction == null)
            {
                DisableInteraction();
                return;
            }

            WidgetList.Clear();

            List <IWidgetPropertyData> allWidgets    = SelectionService.GetCurrentPage().GetAllWidgets();
            List <WidgetNode>          TargetWidgets = new List <WidgetNode>();

            foreach (IWidgetPropertyData it in allWidgets.Where(x => x.IsGroup == false))
            {
                WidgetViewModBase wdg = it as WidgetViewModBase;
                if (wdg == null)
                {
                    continue;
                }

                // load widget that is not in a group .
                if ((wdg.ParentID == Guid.Empty))
                {
                    bool    bChecked     = false;
                    IRegion targetObject = wdg.WidgetModel.WdgDom;
                    if (targetObject == null)
                    {
                        break;
                    }
                    //if the widget is already checked.
                    var selWidget = _widgetShowHideAction.TargetObjects.FirstOrDefault(x => x.Guid == targetObject.Guid);
                    if (selWidget != null)
                    {
                        bChecked = true;
                    }
                    TargetWidgets.Add(new WidgetNode(this, targetObject, wdg.Type, bChecked));
                }
            }

            //load all groups.
            foreach (IGroup group in _currentPage.Groups)
            {
                bool bChecked = false;
                var  selGroup = _widgetShowHideAction.TargetObjects.FirstOrDefault(x => x.Guid == group.Guid);
                if (selGroup != null)
                {
                    bChecked = true;
                }
                TargetWidgets.Add(new WidgetNode(this, group, ObjectType.Group, bChecked));
            }

            _isCheckAll = !TargetWidgets.Any(x => x.IsSelected == false);

            WidgetList.AddRange(TargetWidgets);

            FirePropertyChanged("IsCheckAll");
            FirePropertyChanged("ShowHideType");
            FirePropertyChanged("AnimateType");
            FirePropertyChanged("AnimateTime");
            FirePropertyChanged("IsShowHideEnabled");
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Populate the sub entities of fieldTestList
        /// </summary>
        /// <param name="fieldTests"></param>
        /// <param name="toPopulate"></param>
        public override void Populate(IEnumerable <FieldTest> fieldTests, Flags toPopulate)
        {
            Log("Populate", fieldTests.GetIdenties(), toPopulate);

            // Implement breadth first loading of related entities.
            // Any entity that has been requested to be loaded, should be loaded at this level where possible.
            // Remove all sub entity types that this entity relates to directly.
            Flags stillToPopulate = toPopulate;

            stillToPopulate = stillToPopulate.Remove(EntityType.Widget);
            stillToPopulate = stillToPopulate.Remove(EntityType.Widget);

            // Get parent entities: Widget
            if ((toPopulate & EntityType.Widget) == EntityType.Widget)
            {
                // Grab the ids for the ones that actually need populating
                IEnumerable <FieldTest> toBePopulated = fieldTests.Where(entity => entity.ForeignKeyFieldWidgetRequiresPopulation);
                int[] idsToLoad = toBePopulated.Select(entity => entity.ForeignKeyField).ToList().ToArray();

                // And load the sub entities for those ones.
                WidgetList parentWidgetList = toBePopulated.Count() > 0
                    ? WidgetRepo.Get(idsToLoad, stillToPopulate)
                    : new WidgetList();
                Dictionary <int, Widget> widgetListById = parentWidgetList.MapById;

                // Now go over all the entites. For ones that need popualting, populate entities
                // directly. For those already populated, make a check on sub entities to ensure
                // they are loaded to the required level
                WidgetList toBeChecked = new WidgetList();
                foreach (FieldTest fieldTest in fieldTests)
                {
                    if (fieldTest.ForeignKeyFieldWidgetRequiresPopulation)
                    {
                        fieldTest.ForeignKeyFieldWidget =
                            widgetListById.ContainsKey(fieldTest.ForeignKeyField)
                                                        ? widgetListById[fieldTest.ForeignKeyField]
                                                        : null;
                    }
                    else if (fieldTest.ForeignKeyFieldWidgetPopulated)
                    {
                        toBeChecked.Add(fieldTest.ForeignKeyFieldWidget);
                    }
                }

                // If there's any "to be checked" (because they were already loaded) let the entiies own
                // repo do whatever checks it needs to do
                if (toBeChecked.Count > 0)
                {
                    WidgetRepo.Populate(toBeChecked, stillToPopulate);
                }
            }

            // Get parent entities: Widget
            if ((toPopulate & EntityType.Widget) == EntityType.Widget)
            {
                // Grab the ids for the ones that actually need populating
                IEnumerable <FieldTest> toBePopulated = fieldTests.Where(entity => entity.ForeignKeyFieldNullableWidgetRequiresPopulation);
                int[] idsToLoad = toBePopulated.Select(entity => entity.ForeignKeyFieldNullable.Value).ToList().ToArray();

                // And load the sub entities for those ones.
                WidgetList parentWidgetList = toBePopulated.Count() > 0
                    ? WidgetRepo.Get(idsToLoad, stillToPopulate)
                    : new WidgetList();
                Dictionary <int, Widget> widgetListById = parentWidgetList.MapById;

                // Now go over all the entites. For ones that need popualting, populate entities
                // directly. For those already populated, make a check on sub entities to ensure
                // they are loaded to the required level
                WidgetList toBeChecked = new WidgetList();
                foreach (FieldTest fieldTest in fieldTests)
                {
                    if (fieldTest.ForeignKeyFieldNullableWidgetRequiresPopulation)
                    {
                        fieldTest.ForeignKeyFieldNullableWidget =
                            widgetListById.ContainsKey(fieldTest.ForeignKeyFieldNullable.Value)
                                                        ? widgetListById[fieldTest.ForeignKeyFieldNullable.Value]
                                                        : null;
                    }
                    else if (fieldTest.ForeignKeyFieldNullableWidgetPopulated)
                    {
                        toBeChecked.Add(fieldTest.ForeignKeyFieldNullableWidget);
                    }
                }

                // If there's any "to be checked" (because they were already loaded) let the entiies own
                // repo do whatever checks it needs to do
                if (toBeChecked.Count > 0)
                {
                    WidgetRepo.Populate(toBeChecked, stillToPopulate);
                }
            }
        }