Example #1
0
        public void TriggerSwitch(SwitchType expectedType, HitableType expectedHitType = HitableType.BOTH)
        {
            //Check if correct switch and if its active
            if (expectedType != type)
            {
                return;
            }
            if (activated)
            {
                return;
            }

            //Call Trigger
            TriggerSwitch(expectedHitType);

            //Play any cutscene
            if (hasCutscene)
            {
                StartCoroutine(CutsceneManager.cutsceneManager.PlayCutscene(scenes));
            }

            //Index, and make inactive if permanent
            index++;
            if (index >= switchEvents.Length)
            {
                index = 0;
            }
            if (index == 0 && permanent)
            {
                activated = true;
            }
        }
Example #2
0
 private void BtnCnCNetLobby_LeftClick(object sender, EventArgs e)
 {
     LastSwitchType = SwitchType.SECONDARY;
     primarySwitches[primarySwitches.Count - 1].SwitchOff();
     cncnetLobbySwitch.SwitchOn();
     privateMessageSwitch.SwitchOff();
 }
Example #3
0
        private static void ApplySwitchState(SwitchType switch_type, string new_state, Action callback)
        {
            if (switch_type.State != new_state)
            {
                Chameleon.Invalidate();

                InvalidateOptions options = new InvalidateOptions();
                options.Time     = 100;
                options.Callback = callback;

                string class_state_suffix = "";
                if (switch_type.State != null)
                {
                    class_state_suffix = "-" + switch_type.State;
                }

                string current_class = switch_type.ClassName + class_state_suffix;
                string new_class     = switch_type.ClassName + "-" + new_state;

                jQuery.Select("." + current_class).RemoveClass("switch-" + switch_type.State).AddClass("switch-" + new_state);
                jQuery.Select("." + current_class).RemoveClass(current_class).AddClass(new_class)
                .Plugin <ChameleonUiObject>().ChameleonInvalidate(options);

                switch_type.State = new_state;

                Chameleon.InvalidateTwo();
            }
        }
    public void TryGoToNextScene()
    {
        string text = "BE~~~~~~";

        if (m_CarIndex == 4)
        {
            this.ChangeSpeakText(text);
            return;
        }

        if (!m_Hero.m_HoldPassCard)
        {
            this.ChangeSpeakText(text);
            return;
        }
        if (m_CarIndex == 3 &&
            SpeakerManager.instance.m_Handsome.m_CurLineIdx_Night != 5)
        {
            this.ChangeSpeakText(text);
            return;
        }

        text = "Goto the next scene?";
        this.ChangeSpeakText(text);

        m_Btn_Yes.SetActive(true);
        m_Btn_No.SetActive(true);
        m_CurSwitch = SwitchType.GoToNextScene;
    }
Example #5
0
        internal CommandSwitch(string name, string abbreviation, SwitchType switchType, OperationalContext switchLevel = DefaultSwitchLevel)
        {
            // ensure that name doesn't start with the switch indicators.
            // also convert to lower-case
            if (name.StartsWith(FullSwitchIndicator))
            {
                this.Name = name.Substring(FullSwitchIndicator.Length);
            }
            else
            {
                this.Name = name;
            }

            if (abbreviation.StartsWith(AbbreviationSwitchIndicator))
            {
                this.Abbreviation = abbreviation.Substring(AbbreviationSwitchIndicator.Length);
            }
            else
            {
                this.Abbreviation = abbreviation;
            }

            this.SwitchType  = switchType;
            this.SwitchLevel = switchLevel;

            System.Diagnostics.Debug.Assert(!s_allSwitches.Any(s => s.Equals(this)), $"A switch with name or abbreviation '{name}+{abbreviation}' has already been crated!");

            s_allSwitches.Add(this);
        }
        /// <summary>
        /// Called when "deleteAllSwitch" switch is toggled or untoggled.
        /// </summary>
        /// <param name="sender">Switch</param>
        /// <param name="e">ToggledEventArgs</param>
        private void DeleteAllSwitch_Toggled(object sender, ToggledEventArgs e)
        {
            if (OnAlldeleted == SwitchType.SingleSwitch)
            {
                return;
            }

            OnAlldeleted = SwitchType.WholeSwitch;
            // According to the value to which 'deleteAllSwitch' switch is toggled, make all data items' Delete value updated.
            foreach (CityRecord record in info.CityRecordList)
            {
                record.Delete = e.Value;
            }
            // Update titleBar's Text based on how many delete switches are on.
            if (e.Value)
            {
                titleBar.TitleLabel.Text = info.CityRecordList.Count + " selected";
                selectedItems            = info.CityRecordList.Count;
            }
            else
            {
                titleBar.TitleLabel.Text = "0 selected";
                selectedItems            = 0;
            }

            OnAlldeleted = SwitchType.None;
        }
Example #7
0
 private void BtnMainButton_LeftClick(object sender, EventArgs e)
 {
     LastSwitchType = SwitchType.PRIMARY;
     cncnetLobbySwitch.SwitchOff();
     privateMessageSwitch.SwitchOff();
     primarySwitches[primarySwitches.Count - 1].SwitchOn();
 }
