Exemple #1
0
    // Use this for initialization
    void Start()
    {
        panelUpdater = this.GetComponent <WardrobePreviewPanelUpdater>();
        pageText     = GameObject.Find("PageText").GetComponent <Text>();
        //filterField = GameObject.Find("FilterField").GetComponent<InputField>();

        raceString   = "human";
        genderString = "male";

        genderDropdown.ClearOptions();
        genderDropdown.AddOptions(WardrobeStuff.genderMap.Keys.ToList());
        raceDropdown.ClearOptions();
        raceDropdown.AddOptions(WardrobeStuff.raceMap.Keys.ToList());
        appearanceDropdown.ClearOptions();
        updateRaceGender();

        slotChangeDropdown.ClearOptions();
        List <DOption> slotOptions = new List <DOption>();

        foreach (GearSlot slot in Enum.GetValues(typeof(GearSlot)))
        {
            DOption option = new DOption(slot.ToString(), slot);
            option.userObject = slot;
            slotOptions.Add(option);
        }
        slotChangeDropdown.AddOptions(slotOptions.Cast <Dropdown.OptionData>().ToList());

        DBInst.progress += (m) => progress = m;
        DBInst.loadOrCallback((d) => {
            db = d;
        });
    }
Exemple #2
0
    void Start()
    {
        DropDownItemIconScript itemIconScript = GetComponent <DropDownItemIconScript>();

        dropdown = GetComponent <Dropdown>();

        readFavs();
        setupArrowFavIcon();
        setupItemListFavIcon();

        dropdown.onValueChanged.AddListener((x) =>
        {
            if (itemsDirty)
            {
                DOption selected = (DOption)dropdown.options[x];
                doOptions();
                for (int i = 0; i < dropdown.options.Count; i++)
                {
                    DOption d = (DOption)dropdown.options[i];
                    if (d == selected)
                    {
                        dropdown.value = i;
                        dropdown.RefreshShownValue();
                        break;
                    }
                }
                storeFavs();
            }
            itemsDirty = false;
        });
    }
Exemple #3
0
    private void updateAnimDropbox()
    {
        animationSetDropdown.ClearOptions();
        List <DOption> options = new List <DOption>();

        options.Add(new DOption("unarmed", null));
        HashSet <string> done = new HashSet <string>();

        foreach (entry e in db.getEntriesForID(230))
        {
            CObject _250 = db.toObj(e.id, e.key);
            if (_250.hasMember(7))
            {
                string animation = _250.getStringMember(7);
                if (!done.Contains(animation) && !animation.Contains("crossbow") && !animation.Contains("shared"))
                {
                    DOption option = new DOption(animation, e);
                    options.Add(option);
                    done.Add(animation);
                }
            }
        }

        options.Sort((a, b) => string.Compare(a.text, b.text));
        animationSetDropdown.AddOptions(options.Cast <Dropdown.OptionData>().ToList());
    }
Exemple #4
0
    // Update is called once per frame
    void Update()
    {
        if (filterToSet != null && DateTime.Now > filterSetTime)
        {
            filter      = filterToSet;
            filterToSet = null;
            changeSlot();
        }

        NIFTexturePool.inst.process();
        if (text != null)
        {
            text.text = progress;
        }
        if (db != null && !first)
        {
            first = true;
            // finally everything is loaded and ready so lets load an appearence set
            try
            {
                // fill animations
                updateAnimDropbox();


                // fill the "appearence" sets
                List <DOption> options = new List <DOption>();
                options.Add(new DOption("", null));

                foreach (entry e in db.getEntriesForID(7638))
                {
                    CObject _7637   = db.toObj(e.id, e.key);
                    int     textKey = _7637.getMember(1).getIntMember(0);
                    string  str     = DBInst.lang_inst.getOrDefault(textKey, _7637.getMember(0).convert().ToString());
                    DOption option  = new DOption(str, e);
                    options.Add(option);
                }

                options.Sort((a, b) => string.Compare(a.text, b.text));
                appearanceDropdown.AddOptions(options.Cast <Dropdown.OptionData>().ToList());
                appearanceDropdown.GetComponent <FavDropDown>().doOptions();
                changeSlot();


                updatePreviews();
            }
            catch (Exception ex)
            {
                Debug.LogException(ex, this.gameObject);
            }
        }
        if (db != null && lastVisible != this.panelUpdater.getVisiblePanels() || this.panelUpdater.changed)
        {
            updatePreviews();
            lastVisible = panelUpdater.getVisiblePanels();
        }
    }
Exemple #5
0
 public void setSelected(DOption option)
 {
     Debug.Log("set selected option:" + option.text);
     if (this.selectedOption == option)
     {
         return;
     }
     this.selectedOption = option;
     RefreshShownValue();
     onValueChanged.Invoke(options.IndexOf(option));
 }
