예제 #1
0
        public InformationPanel(Character subject, Vector2 size)
        {
            Size = size;

            EnemyIndicator     = new EnemyIndicator();
            InventoryIndicator = new InventoryIndicator {
                Subject = subject,
            };

            var list = new UiList
            {
                DisplayingQueue = new List <IPositionedUiElement>
                {
                    EnemyIndicator,
                    new CharacteristicsIndicator {
                        Subject = subject,
                    },
                    InventoryIndicator,
                },
                Indentiation = 1,
                Position     = new Vector2(1, 1),
            };

            _complex = new UiComplex
            {
                Background = new PanelBackground {
                    BorderColor = ConsoleColor.White, Size = size,
                },
                DisplayingQueue = new List <IPositionedUiElement> {
                    list,
                },
            };
        }
        public async Task <UiList <UiUserListItem> > Get(
            [FromQuery] string name,
            [FromQuery] int?skip,
            [FromQuery] int?take)
        {
            var result = new UiList <UiUserListItem>();
            var query  = _userManager.Users;

            if (!string.IsNullOrWhiteSpace(name))
            {
                query = query.Where(x => x.UserName.Contains(name, System.StringComparison.OrdinalIgnoreCase));
            }
            if (skip.HasValue)
            {
                query = query.Skip(skip.Value);
            }
            if (take.HasValue)
            {
                query = query.Take(take.Value);
            }
            result.TotalCount = query.Count();
            result.Items      = new List <UiUserListItem>();
            foreach (var user in query.ToList())
            {
                var listItem = _mapper.Map <UiUserListItem>(user);
                listItem.Roles.AddRange((await _userManager.GetRolesAsync(user)).Select(x => new UiRoleListItem {
                    Name = x
                }));
                result.Items.Add(listItem);
            }
            return(result);
        }
예제 #3
0
        public UiList <UiRoleListItem> Get()
        {
            var result = new UiList <UiRoleListItem>();

            result.TotalCount = _roleManager.Roles.Count();
            result.Items      = _mapper.Map <List <UiRoleListItem> >(_roleManager.Roles.ToList());
            return(result);
        }
예제 #4
0
    public static void Init(UiRootScript uiBind)
    {
        UguiRoot = uiBind.gameObject;

        _uiBind = uiBind;

        //注册UI
        UiList.RegisterUI();

        BackGround = _uiBind.BackGround;
    }
예제 #5
0
        protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
        {
            try
            {
                m_Delegate = new runDelegate(Run);
                string    filterText = FilterText.Get(context);
                TreeScope treeScope;
                if (Scope == ScopeOption.Children)
                {
                    treeScope = TreeScope.Children;
                }
                else if (Scope == ScopeOption.Descendants)
                {
                    treeScope = TreeScope.Descendants;
                }
                else
                {
                    treeScope = TreeScope.Subtree;
                }
                UiElement element = null;
                var       selStr  = Selector.Get(context);


                element = Common.GetValueOrDefault(context, this.Element, null);
                if (element == null && selStr != null)
                {
                    element = UiElement.FromSelector(selStr);
                }
                else
                {
                    PropertyDescriptor property = context.DataContext.GetProperties()[EleScope.GetEleScope];
                    element = property.GetValue(context.DataContext) as UiElement;
                }

                List <UiElement> uiList = new List <UiElement>();
                uiList = element.FindAllByFilter(treeScope, TrueCondition.Default, filterText);
                UiList.Set(context, uiList);

                return(m_Delegate.BeginInvoke(callback, state));
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "获取子节点元素失败", e.Message);
                if (ContinueOnError.Get(context))
                {
                    return(m_Delegate.BeginInvoke(callback, state));
                }
                else
                {
                    throw e;
                }
            }
        }
예제 #6
0
        private void FillElementsForm()
        {
            UiList list = _elementsForm.GetComponentInChildren <UiList>();

            if (list == null)
            {
                Debug.LogError("Elements window has no UiList!");
                return;
            }

            var prefabList = _mapManager.GetPrefabList();

            foreach (var prefab in prefabList)
            {
                GameObject    button = Instantiate(_elementButtonPrefab);
                RectTransform rt     = button.GetComponent <RectTransform>();
                list.Add(rt);
                ElementButton buttonComponent = button.GetComponent <ElementButton>();
                buttonComponent.SetData(prefab.Value.GetComponent <TileObject>());
            }
        }