Example #8
0
    public override void ShowGUI()
    {
        linkedConversation = (Conversation)EditorGUILayout.ObjectField("Conversation:", linkedConversation, typeof(Conversation), true);

        Conversation conv = linkedConversation;

        if (conv)
        {
            ButtonDialog[] optionsArray = conv.options.ToArray();
            string[]       options      = new string[optionsArray.Length];

            for (int j = 0; j < options.Length; j++)
            {
                options[j] = optionsArray[j].label;
            }

            if (optionNumber > options.Length - 1)
            {
                // Cap max if some were removed
                optionNumber = options.Length - 1;
            }

            optionNumber = EditorGUILayout.Popup(optionNumber, options);
        }

        switchType = (SwitchType)EditorGUILayout.EnumPopup("Set to:", switchType);

        AfterRunningOption();
    }
Example #9
0
        /// <summary>
        /// 创建电源输出控制指令
        /// </summary>
        /// <param name="switchType">开关量</param>
        /// <returns>电源输出控制指令</returns>
        public string OutputCmd(SwitchType switchType)
        {
            ScpiCmdBuilder.AppendCmdInMessage(ref strBuilder, EScpiCmd.Output);
            ScpiCmdBuilder.AppendParamsInMessage(ref strBuilder, (int)switchType);

            return(ScpiCmdBuilder.ToCmdMsg(strBuilder));
        }
Example #10
0
 public SwitchTile(TileType tileType, int tileID, Texture2D switchOffTexture, Texture2D switchOnTexture, SwitchType setType, String linkedTileString)
     : base(tileType, tileID, switchOffTexture)
 {
     switchType = setType;
     linkedTileDict = new Dictionary<EventType,List<Tile>>();
     unparsedCoordinateString = linkedTileString;
 }
 public SwitchProfile(SwitchType switchType, string winTitle, int monitorToSwitch, int del)
 {
     type = switchType;
     windowTitle = winTitle;
     monitorToSwitchTo = monitorToSwitch;
     delay = del;
 }
        /// <summary>
        /// Edit a switch registered with the HomeWizard
        /// </summary>
        /// <param name="id">Required: Id of the switch</param>
        /// <param name="name">Required: Name of the switch (max 15 characters)</param>
        /// <param name="type">Required: Type of the switch</param>
        public async Task EditSwitch(long id, string name, SwitchType type)
        {
            string switchType     = type.ToString().ToLowerInvariant();
            string urlEncodedName = WebUtility.UrlEncode(CleanName(name));

            await GetData("sw/edit/" + id + "/" + urlEncodedName + "/no/" + switchType + "/0");
        }
Example #13
0
            /// <summary>
            /// Starts the process of creating a <see cref="Switch"/>.
            /// </summary>
            /// <param name="type">The type of switch.</param>
            /// <returns>Returns a <see cref="Builder"/>.</returns>
            public static Builder Start(SwitchType type)
            {
                Builder builder = new Builder();

                builder.instance.type = type;
                return(builder);
            }
Example #14
0
        /// <summary>
        /// Get the SwitchType using IP Address of the Network Switch
        /// </summary>
        /// <param name="ipAddress">IP Address of Network Switch</param>
        /// <returns><see cref="SwitchType"/></returns>
        private static SwitchType GetSwitchType(IPAddress ipAddress)
        {
            TelnetIpc  telnet     = new TelnetIpc(ipAddress.ToString(), 23);
            SwitchType switchType = SwitchType.None;

            try
            {
                telnet.Connect();
                telnet.SendLine(" ");
                Thread.Sleep(1000);
                // This command is tested currently only for HP ProCurve switch, need to check for other switches how it behaves
                telnet.SendLine("show config");
                Thread.Sleep(3000);
                string data = telnet.ReceiveUntilMatch("$");

                // HP manufactured switch can contain any of the strings.
                // ProCurve, Hewlett-Packard, Hewlett Packard
                if (data.Contains("ProCurve", StringComparison.CurrentCultureIgnoreCase) || data.Contains("Hewlett-Packard", StringComparison.CurrentCultureIgnoreCase) || data.Contains("Hewlett Packard", StringComparison.CurrentCultureIgnoreCase))
                {
                    switchType = SwitchType.HPProCurve;
                }
            }
            finally
            {
                telnet.Dispose();
                Thread.Sleep(1000);
            }

            return(switchType);
        }