Exemple #6
0
    public void onItemClick(BaseEventData data)
    {
        PointerEventData pdata = (PointerEventData)data;
        //Debug.Log("click:" + data);
        GameObject  itemTemplate = pdata.pointerPress;
        ImaListItem listItem     = itemTemplate.GetComponent <ImaListItem>();
        DOption     option       = (DOption)listItem.userObject;

        itemTemplate.transform.Find("Item Background").gameObject.GetComponent <Image>().color = normalColor;
        setSelected(option);
        hide();
    }
Exemple #7
0
 void toggleFav(DOption option)
 {
     option.fav = !option.fav;
     if (option.fav)
     {
         option.image = favSprite;
     }
     else
     {
         option.image = notFavSprite;
     }
 }
Exemple #8
0
    void FavButtonClicked(Dictionary <string, object> dict)
    {
        int       index  = (int)dict["index"];
        FavButton button = (FavButton)dict["source"];
        DOption   option = (DOption)dropdown.options[index];

        Debug.Log("fav button clicked index:" + index + " source:" + button + " option:" + option.text);
        toggleFav(option);
        button.gameObject.GetComponent <Image>().sprite = option.image;
        dropdown.RefreshShownValue();
        itemsDirty = true;
        storeFavs();
    }
Exemple #9
0
    void FavButtonClicked(Dictionary <string, object> dict)
    {
        ImaScrollViewport viewport = GetComponentInChildren <ImaScrollViewport>();
        int          index         = (int)dict["index"];
        ImaFavButton button        = (ImaFavButton)dict["source"];
        DOption      option        = (DOption)dropdown.options[index + viewport.startVisibleIndex];

        Debug.Log("fav button clicked index:" + index + " source:" + button + " option:" + option.text);
        toggleFav(option);
        button.gameObject.GetComponent <Image>().sprite = option.image;
        dropdown.RefreshShownValue();
        itemsDirty = true;
        storeFavs();
    }
Exemple #10
0
    public void changeSlot()
    {
        DOption  option = (DOption)slotChangeDropdown.options[slotChangeDropdown.value];
        GearSlot slot   = (GearSlot)option.userObject;

        if (originals == null)
        {
            originals = db.getClothing().ToArray();
        }
        clothingItems           = originals.Where(c => shouldShow(slot, c)).ToArray();
        panelUpdater.panelItems = clothingItems.Count();

        previewIndex = 0;
        updatePageText();
        updatePreviews();
    }
Exemple #11
0
    public void updateWorldDropdown()
    {
        List <DOption> options = new List <DOption>();

        foreach (WorldSpawn spawn in worlds)
        {
            DOption option = new DOption(spawn.worldName + " - " + spawn.spawnName + " - " + spawn.pos, spawn);
            options.Add(option);
        }
        dropdown.options.Clear();
        string filter = this.filter.text.ToLower();

        dropdown.GetComponent <FavDropDown2>().SetOptions(options.Where(x => x.text.ToLower().Contains(filter)).ToList());
        //dropdown.GetComponent<FavDropDown2>().readFavs();
        //dropdown.value = startIndex;
        dropdown.RefreshShownValue();
    }
