Exemple #1
0
        public Toy(String ID, String Type, bool Connected = false, String Version = "", String NickName = "", String Motor = "")
        {
            this.ID    = ID;
            this.Type  = Type;
            this.Motor = Motor;

            ToysConfig newConfig = ToysConfig.createToyConfig(this.GetId());

            if (PluginConfig.Instance.ToyConfigurations != null)
            {
                if (PluginConfig.Instance.ToyConfigurations != null && PluginConfig.Instance.IsAdded(this.ID))
                {
                    newConfig = PluginConfig.Instance.getToyConfig(this.ID);
                }
                else
                {
                    PluginConfig.Instance.AddToyConfiguration(this.ID, newConfig);
                }
            }
            Config         = newConfig;
            this.Connected = Connected;
            this.NickName  = NickName;
            this.Version   = Version;
            this.on        = false;
        }
        public void SetupList()
        {
            GetVersion();
            SetUpUIElements();

            var hoverHint = modeSelection.gameObject.AddComponent <HoverHint>();

            hoverHint.text = Plugin.Control.GetMode().getDescription();
            HoverHintController hoverHintController = Resources.FindObjectsOfTypeAll <HoverHintController>().First();

            hoverHint.SetPrivateField("_hoverHintController", hoverHintController);

            List <ConnectionConfig> Connections = PluginConfig.Instance.GetConnections();

            connectionTableData.data.Clear();

            foreach (ConnectionConfig Connection in Connections)
            {
                Sprite spriteAvail = null;
                if (Connection.Active)
                {
                    spriteAvail = Utilities.LoadSpriteFromResources("LovenseBSControl.Resources.Sprites.available_profile.png");
                }

                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(Connection.Name, Connection.Prefix + Connection.IpAdress + ":" + Connection.Port, spriteAvail);
                connectionTableData.data.Add(customCellInfo);
            }

            connectionTableData.tableView.ReloadData();
            this.selectedConnection = Connections[this.selectedConnectionNumber];
            toggleStatusBtn.text    = this.selectedConnection.Active ? "Disable" : "Enable";

            connectionTableData.tableView.ScrollToCellWithIdx(this.selectedConnectionNumber, TableView.ScrollPositionType.Beginning, false);
            connectionTableData.tableView.SelectCellWithIdx(this.selectedConnectionNumber);


            if (!Plugin.Control.IsToyAvailable())
            {
                return;
            }
            List <Toy> Toys = Plugin.Control.GetToyList();

            customListTableData.data.Clear();

            foreach (Toy toy in Toys)
            {
                Sprite     sprite    = Utilities.LoadSpriteFromResources("LovenseBSControl.Resources.Sprites." + toy.GetPictureName());
                ToysConfig toyConfig = toy.GetToyConfig();
                CustomListTableData.CustomCellInfo customCellInfo = new CustomListTableData.CustomCellInfo(toy.GetNickName(), toy.GetText() + " - " + ((toy.IsConnected() ? "Connected" : "Disconnected") + (toy.IsConnected()? " - " + toy.getBattery() + "%" : "") + " - " + toyConfig.HType), sprite);
                customListTableData.data.Add(customCellInfo);
            }

            customListTableData.tableView.ReloadData();
            this.selectedToy = Toys[this.selectedToyNumber];

            customListTableData.tableView.ScrollToCellWithIdx(this.selectedToyNumber, TableView.ScrollPositionType.Beginning, false);
            customListTableData.tableView.SelectCellWithIdx(this.selectedToyNumber);
        }
 public void onChangeHands(string data)
 {
     if (this.selectedToy != null)
     {
         ToysConfig config = this.selectedToy.GetToyConfig();
         config.setHType(data);
         SetupList();
     }
 }