Example #15
0
    public void ChangePushState(SwitchType _typeId, uint _state)
    {
        CsSystemChangeSwitch p = PacketObject.Create <CsSystemChangeSwitch>();

        p.switchId = (byte)_typeId;
        p.value    = _state;
        session.Send(p);
    }
 /// <summary>
 ///     Initializes a new instance of the <see cref="PlaceSendMessage" /> class.
 /// </summary>
 public SwitchPressSendMessage(SwitchType switchType, int id, bool enabled, int x, int y)
 {
     this.X          = x;
     this.Y          = y;
     this.SwitchType = switchType;
     this.Id         = id;
     this.Enabled    = enabled;
 }
        //TODO: Hue lights
        //command: sw/<switch id>/[on/off]/[0..360]/[0..100]/[0..100]
        //Control a Hue light. Where the on or off switches the light on or off. The other values are: Hue, Saturation and Brightness in that order.

        /// <summary>
        /// Add a switch to the HomeWizard
        /// </summary>
        /// <param name="name">Required: Name of the switch (max 15 characters)</param>
        /// <param name="type">Required: Type of the switch</param>
        /// <param name="code">Required: Code of the switch</param>
        /// <returns>Id of the added switch</returns>
        public async Task <long> AddSwitch(string name, SwitchType type, string code)
        {
            string    switchType     = type.ToString().ToLowerInvariant();
            string    urlEncodedName = WebUtility.UrlEncode(CleanName(name));
            NewSwitch added          = await GetData <NewSwitch>("sw/add/" + urlEncodedName + "/" + switchType + "/" + code);

            return(added.Id);
        }
        void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored)
        {
            logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString());

            SwitchInfo switchInfo = new SwitchInfo();

            switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem);
            switchInfo.Level      = 0;
            switchInfo.Type       = switchType;

            switchInfo.IsColored = isColored;
            switchInfo.Color     = Color.Black;

            registeredSwitches.Add(switchPort, switchInfo);

            string switchFriendlyName = switchPort.GetInfo().GetFriendlyName();

            switchFriendlyNames.Add(switchFriendlyName, switchPort);

            if (switchInfo.Capability != null)
            {
                IList <VParamType> retVals;

                if (switchType == SwitchType.Multi)
                {
                    retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null,
                                                ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        switchInfo.Level = (double)retVals[0].Value();
                    }
                }
                else
                {
                    retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null,
                                                ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        bool boolLevel = (bool)retVals[0].Value();
                        switchInfo.Level = (boolLevel) ? 1 : 0;
                    }
                }
            }
        }
        /// <summary>
        /// Add a switch to the configuration
        /// </summary>
        /// <param name="Name">Switch Name</param>
        /// <param name="Number">Pretty unencoded switch number</param>
        /// <param name="Type">NO = Normally Open (leaf), NC = Normally Closed (optos)</param>
        public void AddSwitch(string Name, string Number, SwitchType Type = SwitchType.NO)
        {
            SwitchConfigFileEntry se = new SwitchConfigFileEntry();

            se.Name   = Name;
            se.Type   = Type;
            se.Number = Number;
            PRSwitches.Add(se);
        }
Example #20
0
 private void OnValueChanged(bool isOn, SwitchType type)
 {
     if (!tempState.ContainsKey(type))
     {
         return;
     }
     tempState[type] = isOn ? (uint)1 : 0;
     CheckBtnSave();
 }
 public SwitchForm(string idString, SwitchType type, bool multi, int minLen, int maxLen, string postCharSet)
 {
     IDString    = idString;
     Type        = type;
     Multi       = multi;
     MinLen      = minLen;
     MaxLen      = maxLen;
     PostCharSet = postCharSet;
 }
Example #22
0
        public void SwitchDefaultOnly()
        {
            bool executed = false;
            var  item     = new TypeA();

            item.Switch(
                SwitchType.Default(() => executed = true));
            Assert.True(executed);
        }
Example #23
0
        public void SwitchTypeNoValidCase()
        {
            bool executed = false;
            var  item     = new TypeB();

            item.Switch(
                SwitchType.Case <TypeA>(() => executed = true));
            Assert.False(executed);
        }
Example #24
0
 public SwitchForm(string idString, SwitchType type, bool multi, int minLen, int maxLen, string postCharSet)
 {
     this.IDString    = idString;
     this.Type        = type;
     this.Multi       = multi;
     this.MinLen      = minLen;
     this.MaxLen      = maxLen;
     this.PostCharSet = postCharSet;
 }
Example #25
0
 public SwitchForm(String idString, SwitchType type, Boolean multi,
                   Int32 minLen, Int32 maxLen, String postCharSet)
 {
     this.IDString    = idString;
     this.Type        = type;
     this.Multi       = multi;
     this.MinLen      = minLen;
     this.MaxLen      = maxLen;
     this.PostCharSet = postCharSet;
 }
Example #26
0
 public MenuItem(string t, string a, string p, bool e, SwitchType st = SwitchType.None, int rmax = 0)
 {
     Title    = t;
     Action   = a;
     Param    = p;
     Enabled  = e;
     sType    = st;
     rangeval = 0;
     rangemax = rmax;
 }
Example #27
0
 public SwitchForm(string idString, SwitchType type, bool multi,
     int minLen, int maxLen, string postCharSet)
 {
     IDString = idString;
     Type = type;
     Multi = multi;
     MinLen = minLen;
     MaxLen = maxLen;
     PostCharSet = postCharSet;
 }
Example #28
0
        public void SwitchDefaultExecuted()
        {
            bool executed = false;
            var  item     = new TypeB();

            item.Switch(
                SwitchType.Case <TypeA>(() => Expression.Empty()),
                SwitchType.Default(() => executed = true));
            Assert.True(executed);
        }
Example #29
0
    public static SwitchExit NextValid(this SwitchExit value, SwitchType type)
    {
        var next = value.Next();

        if (type == SwitchType.TwoWay && next == SwitchExit.Ahead)
        {
            next = next.Next();
        }
        return(next);
    }
Example #30
0
        public void SwitchTypeHappyFlow()
        {
            bool executed = false;
            var  item     = new TypeA();

            item.Switch(
                SwitchType.Case <TypeA>(() => executed = true),
                SwitchType.Default(() => throw new Exception("This case should not be executed.")));
            Assert.True(executed);
        }