Exemple #12
0
    public void changeAppearance()
    {
        Debug.Log("Change appearance triggered", this.gameObject);
        if (appearanceDropdown.options.Count == 0)
        {
            return;
        }
        int     v      = appearanceDropdown.value;
        DOption option = (DOption)appearanceDropdown.options[v];

        if (option.userObject == null)
        {
            Debug.Log("Clearing appearing", this.gameObject);
            paperDoll.clearAppearence();
            updatePreviews();
        }
        else
        {
            entry entry = (entry)option.userObject;
            paperDoll.setAppearenceSet(entry.key);
            //paperDoll.FixedUpdate(); // force an update
            updatePreviews();
        }
    }
    // Use this for initialization
    void Start()
    {
        // prime the GUID random number generator
        Guid.NewGuid();

        GameObject lodSliderObj = GameObject.Find("LODSlider");

        if (lodSliderObj != null)
        {
            Slider lodslider = lodSliderObj.GetComponent <Slider>();
            this.LODCutoff  = PlayerPrefs.GetFloat("worldLodSlider", 0.033f);
            lodslider.value = this.LODCutoff;
            Debug.Log("Read lodcutoff:" + LODCutoff);
        }


        charC = GameObject.Find("ThirdPersonController");
        if (charC != null)
        {
            tpuc   = charC.GetComponent <ThirdPersonUserControl>();
            tpucRB = charC.GetComponent <Rigidbody>();
            charC.SetActive(false);
        }
        GameObject dropdownObj = GameObject.Find("SpawnDropdown");

        MAX_NODE_PER_FRAME = ProgramSettings.get("MAX_NODE_PER_FRAME", 15000);
        setCameraLoc(GameWorld.initialSpawn);
        map = CDRParse.getMap(GameWorld.worldName);

        if (dropdownObj != null)
        {
            dropdown = dropdownObj.GetComponent <Dropdown>();

            zoneMeshes = GameObject.Find("ZoneMeshes");
            zoneMeshes.SetActive(false);
            Material zoneBlockMaterial = Material.Instantiate(Resources.Load <Material>("borderzone"));

            zoneText = GameObject.Find("ZoneText").GetComponent <Text>();
            foreach (Zone z in map.zones)
            {
                //Debug.Log("creating zone:" + z._113Key);
                SCG.List <Vector3> points = z.points;
                GameObject         zone   = new GameObject("zone:" + z._113Key);

                PolygonCollider2D p = zone.AddComponent <PolygonCollider2D>();
                p.points   = points.Select(x => new Vector2(x.x, x.z)).ToArray();
                z.collider = p;

                GameObject zoneMesh = new GameObject("zone:" + z._113Key);
                if (z._113Key == 1802934646)
                {
                    MeshFilter   mf   = zoneMesh.AddComponent <MeshFilter>();
                    MeshRenderer mr   = zoneMesh.AddComponent <MeshRenderer>();
                    Mesh         mesh = ExtrudeSprite.CreateMesh(p.points, -10000.2f, 10000.2f);

                    mf.sharedMesh     = mesh;
                    mr.sharedMaterial = zoneBlockMaterial;


                    zoneMesh.transform.SetParent(zoneMeshes.transform);
                    zoneMesh.transform.localRotation = Quaternion.identity;
                    zoneMesh.transform.localPosition = Vector3.zero;
                }
            }
            foreach (Scene z in map.scenes)
            {
                SCG.List <Vector3> points = z.points;
                GameObject         zone   = new GameObject("scene:" + z._114Key);

                PolygonCollider2D p = zone.AddComponent <PolygonCollider2D>();
                p.points   = points.Select(x => new Vector2(x.x, x.z)).ToArray();
                z.collider = p;
            }

            dropdown.gameObject.SetActive(false);
            dropdown.options.Clear();
            int startIndex = 0;
            int i          = 0;
            foreach (WorldSpawn spawn in GameWorld.getSpawns())
            {
                if (spawn.spawnName.Equals(GameWorld.initialSpawn.spawnName))
                {
                    startIndex = i;
                }
                DOption option = new DOption(spawn.worldName + " - " + spawn.spawnName + " - " + spawn.pos, false);
                dropdown.options.Add(option);
                i++;
            }
            dropdown.value = startIndex;
            dropdown.gameObject.SetActive(true);
            dropdown.GetComponent <FavDropDown>().doOptions();
            dropdown.RefreshShownValue();
        }
        if (bigMap != null)
        {
            bigMap.setWorld(GameWorld.worldName);

            bigMap.OnSpawnClick += (s) =>
            {
                setCameraLoc(s);
            };
        }
    }
    void updateItems()
    {
        trimVisibleItems();
        for (int i = 0; i < visibleItemCount(); i++)
        {
            GameObject item;
            if (!visibleItems.TryGetValue(i, out item))
            {
                item            = GameObject.Instantiate(templateItem, gameObject.transform);
                visibleItems[i] = item;
            }

            int optionIndex = startVisibleIndex + i;
            if (optionIndex < options.Count)
            {
                DOption option = options[optionIndex];
                Text    text   = item.GetComponentInChildren <Text>();
                text.text = option.text;
                item.GetComponent <RectTransform>().anchoredPosition = new Vector2(10, (-i * itemHeight()) - 2);
                if (itemImageName != null)
                {
                    Transform itemImageObj = item.transform.FindDeepChild(itemImageName);
                    if (itemImageObj != null)
                    {
                        Image itemImage = itemImageObj.GetComponent <Image>();
                        if (itemImage != null)
                        {
                            if (option.image == null)
                            {
                                Debug.LogWarning("option image was null for option[" + option.text + ":" + option.fav + ":" + itemImage.transform);
                            }
                            itemImage.GetComponent <Image>().sprite = option.image;
                            ///Debug.Log("set sprite of itemImage to " + option.image.name, itemImage);
                        }
                        else
                        {
                            Debug.LogWarning("Unable to get image fore item image obj", itemImageObj);
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Unable to find itemImageName in item", item);
                    }
                }
                else
                {
                    Debug.LogWarning("No item imate name specified", item);
                }

                item.SetActive(true);
                item.GetComponent <ImaListItem>().userObject = option;
                item.name = i + ":" + text.text;
            }
            else
            {
                item.SetActive(false);
            }
        }

        // ensure the scrollbox is always the last sibling
        GetComponentInChildren <Scrollbar>().transform.SetAsLastSibling();
    }