Exemplo n.º 1
0
    public static DropdownComponent Instantiate(GameObject prefab, GameObject parent, DropdownParameter parameter)
    {
        DropdownComponent obj = Instantiate(prefab, parent.transform).GetComponent <DropdownComponent>();

        obj.parameter = parameter;
        if (parameter.Title == null)
        {
            obj.title.gameObject.SetActive(false);
        }
        else
        {
            obj.title.text = parameter.Title;
        }

        if (parameter.Text == null)
        {
            obj.dscriptionObj.SetActive(false);
        }
        else
        {
            obj.dscription.text = parameter.Text;
        }
        obj.dropdown.ClearOptions();
        obj.dropdown.AddOptions(parameter.list);
        return(obj);
    }
Exemplo n.º 2
0
 private VNode RenderPersonalInfo()
 {
     return(Div(
                Div(
                    Styles.TabNameTagNoWidth & Styles.MinW25 & Styles.FitContent,
                    Text("Change Username", Styles.Fontcopperplate & Styles.Underline & Styles.MB2P5rem),
                    Row(
                        Text("Current Username:"******"New Username:"******"Apply", Styles.BtnSettings, () => Account.Commands.ChangeUsername(AccountEntry.ID, Username))
                        )
                    ),
                Div(
                    Styles.TabNameTagNoWidth & Styles.MinW25 & Styles.FitContent,
                    Text("Change Icon", Styles.Fontcopperplate & Styles.Underline & Styles.MB2P5rem),
                    Row(
                        DropdownComponent <string> .Render(AccountProjection.GetIcons(), i => Icon = i, "Change Icon", i => Div(DOM.Icon(i, Styles.TCblack))),
                        DOM.Icon(Icon != default ? Icon : "fas fa-question-circle", Styles.MX1),
                        Text("Apply", Styles.BtnSettings & Styles.MX1, () => Account.Commands.ChangeIcon(AccountEntry.ID, Icon))
                        )
                    )
                ));
 }
Exemplo n.º 3
0
    private void SetComponentForParameter()
    {
        List <SubNodeParameter> subNodeParameters = new List <SubNodeParameter>();

        foreach (Parameter p in this.node.parameters)
        {
            //Number
            if (p.type == ParameterType.number)
            {
                NumberParameter pram  = p as NumberParameter;
                var             compo = NumberComponent.Instantiate(MainViweModel.instance.NumberComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //sentence
            if (p.type == ParameterType.sentence)
            {
                SentenceParameter pram = p as SentenceParameter;
                var compo = SentenceComponent.Instantiate(MainViweModel.instance.SentenceComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //dropdown
            if (p.type == ParameterType.dropdown)
            {
                DropdownParameter pram = p as DropdownParameter;
                var compo = DropdownComponent.Instantiate(MainViweModel.instance.DropdownComponentPrefab, contentsObject, pram);
                componentList.Add(compo);
            }

            //nodes
            if (p.type == ParameterType.nodes)
            {
                NodesParameter pram  = p as NodesParameter;
                var            compo = SubNodeListComponent.Instantiate(MainViweModel.instance.SubNodeListComponentPrefab, contentsObject, pram.list, this);
                componentList.Add(compo);
                if (pram.Title != null)
                {
                    compo.title.text = pram.Title;
                }
            }

            //subNodeList
            if (p.type == ParameterType.subNode)
            {
                subNodeParameters.Add(p as SubNodeParameter);
            }
        }

        if (subNodeParameters.Count != 0)
        {
            var compo = SubNodeListComponent.Instantiate(MainViweModel.instance.SubNodeListComponentPrefab, contentsObject, subNodeParameters, this);
            componentList.Add(compo);
        }
    }
        public VNode Render()
        {
            void startNewGame()
            {
                BC.Solitaire.Solitaire.Commands.OpenGame(GameID = GameID.Create(), AccountID);
                BC.Solitaire.Solitaire.Commands.JoinGame(GameID, AccountID);
            }

            void joinOldGame()
            {
                GameID = LastPlayedgame;
                BC.Solitaire.Solitaire.Commands.JoinGame(GameID, AccountID);
            }

            VNode highscore(IEnumerable <GameEntry> gameEntries, string title)
            {
                return(Div(
                           Styles.TabNameTag & Styles.FitContent & Styles.Fontcopperplate & Styles.Underline & Styles.MY2,
                           Text(title),
                           Fragment(gameEntries.ToList().Select(e =>
                                                                Row(
                                                                    Styles.Fontcopperplate,
                                                                    Text($"{gameEntries.ToList().IndexOf(e) + 1}", Styles.MX2 & Styles.W3C),
                                                                    Text(e.FinalScore.ToString(), Styles.W3C & Styles.TextAlignR),
                                                                    Text(AccountProjection[e.Player].Username, Styles.MX2 & Styles.W4C & Styles.TextAlignR)
                                                                    )))));
            }

            if (GameID == default)
            {
                VNode continueLastGame = null;
                if (LastPlayedgame != default)
                {
                    continueLastGame = Text("Continue Last Game", Styles.TabButton & Styles.W12C, () => joinOldGame());
                }
                return(Div(
                           Row(
                               continueLastGame,
                               Text("Start New Game", Styles.TabButton, () => startNewGame())
                               ),
                           //dropdown here
                           Div(
                               Styles.P4 & Styles.TabNameTagNoWidth & Styles.W8C,
                               DropdownComponent <ScoreTimespan> .Render(GetScoreTimeSpan(), a => ScoreOfTimespan = a, ScoreOfTimespan.ToString(), s => Text(s.ToString()))
                               ),
                           Row(
                               highscore(SolitaireProjection.GetPersonalHighscore(ScoreOfTimespan, AccountID), "Personal Highscore"),
                               highscore(SolitaireProjection.GetGlobalHighscore(ScoreOfTimespan), "Global Highscore")
                               )
                           ));
            }
            return(RenderGameboard());
        }
Exemplo n.º 5
0
 public override void OnBind()
 {
     foreach (var comp in components)
     {
         if (comp is DropdownComponent)
         {
             DropdownComponent dc = comp as DropdownComponent;
             DropdownAttribute da = comp.ControlAttribute as DropdownAttribute;
             if (!string.IsNullOrEmpty(da.Parent))
             {
                 var parent = GetComponent(da.Parent) as DropdownComponent;
                 if (parent != null)
                 {
                     dc.parent = parent;
                 }
             }
         }
     }
 }