Example #31
0
 public SwitchCommand(string switchCommand, string switchValue)
 {
     this.commandSwitch = SwitchType.DataArgument;
     try
     {
         this.commandSwitch = (SwitchType)Enum.Parse(typeof(SwitchType), switchCommand, true);
     }
     catch { }
     this.commandName  = switchCommand.ToLowerInvariant();
     this.commandValue = switchValue.Replace("\"", string.Empty);
 }
Example #32
0
        private void BtnCnCNetLobby_LeftClick(object sender, EventArgs e)
        {
            LastSwitchType = SwitchType.SECONDARY;
            primarySwitches[primarySwitches.Count - 1].SwitchOff();
            cncnetLobbySwitch.SwitchOn();
            privateMessageSwitch.SwitchOff();

            // HACK warning
            // TODO: add a way for DarkeningPanel to skip transitions
            ((DarkeningPanel)((XNAControl)cncnetLobbySwitch).Parent).Alpha = 1.0f;
        }
Example #33
0
 protected Solution()
 {
     this.Key = "solution";
     _nNonOrthogonalCorrectors = 0;
     _momentumPredictor        = SwitchType.on;
     _transonic  = SwitchType.off;
     _consistent = SwitchType.off;
     _residual   = new Residual();
     _pRefCell   = 0;
     _pRefValue  = 0;
 }
        internal CommandSwitch(string name, string abbreviation, SwitchType switchType)
        {
            //ensure that either name doesn't start with '/' or '-'
            //also convert to lower-case
            if ((name[0] == '/') || (name[0] == '-'))
                this.name = (name.Substring(1)).ToLower(CultureInfo.InvariantCulture);
            else
                this.name = name.ToLower(CultureInfo.InvariantCulture);
            if ((abbreviation[0] == '/') || (abbreviation[0] == '-'))
                this.abbreviation = (abbreviation.Substring(1)).ToLower(CultureInfo.InvariantCulture);
            else
                this.abbreviation = abbreviation.ToLower(CultureInfo.InvariantCulture);

            this.switchType = switchType;
        }
Example #35
0
        /// <summary>
        /// Decodes an argument.
        /// </summary>
        /// <param name="arg">The argument string to decode.</param>
        /// <param name="name">Contains the name of the switch on return.</param>
        /// <param name="value">Contains the value of the argument on return.</param>
        /// <param name="switchType">Contains the type of switch on return.</param>
        /// <returns>True if the argument was valid false otherwise.</returns>
        static bool DecodeArgument(string arg, out string name, out string value, out SwitchType switchType)
        {
            bool lbValid = false;

            name = string.Empty;
            value = string.Empty;
            switchType = SwitchType.NA;

            // Check for switch
            if (arg.StartsWith("/"))
            {
                // If the switch is valid
                if (arg.Length > 1)
                {
                    // Determine switch type
                    switch(arg[1])
                    {
                        default: switchType = SwitchType.On; break;
                        case '-': { arg = "/" + arg.Substring(2); switchType = SwitchType.Off; break; }
                        case '+': { arg = "/" + arg.Substring(2); switchType = SwitchType.On; break; }
                    }

                    // Check for value
                    int liPos = arg.IndexOf(":");
                    value = string.Empty;

                    // Get name if no value
                    if (liPos == -1)
                        name = arg.Substring(1).ToUpper();
                    else
                    {
                        // Get name and value
                        name = arg.Substring(1, liPos - 1).ToUpper();
                        value = arg.Substring(liPos + 1);
                    }

                    lbValid = true;
                }
            }
            else
            {
                // Use argument as value only
                value = arg;
                lbValid = true;
            }

            return lbValid;
        }
Example #36
0
        public override void ShowGUI()
        {
            linkedConversation = (Conversation) EditorGUILayout.ObjectField ("Conversation:", linkedConversation, typeof (Conversation), true);

            if (linkedConversation)
            {
                linkedConversation.Upgrade ();
            }

            constantID = FieldToID <Conversation> (linkedConversation, constantID);
            linkedConversation = IDToField <Conversation> (linkedConversation, constantID, true);

            if (linkedConversation)
            {
                optionNumber = ShowOptionGUI (linkedConversation.options, optionNumber);
            }

            switchType = (SwitchType) EditorGUILayout.EnumPopup ("Set to:", switchType);

            AfterRunningOption ();
        }
Example #37
0
 /// <summary>
 /// Creates a new Switch object
 /// </summary>
 /// <param name="game">The GameController this switch belongs to</param>
 /// <param name="name">The pretty name of this switch</param>
 /// <param name="number">The encoded number of this switch</param>
 /// <param name="sType">Switch type NO = Normally Open (leaf switches), NC = Normally Closed (optos)</param>
 public Switch(GameController game, string name, ushort number, SwitchType sType = SwitchType.NO)
     : base(game, name, number)
 {
     this._type = sType;
 }
Example #38
0
 public SwitchForm(string idString, SwitchType type, bool multi, int minLen)
     : this(idString, type, multi, minLen, 0, "")
 {
 }
