Ejemplo n.º 1
0
        private void onAddButtonClicked()
        {
            uiPlayerDialog.Visible = false;

            uiPlayerDetailDialog = new UIPlayerDetailDialog(gameSystem)
            {
                Text            = gameSystem.wording.add,
                okButtonClicked = async() =>
                {
                    var name = uiPlayerDetailDialog.name;

                    if (!checkPlayer(ref name))
                    {
                        return;
                    }

                    gameSystem.players.Add(new PlayerInfo()
                    {
                        name    = name,
                        code    = Guid.NewGuid().ToString(),
                        servers = new List <ServerInfo>()
                    });

                    PlayerHelper.savePlayer(gameSystem.players);

                    uiPlayerDialog.setData(gameSystem.players.Select(o => o.name).ToList());

                    uiPlayerDetailDialog.Close();

                    uiPlayerDialog.Visible = true;
                },
                cancelButtonClicked = () =>
                {
                    uiPlayerDetailDialog.Close();

                    uiPlayerDialog.Visible = true;
                }
            };

            uiPlayerDetailDialog.Show();
        }
Ejemplo n.º 2
0
        private void onEditButtonClicked(string oldName)
        {
            uiPlayerDialog.Visible = false;

            uiPlayerDetailDialog = new UIPlayerDetailDialog(gameSystem)
            {
                Text            = gameSystem.wording.edit,
                okButtonClicked = () =>
                {
                    var newName = uiPlayerDetailDialog.name;

                    if (!checkPlayer(ref newName))
                    {
                        return;
                    }

                    gameSystem.players.SingleOrDefault(o => o.name == oldName).name = newName;

                    PlayerHelper.savePlayer(gameSystem.players);

                    uiPlayerDialog.setData(gameSystem.players.Select(o => o.name).ToList());

                    uiPlayerDetailDialog.Close();

                    uiPlayerDialog.Visible = true;
                },
                cancelButtonClicked = () =>
                {
                    uiPlayerDetailDialog.Close();

                    uiPlayerDialog.Visible = true;
                }
            };

            uiPlayerDetailDialog.Show();
        }