예제 #7
0
        public UiLayerEditor(ContentManager Content, Overworld o)
        {
            this.o      = o;
            this.layers = o.meta.layers;
            layerList   = new UiList(Content, layers.ToArray());
            commandList = new UiList(Content, new string[4] {
                "Add", "Delete", "Set Base", "Exit"
            });
            commandList.addCallback(element =>
            {
                commandList.finished = false;
                switch (commandList.selected)
                {
                case 0: mode = Mode.Adding; genLayerStrings(); layerList.selected = 0; break;

                case 1: mode = Mode.Deleting; genLayerStrings(); layerList.selected = 0; break;

                case 2: mode = Mode.SetBase; genLayerStrings(); layerList.selected = o.meta.baseLayer; break;

                case 3: finished = true; break;
                }
            });
            layerList.addCallback(element =>
            {
                layerList.finished = false;
                if (layerList.selected != -1)
                {
                    if (mode == Mode.Adding)
                    {
                        system.pushElement(new UiTextInput("Filename: ").addCallback(input =>
                        {
                            UiTextInput textInput = (UiTextInput)input;
                            if (textInput.text != null)
                            {
                                layers.Insert(layerList.selected, textInput.text);
                                if (layerList.selected >= o.meta.baseLayer)
                                {
                                    o.meta.baseLayer++;
                                }
                                layerList.setStrings(layers.ToArray());
                                o.reloadLayers();
                            }
                        }), Vector2.Zero);
                    }
                    else if (mode == Mode.Deleting)
                    {
                        layers.RemoveAt(layerList.selected);
                        if (layerList.selected <= o.meta.baseLayer)
                        {
                            o.meta.baseLayer--;
                        }
                        layerList.setStrings(layers.ToArray());
                        o.reloadLayers();
                    }
                    else if (mode == Mode.SetBase)
                    {
                        o.meta.baseLayer = layerList.selected;
                        o.reloadLayers();
                    }
                    mode = Mode.Inactive;
                }
            });
        }
예제 #8
0
 public void AddToUI(GuiElement item)
 {
     UiList.Add(item);
 }
예제 #9
0
        public TitleScreen(Game1 game, ContentManager Content)
        {
            this.game    = game;
            this.Content = Content;
            bg           = Content.Load <Texture2D>(GameInfo.titleBackground);
            ui           = new UiSystem(false);

            mainList = new UiList(Content, new string[4] {
                "New Game", "Load Game", "Options", "Quit"
            });
            mainList.addCallback(element =>
            {
                element.finished = false; // cancel removing the main list
                UiList list      = (UiList)element;
                int selected     = list.selected;
                switch (selected)
                {
                case -1:     // thwart attempt to close the main menu
                    {
                        list.selected = 0;
                        break;
                    }

                case 0:     // new game
                    {
                        TimeOfDay.restart();
                        Flags.reset();
                        if (GameInfo.startOverworld)
                        {
                            game.goToOverworld(new Player(Content, null, null), GameInfo.startMap);
                        }
                        else
                        {
                            game.goToWorld(new Player(Content, null, null), GameInfo.startMap);
                        }
                        break;
                    }

                case 1:     // load game
                    {
                        ui.pushElement(new UiSavePicker(Content, false).addCallback(element =>
                        {
                            UiSavePicker saves = (UiSavePicker)element;
                            string chosen      = saves.selectedString;
                            if (chosen == UiSavePicker.NO_FILES || chosen == null)
                            {
                                return;
                            }
                            SaveGame game = SaveGame.Load(Content, chosen);
                            TimeOfDay.restart();
                            Flags.reset();

                            // restore data from save
                            Player player = new Player(Content, null, null);
                            foreach (string s in game.inventory.Keys)
                            {
                                player.addItem(s, game.inventory[s]);
                            }
                            Flags.setAllFlags(game.flags, game.strings);
                            TimeOfDay.addMillis(game.time);
                            player.setTileLocation(game.location);

                            // go to overworld or map
                            if (game.overworld)
                            {
                                this.game.goToOverworld(player, game.map);
                            }
                            else
                            {
                                this.game.goToWorld(player, game.map, false);
                            }
                        }), new Vector2(Tile.TILE_SIZE, Tile.TILE_SIZE));
                        break;
                    }

                case 2:     // options
                    {
                        ui.pushElement(new UiOptionsMenu(game, Content),
                                       new Vector2(
                                           Game1.INTERNAL_WIDTH / 2 - UiOptionsMenu.WIDTH / 2,
                                           Game1.INTERNAL_HEIGHT / 2 - UiOptionsMenu.HEIGHT / 2)
                                       );
                        break;
                    }

                case 3:     // quit
                    {
                        game.Exit();
                        break;
                    }
                }
            });

            Vector2 center = Vector2.Round(new Vector2(
                                               Game1.INTERNAL_WIDTH / 2 - mainList.size.X / 2,
                                               (Game1.INTERNAL_HEIGHT / 2 - mainList.size.Y / 2) + 20));

            ui.pushElement(mainList, center);
        }