Example #39
0
 public SwitchForm(string idString, SwitchType type, bool multi)
     : this(idString, type, multi, 0)
 {
 }
        void SwitchNWrite(BlockRecord RecIn, SwitchType Change)
        {
            // As a temp, this will just grab the correct offset and write to it
            // I disabled the switch/backup effect in order to preserve functionality
            //
            // RECONSTRUCT
            //

            bool canswitch = (xSTFSStruct.ThisType == STFSType.Type1);
            //const uint basetable = 0xFFFFF000;
            BlockRecord current = xSTFSStruct.TopRecord;
            long[] pos = new long[] { 0, 0, 0 };
            // Grab base starting points
            if (RecIn.ThisBlock >= Constants.BlockLevel[0] ||
                xSTFSStruct.xBlockCount > Constants.BlockLevel[0])
            {
                if (RecIn.ThisBlock >= Constants.BlockLevel[1] ||
                    xSTFSStruct.xBlockCount > Constants.BlockLevel[1])
                    pos[0] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L2) + 0x14;
                pos[1] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L1) + 0x14;
            }
            pos[2] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L0) + 0x14;
            //bool wipe = current.BlocksFree >= (Constants.BlockLevel[1] * Constants.BlockLevel[0]);
            long len = GenerateDataOffset(RecIn.ThisBlock) + 0x1000;
            if (xIO.Length < len)
                xIO.SetLength(len);
            if (Change == SwitchType.Allocate)
                xSTFSStruct.TopRecord.BlocksFree--;
            else if (Change == SwitchType.Delete)
                xSTFSStruct.TopRecord.BlocksFree++;
            if (pos[0] != 0)
            {
                //if (wipe)
                //{
                //    xIO.Position = (pos[0] & basetable) + (current.Index << 0xC);
                //    xIO.Write(new byte[0x1000]);
                //    xIO.Flush();
                //}
                /*if (canswitch) // If this table hasn't been switched yet
                {
                    if (!switched2)
                    {
                        xIO.Position = (pos[0] & basetable) + (current.Index << 0xC); // Get starting of table
                        byte[] data = xIO.ReadBytes(0x1000); // Read it
                        xSTFSStruct.TopRecord.Switch(); // Switch the index
                        pos[0] += (xSTFSStruct.TopRecord.Index << 0xC); // Add to the base STFS function result
                        xIO.Position = (pos[0] & basetable); // Go to new position and write it
                        xIO.Write(data);
                        xIO.Flush();
                        data = null;
                        switched2 = true;
                    }
                    else pos[0] += (current.Index << 0xC); // Already switched, add the index
                }*/

                //KILL ON RECONSTRUCTION
                if (canswitch)
                    pos[0] += (current.Index << 0xC);
                // ---------------------

                xIO.Position = pos[0];
                current = new BlockRecord(xIO.ReadUInt32());
                //wipe = current.BlocksFree >= Constants.BlockLevel[1];
                if (Change != SwitchType.None)
                {
                    if (Change == SwitchType.Allocate)
                        current.BlocksFree--; // Takes away a free block
                    else current.BlocksFree++; // Adds a free block
                    xIO.Position = pos[0];
                    xIO.Write(current.Flags);
                    xIO.Flush();
                }
            }
            // Follows same pattern
            if (pos[1] != 0)
            {
                //if (wipe)
                //{
                //    xIO.Position = (pos[1] & basetable) + (current.Index << 0xC);
                //    xIO.Write(new byte[0x1000]);
                //    xIO.Flush();
                //}
                /*if (canswitch)
                {
                    if (!switched1.Contains((int)(RecIn.ThisBlock / Constants.BlockLevel[1])))
                    {
                        xIO.Position = (pos[1] & basetable) + (current.Index << 0xC);
                        byte[] data = xIO.ReadBytes(0x1000);
                        current.Switch();
                        pos[1] += (current.Index << 0xC);
                        xIO.Position = (pos[1] & basetable);
                        xIO.Write(data);
                        xIO.Flush();
                        data = null;
                        if (pos[0] != 0)
                        {
                            xIO.Position = pos[0];
                            xIO.Write(current.Flags);
                            xIO.Flush();
                        }
                        switched1.Add((int)(RecIn.ThisBlock / Constants.BlockLevel[1]));
                        if (xSTFSStruct.xBlockCount <= Constants.BlockLevel[1])
                            xSTFSStruct.TopRecord.Switch();
                    }
                    else pos[1] += (current.Index << 0xC);
                }*/

                //KILL ON RECONSTRUCTION
                if (canswitch)
                    pos[1] += (current.Index << 0xC);
                // ---------------------

                xIO.Position = pos[1];
                current = new BlockRecord(xIO.ReadUInt32());
                //wipe = current.BlocksFree >= Constants.BlockLevel[0];
                if (Change != SwitchType.None)
                {
                    if (Change == SwitchType.Allocate)
                        current.BlocksFree--; // Takes away a free block
                    else current.BlocksFree++; // Adds a free block
                    xIO.Position = pos[1];
                    xIO.Write(current.Flags);
                    xIO.Flush();
                }
            }
            //if (wipe)
            //{
            //    xIO.Position = (pos[0] & basetable) + (current.Index << 0xC);
            //    xIO.Write(new byte[0x1000]);
            //    xIO.Flush();
            //}
            /*if (canswitch)
            {
                if (!switched0.Contains((int)(RecIn.ThisBlock / Constants.BlockLevel[0])))
                {
                    xIO.Position = (pos[2] & basetable) + (current.Index << 0xC);
                    byte[] data = xIO.ReadBytes(0x1000);
                    current.Switch();
                    pos[2] += (current.Index << 0xC);
                    xIO.Position = (pos[2] & basetable);
                    xIO.Write(data);
                    xIO.Flush();
                    data = null;
                    if (pos[1] != 0)
                    {
                        xIO.Position = pos[1];
                        xIO.Write(current.Flags);
                        xIO.Flush();
                    }
                    switched1.Add((int)(RecIn.ThisBlock / Constants.BlockLevel[0]));
                    if (xSTFSStruct.xBlockCount <= Constants.BlockLevel[0])
                        xSTFSStruct.TopRecord.Switch();
                }
                else pos[2] += (current.Index << 0xC);
            }*/

            //KILL ON RECONSTRUCTION
            if (canswitch)
                pos[2] += (current.Index << 0xC);
            // ---------------------

            if (Change == SwitchType.Allocate)
            {
                if (RecIn.Status == HashStatus.Old)
                    RecIn.Status = HashStatus.Reused;
                else RecIn.Status = HashStatus.New;
            }
            else if (Change == SwitchType.Delete)
                RecIn.MarkOld();
            xIO.Position = pos[2];
            xIO.Write(RecIn.Flags);
            xIO.Flush();
            if (RecIn.ThisBlock >= xSTFSStruct.xBlockCount)
                xSTFSStruct.xBlockCount = RecIn.ThisBlock + 1;
        }
        public void Start()
        {
            switch (groupName)
            {
                case "Gear":
                    actionGroup = KSPActionGroup.Gear;
                    break;
                case "Brakes":
                    actionGroup = KSPActionGroup.Brakes;
                    break;
                case "Light":
                    actionGroup = KSPActionGroup.Light;
                    break;
                case "RCS":
                    actionGroup = KSPActionGroup.RCS;
                    break;
                case "SAS":
                    actionGroup = KSPActionGroup.SAS;
                    break;
                case "Stage":
                    customAction = true;
                    //actionGroup = KSPActionGroup.Stage;
                    break;
                case "Abort":
                    actionGroup = KSPActionGroup.Abort;
                    break;
                case "Custom01":
                    actionGroup = KSPActionGroup.Custom01;
                    break;
                case "Custom02":
                    actionGroup = KSPActionGroup.Custom02;
                    break;
                case "Custom03":
                    actionGroup = KSPActionGroup.Custom03;
                    break;
                case "Custom04":
                    actionGroup = KSPActionGroup.Custom04;
                    break;
                case "Custom05":
                    actionGroup = KSPActionGroup.Custom05;
                    break;
                case "Custom06":
                    actionGroup = KSPActionGroup.Custom06;
                    break;
                case "Custom07":
                    actionGroup = KSPActionGroup.Custom07;
                    break;
                case "Custom08":
                    actionGroup = KSPActionGroup.Custom08;
                    break;
                case "Custom09":
                    actionGroup = KSPActionGroup.Custom09;
                    break;
                case "Custom10":
                    actionGroup = KSPActionGroup.Custom10;
                    break;
                default:
                    customAction = true;
                    break;
            }
            actionGroupNumber = BaseAction.GetGroupIndex(actionGroup);
            switchObjectTransform = base.internalProp.FindModelTransform(switchObjectName);

            buttonObject = base.internalProp.FindModelTransform(buttonTrigger).gameObject;
            buttonHandler = buttonObject.AddComponent<FSgenericButtonHandler>();
            buttonHandler.mouseDownFunction = buttonClick;
            //buttonObject.AddComponent<FSswitchButtonHandler>();
            //buttonObject.GetComponent<FSswitchButtonHandler>().buttonNumber = 1;
            //buttonObject.GetComponent<FSswitchButtonHandler>().target = base.internalProp.gameObject;

            try
            {
                switchTypeEnum = (SwitchType) Enum.Parse(typeof(SwitchType), switchType, true);
            }
            catch
            {
                switchTypeEnum = SwitchType.undefined;
            }
        }
