Beispiel #1
0
    void AddMap()
    {
        if (LstMaps.CurrentSelection < 0)
        {
            return;
        }

        string mapluafile = MapLuaFiles[LstMaps.CurrentSelection];

        int[] modeIndices = LstModes.GetCheckedIndices();
        int[] eraIndices  = LstEras.GetCheckedIndices();

        for (int i = 0; i < modeIndices.Length; ++i)
        {
            SubIcon modeSub = ModeSubs[modeIndices[i]];

            for (int j = 0; j < eraIndices.Length; j++)
            {
                SubIcon eraSub = EraSubs[eraIndices[j]];

                string         mapName = ENV.GetLocalizedMapName(mapluafile);
                PhxListBoxItem item    = LstRotation.AddItem(mapName);
                item.SetIcon(modeSub.Icon);
                item.SetIcon2(eraSub.Icon);

                string mapScript = SWBFHelpers.Format(mapluafile, eraSub.Sub, modeSub.Sub);
                RotationLuaFiles.Add(mapScript);
            }
        }
    }
Beispiel #2
0
    public PhxListBoxItem AddItem(string itemStr, bool bSpecialItem = false)
    {
        GameObject    itemInst  = Instantiate(ItemPrefab, Content);
        RectTransform itemTrans = itemInst.transform as RectTransform;
        RectTransform conTrans  = Content.transform as RectTransform;

        float yPos = -itemTrans.sizeDelta.y * Items.Count - Spacing * Items.Count;

        itemTrans.anchoredPosition = new Vector2(0.0f, yPos);

        PhxListBoxItem item = itemInst.GetComponent <PhxListBoxItem>();
        int            idx  = Items.Count;

        item.OnClick += (PointerEventData eventData) =>
        {
            Select(idx);
        };
        item.SetIsCheckable(CheckList);
        item.IsSpecialItem = bSpecialItem;
        item.SetText(itemStr);
        item.SetSelected(false);

        yPos -= itemTrans.sizeDelta.y;
        conTrans.sizeDelta = new Vector2(conTrans.sizeDelta.x, -yPos);

        Items.Add(item);
        return(item);
    }
Beispiel #3
0
    void OnMapSelectionChanged(int newIdx)
    {
        string mapluafile = MapLuaFiles[newIdx];

        LstModes.Clear();
        LstEras.Clear();
        ModeSubs.Clear();
        EraSubs.Clear();

        object[]            res   = RT.CallLuaFunction("missionlist_ExpandModelist", 1, mapluafile);
        PhxLuaRuntime.Table modes = res[0] as PhxLuaRuntime.Table;
        foreach (KeyValuePair <object, object> entry in modes)
        {
            PhxLuaRuntime.Table mode = entry.Value as PhxLuaRuntime.Table;
            string modeNamePath      = mode.Get <string>("showstr");
            if (mode.Get("bIsWildcard") == null)
            {
                PhxListBoxItem item = LstModes.AddItem(ENV.GetLocalized(modeNamePath));
                Texture2D      icon = TextureLoader.Instance.ImportUITexture(mode.Get <string>("icon"));
                item.SetIcon(icon);

                string key = mode.Get <string>("key");
                item.SetChecked(LastCheckedModes.Contains(key));
                item.OnCheckChanged += (bool check) =>
                {
                    if (check)
                    {
                        LastCheckedModes.Add(key);
                    }
                    else
                    {
                        LastCheckedModes.Remove(key);
                    }
                };

                ModeSubs.Add(new SubIcon {
                    Sub = mode.Get <string>("subst"), Icon = icon
                });
            }
        }

        res = RT.CallLuaFunction("missionlist_ExpandEralist", 1, mapluafile);
        PhxLuaRuntime.Table eras = res[0] as PhxLuaRuntime.Table;
        foreach (KeyValuePair <object, object> entry in eras)
        {
            PhxLuaRuntime.Table era = entry.Value as PhxLuaRuntime.Table;
            string eraNamePath      = era.Get <string>("showstr");
            if (era.Get("bIsWildcard") == null)
            {
                PhxListBoxItem item = LstEras.AddItem(ENV.GetLocalized(eraNamePath));
                Texture2D      icon = TextureLoader.Instance.ImportUITexture(era.Get <string>("icon2"));
                item.SetIcon(icon);

                string key = era.Get <string>("key");
                item.SetChecked(LastCheckedEras.Contains(key));
                item.OnCheckChanged += (bool check) =>
                {
                    if (check)
                    {
                        LastCheckedEras.Add(key);
                    }
                    else
                    {
                        LastCheckedEras.Remove(key);
                    }
                };

                EraSubs.Add(new SubIcon {
                    Sub = era.Get <string>("subst"), Icon = icon
                });
            }
        }
    }