Exemplo n.º 1
0
        public void UpdateSelection(OptionValueChangedEventArgs e)
        {
            if (e == null)
            {
                return;
            }
            if (inUpdate)
            {
                return;
            }
//      if (!optionItem.IsAlive) {
//        return;
//      }

//      IOptionItem oi = (IOptionItem)optionItem.Target;
            object value = e.NewValue;

            if (value == OptionItem.VALUE_UNDEFINED)
            {
                //no change
                return;
            }
            try {
                inUpdate = true;
                //lock selection for the duration of our update
                selection.BeginValueUpdate();

                ICollection <IPropertyItemDescriptor <T> > descriptors;
                descriptors = selection.Selection;

                bool hasChanged = false;
                foreach (IPropertyItemDescriptor <T> descriptor in descriptors)
                {
                    //get the propertyItem from the current lookup
                    IPropertyMap map = descriptor.Properties;
                    if (map == null)
                    {
                        continue;
                    }

                    //get value from current selection item
                    IPropertyItem item   = map.GetEntry(virtualPropertyName);
                    IValueSetter  setter = item != null ? item.Setter : null;
                    if (setter == null || !setter.CanSet())
                    {
                        continue;
                    }
                    setter.SetValue(value);
                    hasChanged = true;
                }

                if (hasChanged)
                {
                    selection.UpdateSelectedItems();
                }
            } finally {
                selection.EndValueUpdate();
                inUpdate = false;
            }
        }
Exemplo n.º 2
0
        // Handling of mod activation / deactivation
        private static void ModActiveValueChanged(object sender, OptionValueChangedEventArgs e)
        {
            // Communicate change to other players
            if (AmongUsClient.Instance.AmHost)
            {
                CustomRpcSender.RpcSetModActive(ModActive.GetValue());
            }

            // Handle it ourselfes
            if (ModActive.GetValue())
            {
                modActivated();
            }
            else
            {
                modDeactivated();
            }
        }
Exemplo n.º 3
0
        // Handling of skin activation / deactivation
        private static void SkinsAllowed_ValueChanged(object sender, OptionValueChangedEventArgs e)
        {
            // Communicate change to other players
            if (AmongUsClient.Instance.AmHost)
            {
                CustomRpcSender.RpcSetSkinsAllowed(SkinsAllowed.GetValue());
            }

            // Handle it ourselfes
            if (SkinsAllowed.GetValue())
            {
                skinsActivated();
            }
            else
            {
                skinsDeactivated();
            }
        }