Example #42
0
 public Button(byte midiNote, byte velocity, SwitchType switchType)
 {
     MidiNote = midiNote;
     Velocity = velocity;
     SwitchType = switchType;
 }
Example #43
0
 /// <summary>
 /// Add a switch to the configuration
 /// </summary>
 /// <param name="Name">Switch Name</param>
 /// <param name="Number">Pretty unencoded switch number</param>
 /// <param name="Type">NO = Normally Open (leaf), NC = Normally Closed (optos)</param>
 public void AddSwitch(string Name, string Number, SwitchType Type = SwitchType.NO)
 {
     SwitchConfigFileEntry se = new SwitchConfigFileEntry();
     se.Name = Name;
     se.Type = Type;
     se.Number = Number;
     PRSwitches.Add(se);
 }
        void SwitchNWrite(BlockRecord RecIn, SwitchType Change)
        {
            bool canswitch = (xSTFSStruct.ThisType == STFSType.Type1);

            BlockRecord current = xSTFSStruct.TopRecord;
            long[] pos = new long[] { 0, 0, 0 };
            // Grab base starting points
            if (RecIn.ThisBlock >= Constants.BlockLevel[0] ||
                xSTFSStruct.xBlockCount > Constants.BlockLevel[0])
            {
                if (RecIn.ThisBlock >= Constants.BlockLevel[1] ||
                    xSTFSStruct.xBlockCount > Constants.BlockLevel[1])
                    pos[0] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L2) + 0x14;
                pos[1] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L1) + 0x14;
            }
            pos[2] = xSTFSStruct.GenerateHashOffset(RecIn.ThisBlock, TreeLevel.L0) + 0x14;

            long len = GenerateDataOffset(RecIn.ThisBlock) + 0x1000;
            if (xIO.Length < len)
                xIO.SetLength(len);
            if (Change == SwitchType.Allocate)
                xSTFSStruct.TopRecord.BlocksFree--;
            else if (Change == SwitchType.Delete)
                xSTFSStruct.TopRecord.BlocksFree++;
            if (pos[0] != 0)
            {
                if (canswitch)
                    pos[0] += (current.Index << 0xC);
                // ---------------------

                xIO.Position = pos[0];
                current = new BlockRecord(xIO.ReadUInt32());

                if (Change != SwitchType.None)
                {
                    if (Change == SwitchType.Allocate)
                        current.BlocksFree--; // Takes away a free block
                    else
                        current.BlocksFree++; // Adds a free block
                    xIO.Position = pos[0];
                    xIO.Write(current.Flags);
                    xIO.Flush();
                }
            }
            // Follows same pattern
            if (pos[1] != 0)
            {

                if (canswitch)
                    pos[1] += (current.Index << 0xC);
                // ---------------------

                xIO.Position = pos[1];
                current = new BlockRecord(xIO.ReadUInt32());

                if (Change != SwitchType.None)
                {
                    if (Change == SwitchType.Allocate)
                        current.BlocksFree--; // Takes away a free block
                    else
                        current.BlocksFree++; // Adds a free block
                    xIO.Position = pos[1];
                    xIO.Write(current.Flags);
                    xIO.Flush();
                }
            }

            if (canswitch)
                pos[2] += (current.Index << 0xC);
            // ---------------------

            if (Change == SwitchType.Allocate)
            {
                if (RecIn.Status == HashStatus.Old)
                    RecIn.Status = HashStatus.Reused;
                else
                    RecIn.Status = HashStatus.New;
            }
            else if (Change == SwitchType.Delete)
                RecIn.MarkOld();
            xIO.Position = pos[2];
            xIO.Write(RecIn.Flags);
            xIO.Flush();
            if (RecIn.ThisBlock >= xSTFSStruct.xBlockCount)
                xSTFSStruct.xBlockCount = RecIn.ThisBlock + 1;
        }
Example #45
0
    protected GameObject CreateSwitch(SwitchType type, int x, int y)
    {
        GameObject obj = null;

        switch(type)
        {
        case SwitchType.KICK:
            obj = gameManager.kickSwitch;
            break;

        case SwitchType.CLAP:
            obj = gameManager.clapSwitch;
            break;

        case SwitchType.SNARE:
            obj = gameManager.snareSwitch;
            break;

        case SwitchType.FBASS:
            obj = gameManager.fbassSwitch;
            break;

        case SwitchType.SYNTH:
            obj = gameManager.synthSwitch;
            break;

        case SwitchType.SYNTH2:
            obj = gameManager.synth2Switch;
            break;

        case SwitchType.LEVEL_END:
            obj = gameManager.endSwitch;
            break;
        }

        GameObject switchObj = (GameObject)Instantiate(obj, new Vector3(transform.position.x + (x * scale), transform.position.y + (y * scale), -2), Quaternion.identity);
        switchObj.transform.parent = gameObject.transform;
        switchObj.transform.Rotate(new Vector3(90, 180, 0));
        switchObj.transform.localScale = new Vector3(scale * 0.1f , 1, scale * 0.1f);

        return switchObj;
    }
Example #46
0
        /***********************************************************************************************/
        /// <summary>
        /// Method creates a 
        /// </summary>

        /// <param name="resourceId">The Bit position to be toggeled</param>
        /// <param name="switchType">Inidicated whether to set or clear the bit</param>
        /// <param name="accessToken">The access token to be evaluated</param>
        /// <returns>Modified Access Token</returns>

        public string CreateToken(int resourceId, SwitchType switchType, string accessToken)
        {

            string result = string.Empty;
            int position = 0;
            int count = 0;
            byte[] binary;

            // DONE: Remove the first and last characters from the Token
            // Cconvert the accessToken in to Character Array
            char[] accessChars = accessToken.ToCharArray();
            // If resourceId is less then or equal to CharacterArray times 8 then continue
            //

            if (resourceId <= accessChars.Length * BIT_COUNT)
            {

                // One base instead of Zero base to support Nexsure
                //
                if (resourceId > 0)
                {
                    resourceId--;
                }

                // Convert the Character Array to Byte Array
                //
                binary = System.Text.Encoding.Default.GetBytes(accessChars);
                Array.Reverse(binary);

                // If the bit position is greater then 7 get the byte where the
                //  bit is located
                if (resourceId > 7)
                {
                    position = (byte)Math.Floor((double)(resourceId / BIT_COUNT));
                    count = resourceId - (position * BIT_COUNT);
                }

              // Else we know the bit is located in the first byte
                //
                else
                {
                    position = 0;
                    count = resourceId;
                }

                // Get the byte from the byte Array that holds the bit
                //
                byte x = binary[position];
                //If Switch Type is On then we change the value to 1
                //
                if (switchType == SwitchType.On)
                {
                    x |= BIT_ON[count];
                }

                // else we change the value to 0
                //
                else
                {
                    x &= BIT_OFF[count];
                }

                // Insert the bit back into byte Array
                //

                binary[position] = x;
                result = String.Empty;
                Array.Reverse(binary);
                // Convert the byte Array into string
                //
                result = System.Text.Encoding.Default.GetString(binary, 0, binary.Length);
            }

            else //If resourceId length is greater then the token length throw an exception
            {
                throw new ArgumentOutOfRangeException("ResourceId", resourceId, "ResourceId too large");
            }
            return result;//return the access token to the caller
        }
Example #47
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwitchForm"/> class.
 /// </summary>
 /// <param name="idString">
 /// The id string.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="multi">
 /// The multi.
 /// </param>
 /// <param name="desc">
 /// The desc.
 /// </param>
 public SwitchForm(string idString, SwitchType type, bool multi, string desc)
     : this(idString, type, multi, 0, desc)
 {
 }
Example #48
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwitchForm"/> class.
 /// </summary>
 /// <param name="idString">
 /// The id string.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="multi">
 /// The multi.
 /// </param>
 /// <param name="minLen">
 /// The min len.
 /// </param>
 /// <param name="desc">
 /// The desc.
 /// </param>
 public SwitchForm(string idString, SwitchType type, bool multi, int minLen, string desc)
     : this(idString, type, multi, minLen, 0, string.Empty)
 {
     this.Description = desc;
 }
Example #49
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwitchForm"/> class.
 /// </summary>
 /// <param name="idString">
 /// The id string.
 /// </param>
 /// <param name="type">
 /// The type.
 /// </param>
 /// <param name="multi">
 /// The multi.
 /// </param>
 /// <param name="minLen">
 /// The min len.
 /// </param>
 /// <param name="maxLen">
 /// The max len.
 /// </param>
 /// <param name="postCharSet">
 /// The post char set.
 /// </param>
 public SwitchForm(string idString, SwitchType type, bool multi, int minLen, int maxLen, string postCharSet)
 {
     this.IDString = idString;
     this.Type = type;
     this.Multi = multi;
     this.MinLen = minLen;
     this.MaxLen = maxLen;
     this.PostCharSet = postCharSet;
 }
Example #50
0
 internal void SetButtonSwitchType(GuiDrumDPad dp, SwitchType type)
 {
     Debug.Assert((byte)dp % 2 == 0, "only left, up, right, down is allowed here");
     SetSelectIndex(ref m_DdlAdvSwitchStateArray[NUM_BUTTON_STATES + (byte)dp / 2], type);
 }
Example #51
0
 internal void SetButtonSwitchType(GuiDrumButton b, SwitchType type)
 {
     SetSelectIndex(ref m_DdlAdvSwitchStateArray[(byte)b], type);
 }
        void InitSwitch(VPort switchPort, SwitchType switchType, bool isColored)
        {

            logger.Log("{0} adding switch {1} {2}", this.ToString(), switchType.ToString(), switchPort.ToString());

            SwitchInfo switchInfo = new SwitchInfo();
            switchInfo.Capability = GetCapability(switchPort, Constants.UserSystem);
            switchInfo.Level = 0;
            switchInfo.Type = switchType;

            switchInfo.IsColored = isColored;
            switchInfo.Color = Color.Black;

            registeredSwitches.Add(switchPort, switchInfo);

            string switchFriendlyName = switchPort.GetInfo().GetFriendlyName();
            switchFriendlyNames.Add(switchFriendlyName, switchPort);

            if (switchInfo.Capability != null)
            {
                IList<VParamType> retVals;

                if (switchType == SwitchType.Multi)
                {
                    retVals = switchPort.Invoke(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, null,
                    ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchMultiLevel.RoleName, RoleSwitchMultiLevel.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        switchInfo.Level = (double)retVals[0].Value();
                    }
                }
                else
                {
                    retVals = switchPort.Invoke(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, null,
                    ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleSwitchBinary.RoleName, RoleSwitchBinary.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get current level for {0}", switchFriendlyName);
                    }
                    else
                    {
                        bool boolLevel = (bool)retVals[0].Value();
                        switchInfo.Level = (boolLevel) ? 1 : 0;
                    }
                }

                //fix the color up now

                if (isColored)
                {
                    var retValsColor = switchPort.Invoke(RoleLightColor.RoleName, RoleLightColor.OpGetName, null,
                                                          ControlPort, switchInfo.Capability, ControlPortCapability);

                    switchPort.Subscribe(RoleLightColor.RoleName, RoleLightColor.OpGetName, ControlPort, switchInfo.Capability, ControlPortCapability);

                    if (retVals[0].Maintype() < 0)
                    {
                        logger.Log("SwitchController could not get color for {0}", switchFriendlyName);
                    }
                    else
                    {
                        byte red, green, blue;

                        red = Math.Min(Math.Max((byte)(int)retValsColor[0].Value(), (byte)0), (byte)255);
                        green = Math.Min(Math.Max((byte)(int)retValsColor[1].Value(), (byte)0), (byte)255);
                        blue = Math.Min(Math.Max((byte)(int)retValsColor[2].Value(), (byte)0), (byte)255);

                        switchInfo.Color = Color.FromArgb(red, green, blue);
                    }
                }
            }
        }